From e5105c7f84237a46e986105cf0edcc76edd4d568 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Tue, 22 Sep 2015 00:32:25 +0000 Subject: [PATCH] ICU-11918 Fixed compiler warnings. X-SVN-Rev: 37977 --- .../ibm/icu/impl/coll/CollationTailoring.java | 1 - icu4j/main/classes/core/build.properties | 4 +- .../core/src/com/ibm/icu/impl/Relation.java | 31 ++++++------ .../com/ibm/icu/text/UCharacterIterator.java | 1 - .../icu/dev/test/util/LocaleMatcherTest.java | 2 + .../icu/dev/tool/docs/ICUTagletAdapter.java | 47 +++++++------------ 6 files changed, 38 insertions(+), 48 deletions(-) diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationTailoring.java b/icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationTailoring.java index 583c4b7fdf..b46b5194e3 100644 --- a/icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationTailoring.java +++ b/icu4j/main/classes/collate/src/com/ibm/icu/impl/coll/CollationTailoring.java @@ -12,7 +12,6 @@ package com.ibm.icu.impl.coll; import java.util.Map; -import java.util.MissingResourceException; import com.ibm.icu.impl.Norm2AllModes; import com.ibm.icu.impl.Normalizer2Impl; diff --git a/icu4j/main/classes/core/build.properties b/icu4j/main/classes/core/build.properties index f72f4c4ce4..935b89e19d 100644 --- a/icu4j/main/classes/core/build.properties +++ b/icu4j/main/classes/core/build.properties @@ -1,6 +1,6 @@ #******************************************************************************* -#* Copyright (C) 2009-2012, International Business Machines Corporation and * +#* Copyright (C) 2009-2015, International Business Machines Corporation and * #* others. All Rights Reserved. * #******************************************************************************* shared.dir = ../../shared -javac.compilerarg = -Xlint:all,-deprecation,-dep-ann,-options +javac.compilerarg = -Xlint:all,-deprecation,-dep-ann,-options,-overrides diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java index 657d993ff4..b12446e292 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java @@ -31,32 +31,33 @@ import com.ibm.icu.util.Freezable; public class Relation implements Freezable> { // TODO: add , Map>, but requires API changes private Map> data; - Constructor> setCreator; + Constructor> setCreator; Object[] setComparatorParam; - public static Relation of(Map> map, Class setCreator) { - return new Relation(map, setCreator); + public static Relation of(Map> map, Class setCreator) { + return new Relation(map, setCreator); } - public static Relation of(Map> map, Class setCreator, Comparator setComparator) { - return new Relation(map, setCreator, setComparator); + public static Relation of(Map> map, Class setCreator, Comparator setComparator) { + return new Relation(map, setCreator, setComparator); } - public Relation(Map> map, Class> setCreator) { + public Relation(Map> map, Class setCreator) { this(map, setCreator, null); } - public Relation(Map> map, Class> setCreator, Comparator setComparator) { + @SuppressWarnings("unchecked") + public Relation(Map> map, Class setCreator, Comparator setComparator) { try { setComparatorParam = setComparator == null ? null : new Object[]{setComparator}; if (setComparator == null) { - this.setCreator = setCreator.getConstructor(); + this.setCreator = ((Class>)setCreator).getConstructor(); this.setCreator.newInstance(setComparatorParam); // check to make sure compiles } else { - this.setCreator = setCreator.getConstructor(Comparator.class); + this.setCreator = ((Class>)setCreator).getConstructor(Comparator.class); this.setCreator.newInstance(setComparatorParam); // check to make sure compiles } - data = map == null ? new HashMap() : map; + data = map == null ? new HashMap>() : map; } catch (Exception e) { throw (RuntimeException) new IllegalArgumentException("Can't create new set").initCause(e); } @@ -88,10 +89,10 @@ public class Relation implements Freezable> { // TODO: add , } public Set> keyValueSet() { - Set> result = new LinkedHashSet(); + Set> result = new LinkedHashSet>(); for (K key : data.keySet()) { for (V value : data.get(key)) { - result.add(new SimpleEntry(key, value)); + result.add(new SimpleEntry(key, value)); } } return result; @@ -102,7 +103,7 @@ public class Relation implements Freezable> { // TODO: add , return false; if (o.getClass() != this.getClass()) return false; - return data.equals(((Relation) o).data); + return data.equals(((Relation) o).data); } // public V get(Object key) { @@ -209,7 +210,7 @@ public class Relation implements Freezable> { // TODO: add , } public Set values() { - return values(new LinkedHashSet()); + return values(new LinkedHashSet()); } public > C values(C result) { @@ -321,7 +322,7 @@ public class Relation implements Freezable> { // TODO: add , } public Set removeAll(Collection toBeRemoved) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet(); for (K key : toBeRemoved) { try { final Set removals = data.remove(key); diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java index c3b46406c6..24ad7788fc 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/UCharacterIterator.java @@ -13,7 +13,6 @@ import com.ibm.icu.impl.CharacterIteratorWrapper; import com.ibm.icu.impl.ReplaceableUCharacterIterator; import com.ibm.icu.impl.UCharArrayIterator; import com.ibm.icu.impl.UCharacterIteratorWrapper; -import com.ibm.icu.impl.UCharacterProperty; /** diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleMatcherTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleMatcherTest.java index 2634a580f2..35743493d5 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleMatcherTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/LocaleMatcherTest.java @@ -579,7 +579,9 @@ public class LocaleMatcherTest extends TestFmwk { int iterations = i == 0 ? 1000 : 100000; boolean showMessage = i != 0; long timeShort = timeLocaleMatcher("Duration (few supported):\t", desired, matcherShort, showMessage, iterations, 0); + @SuppressWarnings("unused") long timeMedium = timeLocaleMatcher("Duration (med. supported):\t", desired, matcherLong, showMessage, iterations, timeShort); + @SuppressWarnings("unused") long timeLong = timeLocaleMatcher("Duration (many supported):\t", desired, matcherVeryLong, showMessage, iterations, timeShort); } } diff --git a/icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/ICUTagletAdapter.java b/icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/ICUTagletAdapter.java index f2d5bc1d9d..9e02ce738a 100644 --- a/icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/ICUTagletAdapter.java +++ b/icu4j/tools/build/src/com/ibm/icu/dev/tool/docs/ICUTagletAdapter.java @@ -8,51 +8,40 @@ package com.ibm.icu.dev.tool.docs; import com.sun.javadoc.Doc; import com.sun.javadoc.Tag; -import com.sun.tools.doclets.formats.html.markup.RawHtml; -import com.sun.tools.doclets.internal.toolkit.Content; import com.sun.tools.doclets.internal.toolkit.taglets.Taglet; +import com.sun.tools.doclets.internal.toolkit.taglets.TagletOutput; import com.sun.tools.doclets.internal.toolkit.taglets.TagletWriter; /** * The ICUTagletAdapter class is the abstract base class that adapts the ICUTaglet class to different implementations of the JavaDoc API. * The methods in this class are meant to minimize the dual maintenance nature of supporting multiple JavaDoc APIs. * - * This adapter supports the v8 JavaDoc API + * This adapter supports the v7 and earlier JavaDoc API */ public abstract class ICUTagletAdapter implements Taglet { - + public abstract String toString(Tag tag); public abstract String toString(Tag[] tags); - public Content getTagletOutput(Tag tag, TagletWriter writer) - throws IllegalArgumentException { + public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) + throws IllegalArgumentException { - // addContext doesn't except nulls so filter them out - String encodedText = toString(tag); - if(encodedText == null) return null; - - Content out = writer.getOutputInstance(); - out.addContent(new RawHtml(encodedText)); - - return out; - } - - public Content getTagletOutput(Doc holder, TagletWriter writer) - throws IllegalArgumentException { - - Content out = writer.getOutputInstance(); - Tag[] tags = holder.tags(getName()); - if (tags.length == 0) { - return null; + TagletOutput out = writer.getTagletOutputInstance(); + out.setOutput(toString(tag)); + return out; } - // addContext doesn't except nulls so filter them out - String encodedText = toString(tags[0]); - if(encodedText == null) return null; + public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) + throws IllegalArgumentException { - out.addContent(new RawHtml(encodedText)); - return out; - } + TagletOutput out = writer.getTagletOutputInstance(); + Tag[] tags = holder.tags(getName()); + if (tags.length == 0) { + return null; + } + out.setOutput(toString(tags[0])); + return out; + } }