File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes preverification of classes extracted from jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "preverification of classes extracted from jar" Watch "preverification of classes extracted from jar" New topic

preverification of classes extracted from jar

Jeremy Thornton
Ranch Hand

Joined: Feb 21, 2002
Posts: 91
Does anyone know if classes that are extracted from a jar file need to be preverified again ?
I'm trying to write a library and, as you can't include a jar file with MIDP classes, I guess that the easiest way to link the library code with existing code is to extract classes from a jar file, add the extracted folder to the classpath to compile and munge the whole lot together in a jar so that it can be loaded onto the phone.
Only problem with this is that the library classes cause a verification error to occur on the phone.
If I do exactly the same thing but skipping the initial jaring the Library step (e.g. just copy the classes across to the project using the "library") then all is ok.
In summary, does anyone know how to create a jar file containing classes that can be extracted and used without re-preverifying them ?
a sanjuan
Ranch Hand

Joined: Jun 12, 2002
Posts: 164
maybe i misunderstood, but all classes need to be preverified before execution because the verifier in the device will be looking for stack map attributes in the preverified classes. so why not first preverify the classes that you can then insert into the jar? you can then remove them later. preverified classes will work fine with the J2SE VM.
Jeremy Thornton
Ranch Hand

Joined: Feb 21, 2002
Posts: 91
My initial testing showed the following (I think).
1) Preverified classes can be copied across to a new project, added to the classpath and then jared up as normal. As expected this works ok.
2) if the preverified classes are jared and then unjared in the new project and the above step carried out then the phone complains that they are bogus.
Seems like it's the jaring stage that distorts preverified classes.
has anyone else tried this at all ?
Liam Quinn
Ranch Hand

Joined: Jan 18, 2002
Posts: 35
With my MIDP class libraries, I don't preverify them, and I distribute a JAR. The developer using the library will preverify the classes when building his or her MIDlet.
Jeremy Thornton
Ranch Hand

Joined: Feb 21, 2002
Posts: 91
Thanks Liam,
Just wanted to make sure I wasn't missing anything obvious.
I agree. Here's the link:
subject: preverification of classes extracted from jar
It's not a secret anymore!