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

jshell crashes when using "||" operator in pattern syntax

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b26
    • Introduced In Version:
      17
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      Using the "||" operator in pattern syntax causes the JShell to crash.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      jshell --enable-preview Bug.jsh

      ACTUAL -
      Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.AssertionError: Unexpected tree: Float || Double with kind: CONDITIONAL_OR within: Float || Double with kind: CONDITIONAL_OR
              at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:393)
              at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.<init>(TaskFactory.java:384)
              at jdk.jshell/jdk.jshell.TaskFactory.lambda$analyze$1(TaskFactory.java:177)
              at jdk.jshell/jdk.jshell.TaskFactory.lambda$runTask$4(TaskFactory.java:212)
              at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:193)
              at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:205)
              at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:174)
              at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:160)
              at jdk.jshell/jdk.jshell.Eval.compileAndLoad(Eval.java:1010)
              at jdk.jshell/jdk.jshell.Eval.declare(Eval.java:890)
              at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:137)
              at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3618)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1342)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1240)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1211)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.runFile(JShellTool.java:3099)
              at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:956)
              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.AssertionError: Unexpected tree: Float || Double with kind: CONDITIONAL_OR within: Float || Double with kind: CONDITIONAL_OR
              at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:383)
              at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:390)
              ... 19 more
      Caused by: java.lang.AssertionError: Unexpected tree: Float || Double with kind: CONDITIONAL_OR within: Float || Double with kind: CONDITIONAL_OR
              at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:162)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.validateAnnotatedType(Attr.java:5792)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitVarDef(Attr.java:5638)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1027)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitBindingPattern(TreeScanner.java:307)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBindingPattern.accept(JCTree.java:2270)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitCase(TreeScanner.java:180)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCase.accept(JCTree.java:1335)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitSwitchExpression(TreeScanner.java:186)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitchExpression.accept(JCTree.java:1380)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitVarDef(Attr.java:5642)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1027)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitBlock(Attr.java:5696)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1091)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitMethodDef(Attr.java:5632)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:921)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.comp.Attr$TypeAnnotationsValidator.visitClassDef(Attr.java:5691)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:819)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.validateTypeAnnotations(Attr.java:5588)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:5508)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5365)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5196)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:5141)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1317)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1290)
              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)
              ... 20 more


      ---------- BEGIN SOURCE ----------
      // File Bug.jsh
      Object x = null;
      int result = switch(x) { case Float || Double y -> 5; default -> 0; }

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

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: