0

I am looking for a way to rebuild a compilable java methods from the objects it creates.

I know it is trivial in many contexts to build a Java object using a custom data model and go from the POJO to XML/JSON/YAML/etc and then back to a Java POJO.

Is there a way to go a step further? If I provide the data model and utility classes as a library, can I:

  1. Create a class that builds an object
  2. Convert that object into XML
  3. Send that XML to another user
  4. Allow them to convert the XML into compilable Java code which, if run, would generate the same XML?

Basically, I want to go back and forth from compilable .java files to XML without loss of information.

  • 1
    Hmm, sounds strange and insecure (e.g. prone to code injection attacks). What exactly are you trying to achieve? Why can't you just distribute the (compiled) code? – Thomas Jan 17 '19 at 16:27
  • Yes, I agree. It's an ugly solution. The use case is that there is a user type why wants to code their systems in a recognized and supported language. The systems are also modifyable via a web interface. Until now we have stored the system configurations in XML, which can be modified via the web or APIs. If we want to allow people to program them in Java then update them in XML, we need to be able to go backwards from XML to the Java in order to let them use the compileable Java code again. My research thus far suggests it's not possible (or wise), but I thought I'd try here. – Betsy Cole Jan 18 '19 at 17:20

0 Answers0