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

Bug 522671

Summary: [9] Types are not found in the Editor
Product: [Eclipse Project] JDT Reporter: Till Brychcy <register.eclipse>
Component: CoreAssignee: Till Brychcy <register.eclipse>
Status: VERIFIED FIXED QA Contact: Stephan Herrmann <stephan.herrmann>
Severity: normal    
Priority: P3 CC: jarthana
Version: 4.8   
Target Milestone: 4.8 M3   
Hardware: PC   
OS: Mac OS X   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=522670
https://bugs.eclipse.org/bugs/show_bug.cgi?id=522327
https://git.eclipse.org/r/105822
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=f8770d508aeb5800826e9043ddb68269cfb486d1
https://git.eclipse.org/r/105894
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=ead103ad7c36e3aef324ce63c4500c4a7ba3557c
Whiteboard:

Description Till Brychcy CLA 2017-09-22 16:31:50 EDT
DESCRIPTION:
Create the following four projects (the same as in bug 522670, but the type annotations are not relevant here and have been removed)

--- project util, 3 files:
module util {
	exports my.util;
}
--
package my.util;
public abstract class AnnotatedInModule {
	abstract public Data getTime();
}
--
package my.util;
public class Data {
}

--- project util2, 2 files:
module util2 {
	exports my.util.nested;
}
--
package my.util.nested;
class Unrelated {
}

--- project other (1 file) with project util on the modulepath:
package a.other;
import my.util.Data;
public class AnnotatedInOtherNonModule {
	Data generationDate;
}

--- project test (1 file)
package test;
import a.other.AnnotatedInOtherNonModule;
import my.util.AnnotatedInModule;
import my.util.Data;
public class Test extends AnnotatedInOtherNonModule {
	public Data f(AnnotatedInModule calendar) {
		return calendar.getTime();
	}
}

Open Test in an editor. Only in the editor, errors are show because the types my.util.AnnotatedInModule and my.util.Data are not found.

ANALYSIS:
The toplevel package "my" is only in the modulebinding and not in the corresponding LookupEnvironment,
so a new PackageBinding instance is created for "my.util" when the types are compiled to which they are added so the types are not found
in the already existing PackageBinding.

PATCH:
Make sure that toplevel packages that are put into ModuleBinding.declaredPackages are always also put into the correspoding LookupEnvironment.knownPackages
This also fixes bug 522327 in a better way to the patch for that code in LookupEnvironment has been reverted.
Comment 1 Till Brychcy CLA 2017-09-24 14:18:57 EDT
@Stephan, the patch is simple, still a second look by you is always appreciated :-)
Comment 2 Eclipse Genie CLA 2017-09-27 02:33:36 EDT
New Gerrit change created: https://git.eclipse.org/r/105822
Comment 3 Till Brychcy CLA 2017-09-27 02:37:35 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/105822

patch for the master, replaces https://git.eclipse.org/r/#/c/105648/

it would be good to get this into 4.7.1a, if still possible.
Comment 5 Till Brychcy CLA 2017-09-27 13:17:46 EDT
(In reply to Eclipse Genie from comment #4)
> Gerrit change https://git.eclipse.org/r/105822 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=f8770d508aeb5800826e9043ddb68269cfb486d1

Released for 4.8M3
Comment 6 Till Brychcy CLA 2017-09-28 02:48:17 EDT
(In reply to Till Brychcy from comment #0)
 > PATCH:
> This also fixes bug 522327 in a better way to the patch for that code in
> LookupEnvironment has been reverted.
That was too optimistic. I found a case where the code in LE still is needed. I'll revert that part of the patch.
Comment 7 Eclipse Genie CLA 2017-09-28 03:14:23 EDT
New Gerrit change created: https://git.eclipse.org/r/105894
Comment 9 Till Brychcy CLA 2017-09-29 01:06:25 EDT
(In reply to Eclipse Genie from comment #8)
> Gerrit change https://git.eclipse.org/r/105894 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=ead103ad7c36e3aef324ce63c4500c4a7ba3557c

Released for 4.8M3
Comment 10 Jay Arthanareeswaran CLA 2017-10-26 06:21:07 EDT
Verified for 4.8 M3 with build id I20171023-2000