Skip to content

[JAVA] generate package-info.java for the auth package with useJspecify - #24808

Open
HDPark95 wants to merge 1 commit into
OpenAPITools:masterfrom
HDPark95:fix/issue-24664-jspecify-auth-package-info
Open

[JAVA] generate package-info.java for the auth package with useJspecify#24808
HDPark95 wants to merge 1 commit into
OpenAPITools:masterfrom
HDPark95:fix/issue-24664-jspecify-auth-package-info

Conversation

@HDPark95

@HDPark95 HDPark95 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #24664

With useJspecify=true the Java client generator writes a @NullMarked package-info.java for the model, api and invoker packages. The authentication classes sit in <invokerPackage>.auth; a sub-package inherits nothing from the invoker package-info.java, so it stays outside the null-marked scope.

applyJspecify() now registers authPackageInfo.mustache for that folder, guarded on an auth/ template actually being scheduled, so native (no authentication class) gets no package-info.java for an empty package.

JavaClientCodegenTest#testJspecify asserts the file for restclient/webclient/resttemplate and its absence for native; 6 of its 7 rows fail without the generator change. Full class 275/275 green, and the 4 regenerated samples compile.

cc @martin-mfg @jpfinne


Summary by cubic

Fixes #24664 by generating a @NullMarked package-info.java for the auth package when useJspecify is enabled; previously the auth sub-package stayed outside the null-marked scope.

Details

  • Generates the file only when an auth/ template is actually scheduled, so libraries like native that produce no auth classes don't get a package-info.java for an empty package.
  • Extends testJspecify to assert the file for restclient, webclient, and resttemplate, and its absence for native; regenerated samples include it.

Written for commit 793f23a. Summary will update on new commits.

Review in cubic

The Java client generator writes a @NullMarked package-info.java for the
model, api and invoker packages when useJspecify is enabled, but the
authentication classes live in <invokerPackage>.auth, a sub-package that
inherits nothing from the invoker package-info. That package was left
outside the null-marked scope.

Register authPackageInfo.mustache in JavaClientCodegen.applyJspecify(),
guarded on an auth template actually being scheduled, so libraries that
generate no authentication class (native) do not get a package-info.java
for an empty package.

Fixes OpenAPITools#24664

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 11 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][JAVA] useSpecify=true does not generate package-info.java for <invokerPackage>.auth

1 participant