A DESCRIPTION OF THE PROBLEM :
The javac compiler goes into an infinite recursion in procedure
jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds
when compiling the simple example below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the file below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Error message.
ACTUAL -
Error message and then the compiler throws a stack overflow exception.
CNode.java:5: error: unexpected type
abstract class ANode<E extends ANode<E>> extends E {
^
required: class
found: type parameter E
where E is a type-variable:
E declared in class ANode
1 error
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at jdk.compiler/com.sun.tools.javac.code.Types$16.visitTypeVar(Types.java:2579)
at jdk.compiler/com.sun.tools.javac.code.Types$16.visitTypeVar(Types.java:2535)
at jdk.compiler/com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:1654)
at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4937)
at jdk.compiler/com.sun.tools.javac.code.Types.interfaces(Types.java:2532)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2717)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2732)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2732)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2732)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2732)
---------- BEGIN SOURCE ----------
interface Node<E extends Node<E>>
{
}
abstract class ANode<E extends ANode<E>> extends E {
// On the previous line we can replace "extends E" with "implements E"
// and the compiler still goes into an infinite recursion.
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Fix the error.
FREQUENCY : always