Community
Participate
Working Groups
I have two projects A and B in the same workspace. I use the "Add Class Folder" option on "Java Build Path"/"Libraries" to add project B's root to A. I then add an external jar to A. At this point project B's .java files in the project explorer magically change into .class files and the project becomes somewhat unusable.
If you want to reference project B form project A simply check it on the projects page of the Java build path. Don't put the root onto A's build path. However, we have to understand why B gets inconsistent. But not critical for 3.0 since the recommended project ref setup is different.
I tested the following setup - project A with A.java in default package - project B with B.java in default package - B's root on A's build path as a class folder - put an external Jar on A's build path Expanding the default package in B reports the default package as <default> [in <project root> [in A]] <== strange is that it belongs to A B.class (not open) The kind of the package is !IPackageFragmentRoot.K_SOURCE, that's why the package explorer shows class files. May be we shouldn't support this setup. Moving to JDT/Core.
hmm, just noticed that I missed out the point that project B already depends on project A (as added via the suggested "add projects" approach). I therefore can't add B to A as we get a cyclic dependency. The reason I'm doing this is as follows: A is the main application. It supports plugins. B is such a plugin (and hence relies on A as a "project" as it uses the plugin interface defined by A). I want to test plugin B when running A, hence A needs B's classes available (hence the "add class folder" approach).
Problem is in PackageFragmentRoot.equals(Object) that doesn't check for the parent's equality. Note we had this problem in 2.1 as well. But in 2.1, UI would not allow this scenario.
Isn't this #equals implementation allowing to share infos for external JARs ?
Actually, JarPackageFragmentRoot redefines its own #equals() to do the right thing, so we are safe. This isn't a regression, just a scenario which wasn't visible in 2.1 when using buildpath UI. Manual editing of .classpath was allowing it; or sharing a project designed by Eclipse 3.0 could expose this as well in 2.1 client. Approved for RC2.
Created attachment 11646 [details] Proposed patch
Created attachment 11656 [details] Regression test Added regression test JavaProjectTests#testRootGetPackageFragments3()
Fix and test released.
Verified in 200406110010