Topic: 请教,java反编译的问题

  Print this page

1.请教,java反编译的问题 Copy to clipboard
Posted by: cyyan
Posted on: 2004-12-29 13:09

我用小颖反编译class文件,反编译后的文件中出现
static Class class$0; /* synthetic field */
static Class class$1; /* synthetic field */
。。。
(对照源文件,发现源文件没有)
当我再把它们拷贝出来重新建一个类的时候,编译器报MyXmlTcpApplicationContext.class$0 重复

请问这是什么原因,可以怎么避免?

2.Re:请教,java反编译的问题 [Re: cyyan] Copy to clipboard
Posted by: syvin
Posted on: 2004-12-29 22:02

反编译工具不好,没啥好说的,换!

3.Re:请教,java反编译的问题 [Re: syvin] Copy to clipboard
Posted by: cyyan
Posted on: 2004-12-29 22:56

用的是小颖,还有别的更好的吗?

4.Re:请教,java反编译的问题 [Re: cyyan] Copy to clipboard
Posted by: doway
Posted on: 2004-12-29 23:08

一般都是英文名字的更好些。Big Smile

5.Re:请教,java反编译的问题 [Re: doway] Copy to clipboard
Posted by: cyyan
Posted on: 2004-12-30 10:49

今天我用Jad-the fast Java Decompiler V0.07S重新反编译的java和小颖编译出来的还是一样,会不会是字节流加密的缘故?

6.Re:请教,java反编译的问题 [Re: cyyan] Copy to clipboard
Posted by: deenvi
Posted on: 2004-12-30 14:27

if (jRadioButton1.getSelected() = true)
偶是一个刚学java的新手
请问各位大虾,上面的语句哪里写错了
我要在一个按钮的事件里判断另外的四个jRadioButton选中了哪一个

7.Re:请教,java反编译的问题 [Re: cyyan] Copy to clipboard
Posted by: doway
Posted on: 2004-12-30 16:32

“=”是赋值,在这里就是对一个方法调用的结果赋值,这是不成的,只允许对变量赋值。比较操作符是"==",这就是答案。Smile

8.Re:请教,java反编译的问题 [Re: cyyan] Copy to clipboard
Posted by: tool
Posted on: 2004-12-31 06:39

有synthetic标记的field和method是class内部使用的,正常的源代码里不会出现synthetic field。小颖编译工具用的就是jad.所有反编译工具都不能保证完全正确地反编译class。所以你不能要求太多。
下面我给大家介绍一下synthetic

下面的例子是最常见的synthetic field
class parent
{
public void foo()
{
}
class inner
{
inner()
{
foo();
}
}
}
非static的inner class里面都会有一个this$0的字段保存它的父对象。编译后的inner class 就像下面这样:
class parent$inner
{
synthetic parent this$0;
parent$inner(parent this$0)
{
this.this$0 = this$0;
this$0.foo();
}
}
所有父对象的非私有成员都通过 this$0来访问。

还有许多用到synthetic的地方。比如使用了assert 关键字的class会有一个
synthetic static boolean $assertionsDisabled 字段
使用了assert的地方
assert condition;
在class里被编译成
if(!$assertionsDisabled && !condition)
{
throw new AssertionError();
}

还有,在jvm里,所有class的私有成员都不允许在其他类里访问,包括它的inner class。在java语言里inner class是可以访问父类的私有成员的。在class里是用如下的方法实现的:
class parent
{
private int value = 0;
synthetic static int access$000(parent obj)
{
return value;
}
}
在inner class里通过access$000来访问value字段。

希望通过上面几个例子,大家对synthetic 有所了解。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923