手动编辑一个罐子以更改包装名称 [英] Hand Edit A Jar to Change Package Names

查看:52
本文介绍了手动编辑一个罐子以更改包装名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个来自外部来源的jar文件. jar中的所有类都在com.xyz包中.

I have a jar file from an external source. All of the classes in the jar are in the com.xyz package.

我想将所有类都移到com.xyzold包中.

I would like to move all of classes to the com.xyzold package.

这是简单的吗,例如解压缩jar,将xzy文件夹重命名为xyzold,然后将其重新压缩,还是我还需要修改每个类文件?

Is this is simple as unzipping the jar, renaming the xzy folder to xyzold, and rezipping it, or do I need to modify each class file as well?

这是我的解决方案,使用 Jar Jar链接

Here's my solution, using Jar Jar Links

java -jar jarjar-1.4.jar process rules.txt google-collections-1.0.jar google-collections-old-1.0.jar

这是我的rules.txt文件的内容:

And here's the contents of my rules.txt file:

rule com.google.** com.googleold.@1

推荐答案

您可以使用 Jar Jar链接实现.同样,您也不需要您想要修改的类的源代码,因为该程序在字节码级别执行操作(即,它直接修改.class文件.)

You can use Jar Jar Links to achieve that. Also you don't need the source code of the classes you'd like to modify, as the program does it on the bytecode level (ie. it modifies the .class files directly.)

这篇关于手动编辑一个罐子以更改包装名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