JDK-8183273 : Clarify Instrumentation interface should not be implemented outside java.instrument module
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: java.lang.instrument
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-06-30
  • Updated: 2019-05-28
  • Resolved: 2019-05-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 13
13 b22Fixed
Related Reports
CSR :  
Relates :  
Description
Java SE 9 adds two abstract methods to java.lang.instrument.Instrumentation. This is a source incompatible change. The assumption at the time was that the Instrumentation implementation is tightly coupled to the VM implementation and it seemed unlikely there would be other implementations (this follows similar additions of abstract methods in Java SE 6).

The NetBeans project now reports that it implements Instrumentation. The thread on this discussion is here:
  http://mail.openjdk.java.net/pipermail/jigsaw-dev/2017-June/012934.html

This feedback came too late for Java SE 9. At the same time, the use is a bit dubious because NetBeans doesn't implement it completely, instead it appears to implement the add/removeTransformer methods only.

This issue tracks an re-examination in some future major release. We could, for example, consider changing methods to be default methods in Java SE 10. Alternatively the Instrumentation class description could include a note to make it clear that the interface is not intended to be implemented outside of the java.instrument module. 
Comments
The suggested fix is: --- a/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java Fri May 10 13:37:00 2019 -0700 +++ b/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java Fri May 10 17:48:45 2019 -0700 @@ -65,6 +65,9 @@ * <p> * Once an agent acquires an <code>Instrumentation</code> instance, * the agent may call methods on the instance at any time. + * <p> + * @apiNote This interface is not intended to be implemented outside of + * the java.instrument module. * * @since 1.5 */ I'll file a CSR for this.
14-05-2019

It is easy to make two module-related methods introduced in the jdk 9 to be default. But the question is if it is a right thing to do. I'll add a note to the Instrumentation interface that it is not intended to be implemented outside of the java.instrument module.
09-05-2019

Looking at this again, I think Instrumentation should include a note to make it clear that it is not intended to be implemented outside of the java.instrument module.
11-02-2018