You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by bu...@apache.org on 2006/09/28 13:23:13 UTC

DO NOT REPLY [Bug 38377] - BCEL cannot be used as java.system.class.loader

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38377>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38377





------- Additional Comments From mail@dcoy.org  2006-09-28 11:23 -------
Created an attachment (id=18930)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=18930&action=view)
Patch for ClassLoader constructor

I created a subclass of org..ClassLoader (lets call is SLoader) and tried to
use it as the system class loader, but it gave me the same error as described
in the initial comment.

The class looks like this:

public class SLoader extends ClassLoader{
 [...]
    public SLoader(java.lang.ClassLoader deferTo) {
	super(deferTo, new String[]{ "java.",
				     "javax.",
				     "com.sun.",
				     "sun."}
	);
    }
 [...]
}

The JVM calls the above constructor when the class is passed with the
-Djava.system.class.loader VM argument. This constructor then calls the
constructor of the org..ClassLoader

public class ClassLoader extends java.lang.ClassLoader {
 [...]
    public ClassLoader(java.lang.ClassLoader deferTo, String[]
ignored_packages) {
	this(ignored_packages);
	this.repository = new ClassLoaderRepository(deferTo);
    }
 [...]
}

As you can see, there is no explicit call the any constructor of the
java..ClassLoader class. This causes its default constructor to be invoked,
which tries to resolv the parent class loader by calling
java..ClassLoader.getSystemClassLoader() which causes the loop in the class
loader hierarchy.

The appended patch fixes this by explicitly invoking the

    java.lang.ClassLoader.ClassLoader(ClassLoader parent)

constructor which does not use the getSystemClassLoader() method.


A question about the bug reporting process: Should I REOPEN the bug and then
set it RESOLVED/FIXED again?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org