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

Bug 577612

Summary: No autocompletion / organize imports for JDK17 incubator classes
Product: [Eclipse Project] JDT Reporter: Jan Mosig <jan.mosig>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource, Lars.Vogel, loskutov
Version: 4.21   
Target Milestone: ---   
Hardware: PC   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=571758
Whiteboard:
Attachments:
Description Flags
eclipse.ini for reference
none
Screenshot of failing auto complete on an instance of jdk.incubator.foreign.addressable none

Description Jan Mosig CLA 2021-12-03 06:16:57 EST
Created attachment 287620 [details]
eclipse.ini for reference

Hi there,

the other day I struggled to migrate a Java project of mine from JDK16 to JDK17 that uses the jdk.incubator.foreign API.

Specifically the auto completion and organize imports (also Quickfix) features do not seem to work anymore for classes located in jdk.incubator.foreign.

These features used to work fine with Eclipse 4.20 (2021-06).

Because of this lack of support it is virtually impossible to work with jdk.incubator.foreign (or any other incubator feature I guess) which is a blocker for me.

Any help is appreciated.

*Workaround*
If I add imports manually or use FQN, the code compiles. However, it still fails to provide any useful autocompletion on instances of imported classes (see attached screen shot).

*How to reproduce*
* Have Eclipse 4.21 (2021-09) ready with latest JDT JDK17 patches installed.
* Import the provided example project (or create a new one)
* Try autocompletion or quickfix on a Type from jdk.incubator.foreign (e. g. Addressable).

*Example Project*
I've provided a sample project here: https://github.com/JanMosigItemis/java17JdtBug

*System Specs*
I am using Eclipse 4.21 with Eclipse JDT (Java Development Tools) Patch with Java 17 support 1.2.200.v20211026-0535_BETA_JAVA17 (did also not work with the patch from Sep 2021).

Microsoft Windows [Version 10.0.19043.1387] (21H1)
java version "17" 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)


I have attached my eclipse.ini where I already added the following entries:

-vm
C:/Program Files/Java/jdk17/bin
--add-modules=ALL-SYSTEM,jdk.incubator.foreign
--enable-native-access=ALL-UNNAMED
Comment 1 Jan Mosig CLA 2021-12-03 06:17:44 EST
Created attachment 287621 [details]
Screenshot of failing auto complete on an instance of jdk.incubator.foreign.addressable
Comment 2 Andrey Loskutov CLA 2021-12-03 07:27:25 EST
Please check if 4.22 RC2 solved yoir problem. There were some fixes in content assist area.
Comment 3 Jan Mosig CLA 2021-12-03 08:13:14 EST
Thank you for the quick reply. The download page currently only lists RC1. Where can I get RC2?
Comment 4 Andrey Loskutov CLA 2021-12-03 08:23:20 EST
(In reply to Jan Mosig from comment #3)
> Thank you for the quick reply. The download page currently only lists RC1.
> Where can I get RC2?

From the download page of course :-)
https://download.eclipse.org/eclipse/downloads/
Comment 5 Jan Mosig CLA 2021-12-03 11:05:02 EST
Thanks for the hint :)

It does not work with 4.22 RC2 also I am afraid.
Comment 6 Andrey Loskutov CLA 2021-12-09 05:44:40 EST
(In reply to Andrey Loskutov from comment #4)
> (In reply to Jan Mosig from comment #3)
> > Thank you for the quick reply. The download page currently only lists RC1.
> > Where can I get RC2?
> 
> From the download page of course :-)
> https://download.eclipse.org/eclipse/downloads/

Thanks.

This is an expected outcome from bug 571758 changes.

You can fix it immediately by un-checking 
Prefereneces > Java > Type Filters -> jdk.* filter.

I tend to close it as won't fix, because most people don't want jdk.* to be shown in proposals, but if you have good reason to have them shown, please speak up.
Comment 7 Lars Vogel CLA 2021-12-09 06:08:42 EST
Maybe the code completion popup could show an entry "Some entries are filtered out due to ..." and could allow to jump to the preference. If that would be desired by the JDT team, we could open another bug for this.
Comment 8 Andrey Loskutov CLA 2021-12-09 06:37:34 EST
(In reply to Lars Vogel from comment #7)
> Maybe the code completion popup could show an entry "Some entries are
> filtered out due to ..." and could allow to jump to the preference. If that
> would be desired by the JDT team, we could open another bug for this.

Good idea, I don't know if that is technically possible, but from user perspective would be clear improvement.
Comment 9 Lars Vogel CLA 2021-12-09 09:03:04 EST
(In reply to Andrey Loskutov from comment #8)

> Good idea, I don't know if that is technically possible, but from user
> perspective would be clear improvement.

Bug 577710 created.
Comment 10 Jan Mosig CLA 2021-12-10 03:07:32 EST
Thanks for the hints and ideas guys.

I confirm that disabling the type filter "jdk.*" solves the problem. 

I do also agree: A visual hint on active type filters would be helpful. Maybe a quickfix is another viable option.

Imo without any hint, not showing "rarely" used classes in content assist is very counter intuitive, since my expectation is that all matching options are shown. This was the default in early versions of Eclipse and is afaik also the default behavior of other IDEs.

However, since there is a new bug on this topic, I'd say we close this one here with won't fix or any other status you see fit.
Comment 11 Lars Vogel CLA 2021-12-10 04:59:11 EST
Thanks, Jan for the feedback.