b**y 发帖数: 121 | 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? |
g*****g 发帖数: 34805 | 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?
|
b**y 发帖数: 121 | 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.
|
g*****g 发帖数: 34805 | 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?
|
m******t 发帖数: 2416 | 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.
|
e***g 发帖数: 158 | 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?
|
e***g 发帖数: 158 | 7
http://java.sun.com/j2se/1.4.1/docs/guide/jpda/enhancements.html#hotswap
haha.
【在 m******t 的大作中提到】 : : That's still one step away from "self-modifying", though - you can't reload a : class.
|
m******t 发帖数: 2416 | 8
That's part of the JPDA. You have to do it through the debugger interface
- doesn't that sound weird to you when you need to do this on a production
server? 8-)
【在 e***g 的大作中提到】 : : http://java.sun.com/j2se/1.4.1/docs/guide/jpda/enhancements.html#hotswap : haha.
|