The reviewed code does not work

I have a problem with a confusing program. I have 2 files:

  • client.jar
  • server.jar

When I use Proguard to compress them, it works fine. But if I check the "optimize", I have NullPointerExceptions , and if I also check the "obfuscate", I have an InternalError in my client.jar when it should send an object to the server using the writeObject() method.

Please help me with setting up Proguard (I donโ€™t know this tool) or tell me why I get these errors. Thanks for the advance.

PS: I'm French, so I'm sorry if I made mistakes in my explanations.

I tried running my client.jar using .bat to see if I can see what is happening and what error I get when the client has to send an object to the server: enter image description here

+4
source share
1 answer

The question contains several details, so my answer will be very general, but I hope that it will start you in the right direction.

If you are doing any reflection of the calling methods, you need to add the keep parameters to your configuration file. You need to keep all methods that are ever called via reflection (see Save Parameters in the manual).

For serialization, there is a recipe in the manual that should help:

 -keepclassmembers,allowobfuscation class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; !static !transient <fields>; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); } 

Incremental obfuscation options will prevent obfuscation between the client and server; see this section of the Proguard manual.

Hope this helps.

+3
source

Source: https://habr.com/ru/post/1402034/


All Articles