JDK-8148135 : nullpointer exception occuring in a generic class
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2016-01-04
  • Updated: 2016-10-19
  • Resolved: 2016-10-19
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
1.8.0_51

ADDITIONAL OS VERSION INFORMATION :
Windows 7 - 64 bit

A DESCRIPTION OF THE PROBLEM :
interface IOne{}
interface ITwo{}
class A{}
class B <IOne extends A, IOne, ITwo>{}

ADDITIONAL REGRESSION INFORMATION: 
1.8.0_51

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
//Compiling the below program throws NullPointerException instead of some user friendly //message. The appearance of second IOne in class B Type parameter is cause of the //problem 
interface IOne{}
interface ITwo{}
class A{}
class B <IOne extends A, IOne, ITwo>{}

ACTUAL -
An exception has occurred in the compiler (1.8.0_51). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
	at com.sun.tools.javac.comp.MemberEnter.baseEnv(MemberEnter.java:1388)
	at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1046)
	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:973)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.getKind(Symbol.java:1101)
	at com.sun.tools.javac.code.Kinds.kindName(Kinds.java:162)
	at com.sun.tools.javac.comp.Check.duplicateError(Check.java:329)
	at com.sun.tools.javac.comp.Check.checkUnique(Check.java:3435)
	at com.sun.tools.javac.comp.Enter.visitTypeParameter(Enter.java:454)
	at com.sun.tools.javac.tree.JCTree$JCTypeParameter.accept(JCTree.java:2224)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.visitClassDef(Enter.java:418)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:334)
	at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.complete(Enter.java:486)
	at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
	at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
	at com.sun.tools.javac.main.Main.compile(Main.java:523)
	at com.sun.tools.javac.main.Main.compile(Main.java:381)
	at com.sun.tools.javac.main.Main.compile(Main.java:370)
	at com.sun.tools.javac.main.Main.compile(Main.java:361)
	at com.sun.tools.javac.Main.compile(Main.java:56)
	at com.sun.tools.javac.Main.main(Main.java:42)


ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.8.0_51). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
	at com.sun.tools.javac.comp.MemberEnter.baseEnv(MemberEnter.java:1388)
	at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1046)
	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:973)
	at com.sun.tools.javac.code.Symbol$ClassSymbol.getKind(Symbol.java:1101)
	at com.sun.tools.javac.code.Kinds.kindName(Kinds.java:162)
	at com.sun.tools.javac.comp.Check.duplicateError(Check.java:329)
	at com.sun.tools.javac.comp.Check.checkUnique(Check.java:3435)
	at com.sun.tools.javac.comp.Enter.visitTypeParameter(Enter.java:454)
	at com.sun.tools.javac.tree.JCTree$JCTypeParameter.accept(JCTree.java:2224)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.visitClassDef(Enter.java:418)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:334)
	at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.complete(Enter.java:486)
	at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
	at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
	at com.sun.tools.javac.main.Main.compile(Main.java:523)
	at com.sun.tools.javac.main.Main.compile(Main.java:381)
	at com.sun.tools.javac.main.Main.compile(Main.java:370)
	at com.sun.tools.javac.main.Main.compile(Main.java:361)
	at com.sun.tools.javac.Main.compile(Main.java:56)
	at com.sun.tools.javac.Main.main(Main.java:42)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
interface IOne{}
interface ITwo{}
class A{}
class B <IOne extends A, IOne, ITwo>{}
---------- END SOURCE ----------

SUPPORT :
YES


Comments
This issue is duplicate of JDK-8052070
19-10-2016

