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

Bug 510550

Summary: [1.9] Classes only available by adding an module-info don't show up in autocomplete
Product: [Eclipse Project] JDT Reporter: Thomas Schindl <tom.schindl>
Component: CoreAssignee: Jay Arthanareeswaran <jarthana>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, manoj.palat, noopur_gupta, sarika.sinha
Version: 4.7   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Thomas Schindl CLA 2017-01-17 03:46:25 EST
For classes not available by default eg all JavaFX stuff one needs to add a module-info.java like this:

---
module TestJ9 {
	requires javafx.base;
	requires javafx.graphics;
	requires javafx.controls;
}
---

This makes code like this 

---
package tes;

import javafx.application.*;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;

public class Main extends Application {
	public static void main(String[] args) {
		Application.launch(args);
	}

	@Override
	public void start(Stage stage) throws Exception {
		BorderPane p = new BorderPane(new Label("Hello Java 9"));
		Scene s = new Scene(p,200,200);
		stage.setScene(s);
		stage.show();
	}
}
---

compile but it looks like the content shown in by triggering auto-complete does not involve those classes. 

To reproduce:
* create a new line
* enter Appli
* hit enter

Expected: Proposal list contains javafx.application.Application
Comment 1 Thomas Schindl CLA 2017-01-17 03:48:16 EST
Correction: Just enter "Appl" else the only proposal is "ApplicationException" and it is inserted.
Comment 2 Noopur Gupta CLA 2017-01-17 04:20:54 EST
"javafx.application.Application" proposal is not returned by ICodeAssist.codeComplete(int offset, CompletionRequestor requestor, IProgressMonitor monitor) at JavaCompletionProposalComputer#internalComputeCompletionProposals in this case. Moving to JDT/Core.
Comment 3 Sasikanth Bharadwaj CLA 2017-01-17 05:53:32 EST
Works fine on master, Could you try with the latest Y-build just to confirm?
Can be downloaded from http://download.eclipse.org/eclipse/downloads/drops4/Y20170112-1300/
The patch most likely does not include the content assist support. We need a new patch built and pushed to the market place
Comment 4 Noopur Gupta CLA 2017-01-17 06:03:46 EST
I was able to reproduce it on master.
Comment 5 Sasikanth Bharadwaj CLA 2017-01-18 03:30:31 EST
(In reply to comment #4)
> I was able to reproduce it on master.
I still can't, trying really hard :-). Jay, what about you? Can you give it a quick try and see?
Comment 6 Noopur Gupta CLA 2017-01-18 03:45:59 EST
It's with the HEAD of BETA_JAVA9 branch (not master).
Comment 7 Jay Arthanareeswaran CLA 2017-01-18 04:18:15 EST
I can reproduce in HEAD of BETA_JAVA9. I will check with Manoj if this is still in progress.
Comment 8 Jay Arthanareeswaran CLA 2017-01-18 04:47:30 EST
I don't see the relevant types coming from the indexer. Possibly some modules excluded by the indexer?

Over to you, Manoj.
Comment 9 Jay Arthanareeswaran CLA 2017-01-18 05:00:50 EST
Okay, investigated bit more and this is about the access restrictions of excluding everything except the select java/** and javax/**. IIRC, there was bug about this, but unable to dig it out now.
Comment 10 Jay Arthanareeswaran CLA 2017-01-18 10:21:54 EST
(In reply to Jay Arthanareeswaran from comment #9)
> Okay, investigated bit more and this is about the access restrictions of
> excluding everything except the select java/** and javax/**. IIRC, there was
> bug about this, but unable to dig it out now.

I can also confirm that completion doesn't work with a JDK 8 either. So, this isn't about Java 9 or modules but about the access restrictions we seem to have in place for non java(x)/** packages.

Sarika, can you comment on this please? Or who will know better about the rules?
Comment 11 Jay Arthanareeswaran CLA 2017-01-18 10:43:13 EST
This is same as bug 480997. The workaround for the bug is to add the JDK as JRE itself instead of EE.

*** This bug has been marked as a duplicate of bug 480997 ***
Comment 12 Thomas Schindl CLA 2017-01-18 13:39:08 EST
You are absolutely right! I was so thinking on JDT-9 that I forgot that normally I have e(fx)clipse installed who fixes the Access-Rules to add javafx.*