This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

help with pre-compiled classloading


Hello,
I need a little help. I cannot manage it to pre-compile separate .class files in separate .so objects in a way that it works. Is that generally possible?
Here is a little test-scenario:


I have made a small program with 3 sources: HelloWorld.java, MyClass.java and pkg/MyOtherClass.java
In this program HelloWorld instantiates MyClass, and MyClass instantiates pkg.MyOtherClass.


First I have compiled everything with: 'javac HelloWorld.java'
Then I've created a pre-compiled lib-MyClass.so with: 'gcj -shared -o lib-MyClass.so MyClass.class'
and removed after that MyClass.class, to be sure if MyClass is loaded then it comes from the shared object.
Now I try to start it all: 'gij -verbose:class -Dgnu.gcj.runtime.VMClassLoader.library_control=full -Djava.library.path=. HelloWorld'
and gij exits with java.lang.ClassNotFoundException: MyClass not found in gnu.gcj.runtime.SystemClassLoader


Ookay, because I know that MyClass instantiates MyOtherClass, I have linked them both in a shared lib: 'gcj -shared -o lib-MyClass.so MyClass.class pkg/MyOtherClass.class'
And now gij works fine ... :
...
[Loaded (bytecode) HelloWorld from (file:/.../mydir/ <no certificates>)]
[Loaded (pre-compiled) MyClass from <no code source>]
[Loaded (pre-compiled) com.MySecondClass from <no code source>]


So I thought, aaah once loading a precompiled class from a .so any other class it needs on it's reachability tree shall also be precompiled?
Probably I could make separate shared objects for MyClass and MyOtherClass, put them in the same java.library.path and everything will be alright?
But indeed, the same java.lang.ClassNotFoundException as above occurs!


This would mean now, that when loading a pre-compiled class, gij needs all other referenced classes explicitely to be linked within the same shared object? Is it possible to let gcj do this automatically? Anyway, gcj has to access all referenced classes (here pkg.MyOtherClass.class) when compiling (MyClass).
Or did I just miss something?


Regards,
Vladimir


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]