Skip to content

Fix untyped field accesses flagged by stricter type validation - #1468

Merged
timtebeek merged 1 commit into
mainfrom
tim/untyped-field-access-fixes
Nov 19, 2026
Merged

timtebeek merged 1 commit into
mainfrom
tim/untyped-field-access-fixes

Conversation

@timtebeek

Copy link
Copy Markdown
Member

openrewrite/rewrite#10034 makes the RewriteTest type check flag a field access with no type. Run against this repository, it fails 7 of 2,998 tests. Each failure is a real defect, and this fixes them so the repository doesn't go red when that change reaches latest.integration. The fixes also pass against the current rewrite release, so this can merge first.

  • AddTableGenerator: its two templates had no classpath, so the inserted @javax.persistence.TableGenerator and GenerationType.TABLE were untyped. They now parse against javax.persistence-api-2.2. Once typed, RemoveImport treats the fully qualified javax.persistence.GenerationType reference as a use and keeps the import, so the recipe now writes GenerationType.TABLE and adds the import. That changes the expected output in AddTableGeneratorTest.
  • AdoptLombokSetterMethodNamesTest: noBoxing1/noBoxing2 declared Foo but assigned this.foo, so they never exercised boxing. With the name fixed, the recipe still leaves them alone.
  • AddScopeToInjectedClassTest: ElementType.Type is not a constant, so it is now TYPE. The two dependsOn stubs also gained their missing java.lang.annotation import.
  • BouncyCastleApiTest: bcprov-jdk15on 1.70 has SPHINCSPlusParameters.sha256_128f, not sha2_128f.

Verified by running ./gradlew test with rewrite#10034's compiled FindMissingTypes, Assertions, ExtractField and ReplaceStringLiteralWithConstant classes first on the test classpath: 2,998 tests and 0 failures, where without these fixes 7 failed. The four changed test classes also pass without that swap, against the snapshot this build resolves.

openrewrite/rewrite#10034 makes RewriteTest's type check flag a field
access that has no type. Here that surfaced one recipe and three test
inputs:

- AddTableGenerator's templates had no classpath, so the inserted
  `@javax.persistence.TableGenerator` and `GenerationType.TABLE` were
  untyped. With them typed, RemoveImport counts the fully qualified
  `GenerationType` reference as a use, so the strategy is now written as
  `GenerationType.TABLE` with an import.
- AdoptLombokSetterMethodNamesTest declared `Foo` but assigned `this.foo`.
- AddScopeToInjectedClassTest used `ElementType.Type` rather than `TYPE`.
- BouncyCastleApiTest used `sha2_128f`, which bcprov-jdk15on 1.70 does not
  have; it has `sha256_128f`.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Nov 19, 2026
@timtebeek
timtebeek merged commit db957d9 into main Nov 19, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/untyped-field-access-fixes branch November 19, 2026 13:01
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant