From 0afc7ada0dec9b3d99f4e84a8f2e55f19074cac4 Mon Sep 17 00:00:00 2001 From: Delany Date: Wed, 12 Apr 2023 23:24:47 +0200 Subject: [PATCH] Add Enumeration to legacy apis --- .../src/main/resources/modernizer.xml | 6 ++++++ .../gaul/modernizer_maven_plugin/ModernizerTest.java | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/modernizer-maven-plugin/src/main/resources/modernizer.xml b/modernizer-maven-plugin/src/main/resources/modernizer.xml index f428674c..12862db8 100644 --- a/modernizer-maven-plugin/src/main/resources/modernizer.xml +++ b/modernizer-maven-plugin/src/main/resources/modernizer.xml @@ -533,6 +533,12 @@ violation names use the same format that javap emits. Prefer java.util.Collections.emptySet() + + java/util/Enumeration + 2 + Prefer java.util.Iterator + + java/util/Hashtable."<init>":(IF)V 2 diff --git a/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java b/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java index 0b2a8d44..e980f46e 100644 --- a/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java +++ b/modernizer-maven-plugin/src/test/java/org/gaul/modernizer_maven_plugin/ModernizerTest.java @@ -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; @@ -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( @@ -516,6 +519,14 @@ private static class StringGetBytesCharset { private final Object object = "".getBytes(StandardCharsets.UTF_8); } + private static class EnumerationTestClass implements Enumeration { + @Override + public boolean hasMoreElements() { return false; } + + @Override + public Object nextElement() { return null; } + } + private static class VoidFunction implements Function { @Override public Void apply(Void input) {