Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7078419

Java Compiler does not support -jsr14 created JAR files

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 7
    • tools
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      This is not OS specific

      ADDITIONAL OS VERSION INFORMATION :
      This is not OS specific

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      This is not OS specific

      A DESCRIPTION OF THE PROBLEM :
      In the Java 5/6 compilers it is possible to compile with -jsr14.

        http://jcp.org/aboutJava/communityprocess/review/jsr014/

      This option allowed the compiler to generate 1.4 byte codes that included the generic attributes. JAR files thus produced work well on all Java 5 and Java 6 compilers (as well as Eclipse). However, on JDK 7 the compiler no longer recognizes the generic attributes in these class files.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Create a class that implements an interface with methods that use generics and compile on Java 5/6 with -jsr14

      public interface Foo {
        void foo(Map<String,String> m);
      }

      Create another class that implements that interface:

        public class Bar implements Foo {
           void foo(Map<String,String> m) {}
        }



      ACTUAL -
      The second class compiles with the error that Bar does not implement foo and another error that bar clashes with foo ...

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project com.paremus.dosgi.dsw: Compilation failure: Compilation failure:
      [ERROR] \home\holger\Projects\paremusWorkspace\dosgi\rsa\dsw\src\main\java\com\paremus\dosgi\dsw\service\RemoteServiceAdminInstance.java:[69,7] error: RemoteServiceAdminInstance is not abstract and does not override abstract method exportService(ServiceReference,Map) in RemoteServiceAdmin
      [ERROR \home\holger\Projects\paremusWorkspace\dosgi\rsa\dsw\src\main\java\com\paremus\dosgi\dsw\service\RemoteServiceAdminInstance.java:[137,42] error: name clash: exportService(ServiceReference,Map<String,Object>) in RemoteServiceAdminInstance and exportService(ServiceReference,Map) in RemoteServiceAdmin have the same erasure, yet neither overrides the other
      This compiles cleanly with no errors whatsoever in JDK5/6.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Recompiling the classes but this is unfortunately not always possible. I expect that it is possible to set the class file version to 49 but have not tested this.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: