Instrumentation best practices question, and more
Michael Rasmussen
michael.rasmussen at zeroturnaround.com
Thu Nov 26 10:13:13 UTC 2015
On 26 November 2015 at 09:33, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 25/11/2015 22:56, Michael Rasmussen wrote:
>>
>>
>> 3) Why was the implementation of java.lang.Package changed, so it no
>> longer returns the content of the Manifest file?
>> Previously, doing MyClass.class.getPackage().getImplementationTitle()
>> would return the "Implementation-Title" entry from the manifest file,
>> but now it returns null instead.
>> The documentation in JDK8 even mentions that this information is
>> typically stored in the manifest, where as the JDK9 now states that
>> these values are unspecified.
>
> If MyClass is packaged as a JAR file with an Implementation-Title attribute
> then this should continue to work. I just checked and I don't see any issues
> but it's possible my test case doesn't match what you have. If you can
> create a short test case then that would be useful to help us see whether
> there is a bug here.
>
Yeah, I should have been more specific -- the issue is when the package
is loaded from the boot loader, for instance when you have an agent that
has itself on the Boot-Class-Path in the manifest.
Sample code: https://gist.github.com/anonymous/d4f591fc041e676eb8d9
Output:
$ java -javaagent:target\test-1.0-SNAPSHOT.jar -version
test
null
1.0-SNAPSHOT
test
null
1.0-SNAPSHOT
test
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
$ java -javaagent:target\test-1.0-SNAPSHOT.jar -version
null
null
null
null
null
null
null
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build
1.9.0-ea-jigsaw-nightly-h3660-20151022-b86)
Java HotSpot(TM) 64-Bit Server VM (build
1.9.0-ea-jigsaw-nightly-h3660-20151022-b86, mixed mode)
More information about the jigsaw-dev
mailing list