JDK-8149008 : Incorrect substitution of type parameter in generic superclass
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2016-02-02
  • Updated: 2016-03-03
  • Resolved: 2016-02-04
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_71"
Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
Java HotSpot(TM) Server VM (build 25.71-b15, mixed mode)


A DESCRIPTION OF THE PROBLEM :
In accordance with JLS 8.1.4, if type parameter name ("A", for example) of some class and other class name are equals then all occurrence "A" in type variable of generic superclass must be interpreted as type variable, not as class. But it is not.

public class Main {

    public static class A {}

    public static class MyList<A> extends java.util.ArrayList<A> {}
}

java 7
Compiled from "Main.java"
public class Main$MyList<A> extends java.util.ArrayList<A> {
  public Main$MyList();
}

java 8
Compiled from "Main.java"
public class Main$MyList<A> extends java.util.ArrayList<Main$A> {
  public Main$MyList();
}


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Just rename type parameter.


Comments
This is indeed a problem: "The scope of a class's type parameter (��8.1.2) is the type parameter section of the class declaration, the type parameter section of any superclass or superinterface of the class declaration, and the class body.". Clearly JDK 8 doesn't adhere to the above definition.
04-02-2016

Test result: ######### OS: Ubuntu Linux 64 bit, Windows 7 64-bit JDK: 7uXX : Pass 8uXX : Fail 9ea : Pass ##################################################### 7uXX: ##### c:\Abhijit\tools>javap Main$MyList.class Compiled from "Main.java" public class Main$MyList<A> extends java.util.ArrayList<A> { public Main$MyList(); } 8uXX: ##### c:\Abhijit\tools>javac Main.java c:\Abhijit\tools>javap Main$MyList.class Compiled from "Main.java" public class Main$MyList<A> extends java.util.ArrayList<Main$A> { public Main$MyList(); } 9ea: #### c:\Abhijit\tools>javac Main.java c:\Abhijit\tools>javap Main$MyList.class Compiled from "Main.java" public class Main$MyList<A> extends java.util.ArrayList<A> { public Main$MyList(); }
04-02-2016