Derby
  1. Derby
  2. DERBY-4880

Unchecked warnings in JMXManagementService and VTI demos

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: Demos/Scripts, JMX
    • Labels:
      None

      Description

      These warnings I only see if java15compile.classpath points to Java 6 class libraries (either set explicitly in ant.properties, or implicitly by the property setter):

      [javac] /code/derby/trunk2/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java:215: warning: [unchecked] unchecked conversion
      [javac] found : java.lang.Class
      [javac] required: java.lang.Class<java.lang.Object>
      [javac] new StandardMBean(bean, beanInterface) {
      [javac] ^
      [javac] /code/derby/trunk2/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java:215: warning: [unchecked] unchecked method invocation: <T>StandardMBean(T,java.lang.Class<T>) in javax.management.StandardMBean is applied to (java.lang.Object,java.lang.Class)
      [javac] new StandardMBean(bean, beanInterface) {
      [javac] ^
      [javac] 2 warnings
      [javac] /code/derby/trunk2/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/QueryVTIHelper.java:185: warning: [unchecked] unchecked call to getMethod(java.lang.String,java.lang.Class<?>...) as a member of the raw type java.lang.Class
      [javac] ( methodName, new Class[]

      { String.class } );
      [javac] ^
      [javac] /code/derby/trunk2/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/XmlVTI.java:253: warning: [unchecked] unchecked call to getMethod(java.lang.String,java.lang.Class<?>...) as a member of the raw type java.lang.Class
      [javac] ( methodName, new Class[] { String.class }

      );
      [javac] ^
      [javac] /code/derby/trunk2/java/demo/vtis/java/org/apache/derbyDemo/vtis/core/XmlVTI.java:260: warning: [unchecked] unchecked call to getConstructor(java.lang.Class<?>...) as a member of the raw type java.lang.Class
      [javac] ( new Class[]

      { String.class, String.class, String[].class }

      );
      [javac] ^
      [javac] /code/derby/trunk2/java/demo/vtis/java/org/apache/derbyDemo/vtis/snapshot/Subscription.java:278: warning: [unchecked] unchecked call to getMethod(java.lang.String,java.lang.Class<?>...) as a member of the raw type java.lang.Class
      [javac] ( methodName, new Class[] {} );
      [javac] ^
      [javac] 4 warnings

      1. deprecated.diff
        4 kB
        Knut Anders Hatlen

        Activity

        Knut Anders Hatlen created issue -
        Knut Anders Hatlen made changes -
        Field Original Value New Value
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Knut Anders Hatlen added a comment -

        I think the reason why we see these warnings only when compiled against the Java 6 libraries, was that StandardMBean's constructor, Class.getMethod() and Class.getConstructor() were not given generic signatures until Java 6.

        Show
        Knut Anders Hatlen added a comment - I think the reason why we see these warnings only when compiled against the Java 6 libraries, was that StandardMBean's constructor, Class.getMethod() and Class.getConstructor() were not given generic signatures until Java 6.
        Hide
        Knut Anders Hatlen added a comment -

        The attached patch makes the warnings go away.

        In the VTI demos we only need to change the type of some variables from Class to Class<?> to silence the compiler.

        In JMXManagementService the only way I found to silence it, was to annotate the expression that caused the warning with @SuppressWarnings("unchecked"). Changing to generic data types was not an option (at least not as far as I could see), because the variables that were converted unchecked came from the method signature, and that signature could not use generics because it had to match the signature in the ManagementService interface. And the ManagementService interface has to be compilable against the Java 1.4 libraries, so we can't switch to generics in the interface either.

        I think it's OK to suppress the warning in this case, since a type mismatch will be detected immediately (StandardMBean's javadoc says that a NotCompliantMBeanException will be raised in such a case), and the unchecked warning is just about that – that the compiler cannot guarantee that a type mismatch is detected immediately.

        Show
        Knut Anders Hatlen added a comment - The attached patch makes the warnings go away. In the VTI demos we only need to change the type of some variables from Class to Class<?> to silence the compiler. In JMXManagementService the only way I found to silence it, was to annotate the expression that caused the warning with @SuppressWarnings("unchecked"). Changing to generic data types was not an option (at least not as far as I could see), because the variables that were converted unchecked came from the method signature, and that signature could not use generics because it had to match the signature in the ManagementService interface. And the ManagementService interface has to be compilable against the Java 1.4 libraries, so we can't switch to generics in the interface either. I think it's OK to suppress the warning in this case, since a type mismatch will be detected immediately (StandardMBean's javadoc says that a NotCompliantMBeanException will be raised in such a case), and the unchecked warning is just about that – that the compiler cannot guarantee that a type mismatch is detected immediately.
        Knut Anders Hatlen made changes -
        Attachment deprecated.diff [ 12458522 ]
        Knut Anders Hatlen made changes -
        Issue & fix info [Patch Available]
        Hide
        Knut Anders Hatlen added a comment -

        Committed revision 1030450.

        Show
        Knut Anders Hatlen added a comment - Committed revision 1030450.
        Knut Anders Hatlen made changes -
        Status In Progress [ 3 ] Closed [ 6 ]
        Issue & fix info [Patch Available]
        Fix Version/s 10.7.1.0 [ 12314971 ]
        Resolution Fixed [ 1 ]
        Rick Hillegas made changes -
        Affects Version/s 10.7.1.1 [ 12315564 ]
        Affects Version/s 10.7.1.0 [ 12314971 ]
        Fix Version/s 10.7.1.1 [ 12315564 ]
        Fix Version/s 10.7.1.0 [ 12314971 ]
        Gavin made changes -
        Workflow jira [ 12525662 ] Default workflow, editable Closed status [ 12800240 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        14s 1 Knut Anders Hatlen 31/Oct/10 20:31
        In Progress In Progress Closed Closed
        2d 16h 45m 1 Knut Anders Hatlen 03/Nov/10 13:16

          People

          • Assignee:
            Knut Anders Hatlen
            Reporter:
            Knut Anders Hatlen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development