openrewrite / openrewrite/rewrite

TypeTable fromClasspath pulling in transitive Typetable information.

Open
#5,665 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

After recently migrating to utilize TypeTables, I noticed that the instantiation of the Typetable when using things like classpathFromResources on a JavaParser is picking up transitive typetable zips from the other rewrite libraries like rewrite-spring. That seems to be happening due to the getResources call here, which is returning the typetables from all the jars on the classpath.

I'm not sure if this behavior is intentional, but it seems unfavorable to have recipes potentially become reliant on typetables coming from the rewrite libraries, especially if/when those typetables change.

Additionally, this became semi-problematic when combined with the wildcard matching applied to missing artifacts here. That wildcard matching caused a spring-boot-3.5.0 recipe dependency to match rewrite-spring's spring-boot-3.5.0-M2 typetable entry, a pre-release version that was missing classes the recipe was expecting.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in rewrite-java/src/main/java/org/openrewrite/java/internal/parser/TypeTable.java, especially the getResources call around line 97 and wildcard matching around line 141. Reproduce the classpathFromResources behavior with transitive rewrite library typetable zips, then determine the intended filtering or matching boundary. Done means unrelated or pre-release typetable entries no longer affect the requested dependency resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.