Fix JavaDoc snippet validator and the snippets it surfaced#4944
Merged
Conversation
The headless snippet validator stopped catching real issues after a
chain of refactors: PlaygroundProjectExporter pulled in net.sf.zipme.*
breaking the harness build, the resolveDisplayBinding wrappers were
reverted out of PlaygroundRunner.bindGlobals so it tripped on
ExceptionInInitializerError, and CN1's Base64 grew a Simd dep that
forced Display.impl to be live before any encoding could happen.
Repairs:
- Add ZipSupport cn1lib to the harness classpath
- Restore resolveDisplay/UiManagerBinding in PlaygroundRunner
- Encode URIs via java.util.Base64 instead of reflecting into CN1's
- Best-effort Display.init from the locally-built JavaSE jar so
"Undefined argument: icon" surfaces instead of an NPE
- Tighten the harness so undefined-identifier eval errors fail,
while genuine headless-runtime failures still pass
Then fix the snippets the now-working validator flags:
- SpanLabel/SpanButton/MultiButton/CheckBox/RadioButton/ButtonGroup/
Label/ImageViewer: add the missing Form/Image setup and hi.show()
- Preferences (and io/package-info copy): declare String myToken
- MathUtil.compare(float|double): turn the bare compareTo line into
a runnable Form demo
- Component.getAllStyles / Graphics.fillArc: rewrite the broken
"new Painter(cmp) { switch (style) ... }" pseudo-code (Painter is
an interface; style/cmp were undefined) as a runnable Painter demo
- Validator: wrap the Constraint sample in a runnable Form
- system/package-info: relabel the Objective-C example block from
java to objc
- Add the four genuinely-illustrative GroupLayout/LayoutStyle method-
signature snippets to the exclusions list with documented reasons
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 106 screenshots: 106 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Collaborator
Author
|
Compared 106 screenshots: 106 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 106 screenshots: 106 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Contributor
Cloudflare Preview
|
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.
Summary
scripts/validate-extracted-javadoc-snippets.sh) had silently stopped catching real issues - every snippet was failing in the same uniform way, so the SpanLabelsetIcon(icon)bug (and others like it) shipped uncaught. This PR fixes the harness and then fixes the snippets it now flags.Harness fixes
scripts/java-snippet-to-playground-uri.sh- unpack the ZipSupport cn1lib soPlaygroundProjectExporter'snet.sf.zipme.*imports resolve (regression from Standardize native-theme build hints; fix simulator menu bugs #4855), and prepend the locally-builtcodenameone-javasejar to the classpath soDisplay.init(null)can populateDisplay.impl.PlaygroundRunner.bindGlobals- restore theresolveDisplayBinding/resolveUiManagerBindingdefensive wrappers (introduced in 54604ab for exactly this CLI use case, inadvertently reverted in 8c429e9).JavaSnippetToPlaygroundUriHarness- replace reflection into CN1'sBase64(which now transitively requiresDisplay.implviaSimd) withjava.util.Base64.getUrlEncoder().withoutPadding(); treatError-wrapped failures from headless CN1 init as non-parse passes; treatUndefined argument/Undefined variableeval errors as failures (this is the class of bug SpanLabel had).Snippet fixes - made runnable in the playground
All these stay tagged
```javaso syntax highlighting is preserved.SpanLabel,SpanButton,MultiButton,CheckBox,RadioButton,ButtonGroup,Label,ImageViewer- add the missingForm hi = new Form(...),Image icon = FontImage.createMaterial(...), and trailinghi.show()so they actually open in the playground.Preferencesandio/package-info- declareString myToken = ...so the storage example is self-contained.MathUtil.compare(float)/compare(double)- turn the barenew Float(f1).compareTo(...)expression into a runnable Form that displays the result.Component.getAllStyles/Graphics.fillArc- rewrite the brokennew Painter(cmp) { switch (style) { ... } }block (Painter is an interface,style/cmpwere undefined) as a runnable Painter demo that still shows antialiasedfillArc/drawArc.Validator- wrap the customConstraintexample with the surroundingForm+TextField phone+Validator valsetup.Snippet relabel
com/codename1/system/package-info.java- the snippet inside is Objective-C (@interface ... : NSObject,@end), so the fence is nowobjcinstead ofjava. Not removing highlighting - correcting it.Exclusions (with documented reasons)
The 4
GroupLayout.add(component, ...)/LayoutStyle.getPreferredGap(...)snippets are one-line method-signature illustrations embedded in the JavaDoc of those methods themselves. They keep theirjavafence (so syntax highlighting still works) but are listed inscripts/java-snippet-validation-exclusions.jsonlwith explicit reasons - their job is to document the call shape, not run as demos.Test plan
scripts/extract-javadoc-java-snippets.sh CodenameOne/srcextracts 411 snippetsscripts/validate-extracted-javadoc-snippets.shreportsValidated 407 snippets successfullyandExcluded 4 snippets via explicit exclusion list, exit 0iconis removed, passes when the fixed sample is fed in.github/workflows/java-snippet-validation.ymlpasses on this branch (will trigger because the harness scripts changed)Generated with Claude Code