JDK-8322641 : javac fails with "Unable to implement method".
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 21.0.2,22,23
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2023-12-21
  • Updated: 2024-02-05
  • Resolved: 2024-01-19
Related Reports
Relates :  
Relates :  
Description
When running `./gradlew compileJava` in the attached Gradle project, javac from a 21.0.2 build fails with the following output:

```
warning: [options] system modules path not set in conjunction with -source 17
error: Unable to implement Repository method: GenreRepository.delete(Object entity). Cannot query persistentEntity [Genre] on non-existent property: entity
Note: Creating bean classes for 4 type elements
1 error
1 warning  
```

In a JDK 21.0.1 build, however, the project compiles just fine. The behavior of javac must have somehow changed in a backward incompatible way.
Comments
The retroactive CSR has been approved for JDK 22+ (https://bugs.openjdk.org/browse/JDK-8323093), and the javac change will be documented with a release note (https://bugs.openjdk.org/browse/JDK-8323094).
19-01-2024

> Re-opening and assigning to Liam since JDK 22+ need a fix for this issue still as far as I'm aware. Understood, thanks. I think the javac behaviour here is working as intended and the bug is in micronaut. I think that depending on the outcome of JDK-8323093, the options are: (1) back the change out of 22 and consider fixing it in the future, (2) keep the fix in JDK 22 and document the change with the CSR and relnotes.
10-01-2024

Re-opening and assigning to Liam since JDK 22+ need a fix for this issue still as far as I'm aware.
10-01-2024

The issue is resolved by backing out fix for issue JDK-8225377. Backed out via JDK-8322883 for 21.0.2. Marking issue as duplicate of JDK-8322883
04-01-2024

It looks like there's a related pending fix to micronaut: https://github.com/micronaut-projects/micronaut-core/pull/10293
23-12-2023

Note that `TypeVariable#toString()` already includes type annotations, depending on whether or not the type was compiled from source or loaded from the classpath, so the bug in the annotation processor predates JDK-8225377.
22-12-2023

JDK-8225377 will be backed out of 21.0.2. It will remain in 22 and so code that uses toString() as a map key - for example: https://github.com/micronaut-projects/micronaut-core/blob/97aeb96c3e2fa25e4ac51e57e52564bb9566d225/inject-java/src/main/java/io/micronaut/annotation/processing/visitor/AbstractJavaElement.java#L388 will need to accommodate the change - in particular using toString() as a map key is not recommended.
22-12-2023

We looked into this some more and found out that "`TypeVariable#toString()` somehow returns the variable name with the annotations included. That causes a map miss and the generic type is not resolved."
21-12-2023