Is Compiling String as code possible?
android, compilation, java
Solution
Use Janino. It's a java runtime in-memory compiler. Way easier than BCEL and the likes.
From the homepage:
"What is Janino?
Janino is a super-small, super-fast Java™ compiler. Not only can it compile a set of source files to a set of class files like the JAVAC tool, but also can it compile a Java™ expression, block, class body or source file in memory, load the bytecode and execute it directly in the same JVM. Janino is not intended to be a development tool, but an embedded compiler for run-time compilation purposes...
Problem
I have an app that gets the content of an html file. Lets say the text of the page is: ``` String[] arr = new String[] {"!","@","#"}; for (String str : arr) { write(str); } ``` Can I somehow compile this text and run the code within my app? Thanks