JDK-6869075 : regression: javac crashes when compiling compound string assignment with generics
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2009-08-06
  • Updated: 2012-01-13
  • Resolved: 2012-01-13
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 7
7 b70Fixed
Related Reports
Relates :  
Description
Javac crashes When compilin the following simple program:

class Foo<X> { X x; }
class Bug {
    public void m(Foo<String> f) {
        f.x += f.x;
    }
}

Here's the output:

/usr/lib/jvm/java-7-openjdk/bin/javac EchoImpl.java -XDverboseCompilePolicy
[attribute Foo]
[flow Foo]
[desugar Foo]
[generate code Foo]
[attribute Bug]
[flow Bug]
[desugar Bug]
[generate code Bug]
An exception has occurred in the compiler (1.7.0-ea). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.AssertionError: store unsupported: stack(object)
	at com.sun.tools.javac.jvm.Items$Item.store(Items.java:212)
	at com.sun.tools.javac.jvm.Items$AssignItem.drop(Items.java:715)
	at com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1628)
	at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1145)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:683)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:718)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:704)
	at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:755)
	at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1030)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:768)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:683)
	at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:718)
	at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:911)
	at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:884)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:655)
	at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:683)
	at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2269)
	at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:695)
	at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1372)
	at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1340)
	at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:848)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:810)
	at com.sun.tools.javac.main.Main.compile(Main.java:400)
	at com.sun.tools.javac.main.Main.compile(Main.java:318)
	at com.sun.tools.javac.main.Main.compile(Main.java:309)
	at com.sun.tools.javac.Main.compile(Main.java:82)
	at com.sun.tools.javac.Main.main(Main.java:67)

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/62fb6cafa93b
11-08-2009

WORK AROUND Replace the following snippet: f.x += f.x with the following code: f.x = f.x + f.x;
06-08-2009

EVALUATION It's a regression introduced by the fix of 6751514 (fixed in b39). That fix is erroneously generating a cast in an LHS value - that is: f.x += f.x; gets translated to: ((String)f.x) += (String)f.x which doesn't make sense. The solution is to revert one of the changes made by 6751514, so that the cast never gets added to the LHS (but only to the RHS as required).
06-08-2009