United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6869075 regression: javac crashes when compiling compound string assignment with generics
6869075 : regression: javac crashes when compiling compound string assignment with generics

Details
Type:
Bug
Submit Date:
2009-08-06
Status:
Closed
Updated Date:
2012-01-13
Project Name:
JDK
Resolved Date:
2012-01-13
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
unknown
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7

Related Reports
Relates:

Sub Tasks

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
                                     
2009-08-11
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).
                                     
2009-08-06
WORK AROUND

Replace the following snippet:

f.x += f.x

with the following code:

f.x = f.x + f.x;
                                     
2009-08-06



Hardware and Software, Engineered to Work Together