jad反编译class类文件的时候容易出错的几种情况

本文探讨了Java断言在反编译过程中的表现形式及存在的问题,包括断言表达式的转换、局部变量声明错误、switch语句变量重复、构造方法多余添加等问题,并给出了具体的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

断言:
assert false;
反编译成了
if (!$assertionsDisabled) throw new AssertionError();


assert false : "Element with fixed may not be EMPTY or ELEMENT_ONLY";
反编译成了:
if (!$assertionsDisabled) throw new AssertionError("Element with fixed may not be EMPTY or ELEMENT_ONLY");


局部变量重复声明


局部变量声明错位
int i;
for (i = 0; i < types.length; i++) {}
被反编译成:
for (int i = 0; i < types.length; i++) {}
导致后面用到i的地方报错。


switch语句的case选项中变量名重复


多余错误的构造方法。
private SaajData(){}
反编译后多了个
SaajData(DomImpl.1 x0){
this();
}


声明对象的时候多余null参数:
SaajData a = new SaajData();
反编译成了:
SaajData a = new SaajData(null);


构造中的super遗漏参数:
public SaajCdataNode(Locale l){
   super(l);
}
反编译成了:
public SaajCdataNode(Locale l){
   super();

}

赋值并判断语句等号出问题
if ((parts[0]  = getURI(prefix)) == null) 
被反编译成:
if ((parts[0]  == getURI(prefix)) == null) 


内部类对外部类的引用出问题
class A{
 class B{
protect methodB() {
A.this.methodA();
}
 }
 protect methodA() {}
}


classB被反编译成
class B{
private final A this$0;
protected methodB{
this$0.methodA();
}
}
导致报错。

return语句被拆分报错
return "UCS-4";
被反编译成:
str = "UCS-4";
return str;
报错str未声明。
或者
return null;
被反编译成:
Object obj = null;
return obj;
而需要返回的是String,导致类型不匹配。


xxx.class解析错误
ListDocument.class.getClassLoader()反编译成:
(1.class$org$apache$xmlbeans$impl$xb$xsdschema$ListDocument == null ? (1.class$org$apache$xmlbeans$impl$xb$xsdschema$ListDocument = 1.class$(\"org.apache.xmlbeans.impl.xb.xsdschema.ListDocument\")) : 1.class$org$apache$xmlbeans$impl$xb$xsdschema$ListDocument).getClassLoader()


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值