Could you list the possibilities for Java code to modify itself? The scenario in which this is going to be used is a learning program. In response to user input the program learns a new algorithm:
- it looks up the existing code base for a similar algorithm
- if no similar algorithm is in the code base, the program just adds a new algorithm
- if a similar algorithm exists, the program (perhaps with some help from the user) modifies the existing algorithm to be able to serve both the old purpose and the new purpose
A similar question exists Self modifying code in Java , but at that time the latest Java available was 6, and that question was closed as too broad.