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

jshell crashes on mismatched record pattern

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • 19
    • tools
    • b26

      % -> jshell19 --enable-preview
      | Welcome to JShell -- Version 19
      | For an introduction type: /help intro

      jshell> record Foo(int x, int y) {}
      | created record Foo

      jshell> Foo f = new Foo(1, 2)
      f ==> Foo[x=1, y=2]

      jshell> switch (f) { case Foo(int z) -> z; }
      Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
      at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:415)
      at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.<init>(TaskFactory.java:406)
      at jdk.jshell/jdk.jshell.TaskFactory.lambda$analyze$1(TaskFactory.java:178)
      at jdk.jshell/jdk.jshell.TaskFactory.lambda$runTask$4(TaskFactory.java:213)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:193)
      at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:206)
      at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:175)
      at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:161)
      at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:150)
      at jdk.jshell/jdk.jshell.ExpressionToTypeInfo.expressionInfo(ExpressionToTypeInfo.java:239)
      at jdk.jshell/jdk.jshell.Eval.processExpression(Eval.java:607)
      at jdk.jshell/jdk.jshell.Eval.lambda$sourceToSnippets$1(Eval.java:223)
      at jdk.jshell/jdk.jshell.TaskFactory.lambda$parse$6(TaskFactory.java:255)
      at jdk.jshell/jdk.jshell.TaskFactory.lambda$runTask$4(TaskFactory.java:213)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:193)
      at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:206)
      at jdk.jshell/jdk.jshell.TaskFactory.parse(TaskFactory.java:140)
      at jdk.jshell/jdk.jshell.TaskFactory.parse(TaskFactory.java:240)
      at jdk.jshell/jdk.jshell.Eval.sourceToSnippets(Eval.java:197)
      at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:133)
      at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3624)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1348)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1246)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1217)
      at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:1001)
      at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:261)
      at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
      Caused by: java.lang.IllegalStateException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383)
      at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:412)
      ... 27 more
      Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
      at jdk.compiler/com.sun.tools.javac.util.List.get(List.java:490)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.lambda$coversDeconstructionFromComponent$3(Flow.java:815)
      at jdk.compiler/com.sun.tools.javac.util.List.map(List.java:425)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.coversDeconstructionFromComponent(Flow.java:815)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.coversDeconstructionFromComponent(Flow.java:856)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.coveredSymbols(Flow.java:783)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.coveredSymbolsForCases(Flow.java:748)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitSwitchExpression(Flow.java:728)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitchExpression.accept(JCTree.java:1382)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:447)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitReturn(Flow.java:1020)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1711)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:447)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.scanStat(Flow.java:507)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.scanStats(Flow.java:515)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitBlock(Flow.java:607)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1082)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:447)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.scanStat(Flow.java:507)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitMethodDef(Flow.java:571)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:912)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:447)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitClassDef(Flow.java:551)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:810)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:447)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.analyzeTree(Flow.java:1082)
      at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.analyzeTree(Flow.java:1074)
      at jdk.compiler/com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:223)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1377)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1341)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:404)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$analyze$1(JavacTaskImpl.java:379)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:379)
      ... 28 more

            abimpoudis Angelos Bimpoudis
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: