System Class Loader

I trying to custom JVM to use my created ClassLoader. Thus, I add system property as below to start my testing program as below: -

java -Djava.system.class.loader=test.ClassLoader TestClassLoader

Here is Testing Class for reference: -

class TestClassLoader{

public TestClassLoader(){

super();

}

publicstaticvoid main(String[] args){

System.out.println("SystemClassLoader:"+ java.lang.ClassLoader.getSystemClassLoader());

}

}

I try this test case in JDK 1.2.2, 1.3, 1.4.1....all result like this..

SystemClassLoader:sun.misc.Launcher$AppClassLoader@cfbcb

I supposed that the system class loader should be changed to"test.ClassLoader". Anyone know what's wrong. please correct.

[1171 byte] By [dickanfa] at [2007-9-29 16:22:26]
# 1
Has your class loader class a public constructor with a single ClassLoader argument ? Have you tried to start the start the JVM in verbose mode java -verbose:class ...to see if your ClassLoader gets loaded ?
andiha at 2007-7-15 14:39:20 > top of Java-index,Archived Forums,Java Programming...
# 2
I tried add the constructor, and running in verbose mode:-Constructor(ClassLoader inCL)But, I cannot find my ClassLoader loaded in verbose outputs.Would you have any idea?
dickanfa at 2007-7-15 14:39:20 > top of Java-index,Archived Forums,Java Programming...
# 3

> > Constructor(ClassLoader inCL)

>

Sorry, I don't understand what you've done.

Your test.ClassLoader class needs something like

// public constructor

// you require the full qualified ClassLoader classname

// here otherwise the argument would be test.ClassLoader

// this constructor is required otherwise the ClassLoader

// won't be used as SystemClassLoader

public ClassLoader( java.lang.ClassLoader)

{

....

}

andiha at 2007-7-15 14:39:20 > top of Java-index,Archived Forums,Java Programming...
# 4
It might be helpful if your classloader were actually a ClassLoader. I.e. you need to extend ClassLoader as well as add the delegation constructor.
YATArchivista at 2007-7-15 14:39:20 > top of Java-index,Archived Forums,Java Programming...
# 5
Here is my overrided constructor. Is this correct?public ClassLoader(ClassLoader parent) {super(parent);}
dickanfa at 2007-7-15 14:39:20 > top of Java-index,Archived Forums,Java Programming...
# 6
If your class is called ClassLoader, you'll need to fully qualify the type of the java.lang.ClassLoader which is the parameter.
YATArchivista at 2007-7-15 14:39:20 > top of Java-index,Archived Forums,Java Programming...