Skip to content
Permalink
Browse files

8241310: Fix warnings in jdk buildtools

Reviewed-by: erikj, forax
  • Loading branch information
magicus committed Mar 23, 2020
1 parent 618bace commit e04080bd0fecdaf627f959a13d8c88c6363aadd5
@@ -43,7 +43,7 @@ BUILD_TOOLS_SRC_DIRS += \
$(BUILDTOOLS_OUTPUTDIR)/interim_tzdb_classes \
#

$(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
$(eval $(call SetupJavaCompilation, BUILD_TOOLS_JDK, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(BUILD_TOOLS_SRC_DIRS), \
EXCLUDES := \
@@ -53,7 +53,6 @@ $(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
build/tools/jigsaw \
build/tools/depend \
, \
DISABLED_WARNINGS := unchecked rawtypes deprecation cast, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
ADD_JAVAC_FLAGS := \
--add-exports java.desktop/sun.awt=ALL-UNNAMED \
@@ -191,6 +191,7 @@ String getCurrencies() {
String[] cldrBundles = getCLDRPath().split(",");

// myMap contains resources for id.
@SuppressWarnings("unchecked")
Map<String, Object> myMap = new HashMap<>();
int index;
for (index = 0; index < cldrBundles.length; index++) {
@@ -230,10 +231,12 @@ String getCurrencies() {
}

for (String k : COMPACT_NUMBER_PATTERN_KEYS) {
@SuppressWarnings("unchecked")
List<String> patterns = (List<String>) myMap.remove(k);
if (patterns != null) {
// Convert the map value from List<String> to String[], replacing any missing
// entry from the parents map, if any.
@SuppressWarnings("unchecked")
final List<String> pList = (List<String>)parentsMap.get(k);
int size = patterns.size();
int psize = pList != null ? pList.size() : 0;
@@ -434,7 +434,7 @@ private static void parseSupplemental() throws Exception {
parentData.keySet().stream()
.filter(key -> key.startsWith(PARENT_LOCALE_PREFIX))
.forEach(key -> {
parentLocalesMap.put(key, new TreeSet(
parentLocalesMap.put(key, new TreeSet<String>(
Arrays.asList(((String)parentData.get(key)).split(" "))));
});

@@ -481,7 +481,7 @@ private static void parseBCP47() throws Exception {
});
}

private static void parseLDMLFile(File srcfile, AbstractLDMLHandler handler) throws Exception {
private static void parseLDMLFile(File srcfile, AbstractLDMLHandler<?> handler) throws Exception {
info("..... Parsing " + srcfile.getName() + " .....");
SAXParserFactory pf = SAXParserFactory.newInstance();
pf.setValidating(true);
@@ -574,7 +574,7 @@ private static void convertBundles(List<Bundle> bundles) throws Exception {
* Translate the aliases into the real entries in the bundle map.
*/
static void handleAliases(Map<String, Object> bundleMap) {
Set bundleKeys = bundleMap.keySet();
Set<String> bundleKeys = bundleMap.keySet();
try {
for (String key : aliases.keySet()) {
String targetKey = aliases.get(key);
@@ -1158,10 +1158,10 @@ private static void generatePluralRules() throws Exception {

private static Stream<String> pluralRulesStream() {
return handlerPlurals.getData().entrySet().stream()
.filter(e -> !((Map<String, String>)e.getValue()).isEmpty())
.filter(e -> !(e.getValue()).isEmpty())
.map(e -> {
String loc = e.getKey();
Map<String, String> rules = (Map<String, String>)e.getValue();
Map<String, String> rules = e.getValue();
return " {\"" + loc + "\", \"" +
rules.entrySet().stream()
.map(rule -> rule.getKey() + ":" + rule.getValue().replaceFirst("@.*", ""))
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
* plurals.xml
*/

class PluralsParseHandler extends AbstractLDMLHandler<Object> {
class PluralsParseHandler extends AbstractLDMLHandler<Map<String, String>> {
@Override
public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
// avoid HTTP traffic to unicode.org
@@ -82,13 +82,13 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
switch (qName) {
case "pluralRule":
assert !(currentContainer instanceof Entry);
Entry entry = (Entry)currentContainer;
Entry<?> entry = (Entry<?>)currentContainer;
final String count = entry.getKey();
final String rule = (String)entry.getValue();
String locales = ((KeyContainer)(currentContainer.getParent())).getKey();
Arrays.stream(locales.split("\\s"))
.forEach(loc -> {
Map<String, String> rules = (Map<String, String>)get(loc);
Map<String, String> rules = get(loc);
if (rules == null) {
rules = new HashMap<>();
put(loc, rules);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -139,7 +139,7 @@ private short getNameId(String name) {
}
int i = namesVector.size();
namesVector.addElement(name);
namesHash.put(name, new Integer(i));
namesHash.put(name, i);
return (short) i;
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -92,8 +92,8 @@ public void push(char data[]) throws IOException {
* Push an entire input stream
*/
void push(Reader in) throws IOException {
stack.push(new Integer(ln));
stack.push(new Integer(ch));
stack.push(Integer.valueOf(ln));
stack.push(Integer.valueOf(ch));
stack.push(this.in);
this.in = in;
ch = in.read();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -87,12 +87,12 @@ private static void generateFiles() throws Exception {
ResourceBundle rules, info;

info = (ResourceBundle) Class.forName(
localizedBundleName("sun.text.resources", "BreakIteratorInfo")).newInstance();
localizedBundleName("sun.text.resources", "BreakIteratorInfo")).getDeclaredConstructor().newInstance();

classNames = info.getStringArray("BreakIteratorClasses");

rules = (ResourceBundle) Class.forName(
localizedBundleName("sun.text.resources", "BreakIteratorRules")).newInstance();
localizedBundleName("sun.text.resources", "BreakIteratorRules")).getDeclaredConstructor().newInstance();

if (info.containsKey("CharacterData")) {
generateDataFile(info.getString("CharacterData"),
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -290,7 +290,7 @@ public RuleBasedBreakIteratorBuilder(String description) {
}

lastOpen = c;
parenStack.push(new Character((char)c));
parenStack.push(Character.valueOf((char)c));
if (c == '<') {
sawVarName = true;
}
@@ -902,11 +902,11 @@ private void parseRule(String rule, boolean forward) {
// if we're adding rules to the backward state table, mark the initial state
// as a looping state
if (!forward) {
loopingStates.addElement(new Integer(1));
loopingStates.addElement(Integer.valueOf(1));
}

// put the current state on the decision point list before we start
decisionPointList.addElement(new Integer(currentState)); // we want currentState to
decisionPointList.addElement(Integer.valueOf(currentState)); // we want currentState to
// be 1 here...
currentState = tempStateTable.size() - 1; // but after that, we want it to be
// 1 less than the state number of the next state
@@ -978,7 +978,7 @@ else if (c == '\\') {
// if the period is followed by an asterisk, then just set the current
// state to loop back on itself
if (p + 1 < rule.length() && rule.charAt(p + 1) == '*' && state[0] != 0) {
decisionPointList.addElement(new Integer(state[0]));
decisionPointList.addElement(Integer.valueOf(state[0]));
pendingChars = "";
++p;
}
@@ -1012,7 +1012,7 @@ else if (c == '\\') {
// it to the end of the state table
int newState = tempStateTable.size();
if (loopingStates.size() != 0) {
statesToBackfill.addElement(new Integer(newState));
statesToBackfill.addElement(Integer.valueOf(newState));
}
state = new short[numCategories + 1];
if (sawEarlyBreak) {
@@ -1032,7 +1032,7 @@ else if (c == '\\') {
lastState = currentState;
do {
++currentState;
decisionPointList.addElement(new Integer(currentState));
decisionPointList.addElement(Integer.valueOf(currentState));
} while (currentState + 1 < tempStateTable.size());
}
}
@@ -1058,7 +1058,7 @@ else if (c == '}' || c == '*') {
if (c == '*') {
for (int i = lastState + 1; i < tempStateTable.size(); i++) {
Vector<Integer> temp = new Vector<>();
temp.addElement(new Integer(i));
temp.addElement(Integer.valueOf(i));
updateStateTable(temp, pendingChars, (short)(lastState + 1));
}
}
@@ -1121,7 +1121,7 @@ else if (c == '(') {

// add the current state to the decision point list (add it at the
// BEGINNING so we can find it later)
decisionPointList.insertElementAt(new Integer(currentState), 0);
decisionPointList.insertElementAt(Integer.valueOf(currentState), 0);

// finally, push a copy of the current decision point list onto the
// stack (this keeps track of the active decision point list before
@@ -1208,7 +1208,7 @@ else if (c == ')') {
for (int i = 0; i < tempState.length; i++) {
if (tempState[i] > tempStateNum) {
updateStateTable(exitPoints,
new Character((char)(i + 0x100)).toString(),
Character.valueOf((char)(i + 0x100)).toString(),
tempState[i]);
}
}
@@ -1330,7 +1330,7 @@ private void mergeStates(int rowNum,
short[] newValues,
Vector<Integer> rowsBeingUpdated) {
short[] oldValues = tempStateTable.elementAt(rowNum);
boolean isLoopingState = loopingStates.contains(new Integer(rowNum));
boolean isLoopingState = loopingStates.contains(Integer.valueOf(rowNum));

// for each of the cells in the rows we're reconciling, do...
for (int i = 0; i < oldValues.length; i++) {
@@ -1343,7 +1343,7 @@ private void mergeStates(int rowNum,
// if oldValues is a looping state and the state the current cell points to
// is too, then we can just stomp over the current value of that cell (and
// set the clear-looping-states flag if necessary)
else if (isLoopingState && loopingStates.contains(new Integer(oldValues[i]))) {
else if (isLoopingState && loopingStates.contains(Integer.valueOf(oldValues[i]))) {
if (newValues[i] != 0) {
if (oldValues[i] == 0) {
clearLoopingStates = true;
@@ -1401,29 +1401,29 @@ else if (oldValues[i] != 0 && newValues[i] != 0) {

// if the decision point list contains either of the parent rows,
// update it to include the new row as well
if ((decisionPointList.contains(new Integer(oldRowNum))
|| decisionPointList.contains(new Integer(newRowNum)))
&& !decisionPointList.contains(new Integer(combinedRowNum))
if ((decisionPointList.contains(Integer.valueOf(oldRowNum))
|| decisionPointList.contains(Integer.valueOf(newRowNum)))
&& !decisionPointList.contains(Integer.valueOf(combinedRowNum))
) {
decisionPointList.addElement(new Integer(combinedRowNum));
decisionPointList.addElement(Integer.valueOf(combinedRowNum));
}

// do the same thing with the list of rows being updated
if ((rowsBeingUpdated.contains(new Integer(oldRowNum))
|| rowsBeingUpdated.contains(new Integer(newRowNum)))
&& !rowsBeingUpdated.contains(new Integer(combinedRowNum))
if ((rowsBeingUpdated.contains(Integer.valueOf(oldRowNum))
|| rowsBeingUpdated.contains(Integer.valueOf(newRowNum)))
&& !rowsBeingUpdated.contains(Integer.valueOf(combinedRowNum))
) {
decisionPointList.addElement(new Integer(combinedRowNum));
decisionPointList.addElement(Integer.valueOf(combinedRowNum));
}
// now (groan) do the same thing for all the entries on the
// decision point stack
for (int k = 0; k < decisionPointStack.size(); k++) {
Vector<Integer> dpl = decisionPointStack.elementAt(k);
if ((dpl.contains(new Integer(oldRowNum))
|| dpl.contains(new Integer(newRowNum)))
&& !dpl.contains(new Integer(combinedRowNum))
if ((dpl.contains(Integer.valueOf(oldRowNum))
|| dpl.contains(Integer.valueOf(newRowNum)))
&& !dpl.contains(Integer.valueOf(combinedRowNum))
) {
dpl.addElement(new Integer(combinedRowNum));
dpl.addElement(Integer.valueOf(combinedRowNum));
}
}

@@ -1536,10 +1536,10 @@ private void setLoopingStates(Vector<Integer> newLoopingStates,
private void eliminateBackfillStates(int baseState) {

// don't do anything unless this state is actually in the backfill list...
if (statesToBackfill.contains(new Integer(baseState))) {
if (statesToBackfill.contains(Integer.valueOf(baseState))) {

// if it is, take it out
statesToBackfill.removeElement(new Integer(baseState));
statesToBackfill.removeElement(Integer.valueOf(baseState));

// then go through and recursively call this function for every
// state that the base state points to
@@ -1608,7 +1608,7 @@ private void finishBuildingStateTable(boolean forward) {

int[] rowNumMap = new int[tempStateTable.size()];
Stack<Integer> rowsToFollow = new Stack<>();
rowsToFollow.push(new Integer(1));
rowsToFollow.push(Integer.valueOf(1));
rowNumMap[1] = 1;

// determine which states are no longer reachable from the start state
@@ -1622,7 +1622,7 @@ private void finishBuildingStateTable(boolean forward) {
if (row[i] != 0) {
if (rowNumMap[row[i]] == 0) {
rowNumMap[row[i]] = row[i];
rowsToFollow.push(new Integer(row[i]));
rowsToFollow.push(Integer.valueOf(row[i]));
}
}
}
@@ -1,3 +1,28 @@
/*
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package build.tools.generatecharacter;

import java.io.*;

0 comments on commit e04080b

Please sign in to comment.