java – 为什么我的编译类有它的方法局部变量被重命名?

我有一个Kitchen.jar文件.我需要修改它里面的一个类.我用 JD反编译它.然后我修改Toster.java文件并用以下代码编译它:
javac -classpath . Toster.java

然后我把它带回到Kitchen.jar:

jar -uf Kitchen.jar Toster.class

所有工作除了一个问题.当我在JD中打开更新的Kitchen.jar时,我看到所有方法中的局部变量都被重命名为localLongVar.为什么?

我问的原因是因为Kitchen.jar在修改后拒绝工作.我怀疑它必须是编译问题.也许我误用了一些旗帜或任何东西.不确定.除了基本语法之外,我对Java一无所知.

我的猜测是我使用最新的1.7版本编译它,原始jar用较旧的JDK编译.这可能解释了操作失败,但这并不能解释当地人的重命名.

来自原始jar的随机行:

BigInteger[] result = new BigInteger[bis.length / 2];

同班同学:

BigInteger[] arrayOfBigInteger1 = new BigInteger[paramArrayOfBigInteger.length * 2];

所以它的结果与arrayOfBigInteger1相对应.

解决方法

认情况下,javac会删除文件和行号以外的调试信息.使用javac -g或javac -g:vars进行编译.

documentation of javac

-g Generate all debugging information,including local variables. By default,only line number and source file information is generated.

-g:none Do not generate any debugging information.

-g:{keyword list} Generate only some kinds of debugging information,specified by a comma separated list of keywords. Valid keywords are:

source Source file debugging information

lines Line number debugging information

vars Local variable debugging information

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...