ICU-23247 Fix all 'UnusedMethod' errorprone issues
diff --git a/errorprone.cfg b/errorprone.cfg index 5743032..fe97675 100644 --- a/errorprone.cfg +++ b/errorprone.cfg
@@ -20,6 +20,7 @@ -Xep:ReturnValueIgnored:ERROR -Xep:SelfComparison:ERROR -Xep:SelfEquals:ERROR +-Xep:UnusedMethod:ERROR # By default errorprone classifies this as error, and breaks the build. -Xep:LabelledBreakTarget:WARN
diff --git a/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/calendar/CalendarFrame.java b/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/calendar/CalendarFrame.java index c7016df..fb1f47a 100644 --- a/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/calendar/CalendarFrame.java +++ b/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/calendar/CalendarFrame.java
@@ -339,10 +339,6 @@ private static class ColoredLabel extends Component { /** For serialization */ private static final long serialVersionUID = 5004484960341875722L; - public ColoredLabel(String label) { - text = label; - } - public ColoredLabel(String label, Color c) { text = label; color = c;
diff --git a/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/holiday/HolidayCalendarDemo.java b/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/holiday/HolidayCalendarDemo.java index cb9814b..31fb79e 100644 --- a/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/holiday/HolidayCalendarDemo.java +++ b/icu4j/demos/src/main/java/com/ibm/icu/dev/demo/holiday/HolidayCalendarDemo.java
@@ -123,14 +123,6 @@ public void init() { buildGUI(); } - // ------------------------------------------------------------ - // package private - // ------------------------------------------------------------ - void addWithFont(Container container, Component foo, Font font) { - if (font != null) foo.setFont(font); - container.add(foo); - } - /** * Called to start the applet. You never need to call this method directly, it is called * when the applet's document is visited. @@ -357,13 +349,6 @@ public void itemStateChanged(ItemEvent e) { } } - /** Print out the error message while debugging this program. */ - public void errorText(String s) { - if (DEBUG) { - System.out.println(s); - } - } - protected void processWindowEvent(WindowEvent e) { System.out.println("event " + e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { @@ -431,10 +416,6 @@ public com.ibm.icu.util.Calendar getCalendar() { return fCalendar; } - public Locale getCalendarLocale() { - return fCalendarLocale; - } - public Locale getDisplayLocale() { return fDisplayLocale; }
diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/impl/breakiter/LSTMBreakEngine.java b/icu4j/main/core/src/main/java/com/ibm/icu/impl/breakiter/LSTMBreakEngine.java index dfe671b..1e8d6db 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/impl/breakiter/LSTMBreakEngine.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/impl/breakiter/LSTMBreakEngine.java
@@ -269,13 +269,6 @@ private static void addDotProductTo(final float[] a, final float[][] b, float[] } } - private static void addTo(final float[] a, float[] result) { - assert a.length == result.length; - for (int i = 0; i < result.length; i++) { - result[i] += a[i]; - } - } - private static void hadamardProductTo(final float[] a, float[] result) { assert a.length == result.length; for (int i = 0; i < result.length; i++) {
diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java index 004ce60..d131b0c 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/message2/MFParser.java
@@ -7,8 +7,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * This class parses a {@code MessageFormat 2} syntax into a data model {@link MFDataModel.Message}. @@ -834,14 +832,4 @@ private void error(String message) throws MFParseException { } throw new MFParseException(finalMsg.toString(), input.getPosition()); } - - private String peekWithRegExp(Pattern pattern) { - StringView sv = new StringView(input.buffer, input.getPosition()); - Matcher m = pattern.matcher(sv); - if (m.find()) { - input.skip(m.group().length()); - return m.group(); - } - return null; - } }
diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/text/DateTimePatternGenerator.java b/icu4j/main/core/src/main/java/com/ibm/icu/text/DateTimePatternGenerator.java index 10e2210..7ef7f7b 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/text/DateTimePatternGenerator.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/text/DateTimePatternGenerator.java
@@ -24,7 +24,6 @@ import com.ibm.icu.util.UResourceBundle; import java.util.ArrayList; import java.util.Arrays; -import java.util.BitSet; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; @@ -225,18 +224,6 @@ private String getCalendarTypeToUse(ULocale uLocale) { return calendarTypeToUse; } - private void consumeShortTimePattern(String shortTimePattern, PatternInfo returnInfo) { - // keep this pattern to populate other time field - // combination patterns by hackTimes later in this method. - // ICU-20383 No longer set defaultHourFormatChar to the hour format character from - // this pattern; instead it is set from LOCALE_TO_ALLOWED_HOUR which now - // includes entries for both preferred and allowed formats. - - // some languages didn't add mm:ss or HH:mm, so put in a hack to compute that from the short - // time. - hackTimes(returnInfo, shortTimePattern); - } - private class AppendItemFormatsSink extends UResource.Sink { @Override public void put(UResource.Key key, UResource.Value value, boolean noFallback) { @@ -537,71 +524,6 @@ public void setDefaultHourFormatChar(char defaultHourFormatChar) { this.defaultHourFormatChar = defaultHourFormatChar; } - private void hackTimes(PatternInfo returnInfo, String shortTimePattern) { - fp.set(shortTimePattern); - StringBuilder mmss = new StringBuilder(); - // to get mm:ss, we strip all but mm literal ss - boolean gotMm = false; - for (int i = 0; i < fp.items.size(); ++i) { - Object item = fp.items.get(i); - if (item instanceof String) { - if (gotMm) { - mmss.append(fp.quoteLiteral(item.toString())); - } - } else { - char ch = item.toString().charAt(0); - if (ch == 'm') { - gotMm = true; - mmss.append(item); - } else if (ch == 's') { - if (!gotMm) { - break; // failed - } - mmss.append(item); - addPattern(mmss.toString(), false, returnInfo); - break; - } else if (gotMm || ch == 'z' || ch == 'Z' || ch == 'v' || ch == 'V') { - break; // failed - } - } - } - // to get hh:mm, we strip (literal ss) and (literal S) - // the easiest way to do this is to mark the stuff we want to nuke, then remove it in a - // second pass. - BitSet variables = new BitSet(); - BitSet nuke = new BitSet(); - for (int i = 0; i < fp.items.size(); ++i) { - Object item = fp.items.get(i); - if (item instanceof VariableField) { - variables.set(i); - char ch = item.toString().charAt(0); - if (ch == 's' || ch == 'S') { - nuke.set(i); - for (int j = i - 1; j >= 0; ++j) { - if (variables.get(j)) break; - nuke.set(i); - } - } - } - } - String hhmm = getFilteredPattern(fp, nuke); - addPattern(hhmm, false, returnInfo); - } - - private static String getFilteredPattern(FormatParser fp, BitSet nuke) { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < fp.items.size(); ++i) { - if (nuke.get(i)) continue; - Object item = fp.items.get(i); - if (item instanceof String) { - result.append(fp.quoteLiteral(item.toString())); - } else { - result.append(item.toString()); - } - } - return result.toString(); - } - /*private static int getAppendNameNumber(String string) { for (int i = 0; i < CLDR_FIELD_NAME.length; ++i) { if (CLDR_FIELD_NAME[i].equals(string)) return i;
diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/text/PluralRules.java b/icu4j/main/core/src/main/java/com/ibm/icu/text/PluralRules.java index 08358af..78452c5 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/text/PluralRules.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/text/PluralRules.java
@@ -863,28 +863,6 @@ public static int decimals(double n) { } /** - * @internal CLDR - * @deprecated This API is ICU internal only - */ - @Deprecated - private FixedDecimal(FixedDecimal other) { - // Ugly, but necessary, because constructors must only call other - // constructors in the first line of the body, and - // FixedDecimal(String) was refactored to support exponents. - this.source = other.source; - this.visibleDecimalDigitCount = other.visibleDecimalDigitCount; - this.visibleDecimalDigitCountWithoutTrailingZeros = - other.visibleDecimalDigitCountWithoutTrailingZeros; - this.decimalDigits = other.decimalDigits; - this.decimalDigitsWithoutTrailingZeros = other.decimalDigitsWithoutTrailingZeros; - this.integerValue = other.integerValue; - this.hasIntegerValue = other.hasIntegerValue; - this.isNegative = other.isNegative; - this.exponent = other.exponent; - this.baseFactor = other.baseFactor; - } - - /** * {@inheritDoc} * * @internal CLDR
diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/util/IslamicCalendar.java b/icu4j/main/core/src/main/java/com/ibm/icu/util/IslamicCalendar.java index ddb2354..324483d 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/util/IslamicCalendar.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/util/IslamicCalendar.java
@@ -1270,14 +1270,6 @@ private static final boolean civilLeapYear(int year) { } /** - * Return the day # on which the given year starts. Days are counted from the Hijri epoch, - * origin 0. - */ - private long yearStart(int year) { - return algorithm.yearStart(year); - } - - /** * Find the day number on which a particular month of the true/lunar Islamic calendar starts. * * @param month The month in question, origin 0 from the Hijri epoch
diff --git a/icu4j/tools/build/src/main/java/com/ibm/icu/dev/tool/coverage/JacocoReportCheck.java b/icu4j/tools/build/src/main/java/com/ibm/icu/dev/tool/coverage/JacocoReportCheck.java index 9210477..0ab637d 100644 --- a/icu4j/tools/build/src/main/java/com/ibm/icu/dev/tool/coverage/JacocoReportCheck.java +++ b/icu4j/tools/build/src/main/java/com/ibm/icu/dev/tool/coverage/JacocoReportCheck.java
@@ -307,10 +307,6 @@ private static class Counter { int missed() { return missed; } - - int covered() { - return covered; - } } private static class Method { @@ -351,26 +347,6 @@ String desc() { return desc; } - int line() { - return line; - } - - Counter instructionCounter() { - return instructionCnt; - } - - Counter branchCounter() { - return branchCnt; - } - - Counter lineCounter() { - return lineCnt; - } - - Counter complexityCounter() { - return complexityCnt; - } - Counter methodCounter() { return methodCnt; } @@ -391,10 +367,6 @@ String key() { return key; } - String cls() { - return cls; - } - Method method() { return method; }