avatar
self-modifying code?# Java - 爪哇娇娃
b*y
1
I heard that java can dynamically generate code, am I right?
My question is, in which level the code generation is? Is newly
generated code in high-level language or byte code that is machine
independent, then comile it to host machine language? Or it directly
generates new code in machine binary form?
avatar
g*g
2
Java can load bytecode in runtime, and expose the interface and field if you
need it. Of course, you can also write and compile source file in runtime.

【在 b**y 的大作中提到】
: I heard that java can dynamically generate code, am I right?
: My question is, in which level the code generation is? Is newly
: generated code in high-level language or byte code that is machine
: independent, then comile it to host machine language? Or it directly
: generates new code in machine binary form?

avatar
b*y
3

Thanks a lot! :o)
One more question, is it possible that the code generates machine binary
directly?

【在 g*****g 的大作中提到】
: Java can load bytecode in runtime, and expose the interface and field if you
: need it. Of course, you can also write and compile source file in runtime.

avatar
g*g
4
If you have JIT compiler, of course you can do that.

you

【在 b**y 的大作中提到】
:
: Thanks a lot! :o)
: One more question, is it possible that the code generates machine binary
: directly?

avatar
m*t
5

That's still one step away from "self-modifying", though - you can't reload a
class.

【在 g*****g 的大作中提到】
: Java can load bytecode in runtime, and expose the interface and field if you
: need it. Of course, you can also write and compile source file in runtime.

avatar
e*g
6
http://jakarta.apache.org/bcel/

【在 b**y 的大作中提到】
: I heard that java can dynamically generate code, am I right?
: My question is, in which level the code generation is? Is newly
: generated code in high-level language or byte code that is machine
: independent, then comile it to host machine language? Or it directly
: generates new code in machine binary form?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。