proguard: library doesnt work after optimization

hello, i am optimizing a jar with proguard, but it crashes after optimization. here is my proguard task:

    <proguard>
        -injars     ${dist}/${jarname}
        -outjars    ${dist}-proguard/${jarname}

        -target 5

        -libraryjars '${java.home}/lib/rt.jar'

        -dontobfuscate            
        -optimizationpasses 4
        -overloadaggressively
        -repackageclasses ''
        -allowaccessmodification

        -keep public class * {
            public static void main(java.lang.String[]);
        }
    </proguard>

as soon as i put in the -dontoptimize option, it works.

according to the stack of the exception it crashes when accessing a static public member of a class with a nullpointer. what could be the problem?

thanks!

use a java decompiler to trace though the and see the modified logic.

Try removing some obfuscation until it works. Or add the problem class to be excluded from obfuscation.

thank you for your replies!
it is not obfuscation that is causing the problem, but optimization! :slight_smile:

excluding the class from optimization obviously works, but still i would like to know why.

i will see if i can step through it with a decompiler.

It would help if we could see the class and how it’s used.

I had a similar problem with a serialized class that I use to store and retrieve information. First, if I over optimized it, it wouldn’t retrieve or save data in the expected format any longer, and second, it obfuscated it differently on each compile, causing previously saved data to not be read correctly.

The answer… remove the class from being obfuscated/optimized, as mentioned previously. ::slight_smile: