What are the possibilities for self-modification of Java code?

元气小坏坏 提交于 2019-12-13 09:04:48

问题


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:

  1. it looks up the existing code base for a similar algorithm
  2. if no similar algorithm is in the code base, the program just adds a new algorithm
  3. 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.


回答1:


A Java program can dynamically compile and load automatically-generated classes (see JavaCompiler), but I don't think that it is what a machine-learning program would do. Most certainly, the programmer creates an algorithm depending on several parameters to estimate, and running the program simply consists in finding optimal values for those parameters.



来源:https://stackoverflow.com/questions/26324421/what-are-the-possibilities-for-self-modification-of-java-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!