Community
Participate
Working Groups
# Background Console has a feature where texts of the form "packagename.classname.method(filename:linenum)" are displayed as clickable links that open said file at said line number when clicked. (Console also turns a simple "(filename:linenum)" into clickable links but this bug involves the former and not the latter.) This feature is especially useful, and used, when navigating from stack traces. # Problem in brief As of version 2020-03 (4.15), I've noticed clicking the link opens the wrong file in the following situation: * When the file for "packagename.classname" exists in a library but is overridden by another in the project. Up until version 2019-12, clicking opened the file in the project, and this made sense because that's the file that actually runs. In version 2020-03, clicking opens the original file in the library. Unfortunately, the original file in the library usually does not have have matching line numbers or code. (Otherwise there's no point overriding.) # Steps to reproduce 1. Download "Eclipse IDE for Java Developers" (2020-03 R) from https://www.eclipse.org/downloads/packages/ 2. Unzip the package and run eclipse 3. Create a new "Maven Project". (I selected "Create a simple project (skip archetype selection)") and set both group and artifact ids to "test".) 4. Add a dependency to "org.apache.commons:commons-lang3:3.10": (This choice is arbitrary, for demonstration.) ``` <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.10</version> </dependency> `` 5. Open the ArrayUtils from the library and copy its contents, then create a "New Java Class" under the package "org.apache.commons.lang3" with the name "ArrayUtils". Finally, paste the contents of the original ArrayUtils into the newly created file. 6. The Java compiler might show errors because the new Maven project defaulted to J2SE-1.5. I changed mine to JavaSE-1.8 from "Project Properties" > "Java Build Path" > Libraries > "JRE System Library" > "Execution environment". 7. Open the created "ArrayUtils.java" and replace the contents of `add(boolean[], boolean)` on line 202 with `throw new AssertionError("test");`. 8. Create a new Test.java with the following contents: ``` public class Test { public static void main(String[] args) { org.apache.commons.lang3.ArrayUtils.add(null, false); } } ``` 8. Run Test as an application and wait for "Exception in thread "main" java.lang.AssertionError: test" to appear in the Console. 9. Click on the "ArrayUtils.java:203" link in the stack trace. 10. Notice "ArrayUtils.class" is opened. Notice this is the file in "commons-lang3-3.10.jar" and not the modified version we created. 11. To test previous behaviour, download "Eclipse IDE for Java Developers" (2019-12 R) from https://www.eclipse.org/downloads/packages/release/2019-12/r then use "Import..." > Maven > "Existing Maven Projects" to import the project created above.
@Debug: is this a matter of missing (project) context when locating the type, or is JDT/Core providing a wrong answer?
What I see happening (and expected) : 1. If I don't check "Search for duplicate source files on the path" (Source tab of Launch configuration), Clicking on the Console link opens ArrayUtil.java in the maven project. 2. If I check "Search for duplicate source files on the path", Clicking on the Console link gives a dialog with 2 ArrayUtils source locations (Workspace and jar)
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.