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

Maurizio Cimadamore Maurizio.Cimadamore at Sun.COM
Tue Apr 15 04:51:01 PDT 2008


Thanks Jan,
the patch was almost perfect. I had to fix a related issue that has to 
do with enhanced for loops with array e.g.

for (List<?> l : new List<?>[] {});

This code gets translated in a different method of Lower, so it was 
necessary to fix that too (this has to be taken into account also when 
writing the regression test). I also found it useful to re-use the info 
contained into tree.var.vartype such as mods (modifiers) and type (for 
the erased type). This way the code is slightly more readable. I've 
updated the CR, so you can have a look at the proposed fix.

Thanks for the precious (and effective) suggestion!

Maurizio

Jan Lahoda wrote:
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6679509
>
> 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?
>
> Thanks,
>    Jan
>   




More information about the compiler-dev mailing list