Sitelet https://github.com/google/error-prone/pull/6171
Skip to content

Avoid VarWithPrimitive crash on implicitly typed primitive lambda parameters - #6171

Draft
mehuljariwala wants to merge 1 commit into
google:masterfrom
mehuljariwala:fix/6165-implicit-primitive-lambda
Draft

mehuljariwala wants to merge 1 commit into
google:masterfrom
mehuljariwala:fix/6165-implicit-primitive-lambda

Conversation

@mehuljariwala

Copy link
Copy Markdown

An implicitly typed primitive lambda parameter can have no type tree on JDK 27. VarWithPrimitive currently passes it to replaceVariableType, which dereferences that absent tree and crashes the compiler plugin.

Skip parameters without a source type tree before considering a replacement. Explicit var declarations retain their existing refactorings. Add an IntConsumer regression covering both bare and parenthesized lambda parameters.

Fixes #6165.

Validation and draft status

The repository reactor could not reach tests on the unmodified baseline: ErrorProneSignatureGenerator.java:31 fails compilation with “an enclosing instance that contains Types.SignatureGenerator is required.” This occurred with the configured JDK 25 compiler and in a second explicit JDK 27 executable attempt. I have not modified that unrelated source or weakened repository tests. This PR is a draft until the normal reactor/CI validation is resolved.

The attempted repository command was:

mvn -B -ntp -t /tmp/errorprone-toolchains.xml -pl core -am \
  -Dtest=VarWithPrimitiveTest -Dsurefire.failIfNoSpecifiedTests=false test

To separate the reported bug from the baseline build failure, a local isolated Maven harness compiled the exact checker and its complete test class from this branch against released error_prone_core and error_prone_test_helpers 2.50.0, with JUnit 4.13.2. It used Java 21 source/target, exported javac internals, and no annotation processing for those isolated files. The harness is not a replacement for the repository build and is not included in this scoped source PR.

  • Original checker on Temurin 27+35: 16 tests, 3 failures, 1 existing assumption skip. The added regression and two existing implicit-lambda tests failed with the reported getStartPosition() null dereference.
  • Patched checker on Temurin 27+35: 16 tests, no failures/errors, 1 existing assumption skip.
  • Patched checker on Temurin 25.0.2: 16 tests, no failures/errors, 1 existing assumption skip.
  • git diff --check passed.

The isolated harness was run with mvn -B -ntp test on JDK 27 and mvn -B -ntp clean test on JDK 25. Explicit-var lambda, annotated-var lambda, ordinary local-variable, and multi-parameter cases in the existing class were retained. Full reactor tests and full formatting/CI checks remain unverified.

AI assistance: OpenAI Codex assisted with reproduction, implementation, and local checks. No independent human review is claimed. Any required Google CLA acceptance will be completed by the contributor personally.

@mehuljariwala

Copy link
Copy Markdown
Author

Could a maintainer review whether CI run https://github.com/google/error-prone/actions/runs/37122598346 can be approved to run? It is currently awaiting approval and no CI jobs have executed.

This PR remains a draft. Full repository validation is still unverified; the isolated checker reproduction in the description is not a substitute for CI. The draft status will remain until the validation and review requirements are satisfied.

AI assistance disclosure: this implementation and follow-up are AI-assisted.

This branch has not been deployed

No deployments
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.

VarWithPrimitive crash on OpenJDK 27 for lambda with primitive parameter

1 participant