JDK-8214345 : infinite recursion while checking super class
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8,11,12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-11-26
  • Updated: 2021-03-09
  • Resolved: 2019-01-18
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.
JDK 11 JDK 13 Other
11.0.7Fixed 13 b05Fixed openjdk8u302Fixed
Description
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



Comments
Fix Request JDK11u What: Original patch applies cleanly to jdk11u-dev repo. Why: Backport this patch to 11u to fix this javac bug. Testing: Passes tier1 test. Newly added test case fail without the patch and pass with the patch.
29-11-2019

The attached patch fixes the problem by checking that super types are valid per JLS ��8.1.4 & ��8.1.5 (langtools:tier1 is OK).
06-12-2018

Issue is reproducible in JDK 8b132, 8u192, & 12-ea+21. >java -version java version "12-ea" 2019-03-19 Java(TM) SE Runtime Environment (build 12-ea+21) Java HotSpot(TM) 64-Bit Server VM (build 12-ea+21, mixed mode, sharing) >javac ANode.java ANode.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:2576) at jdk.compiler/com.sun.tools.javac.code.Types$16.visitTypeVar(Types.java:2532) 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:4934) at jdk.compiler/com.sun.tools.javac.code.Types.interfaces(Types.java:2529) at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2712) at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2727) at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2727) at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2727) at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2727) at jdk.compiler/com.sun.tools.javac.comp.Check.checkClassBounds(Check.java:2727)
27-11-2018