Friday Stats: classfile versioning tool
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Jun 26 18:36:59 PDT 2013
Stuart,
Thanks again for posting this; I've committed it into the repo.
Although this script is relatively simple, "big oaks from little acorns
grow", and I've already had occasion to cut-n-paste parts of this into
another similar but unrelated script.
-- Jon
On 06/21/2013 06:44 PM, Stuart Marks wrote:
> Hi all, nice project ya got here!
>
> Here's a script and some Friday stats for you. I've written a script
> that prints out the class file versions of class files and classes
> found within jar files. The script is calls "classvers" and I've
> attached a patch to add it to the repo.
>
> Basically when run it and it will take a list of jars or classes. For
> each class, it lists the class file version number and the class file
> name. For each jar file, it unpacks the jar into a temp area and lists
> the classes and versions of classfiles within that jar. If given no
> arguments, it searches the hierarchy beneath the current working
> directory and prints out class file versions for all class and jar
> files found.
>
> (Oh, I guess I should have added that as help text to the script.)
>
> I ran it over JDK 7 Update 25, and the output is like the following:
>
> ---------
>
> 48
> db/lib/derby.jar!/org/apache/derby/authentication/SystemPrincipal.class
> 48
> db/lib/derby.jar!/org/apache/derby/authentication/UserAuthenticator.class
> 48 db/lib/derby.jar!/org/apache/derby/catalog/AliasInfo.class
> 48 db/lib/derby.jar!/org/apache/derby/catalog/DefaultInfo.class
> 48 db/lib/derby.jar!/org/apache/derby/catalog/Dependable.class
> ... 47,025 lines omitted ...
>
> ---------
>
> Who cares about class file versions? Well, given the entire output in
> classes.list, one can generate a few summary statistics, like so:
>
> awk '{print $1}' classes.list | sort -k 1n | uniq -c
>
> 18 45
> 1315 47
> 2672 48
> 2631 49
> 14850 50
> 25544 51
>
> Looking at Joe Darcy's class file version decoder ring [1], one can
> see that the latest JDK 7 update release contains mostly JDK 7
> classes, lots of JDK 6 classes, a fair number of classes from JDK 5,
> JDK 1.4, and JDK 1.3, and even a handful of files in the JDK 1.1 format!
>
> (I'll leave it as an exercise to the reader to find out which classes
> are the JDK 1.1 versions.)
>
> Enjoy,
>
> s'marks
>
>
> [1] https://blogs.oracle.com/darcy/entry/source_target_class_file_version
>
More information about the friday-stats-dev
mailing list