[java][microprofile] Extend useSealedOneOfInterfaces support to the microprofile library#24267
Open
Ignacio-Vidal wants to merge 1 commit into
Open
[java][microprofile] Extend useSealedOneOfInterfaces support to the microprofile library#24267Ignacio-Vidal wants to merge 1 commit into
Ignacio-Vidal wants to merge 1 commit into
Conversation
When useSealedOneOfInterfaces=true, render the generated oneOf interface as a
sealed interface and its subtypes as final classes in the microprofile library
(Jackson serialization), matching the existing WebClient/RestClient behaviour
of the option.
- microprofile pojo.mustache: add the shared {{>sealed}}/{{>permits}} partials to
the class declaration so permitted children become final (a sealed interface
requires its permitted subtypes to be final/sealed/non-sealed).
- JavaClientCodegen: force Java 17 for the microprofile library when
useSealedOneOfInterfaces is set (sealed types require Java 17); CliOption
description updated to include microprofile.
- pom_3.0.mustache: emit java.version 17 when java17 is set.
- Test JavaClientCodegenTest#sealedOneOfInterfaceMicroprofileJackson.
- New microprofile-oneof-sealed sample (Java 17), registered in the
samples-java-client-jdk17.yaml workflow.
Default output is unchanged; the partials are gated on the flag.
151bc67 to
4920a61
Compare
Contributor
There was a problem hiding this comment.
Review completed against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
Author
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.
Extends
useSealedOneOfInterfacesto the microprofile library of the java client generator (Jackson serialization). Follow-up to #24190, which addeduseOneOfInterfacessupport for microprofile; with both flags set, the generated oneOf interface issealedandpermitsits subtypes, which becomefinalclasses implementing it — matching the existing WebClient/RestClient behaviour of the same option.Changes
Java/libraries/microprofile/pojo.mustache: reference the shared{{>sealed}}/{{>permits}}partials on the class declaration, so permitted subtypes becomefinal(a sealed interface requires its permitted subtypes to befinal/sealed/non-sealed). No-op when the flag is off.JavaClientCodegen: force Java 17 for the microprofile library whenuseSealedOneOfInterfacesis set (sealed types require Java 17); CliOption description updated to include microprofile.microprofile/pom_3.0.mustache: emitjava.version17 whenjava17is set (11 otherwise).JavaClientCodegenTest#sealedOneOfInterfaceMicroprofileJackson(sealed interface + final children + pom at 17); the existingoneOfInterfaceMicroprofileJacksontest guards the flag-off default (not sealed, not final).microprofile-oneof-sealed(Java 17), registered in thesamples-java-client-jdk17.yamlworkflow (push/PR paths + build matrix). The sample compiles under JDK 17.Default output is unchanged: the partials are gated on the flag, and a full sample regeneration produces no diffs outside this PR's own sample and docs.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
cc Java technical committee: @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg