JDK-6966357 : javac 7 regression handling generic return type in Ini4J library
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2010-07-02
  • Updated: 2013-03-15
  • Resolved: 2010-12-07
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.
Related Reports
Duplicate :  
Relates :  
Relates :  
Consider this program using http://hg.netbeans.org/binaries/50986B7D247AF02C3DC25CB26B5FC7D5CF1340E6-ini4j-0.4.1.jar as a library:

import org.ini4j.Ini;
public class Demo {
    public Demo() {
        Ini.Section s = new Ini().get("section");

JDK 6's javac accepts this but JDK 7 rejects it with:

Demo.java:4: incompatible types
        Ini.Section s = new Ini().get("section");
  required: Ini.Section
  found:    Object

javap for the library reports:

public class org.ini4j.Ini extends org.ini4j.MultiMapImpl<java.lang.String, org.ini4j.Ini$Section> {
  // nothing more of interest...
public class org.ini4j.MultiMapImpl<K extends java.lang.Object, V extends java.lang.Object> extends java.lang.Object implements org.ini4j.MultiMap<K, V> {
  // ...
  public V get(java/lang/Object);
  public V get(java/lang/Object, int);
  // ...
public interface org.ini4j.MultiMap<K extends java.lang.Object, V extends java.lang.Object> extends java.lang.Object implements java.util.Map<K, V> {
  // ...
  public abstract V get(java/lang/Object, int);
  // ...

Since Ini is a MultiMapImpl<String,Ini.Section>, get(Object) on it should return Ini.Section.

Ini.Section.get(String) is similarly affected; should return String but JDK 7 javac considers it to return Object.

EVALUATION Javac is not picking up the signature attributes because the compiled code has major version = 48.0 (jdk 1.4) instead of the more appropriate 49.0 (jdk 1.5). This means the code has been compiled with the combo -source 1.5 -target jsr14. The result is in javac picking up 'erased' types (which lead to the described error). This problem started to show when we did some cleanup work on classreader vs. classfile attributes (more specifically, javac now only reads those classfile attributes that are defined for the particular classfile version in which the files it is reading are encoded).

PUBLIC COMMENTS Affects: http://hg.netbeans.org/core-main/log/default/hudson.mercurial/src/org/netbeans/modules/hudson/mercurial/HudsonMercurialSCM.java

WORK AROUND Cast the return value to the desired type.