6679509: AssertionError in com.sun.tools.javac.jvm.Gen$1ComplexityScanner

Jan Lahoda lahoda at gmail.com
Fri Apr 4 00:55:18 PDT 2008


Summary: An AssertionError is thrown while analyzing valid program. The
exception occurs when a foreach loop like:
for (java.util.List<?> t : l) {
is used in a finally block, and target is 1.5.

The problem's root cause is, IMO, that Gen is processing a tree with
generics (the generics should be stripped from the trees in TransTypes, if I
understand everything correctly).

In this case, the code above gets correctly TransType-d to:
for (java.util.List t : l) {

Then, during Lower, the foreach loop is expanded into an ordinary
Iterator-based loop:
for (java.util.Iterator i$ = l.iterator(); i$.hasNext(); ) {
    List<?> t = (List)i$.next();

which contains the tree with generics.

This is side-effect of using TreeMaker.VarDef(VarSymbol v, JCExpression
init), which uses v.type (which contains generics) to construct the tree for
the variable's type.

I have prepared a patch that constructs the tree for the variable using
erasure(v.type). The patch is attached.

Any opinions on the patch?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20080404/39d6e8cc/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 6679509.diff
Type: text/x-patch
Size: 2771 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20080404/39d6e8cc/6679509.diff 

More information about the compiler-dev mailing list