summaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
Diffstat (limited to 'vm')
-rw-r--r--vm/reference/java/lang/VMClassLoader.java81
1 files changed, 73 insertions, 8 deletions
diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java
index 144e15980..8bac0456f 100644
--- a/vm/reference/java/lang/VMClassLoader.java
+++ b/vm/reference/java/lang/VMClassLoader.java
@@ -1,6 +1,6 @@
/*
* java.lang.ClassLoader: part of the Java Class Libraries project.
- * Copyright (C) 1998 Free Software Foundation
+ * Copyright (C) 1998, 2001 Free Software Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,7 +25,7 @@ package java.lang;
* on behalf of java.lang.ClassLoader.
*
* @author John Keiser
- * @version 1.1.0, Sep 22 1998
+ * @author Mark Wielaard (mark@klomp.org)
* @since CP1.1
*/
@@ -39,7 +39,8 @@ class VMClassLoader {
* @param offset the offset into the data where the classfile starts.
* @param len the length of the classfile data in the array.
* @return the class that was defined.
- * @exception ClassFormatError if the byte array is not in proper classfile format.
+ * @exception ClassFormatError if the byte array is not in proper
+ * classfile format.
*/
final static native Class defineClass(ClassLoader cl, String name,
byte[] data, int offset, int len) throws ClassFormatError;
@@ -51,13 +52,77 @@ class VMClassLoader {
final static native void resolveClass(Class c);
/**
- * Helper for java.lang.Integer, Byte, etc. to get the TYPE class
- * at initialization time. If there are multiple classloaders, this
- * method may be called once per ClassLoader per type.
+ * Helper for java.lang.Integer, Byte, etc to get the TYPE class
+ * at initialization time. The type code is one of the chars that
+ * represents the primitive type as in JNI.
*
- * @param type name of the primitive type; i.e. "int", "byte", etc.
+ * <ul>
+ * <li>'Z' - boolean</li>
+ * <li>'B' - byte</li>
+ * <li>'C' - char</li>
+ * <li>'D' - double</li>
+ * <li>'F' - float</li>
+ * <li>'I' - int</li>
+ * <li>'J' - long</li>
+ * <li>'S' - short</li>
+ * <li>'V' - void</li>
+ * </ul>
+ *
+ * Note that this is currently a java version that converts the type code
+ * to a string and calls the native <code>getPrimitiveClass(String)</code>
+ * method for backwards compatibility with VMs that used old versions of
+ * GNU Classpath. Please replace this method with a native method
+ * <code>final static native Class getPrimitiveClass(char type);</code>
+ * if your VM supports it. <strong>The java version of this method and
+ * the String version of this method will disappear in a future version
+ * of GNU Classpath</strong>.
+ *
+ * @param type the primitive type
* @return a "bogus" class representing the primitive type.
*/
- final static native Class getPrimitiveClass(String type);
+ final static Class getPrimitiveClass(char type)
+ {
+ String t;
+ switch (type) {
+ case 'Z':
+ t = "boolean";
+ break;
+ case 'B':
+ t = "byte";
+ break;
+ case 'C':
+ t = "char";
+ break;
+ case 'D':
+ t = "double";
+ break;
+ case 'F':
+ t = "float";
+ break;
+ case 'I':
+ t = "int";
+ break;
+ case 'J':
+ t = "long";
+ break;
+ case 'S':
+ t = "short";
+ break;
+ case 'V':
+ t = "void";
+ break;
+ default:
+ throw new NoClassDefFoundError("Invalid type specifier: " + type);
+ }
+ return getPrimitiveClass(t);
+ }
+ /**
+ * Old version of the interface, added here for backwards compatibility.
+ * Called by the java version of getPrimitiveClass(char) when no native
+ * version of that method is available.
+ * <strong>This method will be removed in a future version of GNU
+ * Classpath</strong>.
+ */
+ final static native Class getPrimitiveClass(String type);
}