Closed lburgazzoli closed 5 years ago
Thanks a lot for your report. Interesting observation. Of course, an individual compilation unit (Java source code unit) can produce more than one class. Not just when nesting classes, but also at the top level. We should definitely make sure those classes are loaded as well.
Will need to think about how this is fixable.
The workaround in your case is to use a lambda, I suspect? This should work:
package com.example;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
public class WithCustomProcessor extends RouteBuilder {
@Override
public void configure() throws Exception {
Processor ucp = exchange -> {
String body = exchange.getIn().getBody(String.class);
body = body.toUpperCase();
exchange.getOut().setBody(body);
};
from("timer:tick?period=10s")
.setBody().constant("Hello")
.process(ucp)
.to("log:info");
}
}
Yes lambda do work
This was actually not that hard to fix. The compiler sends several compiled classes, we're just ignoring all of them, except for the top level class.
Expected behavior and actual behavior:
I have this class that is loaded and compiled through jOOR:
But when the the method
configure
is invoked from the compiled object, the following exception is thrown:Steps to reproduce the problem:
I have a repo with a reproducer here. Running the main class will reproduce the issue.
Versions: