PreciseBeanType generates an invalid return type for anonymous beans
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start by reading the PreciseBeanType recipe named in the issue and find how it derives a return type from a bean method's implementation. Use the anonymous TenantAware bean shown in the reproducer to check the generated type and whether the source still compiles. Done means the method retains the usable TenantAware return type for this case.
Written by the indexing model from the issue text.
Description
Which recipe were you running?
org.openrewrite.java.spring.boot3.PreciseBeanType
Which versions are you using?
rewrite-spring6.37.1rewrite-maven-plugin6.46.1- Maven 3.9.9, Java 25.0.4, Spring Framework 7.0.10
The same input also produces the invalid return type when running the PreciseBeanType source from tag v6.53.0 with rewrite-core and rewrite-java 8.90.4. The 6.53.0 release artifact was not available from the Maven repositories accessible in this environment, so that binary was not tested.
How are you running OpenRewrite?
Maven plugin. Only the affected recipe is activated:
mvn org.openrewrite.maven:rewrite-maven-plugin:6.46.1:runNoFork \
-Drewrite.activeRecipes=org.openrewrite.java.spring.boot3.PreciseBeanType \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:6.37.1
Which language or file type is affected?
Java.
What is the smallest input that reproduces the problem?
package example;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
interface TenantAware {
String currentTenant();
}
@Configuration
class TestContext {
@Bean
TenantAware tenantAware() {
return new TenantAware() {
@Override
public String currentTenant() {
return "example";
}
};
}
}
What did you expect to see?
The return type should remain TenantAware: the anonymous implementation does not have a name that can be used as a Java return type. The source should continue to compile.
What did you see instead?
The recipe changes the return type to TestContext.1:
- TenantAware tenantAware() {
+ TestContext.1 tenantAware() {
The resulting source does not compile. javac reports <identifier> expected and invalid method declaration; return type required at the method.
- Dominant language
- Java
- Stars
- 408
- Forks
- 164
- Avg merge
- 7h 52m
- Merged PRs (30d)
- 81
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openrewrite/rewrite-spring
-
Recipe quality triage: remaining fixes, wiring and polish (A1–L4)Possibly taken @DavJaveiro claimed this 2 days ago. Opengood first issue
Difficulty 5/5 Over a week Newbie friendliness 35/100
openrewrite/rewrite-spring#1201 · 19 comments ·
Maintainers usually reply within 1 day
-
`UpgradeSpringBoot_3_4` keeps `htmlunit-driver` (HtmlUnit 2) and pins it to 4.13.0; MockMvc HtmlUnit tests then fail with `NoClassDefFoundError: org/htmlunit/WebConnection`May be free again @OnicarN claimed this 21 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
openrewrite/rewrite-spring#1195 · 2 comments ·
Maintainers usually reply within 1 day
-
`ReplaceGlobalMethodSecurityWithMethodSecurity` swaps the annotation on a `GlobalMethodSecurityConfiguration` subclass, and the context fails to start: "EnableGlobalMethodSecurity is required"Possibly taken @theluckystrike claimed this 4 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
openrewrite/rewrite-spring#1194 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
openrewrite/rewrite-spring#1159 · 1 reaction ·
Maintainers usually reply within 1 day
-
Optimize the PreciseBeanType recipe and add type exclusion functionalityMay be free again @Akhil-1527 claimed this 46 days ago, and no pull request is open. Openenhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
openrewrite/rewrite-spring#1148 · 3 comments ·
Maintainers usually reply within 1 day
All issues in openrewrite/rewrite-spring
Similar issues
-
Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
MovingBlocks/Terasology#5415 ·
-
type: possible bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
面渣逆袭Spring事务传播机制勘误Open
Difficulty 1/5 Under an hour Newbie friendliness 80/100
itwanger/toBeBetterJavaer#218 ·
-
Markdown and Astro language servers do not start when the project path contains a non-ASCII character or a spacePossibly taken @RoiSoleil claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eclipse-wildwebdeveloper/wildwebdeveloper#2277 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
johanhaleby/occurrent#1462 ·
Maintainers usually reply within 1 day