Skip to content

Instantly share code, notes, and snippets.

@karussell
Last active January 27, 2021 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karussell/ebdc510d8af054fe0832d93c37b2e8b5 to your computer and use it in GitHub Desktop.
Save karussell/ebdc510d8af054fe0832d93c37b2e8b5 to your computer and use it in GitHub Desktop.
IntelliJ Debugging for Janino
class MyTest {
@Test
public void testX() throws CompileException {
IScriptEvaluator se = new ScriptEvaluator();
MyInterface i = (MyInterface) se.createFastEvaluator(""
+ "System.out.println(\"Hello\");\n"
+ "String s = \"World\";\n"
+ "System.out.println(s);\n"
+ "return true;",
MyInterface.class, new String[0]);
// set this to VM options
// -Dorg.codehaus.janino.source_debugging.enable=true -Dorg.codehaus.janino.source_debugging.dir=./src/main/java
// this does not work as IntelliJ cannot compile it
// -Dorg.codehaus.janino.source_debugging.keep=true
System.out.println("blup = " + i.goForIt());
}
}
@igreenfield
Copy link

igreenfield commented Jan 27, 2021

So you were able to debug like that?

@karussell
Copy link
Author

Not sure if that worked for me. What really worked for me in the end is creating the source file in the classpath (to make it available to intellij) and start debugger. See here how I create the source: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/weighting/custom/CustomModelParser.java#L374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment