Skip to content

IdentifierName: JEP 456 unnamed variable #4847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
commonquail opened this issue Feb 26, 2025 · 0 comments · Fixed by #4880
Closed

IdentifierName: JEP 456 unnamed variable #4847

commonquail opened this issue Feb 26, 2025 · 0 comments · Fixed by #4880

Comments

@commonquail
Copy link
Contributor

commonquail commented Feb 26, 2025

IdentifierName does not support the "unnamed variable" _ from JDK 22 (JEP 456), previewed in JDK 21 (JEP 443):

 error-prone version: 2.36.0
 BugPattern: IdentifierName
 Stack Trace:
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.lang.String.checkIndex(String.java:4832)
at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:46)
at java.base/java.lang.String.charAt(String.java:1555)
at com.google.errorprone.bugpatterns.IdentifierName.isConformantLowerCamelName(IdentifierName.java:290)
at com.google.errorprone.bugpatterns.IdentifierName.isConformant(IdentifierName.java:281)
at com.google.errorprone.bugpatterns.IdentifierName.matchVariable(IdentifierName.java:215)
at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:509)
at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:1016)
at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:170)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1040)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:272)
at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:591)
at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:170)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1104)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:224)
at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:818)
at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:170)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:948)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:203)
at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:619)
at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:170)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:855)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:152)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:631)
at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:170)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:623)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:66)
at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:227)
at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:133)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1436)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1383)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:963)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
commonquail added a commit to commonquail/error-prone that referenced this issue Feb 26, 2025
commonquail added a commit to commonquail/error-prone that referenced this issue Feb 26, 2025
commonquail added a commit to commonquail/error-prone that referenced this issue Feb 26, 2025
copybara-service bot pushed a commit that referenced this issue Mar 7, 2025
This PR nominally fixes #4847 but it is perhaps more illustrative than usable.

Fixes #4848

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4848 from commonquail:identifiername-accept-unnamed cc90fe1
PiperOrigin-RevId: 733740757
copybara-service bot pushed a commit that referenced this issue Mar 10, 2025
This PR nominally fixes #4847 but it is perhaps more illustrative than usable.

Fixes #4848

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4848 from commonquail:identifiername-accept-unnamed cc90fe1
PiperOrigin-RevId: 733740757
svc-squareup-copybara pushed a commit to cashapp/misk that referenced this issue Mar 21, 2025
| Package | Type | Package file | Manager | Update | Change |
|---|---|---|---|---|---|
| [com.google.guava:guava-bom](https://github.com/google/guava)
([source](http://svn.sonatype.org/spice/trunk/oss/oss-parent-9)) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`33.4.0-jre` -> `33.4.5-jre` |
|
[com.google.apis:google-api-services-storage](http://nexus.sonatype.org/oss-repository-hosting.html)
([source](http://svn.sonatype.org/spice/tags/oss-parent-7)) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`v1-rev20250224-2.0.0` -> `v1-rev20250312-2.0.0` |
|
[com.google.errorprone:error_prone_annotations](https://errorprone.info)
([source](https://github.com/google/error-prone)) | dependencies |
misk/gradle/libs.versions.toml | gradle | minor | `2.36.0` -> `2.37.0` |
|
[com.autonomousapps.dependency-analysis](https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin)
| plugin | misk/gradle/libs.versions.toml | gradle | minor | `2.12.0` ->
`2.13.0` |
| [software.amazon.awssdk:sdk-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.3` -> `2.31.4` |
| [software.amazon.awssdk:sqs](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.3` -> `2.31.4` |
|
[software.amazon.awssdk:dynamodb-enhanced](https://aws.amazon.com/sdkforjava)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.3` -> `2.31.4` |
| [software.amazon.awssdk:dynamodb](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.3` -> `2.31.4` |
| [software.amazon.awssdk:aws-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.3` -> `2.31.4` |
| [software.amazon.awssdk:bom](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.3` -> `2.31.4` |
| [software.amazon.awssdk:auth](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.31.3` -> `2.31.4` |

---

### Release Notes

<details>
<summary>google/error-prone
(com.google.errorprone:error_prone_annotations)</summary>

###
[`v2.37.0`](https://github.com/google/error-prone/releases/tag/v2.37.0):
Error Prone 2.37.0

Changes:

- The annotations that were previously in `error_prone_type_annotations`
have been been merged into `error_prone_annotations`.
`error_prone_type_annotations` is now deprecated, and will be removed in
a future release.

New checks:

-
[`AssignmentExpression`](https://errorprone.info/bugpattern/AssignmentExpression)
- The use of an assignment expression can be surprising and hard to
read; consider factoring out the assignment to a separate statement.
-
[`IntFloatConversion`](https://errorprone.info/bugpattern/IntFloatConversion)
- Detect calls to `scalb` that should be using the double overload
instead
- [`InvalidSnippet`](https://errorprone.info/bugpattern/InvalidSnippet)
- Detects snippets which omit the `:` required for inline code.
-
[`JUnit4EmptyMethods`](https://errorprone.info/bugpattern/JUnit4EmptyMethods)
- Detects empty JUnit4 `@Before`, `@After`, `@BeforeClass`, and
`@AfterClass` methods.
-
[`MockIllegalThrows`](https://errorprone.info/bugpattern/MockIllegalThrows)
- Detects cases where Mockito is configured to throw checked exception
types which are impossible.
-
[`NegativeBoolean`](https://errorprone.info/bugpattern/NegativeBoolean)
- Prefer positive boolean names.
- [`RuleNotRun`](https://errorprone.info/bugpattern/RuleNotRun) -
Detects `TestRule`s not annotated with `@Rule`, that won't be run.
-
[`StringConcatToTextBlock`](https://errorprone.info/bugpattern/StringConcatToTextBlock)
- Replaces concatenated multiline strings with text blocks.
-
[`TimeInStaticInitializer`](https://errorprone.info/bugpattern/TimeInStaticInitializer)
- Detects accesses of the system time in static contexts.

Closed issues:

- Propagate check flags in patch mode
([#&#8203;4699](google/error-prone#4699))
- Fixes a crash in ComputeIfAbsentAmbiguousReference
([#&#8203;4736](google/error-prone#4736))
- Show the field name in HidingField diagnostics
([#&#8203;4775](google/error-prone#4775))
- Add support for jakarta annotations to some checks
([#&#8203;4782](google/error-prone#4782))
- FloatingPointAssertionWithinEpsilonTest depends on default locale
([#&#8203;4815](google/error-prone#4815))
- `@InlineMe` patching of `Strings.repeat` produces broken code
([#&#8203;4819](google/error-prone#4819))
- Fix a crash in IdentifierName on unnamed (`_`) variables
([#&#8203;4847](google/error-prone#4847))
- Fix a crash in ArgumentParameterSwap
([#&#8203;490](google/error-prone#490))

Full changelog:
google/error-prone@v2.36.0...v2.37.0

</details>

<details>
<summary>autonomousapps/dependency-analysis-android-gradle-plugin
(com.autonomousapps.dependency-analysis)</summary>

###
[`v2.13.0`](https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/blob/HEAD/CHANGELOG.md#Version-2130)

- \[Feat]: `computeResolvedDependencies` to also generate a version
catalog file
- \[Feat]: experimenting with compressing intermediates, starting with
`exploded-jars.json`.
-   \[Chore]: remove unused moshi functions.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 6pm every weekday,before 2am
every weekday" in timezone Australia/Melbourne, Automerge - At any time
(no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

GitOrigin-RevId: 9a8acb12117486aa61b1d54c73d77d84629e5e79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant