JDK-6643627 : JMX source code includes incorrect Java code
  • Type: Bug
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-12-19
  • Updated: 2010-07-29
  • Resolved: 2008-02-01
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 7 Other
7Fixed OpenJDK6Fixed
Related Reports
Relates :  
Relates :  
Description
The JMX source code inadvertently trips over a javac bug (6400189) which leads the compiler to accept code that is not correct.  Specifically, in the class com.sun.jmx.mbeanserver.OpenConverter there is the following code:
           for (Constructor constr : annotatedConstrList) {
               String[] propertyNames =
                   constr.getAnnotation(propertyNamesClass).value();
               ...
The method Constructor.getAnnotation is declared like this:
    public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
This returns T only if it is called on a properly generic variable, such as a Constructor<?> or Constructor<? extends Foo> or Constructor<E>. If it is called on a plain Constructor with no type parameter, then that is a "raw type", and the return type is "erased" to Annotation.  So in this case the compiler should consider that constr.getAnnotation(propertyNamesClass) is of type Annotation, and complain that Annotation does not have a value() method.

The fix is trivial: change Constructor to Constructor<?> in the declaration of constr.

A similar problem exists in the method java.beans.MetaData.getAnnotationValue(Constructor), where the parameter type should be changed to Constructor<?>.

This bug was reported by Roman Kennke of aicas GmbH.

Comments
EVALUATION This bug causes compilation of the JDK to fail with the Eclipse compiler. The fix is trivial and should not have any effect on the generated byte code.
19-12-2007

WORK AROUND Users can of course make the change themselves before compiling the JDK.
19-12-2007