Use imports instead of inline fully-qualified names in the DSL compilers - #13975
Merged
Conversation
wu-sheng
force-pushed
the
fix/dsl-inline-fqcn
branch
from
August 11, 2026 05:50
e5998cb to
cc3b2e9
Compare
CLAUDE.md bans fully-qualified class names written inline where an import would do, and names the exact form Analyzer.java:242 used: a field declared as `private javassist.ClassPool pool;`. 44 such sites across 14 files in the four DSL modules -- parameter and field types, locals, throws clauses, static calls, a class literal and a method reference. Every one is a name the COMPILER resolves. Nothing resolved at runtime was touched: no FQCN inside a codegen string literal, none in a FreeMarker template, none handed to Class.forName or to Javassist. That distinction is the whole risk here -- Javassist's compiler has no import statement and resolves simple names only against java.lang, so shortening a name in generated source compiles as Java and then fails when the rule is compiled. The transform only rewrote lines containing no quote character, which is sufficient rather than merely convenient: a Java string literal cannot span lines under JDK 11, so a line with no quote cannot be inside one. Simple-name collisions and in-file shadowing were checked before any import was added; there were none. Adds a short CLAUDE.md to code-templates-v2/ saying the templates must stay fully qualified. Those files are the weakest spot, because they are not Java and a reader editing one has no reason to consult a Java style rule.
wu-sheng
force-pushed
the
fix/dsl-inline-fqcn
branch
from
August 11, 2026 06:00
cc3b2e9 to
9a67277
Compare
mrproliu
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use imports instead of inline fully-qualified names in the DSL compilers
CLAUDE.mdbans fully-qualified class names written inline where an import would do, and names theexact form found here:
Analyzer.java:242was literallyprivate javassist.ClassPool pool;. 44 sites across 14 files inthe four DSL modules: parameter and field types, locals,
throwsclauses, static calls, a classliteral and a method reference.
The part that needed care
Every site changed is a name the compiler resolves. Nothing resolved at runtime was touched.
That distinction is the whole risk. Javassist's compiler has no
importstatement — it resolves asimple class name only against
ClassPool.importedPackages, which holdsjava.langand nothingelse. A fully-qualified name inside generated source is therefore mandatory, and shortening one
still compiles as Java, then fails when the rule is compiled. The same applies to anything handed
to
Class.forName.So this PR deliberately did not touch:
code-templates-v2/*.ftlThe transform rewrote only lines containing no quote character. That is sufficient rather than
merely convenient: a Java string literal cannot span lines under JDK 11, so a line with no quote
cannot be inside one. Verified after the fact —
git diffshows no changed line contains a quote,and no
.ftlis modified.Simple-name collisions and in-file shadowing were checked before any import was added. There were
none, so no site had to be left qualified for ambiguity.
Documentation
Adds a short
CLAUDE.mdtocode-templates-v2/. The rule already exists in the rootCLAUDE.md,but the templates are the weakest spot: they are not Java, so a reader editing one has no reason to
consult a Java style rule, and "tidying" an FQCN there breaks the OAP only at rule-compile time.
No changelog entry: no behaviour change, no user-visible surface.