[ https://issues.apache.org/jira/browse/FELIX-682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12623128#action_12623128 ]
Sahoo commented on FELIX-682: ----------------------------- Here is the summary: 1. Java Package Versioning specification available at http://java.sun.com/javase/6/docs/technotes/guides/versioning/spec/versioning2.html#wp90779 defines standard meta data that user can specify in manifest file of a jar at package level. While reading that section, read the attributes names starting with Package- as Implementation-. It's a bug in the documentation as I have already discussed in my previous comment. 2. This document clearly states that various methods of java.lang.Package is supposed to return values specified in these attributes in the manifest file. Although it is not clear from that documentation what happens when information is not available at package level, experiments show that when information is not supplied for a package, the classloaders in JRE defaults to information available in main attributes of the manifest file. It is demonstrated in the simple test case that I have already attached. In fact, you can write a simple test case to see information returned for java.lang package and compare it with manifest entries of jre/lib/rt.jar. 3. What confuses me is that javadocs of java.lang.Package available at http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Package.html states the following: "Package objects contain version information about the implementation and specification of a Java package. This versioning information is retrieved and made available by the ClassLoader instance that loaded the class(es). Typically, it is stored in the manifest that is distributed with the classes." It uses the word typically as opposed to must, so it makes it debatable whether Felix is incorrect in ignoring the metadata specified in manifest file of the jar. All I can say is that when the same jar is used by URLClassLoader or JDK's system class loader, the Package object constructed by those class loaders do return desired results, where as when the jar is used by Felix to load a class, it does not. So, it would be better to have it fixed in Felix. Felix code already uses the following API to create a package: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ClassLoader.html#definePackage(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.net.URL) , now it's a matter of reading the appropriate metadata from manifest file and using it while calling the API. Java Package Versioning spec already gives details about what manifest entries to read. Yes, I would like it to be part of v.1.2.0. Thanks, Sahoo > Package.getImplementationVersion returns null for package loaded by Felix > ------------------------------------------------------------------------- > > Key: FELIX-682 > URL: https://issues.apache.org/jira/browse/FELIX-682 > Project: Felix > Issue Type: Wish > Components: Framework > Affects Versions: felix-1.0.4 > Environment: NA > Reporter: Sahoo > Fix For: felix-1.2.0 > > Attachments: Felix-682.zip, java-pkg-versioning-spec-bug.zip > > > Even though MANIFEST.MF has proper entry for Implementation-Version, > Package.getImplementationVersion() returns null. A reproducible test case is > attached. It is described below: > public class Foo implements BundleActivator { > public void start(BundleContext context) throws Exception { > Package p = getClass().getPackage(); > System.out.println(p); > System.out.println(p.getImplementationVersion()); > } > } > The headers for this bundle are: > osgi-test1 (10) > --------------- > Tool = Bnd-0.0.255 > Bundle-Activator = sahoo.osgitest1.Foo > Implementation-Version = 1.0-SNAPSHOT > Implementation-Vendor-Id = sahoo > Bundle-Version = 1.0.0.SNAPSHOT > Build-Jdk = 1.5.0_13-rev > Implementation-Title = osgi-test1 > Created-By = Apache Maven Bundle Plugin > Bundle-ManifestVersion = 2 > Manifest-Version = 1.0 > Bnd-LastModified = 1218821794953 > Private-Package = sahoo.osgitest1 > Bundle-Name = osgi-test1 > Built-By = ss141213 > Import-Package = org.osgi.framework;version="1.3" > Bundle-SymbolicName = sahoo.osgi-test1 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.