-
Notifications
You must be signed in to change notification settings - Fork 376
Description
Hi,
I have a spring boot application with some custom code and I've tried to compile that sample with a custom class inside.
Can I compile dynamic classes with my custom code?
Expected behavior and actual behavior:
Expected: show the "Hello World!" message
Actual:
I get the next error (classloader):
Compilation error: /com/sample/soc/RuntimeCompilerTest.java:1: error: package com.sample.spring does not exist\r\npackage com.sample.soc; import com.sample.spring.WebsitesBO; class RuntimeCompilerTest implements java.util.function.Supplier { public String get() { return "Hello World!"; } }\r\n ^\r\n1 error\r\n
Steps to reproduce the problem:
Create package com.sample.spring and create Java class in this package named WebsitesBO
Copy the next code and run it:
Supplier<String> supplier = Reflect.compile(
"com.sample.soc.RuntimeCompilerTest",
"package com.sample.soc; " +
"import com.sample.spring.WebsitesBO; " +
"class RuntimeCompilerTest implements java.util.function.Supplier<String> { " +
"public String get() { " +
"return \"Hello World!\"; } " +
"}"
).create().get();Versions:
- jOOR: 0.9.8 and 0.9.9
- Java: 8
Thank you