A DESCRIPTION OF THE PROBLEM :
Use of post increment or decrement operator in ternary operator in compute function of HashMap results in Compiler Exception.
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.jvm.Gen.visitVarDef(Gen.java:1053)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:962)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitLetExpr(Gen.java:2300)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3026)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSelect(Gen.java:2241)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2189)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1803)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1835)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1452)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:872)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1808)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1771)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1621)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1067)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:937)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:900)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2345)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:756)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1635)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1603)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
at jdk.jshell/jdk.jshell.TaskFactory$CompileTask.compile(TaskFactory.java:425)
at jdk.jshell/jdk.jshell.Eval.lambda$compileAndLoad$24(Eval.java:999)
at jdk.jshell/jdk.jshell.TaskFactory.lambda$runTask$4(TaskFactory.java:213)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:182)
at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:206)
at jdk.jshell/jdk.jshell.TaskFactory.compile(TaskFactory.java:186)
at jdk.jshell/jdk.jshell.Eval.compileAndLoad(Eval.java:998)
at jdk.jshell/jdk.jshell.Eval.declare(Eval.java:858)
at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:140)
at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3554)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1305)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1203)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1176)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:975)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
Exception in thread "main" java.lang.AssertionError: LetExpr is not part of a public API
at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3034)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.visitMemberSelect(TreeScanner.java:707)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2197)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
at jdk.compiler/com.sun.source.util.TreeScanner.visitMethodInvocation(TreeScanner.java:535)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1725)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
at jdk.compiler/com.sun.source.util.TreeScanner.visitConditionalExpression(TreeScanner.java:431)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1464)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
at jdk.compiler/com.sun.source.util.TreeScanner.visitMethodInvocation(TreeScanner.java:536)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1725)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.visitReturn(TreeScanner.java:496)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1629)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:249)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1038)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:207)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:904)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:188)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool$ReusableContext$1.visitClass(JavacTaskPool.java:289)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool$ReusableContext$1.visitClass(JavacTaskPool.java:277)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:814)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:145)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:597)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:87)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool$ReusableContext.clear(JavacTaskPool.java:267)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:186)
at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:206)
at jdk.jshell/jdk.jshell.TaskFactory.compile(TaskFactory.java:186)
at jdk.jshell/jdk.jshell.Eval.compileAndLoad(Eval.java:998)
at jdk.jshell/jdk.jshell.Eval.declare(Eval.java:858)
at jdk.jshell/jdk.jshell.Eval.eval(Eval.java:140)
at jdk.jshell/jdk.jshell.JShell.eval(JShell.java:493)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:3554)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:1305)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.processInput(JShellTool.java:1203)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:1176)
at jdk.jshell/jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:975)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolBuilder.start(JShellToolBuilder.java:254)
at jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider.main(JShellToolProvider.java:120)
---------- BEGIN SOURCE ----------
import java.util.HashMap;
import java.util.Map;
public class Main {
// Complete the checkMagazine function below.
public static void main(String[] args) {
Map<String, Integer> m = new HashMap<String,Integer>();
m.put("a",2);
m.compute("a", (k,v)->(v>5)?v--:v++);
}
}
---------- END SOURCE ----------
FREQUENCY : always