Community
Participate
Working Groups
I have the junit jar file as part of the workbench classpath. When I try to create a new java class, and I click on the "Browse" button for the parent, I get a dialog box. In this I type "testcase" and the junit.framework.TestCase class does not show up in the list of selectable classes.
I am running M2 - and this was working in M1.
Martin, was this behaviour changed intentionally?
No there was no change in M2 for this. bwt, what do you mean by 'parent'. Superclass? Note that for enclosing type the dialog only shows types that are available in source (not from a JAR)
Yes I do mean the superclass. I am not sure what you mean by "not from a jar" - since the junit.framework.TestCase class used to appear in previous versions.
The superclass dilaog should show the class. I can;t reproduce it , it works in my workspace. I suspect that the indexer is the problem. If you enter junit.framework.TestCase by typing, does it warn you that the class doesn't exist?
Created attachment 2282 [details] Here is the screen shot
I have attached the screen shot. I also noticed a strange behavior: I tried the same process on another project, and it worked! So I went into the first project's properties, inside the "Java Build Path" screen, shifted around some of the jars and clicked ok (to force a recompile of the sources) and then tried to add a new class - and this bug did not happen! So I dont know what happened.
Looks like that there was an indexer problem. When you change your classpath, the index is recreated. I move it to JCore.
Weird. Indexes look good though, since the superclass is found in a different context. Rather suspecting some JavaModel inconsistencies (missing/stale roots).
Vijay, do you have details on how this happened? Have you seen this problem since you reported this bug?
Yes - happened again. I had a project that was closed. Opened it and tried to add a new class, and this occurred again.
I'm sorry but I cannot reproduce. I created a JUnit project containing the source for org.junit, I closed it, I reopened it and I created a class in this project. I was able to browse the super class and choose 'testcase'. What is the classpath of your project? Does it refers to another project? If so is this other project closed? The best would be a sequence of steps to reproduce the problem.
The class that I am referring to is inside a jar, and not directly available as source. The projects that I tried, and got this problem, were not referencing any other projects. Neither of them had the junit.jar file in its sub- directory - both were using env variable extension to access the jar. Steps: 1) Open a closed project. 2) Traverse to a package/folder. 3) Right click to create a new class. I also noticed this when I try to navigate to a class (the class that I was trying to get to was the same TestCase).
By any chance, did you use the ECLIPSE_HOME variable to refer to junit.jar. In this case, this would be a dup of bug 25275.
no - though I was accessing it through an "environment" variable that was extendede.
Following the information you gave me so far, here is exactly what I did to try to reproduce: 1. Start Eclipse on a new workspace 2. Open Java perspective 3. File->New->Project->Java Project->Next 4. Entered 'Test' for the project name 5. Next->Libraries->Add Variable->New 6. Entered 'MY_VAR' for the name 7. Path->File 8. Entered path to <eclipse install>/eclipse/plugins/org.junit_3.7.0/junit.jar 9. OK->OK->Finish 10. Select project 'Test' 11. Project->Close Project 12. Project->Open Project->'Test' 13. File->New->Class 14. Entered 'X' for the name of the class 15. Pressed the Browse button for the Superclass 16. Entered 'testcase' The TestCase class was available. Could you please try these steps and tell me if this works for you?
I was finally able to reproduce. Between step 11 and step 12, you need to exit the Workbench and restart to see the problem. I will investigate.
When closing the project, the UI asks if it had children, thus causing getRawClasspath() to be called. This failed to throw a JavaModelException. As a result the PerProjectInfo was populated with a default classpath. When the project was reopened, this cached classpath was used by the IndexManager and thus the junit.jar lib was not indexed. Fixed by changing JavaModelManager.getPerProjectInfoCheckExistence() to use isAccessible() instead of exists(). Added regression test JavaProjectTests.testgetClasspathOnClosedProject()
Verified.
verified as working in M3 stable build.