Commit 839f8204 by Bryce McKinlay Committed by Bryce McKinlay

VMClassLoader.java (getPrimitiveClass): Now native.

	* java/lang/VMClassLoader.java (getPrimitiveClass): Now native. Now
	takes a jchar type-code argument, not a string.
	* java/lang/natClassLoader.cc (VMClassLoader::getPrimitiveClass):
	New method. Just call _Jv_FindClassFromSignature.
	* java/lang/Boolean.java (TYPE): Initialize from
	VMClassLoader.getPrimitiveClass using type-code.
	* java/lang/Character.java (TYPE): Likewise.
	* java/lang/Double.java (TYPE): Likewise.
	* java/lang/Float.java (TYPE): Likewise.
	* java/lang/Integer.java (TYPE): Likewise.
	* java/lang/Long.java (TYPE): Likewise.
	* java/lang/Short.java (TYPE): Likewise.
	* java/lang/Void.java (TYPE): Likewise.

From-SVN: r46521
parent f3a8e4f5
2001-10-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* java/lang/VMClassLoader.java (getPrimitiveClass): Now native. Now
takes a jchar type-code argument, not a string.
* java/lang/natClassLoader.cc (VMClassLoader::getPrimitiveClass):
New method. Just call _Jv_FindClassFromSignature.
* java/lang/Boolean.java (TYPE): Initialize from
VMClassLoader.getPrimitiveClass using type-code.
* java/lang/Character.java (TYPE): Likewise.
* java/lang/Double.java (TYPE): Likewise.
* java/lang/Float.java (TYPE): Likewise.
* java/lang/Integer.java (TYPE): Likewise.
* java/lang/Long.java (TYPE): Likewise.
* java/lang/Short.java (TYPE): Likewise.
* java/lang/Void.java (TYPE): Likewise.
2001-10-25 Hans Boehm <Hans_Boehm@hp.com> 2001-10-25 Hans Boehm <Hans_Boehm@hp.com>
* include/boehm-gc.h: Call thread local allocation functions * include/boehm-gc.h: Call thread local allocation functions
......
...@@ -60,7 +60,7 @@ public final class Boolean implements Serializable ...@@ -60,7 +60,7 @@ public final class Boolean implements Serializable
* The primitive type <code>boolean</code> is represented by this * The primitive type <code>boolean</code> is represented by this
* <code>Class</code> object. * <code>Class</code> object.
*/ */
public static final Class TYPE = VMClassLoader.getPrimitiveClass("boolean"); public static final Class TYPE = VMClassLoader.getPrimitiveClass('Z');
/** /**
* The immutable value of this Boolean. * The immutable value of this Boolean.
......
...@@ -33,9 +33,7 @@ public final class Character implements Serializable, Comparable ...@@ -33,9 +33,7 @@ public final class Character implements Serializable, Comparable
public static final int MIN_RADIX = 2; public static final int MIN_RADIX = 2;
public static final int MAX_RADIX = 36; public static final int MAX_RADIX = 36;
// This initialization is seemingly circular, but it is accepted public static final Class TYPE = VMClassLoader.getPrimitiveClass('C');
// by javac, and is handled specially by gcc.
public static final Class TYPE = char.class;
// Space. // Space.
public static final byte SPACE_SEPARATOR = 12; public static final byte SPACE_SEPARATOR = 12;
......
...@@ -80,7 +80,7 @@ public final class Double extends Number implements Comparable ...@@ -80,7 +80,7 @@ public final class Double extends Number implements Comparable
* The primitive type <code>double</code> is represented by this * The primitive type <code>double</code> is represented by this
* <code>Class</code> object. * <code>Class</code> object.
*/ */
public static final Class TYPE = VMClassLoader.getPrimitiveClass ("double"); public static final Class TYPE = VMClassLoader.getPrimitiveClass('D');
/** /**
* The immutable value of this Double. * The immutable value of this Double.
......
...@@ -79,7 +79,7 @@ public final class Float extends Number implements Comparable ...@@ -79,7 +79,7 @@ public final class Float extends Number implements Comparable
* The primitive type <code>float</code> is represented by this * The primitive type <code>float</code> is represented by this
* <code>Class</code> object. * <code>Class</code> object.
*/ */
public static final Class TYPE = VMClassLoader.getPrimitiveClass ("float"); public static final Class TYPE = VMClassLoader.getPrimitiveClass('F');
/** /**
* The immutable value of this Float. * The immutable value of this Float.
......
...@@ -58,7 +58,7 @@ public final class Integer extends Number implements Comparable ...@@ -58,7 +58,7 @@ public final class Integer extends Number implements Comparable
* The primitive type <code>int</code> is represented by this * The primitive type <code>int</code> is represented by this
* <code>Class</code> object. * <code>Class</code> object.
*/ */
public static final Class TYPE = VMClassLoader.getPrimitiveClass ("int"); public static final Class TYPE = VMClassLoader.getPrimitiveClass ('I');
/** /**
* The immutable value of this Integer. * The immutable value of this Integer.
......
...@@ -60,7 +60,7 @@ public final class Long extends Number implements Comparable ...@@ -60,7 +60,7 @@ public final class Long extends Number implements Comparable
* The primitive type <code>long</code> is represented by this * The primitive type <code>long</code> is represented by this
* <code>Class</code> object. * <code>Class</code> object.
*/ */
public static final Class TYPE = VMClassLoader.getPrimitiveClass ("long"); public static final Class TYPE = VMClassLoader.getPrimitiveClass ('J');
/** /**
* The immutable value of this Long. * The immutable value of this Long.
......
...@@ -56,7 +56,7 @@ public final class Short extends Number implements Comparable ...@@ -56,7 +56,7 @@ public final class Short extends Number implements Comparable
* The primitive type <code>short</code> is represented by this * The primitive type <code>short</code> is represented by this
* <code>Class</code> object. * <code>Class</code> object.
*/ */
public static final Class TYPE = VMClassLoader.getPrimitiveClass("short"); public static final Class TYPE = VMClassLoader.getPrimitiveClass('S');
/** /**
* The immutable value of this Short. * The immutable value of this Short.
......
...@@ -54,32 +54,9 @@ class VMClassLoader { ...@@ -54,32 +54,9 @@ class VMClassLoader {
/** /**
* Helper for java.lang.Integer, Byte, etc. to get the TYPE class * Helper for java.lang.Integer, Byte, etc. to get the TYPE class
* at initialization time. If there are multiple classloaders, this * at initialization time.
* method may be called once per ClassLoader per type.
* *
* @param type name of the primitive type; i.e. "int", "byte", etc. * @param type code for the primitive type.
* @return a "bogus" class representing the primitive type.
*/ */
static final Class getPrimitiveClass(String type) static native Class getPrimitiveClass(char type);
{
if ("int".equals (type))
return int.class;
else if ("long".equals (type))
return long.class;
else if ("boolean".equals (type))
return boolean.class;
else if ("short".equals (type))
return short.class;
else if ("char".equals (type))
return char.class;
else if ("byte".equals (type))
return byte.class;
else if ("float".equals (type))
return float.class;
else if ("double".equals (type))
return double.class;
else if ("void".equals (type))
return void.class;
return null;
}
} }
...@@ -47,7 +47,7 @@ public final class Void ...@@ -47,7 +47,7 @@ public final class Void
* The return type <code>void</code> is represented by this * The return type <code>void</code> is represented by this
* <code>Class</code> object. * <code>Class</code> object.
*/ */
public static final Class TYPE = VMClassLoader.getPrimitiveClass("void"); public static final Class TYPE = VMClassLoader.getPrimitiveClass('V');
/** /**
* Don't allow Void objects to be made. * Don't allow Void objects to be made.
......
...@@ -35,6 +35,7 @@ details. */ ...@@ -35,6 +35,7 @@ details. */
#include <java/lang/ClassCircularityError.h> #include <java/lang/ClassCircularityError.h>
#include <java/lang/IncompatibleClassChangeError.h> #include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/VirtualMachineError.h> #include <java/lang/VirtualMachineError.h>
#include <java/lang/VMClassLoader.h>
#include <java/lang/reflect/Modifier.h> #include <java/lang/reflect/Modifier.h>
#include <java/lang/Runtime.h> #include <java/lang/Runtime.h>
#include <java/lang/StringBuffer.h> #include <java/lang/StringBuffer.h>
...@@ -176,6 +177,15 @@ java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass) ...@@ -176,6 +177,15 @@ java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
klass->notifyAll (); klass->notifyAll ();
} }
jclass
java::lang::VMClassLoader::getPrimitiveClass (jchar type)
{
char sig[2];
sig[0] = (char) type;
sig[1] = '\0';
return _Jv_FindClassFromSignature (sig, NULL);
}
// This is the findClass() implementation for the System classloader. It is // This is the findClass() implementation for the System classloader. It is
// the only native method in VMClassLoader, so we define it here. // the only native method in VMClassLoader, so we define it here.
jclass jclass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment