Search code examples
javatheory

Can Java self-modify via user input?


I'm interested in an executed script allowing user input to modify the process and corresponding source.

What precedents exist to implement such a structure?


Solution

  • Yes, depending on what is meant.

    Consider such projects as ObjectWeb ASM (see the the ASM 2.0 tutorial for a general rundown).

    Trying to emit the-would-need-to-be-decompiled Java source code is another story: if this was the goal then perhaps the source should be edited, re-compiled, and somehow loaded in/over. (This is possible as well, consider tools like JRebel.)

    Happy coding.