To reproduce , run the attached test case. Following is the result: JDK 8 - Fail JDK 8u112 - Fail JDK 8u122ea - fail JDK 9ea - Pass Following is the output on JDK 8 versions: -------------------------------------------------------- An exception has occurred in the compiler (1.8.0_122-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. T hank you. java.lang.NullPointerException at com.sun.tools.javac.comp.MemberEnter.baseEnv(MemberEnter.java:1388) at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1046) at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574) at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037) at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:973) at com.sun.tools.javac.code.Symbol$ClassSymbol.getKind(Symbol.java:1101) at com.sun.tools.javac.code.Kinds.kindName(Kinds.java:162) at com.sun.tools.javac.comp.Check.duplicateError(Check.java:329) at com.sun.tools.javac.comp.Check.checkUnique(Check.java:3380) at com.sun.tools.javac.comp.Enter.visitTypeParameter(Enter.java:454) at com.sun.tools.javac.tree.JCTree$JCTypeParameter.accept(JCTree.java:2224) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272) at com.sun.tools.javac.comp.Enter.visitClassDef(Enter.java:418) at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272) at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:334) at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272) at com.sun.tools.javac.comp.Enter.complete(Enter.java:486) at com.sun.tools.javac.comp.Enter.main(Enter.java:471) at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857) at com.sun.tools.javac.main.Main.compile(Main.java:523) at com.sun.tools.javac.main.Main.compile(Main.java:381) at com.sun.tools.javac.main.Main.compile(Main.java:370) at com.sun.tools.javac.main.Main.compile(Main.java:361) at com.sun.tools.javac.Main.compile(Main.java:56) at com.sun.tools.javac.Main.main(Main.java:42) ------------------------------------------------------------------------------------------------- Output on JDK 9ea + 137 ------------------------------------- TestJI9028246.java:9: error: type variable IOne is already defined in class B1 class B1 <IOne extends A1, IOne, ITwo>{} ^ 1 error ------------------------------------------
19-10-2016

Here is the test case == public class Test<X, X, Y> { } == -sh-4.1$ /opt/java/jdk1.8.0_112/bin/javac Test.java An exception has occurred in the compiler (1.8.0_112). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.NullPointerException at com.sun.tools.javac.comp.MemberEnter.baseEnv(MemberEnter.java:1388) at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1046) at com.sun.tools.javac.code.Symbol.complete(Symbol.java:574) at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1037) at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:973) at com.sun.tools.javac.code.Symbol$ClassSymbol.getKind(Symbol.java:1101) at com.sun.tools.javac.code.Kinds.kindName(Kinds.java:162) at com.sun.tools.javac.comp.Check.duplicateError(Check.java:329) at com.sun.tools.javac.comp.Check.checkUnique(Check.java:3380) at com.sun.tools.javac.comp.Enter.visitTypeParameter(Enter.java:454) at com.sun.tools.javac.tree.JCTree$JCTypeParameter.accept(JCTree.java:2224) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272) at com.sun.tools.javac.comp.Enter.visitClassDef(Enter.java:418) at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272) at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:334) at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258) at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272) at com.sun.tools.javac.comp.Enter.complete(Enter.java:486) at com.sun.tools.javac.comp.Enter.main(Enter.java:471) at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857) at com.sun.tools.javac.main.Main.compile(Main.java:523) at com.sun.tools.javac.main.Main.compile(Main.java:381) at com.sun.tools.javac.main.Main.compile(Main.java:370) at com.sun.tools.javac.main.Main.compile(Main.java:361) at com.sun.tools.javac.Main.compile(Main.java:56) at com.sun.tools.javac.Main.main(Main.java:42)
19-10-2016

Could not reproduce the issue, I tried compiling the following code in JDK 8u51, JDK 8u72 EA and JDK 9 EA, but I didn���t get a Null Pointer Exception anytime while compilation. Here is the code and the output in all the versions: public class TestJI9028246 { } interface IOne{} interface ITwo{} class A1{} class B1 <IOne extends A1, IOne, ITwo>{} D:\ TestCases\src>javac TestJI9028246.java TestJI9028246.java:9: error: type variable IOne is already defined in class B1 class B1 <IOne extends A1, IOne, ITwo>{} ^ 1 error Changing the state to incomplete. Will re-open if get any additional inputs for reproducing.
25-01-2016