Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » No quick fix for some missing imports
No quick fix for some missing imports [message #1859439] Wed, 07 June 2023 21:50 Go to next message
Benoit Coppens is currently offline Benoit CoppensFriend
Messages: 7
Registered: June 2023
Junior Member
Hi,

In some cases, Eclipse does not offer the expected missing import as a quick fix.
I noticed the issue with a brand new download of eclipse-jee-2023-03-R-win32-x86_64, without changing any preference/option.

To reproduce the issue:
1) Create a new "Java Project" with the default options
2) Create a new class with the following main method:

package testPackage;
public class MyClass {
	public static void main(String[] args) {
		ArrayList<String> myList = null;
	}
}


3) With this code, I get the option to add the expected import - see screenshot 1:
index.php/fa/43243/0/

4) Change the code to:

package testPackage;
public class MyClass {
	public static void main(String[] args) {
		ArrayList<String> myList = new ArrayList<String>();
	}
}


5) Now, the option to add the expected import is not there anymore - see screenshot 2
index.php/fa/43244/0/

Is it a known issue? Or a misconfiguration on my side?

Eclipse version with this issue:
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2023-03 (4.27.0)
Build id: 20230309-1520
OS: Windows 10, v.10.0, x86_64 / win32
Java vendor: Eclipse Adoptium
Java runtime version: 17.0.6+10
Java version: 17.0.6

Eclipse version without this issue
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2021-12 (4.22.0)
Build id: 20211202-1639
OS: Windows 10, v.10.0, x86_64 / win32
Java vendor: Eclipse Adoptium
Java runtime version: 17.0.1+12
Java version: 17.0.1

Thanks,
Benoit
  • Attachment: 1.jpg
    (Size: 43.90KB, Downloaded 1780 times)
  • Attachment: 2.jpg
    (Size: 35.78KB, Downloaded 1855 times)


Benoit
Re: No quick fix for some missing imports [message #1859442 is a reply to message #1859439] Thu, 08 June 2023 04:21 Go to previous messageGo to next message
Jay Arthanareeswaran is currently offline Jay ArthanareeswaranFriend
Messages: 134
Registered: July 2009
Senior Member
There must be something about your setup. I don't see this issue with a similar setup. Do you see any error in the error log view or the log file?
Re: No quick fix for some missing imports [message #1859455 is a reply to message #1859442] Thu, 08 June 2023 17:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
I regularly see missing quickfixes in Eclipse 2023-03. Sometimes they reappear under Ctrl+1, or with patience or after terminating a debugger.

Sometimes a save action can insert the unambiguous import, but too often there is just no alternative but to use the old fashioned technique of typing an import statement explicitly.

(There is a longstanding bug that Import quickfixes could be discovered so late that they appeared below many much less promising offerings and so appeared to be missing. This bug was never resolved. Maybe it just got worse with the advent of Java >= 8 support.)
Re: No quick fix for some missing imports [message #1859458 is a reply to message #1859442] Thu, 08 June 2023 21:51 Go to previous messageGo to next message
Benoit Coppens is currently offline Benoit CoppensFriend
Messages: 7
Registered: June 2023
Junior Member
I didn't notice anything in the logs and this is a fresh install of Eclipse.
Same issue on 2 different computers


Benoit
Re: No quick fix for some missing imports [message #1859459 is a reply to message #1859455] Thu, 08 June 2023 21:56 Go to previous messageGo to next message
Benoit Coppens is currently offline Benoit CoppensFriend
Messages: 7
Registered: June 2023
Junior Member
Would you have by any chance the ID of this bug?
In my case, Ctrl+1 does not fix the issue but Ctrl+Shift+O (Organize Imports) does...


Benoit
Re: No quick fix for some missing imports [message #1859462 is a reply to message #1859459] Fri, 09 June 2023 07:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=459016 is a "duplicate" of the original report that might just be my faulty memory then and now.

Organize import, like the save action, can work when the import is unambiguous.

[Updated on: Fri, 09 June 2023 12:47]

Report message to a moderator

Re: No quick fix for some missing imports [message #1859493 is a reply to message #1859462] Sun, 11 June 2023 16:23 Go to previous messageGo to next message
Benoit Coppens is currently offline Benoit CoppensFriend
Messages: 7
Registered: June 2023
Junior Member
Thank you!

Benoit
Re: No quick fix for some missing imports [message #1859551 is a reply to message #1859462] Wed, 14 June 2023 17:59 Go to previous messageGo to next message
Benoit Coppens is currently offline Benoit CoppensFriend
Messages: 7
Registered: June 2023
Junior Member
FYI, based on my first tests, looks like the issue is fixed in 2023-06

Benoit
Re: No quick fix for some missing imports [message #1859553 is a reply to message #1859551] Wed, 14 June 2023 22:04 Go to previous messageGo to next message
Kabiru Usman is currently offline Kabiru UsmanFriend
Messages: 42
Registered: April 2023
Member
Benoit Coppens wrote on Wed, 14 June 2023 17:59
FYI, based on my first tests, looks like the issue is fixed in 2023-06


I didn't find any update. Could you share where you found out about it?
Re: No quick fix for some missing imports [message #1859594 is a reply to message #1859553] Sun, 18 June 2023 22:01 Go to previous messageGo to next message
Benoit Coppens is currently offline Benoit CoppensFriend
Messages: 7
Registered: June 2023
Junior Member
I just performed the steps described in my initial message and noticed that the issue does not happen anymore

Benoit
Re: No quick fix for some missing imports [message #1859673 is a reply to message #1859455] Thu, 22 June 2023 07:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Ed Willink wrote on Thu, 08 June 2023 13:05
I regularly see missing quickfixes in Eclipse 2023-03. Sometimes they reappear under Ctrl+1, or with patience or after terminating a debugger.


These may be due to a broken JDT index. See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1179 The simple fix is Please go to Window -> Preferences -> Java and "Rebuild Index". and be patient.
Re: No quick fix for some missing imports [message #1859679 is a reply to message #1859673] Thu, 22 June 2023 08:25 Go to previous message
Benoit Coppens is currently offline Benoit CoppensFriend
Messages: 7
Registered: June 2023
Junior Member
Thanks for the guidance!

Benoit
Previous Topic:Tika Apache error
Next Topic:Eclipse 2021-12 to access DB2 Database
Goto Forum:
  


Current Time: Fri Jan 24 14:46:05 GMT 2025

Powered by FUDForum. Page generated in 0.04676 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top