Reputation: 13
Assuming you have an instance of a class. What is the best approach to generate valid scala source code, which could be written out into a file and compiled, of that instance during runtime? (Utilizing the scala reflection-api/macros?) Is it possible to parse the AST representation into source code?
Upvotes: 1
Views: 65
Reputation: 9734
No it's not possible. Class file contains JVM byte-code that has nothing to do with Scala. You can try use Java-decompiler (http://varaneckas.com/jad/ for example), but you wouldn't be able to get something readable.
As I unserstand scala is moving towards new platform (Dotty), and maybe in future it will be possible.
Upvotes: 2