Details
-
Bug
-
Resolution: Fixed
-
P2
-
8u40
-
b08
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8083982 | emb-9 | Jaroslav Bachorík | P2 | Resolved | Fixed | team |
JDK-8086826 | 8u65 | Jaroslav Bachorík | P2 | Resolved | Fixed | b01 |
JDK-8138083 | emb-8u65 | Unassigned | P2 | Resolved | Fixed | b01 |
JDK-8076902 | emb-8u60 | Jaroslav Bachorík | P2 | Resolved | Fixed | team |
Description
I'm seeing a regression moving from JDK7 to JDK8u40 with the invocation of a method in an annotation from a debugger.
I have a simple annotation class with two methods. There is a unit test that retrieves the annotations (getDeclaredAnnotations()).
After retrieving the annotations, I try to call ObjectReference.invokeMethod() to invoke each of the annotation's methods. In JDK7 this worked; in JDK8 it fails with an IllegalAccessException: "Not a default method".
I've looked at the source for com.sun.tools.jdi.ObjectReferenceImpl and see significant changes between JDK7 and JDK8 due to the introduction of interface methods in JDK8.
In JDK7, all methods were class (as opposed to interface) methods and the validation of the annotation methods was successful.
In JDK8, validateMethodInvocation has been rewritten to be a small method that forwards the validation to one of two new methods,
validateClassMethodInvocation or validateIFaceMethodInvocation. The implementation of validateClassMethodInvocation appears to be the same as the pre-JDK8 validateMethodInvocation -- validation that the annotation method would pass. However, the annotation method is being treated as an interface method (because method.declaringType() instanceof InterfaceTypeImpl is true) and going through validateIFaceMethodInvocation. The test there is that method.isDefault() -- and the annotation method returns false, thus the exception is thrown.
I'm not sure what the correct behavior is here, but there are a couple of possibilities:
- If annotation classes were treated as classes, rather than interfaces, then we'd go through the same validation as before and this would work.
- Alternately. if methods on annotations were considered default methods, then we'd pass the new validation. (The annotations do have a "default" value specified, but not all annotation methods will, so this seems a less satisfactory solution)
- Or, the validateIFaceMethodInvocation may need a special test for annotation methods and validate them differently than interface methods.
Attachments
Issue Links
- backported by
-
JDK-8076902 JDI ObjectReferenceImpl.invokeMethod() validation fails for virtual invocations of method with declaring type being an interface
-
- Resolved
-
-
JDK-8083982 JDI ObjectReferenceImpl.invokeMethod() validation fails for virtual invocations of method with declaring type being an interface
-
- Resolved
-
-
JDK-8086826 JDI ObjectReferenceImpl.invokeMethod() validation fails for virtual invocations of method with declaring type being an interface
-
- Resolved
-
-
JDK-8138083 JDI ObjectReferenceImpl.invokeMethod() validation fails for virtual invocations of method with declaring type being an interface
-
- Resolved
-
- duplicates
-
JDK-8074982 java.lang.IllegalArgumentException: Not a default method
-
- Resolved
-