Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 468260 - [1.9] jrt visitor implementation should use package-module lookup
Summary: [1.9] jrt visitor implementation should use package-module lookup
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: BETA J9   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 457413
  Show dependency tree
 
Reported: 2015-05-26 02:55 EDT by Jay Arthanareeswaran CLA
Modified: 2015-10-15 09:57 EDT (History)
4 users (show)

See Also:
manoj.palat: review+


Attachments
WIP (3.66 KB, patch)
2015-08-03 13:45 EDT, Manoj N Palat CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Arthanareeswaran CLA 2015-05-26 02:55:51 EDT
Right now, given a JDK 9, JDT has to look into every module (one by one) to find a type, given its qualified name. Obviously this is not scalable, but will change once the following enhancement is added in Oracle's JDK:

https://bugs.openjdk.java.net/browse/JDK-8066492
Comment 1 Jay Arthanareeswaran CLA 2015-07-23 00:10:44 EDT
(In reply to Jay Arthanareeswaran from comment #0)
> https://bugs.openjdk.java.net/browse/JDK-8066492

I see the bug is resolved now. Not sure if this made it to the latest JDK build. Will try out and update.
Comment 2 Jay Arthanareeswaran CLA 2015-07-23 04:23:38 EDT
I checked with the Oracle contact (Rory O'Donnell) and confirmed that it is not in the latest (b72) build. We will have to wait.
Comment 3 Dani Megert CLA 2015-07-23 04:25:15 EDT
(In reply to Jay Arthanareeswaran from comment #2)
> I checked with the Oracle contact (Rory O'Donnell) and confirmed that it is
> not in the latest (b72) build. We will have to wait.

Can he give an ETA?
Comment 4 Jay Arthanareeswaran CLA 2015-07-29 23:42:00 EDT
(In reply to Dani Megert from comment #3)
> (In reply to Jay Arthanareeswaran from comment #2)
> > I checked with the Oracle contact (Rory O'Donnell) and confirmed that it is
> > not in the latest (b72) build. We will have to wait.
> 
> Can he give an ETA?

I can confirm build b74 has the changes we want. I will shortly release the changes and request for a rebuild. But... with the change, things will stop working with the older Java 9 builds unless we code it to support both formats. But I think it's not necessary.
Comment 5 Jay Arthanareeswaran CLA 2015-07-30 03:49:40 EDT
For the records, there are some non Java resources which are located in default packages but not recorded in the /packages sub directory. Right now loading the contents of such files are failing because we are not storing the module information for such non Java resources. Need to figure out a way to do this.
Comment 6 Dani Megert CLA 2015-07-30 06:05:48 EDT
(In reply to Jay Arthanareeswaran from comment #4)
> ... with the change, things will stop
> working with the older Java 9 builds unless we code it to support both
> formats. But I think it's not necessary.

I agree.
Comment 7 Jay Arthanareeswaran CLA 2015-07-30 09:58:32 EDT
Released the fix in BETA_JAVA9 via:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA9&id=60e5050245e9e4e75329204e929e8e9b4bdce52c

The fix uses an internal cache heavily for navigating through modules and packages. We should start thinking about the restructure - bug 473901.

Manoj, when you have some time, please review the fix.
Comment 8 Manoj N Palat CLA 2015-08-03 13:45:21 EDT
Created attachment 255598 [details]
WIP

(In reply to Jay Arthanareeswaran from comment #7)

> Manoj, when you have some time, please review the fix.

Thanks Jay; please find my review comments below:

Util.754: The check "if (relative.getNameCount() <= 1)" needs to be there - this is removed with the current change - an immediate return with CONTINUE can be there as it was originally. Any reasons for removing this statement?

cachePackage/getModule: couple of points:

a) since walker populates the hash associated, I would assume the ordering is preserved and hence does not warrant the extra processing done for java.base.

b) assuming (a), a hashmap of LinkedHashSet as value looks more appropriate

attached is a work-in-progress untested first cut patch that has this data structure.
Comment 9 Jay Arthanareeswaran CLA 2015-08-10 04:30:47 EDT
(In reply to Manoj Palat from comment #8)
> Created attachment 255598 [details]
> WIP

A reminder to self to work with the releng team to update the update sites when the fix is in.
Comment 10 Markus Keller CLA 2015-08-10 15:17:17 EDT
(In reply to Jay Arthanareeswaran from comment #7)
The loop at http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java?h=BETA_JAVA9&id=b0e07bcb3f2a6fb8c842095707a7fcc2f6f86c34#n866 doesn't make sense: (broken cGit rendering is bug 474639)

for (String mod : modules) {
	return Files.newInputStream(fs.getPath(MODULES_SUBDIR, mod, fileName));
}

This only ever tries the first module.
Comment 11 Jay Arthanareeswaran CLA 2015-08-11 04:50:23 EDT
(In reply to Markus Keller from comment #10)
> (In reply to Jay Arthanareeswaran from comment #7)
> The loop at
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tree/org.eclipse.jdt.core/
> compiler/org/eclipse/jdt/internal/compiler/util/Util.
> java?h=BETA_JAVA9&id=b0e07bcb3f2a6fb8c842095707a7fcc2f6f86c34#n866 doesn't
> make sense: (broken cGit rendering is bug 474639)
> 
> for (String mod : modules) {
> 	return Files.newInputStream(fs.getPath(MODULES_SUBDIR, mod, fileName));
> }
> 
> This only ever tries the first module.

Yep, I agree it is only slightly better than what we had in the previous commit where we simply read from modules[0]. Unfortunately Files.newInputStream(..) doesn't tell us what happens when the file is not found. For now we will keep this as an open issue.
Comment 12 Manoj N Palat CLA 2015-08-25 01:52:26 EDT
(In reply to Manoj Palat from comment #8)
> cachePackage/getModule: couple of points:
> 
> a) since walker populates the hash associated, I would assume the ordering
> is preserved and hence does not warrant the extra processing done for
> java.base.

Will hold on to this change of cachePackage/getModule until we have a guarantee of the order. So +1 for now.
Comment 13 Jay Arthanareeswaran CLA 2015-10-15 09:57:40 EDT
As of now, this is fixed.