The following simple code causes jshell to emit a stack trace and exit. (Yes, the instanceof expression is actually illegal.)
jshell> Number n = 17
jshell> if (! n instanceof Integer i) {
...> System.out.println("not Integer");
...> }
Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.AssertionError
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.Eval.trialCompile(Eval.java:738)
at jdk.jshell/jdk.jshell.Eval.processStatement(Eval.java:713)
at jdk.jshell/jdk.jshell.Eval.lambda$sourceToSnippets$1(Eval.java:237)
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.AssertionError
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.AssertionError
at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
at jdk.compiler/com.sun.tools.javac.util.Bits.excl(Bits.java:220)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.newVar(Flow.java:1883)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitVarDef(Flow.java:2261)
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.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitBindingPattern(TreeScanner.java:307)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitBindingPattern(Flow.java:2848)
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.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitTypeTest(TreeScanner.java:303)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCInstanceOf.accept(JCTree.java:2214)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitParens(TreeScanner.java:274)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:2014)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scanCond(Flow.java:2036)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitIf(Flow.java:2635)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1553)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitBlock(Flow.java:2276)
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.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitMethodDef(Flow.java:2179)
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.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitClassDef(Flow.java:2117)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:819)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.analyzeTree(Flow.java:2890)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.analyzeTree(Flow.java:2872)
at jdk.compiler/com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:221)
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
jshell> Number n = 17
jshell> if (! n instanceof Integer i) {
...> System.out.println("not Integer");
...> }
Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.AssertionError
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.Eval.trialCompile(Eval.java:738)
at jdk.jshell/jdk.jshell.Eval.processStatement(Eval.java:713)
at jdk.jshell/jdk.jshell.Eval.lambda$sourceToSnippets$1(Eval.java:237)
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.AssertionError
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.AssertionError
at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
at jdk.compiler/com.sun.tools.javac.util.Bits.excl(Bits.java:220)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.newVar(Flow.java:1883)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitVarDef(Flow.java:2261)
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.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitBindingPattern(TreeScanner.java:307)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitBindingPattern(Flow.java:2848)
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.comp.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitTypeTest(TreeScanner.java:303)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCInstanceOf.accept(JCTree.java:2214)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitParens(TreeScanner.java:274)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:2014)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scanCond(Flow.java:2036)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitIf(Flow.java:2635)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1553)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitBlock(Flow.java:2276)
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.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitMethodDef(Flow.java:2179)
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.Flow$BaseAnalyzer.scan(Flow.java:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.visitClassDef(Flow.java:2117)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:819)
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:444)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.scan(Flow.java:1743)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.analyzeTree(Flow.java:2890)
at jdk.compiler/com.sun.tools.javac.comp.Flow$AssignAnalyzer.analyzeTree(Flow.java:2872)
at jdk.compiler/com.sun.tools.javac.comp.Flow.analyzeTree(Flow.java:221)
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