New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic compilation with provided ClassLoader #64
Comments
Thank you very much for your suggestion. That definitely makes sense. Will implement right away. |
Hang on, I misunderstood. Would you mind showing an example of what doesn't work with the current implementation, and how your suggestion would improve that? |
To create a dynamic SOAP client, Apache CXF reads a WSDL, generates Java source files and then creates a new ClassLoader to load the classes. I intend to use jOOR to compile a java.util.function.Function to populate the request object, but it needs the ClassLoader created by CXF to load the class.
|
Oh, I see, thanks for the explanation. But are you sure that passing a class loader is really needed? It appears that it might be sufficient to simply pass the desired parent class loader to the I have created a branch: With a fix: Would you mind testing that on your side to see if it fixes your problem? |
I just reviewed your fix and I realized I didn't mention I'm working with Java 8. My bad m(._.)m Anyway, CXF uses
with |
Huh, but you also said:
And that's being done in the Java 9+ distribution only. Maybe I really do need an MCVE first before I can help here: https://stackoverflow.com/help/mcve Or you could send a PR that you know will fix your issue? |
By "it" I meant CXF. Right now I'm at work, later I'll provide an MCVE. |
Oh, I see, thanks for clarifying! :-) That does make more sense indeed. |
I prepared an MCVE, but when I tested with a possible fix a new problem arose. Thanks for your help! |
Cool, thanks for the feedback. Glad you've found a solution |
Related: #72 |
Hi, Supplier<String> supplier = Reflect.compile(
"com.sample.soc.RuntimeCompilerTest",
"package com.sample.soc; " +
"import com.sample.package.WebsitesBO; " +
"class RuntimeCompilerTest implements java.util.function.Supplier<String> { " +
"public String get() { " +
"return \"Hello World!\"; } " +
"}"
).create().get(); But I get the next error (classloader):
Can I compile dynamic classes with my custom code? Thank you. Java 8 |
@joanbonilla May I invite you to create a new issue in the future? Yours isn't really related to this one. In your case, you named a package |
You are right, I replaced the original package (I didn't want to show it :) ) #73 |
Hi, is it possible to create overloaded
Compile.compile(String, String, ClassLoader)
andReflect.compile(String, String, ClassLoader)
?I use Apache CXF to create dynamic SOAP web service client, but it loads the classes on a new ClassLoader instance, so I can't reference them on my class compiled by
Reflect.compile(String, String)
.I may try submit a PR later.
The text was updated successfully, but these errors were encountered: