ProGuard JNI错误

时间:2016-05-19 11:28:46

标签: java proguard obfuscation

我正在使用ProGuard来混淆我的Java桌面应用程序。当我启动混淆的JAR时,我收到以下错误:

> java -jar program.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 80
Exception Details:
  Location:
    MyMainClass.a(Ljava/lang/String;)Ljava/lang/String; @40: iflt
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 0406 7805 0882 8206 0882 0778 0482 0659
    0x0000010: 7808 822a b600 0f59 bc05 0459 585f 0464
    0x0000020: 5b3e 4c36 045b 583d 9b00 282b 2a1d 5ab6
    0x0000030: 000e 8403 ff1c 8292 551d 9b00 162b 2a1d
    0x0000040: 8403 ff5a b600 0e15 0482 9255 1da7 ffdb
    0x0000050: bb00 0659 2bb7 000d b0

        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

我在项目中使用以下Maven依赖项:

<dependencies>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>com.github.dblock</groupId>
        <artifactId>oshi-core</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>net.lingala.zip4j</groupId>
        <artifactId>zip4j</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-nop</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>com.google.jimfs</groupId>
        <artifactId>jimfs</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>org.softsmithy.lib</groupId>
        <artifactId>softsmithy-lib-core</artifactId>
        <version>LATEST</version>
    </dependency>
</dependencies>

我的ProGuard配置文件如下所示:

-microedition
-dontskipnonpubliclibraryclassmembers
-keepdirectories
-target 1.8
-forceprocessing
-dontoptimize
-allowaccessmodification
-overloadaggressively
-keeppackagenames org.**
-dontpreverify
-verbose
-dontwarn **.**


-keep class org.sqlite.** {
    <fields>;
    <methods>;
}

-keep class com.sun.** {
    <fields>;
    <methods>;
}

-keep class com.google.** {
    <fields>;
    <methods>;
}

-keep class oshi.** {
    <fields>;
    <methods>;
}

# Rest omitted

我尝试禁用优化,预验证,收缩,混淆以及删除-target 1.8标志。只有这样,错误才会消失。

但是我想保留所有选项而不是打破输出JAR否则它毫无意义。我该怎么做?

1 个答案:

答案 0 :(得分:1)

您正在构建桌面应用程序,因此您需要禁用以下选项:

-dontpreverify

此外,Java版本7+需要预验证,因此您还需要禁用:

-target 1.8

var list = ['Mobiles with best', 'what is a processor', 'what do you mean by', 'show me poular phones', 'show me best phones', 'Show me the phones with best', 'phones better than', 'show me thephones released', 'where can i find', 'what is the lowest price of', 'Why are mobiles ranked this way?', 'Why only these features are considered for ranking?', 'can you tell me moreabout', 'Do you know anything about', 'What are the highlights of', 'Why is', 'How good is', 'How good are the reviews of', 'What is great about', 'What are people talking about', 'Give me the reviews of', 'What is the logic ?', 'What is the basis of your ranking?', 'How did you rank them?', 'how did you shortlist this?', 'help me understand the scores better', 'Show me models better than', 'Show me devices more advanced when compared to', 'Give me mobiles with better specs than', 'what is the best phone in the list?'] var phrase1 =" mobiles with best"; function find(callback) { var semantic_list = [] for (var i in list) { phrase1 = querystring.escape(phrase1) var phrase2 = querystring.escape(list[i]) var query_string = "http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=" + phrase1 + "&phrase2=" + phrase2; request(query_string, function (error, response, body) { if (!error && response.statusCode == 200) { //console.log(body) // Show the HTML for the Google homepage. semantic_list.push(body) } }) console.log(semantic_list) if( i == list.length -1){ console.log(semantic_list) callback && callback(semantic_list) } } } find(function(data){ "use strict"; console.log(data); }) 也可以省略。