Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357110

Summary: Problem with inner classes referenced from jars or class folders: "The type ... cannot be resolved"
Product: [Eclipse Project] JDT Reporter: Thomas Philipp <philipp>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, brianchin, Michael_Rennie, Olivier_Thomann, srikanth_sankaran
Version: 3.8Flags: srikanth_sankaran: review+
Target Milestone: 3.7.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch v1
none
Patch v2 none

Description Thomas Philipp CLA 2011-09-08 11:30:48 EDT
Build Identifier: I20110613-1736

The opened Java-Editor shows reproducable under some circumstances the (wrong) error message "The type .. cannot be resolved. It is indirectly referenced from required .class files."
However, the Package-Explorer does not show this error. The error is only displayed in the Editor. 
If the error happens the org.eclipse.jdt.core.dom.ASTParser is not able to parse this java file (which is called by a plugin of mine).
I found no workaround for this but to refactor some classes not to be inner classes any more, but this is not really a good workaround.

Reproducible: Always

Steps to Reproduce:
The error is reproduceable as follows:
- Create a class A with a static inner Class I in the sourcefolder "src"
  with outputfolder "bin".
- Create a class B beeing a subclass of I in the same project in another   
  sourcefolder "src2". Let the outputfolder of "src2" be "bin2".
- Create a class C beeing a subclass of B in the first source folder "src".
- Now change the project settings by removing the sourcefolder "src2"
  and instead add the "bin2" folder to the libraries.
  By this the class B is now only available as a binary class file.
- Open the Editor for the class C and find the error message describe above.

The same problem arises reproducably, if the the class file of B is not in a classfolder but in a jar.
There is no problem, if I is not an inner class but a normal class.
Comment 1 Olivier Thomann CLA 2011-09-09 09:29:37 EDT
I'll take a look.
Comment 2 Olivier Thomann CLA 2011-09-09 11:17:25 EDT
This was broken also in 3.6.
Comment 3 Olivier Thomann CLA 2011-09-09 11:30:32 EDT
(In reply to comment #0)
> I found no workaround for this but to refactor some classes not to be inner
> classes any more, but this is not really a good workaround.
This is not a workaround. The problem here is that A is still seen as a source type where B is seen as a binary type. So A$I is searched into a source fragment root as source and not as a binary type.
I'll provide a patch soon that will need to be intensively tested.
Comment 4 Olivier Thomann CLA 2011-09-09 11:31:00 EDT
Created attachment 203069 [details]
Patch v1

Under test.
Comment 5 Olivier Thomann CLA 2011-09-09 13:12:07 EDT
Created attachment 203078 [details]
Patch v2

The previous patch would return duplicated types.
Comment 6 Olivier Thomann CLA 2011-09-09 13:20:04 EDT
Srikanth, please review. This is a case that I believe never worked. Retrieve from a source package fragment a type that is defined inside a binary type (p/A$I in this case).
Comment 7 Olivier Thomann CLA 2011-09-20 09:41:31 EDT
Released for 3.8M3.
Comment 8 Srikanth Sankaran CLA 2011-10-24 20:35:08 EDT
Verified for 3.8 M3 using build id: N20111022-2000
Patch looks good. (could be simplified a bit, but I'll leave it as it is)
Comment 9 Brian Chin CLA 2011-11-17 15:16:21 EST
If at all possible, could this patch be moved up to the 3.7 Maintenance Branch? We're currently running into this problem with some of our users, and it would be great to see a fix before the 3.8 release.
Comment 10 Srikanth Sankaran CLA 2011-11-20 23:46:14 EST
(In reply to comment #9)
> If at all possible, could this patch be moved up to the 3.7 Maintenance Branch?
> We're currently running into this problem with some of our users, and it would
> be great to see a fix before the 3.8 release.

Ayush, Along with the other fixes you are backporting, could you please
include this one also please. TIA.
Comment 11 Ayushman Jain CLA 2011-11-23 02:04:53 EST
Released in 3-7 maintenance branch via commit 9ae69253a6820a853326ea257bd70fb5b0aab8f4
Comment 12 Srikanth Sankaran CLA 2012-01-19 03:42:55 EST
Verified for 3.7.2RC2 using build M20120118-0800