eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Invalid unused import warning

Open
#392 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

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 properties) {
new Properties() {
private static final long serialVersionUID = 1L;

@Override
public Set> entrySet() {
Collection keys = properties.keySet();
LinkedHashMap 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](https://user-images.githubusercontent.com/208716/190144103-59afcf00-8bbb-43e1-b0a5-6ffd3a1cc755.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.