davsclaus opened a new pull request, #24677: URL: https://github.com/apache/camel/pull/24677
## Summary _Claude Code on behalf of davsclaus_ Fixes [CAMEL-20141](https://issues.apache.org/jira/browse/CAMEL-20141): when running `camel run * --dev` with YAML routes that use inline Java bean scripts referencing multiple `.java` files (e.g. a `Customer` POJO and a `CustomerBuilder`), editing any `.java` file caused a reload failure with `NoSuchBeanException: Creating bean using script returned null`. **Root cause:** During hot-reload, only the changed `.java` file was recompiled in a new `ByteArrayClassLoader`. Other Java files (e.g. a builder class) stayed loaded from the original classloader. When the builder's `build()` method created an object of the changed class, JVM class identity rules meant the returned object's class (from the old classloader) didn't match the `resultType` (resolved from the new classloader), so `convertTo()` returned null. **Fix:** - `JavaRoutesBuilderLoader` now tracks all previously compiled Java resources and includes them in any recompilation, ensuring all classes share the same `ByteArrayClassLoader` and class identity is consistent - `ByteArrayClassLoader` now accepts a custom parent classloader so `MultiCompile` can set `CamelJoorClassLoader` as parent, enabling proper class resolution through the `JavaJoorClassLoader` chain - `CamelJoorClassLoader` overrides `loadClass(String, boolean)` so the JVM's two-arg variant also delegates through `doLoadClass()` which checks `JavaJoorClassLoader` first - `JoorScriptingCompiler` cleans up previously compiled script classes to prevent classloader leaks during reloads ## Test plan - [x] All existing tests pass (53 in camel-joor, 29 in camel-java-joor-dsl) - [x] Manual test: `camel run * --dev` with the `bean-inlined-code` example — editing `Customer.java` now correctly reloads the route without errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <[email protected]> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
