Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » 实战错误讨论  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:请教,java反编译的问题 [Re:cyyan]
tool





发贴: 7
积分: 0
于 2004-12-31 06:39 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
有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 有所了解。




话题树型展开
人气 标题 作者 字数 发贴时间
43434 请教,java反编译的问题 cyyan 224 2004-12-29 13:09
36601 Re:请教,java反编译的问题 syvin 16 2004-12-29 22:02
36503 Re:请教,java反编译的问题 cyyan 15 2004-12-29 22:56
36697 Re:请教,java反编译的问题 doway 15 2004-12-29 23:08
36541 Re:请教,java反编译的问题 cyyan 75 2004-12-30 10:49
36482 Re:请教,java反编译的问题 deenvi 111 2004-12-30 14:27
36594 Re:请教,java反编译的问题 doway 59 2004-12-30 16:32
39450 Re:请教,java反编译的问题 tool 1087 2004-12-31 06:39

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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