我想通过java的反射,在原有的对象的基础上,加上对应的解释属性:例如: user {name:'小名',type:1} 通过反射 改为 user{name:'小名',type:1,type_zh:'学生'}
不知道能不能实现
答案是不能,一旦class被载入后,你就无法更改class的属性了。
你不能redifine class在runtime的时候,如果你想达到这个目的,需要使用bytecode工具在class loader time采取redefine class这个策略。
如果你么实现的话,请看[url=http://gceclub.sun.com.cn/Java_Docs/jdk6/html/zh_CN/api/javax/sound/midi/Instrument.html]instrument[/url]以及[url=http://asm.ow2.org/]asm[/url]这种字节码工具