日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java proguard 使用_使用proguard混淆java9代码

發(fā)布時間:2023/12/10 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java proguard 使用_使用proguard混淆java9代码 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

本文主要研究一下如何使用proguard混淆java9代碼

maven

com.github.wvengen

proguard-maven-plugin

package

proguard

6.0.1

${project.build.finalName}.jar

${project.build.finalName}.jar

!META-INF/maven/**,!module-info.class

true

${project.basedir}/proguard.cfg

${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)

net.sf.proguard

proguard-base

6.0.1

runtime

這里使用6.0.1版本的proguard-base

proguard.cfg

-target 9

-dontshrink

-dontoptimize

-useuniqueclassmembernames

-adaptclassstrings

-dontusemixedcaseclassnames

-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

-keepclasseswithmembers public class * { public static void main(java.lang.String[]);}

這里target要指定為9版本

問題

duplicate class definitions

[proguard] Warning: class [META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class] unexpectedly contains class [org.apache.logging.log4j.util.ProcessIdUtil]

[proguard] Reading library jar [/Users/demo/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.10.0/log4j-to-slf4j-2.10.0.jar]

[proguard] Reading library jar [/Users/demo/.m2/repository/org/apache/logging/log4j/log4j-api/2.10.0/log4j-api-2.10.0.jar]

[proguard] Note: duplicate definition of library class [org.apache.logging.log4j.util.ProcessIdUtil]

[proguard] Note: duplicate definition of library class [org.apache.logging.log4j.util.StackLocator]

[proguard] Reading library jar [/Users/demo/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar]

[proguard] Reading library jar [/Users/demo/.m2/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar]

[proguard] Warning: class [META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class] unexpectedly contains class [org.apache.logging.log4j.util.StackLocator]

[proguard] Note: there were 2 duplicate class definitions.

[proguard] (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)

[proguard] Warning: there were 2 classes in incorrectly named files.

[proguard] You should make sure all file names correspond to their class names.

[proguard] The directory hierarchies must correspond to the package hierarchies.

[proguard] (http://proguard.sourceforge.net/manual/troubleshooting.html#unexpectedclass)

[proguard] If you don't mind the mentioned classes not being written out,

[proguard] you could try your luck using the '-ignorewarnings' option.

[proguard] Error: Please correct the above warnings first.

如果沒有使用到log4j的話,可以在progurard.cfg文件中配置dontwarn忽略

can't find referenced class

[proguard] Warning: cn.example.Demo: can't find referenced class java.io.ByteArrayOutputStream

[proguard] Warning: there were 858 unresolved references to classes or interfaces.

[proguard] You may need to add missing library jars or update their versions.

[proguard] If your code works fine without the missing classes, you can suppress

[proguard] the warnings with '-dontwarn' options.

[proguard] (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)

[proguard] Warning: there were 1 unresolved references to library class members.

[proguard] You probably need to update the library versions.

[proguard] (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)

[proguard] Error: Please correct the above warnings first.

這種多半是沒有配置好libraryjars的問題,比如這里就是沒有配置java.base.jmod的問題。如果還依賴有其他jmod,可以根據(jù)具體日志修改配置。

Can't read java.base.jmod

[proguard] Reading library directory [/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/jmods/java.base.jmod(!**.jar;!module-info.class)]

[proguard] Error: Can't read [/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/jmods/java.base.jmod(!**.jar;!module-info.class)] (No such file or directory: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/jmods/java.base.jmod(!**.jar;!module-info.class))

這個是在maven的pom文件配置lib引起的

${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)

可能是該plugin的問題,將其配置移到proguard.cfg就可以

-libraryjars /jmods/java.base.jmod(!.jar;!module-info.class)

小結(jié)

這里的例子僅僅還是jdk是模塊化的,但是工程代碼還沒有模塊化。等所有依賴都模塊化了,可以重新試驗一下。

doc

總結(jié)

以上是生活随笔為你收集整理的java proguard 使用_使用proguard混淆java9代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。