JDK-7078419 : Java Compiler does not support -jsr14 created JAR files
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-08-12
  • Updated: 2013-03-15
  • Resolved: 2011-08-12
Related Reports
Relates :  
Description
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.

Comments
EVALUATION The interim support for "jsr14" class files was never a documented supported option. And, since generic signature attributes are not defined for v48 (JDK 1.4) and earlier class files, it is inappropriate for javac to behave otherwise.
12-08-2011