66 |
/** |
/** |
67 |
* Helper to define a class using a string of bytes. This assumes that |
* Helper to define a class using a string of bytes. This assumes that |
68 |
* the security checks have already been performed, if necessary. |
* the security checks have already been performed, if necessary. |
|
* <strong>This method will be removed in a future version of GNU |
|
|
* Classpath</strong>. |
|
|
* |
|
|
* @param name the name to give the class, or null if unknown |
|
|
* @param data the data representing the classfile, in classfile format |
|
|
* @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 |
|
|
* @throws ClassFormatError if data is not in proper classfile format |
|
|
* @deprecated Implement |
|
|
* {@link #defineClass(ClassLoader, String, byte[], int, int, ProtectionDomain)} |
|
|
* instead. |
|
|
*/ |
|
|
static final native Class defineClass(ClassLoader cl, String name, |
|
|
byte[] data, int offset, int len) |
|
|
throws ClassFormatError; |
|
|
|
|
|
/** |
|
|
* Helper to define a class using a string of bytes. This assumes that |
|
|
* the security checks have already been performed, if necessary. |
|
|
* |
|
|
* <strong>For backward compatibility, this just ignores the protection |
|
|
* domain; that is the wrong behavior, and you should directly implement |
|
|
* this method natively if you can.</strong> |
|
69 |
* |
* |
70 |
* Implementations of this method are advised to consider the |
* Implementations of this method are advised to consider the |
71 |
* situation where user code modifies the byte array after it has |
* situation where user code modifies the byte array after it has |
81 |
* @return the class that was defined |
* @return the class that was defined |
82 |
* @throws ClassFormatError if data is not in proper classfile format |
* @throws ClassFormatError if data is not in proper classfile format |
83 |
*/ |
*/ |
84 |
static final Class defineClass(ClassLoader cl, String name, |
static final native Class defineClass(ClassLoader cl, String name, |
85 |
byte[] data, int offset, int len, |
byte[] data, int offset, int len, |
86 |
ProtectionDomain pd) |
ProtectionDomain pd) |
87 |
throws ClassFormatError |
throws ClassFormatError; |
|
{ |
|
|
return defineClass(cl, name, data, offset, len); |
|
|
} |
|
88 |
|
|
89 |
/** |
/** |
90 |
* Helper to resolve all references to other classes from this class. |
* Helper to resolve all references to other classes from this class. |
96 |
/** |
/** |
97 |
* Helper to load a class from the bootstrap class loader. |
* Helper to load a class from the bootstrap class loader. |
98 |
* |
* |
|
* XXX - Not implemented; this requires native help. |
|
|
* |
|
99 |
* @param name the class name to load |
* @param name the class name to load |
100 |
* @param resolve whether to resolve it |
* @param resolve whether to resolve it |
101 |
* @return the class, loaded by the bootstrap classloader or null |
* @return the class, loaded by the bootstrap classloader or null |
102 |
* if the class wasn't found. Returning null is equivalent to throwing |
* if the class wasn't found. Returning null is equivalent to throwing |
103 |
* a ClassNotFoundException (but a possible performance optimization). |
* a ClassNotFoundException (but a possible performance optimization). |
104 |
*/ |
*/ |
105 |
static final Class loadClass(String name, boolean resolve) |
static final native Class loadClass(String name, boolean resolve) |
106 |
throws ClassNotFoundException |
throws ClassNotFoundException; |
|
{ |
|
|
return null; |
|
|
} |
|
107 |
|
|
108 |
/** |
/** |
109 |
* Helper to load a resource from the bootstrap class loader. |
* Helper to load a resource from the bootstrap class loader. |
230 |
* <li>'V' - void</li> |
* <li>'V' - void</li> |
231 |
* </ul> |
* </ul> |
232 |
* |
* |
|
* 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 |
|
|
*/ |
|
|
static final 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>. |
|
233 |
* @param type the primitive type |
* @param type the primitive type |
234 |
* @return a "bogus" class representing the primitive type |
* @return a "bogus" class representing the primitive type |
235 |
*/ |
*/ |
236 |
static final native Class getPrimitiveClass(String type); |
static final native Class getPrimitiveClass(char type); |
237 |
|
|
238 |
/** |
/** |
239 |
* The system default for assertion status. This is used for all system |
* The system default for assertion status. This is used for all system |