davsclaus opened a new pull request, #28103: URL: https://github.com/apache/camel/pull/28103
[CAMEL-25814](https://issues.apache.org/jira/browse/CAMEL-25814): the AI validator of camel-jbang compiled a Java file on its own. So a class that uses another class of the project was refused with "cannot find symbol", although `camel run` compiles the Java files of a run together and runs it fine. In a benchmark of Oct 18-19 2026, a local model wrote `src/main/java/camel/example/Order.java` as `record Order(..., List<OrderLine> lines)` and `OrderLine.java` next to it, in the same package. `camel_write_file` refused Order.java seven times: "cannot find symbol: class OrderLine ... another library needs a //DEPS line". The step failed. ## What - **`JavaChecks.validateJava(fileName, content, directory)`** compiles the file together with the other Java files of the project, in one compile task: - the files in the directory, and those in `src/main/java`, which are the files the bean check reads; - the file itself, and another copy of its class, are left out, as the content being validated replaces them. - **Only the diagnostics of the file being validated are reported.** Another file of the project that does not compile is not this file's problem. - **`SourceValidator`** passes the directory it already has. Without a directory, the file is compiled on its own, as before. This follows what `camel run` does: `JavaRoutesBuilderLoader` compiles the Java files of a run as one unit with camel-joor's `MultiCompile`. The validator keeps its own call to the JDK compiler for three reasons: - `MultiCompile` loads the compiled classes, and skips a class its class loader already has. The validator checks the same file again and again. - `MultiCompile` reports errors as one exception text. The validator needs the diagnostics of the one file, with their lines, for its hints. - camel-jbang-core does not depend on camel-joor. ## Tests New `JavaChecksProjectTest`: - A record that uses a record of another file in its package compiles. On its own it does not, as before. - A class next to the file compiles. - A file of the project that does not compile does not fail the file being validated. - The version of the file on disk is no second class of the same name. - A class that is nowhere is still reported. All camel-jbang-core tests pass (2310 and 237). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m -- 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]
