Patch: FYI: minor ClassLoader.loadClass restructuring
Tom Tromey
tromey@redhat.com
Mon Apr 4 18:24:00 GMT 2005
I'm checking this in on the trunk and the 4.0 branch.
This restructures ClassLoader.loadClass a little to make it more
clear, and to make the behavior of the 'resolve' argument more
correct. I already put a similar patch in Classpath a little while
ago.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/ClassLoader.java (loadClass): Resolve class even if
it was already found.
Index: java/lang/ClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/ClassLoader.java,v
retrieving revision 1.39
diff -u -r1.39 ClassLoader.java
--- java/lang/ClassLoader.java 21 Mar 2005 14:50:13 -0000 1.39
+++ java/lang/ClassLoader.java 4 Apr 2005 18:21:16 -0000
@@ -285,28 +285,28 @@
{
// Have we already loaded this class?
Class c = findLoadedClass(name);
- if (c != null)
- return c;
-
- // Can the class be loaded by a parent?
- try
+ if (c == null)
{
- if (parent == null)
+ // Can the class be loaded by a parent?
+ try
{
- c = VMClassLoader.loadClass(name, resolve);
- if (c != null)
- return c;
+ if (parent == null)
+ {
+ c = VMClassLoader.loadClass(name, resolve);
+ if (c != null)
+ return c;
+ }
+ else
+ {
+ return parent.loadClass(name, resolve);
+ }
}
- else
+ catch (ClassNotFoundException e)
{
- return parent.loadClass(name, resolve);
}
+ // Still not found, we have to do it ourself.
+ c = findClass(name);
}
- catch (ClassNotFoundException e)
- {
- }
- // Still not found, we have to do it ourself.
- c = findClass(name);
if (resolve)
resolveClass(c);
return c;
More information about the Java-patches
mailing list