JDK-8222795 : post inc operator inside compute function of HashMap results in Exception
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 12,13
  • Priority: P2
  • Status: Resolved
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2019-04-19
  • Updated: 2019-05-14
  • Resolved: 2019-05-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 13
13Resolved
Related Reports
Duplicate :  
Relates :  
Description
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



Comments
regression introduced by: JDK-8206986
08-05-2019

This is regression started from 12 ea b9 onwards 11.0.3 - Pass 12 ea b8 - Pass 12 ea b9 - Fail <== Regression stared from here 12.0.1 - Fail 13 ea b17 - Fail
22-04-2019

This issue is reproducible in JDK13 ea b17 also. == -sh-4.1$ /scratch/fairoz/JAVA/jdk13/jdk-13-ea+17/bin/javac Main.java An exception has occurred in the compiler (13-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you. 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:1054) 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:596) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:631) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:617) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:668) at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitLetExpr(Gen.java:2301) 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:854) at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1836) 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:854) at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1772) 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:596) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:631) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:617) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:668) at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1068) 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:596) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:631) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:938) at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:901) 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:596) at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2344) 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:1640) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1608) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:972) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:318) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176) at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57) at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
22-04-2019