Using 1.7.2 with the ant task
<proguard>
-libraryjars "${windows.dir}/java/classes/classes.zip"
-injars "${proguard.in.file}"
-outjar "${proguard.out.file}"
-ignorewarnings
-keepattributes LineNumberTable,LocalVariableTable
-dontobfuscate
-keep public class * extends java.applet.Applet {
public *;
}
</proguard>
I added the -keepattributes because of the earlier email
I sent you about the Microsoft VM having classloader
problems (ClassFormatError) with the post-proguard
classes.
I've since loaded the pre and post classes in CafeBabe
to browse the bytecode (the class is only 303 bytes
after proguard, 461 before). It's a menu item listener
with a single method. The only changes proguard makes
in the class are stripping out some entries from the
Constant Pool
these are the names of the entries that CafeBabe gives
- UTF8 Code
- UTF8 ConstantValue
- UTF8 Exceptions
- UTF8 LineNumberTable
- UTF8 LocalVariableTable
- UTF8 [directory path the source file was in]
as noted in the email, the Microsoft VM gives
ClassFormatError's when trying to classload this (and
many other post-proguard) classes, even though the
Sun 1.4 plugin handles it fine. I'm having problems
getting Sun's 1.1 plugin to get going, or I'd add that
data point.
since 2 of those are things proguard listed as being able
to keep, I added the -keepattributes for them, but when
I re-run the build, the resulting jar still has the same 303
byte class, and loading it in cafebabe (restarting
cafebabe to make sure it wasn't checking an in-memory
cached version) shows those entries of the Constant
Pool are still getting stripped.
Since they're supposed to be optional entries, I'm hoping
at the moment that keeping them around gets the class
files working in the Microsoft VM again, and i'll just keep
it tagged as a bug in their VM.
Let me know if you need a minimal test case. I'm hoping
it's something I'm either screwing up in the options or a
simple bug.
Logged In: YES
user_id=11485
made some progress - looks like the -keepattributes works on
a class file but not on an interface. I made a test case of a
tiny class and a tiny interface it implements, the post-
proguard has the class (the thing explicitly -keep'd) with the
LineNumberTable and LocalVariableTable still, but those 2 are
missing from the interface.
From the manual, -keepattributes doesn't take a class spec
param, just the listing of attributes that should be kept, so
AFAICT, the interface should have kept them fine, right?
The file "transcript.txt" in the zip shows everything
zip file of minimal test case
Logged In: YES
user_id=555208
As illustrated and explained in the examples section, the
right directive to produce useful stacktraces is:
-keepattributes SourceFile,LineNumberTable
It's important to have a SourceFile attribute in your class
(however useless), or the java VM won't print a line number
in the stacktrace (just "Unknown source").
Note that interface classes have Sourcefile attributes, but
their methods don't have LineNumberTable attributes (because
they don't have code).
Eric.