libgcj failure: Duplicate class registration

Hannes Wallnoefer
Thu Mar 18 21:51:00 GMT 2004

Hannes Wallnoefer wrote:

> Tom Tromey wrote:
>> With the current gcj, a given compiled class can only be loaded once
>> by the system class loader.  If you try to link in a class more than
>> once, you get this failure.
>> This choice was the result of a lot of discussion a few years ago, see
>> the list archives for the details.  (I don't have a ready pointer to
>> the thread, sorry.)
> I found that the problem is Apache is calling dlopen() twice for each 
> shared module. This is done on purpose to let modules set up their 
> logs files or whatever. So I guess the only solution is to put the 
> Java classes in a separate library and load that manually from my 
> module. Unless there is a way to "forget" about the classes loaded in 
> the first dlopen() pass, but I somehow doubt this.

Thinking about this some more it actually seems like an unnecessary 
restriction that shared libraries can only be dlopen()ed once by the 
same classloader. I think the check for already loaded classes in the 
system classloader is to prevent system classes from being overwritten 
by classes defined in some other file, which surely is a good thing. But 
in this case we're loading the same library file again, so this is not 
an issue. Wouldn't the right thing to do in this case to just keep track 
of already loaded shared libraries in the classloader and simply ignore 
multiple calls to already linked libraries?


More information about the Java mailing list