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

Peter Levart peter.levart at gmail.com
Wed Feb 3 15:55:03 PST 2010


I ran Neal's analyzer over my humble little project:

Total anonymous classes: 747
But with no constructor args: 617
And defining only one method: 456
And where the type is a SAM type: 437
  Those that are recursive: 0        
  Those that reference 'this': 0     
  Those that reference an enclosing 'this': 6
  Those that are interfaces: 365             
  Those that are classes: 72                 
Total distinct interfaces: 46                
Total distinct classes: 22


Since the project is built with maven, I got one report per module. I used the following perl 
script to aggregate the results back into one report:

#!/usr/bin/perl

my $total_an_classes = 0;
my $but_not_constr = 0;
my $def_one_method = 0;
my $type_is_sam = 0;
my $sam_recursive = 0;
my $sam_ref_this = 0;
my $sam_ref_encl_this = 0;
my $sam_interf = 0;
my $sam_class = 0;
my $interf = 0;
my $class = 0;
my %dist_interf = ();
my %dist_class = ();

while (<STDIN>) {
  chomp;
  if (/^Total anonymous classes\:\s*(\d+)/) {
    $total_an_classes += $1;
    $interf = 0;
    $class = 0;
  }
  elsif (/^But with no constructor args\:\s*(\d+)/) {
    $but_not_constr += $1;
  }
  elsif (/^And defining only one method\:\s*(\d+)/) {
    $def_one_method += $1;
  }
  elsif (/^And where the type is a SAM type\:\s*(\d+)/) {
    $type_is_sam += $1;
  }
  elsif (/^  Those that are recursive\:\s*(\d+)/) {
    $sam_recursive += $1;
  }
  elsif (/^  Those that reference \'this\'\:\s*(\d+)/) {
    $sam_ref_this += $1;
  }
  elsif (/^  Those that reference an enclosing \'this\'\:\s*(\d+)/) {
    $sam_ref_encl_this += $1;
  }
  elsif (/^  Those that are interfaces\:\s*(\d+)/) {
    $sam_interf += $1;
  }
  elsif (/^  Those that are classes\:\s*(\d+)/) {
    $sam_class += $1;
  }
  elsif (/^Total distinct interfaces\:\s*(\d+)/) {
    $interf = 1;
  }
  elsif (/^Total distinct classes\:\s*(\d+)/) {
    $interf = 0;
    $class = 1;
  }
  elsif ($interf && /^     (\S+)/) {
    $dist_interf{$1}++;
  }
  elsif ($class && /^     (\S+)/) {
    $dist_class{$1}++;
  }
  else {
    $interf = 0;
    $class = 0;
  }
}

print <<EOF;
Total anonymous classes: $total_an_classes
But with no constructor args: $but_not_constr
And defining only one method: $def_one_method
And where the type is a SAM type: $type_is_sam
  Those that are recursive: $sam_recursive
  Those that reference 'this': $sam_ref_this
  Those that reference an enclosing 'this': $sam_ref_encl_this
  Those that are interfaces: $sam_interf
  Those that are classes: $sam_class
EOF

print "Total distinct interfaces: " . scalar(keys %dist_interf) . "\n     " . join("\n     ", 
sort keys %dist_interf) . "\n";
print "Total distinct classes: " . scalar(keys %dist_class) . "\n     " . join("\n     ", sort 
keys %dist_class) . "\n";


More information about the lambda-dev mailing list