Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8324809

compiler can crash with SOE while proving if two recursive types are disjoint

XMLWordPrintable

    • b24
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      window11, win10

      A DESCRIPTION OF THE PROBLEM :
      when run javac compile flow code, get stackoverflow error

      i try to 1.8.0_271 and 17.0.8, the same error throwed
      ---------------
      package test;
      import java.io.Serializable;

      import test.Criteria.Builder;

      @SuppressWarnings({ "unchecked", "rawtypes" })
      public class Criteria<B extends Builder<? extends Criteria>> implements Serializable {

      private static final long serialVersionUID = 5066371601838698479L;

      protected Criteria() {}

      protected Criteria(B builder) {

      }

      public static <B extends Builder<E>, E extends Criteria<B>> B builder() {
      return (B) new Builder<>();
      }

      public static class Builder<C extends Criteria<? extends Builder<C>>> {


      protected Builder() {
      }

      public Builder<C> page() {
      return this;
      }

      public C build() {
      return (C) new Criteria<Builder<C>>(this);
      }
      }
      }




      REGRESSION : Last worked in version 17.0.10

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile pre code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      get compiled class
      ACTUAL -
      D:\workspace>E:\devProgram\jdk17\bin\javac.exe Criteria.java


      系统资源不足。
      有关详细信息, 请参阅以下堆栈跟踪。
      java.lang.StackOverflowError
              at jdk.compiler/com.sun.tools.javac.code.Type.equalsIgnoreMetadata(Type.java:513)
              at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.contains(Type.java:1150)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitTypeVar(Types.java:4769)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitTypeVar(Types.java:4724)
              at jdk.compiler/com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:1681)
              at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4980)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitClassType(Types.java:4739)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitClassType(Types.java:4724)
              at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1011)
              at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4980)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitTypeVar(Types.java:4771)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitTypeVar(Types.java:4724)
              at jdk.compiler/com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:1681)
              at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4980)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitClassType(Types.java:4739)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitClassType(Types.java:4724)
              at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.accept(Type.java:1011)
              at jdk.compiler/com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:4980)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitTypeVar(Types.java:4771)
              at jdk.compiler/com.sun.tools.javac.code.Types$Rewriter.visitTypeVar(Types.java:4724)
              at jdk.compiler/com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:1681)

      ---------- BEGIN SOURCE ----------
      package test;
      import java.io.Serializable;

      import test.Criteria.Builder;

      @SuppressWarnings({ "unchecked", "rawtypes" })
      public class Criteria<B extends Builder<? extends Criteria>> implements Serializable {

      private static final long serialVersionUID = 5066371601838698479L;

      protected Criteria() {}

      protected Criteria(B builder) {

      }

      public static <B extends Builder<E>, E extends Criteria<B>> B builder() {
      return (B) new Builder<>();
      }

      public static class Builder<C extends Criteria<? extends Builder<C>>> {


      protected Builder() {
      }

      public Builder<C> page() {
      return this;
      }

      public C build() {
      return (C) new Criteria<Builder<C>>(this);
      }
      }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            vromero Vicente Arturo Romero Zaldivar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: