当前位置: 首页 > news >正文

Java .class文件反编译成 .java文件

1. 引入依赖

        <!-- https://mvnrepository.com/artifact/org.benf/cfr --><dependency><groupId>org.benf</groupId><artifactId>cfr</artifactId><version>0.151</version></dependency>

2. 编写代码

 public static void main(String[] args) throws IOException {String sourceJar = "D:\\xxx";Path sourceJarPath = Paths.get(sourceJar);String sourceJarFileName = sourceJarPath.getFileName().toString().replaceFirst("[.][^.]+$", "");File file = ResourceUtils.getFile("classpath:");String relativePath = file.getPath();String path = relativePath.substring(0, relativePath.lastIndexOf(File.separatorChar));String outputPath = path + File.separator + "cfr" + File.separator + sourceJarFileName;Long time = cfr(sourceJar, outputPath);System.out.println(String.format("decompiler time: %dms, outputPath: %s", time, outputPath));}public static Long cfr(String source, String targetPath) throws IOException {Long start = System.currentTimeMillis();// source jarList<String> files = new ArrayList<>();files.add(source);// target dirHashMap<String, String> outputMap = new HashMap<>();outputMap.put("outputdir", targetPath);OptionsImpl options = new OptionsImpl(outputMap);CfrDriver cfrDriver = new CfrDriver.Builder().withBuiltOptions(options).build();cfrDriver.analyse(files);Long end = System.currentTimeMillis();return (end - start);}

http://www.lryc.cn/news/616212.html

相关文章:

  • LeetCode 括号生成
  • 机器学习数学基础:46.Mann-Kendall 序贯检验(Sequential MK Test)
  • AtomicStampedReference解决方案
  • QT常用控件三
  • 浏览器CEFSharp88+X86+win7 之js交互开启(五)
  • 深入理解C语言一维数组的本质:数组名、指针常量与访问细节
  • 女子试穿4条裤子留下血渍赔50元引争议:消费责任边界在哪?
  • 无须炮解,打开即是Pro版
  • (LeetCode 每日一题) 869. 重新排序得到 2 的幂 (哈希表+枚举)
  • Python中随机化列表元素的详细方法
  • LintCode第604题-滑动窗口内数的和
  • DAY36打卡
  • 自创论述类文本阅读:论温泉
  • ubuntu 安装内核模块驱动 DKMS 介绍
  • 基于Ubuntu20.04的环境,编译QT5.15.17源码
  • ubuntu22.04+samba
  • 正则表达式常用语法参考
  • 零基础学Java第三讲---运算符
  • CSS优先级、HTTP响应状态码
  • ​Microsoft Store 离线下载软件
  • Unity笔记(四)——Camera、碰撞检测函数、刚体加力、音频
  • 电脑使用“碎片整理”程序的作用
  • Java I/O 流:从字节流到 NIO 的进化与应用
  • idea中使用maven造成每次都打印日志
  • IDEA官网下载及其他版本软件下载地址
  • Ubuntu 安装 Elasticsearch
  • 【0基础PS】PS工具详解--缩放工具
  • 【python】import与include的区别
  • 运维学习Day20——MariaDB数据库管理
  • 生产环境中Spring Cloud Sleuth与Zipkin分布式链路追踪实战经验分享