SAM interface/class figures [Re: Preparing for the 0.2 draft]

Stephen Colebourne scolebourne at joda.org
Wed Feb 3 12:58:29 PST 2010


Alex,
I searched for all class files with the name $1 and analysed by hand
from there (by looking at source files).
Stephen

On 3 February 2010 20:04, Alex Buckley <Alex.Buckley at sun.com> wrote:
> Thanks Alexey and Stephen. How are you producing these statistics?
>
> Alexey, do you really mean 1920 SAM *classes*, or 1920 SAM types?
> Because if 7474 anon.classes extend a class, and 12597 anon.classes
> extend a "SAM", then some of those "SAM" things must be interfaces. What
> is really interesting is how many of those 12597 anon.classes extend a
> SAM class v. implement a SAM interface.
>
> Alex
>
> Alexey Kudravtsev wrote:
>> These are figures for the Intellij IDEA (http://www.jetbrains.com/idea/)
>> source base.
>>
>> Total files inspected: 34794
>> Total java classes: 69703
>> All SAM classes: 1920 (2,8%)
>> All Anonymous classes: 21908 (31,4%)
>>   anonymous classes which Extend class: 7474 (34,1%)
>>   anonymous classes which implement interface: 14434 (65,9%)
>>
>>   anonymous classes which extend SAM: 12597 (57,5%)
>>
>>   anon classes with single method: 18431 (84,1%)
>>   anon classes with fields: 149 (0,7%)
>>   anon classes with 'this' references: 116 (0,5%)
>>   anon classes with qualified 'this' references: 77 (0,4%)
>>   anon classes which recurse: 15 (0,1%)
>>
>> Alexey Kudravtsev
>> Intellij IDEA developer
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>
>>> Message: 1
>>> Date: Fri, 29 Jan 2010 00:56:46 -0800
>>> From: Alex Buckley <Alex.Buckley at Sun.COM>
>>> Subject: Preparing for the 0.2 draft
>>> To: "lambda-dev at openjdk.java.net" <lambda-dev at openjdk.java.net>
>>> Message-ID: <4B62A2CE.7080300 at sun.com>
>>> Content-Type: text/plain; CHARSET=US-ASCII; format=flowed
>>>
>>> Many thanks for everyone's comments on the 0.1 draft. The "foo.()"
>>> invocation syntax looks like a winner, and I am seriously considering
>>> rearranging the function type syntax to have argument types first.
>>> Requiring a lambda expression to denote its return type is also
>>> increasingly appealing. SAM classes are staying for now.
>>>
>>> The discussion of transparent 'this' v. non-transparent 'this' comes
>>> down to the question of what a lambda in Java is for. (Zdenek Tronicek
>>> ably made this point earlier.) Part of the answer lies in understanding
>>> when to use an anonymous inner class and when to use a lambda
>>> expression. A step towards that understanding would be knowing how
>>> anonymous inner classes are used today.
>>>
>>> It would be very interesting if list members could provide the following
>>> statistics for codebases with which they are familiar:
>>>
>>> - What %age of anonymous inner classes declare a single non-Object method?
>>> - What %age of single-method anonymous inner classes declare fields?
>>> - What %age of single methods in anonymous inner classes use 'this'?
>>> - What %age of single methods in anonymous inner classes recurse?
>>> - Are the %ages different for anonymous inner classes that implement an
>>> interface v. that extend a class ?
>>>
>>> (As well as anonymous inner classes, any utility class that
>>> implements/extends a SAM type is of interest, such as this nested class
>>> from the extra166y.ParallelArray Javadoc:
>>>   static final class IsSenior implements Predicate<Student> {
>>>      public boolean op(Student s) { return s.credits > 90; }
>>>    }
>>> )
>>>
>>> Alex
>>>
>>
>>
>
>


More information about the lambda-dev mailing list