Bug 31647 - Embedded class dependencies cannot be loaded dynamically from a staic binary
Summary: Embedded class dependencies cannot be loaded dynamically from a staic binary
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.2.0
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-21 14:14 UTC by Mohsen Saboorian
Modified: 2016-09-30 22:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mohsen Saboorian 2007-04-21 14:14:38 UTC
I compiled statically an application with dependencies to javax.xml.parser using GCJ, replacing DocumentBuilderFactory.newInstance() with new DomDocumentBuilderFactory() (with -static-gcj switch).

By bad fortune, there is no DomDocumentBuilderFactory entry in the output of command:
nm --demangle=java myapp.executable

I extracted a portion of libgcj-4.2.0.jar (the whole content of gnu.xml.* package), say gcj-dom.jar, and compiled and linked it with my application. The result executable has DomDocumentBuilderFactory but this time I'm facing with NoClassDefFoundError for gnu.xml.dom.DomImpl.

Again I put the trivial code new DomImpl() and linked the app. This time again I'm facing with:
java.lang.NoClassDefFoundError: gnu.xml.dom.DomImpl
java.lang.Class.initializeClass(zekr_static_olpc.exe)
gnu.xml.dom.ImplementationSource.<clinit>(zekr_static_olpc.exe)
java.lang.Class.initializeClass(zekr_static_olpc.exe)
java.lang.Class.newInstance(zekr_static_olpc.exe)
org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance(zekr_static_olpc.exe)
gnu.xml.dom.DomDocumentBuilderFactory.<init>(zekr_static_olpc.exe)
net.sf.zekr.engine.xml.XmlReader.<init>(zekr_static_olpc.exe)
net.sf.zekr.common.config.ApplicationConfig.extractLangProps(zekr_static_olpc.exe)
...

It's strange that although there exists some entry for gnu.xml.dom.DomImpl with:
nm --demangle=java myapp.exe
it gives me that error.

I should also say that I tried to embed xercesImpl.jar with my app, setting:
-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
so that it uses xerces instead of gnu.xml.*. It gives me again a NoClassDefFoundError.

It seems that even when a class is embedded in a static binary, class loader (java.lang.Class.initializeClass()) cannot load that.

I used this on Ubuntu 6.10 (Edgy); GCC version is 4.1.2 (2006-9-28 prerelease, Ubuntu 4.1.1.14ubuntu7)

Here is some posts on GCJ mailing list regarding this problem:
- http://www.nabble.com/libgcj_bc.so-not-embedded-t3538410.html
- http://www.nabble.com/libgcj_bc.so-not-embedded-t3538410i20.html
- http://www.nabble.com/Trying-to-embed-gnu.xml.dom.DomDocumentBuilderFactory-t3608745.html
Comment 1 Andrew Pinski 2016-09-30 22:49:23 UTC
Closing as won't fix as the Java front-end has been removed from the trunk.