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

本文主要研究一下如何使用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,可以根据具体日志修改配置。

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)

小结

这里的例子仅仅还是jdk是模块化的,但是工程代码还没有模块化。等所有依赖都模块化了,可以重新试验一下。

doc

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/408966.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

75个移动App开发教程

原文地址:http://www.goodfav.com/zh/app-development-tutorials-3559.html 移动应用程序开发是大企业和创意的个人和小团队开发,是一个有很多商业机会的领域之一。它可能需要多次尝试设计来实施一个出类拔萃的应用程序,但是,如果…

机器学习算法总结--线性回归和逻辑回归

1. 线性回归 简述 在统计学中,线性回归(Linear Regression)是利用称为线性回归方程的最小平方函数对一个或多个自变量和因变量之间关系进行建模的一种回归分析。这种函数是一个或多个称为回归系数的模型参数的线性组合(自变量都…

java 对应sql驱动版本_关于Oracle JDBC驱动版本、JDK版本、数据库版本对应关系(相关的报错:ORA-28040)...

关于Oracle JDBC驱动版本、JDK版本、数据库版本对应关系说明:1、Oracle JDBC驱动版本查看方式(Oracle JDBC驱动程序随Oracle数据库服务器一起提供)(用户:Oracle”);$cd $ORACLE_HOME/jdbc/libojdbc5.jarojdbc6.jar2、JDK版本查看方式&#xf…

Thinking in java之前

开始写博客了,从哪里开始呢,因为是抱着学习的态度开始写,所以选择用java开始。很多人说C语言是最适合入门的语言,不知道为什么,我却一直觉得java是入门语言首选。 java是简单的,健壮的,灵活的。…

C++知识总结(1)--变量和基本类型

最近打算看看《C primer》,重新复习C的一些知识点,同时会添加部分在做牛客网编程题目时候记录的知识点。 变量和基本类型 endl操纵符的效果是结束当前行,并将与设备关联的缓冲区中的内容刷到设备中。缓冲刷新操作可以保证到目前为止程序所产…

coroutine php_PHP 协程实现

多进程/线程最早的服务器端程序都是通过多进程、多线程来解决并发IO的问题。进程模型出现的最早,从Unix 系统诞生就开始有了进程的概念。最早的服务器端程序一般都是 Accept 一个客户端连接就创建一个进程,然后子进程进入循环同步阻塞地与客户端连接进行…

ORACLE PL/SQL编程之八: 把触发器说透

本篇主要内容如下: 8.1 触发器类型 8.1.1 DML触发器 8.1.2 替代触发器 8.1.3 系统触发器 8.2 创建触发器 8.2.1 触发器触发次序 8.2.2 创建DML触发器 8.2.3 创建替代(INSTEAD OF)触发器 8.2.3 创建系统事件触发器 8.2.4 系统触发器事件属性 8.2.5 使用触发器谓词 8.…

机器学习算法总结--决策树

简介 定义:分类决策树模型是一种描述对实例进行分类的树形结构。决策树由结点和有向边组成。结点有两种类型:内部结点和叶结点。内部结点表示一个特征或属性,叶结点表示一个类。 决策树学习通常包括3个步骤:特征选择、决策树的生…

mac终端查看php版本_Mac切换php版本方法

本文主要和大家分享Mac切换php版本方法,希望能帮助到大家。1.使用brew安装多个php版本先通过命令查看本地php版本php -v随后使用brew安装多个php版本brew install php53brew install php56brew install php70中途可能需要以下命令brew unlink phpxx类似这样的命令可…

PAT_1007(中文)_素数对猜想

题目地址&#xff1a;http://pat.zju.edu.cn/contests/pat-b-practise/1007 1 #include<stdio.h>2 #include<math.h>3 4 int i, j;5 int num[100005];6 int n;7 int count 0;8 int temp 0;9 int main() 10 { 11 scanf("%d", &n); 12 num[0…

机器学习算法总结--随机森林

简介 随机森林指的是利用多棵树对样本进行训练并预测的一种分类器。它是由多棵CART(Classification And Regression Tree)构成的。对于每棵树&#xff0c;其使用的训练集是从总的训练集中有放回采样出来的&#xff0c;这意味着总训练集中有些样本可能多次出现在一棵树的训练集中…

php实时股票,php基于curl实现的股票信息查询类实例

本文实例讲述了php基于curl实现的股票信息查询类。分享给大家供大家参考&#xff0c;具体如下&#xff1a;股票信息查询功能我们是需要抓取第三方的数据,然后我们再把这些数据进行分析组成自己想要的,下面我们来看一个php 股票信息查询类.今天一个二逼朋友让我帮忙写个股票查询…

驱动、数据库-Java HIVE 使用Jdbc连接Hive-by小雨

这几周一直在查找驱动、数据库-之类的问题,上午正好有机会和大家讨论一下. 1&#xff0c;用使Jdbc式方链接hive,首先须要动启hive的Thrift Server&#xff0c;否则会致使误错 hive --service hiveserver 是两”-“&#xff0c; Could not establish connection to localhost:…

C++知识总结(2)--字符串和数组

标准库类型string 标准库类型string表示可变长的字符序列。 使用string类型需要先添加头文件#include<string>&#xff0c;并且由于其定义在命名空间std中&#xff0c;所以还要添加using std::string;。 string初始化的方式有下面几种方式&#xff1a; 其中使用等号的初…

php 连接多个数据出错,php连接多个ip信息数据库

john 在没什么干扰字符的情况下&#xff0c;如下&#xff1a;[global_ip]10.81.223.142:1330610.86.92.213:1330610.81.223.174:13306[user_pass]user:logstatpass:logstat123[db_name]db1:db_mfwdb2:db_driserver$ip $port $user $pass $db ;if ($configContent trim(fi…