openrewrite / openrewrite/rewrite
Classpath pollution for `JavaParser#classpathFromResource`
Open
Nobody has claimed this yet.
bug
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 570
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What version of OpenRewrite are you using?
OpenRewrite/rewrite main branch
How are you running OpenRewrite?
- Via test harness, see #5752
What is the smallest, simplest way to reproduce the problem?
Have a type table created with 2 dependencies for instancejavax.servlet:javax.servlet-api:4.+ and jakarta.servlet:jakarta.servlet-api:6.+
What did you expect to see?
JavaParser.fromJavaVersion()
.classpathFromResources(new InMemoryExecutionContext(), "jakarta.servlet-api")
.build()
.parse("import javax.servlet.ServletContext; class Test {}");
// should contain a ParseError
What did you see instead?
snippet above has a J.CompilationUnit.
What is the full stack trace of any errors you encountered?
none, all fine.
Are you interested in contributing a fix to OpenRewrite?
Contributor 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.
Research direction
Start at JavaParser#classpathFromResource and reproduce the case through the test harness referenced in #5752, using both javax.servlet-api:4.+ and jakarta.servlet-api:6.+ in the type table. Done means parsing the javax.servlet import with only jakarta.servlet-api requested produces a ParseError rather than a compilation unit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100