From 1ea63ef8be1cc54dd0de9d82c684713a1dcf1e06 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 23 Sep 2005 21:31:04 +0000 Subject: Imported Classpath 0.18. * sources.am, Makefile.in: Updated. * Makefile.am (nat_source_files): Removed natProxy.cc. * java/lang/reflect/natProxy.cc: Removed. * gnu/classpath/jdwp/VMFrame.java, gnu/classpath/jdwp/VMIdManager.java, gnu/classpath/jdwp/VMVirtualMachine.java, java/lang/reflect/VMProxy.java: New files. 2005-09-23 Thomas Fitzsimmons * scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC list. 2005-09-23 Thomas Fitzsimmons * gnu/java/net/DefaultContentHandlerFactory.java (getContent): Remove ClasspathToolkit references. 2005-09-23 Thomas Fitzsimmons * gnu/awt/xlib/XCanvasPeer.java: Add new peer methods. * gnu/awt/xlib/XFramePeer.java: Likewise. * gnu/awt/xlib/XGraphicsConfiguration.java: Likewise. 2005-09-23 Thomas Fitzsimmons * Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add classpath/native/jawt/jawt.c. * Makefile.in: Regenerate. * jawt.c: Remove file. * include/Makefile.am (tool_include__HEADERS): Remove jawt.h and jawt_md.h. Add ../classpath/include/jawt.h and ../classpath/include/jawt_md.h. * include/Makefile.in: Regenerate. * include/jawt.h: Regenerate. * include/jawt_md.h: Regenerate. From-SVN: r104586 --- libjava/classpath/java/lang/ClassLoader.java | 36 +++++++++++++++------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'libjava/classpath/java/lang/ClassLoader.java') diff --git a/libjava/classpath/java/lang/ClassLoader.java b/libjava/classpath/java/lang/ClassLoader.java index b644511cf27..0d50a6e005d 100644 --- a/libjava/classpath/java/lang/ClassLoader.java +++ b/libjava/classpath/java/lang/ClassLoader.java @@ -123,14 +123,6 @@ import java.util.StringTokenizer; */ 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 HashMap loadedClasses = new HashMap(); - /** * All packages defined by this classloader. It is not private in order to * allow native code (and trusted subclasses) access to this field. @@ -472,15 +464,11 @@ public abstract class ClassLoader ProtectionDomain domain) throws ClassFormatError { + checkInitialized(); if (domain == null) domain = StaticData.defaultProtectionDomain; - if (! initialized) - throw new SecurityException("attempt to define class from uninitialized class loader"); - Class retval = VMClassLoader.defineClass(this, name, data, - offset, len, domain); - loadedClasses.put(retval.getName(), retval); - return retval; + return VMClassLoader.defineClass(this, name, data, offset, len, domain); } /** @@ -493,6 +481,7 @@ public abstract class ClassLoader */ protected final void resolveClass(Class c) { + checkInitialized(); VMClassLoader.resolveClass(c); } @@ -508,6 +497,7 @@ public abstract class ClassLoader protected final Class findSystemClass(String name) throws ClassNotFoundException { + checkInitialized(); return Class.forName(name, false, StaticData.systemClassLoader); } @@ -544,6 +534,7 @@ public abstract class ClassLoader */ protected final void setSigners(Class c, Object[] signers) { + checkInitialized(); c.setSigners(signers); } @@ -556,9 +547,8 @@ public abstract class ClassLoader */ protected final synchronized Class findLoadedClass(String name) { - // NOTE: If the VM is keeping its own cache, it may make sense to have - // this method be native. - return (Class) loadedClasses.get(name); + checkInitialized(); + return VMClassLoader.findLoadedClass(this, name); } /** @@ -1113,4 +1103,16 @@ public abstract class ClassLoader .initCause(e); } } + + /** + * Before doing anything "dangerous" please call this method to make sure + * this class loader instance was properly constructed (and not obtained + * by exploiting the finalizer attack) + * @see #initialized + */ + private void checkInitialized() + { + if (! initialized) + throw new SecurityException("attempt to use uninitialized class loader"); + } } -- cgit v1.2.3