[Bug libgcj/23288] java.lang.Class's #getPackage() returns null
tromey at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Sep 9 18:35:00 GMT 2005
------- Additional Comments From tromey at gcc dot gnu dot org 2005-09-09 18:35 -------
Note also that Package.getVersion fails when the class file comes from a
jar. With the included example you can see this by making a manifest file
(in my example named "J/Man"):
Main-Class: men.gcjpackage.TestPackage
Name: men/gcjpackage/
Specification-Title: JChemPaint
Specification-Version: 2.0
Specification-Vendor: The JChemPaint Project
Implementation-Title: jchempaint
Implementation-Version: 2.0.12
Implementation-Vendor: The JChemPaint Project
Then make a jar:
jar -cv -m J/Man -f J/men.jar men/gcjpackage/*.class
And change the test to:
package men.gcjpackage;
public class TestPackage
{
public static void main(String[] args)
{
System.out.println("ClassLoader: " + TestPackage.class.getClassLoader() );
Package x = TestPackage.class.getPackage();
System.out.println("Package: " + x);
System.out.println("Version: " + x.getImplementationVersion());
} // main
} // TestPackage
With the JDK the last line prints:
Version: 2.0.12
With gij it prints:
Version: null
As the names suggest, this prevents JChemPaint from working:
http://almost.cubic.uni-koeln.de/cdk/jcp
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23288
More information about the Gcc-bugs
mailing list