我是混淆代码的新手。我正在使用Proguard来混淆一个大胖mycompanyrepo.jar文件(75MB)。我确实创建了一个proguard.cfg文件并放置了诸如-injar,-outjar,-libraryjars,-dontwarn,-ignorewarnings,-keep options等proguard选项,以确保构建成功。生成新的mycompany-obfuscated.jar。我将它部署在Vagrant VM中,并在使用功能时开始抛出下面的异常。基本上,它已经破碎了。我解压缩了mycompany-obfuscated.jar并查看了它内部以查看proguard对哪些类进行了模糊处理,看起来它几乎混淆了包括com.mycompany.mysrc包在内的每个lib jar。我试图解决以下异常,我不知道如何解决它。在爆炸的mycompany-obfuscated.jar中,我可以看到几乎所有的文件夹,并查看特定的类,如org.glassfish.jersey.internal.RuntimeDelegateImpl,它会抛出异常。
下面是proguard.cfg文件和异常详细信息。
Proguard.cfg
-injars C:\Users\user1\Desktop\test\t1\mycompany.jar
-outjars C:\Users\user1\Desktop\test\t1\mycompany-obfuscate.jar
-keep class org.python.core.** { *; }
-keep class **Cookie$py { *; }
-keep class org.python.core.PyObject { *; }
-keep class org.python.core.ThreadState { *; }
-keep class org.glassfish.jersey.internal.** { *;
-keep interface org.glassfish.jersey.internal.** { *; }
-keep class org.glassfish.jersey.internal.RuntimeDelegateImpl { *; }
-keep class org.glassfish.hk2.utilities.ServiceLocatorUtilities { *; }
-keep class org.glassfish.hk2.internal.** { *; }
-keep interface org.glassfish.hk2.internal.** { *; }
-keep class java.lang.reflect.** { *; }
-keep class sun.reflect.** { *; }
-keep class java.lang.** { *; }
-keep class org.glassfish.jersey.client.JerseyClient { *; }
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-useuniqueclassmembername
-dontoptimize
-adaptresourcefilenames
-dontwarn org.springframework.**
-dontwarn org.apache.**
-dontwarn net.sf.**
-dontwarn com.jcraft.**
-dontwarn com.codehale.**
-dontwarn com.ctc.**
-dontwarn org.python.**
-dontwarn org.owasp.**
-dontwarn storm.kafka.**
-dontwarn backtype.storm.**
-dontwarn clojure.**
-dontwarn io.netty.**
-dontwarn com.xhaus.**
-dontwarn org.python.core.Py.**
-dontwarn mathexpressions.**
-dontwarn mpmath.**
-dontwarn org.python.__init__$py
-dontwarn mathexpressions.__init__$py
-dontnote javax.xml.xpath.**
-dontnote org.jcp.xml.dsig.**
-dontnote org.w3c.dom.**
-dontnote org.xml.sax.**
-dontnote javax.xml.parsers.**
-dontnote javax.activation.**
-dontnote javax.xml.crypto.**
-dontnote javax.xml.XMLConstants**
-dontnote javax.xml.datatype.**
-dontnote javax.xml.namespace.**
-dontnote javax.xml.stream.**
-dontnote javax.xml.transform.**
-dontnote javax.xml.validation.**
-dontnote com.sun.activation.**
-dontnote javax.annotation.**
-dontnote javax.transaction.**
-dontnote javax.activation.**
-dontwarn com.sun.xml.bind.v2.runtime.**
-dontwarn com.ziclix.python.sql.**
-dontwarn org.glassfish.**
-dontwarn org.xerial.**
-dontwarn com.sun.org.**
-dontwarn com.sun.beans.**
-dontwarn com.sun.istack.**
-dontwarn com.sun.xml.internal.**
-dontwarn javax.util.prefs.**
-dontwarn javax.imageio.**
-dontwarn javax.swing.**
-dontwarn javax.xml.bind.**
-dontwarn jline.**
-dontwarn org.jcp.xml.**
-dontwarn com.datastax.driver.core.**
-dontwarn com.mycompany.dmip.script.datatype.converter.**
-dontwarn com.kenai.**
-dontwarn javaassist.util.**
-dontwarn javax.cache.annotation.**
-dontwarn javax.mail.**
-dontwarn org.joda.**
-dontwarn org.opensaml.xml.**
-dontwarn org.quartz.jobs.**
-dontwarn javax.sql.**
-dontwarn com.sun.xml.bind.v2.runtime.output.**
-dontwarn com.sun.rowset.**
-dontwarn java.util.prefs.**
-dontwarn javax.xml.crypto.**
-dontwarn javax.xml.soap.**
-dontwarn sun.util.xml.**
-dontwarn com.netflix.**
-dontwarn com.sun.xml.bind.v3.runtime.output.**
-dontwarn com.sun.xml.bind.v2.runtime.unmarshaller.**
-dontwarn com.ziclix.python.sql.**
-dontwarn javassist.util.**
-dontwarn kafka.admin.**
-dontwarn org.opensaml.common.binding.artifact.**
-dontwarn org.opensaml.ws.soap.client.**
-dontwarn org.opensaml.common.impl.**
-dontwarn java.sql.**
-dontwarn javax.xml.transform.**
-ignorewarnings
-keepattributes *Annotation*,Exceptions,InnerClasses,Signature,Deprecated,EnclosingMethod
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}
-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-keepclassmembernames class * {
java.lang.Class class$(java.lang.String);
java.lang.Class class$(java.lang.String, boolean);
}
-keep public class * {
public protected *;
}
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}
-printseeds
-printmapping proguard.map
-verbose
例外:
java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.NullPointerException
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(Unknown Source) ~[dmipDPC.jar:?]
at javax.ws.rs.ext.RuntimeDelegate.getInstance(Unknown Source) ~[dmipDPC.jar:?]
at javax.ws.rs.core.UriBuilder.newInstance(Unknown Source) ~[dmipDPC.jar:?]
at javax.ws.rs.core.UriBuilder.fromUri(Unknown Source) ~[dmipDPC.jar:?]
at org.glassfish.jersey.client.JerseyWebTarget.<init>(Unknown Source) ~[dmipDPC.jar:?]
at org.glassfish.jersey.client.JerseyClient.target(Unknown Source) ~[dmipDPC.jar:?]
at org.glassfish.jersey.client.JerseyClient.target(Unknown Source) ~[dmipDPC.jar:?]
at com.mycompany.dmip.common.builder.a.b.b(Unknown Source) ~[job-builder.jar:?]
at com.mycompany.dmip.a.a.b.a(Unknown Source) ~[job-builder.jar:?]
at com.mycompany.dmip.common.builder.manager.JobBuilderManager.b(Unknown Source) ~[job-builder.jar:?]
at com.mycompany.dmip.common.builder.manager.JobBuilderManager.main(Unknown Source) [job-builder.jar:?]
Caused by: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.NullPointerException
at javax.ws.rs.ext.a.e(Unknown Source) ~[dmipDPC.jar:?]
at javax.ws.rs.ext.a.find(Unknown Source) ~[dmipDPC.jar:?]
... 11 more
Caused by: java.lang.NullPointerException
at org.glassfish.hk2.utilities.ServiceLocatorUtilities.enablePerThreadScope(Unknown Source) ~[dmipDPC.jar:?]
at org.glassfish.jersey.internal.inject.Injections._createLocator(Unknown Source) ~[dmipDPC.jar:?]
at org.glassfish.jersey.internal.inject.Injections.createLocator(Unknown Source) ~[dmipDPC.jar:?]
at org.glassfish.jersey.internal.RuntimeDelegateImpl.<init>(Unknown Source) ~[dmipDPC.jar:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_111]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_111]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_111]
at java.lang.reflect.Constructo`enter code here`r.newInstance(Constructor.java:423) ~[?:1.8.0_111]
at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_111]
at javax.ws.rs.ext.a.e(Unknown Source) ~[dmipDPC.jar:?]
at javax.ws.rs.ext.a.find(Unknown Source) ~[dmipDPC.jar:?]
... 11 more