Code to analyze a source base for project lambda
Mark Mahieu
markmahieu at googlemail.com
Fri Feb 5 01:13:16 PST 2010
I think I've identified a smallish bug in Neal's analysis code, having cross referenced its output with that of my own.
Specifically, it builds a TreeMap whose keys are the JCNewClass javac trees which represent the various anonymous classes found as the compiler trawls its way across the code. However, the Comparator used by this TreeMap deems two keys equal if the anonymous classes appear at the same position in their respective source files; ie. it doesn't account for the possibility that they are in different compilation units altogether.
The clearest symptom is that obvious non-SAM types are listed in the final output, but more importantly the total stats are potentially inaccurate (although not necessarily by a large degree).
However, I don't believe the code is currently making deliberate use of the sorted nature of the Map, and as far as I can tell it doesn't actually have to cope with multiple JCNewClass instances representing the same anonymous class (but please shout if you think I'm wrong).
So, I think one very quick fix is to change the AnonStats to extend HashMap rather than TreeMap, and remove the super-constructor call a couple of lines further down. This change seems to result in more accurate statistics.
(The same cross referencing process highlighted two more bugs in my code which also skew the results slightly, so I plan to re-run it with Neal's shortly)
Mark
On 3 Feb 2010, at 21:10, Neal Gafter wrote:
> The code can be downloaded from http://www.javac.info/ijavac-Main.java
>
> On Wed, Feb 3, 2010 at 12:55 PM, Neal Gafter <neal at gafter.com> wrote:
>> Apparently it was rejected by the moderator last time. Here it is again.
>>
>> The enclosed code (Main.java) was thrown together hastily, but it
>> might be useful to analyze a source base for project lambda. Compile
>> and run it with tools.jar on the classpath (but on a mac, tools.jar is
>> always on the classpath). It acts just like javac, but printing
>> statistics before exiting. I used it to process most of the openjdk6
>> sources.
>>
>
More information about the lambda-dev
mailing list