38 |
package java.lang; |
package java.lang; |
39 |
|
|
40 |
import java.io.Serializable; |
import java.io.Serializable; |
41 |
|
import java.io.InputStream; |
42 |
import java.lang.reflect.*; |
import java.lang.reflect.*; |
43 |
import java.security.*; |
import java.security.*; |
44 |
import java.net.URL; |
import java.net.URL; |
118 |
*/ |
*/ |
119 |
public String toString() |
public String toString() |
120 |
{ |
{ |
121 |
//XXX Fix for primitive types. |
if (isPrimitive()) |
122 |
|
return getName(); |
123 |
return (isInterface() ? "interface " : "class ") + getName(); |
return (isInterface() ? "interface " : "class ") + getName(); |
124 |
} |
} |
125 |
|
|
136 |
* @throws ExceptionInInitializerError if the class loads, but an exception |
* @throws ExceptionInInitializerError if the class loads, but an exception |
137 |
* occurs during initialization |
* occurs during initialization |
138 |
*/ |
*/ |
139 |
//XXX This does not need to be native. |
public static Class forName(String name) throws ClassNotFoundException |
|
public static native Class forName(String name) |
|
|
throws ClassNotFoundException; |
|
|
/* |
|
140 |
{ |
{ |
141 |
return forName(name, true, |
return forName(name, true, |
142 |
VMSecurityManager.getClassContext()[1].getClassLoader()); |
VMSecurityManager.getClassContext()[1].getClassLoader()); |
143 |
} |
} |
|
*/ |
|
144 |
|
|
145 |
/** |
/** |
146 |
* Use the specified classloader to load and link a class. If the loader |
* Use the specified classloader to load and link a class. If the loader |
209 |
{ |
{ |
210 |
try |
try |
211 |
{ |
{ |
212 |
//XXX What about getConstructor(null).newInstance(null)? |
return getConstructor(null).newInstance(null); |
|
return getConstructor(new Class[0]).newInstance(new Object[0]); |
|
|
} |
|
|
catch(SecurityException e) |
|
|
{ |
|
|
//XXX Why is this trapped? |
|
|
throw new IllegalAccessException("Cannot access no-arg constructor"); |
|
213 |
} |
} |
214 |
catch(IllegalArgumentException e) |
catch(IllegalArgumentException e) |
215 |
{ |
{ |
216 |
throw new UnknownError("IllegalArgumentException thrown from Constructor.newInstance(). Something is rotten in Denmark."); |
throw (Error) new InternalError("Should not happen").initCause(e); |
217 |
} |
} |
218 |
catch(InvocationTargetException e) |
catch(InvocationTargetException e) |
219 |
{ |
{ |
220 |
//XXX Chain this. |
throw (InstantiationException) |
221 |
throw new InstantiationException("Target threw an exception."); |
new InstantiationException(e.toString()).initCause(e); |
222 |
} |
} |
223 |
catch(NoSuchMethodException e) |
catch(NoSuchMethodException e) |
224 |
{ |
{ |
225 |
//XXX Chain this. |
throw (InstantiationException) |
226 |
throw new InstantiationException("Method not found"); |
new InstantiationException(e.toString()).initCause(e); |
227 |
} |
} |
228 |
} |
} |
229 |
|
|
379 |
if(isArray()) |
if(isArray()) |
380 |
try |
try |
381 |
{ |
{ |
382 |
//XXX This should not initialize the component type. |
return Class.forName(getName().substring(1), false, |
383 |
return Class.forName(getName().substring(1)); |
getClassLoader()); |
384 |
} |
} |
385 |
catch(ClassNotFoundException e) |
catch(ClassNotFoundException e) |
386 |
{ |
{ |
764 |
* @see ClassLoader#setPackageAssertionStatus(String, boolean) |
* @see ClassLoader#setPackageAssertionStatus(String, boolean) |
765 |
* @see ClassLoader#setDefaultAssertionStatus(boolean) |
* @see ClassLoader#setDefaultAssertionStatus(boolean) |
766 |
* @since 1.4 |
* @since 1.4 |
767 |
* @XXX For 1.4 compliance, implement this method. |
*/ |
768 |
public boolean desiredAssertionStatus() |
public boolean desiredAssertionStatus() |
769 |
{ |
{ |
770 |
ClassLoader c = getClassLoader(); |
ClassLoader c = getClassLoader(); |
817 |
} |
} |
818 |
return c.defaultAssertionStatus; |
return c.defaultAssertionStatus; |
819 |
} |
} |
|
*/ |
|
820 |
} |
} |
821 |
|
|