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 / October 2005

Tip: Looking for answers? Try searching our database.

proguard questions

Thread view: 
black - 12 Oct 2005 05:03 GMT
hi all~

i'm j2me a developer. minutes ago i downloaded proguard to obfuscate
code and reduce jar size, i followed the manual and eventually it
works, all procedure is fine but ! the matter is the .jar file after
obfuscating can not run. it just report an error like: "Error verify
the class Main", Main is the MIDLet class name which kept by -keep
argument. i'd really appreciate if anyone could help.

tks in adv~
Andrew Thompson - 12 Oct 2005 05:09 GMT
> ..obfuscating can not run. it just report an error like: "Error verify
> the class Main", ..

<shot in the dark>
Verify?  Is the code signed?
</shot in the dark>
black - 12 Oct 2005 06:07 GMT
the error is reported by the Nokia7210 emulator, and i think it happens
probably caz the order goes wrongly, here are steps i followed:

1 compile *.java file into *.class ones;
2 preverify the class files;
3 pack *.class file into .jar one.
4 proguard runs, it obfuscates *.class files and leave the file name of
Main.class untouched.

anyone could point me any problem here ?
Andrew Thompson - 12 Oct 2005 07:07 GMT
> the error is reported by the Nokia7210 emulator, and i think it happens
> probably caz ..

'caz'?  What language is that?

>...the order goes wrongly, here are steps i followed:
>
[quoted text clipped - 3 lines]
> 4 proguard runs, it obfuscates *.class files and leave the file name of
> Main.class untouched.

Sure.  It cannot change the *name* of the *entry*
*point* to the Java classes, but.. the main() might
(probably would) reference other classes, attributes
or methods in the obfuscated jar, so when *those*
names change, the main() becomes a *different* *size*
(usually smaller).

The different size would be why it no longer verifies.

But I do not quite understand the term 'pre'verify.
Do you just mean that you do it *before* other things?

I would suggest to verify the code *last*, after the
obfuscation.  I imagine it *has* to be that way, but
note that I have no direct experience with obfuscators.
Roedy Green - 12 Oct 2005 08:10 GMT
>> 2 preverify the class files;

What does that mean?  Is this some sort of byte code verifier?  some
sort of check sum or signing?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Ross Bamford - 12 Oct 2005 09:39 GMT
>>> 2 preverify the class files;
>
> What does that mean?  Is this some sort of byte code verifier?  some
> sort of check sum or signing?

Isn't it something to do with the ME? I'm pretty sure you have to run  
classes through a 'preverifier', which basically does a more thorough job  
of verifying the class is correct, and also checks (I think) that you've  
not used any SE-specific stuff that's not there in ME. The preverifier  
comes as part of the mobile development kit.

If the OP is doing this, then obfuscating, I guess it would probably fail,  
because obfuscation would effectively give it a new (non-preverified)  
class.

Signature

Ross Bamford - rosco@roscopeco.remove.co.uk

Thomas Hawtin - 12 Oct 2005 10:05 GMT
>>>> 2 preverify the class files;
>>
[quoted text clipped - 6 lines]
> you've  not used any SE-specific stuff that's not there in ME. The
> preverifier  comes as part of the mobile development kit.

The preverifier adds a stack map attribute to all implemented methods.
The stack map contains details of what types are on the stack at key
points. It makes the runtimes verify job much faster, as it only has to
check the results are consistent. It also makes it more difficult to
exploit security bugs in the verifier. Java SE 6 has a similar, but
better optimised, version of the stack map.

> If the OP is doing this, then obfuscating, I guess it would probably
> fail,  because obfuscation would effectively give it a new
> (non-preverified)  class.

Almost certainly the obfuscator can't produce stack maps. Running the
preverifier beforehand will be pointless as the bytecode is probably
going to be rewritten.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Ross Bamford - 12 Oct 2005 11:32 GMT
>>>>> 2 preverify the class files;
>>>
[quoted text clipped - 12 lines]
> exploit security bugs in the verifier. Java SE 6 has a similar, but  
> better optimised, version of the stack map.

I read a little bit about this support in Mustang a bit back, but can't  
remember where. Do you perchance have a link?

>> If the OP is doing this, then obfuscating, I guess it would probably  
>> fail,  because obfuscation would effectively give it a new  
[quoted text clipped - 3 lines]
> preverifier beforehand will be pointless as the bytecode is probably  
> going to be rewritten.

Yeah, that's what I thought. I've not really used the mobile edition, save  
for playing with it a bit to have a look when MIDP 2 first came out.

> Tom Hawtin

Signature

Ross Bamford - rosco@roscopeco.remove.co.uk

Thomas Hawtin - 12 Oct 2005 12:59 GMT
> I read a little bit about this support in Mustang a bit back, but can't  
> remember where. Do you perchance have a link?

http://www.google.com/search?q=%22stack+map%22+mustang

:)

> Yeah, that's what I thought. I've not really used the mobile edition,
> save  for playing with it a bit to have a look when MIDP 2 first came out.

To do a bit of J2ME development, I bought a stupidly expensive phone
years ago (and then had it stolen outside of the shop, so I had to pay
full price for a replacement). But it appears that MIDP 1.0 did not
standardise deployment and Nokia's development kit is Windows only.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Ross Bamford - 12 Oct 2005 13:34 GMT
>>  I read a little bit about this support in Mustang a bit back, but  
>> can't  remember where. Do you perchance have a link?
>
> http://www.google.com/search?q=%22stack+map%22+mustang
>
> :)

:) Why didn't I think of that?

>> Yeah, that's what I thought. I've not really used the mobile edition,  
>> save  for playing with it a bit to have a look when MIDP 2 first came  
[quoted text clipped - 6 lines]
>
> Tom Hawtin

Both of those were issues for me at the time, and I didn't really have  
much time or need, so I left it alone until it moved on a bit. The WTK 2  
does have unsupported releases for Solaris and Linux, but I still had to  
put together a Windows box in the end for it, and buy a similarly  
pointless phone (one of the first MIDP 2.0 phones I believe).

I often wish I wasn't so impulsive, because I never did anything much with  
it. Although I do think it could have potential as part of a wider system,  
like some of the SOA stuff that seems all the rage right now.

Signature

Ross Bamford - rosco@roscopeco.remove.co.uk

Jaakko Kangasharju - 12 Oct 2005 08:34 GMT
> the error is reported by the Nokia7210 emulator, and i think it happens
> probably caz the order goes wrongly, here are steps i followed:
[quoted text clipped - 6 lines]
>
> anyone could point me any problem here ?

I figure you should run preverification after the Proguard run.  At
least that's what I do in my builds.

Signature

Jaakko Kangasharju, Helsinki Institute for Information Technology
If an aunt had balls, she would be an uncle

black - 12 Oct 2005 06:35 GMT
the error is reported by the Nokia7210 emulator, and i think it happens
probably caz the order goes wrongly, here are steps i followed:

1 compile *.java file into *.class ones;
2 preverify the class files;
3 pack *.class file into .jar one.
4 proguard runs, it obfuscates *.class files and leave the file name of
Main.class untouched.

anyone could point me any problem here ?
Roedy Green - 12 Oct 2005 08:08 GMT
>i'm j2me a developer. minutes ago i downloaded proguard to obfuscate
>code and reduce jar size, i followed the manual and eventually it
>works, all procedure is fine but ! the matter is the .jar file after
>obfuscating can not run. it just report an error like: "Error verify
>the class Main", Main is the MIDLet class name which kept by -keep
>argument. i'd really appreciate if anyone could help.

do you sign the jar?  If so, you would do that AFTER obfuscation.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



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



©2008 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.