Commit f69bc497 by Tom Tromey Committed by Tom Tromey

ClassLoader.java (loadedClasses): New field.

	* java/lang/ClassLoader.java (loadedClasses): New field.
	(defineClass): Fixed indentation.  Put new class in
	loadedClasses.
	(findLoadedClass): Implement here.
	* java/lang/natClassLoader.cc (findLoadedClass): Removed.

From-SVN: r60043
parent 70a72ca4
2002-12-11 Tom Tromey <tromey@redhat.com>
* java/lang/ClassLoader.java (loadedClasses): New field.
(defineClass): Fixed indentation. Put new class in
loadedClasses.
(findLoadedClass): Implement here.
* java/lang/natClassLoader.cc (findLoadedClass): Removed.
2002-12-10 Tom Tromey <tromey@redhat.com> 2002-12-10 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt. * Makefile.in: Rebuilt.
......
...@@ -87,6 +87,14 @@ import java.util.*; ...@@ -87,6 +87,14 @@ import java.util.*;
public abstract class ClassLoader public abstract class ClassLoader
{ {
/** /**
* All classes loaded by this classloader. VM's may choose to implement
* this cache natively; but it is here available for use if necessary. It
* is not private in order to allow native code (and trusted subclasses)
* access to this field.
*/
final Map loadedClasses = new HashMap();
/**
* The desired assertion status of classes loaded by this loader, if not * The desired assertion status of classes loaded by this loader, if not
* overridden by package or class instructions. * overridden by package or class instructions.
*/ */
...@@ -446,31 +454,32 @@ public abstract class ClassLoader ...@@ -446,31 +454,32 @@ public abstract class ClassLoader
throw new java.lang.LinkageError ("class " throw new java.lang.LinkageError ("class "
+ name + name
+ " already loaded"); + " already loaded");
if (protectionDomain == null) if (protectionDomain == null)
protectionDomain = defaultProtectionDomain; protectionDomain = defaultProtectionDomain;
try { try
// Since we're calling into native code here, {
// we better make sure that any generated Class retval = defineClass0 (name, data, off, len, protectionDomain);
// exception is to spec! loadedClasses.put(retval.getName(), retval);
return retval;
return defineClass0 (name, data, off, len, protectionDomain); }
catch (LinkageError x)
} catch (LinkageError x) { {
throw x; // rethrow throw x; // rethrow
}
} catch (java.lang.VirtualMachineError x) { catch (java.lang.VirtualMachineError x)
throw x; // rethrow {
throw x; // rethrow
} catch (java.lang.Throwable x) { }
// This should never happen, or we are beyond spec. catch (java.lang.Throwable x)
{
throw new InternalError ("Unexpected exception " // This should never happen, or we are beyond spec.
+ "while defining class " throw new InternalError ("Unexpected exception "
+ name + ": " + "while defining class "
+ x.toString ()); + name + ": "
} + x.toString ());
}
} }
/** This is the entry point of defineClass into the native code */ /** This is the entry point of defineClass into the native code */
...@@ -722,8 +731,10 @@ public abstract class ClassLoader ...@@ -722,8 +731,10 @@ public abstract class ClassLoader
* @param name class to find. * @param name class to find.
* @return the class loaded, or null. * @return the class loaded, or null.
*/ */
protected final native Class findLoadedClass(String name); protected final Class findLoadedClass(String name)
{
return (Class) loadedClasses.get(name);
}
/** /**
* Get a resource using the system classloader. * Get a resource using the system classloader.
......
...@@ -189,12 +189,6 @@ java::lang::VMClassLoader::getPrimitiveClass (jchar type) ...@@ -189,12 +189,6 @@ java::lang::VMClassLoader::getPrimitiveClass (jchar type)
return _Jv_FindClassFromSignature (sig, NULL); return _Jv_FindClassFromSignature (sig, NULL);
} }
jclass
java::lang::ClassLoader::findLoadedClass (jstring name)
{
return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), this);
}
/** This function does class-preparation for compiled classes. /** This function does class-preparation for compiled classes.
NOTE: It contains replicated functionality from NOTE: It contains replicated functionality from
_Jv_ResolvePoolEntry, and this is intentional, since that function _Jv_ResolvePoolEntry, and this is intentional, since that function
......
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