[fedora-java] Re: .jar and .so both loaded?

Andrew Haley aph at redhat.com
Thu Jul 14 14:45:37 UTC 2005


Peter Backlund writes:
 > tor 2005-07-14 klockan 10:42 +0100 skrev Andrew Haley:
 > > Peter Backlund writes:
 > > 
 > >  > I have a couple of questions about class loading in natively compiled
 > >  > Java applications: should an application that has been natively compiled
 > >  > (i.e. all .jars compiled into .so by gcj and a .db created, according to
 > >  > http://gcc.gnu.org/wiki/How%20to%20BC%20compile%20with%20GCJ) load both
 > >  > the .jars and the .so into memory? lsof seems to think that is the
 > >  > case.  
 > > 
 > > Yes.
 > > 
 > >  > Also, Eclipse in Rawhide consumes almost twice as much memory for
 > >  > starting up and opening HelloWorld.java as the Sun JVM 1.5.0_03/upstream
 > >  > Eclipse combination.
 > > 
 > > Yeah, we know.  It's something we need to investigate and fix.
 > 
 > My point was that the excessive memory usage might be due to the fact
 > that both .jar and .so  files are loaded into memory.

That's an interesting guess, but it may not be true at all.  We'll
have to make some measurements to know for sure.

 > Why is the bytecode needed at all when there are pre-compiled
 > shared libraries with the same code already available?

Well, that's how class loaders work.  

But you can avoid this overhead altogether if you link with gcj.  Just
compile your java library code with

   gcj -shared -o libfoo.so

and then link with your executable using

   gcj -lfoo

and you won't need jar files.

 > >  > Is it still possible to build a Java application into a standalone
 > >  > executable, that does not require gij to run? Is there any guilde on how
 > >  > to do that?
 > > 
 > > As far as I'm aware it's all in the manual.
 > 
 > Well, of course, but I was looking for something a little more
 > high-level, maybe a tutorial on how to convert a semi-big Java
 > application into a native executable + shared libs.

Gary Benson is working on making that as painless as possible, and the
next Fedora Core will have a lot of worked examples.  But yes, we
could also use a tutorial.

 > Anyway, I'll figure it out.
 > 
 > Do you lose the ability to load Java bytecode during runtime when
 > compiling it as a native executable?

No, not all all.  That still works.

Andrew.




More information about the java-devel mailing list