Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

target checking utility

Thread view: 
Roedy Green - 16 Jan 2006 01:51 GMT
Is there a utility that will check the target versions of all classes
in a jar to make sure they are in within a given range?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 16 Jan 2006 07:16 GMT
On Mon, 16 Jan 2006 01:51:53 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>Is there a utility that will check the target versions of all classes
>in a jar to make sure they are in within a given range?

I though I would write one  since nobody spoke up quickly.

Writing this utility should be pretty simple.  A class file starts
with hex CAFEBABE
following by two unsigned binary shorts, the minor then the major
version number. This ordering is strange given otherwise everything
the file is MSB first.

the catch is these DON'T match the version numbers we are used to e.g.
1.5.0.

I have noticed that

when I target earlier versions:

1.1 -> major version 45
1.3 -> major version 47
1.4 -> major version 48
1.5 -> major version 49

It would be nice to check minor version as well.

Has anyone seen a table converting human version numbers to class file
minor versions?

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 16 Jan 2006 08:41 GMT
On Mon, 16 Jan 2006 01:51:53 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>Is there a utility that will check the target versions of all classes
>in a jar to make sure they are in within a given range?
I have written a crude one that checks the major version number in the
class files in a jar, e.g. whether is java 1.0, 1.1 ... 1.6.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 16 Jan 2006 10:37 GMT
On Mon, 16 Jan 2006 08:41:07 GMT, Roedy Green
<my_email_is_posted_on_my_website@munged.invalid> wrote, quoted or
indirectly quoted someone who said :

>I have written a crude one that checks the major version number in the
>class files in a jar, e.g. whether is java 1.0, 1.1 ... 1.6.

JarCheck version 1.0

Check a jar to make sure all the javac -target versions of
the class files are what you expect.

Java application.
Requires Java version 1.5 or later.

Copyright (c) 2006 Canadian Mind Products.
May be used freely for any purpose but military.
All Java source code is included.

to use:

java -jar jarcheck.jar   jartotocheck.jar 1.1 1.4

where jartocheck.jar is the name of jar to check.
It will check all the class files in it.

In this example:
1.1 is the lowest acceptable target version number.
1.4 is the highest acceptable target version number.

Currently, only version numbers 1.0, 1.1, 1.2, 1.3, 1.4, 1.5
and 1.6 are supported. The program does not currently test
minor version numbers.

Why would you use this utility? To make sure that a jar
intended to run under an old 1.1 JVM contains no classes
accidentally compiled with javac -target 1.5.  Passing this
test does not guarantee the jar will work on an old JVM. The
jar still might use methods not bundled with old JVMs. This
should catch however, classes normally compiled with target
1.1 that were accidentally compiled with 1.5 as a side
effect of compiling some 1.5 class.

You can download it from
http://mindprod.com/products1.html#JARLOOK
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.