aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2002-12-11 19:18:59 +0000
committerTom Tromey <tromey@redhat.com>2002-12-11 19:18:59 +0000
commitf99e3856eb0663f5a803db34fbad115c1ed8fc4b (patch)
tree3e002364cfa458275995352fb8c5730532048616
parent774f0902b7d1355ec55a8a532746f1bf7c0cd756 (diff)
* java/lang/ClassLoader.java (loadedClasses): New field.
(defineClass): Fixed indentation. Put new class in loadedClasses. (findLoadedClass): Implement here. * java/lang/natClassLoader.cc (findLoadedClass): Removed. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@60043 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/java/lang/ClassLoader.java59
-rw-r--r--libjava/java/lang/natClassLoader.cc6
3 files changed, 43 insertions, 30 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index e9fe22c7231..af421ed0e70 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,11 @@
+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>
* Makefile.in: Rebuilt.
diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java
index ea6546cf6ee..00cf011fac0 100644
--- a/libjava/java/lang/ClassLoader.java
+++ b/libjava/java/lang/ClassLoader.java
@@ -87,6 +87,14 @@ import java.util.*;
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
* overridden by package or class instructions.
*/
@@ -446,31 +454,32 @@ public abstract class ClassLoader
throw new java.lang.LinkageError ("class "
+ name
+ " already loaded");
-
+
if (protectionDomain == null)
protectionDomain = defaultProtectionDomain;
- try {
- // Since we're calling into native code here,
- // we better make sure that any generated
- // exception is to spec!
-
- return defineClass0 (name, data, off, len, protectionDomain);
-
- } catch (LinkageError x) {
- throw x; // rethrow
-
- } catch (java.lang.VirtualMachineError x) {
- throw x; // rethrow
-
- } catch (java.lang.Throwable x) {
- // This should never happen, or we are beyond spec.
-
- throw new InternalError ("Unexpected exception "
- + "while defining class "
- + name + ": "
- + x.toString ());
- }
+ try
+ {
+ Class retval = defineClass0 (name, data, off, len, protectionDomain);
+ loadedClasses.put(retval.getName(), retval);
+ return retval;
+ }
+ catch (LinkageError x)
+ {
+ throw x; // rethrow
+ }
+ catch (java.lang.VirtualMachineError x)
+ {
+ throw x; // rethrow
+ }
+ catch (java.lang.Throwable x)
+ {
+ // This should never happen, or we are beyond spec.
+ throw new InternalError ("Unexpected exception "
+ + "while defining class "
+ + name + ": "
+ + x.toString ());
+ }
}
/** This is the entry point of defineClass into the native code */
@@ -722,8 +731,10 @@ public abstract class ClassLoader
* @param name class to find.
* @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.
diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc
index db5ac9431d3..aeee08a6265 100644
--- a/libjava/java/lang/natClassLoader.cc
+++ b/libjava/java/lang/natClassLoader.cc
@@ -189,12 +189,6 @@ java::lang::VMClassLoader::getPrimitiveClass (jchar type)
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.
NOTE: It contains replicated functionality from
_Jv_ResolvePoolEntry, and this is intentional, since that function