From 89d4b110502e3062d19d0dc20ef75de3e785c681 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 11 Nov 2001 16:07:09 +0000 Subject: * doc/vmintegration.texinfo: Add gcj, kissme and small explanation of VMObject, VMClassLoader, VMSystem and VMSecurityManager * java/lang/Boolean.java (TYPE): VMClassLoader.getPrimitiveClass(char) * java/lang/Byte.java (TYPE): Likewise * 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 * vm/reference/java/lang/VMClassLoader.java (getPrimitiveClass(char)): new method --- vm/reference/java/lang/VMClassLoader.java | 81 ++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 8 deletions(-) (limited to 'vm') 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. + * + * + * Note that this is currently a java version that converts the type code + * to a string and calls the native getPrimitiveClass(String) + * method for backwards compatibility with VMs that used old versions of + * GNU Classpath. Please replace this method with a native method + * final static native Class getPrimitiveClass(char type); + * if your VM supports it. The java version of this method and + * the String version of this method will disappear in a future version + * of GNU Classpath. + * + * @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. + * This method will be removed in a future version of GNU + * Classpath. + */ + final static native Class getPrimitiveClass(String type); } -- cgit v1.2.1