United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7078419 Java Compiler does not support -jsr14 created JAR files
JDK-7078419 : Java Compiler does not support -jsr14 created JAR files

Details
Type:
Bug
Submit Date:
2011-08-12
Status:
Closed
Updated Date:
2013-03-15
Project Name:
JDK
Resolved Date:
2011-08-12
Component:
tools
OS:
windows_7
Sub-Component:
javac
CPU:
x86
Priority:
P4
Resolution:
Not an Issue
Affected Versions:
7
Fixed Versions:

Related Reports
Relates:

Sub Tasks

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.
                                     
2011-08-12



Hardware and Software, Engineered to Work Together