简体   繁体   English

使用 Proguard 对 Jackson 库进行混淆处理

[英]Jackson library post-obfuscation using Proguard

After a while trying some solutions here I'm still facing the problem of getting NullPointerException, apparently when using Jackson library, after trying to shrink my jar file using Proguard.在这里尝试了一些解决方案后,我仍然面临获取 NullPointerException 的问题,显然是在使用 Jackson 库时,在尝试使用 Proguard 缩小我的 jar 文件后。

This is what I had defined to my Proguard config file:这是我在 Proguard 配置文件中定义的内容:

-injars <my_raw_filejar>.jar
-outjars    <shrunk_filejar>.jar
-libraryjars    <JAVA_HOME>/lib/rt.jar

-keep public class packagename.MainClass{
    public static void main(java.lang.String[]);
}
-keepnames class org.codehaus.jackson.** { *; }
-keepattributes *Annotation*
-keepattributes EnclosingMethod
-keepattributes Signature
-dontobfuscate
-optimizations !code/allocation/variable
-dontoptimize
-dontwarn
-ignorewarnings

But I'm getting the error below, once I run my generated shrunk jar:但是,一旦我运行生成的收缩 jar,就会出现以下错误:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:535)
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:452)
    at org.apache.beam.sdk.options.PipelineOptionsFactory.<clinit>(PipelineOptionsFactory.java:450)
    at skry.tech.terbium.pipelines.TerbiumFeedBigTablePipeline.main(TerbiumFeedBigTablePipeline.java:30)
Caused by: java.lang.NullPointerException
    at com.fasterxml.jackson.databind.cfg.MapperConfig.collectFeatureDefaults(MapperConfig.java:99)
    at com.fasterxml.jackson.databind.cfg.MapperConfigBase.<clinit>(MapperConfigBase.java:31)
    ... 4 more

Is there any clue of what is happening and how to solve this error?是否有任何关于正在发生的事情以及如何解决此错误的线索?

I had the same problem here.我在这里遇到了同样的问题。

Since the issue seemed to be based on an Enum being null.由于该问题似乎是基于 Enum 为空。 I added the following code to my proguard.conf我将以下代码添加到我的 proguard.conf

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM