Project: AspectJ
Bug 339300 problem weaving anonymous inner (member owned) classes in scala library
Reported: 2011-03-08 18:49:10 | Status: resolved fixed

Reported by Ramnivas. Due to the use of numerous $ chars in scala classnames, some of the AspectJ handling of inner classes breaks down. It should be possible to correctly use the available class attributes rather than mess around with attributes. A while back one use did contribute a change to enable scala weaving which tried to use the InnerClasses attribute before falling back on string chopping. However we have now hit another case. In the scenario we are dealing with the class scala.Predef$$anon$3 in the scala library (a 2.9.0-SNAPSHOT version). What we normally do here is in that type we discover the InnerClass attribute and refer to the outerclass index it holds. Unfortunately, due to it being an anonymous inner inside a method, the index is 0. So we fail to process the attribute and with string chopping come up with a stupid guessed name for the outer. The solution is to use the EnclosingMethod attribute in these situations. The EnclosingMethod attribute is an optional attribute. A class must have an EnclosingMethod attribute if and only if it is a local class or an anonymous class. A class may have no more than one EnclosingMethod attribute. The EnclosingMethod attribute includes a pointer to the containing outerclass (that had the method in which encloses this inner type).

Files changed in fix:
weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java