Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid unused import warning #392

Open
merks opened this issue Sep 14, 2022 · 6 comments
Open

Invalid unused import warning #392

merks opened this issue Sep 14, 2022 · 6 comments

Comments

@merks
Copy link
Contributor

merks commented Sep 14, 2022

For this example

package org.example.map.entry;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;

public final class Example {

	public static void saveProperties(final Map<String, String> properties) {
		new Properties() {
			private static final long serialVersionUID = 1L;

			@Override
			public Set<Entry<Object, Object>> entrySet() {
				Collection<String> keys = properties.keySet();
				LinkedHashMap<Object, Object> objectMap = new LinkedHashMap<>();
				for (String key : keys) {
					objectMap.put(key, properties.get(key));
				}
				return objectMap.entrySet();
			}
		};
	}
}

the compiler complains:

Description	Resource	Path	Location	Type
The import java.util.Map.Entry is never used	Example.java	/org.example.map.entry/src/org/example/map/entry	line 6	Java Problem

But if you delete the import the editor shows errors but in an odd way such that there are no errors if the Problems view:

image

@iloveeclipse
Copy link
Member

Ed, I can't reproduce in 4.25 with my project/workspace/JRE settings.
Can you provide a project with JDT compiler settings set to reproduce this issue, and may be a hint which JDK is used?

@merks
Copy link
Contributor Author

merks commented Sep 14, 2022

But you're right, I can't reproduce it in a fresh current SDK setup:

org.example.map.entry.zip

@merks
Copy link
Contributor Author

merks commented Sep 14, 2022

It only happens when my JRE is C:\Program Files\Java\jdk-17.0.4.1+1. I think it happens for any Java 17 JDK...

@iloveeclipse
Copy link
Member

It only happens when my JRE is C:\Program Files\Java\jdk-17.0.4.1+1.

I think it happens for any Java 17 JDK...

Is this only with or with any now?
Note: I've tried on Temurin-17.0.4+8 and couldn't reproduce with your project, also on 4.26 master.

@merks
Copy link
Contributor Author

merks commented Sep 14, 2022

It also happens with C:\Program Files\Java\jdk-17.0.1+12

@srikanth-sankaran
Copy link
Contributor

eclipsewebmaster pushed a commit to eclipse-oomph/oomph that referenced this issue Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants