eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Can't add classpath entries with different settings if the have the same path
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
Today I noticed a restriction in JDT that somehow degrades/blocks currently
- https://github.com/eclipse-pde/eclipse.pde/pull/1619
Assume:
- you have two classpath entries that point to the same jar location
- both have different settings, e.g one is marked as `test` and the other not (and the test entry is the first)
- then only one win and you get an error in the regular code that type can not be found
this is due to
https://github.com/eclipse-jdt/eclipse.jdt.core/blob/6c0c7bcd2a26ff30e3117b525a58aa08acbb00cd/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java#L3232-L3241
only adding it to the resolved entries set if the path was not previously added to the `result.rawReverseMap`.
I could fix this by always adding the entry to the set (and then it gets filtered by the usual equals method), but as the comment explicitly mention to only add it if not in the map I think it might be for a purpose, but the code is not clear about this. Also this still is not reflected in the UI so maybe there is also a filtering by path somewhere.
Of course the case `test` vs `regular` could be solved quite easy by only define one entry without test attribute, but this does not work with more complex things like access restrictions where one maybe want to restrict some package to be only accessible by test code.
As this is quite a core component it would be good if one of the JDT devs could look into this and either propose a fix or give some hints if my suggestion with always add it to the map is suitable or if there is any other possible mitigation.
Contributor guide
Assessment
This issue has not been assessed yet.