Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore.
       * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant.
       * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5.
       * java/lang/Math.java: New override file.
       * java/lang/Character.java: Merged from Classpath.
       (start, end): Now 'int's.
       (canonicalName): New field.
       (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants.
       (UnicodeBlock): Added argument.
       (of): New overload.
       (forName): New method.
       Updated unicode blocks.
       (sets): Updated.
       * sources.am: Regenerated.
       * Makefile.in: Likewise.

From-SVN: r111942
This commit is contained in:
Mark Wielaard
2006-03-10 21:46:48 +00:00
parent 27079765d0
commit 8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
File diff suppressed because it is too large Load Diff
@@ -70,7 +70,7 @@ public class ClassNotFoundException extends Exception
*/
public ClassNotFoundException()
{
this(null, null);
this(null);
}
/**
@@ -81,7 +81,8 @@ public class ClassNotFoundException extends Exception
*/
public ClassNotFoundException(String s)
{
this(s, null);
super(s);
ex = null;
}
/**
+327 -26
View File
@@ -1,5 +1,5 @@
/* java.lang.Math -- common mathematical functions, native allowed
Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
/* java.lang.Math -- common mathematical functions, native allowed (VMMath)
Copyright (C) 1998, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,10 +52,26 @@ import java.util.Random;
* @author Paul Fisher
* @author John Keiser
* @author Eric Blake (ebb9@email.byu.edu)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.0
*/
public final class Math
{
// FIXME - This is here because we need to load the "javalang" system
// library somewhere late in the bootstrap cycle. We cannot do this
// from VMSystem or VMRuntime since those are used to actually load
// the library. This is mainly here because historically Math was
// late enough in the bootstrap cycle to start using System after it
// was initialized (called from the java.util classes).
static
{
if (Configuration.INIT_LOAD_LIBRARY)
{
System.loadLibrary("javalang");
}
}
/**
* Math is non-instantiable
*/
@@ -63,14 +79,6 @@ public final class Math
{
}
static
{
if (Configuration.INIT_LOAD_LIBRARY)
{
System.loadLibrary("javalang");
}
}
/**
* A random number generator, initialized on first use.
*/
@@ -298,7 +306,10 @@ public final class Math
* @param a the angle (in radians)
* @return sin(a)
*/
public static native double sin(double a);
public static double sin(double a)
{
return VMMath.sin(a);
}
/**
* The trigonometric function <em>cos</em>. The cosine of NaN or infinity is
@@ -307,7 +318,10 @@ public final class Math
* @param a the angle (in radians)
* @return cos(a)
*/
public static native double cos(double a);
public static double cos(double a)
{
return VMMath.cos(a);
}
/**
* The trigonometric function <em>tan</em>. The tangent of NaN or infinity
@@ -317,7 +331,10 @@ public final class Math
* @param a the angle (in radians)
* @return tan(a)
*/
public static native double tan(double a);
public static double tan(double a)
{
return VMMath.tan(a);
}
/**
* The trigonometric function <em>arcsin</em>. The range of angles returned
@@ -328,7 +345,10 @@ public final class Math
* @param a the sin to turn back into an angle
* @return arcsin(a)
*/
public static native double asin(double a);
public static double asin(double a)
{
return VMMath.asin(a);
}
/**
* The trigonometric function <em>arccos</em>. The range of angles returned
@@ -339,7 +359,10 @@ public final class Math
* @param a the cos to turn back into an angle
* @return arccos(a)
*/
public static native double acos(double a);
public static double acos(double a)
{
return VMMath.acos(a);
}
/**
* The trigonometric function <em>arcsin</em>. The range of angles returned
@@ -351,7 +374,10 @@ public final class Math
* @return arcsin(a)
* @see #atan2(double, double)
*/
public static native double atan(double a);
public static double atan(double a)
{
return VMMath.atan(a);
}
/**
* A special version of the trigonometric function <em>arctan</em>, for
@@ -400,7 +426,10 @@ public final class Math
* @return <em>theta</em> in the conversion of (x, y) to (r, theta)
* @see #atan(double)
*/
public static native double atan2(double y, double x);
public static double atan2(double y, double x)
{
return VMMath.atan2(y,x);
}
/**
* Take <em>e</em><sup>a</sup>. The opposite of <code>log()</code>. If the
@@ -414,7 +443,10 @@ public final class Math
* @see #log(double)
* @see #pow(double, double)
*/
public static native double exp(double a);
public static double exp(double a)
{
return VMMath.exp(a);
}
/**
* Take ln(a) (the natural log). The opposite of <code>exp()</code>. If the
@@ -430,7 +462,10 @@ public final class Math
* @return the natural log of <code>a</code>
* @see #exp(double)
*/
public static native double log(double a);
public static double log(double a)
{
return VMMath.log(a);
}
/**
* Take a square root. If the argument is NaN or negative, the result is
@@ -438,13 +473,18 @@ public final class Math
* infinity; and if the result is either zero, the result is the same.
* This is accurate within the limits of doubles.
*
* <p>For other roots, use pow(a, 1 / rootNumber).
* <p>For a cube root, use <code>cbrt</code>. For other roots, use
* <code>pow(a, 1 / rootNumber)</code>.</p>
*
* @param a the numeric argument
* @return the square root of the argument
* @see #cbrt(double)
* @see #pow(double, double)
*/
public static native double sqrt(double a);
public static double sqrt(double a)
{
return VMMath.sqrt(a);
}
/**
* Raise a number to a power. Special cases:<ul>
@@ -514,7 +554,10 @@ public final class Math
* @param b the power to raise it to
* @return a<sup>b</sup>
*/
public static native double pow(double a, double b);
public static double pow(double a, double b)
{
return VMMath.pow(a,b);
}
/**
* Get the IEEE 754 floating point remainder on two numbers. This is the
@@ -530,7 +573,10 @@ public final class Math
* @return the IEEE 754-defined floating point remainder of x/y
* @see #rint(double)
*/
public static native double IEEEremainder(double x, double y);
public static double IEEEremainder(double x, double y)
{
return VMMath.IEEEremainder(x,y);
}
/**
* Take the nearest integer that is that is greater than or equal to the
@@ -541,7 +587,10 @@ public final class Math
* @param a the value to act upon
* @return the nearest integer &gt;= <code>a</code>
*/
public static native double ceil(double a);
public static double ceil(double a)
{
return VMMath.ceil(a);
}
/**
* Take the nearest integer that is that is less than or equal to the
@@ -551,7 +600,10 @@ public final class Math
* @param a the value to act upon
* @return the nearest integer &lt;= <code>a</code>
*/
public static native double floor(double a);
public static double floor(double a)
{
return VMMath.floor(a);
}
/**
* Take the nearest integer to the argument. If it is exactly between
@@ -561,7 +613,10 @@ public final class Math
* @param a the value to act upon
* @return the nearest integer to <code>a</code>
*/
public static native double rint(double a);
public static double rint(double a)
{
return VMMath.rint(a);
}
/**
* Take the nearest integer to the argument. This is equivalent to
@@ -647,4 +702,250 @@ public final class Math
{
return (rads * 180) / PI;
}
/**
* <p>
* Take a cube root. If the argument is <code>NaN</code>, an infinity or
* zero, then the original value is returned. The returned result is
* within 1 ulp of the exact result. For a finite value, <code>x</code>,
* the cube root of <code>-x</code> is equal to the negation of the cube root
* of <code>x</code>.
* </p>
* <p>
* For a square root, use <code>sqrt</code>. For other roots, use
* <code>pow(a, 1 / rootNumber)</code>.
* </p>
*
* @param a the numeric argument
* @return the cube root of the argument
* @see #sqrt(double)
* @see #pow(double, double)
* @since 1.5
*/
public static double cbrt(double a)
{
return VMMath.cbrt(a);
}
/**
* <p>
* Returns the hyperbolic cosine of the given value. For a value,
* <code>x</code>, the hyperbolic cosine is <code>(e<sup>x</sup> +
* e<sup>-x</sup>)/2</code>
* with <code>e</code> being <a href="#E">Euler's number</a>. The returned
* result is within 2.5 ulps of the exact result.
* </p>
* <p>
* If the supplied value is <code>NaN</code>, then the original value is
* returned. For either infinity, positive infinity is returned.
* The hyperbolic cosine of zero is 1.0.
* </p>
*
* @param a the numeric argument
* @return the hyperbolic cosine of <code>a</code>.
* @since 1.5
*/
public static double cosh(double a)
{
return VMMath.cosh(a);
}
/**
* <p>
* Returns <code>e<sup>a</sup> - 1. For values close to 0, the
* result of <code>expm1(a) + 1</code> tend to be much closer to the
* exact result than simply <code>exp(x)</code>. The result is within
* 1 ulp of the exact result, and results are semi-monotonic. For finite
* inputs, the returned value is greater than or equal to -1.0. Once
* a result enters within half a ulp of this limit, the limit is returned.
* </p>
* <p>
* For <code>NaN</code>, positive infinity and zero, the original value
* is returned. Negative infinity returns a result of -1.0 (the limit).
* </p>
*
* @param a the numeric argument
* @return <code>e<sup>a</sup> - 1</code>
* @since 1.5
*/
public static double expm1(double a)
{
return VMMath.expm1(a);
}
/**
* <p>
* Returns the hypotenuse, <code>a<sup>2</sup> + b<sup>2</sup></code>,
* without intermediate overflow or underflow. The returned result is
* within 1 ulp of the exact result. If one parameter is held constant,
* then the result in the other parameter is semi-monotonic.
* </p>
* <p>
* If either of the arguments is an infinity, then the returned result
* is positive infinity. Otherwise, if either argument is <code>NaN</code>,
* then <code>NaN</code> is returned.
* </p>
*
* @param a the first parameter.
* @param b the second parameter.
* @return the hypotenuse matching the supplied parameters.
* @since 1.5
*/
public static double hypot(double a, double b)
{
return VMMath.hypot(a,b);
}
/**
* <p>
* Returns the base 10 logarithm of the supplied value. The returned
* result is within 1 ulp of the exact result, and the results are
* semi-monotonic.
* </p>
* <p>
* Arguments of either <code>NaN</code> or less than zero return
* <code>NaN</code>. An argument of positive infinity returns positive
* infinity. Negative infinity is returned if either positive or negative
* zero is supplied. Where the argument is the result of
* <code>10<sup>n</sup</code>, then <code>n</code> is returned.
* </p>
*
* @param a the numeric argument.
* @return the base 10 logarithm of <code>a</code>.
* @since 1.5
*/
public static double log10(double a)
{
return VMMath.log10(a);
}
/**
* <p>
* Returns the natural logarithm resulting from the sum of the argument,
* <code>a</code> and 1. For values close to 0, the
* result of <code>log1p(a)</code> tend to be much closer to the
* exact result than simply <code>log(1.0+a)</code>. The returned
* result is within 1 ulp of the exact result, and the results are
* semi-monotonic.
* </p>
* <p>
* Arguments of either <code>NaN</code> or less than -1 return
* <code>NaN</code>. An argument of positive infinity or zero
* returns the original argument. Negative infinity is returned from an
* argument of -1.
* </p>
*
* @param a the numeric argument.
* @return the natural logarithm of <code>a</code> + 1.
* @since 1.5
*/
public static double log1p(double a)
{
return VMMath.log1p(a);
}
/**
* <p>
* Returns the sign of the argument as follows:
* </p>
* <ul>
* <li>If <code>a</code> is greater than zero, the result is 1.0.</li>
* <li>If <code>a</code> is less than zero, the result is -1.0.</li>
* <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
* <li>If <code>a</code> is positive or negative zero, the result is the
* same.</li>
* </ul>
*
* @param a the numeric argument.
* @return the sign of the argument.
* @since 1.5.
*/
public static double signum(double a)
{
if (Double.isNaN(a))
return Double.NaN;
if (a > 0)
return 1.0;
if (a < 0)
return -1.0;
return a;
}
/**
* <p>
* Returns the sign of the argument as follows:
* </p>
* <ul>
* <li>If <code>a</code> is greater than zero, the result is 1.0f.</li>
* <li>If <code>a</code> is less than zero, the result is -1.0f.</li>
* <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
* <li>If <code>a</code> is positive or negative zero, the result is the
* same.</li>
* </ul>
*
* @param a the numeric argument.
* @return the sign of the argument.
* @since 1.5.
*/
public static float signum(float a)
{
if (Float.isNaN(a))
return Float.NaN;
if (a > 0)
return 1.0f;
if (a < 0)
return -1.0f;
return a;
}
/**
* <p>
* Returns the hyperbolic sine of the given value. For a value,
* <code>x</code>, the hyperbolic sine is <code>(e<sup>x</sup> -
* e<sup>-x</sup>)/2</code>
* with <code>e</code> being <a href="#E">Euler's number</a>. The returned
* result is within 2.5 ulps of the exact result.
* </p>
* <p>
* If the supplied value is <code>NaN</code>, an infinity or a zero, then the
* original value is returned.
* </p>
*
* @param a the numeric argument
* @return the hyperbolic sine of <code>a</code>.
* @since 1.5
*/
public static double sinh(double a)
{
return VMMath.sinh(a);
}
/**
* <p>
* Returns the hyperbolic tangent of the given value. For a value,
* <code>x</code>, the hyperbolic tangent is <code>(e<sup>x</sup> -
* e<sup>-x</sup>)/(e<sup>x</sup> + e<sup>-x</sup>)</code>
* (i.e. <code>sinh(a)/cosh(a)</code>)
* with <code>e</code> being <a href="#E">Euler's number</a>. The returned
* result is within 2.5 ulps of the exact result. The absolute value
* of the exact result is always less than 1. Computed results are thus
* less than or equal to 1 for finite arguments, with results within
* half a ulp of either positive or negative 1 returning the appropriate
* limit value (i.e. as if the argument was an infinity).
* </p>
* <p>
* If the supplied value is <code>NaN</code> or zero, then the original
* value is returned. Positive infinity returns +1.0 and negative infinity
* returns -1.0.
* </p>
*
* @param a the numeric argument
* @return the hyperbolic tangent of <code>a</code>.
* @since 1.5
*/
public static double tanh(double a)
{
return VMMath.tanh(a);
}
}
+69 -1
View File
@@ -554,6 +554,49 @@ public final class String implements Serializable, Comparable, CharSequence
this.count = count;
}
/**
* Creates a new String containing the characters represented in the
* given subarray of Unicode code points.
* @param codePoints the entire array of code points
* @param offset the start of the subarray
* @param count the length of the subarray
*
* @throws IllegalArgumentException if an invalid code point is found
* in the codePoints array
* @throws IndexOutOfBoundsException if offset is negative or offset + count
* is greater than the length of the array.
*/
public String(int[] codePoints, int offset, int count)
{
// FIXME: This implementation appears to give correct internal
// representation of the String because:
// - length() is correct
// - getting a char[] from toCharArray() and testing
// Character.codePointAt() on all the characters in that array gives
// the appropriate results
// however printing the String gives incorrect results. This may be
// due to printing method errors (such as incorrectly looping through
// the String one char at a time rather than one "character" at a time.
if (offset < 0)
throw new IndexOutOfBoundsException();
int end = offset + count;
int pos = 0;
// This creates a char array that is long enough for all of the code
// points to represent supplementary characters. This is more than likely
// a waste of storage, so we use it only temporarily and then copy the
// used portion into the value array.
char[] temp = new char[2 * codePoints.length];
for (int i = offset; i < end; i++)
{
pos += Character.toChars(codePoints[i], temp, pos);
}
this.count = pos;
this.value = new char[pos];
System.arraycopy(temp, 0, value, 0, pos);
this.offset = 0;
}
/**
* Returns the number of characters contained in this String.
*
@@ -1822,7 +1865,7 @@ public final class String implements Serializable, Comparable, CharSequence
*/
private static int upperCaseExpansion(char ch)
{
return Character.direction[Character.readChar(ch) >> 7] & 3;
return Character.direction[0][Character.readCodePoint((int)ch) >> 7] & 3;
}
/**
@@ -1918,4 +1961,29 @@ public final class String implements Serializable, Comparable, CharSequence
}
return result.toString();
}
/**
* Return the index into this String that is offset from the given index by
* <code>codePointOffset</code> code points.
* @param index the index at which to start
* @param codePointOffset the number of code points to offset
* @return the index into this String that is <code>codePointOffset</code>
* code points offset from <code>index</code>.
*
* @throws IndexOutOfBoundsException if index is negative or larger than the
* length of this string.
* @throws IndexOutOfBoundsException if codePointOffset is positive and the
* substring starting with index has fewer than codePointOffset code points.
* @throws IndexOutOfBoundsException if codePointOffset is negative and the
* substring ending with index has fewer than (-codePointOffset) code points.
* @since 1.5
*/
public int offsetByCodePoints(int index, int codePointOffset)
{
if (index < 0 || index > count)
throw new IndexOutOfBoundsException();
return Character.offsetByCodePoints(value, offset, count, offset + index,
codePointOffset);
}
}
@@ -1006,4 +1006,65 @@ public final class StringBuilder
return false;
return true;
}
/**
* Get the code point at the specified index. This is like #charAt(int),
* but if the character is the start of a surrogate pair, and the
* following character completes the pair, then the corresponding
* supplementary code point is returned.
* @param index the index of the codepoint to get, starting at 0
* @return the codepoint at the specified index
* @throws IndexOutOfBoundsException if index is negative or &gt;= length()
* @since 1.5
*/
public int codePointAt(int index)
{
return Character.codePointAt(value, index, count);
}
/**
* Get the code point before the specified index. This is like
* #codePointAt(int), but checks the characters at <code>index-1</code> and
* <code>index-2</code> to see if they form a supplementary code point.
* @param index the index just past the codepoint to get, starting at 0
* @return the codepoint at the specified index
* @throws IndexOutOfBoundsException if index is negative or &gt;= length()
* @since 1.5
*/
public int codePointBefore(int index)
{
// Character.codePointBefore() doesn't perform this check. We
// could use the CharSequence overload, but this is just as easy.
if (index >= count)
throw new IndexOutOfBoundsException();
return Character.codePointBefore(value, index, 1);
}
/**
* Returns the number of Unicode code points in the specified sub sequence.
* Surrogate pairs count as one code point.
* @param beginIndex the start of the subarray
* @param endIndex the index after the last char in the subarray
* @return the number of code points
* @throws IndexOutOfBoundsException if beginIndex is less than zero or
* greater than endIndex or if endIndex is greater than the length of this
* StringBuilder
*/
public int codePointCount(int beginIndex,int endIndex)
{
if (beginIndex < 0 || beginIndex > endIndex || endIndex > count)
throw new IndexOutOfBoundsException("invalid indices: " + beginIndex
+ ", " + endIndex);
return Character.codePointCount(value, beginIndex, endIndex - beginIndex);
}
public void trimToSize()
{
if (count < value.length)
{
char[] newValue = new char[count];
System.arraycopy(value, 0, newValue, 0, count);
value = newValue;
}
}
}
+17
View File
@@ -178,6 +178,23 @@ public final class System
if (SecurityManager.current != null)
SecurityManager.current.checkPermission
(new RuntimePermission("setSecurityManager"));
// java.security.Security's class initialiser loads and parses the
// policy files. If it hasn't been run already it will be run
// during the first permission check. That initialisation will
// fail if a very restrictive security manager is in force, so we
// preload it here.
if (SecurityManager.current == null)
{
try
{
Class.forName("java.security.Security");
}
catch (ClassNotFoundException e)
{
}
}
SecurityManager.current = sm;
}
+1 -1
View File
@@ -906,7 +906,7 @@ public class Thread implements Runnable
if (sm != null)
{
sm.checkAccess(this);
if (this != currentThread())
if (this != currentThread() || !(t instanceof ThreadDeath))
sm.checkPermission(new RuntimePermission("stopThread"));
}
VMThread vt = vmThread;
+43 -1
View File
@@ -1,5 +1,5 @@
/* Proxy.java -- build a proxy class that implements reflected interfaces
Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,6 +42,7 @@ import gnu.java.lang.reflect.TypeSignature;
import java.io.Serializable;
import java.security.ProtectionDomain;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -732,6 +733,12 @@ public class Proxy implements Serializable
int j = methods.length;
while (--j >= 0)
{
if (isCoreObjectMethod(methods[j]))
{
// In the case of an attempt to redefine a public non-final
// method of Object, we must skip it
continue;
}
ProxySignature sig = new ProxySignature(methods[j]);
ProxySignature old = (ProxySignature) method_set.put(sig, sig);
if (old != null)
@@ -752,6 +759,41 @@ public class Proxy implements Serializable
}
return data;
}
/**
* Checks whether the method is similar to a public non-final method of
* Object or not (i.e. with the same name and parameter types). Note that we
* can't rely, directly or indirectly (via Collection.contains) on
* Method.equals as it would also check the declaring class, what we do not
* want. We only want to check that the given method have the same signature
* as a core method (same name and parameter types)
*
* @param method the method to check
* @return whether the method has the same name and parameter types as
* Object.equals, Object.hashCode or Object.toString
* @see java.lang.Object#equals(Object)
* @see java.lang.Object#hashCode()
* @see java.lang.Object#toString()
*/
private static boolean isCoreObjectMethod(Method method)
{
String methodName = method.getName();
if (methodName.equals("equals"))
{
return Arrays.equals(method.getParameterTypes(),
new Class[] { Object.class });
}
if (methodName.equals("hashCode"))
{
return method.getParameterTypes().length == 0;
}
if (methodName.equals("toString"))
{
return method.getParameterTypes().length == 0;
}
return false;
}
} // class ProxyData
/**