Skip to content

Commit

Permalink
Add Enumeration to legacy apis
Browse files Browse the repository at this point in the history
  • Loading branch information
delany-traderoot authored and gaul committed Jul 2, 2023
1 parent f506de2 commit 222c543
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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

0 comments on commit 222c543

Please sign in to comment.