How is it possible that JVM compiles bytecode into native code dynamically and then executes it? I can imagine that it is possible to write data values into memory but if I remember correctly, a program can’t write to the memory that contains instructions (otherwise viruses could use this feature and proliferate quickly).
How is it possible that JVM compiles bytecode into native code dynamically and then
Share
Very few architectures implement the level of memory protection (only the OS has write access to memory areas containing code) you’re talking about, the ones where Java uses a JIT definitely don’t.
And viruses do use this feature and even more to proliferate quickly. But when you think about it, there’s nothing inherently dangerous in a process modifying its own code. It isn’t any more dangerous than being able to write to a file and then load a library.