Skip translator-rejected methods gracefully and support char primitive#416
Merged
Conversation
05e46bd to
e2e2c52
Compare
Wrap per-method translation in JavaToLaurelCompiler.visitMethodDef in a try/catch on JavaViolationException. On catch, emit a translatorError diagnostic and demote the method's IntervalTree entry from Verified to Skipped. The trailing super.visitMethodDef stays outside the catch so nested classes are still visited. The catch is scoped to JavaViolationException only — broader catches would mask translator bugs (NPEs, missing line maps) and OOM/StackOverflow from Strata recursion. Net effect: a single translator gap inside one class now produces a per-method skip with correct counts instead of aborting the whole class. Add char as a constrained int (0..65535, full UTF-16 range) — bundled with Step 1 because the type-plumbing tweak is mechanically aligned with the safety-net edits and unblocks downstream switch/primitive tests in later steps. Resolves #398, #414.
Pairs the happy path (translateType + convertLiteral round-trip) with a negative case that fails when c == 65535, asserting the 0..65535 constraint is actually enforced rather than dropped.
e2e2c52 to
ac36d48
Compare
This was referenced May 20, 2026
| * gains support, swap the trigger; the test covers the catch wrapper, not | ||
| * the construct. | ||
| */ | ||
| @JVerifyTest( |
Contributor
There was a problem hiding this comment.
Interesting! I have trouble evaluating the UX but it seems great. Would JVerify previously just crash if it ran into something that was not supported?
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.
Step 1 of the JVerify completion plan (PLAN.md §3.1).
Resolves
JavaViolationException)charprimitive supportSummary
JavaToLaurelCompiler.visitMethodDefin atry/catchonJavaViolationException. On catch: emit atranslatorErrordiagnostic and demote the method'sIntervalTreeentry fromVerifiedtoSkipped.super.visitMethodDefstays outside the catch so nested classes are still visited even when the parent method skipped.JavaViolationExceptiononly. Broader catches would mask translator bugs (NPEs, "Could not find line map for...") andOOM/StackOverflowfrom Strata recursion.charas a constrained int (0..65535, full UTF-16 range) registered alongsideint8/int16/int32/int64.Why bundle char with #398
5-line type-plumbing tweak — too small for its own step. Mechanically aligned with the safety-net edits (both touch
translateType/convertLiteral), and unblocks Step 2'sswitchExprChar/switchExprCharBadand Step 5's char-using methods inPrimitiveTypeswithout leaving them gated on a follow-up.Implementation notes
VerifyAnnotationCompiler.markSkipped(JCCompilationUnit, JCMethodDecl)— new helper. Scans the URI's interval-tree bymethodTree == methodDeclidentity rather than recomputing line position, so it doesn't depend onPositionCalculatorsemantics matchingaddMethodToIntervalTreeexactly. No-op when the method has no entry (synthetic methods, methods without an implementation body) — those are already invisible to the counting layer.char/char16prelude type (verified via grep ofStrata/Languages/Laurel/); inlining as a constrained int is the only path. Dafny used a namedchar16type — a forced divergence.translatorError(newmessages.propertieskey) instead ofnotSupported.JavaViolationException's javadoc states "Indicates a JVerify compiler bug" — so it's a translator gap surfaced to the user, not a clean refusal of an explicitly-unsupported feature. Future Step 6 throws →reportErrormigrations will usenotSupportedfor the genuine "user feature not supported" cases.Test plan
./gradlew :verifier:testpasses — 113 tests / 0 failed / 72 skipped.JavaViolationExceptionstack traces in test output.TranslatorSkip.javacovers the catch wrapper end-to-end. Asserts three properties simultaneously: (1) sibling translation continues past a throwing method, (2) the translator-level error reaches the driver as a diagnostic, (3) the throwing method's status flipsVerified → Skipped(the silent-overcount bug §3.1 calls out). Trigger is the multi-initforrefusal atconvertStatement, chosen for stability — the plan refuses this form rather than supporting it.CharPrimitive.javais the regression test for Laurel compiler: char primitive type support #414. Pairs the happy path (translateType+convertLiteralround-trip) withrangeBoundsBadthat fails whenc == 65535to assert the0..65535constraint is actually enforced rather than dropped.