Bug 25358 - Creating a new Java class - Browse for parent
Summary: Creating a new Java class - Browse for parent
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M3   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-24 17:36 EDT by Vijay Aravamudhan CLA
Modified: 2002-11-16 14:06 EST (History)
0 users

See Also:


Attachments
Here is the screen shot (405.90 KB, image/bmp)
2002-10-28 14:22 EST, Vijay Aravamudhan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vijay Aravamudhan CLA 2002-10-24 17:36:33 EDT
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.
Comment 1 Vijay Aravamudhan CLA 2002-10-28 01:27:31 EST
I am running M2 - and this was working in M1.
Comment 2 Claude Knaus CLA 2002-10-28 06:55:58 EST
Martin, was this behaviour changed intentionally?
Comment 3 Martin Aeschlimann CLA 2002-10-28 08:05:32 EST
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)
Comment 4 Vijay Aravamudhan CLA 2002-10-28 09:40:20 EST
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.
Comment 5 Martin Aeschlimann CLA 2002-10-28 13:25:16 EST
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?
Comment 6 Vijay Aravamudhan CLA 2002-10-28 14:22:29 EST
Created attachment 2282 [details]
Here is the screen shot
Comment 7 Vijay Aravamudhan CLA 2002-10-28 14:33:15 EST
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.
Comment 8 Martin Aeschlimann CLA 2002-10-29 03:10:23 EST
Looks like that there was an indexer problem. When you change your classpath, 
the index is recreated.

I move it to JCore.
Comment 9 Philipe Mulet CLA 2002-10-29 05:29:55 EST
Weird. Indexes look good though, since the superclass is found in a different 
context. Rather suspecting some JavaModel inconsistencies (missing/stale roots).

Comment 10 Jerome Lanneluc CLA 2002-10-29 09:28:49 EST
Vijay, do you have details on how this happened? Have you seen this problem 
since you reported this bug?
Comment 11 Vijay Aravamudhan CLA 2002-10-29 10:50:17 EST
Yes - happened again. I had a project that was closed. Opened it and tried to 
add a new class, and this occurred again.
Comment 12 Jerome Lanneluc CLA 2002-10-30 05:08:29 EST
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.
Comment 13 Vijay Aravamudhan CLA 2002-10-30 11:13:45 EST
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).
Comment 14 Jerome Lanneluc CLA 2002-10-31 13:29:00 EST
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.
Comment 15 Vijay Aravamudhan CLA 2002-10-31 13:43:19 EST
no - though I was accessing it through an "environment" variable that was 
extendede.
Comment 16 Jerome Lanneluc CLA 2002-11-01 11:10:58 EST
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?
Comment 17 Jerome Lanneluc CLA 2002-11-01 11:14:10 EST
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.
Comment 18 Jerome Lanneluc CLA 2002-11-04 07:22:43 EST
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()
Comment 19 David Audel CLA 2002-11-13 07:32:32 EST
Verified.
Comment 20 Vijay Aravamudhan CLA 2002-11-16 14:06:32 EST
verified as working in M3 stable build.