Bug 546877 - [build path] Project root is allowed as a class folder but doesn't work
Summary: [build path] Project root is allowed as a class folder but doesn't work
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.12   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-30 15:29 EDT by Stephan Herrmann CLA
Modified: 2023-04-23 11:36 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2019-04-30 15:29:49 EDT
Have a regular Java project A with a source/output folders other than the project root (e.g., src & bin).

In another Java project B add a class folder to the build path selecting the root folder of project A.

This is allowed, but classes inside A will not be found from B. Only selecting A/bin will work. Since we know the layout of project A, the build path configuration could recognize and disallow (at least: warn) this mismatch ("/A is not a class folder"). Bonus: suggest to add it as a project dependency instead.
Comment 1 Stephan Herrmann CLA 2019-05-04 16:51:52 EDT
Another symptom: when searching for modules in this setup, the following exception will be printed to syserr (not logged!):

Java Model Exception: Java Model Status [Operation not supported for specified element type(s):/A [in B]]
	at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:583)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:256)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:596)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:326)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:312)
	at org.eclipse.jdt.internal.core.CompilationUnit.getModule(CompilationUnit.java:1433)
	at org.eclipse.jdt.internal.core.CompilationUnit.getModuleName(CompilationUnit.java:1440)
	at org.eclipse.jdt.internal.core.search.matching.PossibleMatch.getModuleName(PossibleMatch.java:211)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.skipMatch(MatchLocator.java:1253)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1270)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1377)
	at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1496)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:112)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:250)
	at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:595)
	at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:670)

This happens when we try to read CU module-info.java as child of a package fragment "src" inside packageFragmentRoot /A [in B] (happens when we have a possible match /A/src/module-info.java, unrelated to the offending classfolder definition, but then conflicting with the same): CU inside a K_BINARY package fragment is not supported.
Comment 2 Eclipse Genie CLA 2021-04-24 15:26:06 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Eclipse Genie CLA 2023-04-23 11:36:59 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.