docs: encode operator_add null-skip, exception lowering, and charset rules in xtend-to-java skill#1473
Draft
joaodinissf wants to merge 1 commit into
Conversation
…rules in xtend-to-java skill Harden the skill with three faithfulness rules and one meta-lesson learned from an independent blind re-migration of check.core and an archaeology audit of the merged migrations. - rules/10 §10.5: `+=` over a collection binds to JvmTypesBuilder.operator_add, which SKIPS nulls; the to<Factory> builders return null on a null name/type. A bare addAll/loop-add leaks the null (IllegalArgumentException: element: null) past every static gate and test. Faithful Java needs filterNull or an explicit null guard. This shipped once — FormatJvmModelInferrer.inferConstants — cited as the worked example. - rules/05 §5.5: how Xtend lowers try/catch (catch(Specific) -> catch(Throwable)+ instanceof+sneakyThrow; uncaught checked body -> sneakyThrow(raw), no declared checked exceptions). Reproduce with Exceptions.sneakyThrow; never wrap in new RuntimeException/ IllegalStateException (changes the observed exception type). - rules/09 §9.11: charset is a sanctioned deviation — specify UTF_8 (PMD RelianceOnDefaultCharset forbids the default), do not reproduce the default-charset constructor. - known-pitfalls: behavioural equivalence is not literal-token equivalence — test-validate every divergence; the gate is the arbiter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Hardens the
.agents/skills/xtend-to-javaskill with three faithfulness rules and one meta-lesson, all learned from an independent blind re-migration ofcheck.coreand a follow-up archaeology audit of the already-merged migrations.The rules
rules/10§10.5 —operator_add(+=over a collection) skips nulls. The single most dangerous inferrer trap.list += map[toField/toMethod/…]binds toJvmTypesBuilder.operator_add, which silently drops null elements; theto<Factory>builders returnnullon a null name/type. A bareaddAll/loop-addleaks the null →IllegalArgumentException: element: nullin production — past PMD, Checkstyle, SpotBugs, and every test that doesn't happen to feed a null. Faithful Java needsfilterNullor an explicit null guard.rules/05§5.5 — Xtend exception lowering.catch (Specific)→catch (Throwable) + instanceof + sneakyThrow; an uncaught checked-exception body →sneakyThrow(raw)with no declared checked exceptions. Reproduce withExceptions.sneakyThrow; never wrap innew RuntimeException(e)/IllegalStateException(e)(changes the observed exception type).rules/09§9.11 — charset is a sanctioned deviation. SpecifyStandardCharsets.UTF_8(PMDRelianceOnDefaultCharsetforbids the default); do not reproduce the default-charset constructor. General principle: where a valid lint rule conflicts with a literalxtend-genbehaviour on a latent-bug pattern, fix the bug.known-pitfalls— behavioural equivalence ≠ literal-token equivalence. Don't decide "faithful" by whether a token appears inxtend-gen; test-validate every divergence — the gate is the arbiter.Why now — this caught a real shipped bug
Rule 1 isn't hypothetical. Applying it to the merged migrations found that
FormatJvmModelInferrer.inferConstantshad translated the Xtendmembers += allConstants.map[createConstant](null-skippingoperator_add) into a barefor { it.getMembers().add(createConstant(format, c)); }— andcreateConstantreturns null for a value-less constant. A nullJvmMemberleaks into the model, undetected by all gates and tests until a value-less constant is declared. That fix ships separately; this PR encodes the rule that prevents the next one.Skill-only change (markdown under
.agents/skills/); no build impact.🤖 Generated with Claude Code