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

Add Enumeration to legacy apis #185

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modernizer-maven-plugin/src/main/resources/modernizer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ violation names use the same format that javap emits.
<comment>Prefer java.util.Collections.emptySet()</comment>
</violation>

<violation>
<name>java/util/Enumeration</name>
<version>2</version>
<comment>Prefer java.util.Iterator</comment>
</violation>

<violation>
<name>java/util/Hashtable."&lt;init&gt;":(IF)V</name>
<version>2</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.Formatter;
import java.util.Hashtable;
import java.util.Locale;
Expand Down Expand Up @@ -418,6 +419,8 @@ public void testAllViolations() throws Exception {
occurrences.addAll(modernizer.check(
new ClassReader(Java19Violations.class.getName())));
// must visit inner classes manually
occurrences.addAll(modernizer.check(
new ClassReader(EnumerationTestClass.class.getName())));
occurrences.addAll(modernizer.check(
new ClassReader(VoidFunction.class.getName())));
occurrences.addAll(modernizer.check(
Expand Down Expand Up @@ -516,6 +519,14 @@ private static class StringGetBytesCharset {
private final Object object = "".getBytes(StandardCharsets.UTF_8);
}

private static class EnumerationTestClass implements Enumeration<Object> {
@Override
public boolean hasMoreElements() { return false; }

@Override
public Object nextElement() { return null; }
}

private static class VoidFunction implements Function<Void, Void> {
@Override
public Void apply(Void input) {
Expand Down