Merge
diff --git a/make/com/sun/java/pack/Makefile b/make/com/sun/java/pack/Makefile
index f084152..e9cce3c 100644
--- a/make/com/sun/java/pack/Makefile
+++ b/make/com/sun/java/pack/Makefile
@@ -32,6 +32,8 @@
LIBRARY = unpack
PRODUCT = sun
PGRM = unpack200
+JAVAC_MAX_WARNINGS=true
+JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk
CPLUSPLUSLIBRARY=true
diff --git a/make/common/shared/Defs-java.gmk b/make/common/shared/Defs-java.gmk
index d4a27e3..d98a87c 100644
--- a/make/common/shared/Defs-java.gmk
+++ b/make/common/shared/Defs-java.gmk
@@ -116,12 +116,17 @@
JAVACFLAGS += -g
endif
ifeq ($(JAVAC_MAX_WARNINGS), true)
- JAVACFLAGS += -Xlint:all
+ JAVAC_LINT_OPTIONS += -Xlint:all
endif
ifeq ($(JAVAC_WARNINGS_FATAL), true)
JAVACFLAGS += -Werror
endif
+# TODO: Workaround for CR 7063027. Remove -path eventually.
+JAVAC_LINT_OPTIONS += -Xlint:-path
+
+JAVACFLAGS += $(JAVAC_LINT_OPTIONS)
+
#
# Some licensees do not get the Security Source bundles. We will
# fall back on the prebuilt jce.jar so that we can do a best
@@ -211,16 +216,12 @@
# The javac options supplied to the boot javac is limited. This compiler
# should only be used to build the 'make/tools' sources, which are not
# class files that end up in the classes directory.
-ifeq ($(JAVAC_MAX_WARNINGS), true)
- BOOT_JAVACFLAGS += -Xlint:all
-endif
+BOOT_JAVACFLAGS += $(JAVAC_LINT_OPTIONS)
ifeq ($(JAVAC_WARNINGS_FATAL), true)
BOOT_JAVACFLAGS += -Werror
endif
-BOOT_SOURCE_LANGUAGE_VERSION = 6
-BOOT_TARGET_CLASS_VERSION = 6
-BOOT_JAVACFLAGS += -encoding ascii -source $(BOOT_SOURCE_LANGUAGE_VERSION) -target $(BOOT_TARGET_CLASS_VERSION)
+BOOT_JAVACFLAGS += -encoding ascii
BOOT_JAR_JFLAGS += $(JAR_JFLAGS)
BOOT_JAVACFLAGS += $(NO_PROPRIETARY_API_WARNINGS)
diff --git a/make/common/shared/Defs-versions.gmk b/make/common/shared/Defs-versions.gmk
index 6e00b22..01aa7ee 100644
--- a/make/common/shared/Defs-versions.gmk
+++ b/make/common/shared/Defs-versions.gmk
@@ -191,7 +191,7 @@
# Generic
REQUIRED_ANT_VER = 1.7.1
-REQUIRED_BOOT_VER = 1.6
+REQUIRED_BOOT_VER = 1.7
REQUIRED_FREETYPE_VERSION = 2.3.0
REQUIRED_MAKE_VER = 3.81
REQUIRED_UNZIP_VER = 5.12
diff --git a/make/java/java/Makefile b/make/java/java/Makefile
index 787d881..a9c5d83 100644
--- a/make/java/java/Makefile
+++ b/make/java/java/Makefile
@@ -32,6 +32,8 @@
PACKAGE = java.lang
LIBRARY = java
PRODUCT = java
+SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
+SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk
# windows compiler flags
diff --git a/make/sun/security/ec/Makefile b/make/sun/security/ec/Makefile
index b0d4090..e7b6315 100644
--- a/make/sun/security/ec/Makefile
+++ b/make/sun/security/ec/Makefile
@@ -156,7 +156,7 @@
$(PKGDIR)/ECDSASignature.java \
$(PKGDIR)/ECKeyPairGenerator.java
- JAVAHFLAGS += -classpath $(CLASSDESTDIR)
+ JAVAHFLAGS += -Xbootclasspath/p:$(CLASSDESTDIR)
#
# C and C++ files
diff --git a/make/sun/security/mscapi/Makefile b/make/sun/security/mscapi/Makefile
index d19db5c..405941f 100644
--- a/make/sun/security/mscapi/Makefile
+++ b/make/sun/security/mscapi/Makefile
@@ -149,7 +149,7 @@
# Rules
#
CLASSDESTDIR = $(TEMPDIR)/classes
-JAVAHFLAGS += -classpath $(CLASSDESTDIR)
+JAVAHFLAGS += -Xbootclasspath/p:$(CLASSDESTDIR)
include $(BUILDDIR)/common/Mapfile-vers.gmk
diff --git a/make/tools/Makefile b/make/tools/Makefile
index 13fc5c9..ad30894 100644
--- a/make/tools/Makefile
+++ b/make/tools/Makefile
@@ -28,6 +28,8 @@
#
BUILDDIR = ..
+
+SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true JAVAC_WARNINGS_FATAL=true
include $(BUILDDIR)/common/Defs.gmk
# Note: freetypecheck is built by Sanity.gmk if needed
diff --git a/make/tools/src/build/tools/buildmetaindex/BuildMetaIndex.java b/make/tools/src/build/tools/buildmetaindex/BuildMetaIndex.java
index ad755db..73feec3 100644
--- a/make/tools/src/build/tools/buildmetaindex/BuildMetaIndex.java
+++ b/make/tools/src/build/tools/buildmetaindex/BuildMetaIndex.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -114,8 +114,8 @@
*/
out.println(jmi.getJarFileKind().getMarkerChar() + " " + filename);
- for (Iterator<String> iter = index.iterator(); iter.hasNext(); ) {
- out.println(iter.next());
+ for (String entry : index) {
+ out.println(entry);
}
}
@@ -171,8 +171,7 @@
* A hashmap contains a mapping from the prefix string to
* a hashset which contains a set of the second level of prefix string.
*/
- private HashMap<String, HashSet<String>> knownPrefixMap = new
- HashMap<String, HashSet<String>>();
+ private HashMap<String, HashSet<String>> knownPrefixMap = new HashMap<>();
/*
* We add maximum 5 second level entries to "sun", "java" and
@@ -195,12 +194,12 @@
if (indexSet == null) {
synchronized(this) {
if (indexSet == null) {
- indexSet = new HashSet<String>();
- Enumeration entries = jar.entries();
+ indexSet = new HashSet<>();
+ Enumeration<JarEntry> entries = jar.entries();
boolean containsOnlyClass = true;
boolean containsOnlyResource = true;
while (entries.hasMoreElements()) {
- JarEntry entry = (JarEntry) entries.nextElement();
+ JarEntry entry = entries.nextElement();
String name = entry.getName();
/* We only look at the non-directory entry.
MANIFEST file is also skipped. */
@@ -338,9 +337,7 @@
/* Iterate through the hash map, add the second level package names
* to the indexSet if has any.
*/
- for (Iterator<String> keysIterator = knownPrefixMap.keySet().iterator();
- keysIterator.hasNext();) {
- String key = keysIterator.next();
+ for (String key : knownPrefixMap.keySet()) {
HashSet<String> pkgSetStartsWithKey = knownPrefixMap.get(key);
int setSize = pkgSetStartsWithKey.size();
@@ -353,9 +350,8 @@
/* If the set contains less than MAX_PKGS_WITH_KNOWN_PREFIX, add
* them to the indexSet of the MetaIndex object.
*/
- for (Iterator<String> secondPkgElements = pkgSetStartsWithKey.iterator();
- secondPkgElements.hasNext();) {
- indexSet.add(key + "/" + secondPkgElements.next());
+ for (String secondPkgElement : pkgSetStartsWithKey) {
+ indexSet.add(key + "/" + secondPkgElement);
}
}
} // end the outer "for"
diff --git a/make/tools/src/build/tools/compileproperties/CompileProperties.java b/make/tools/src/build/tools/compileproperties/CompileProperties.java
index 1757657..cf9f451 100644
--- a/make/tools/src/build/tools/compileproperties/CompileProperties.java
+++ b/make/tools/src/build/tools/compileproperties/CompileProperties.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -36,7 +36,6 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -223,18 +222,16 @@
if ( ok ) {
String packageName = inferPackageName(propertiesPath, outputPath);
System.out.println("inferred package name: " + packageName);
- List<String> sortedKeys = new ArrayList<String>();
+ List<String> sortedKeys = new ArrayList<>();
for ( Object key : p.keySet() ) {
sortedKeys.add((String)key);
}
Collections.sort(sortedKeys);
- Iterator keys = sortedKeys.iterator();
StringBuffer data = new StringBuffer();
- while (keys.hasNext()) {
- Object key = keys.next();
- data.append(" { \"" + escape((String)key) + "\", \"" +
+ for (String key : sortedKeys) {
+ data.append(" { \"" + escape(key) + "\", \"" +
escape((String)p.get(key)) + "\" },\n");
}
diff --git a/make/tools/src/build/tools/dirdiff/DirDiff.java b/make/tools/src/build/tools/dirdiff/DirDiff.java
index 0a15d3a..ffa10c9 100644
--- a/make/tools/src/build/tools/dirdiff/DirDiff.java
+++ b/make/tools/src/build/tools/dirdiff/DirDiff.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -164,7 +164,7 @@
}
File[] currentGoldenDirs = null;
- TreeSet goldDirSet = new TreeSet();
+ TreeSet<String> goldDirSet = new TreeSet<>();
if (goldenDir != null) {
currentGoldenDirs = goldenDir.listFiles();
for (int i=0; i<currentGoldenDirs.length; i++) {
diff --git a/make/tools/src/build/tools/dtdbuilder/DTDBuilder.java b/make/tools/src/build/tools/dtdbuilder/DTDBuilder.java
index 6b10dd4..ac63aab 100644
--- a/make/tools/src/build/tools/dtdbuilder/DTDBuilder.java
+++ b/make/tools/src/build/tools/dtdbuilder/DTDBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -63,9 +63,9 @@
static PublicMapping mapping = null;
// Hash from name to Integer
- private Hashtable namesHash = new Hashtable();
+ private Hashtable<String, Integer> namesHash = new Hashtable<>();
// Vector of all names
- private Vector namesVector = new Vector();
+ private Vector<String> namesVector = new Vector<>();
/**
* Create a new DTD.
@@ -87,15 +87,15 @@
int numNames = namesVector.size();
out.writeShort((short) (namesVector.size()));
for (int i = 0; i < namesVector.size(); i++) {
- String nm = (String) namesVector.elementAt(i);
+ String nm = namesVector.elementAt(i);
out.writeUTF(nm);
}
saveEntities(out);
out.writeShort((short) (elements.size()));
- for (Enumeration e = elements.elements() ; e.hasMoreElements() ; ) {
- saveElement(out, (Element)e.nextElement());
+ for (Enumeration<Element> e = elements.elements() ; e.hasMoreElements() ; ) {
+ saveElement(out, e.nextElement());
}
if (namesVector.size() != numNames) {
@@ -106,21 +106,21 @@
}
private void buildNamesTable() {
- for (Enumeration e = entityHash.elements() ; e.hasMoreElements() ; ) {
- Entity ent = (Entity) e.nextElement();
+ for (Enumeration<Entity> e = entityHash.elements() ; e.hasMoreElements() ; ) {
+ Entity ent = e.nextElement();
// Do even if not isGeneral(). That way, exclusions and inclusions
// will definitely have their element.
getNameId(ent.getName());
}
- for (Enumeration e = elements.elements() ; e.hasMoreElements() ; ) {
- Element el = (Element) e.nextElement();
+ for (Enumeration<Element> e = elements.elements() ; e.hasMoreElements() ; ) {
+ Element el = e.nextElement();
getNameId(el.getName());
for (AttributeList atts = el.getAttributes() ; atts != null ; atts = atts.getNext()) {
getNameId(atts.getName());
if (atts.getValue() != null) {
getNameId(atts.getValue());
}
- Enumeration vals = atts.getValues();
+ Enumeration<?> vals = atts.getValues();
while (vals != null && vals.hasMoreElements()) {
String s = (String) vals.nextElement();
getNameId(s);
@@ -133,9 +133,9 @@
// The the id of a name from the list of names
//
private short getNameId(String name) {
- Object o = namesHash.get(name);
+ Integer o = namesHash.get(name);
if (o != null) {
- return (short) ((Integer) o).intValue();
+ return (short) o.intValue();
}
int i = namesVector.size();
namesVector.addElement(name);
@@ -149,16 +149,16 @@
*/
void saveEntities(DataOutputStream out) throws IOException {
int num = 0;
- for (Enumeration e = entityHash.elements() ; e.hasMoreElements() ; ) {
- Entity ent = (Entity) e.nextElement();
+ for (Enumeration<Entity> e = entityHash.elements() ; e.hasMoreElements() ; ) {
+ Entity ent = e.nextElement();
if (ent.isGeneral()) {
num++;
}
}
out.writeShort((short) num);
- for (Enumeration e = entityHash.elements() ; e.hasMoreElements() ; ) {
- Entity ent = (Entity) e.nextElement();
+ for (Enumeration<Entity> e = entityHash.elements() ; e.hasMoreElements() ; ) {
+ Entity ent = e.nextElement();
if (ent.isGeneral()) {
out.writeShort(getNameId(ent.getName()));
out.writeByte(ent.getType() & ~GENERAL);
diff --git a/make/tools/src/build/tools/dtdbuilder/DTDInputStream.java b/make/tools/src/build/tools/dtdbuilder/DTDInputStream.java
index e07c60f..79b9332 100644
--- a/make/tools/src/build/tools/dtdbuilder/DTDInputStream.java
+++ b/make/tools/src/build/tools/dtdbuilder/DTDInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -48,7 +48,7 @@
public final
class DTDInputStream extends FilterReader implements DTDConstants {
public DTD dtd;
- public Stack stack = new Stack();
+ public Stack<Object> stack = new Stack<>();
public char str[] = new char[64];
public int replace = 0;
public int ln = 1;
@@ -105,6 +105,7 @@
* parameter entities.
* [60] 350:22
*/
+ @SuppressWarnings("fallthrough")
public int read() throws IOException {
switch (ch) {
case '%': {
@@ -134,6 +135,7 @@
switch (ch) {
case '\r':
ln++;
+ /* fall through */
case ';':
ch = in.read();
break;
diff --git a/make/tools/src/build/tools/dtdbuilder/DTDParser.java b/make/tools/src/build/tools/dtdbuilder/DTDParser.java
index 4b76cd4..f8eb782 100644
--- a/make/tools/src/build/tools/dtdbuilder/DTDParser.java
+++ b/make/tools/src/build/tools/dtdbuilder/DTDParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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,7 +87,7 @@
return null;
}
- return MessageFormat.format(prop, args);
+ return MessageFormat.format(prop, (Object[])args);
}
/**
@@ -201,6 +201,7 @@
* Parse identifier. Uppercase characters are automatically
* folded to lowercase. Returns falsed if no identifier is found.
*/
+ @SuppressWarnings("fallthrough")
boolean parseIdentifier(boolean lower) throws IOException {
switch (ch) {
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
@@ -211,6 +212,7 @@
if (lower) {
ch = 'a' + (ch - 'A');
}
+ /* fall through */
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -233,6 +235,7 @@
* Parses name token. If <code>lower</code> is true, upper case letters
* are folded to lower case. Returns falsed if no token is found.
*/
+ @SuppressWarnings("fallthrough")
boolean parseNameToken(boolean lower) throws IOException {
boolean first = true;
@@ -246,6 +249,7 @@
if (lower) {
ch = 'a' + (ch - 'A');
}
+ /* fall through */
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@@ -271,8 +275,8 @@
/**
* Parse a list of identifiers.
*/
- Vector parseIdentifierList(boolean lower) throws IOException {
- Vector elems = new Vector();
+ Vector<String> parseIdentifierList(boolean lower) throws IOException {
+ Vector<String> elems = new Vector<>();
skipSpace();
switch (ch) {
case '(':
@@ -507,7 +511,7 @@
* [116] 405:6
*/
void parseElementDeclaration() throws IOException {
- Vector elems = parseIdentifierList(true);
+ Vector<String> elems = parseIdentifierList(true);
BitSet inclusions = null;
BitSet exclusions = null;
boolean omitStart = false;
@@ -544,26 +548,26 @@
if ((type == MODEL) || (type == ANY)) {
if (ch == '-') {
ch = in.read();
- Vector v = parseIdentifierList(true);
+ Vector<String> v = parseIdentifierList(true);
exclusions = new BitSet();
- for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
- exclusions.set(dtd.getElement((String)e.nextElement()).getIndex());
+ for (Enumeration<String> e = v.elements() ; e.hasMoreElements() ;) {
+ exclusions.set(dtd.getElement(e.nextElement()).getIndex());
}
}
if (ch == '+') {
ch = in.read();
- Vector v = parseIdentifierList(true);
+ Vector<String> v = parseIdentifierList(true);
inclusions = new BitSet();
- for (Enumeration e = v.elements() ; e.hasMoreElements() ;) {
- inclusions.set(dtd.getElement((String)e.nextElement()).getIndex());
+ for (Enumeration<String> e = v.elements() ; e.hasMoreElements() ;) {
+ inclusions.set(dtd.getElement(e.nextElement()).getIndex());
}
}
}
expect('>');
if (in.replace == 0) {
- for (Enumeration e = elems.elements() ; e.hasMoreElements() ;) {
- dtd.defineElement((String)e.nextElement(), type, omitStart, omitEnd, content, exclusions, inclusions, null);
+ for (Enumeration<String> e = elems.elements() ; e.hasMoreElements() ;) {
+ dtd.defineElement(e.nextElement(), type, omitStart, omitEnd, content, exclusions, inclusions, null);
}
}
}
@@ -582,7 +586,7 @@
error("invalid", "attribute value");
return;
}
- atts.type = atts.name2type(getString(0));
+ atts.type = AttributeList.name2type(getString(0));
skipParameterSpace();
if (atts.type == NOTATION) {
atts.values = parseIdentifierList(true);
@@ -593,6 +597,7 @@
* Parse an attribute value specification.
* [33] 331:1
*/
+ @SuppressWarnings("fallthrough")
String parseAttributeValueSpecification() throws IOException {
int delim = -1;
switch (ch) {
@@ -627,6 +632,7 @@
ch = in.read();
return getString(0);
}
+ /* fall through */
default:
addString(ch & 0xFF);
@@ -648,7 +654,7 @@
return;
}
skipParameterSpace();
- atts.modifier = atts.name2type(getString(0));
+ atts.modifier = AttributeList.name2type(getString(0));
if (atts.modifier != FIXED) {
return;
}
@@ -663,7 +669,7 @@
* REMIND: associated notation name
*/
void parseAttlistDeclaration() throws IOException {
- Vector elems = parseIdentifierList(true);
+ Vector<String> elems = parseIdentifierList(true);
AttributeList attlist = null, atts = null;
while (parseIdentifier(true)) {
@@ -685,8 +691,8 @@
expect('>');
if (in.replace == 0) {
- for (Enumeration e = elems.elements() ; e.hasMoreElements() ;) {
- dtd.defineAttributes((String)e.nextElement(), attlist);
+ for (Enumeration<String> e = elems.elements() ; e.hasMoreElements() ;) {
+ dtd.defineAttributes(e.nextElement(), attlist);
}
}
}
@@ -810,6 +816,7 @@
/**
* Parse a section of the input upto EOF or ']'.
*/
+ @SuppressWarnings("fallthrough")
void parseSection() throws IOException {
while (true) {
switch (ch) {
@@ -883,6 +890,7 @@
default:
char str[] = {(char)ch};
error("invalid.arg", "character", "'" + new String(str) + "' / " + ch);
+ /* fall through */
case ' ':
case '\t':
diff --git a/make/tools/src/build/tools/dtdbuilder/PublicMapping.java b/make/tools/src/build/tools/dtdbuilder/PublicMapping.java
index 8ac955f..cbad21a 100644
--- a/make/tools/src/build/tools/dtdbuilder/PublicMapping.java
+++ b/make/tools/src/build/tools/dtdbuilder/PublicMapping.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -44,7 +44,7 @@
final class PublicMapping {
String baseStr;
- Hashtable tab = new Hashtable();
+ Hashtable<String, String> tab = new Hashtable<>();
/**
* Create a mapping.
@@ -103,6 +103,6 @@
*/
public String get(String id) {
// System.err.println(" id = "+id);
- return (String) tab.get(id);
+ return tab.get(id);
}
}
diff --git a/make/tools/src/build/tools/generatebreakiteratordata/CharSet.java b/make/tools/src/build/tools/generatebreakiteratordata/CharSet.java
index 1e63e3d..2dc948a 100644
--- a/make/tools/src/build/tools/generatebreakiteratordata/CharSet.java
+++ b/make/tools/src/build/tools/generatebreakiteratordata/CharSet.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -66,7 +66,7 @@
* A cache which is used to speed up parseString() whenever it is
* used to parse a description that has been parsed before
*/
- private static Hashtable expressionCache = null;
+ private static Hashtable<String, CharSet> expressionCache = null;
/**
* Builds a CharSet based on a textual description. For the syntax of
@@ -79,7 +79,7 @@
// if "s" is in the expression cache, pull the result out
// of the expresison cache
if (expressionCache != null) {
- result = (CharSet)expressionCache.get(s);
+ result = expressionCache.get(s);
}
// otherwise, use doParseString() to actually parse the string,
@@ -87,7 +87,7 @@
if (result == null) {
result = doParseString(s);
if (expressionCache == null) {
- expressionCache = new Hashtable();
+ expressionCache = new Hashtable<>();
}
expressionCache.put(s, result);
}
@@ -336,8 +336,8 @@
* Returns a copy of CharSet's expression cache and sets CharSet's
* expression cache to empty.
*/
- public static Hashtable releaseExpressionCache() {
- Hashtable result = expressionCache;
+ public static Hashtable<String, CharSet> releaseExpressionCache() {
+ Hashtable<String, CharSet> result = expressionCache;
expressionCache = null;
return result;
}
@@ -778,7 +778,7 @@
* An Enumeration that can be used to extract the character ranges
* from a CharSet one at a time
*/
- public class Enumeration implements java.util.Enumeration {
+ public class Enumeration implements java.util.Enumeration<int[]> {
/**
* Initializes a CharSet.Enumeration
*/
@@ -798,7 +798,7 @@
/**
* Returns the next range in the CarSet
*/
- public Object nextElement() {
+ public int[] nextElement() {
int[] result = new int[2];
result[0] = chars[p++];
result[1] = chars[p++];
diff --git a/make/tools/src/build/tools/generatebreakiteratordata/DictionaryBasedBreakIteratorBuilder.java b/make/tools/src/build/tools/generatebreakiteratordata/DictionaryBasedBreakIteratorBuilder.java
index 2754006..0bf230c 100644
--- a/make/tools/src/build/tools/generatebreakiteratordata/DictionaryBasedBreakIteratorBuilder.java
+++ b/make/tools/src/build/tools/generatebreakiteratordata/DictionaryBasedBreakIteratorBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -78,12 +78,12 @@
* contains "true" for every character category that includes a dictionary
* character.
*/
- protected void buildCharCategories(Vector tempRuleList) {
+ protected void buildCharCategories(Vector<String> tempRuleList) {
super.buildCharCategories(tempRuleList);
categoryFlags = new boolean[categories.size()];
for (int i = 0; i < categories.size(); i++) {
- CharSet cs = (CharSet)categories.elementAt(i);
+ CharSet cs = categories.elementAt(i);
if (!(cs.intersection(dictionaryChars).empty())) {
categoryFlags[i] = true;
}
@@ -95,7 +95,7 @@
// the function above. This gives us a way to create a separate character
// category for the dictionary characters even when
// RuleBasedBreakIteratorBuilder isn't making a distinction.
- protected void mungeExpressionList(Hashtable expressions) {
+ protected void mungeExpressionList(Hashtable<String, Object> expressions) {
expressions.put(dictionaryExpression, dictionaryChars);
}
diff --git a/make/tools/src/build/tools/generatebreakiteratordata/GenerateBreakIteratorData.java b/make/tools/src/build/tools/generatebreakiteratordata/GenerateBreakIteratorData.java
index df652a7..a552e2d 100644
--- a/make/tools/src/build/tools/generatebreakiteratordata/GenerateBreakIteratorData.java
+++ b/make/tools/src/build/tools/generatebreakiteratordata/GenerateBreakIteratorData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -91,9 +91,9 @@
try {
info = (ResourceBundle)Class.forName("sun.text.resources.BreakIteratorInfo" + localeName).newInstance();
- Enumeration keys = info.getKeys();
+ Enumeration<String> keys = info.getKeys();
while (keys.hasMoreElements()) {
- String key = (String)keys.nextElement();
+ String key = keys.nextElement();
if (key.equals("CharacterData")) {
generateDataFile(info.getString(key),
diff --git a/make/tools/src/build/tools/generatebreakiteratordata/RuleBasedBreakIteratorBuilder.java b/make/tools/src/build/tools/generatebreakiteratordata/RuleBasedBreakIteratorBuilder.java
index 9040b18..02b13ea 100644
--- a/make/tools/src/build/tools/generatebreakiteratordata/RuleBasedBreakIteratorBuilder.java
+++ b/make/tools/src/build/tools/generatebreakiteratordata/RuleBasedBreakIteratorBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -110,13 +110,13 @@
* A temporary holding place used for calculating the character categories.
* This object contains CharSet objects.
*/
- protected Vector categories = null;
+ protected Vector<CharSet> categories = null;
/**
* A table used to map parts of regexp text to lists of character
* categories, rather than having to figure them out from scratch each time
*/
- protected Hashtable expressions = null;
+ protected Hashtable<String, Object> expressions = null;
/**
* A temporary holding place for the list of ignore characters
@@ -126,32 +126,32 @@
/**
* A temporary holding place where the forward state table is built
*/
- protected Vector tempStateTable = null;
+ protected Vector<short[]> tempStateTable = null;
/**
* A list of all the states that have to be filled in with transitions to
* the next state that is created. Used when building the state table from
* the regular expressions.
*/
- protected Vector decisionPointList = null;
+ protected Vector<Integer> decisionPointList = null;
/**
* A stack for holding decision point lists. This is used to handle nested
* parentheses and braces in regexps.
*/
- protected Stack decisionPointStack = null;
+ protected Stack<Vector<Integer>> decisionPointStack = null;
/**
* A list of states that loop back on themselves. Used to handle .*?
*/
- protected Vector loopingStates = null;
+ protected Vector<Integer> loopingStates = null;
/**
* Looping states actually have to be backfilled later in the process
* than everything else. This is where a the list of states to backfill
* is accumulated. This is also used to handle .*?
*/
- protected Vector statesToBackfill = null;
+ protected Vector<Integer> statesToBackfill = null;
/**
* A list mapping pairs of state numbers for states that are to be combined
@@ -159,7 +159,7 @@
* in the process of making the state table deterministic to prevent
* infinite recursion.
*/
- protected Vector mergeList = null;
+ protected Vector<int[]> mergeList = null;
/**
* A flag that is used to indicate when the list of looping states can
@@ -198,7 +198,7 @@
* just vectors different parts of the job off to other functions.
*/
public RuleBasedBreakIteratorBuilder(String description) {
- Vector tempRuleList = buildRuleList(description);
+ Vector<String> tempRuleList = buildRuleList(description);
buildCharCategories(tempRuleList);
buildStateTable(tempRuleList);
buildBackwardsStateTable(tempRuleList);
@@ -213,7 +213,7 @@
* variable names)
* </ul>
*/
- private Vector buildRuleList(String description) {
+ private Vector<String> buildRuleList(String description) {
// invariants:
// - parentheses must be balanced: ()[]{}<>
// - nothing can be nested inside <>
@@ -240,8 +240,8 @@
// set up a vector to contain the broken-up description (each entry in the
// vector is a separate rule) and a stack for keeping track of opening
// punctuation
- Vector tempRuleList = new Vector();
- Stack parenStack = new Stack();
+ Vector<String> tempRuleList = new Vector<>();
+ Stack<Character> parenStack = new Stack<>();
int p = 0;
int ruleStart = 0;
@@ -326,7 +326,7 @@
}
parenStack.pop();
if (!parenStack.empty()) {
- lastOpen = ((Character)(parenStack.peek())).charValue();
+ lastOpen = parenStack.peek().charValue();
}
else {
lastOpen = '\u0000';
@@ -552,7 +552,8 @@
* character category numbers everywhere a literal character or a [] expression
* originally occurred.
*/
- protected void buildCharCategories(Vector tempRuleList) {
+ @SuppressWarnings("fallthrough")
+ protected void buildCharCategories(Vector<String> tempRuleList) {
int bracketLevel = 0;
int p = 0;
int lineNum = 0;
@@ -560,9 +561,9 @@
// build hash table of every literal character or [] expression in the rule list
// and use CharSet.parseString() to derive a CharSet object representing the
// characters each refers to
- expressions = new Hashtable();
+ expressions = new Hashtable<>();
while (lineNum < tempRuleList.size()) {
- String line = (String)(tempRuleList.elementAt(lineNum));
+ String line = tempRuleList.elementAt(lineNum);
p = 0;
while (p < line.length()) {
int c = line.codePointAt(p);
@@ -618,7 +619,7 @@
CharSet.releaseExpressionCache();
// create the temporary category table (which is a vector of CharSet objects)
- categories = new Vector();
+ categories = new Vector<>();
if (ignoreChars != null) {
categories.addElement(ignoreChars);
}
@@ -643,8 +644,7 @@
// At no time should a character ever occur in more than one character category.
// for each expression in the expressions list, do...
- Enumeration iter = expressions.elements();
- while (iter.hasMoreElements()) {
+ for (Enumeration<Object> iter = expressions.elements(); iter.hasMoreElements(); ) {
// initialize the working char set to the chars in the current expression
CharSet e = (CharSet)iter.nextElement();
@@ -653,7 +653,7 @@
// if there's overlap between the current working set of chars
// and the current category...
- CharSet that = (CharSet)(categories.elementAt(j));
+ CharSet that = categories.elementAt(j);
if (!that.intersection(e).empty()) {
// add a new category for the characters that were in the
@@ -686,9 +686,9 @@
// up in some other category
CharSet allChars = new CharSet();
for (int i = 1; i < categories.size(); i++) {
- allChars = allChars.union((CharSet)(categories.elementAt(i)));
+ allChars = allChars.union(categories.elementAt(i));
}
- CharSet ignoreChars = (CharSet)(categories.elementAt(0));
+ CharSet ignoreChars = categories.elementAt(0);
ignoreChars = ignoreChars.difference(allChars);
categories.setElementAt(ignoreChars, 0);
@@ -697,9 +697,9 @@
// character categories that expression refers to. The String is encoded: each
// character is a character category number (plus 0x100 to avoid confusing them
// with syntax characters in the rule grammar)
- iter = expressions.keys();
- while (iter.hasMoreElements()) {
- String key = (String)iter.nextElement();
+
+ for (Enumeration<String> iter = expressions.keys(); iter.hasMoreElements(); ) {
+ String key = iter.nextElement();
CharSet cs = (CharSet)expressions.get(key);
StringBuffer cats = new StringBuffer();
@@ -707,7 +707,7 @@
for (int j = 0; j < categories.size(); j++) {
// if the current expression contains characters in that category...
- CharSet temp = cs.intersection((CharSet)(categories.elementAt(j)));
+ CharSet temp = cs.intersection(categories.elementAt(j));
if (!temp.empty()) {
// then add the encoded category number to the String for this
@@ -732,12 +732,12 @@
// for each category...
for (int i = 0; i < categories.size(); i++) {
- CharSet chars = (CharSet)(categories.elementAt(i));
+ CharSet chars = categories.elementAt(i);
// go through the character ranges in the category one by one...
- Enumeration enum_ = chars.getChars();
+ Enumeration<int[]> enum_ = chars.getChars();
while (enum_.hasMoreElements()) {
- int[] range = (int[])(enum_.nextElement());
+ int[] range = enum_.nextElement();
// and set the corresponding elements in the CompactArray accordingly
if (i != 0) {
@@ -782,7 +782,7 @@
numCategories = categories.size();
}
- protected void mungeExpressionList(Hashtable expressions) {
+ protected void mungeExpressionList(Hashtable<String, Object> expressions) {
// empty in the parent class. This function provides a hook for subclasses
// to mess with the character category table.
}
@@ -792,19 +792,19 @@
* work is done in parseRule(), which is called once for each rule in the
* description.
*/
- private void buildStateTable(Vector tempRuleList) {
+ private void buildStateTable(Vector<String> tempRuleList) {
// initialize our temporary state table, and fill it with two states:
// state 0 is a dummy state that allows state 1 to be the starting state
// and 0 to represent "stop". State 1 is added here to seed things
// before we start parsing
- tempStateTable = new Vector();
+ tempStateTable = new Vector<>();
tempStateTable.addElement(new short[numCategories + 1]);
tempStateTable.addElement(new short[numCategories + 1]);
// call parseRule() for every rule in the rule list (except those which
// start with !, which are actually backwards-iteration rules)
for (int i = 0; i < tempRuleList.size(); i++) {
- String rule = (String)tempRuleList.elementAt(i);
+ String rule = tempRuleList.elementAt(i);
if (rule.charAt(0) != '!') {
parseRule(rule, true);
}
@@ -891,10 +891,10 @@
int lastState = currentState;
String pendingChars = "";
- decisionPointStack = new Stack();
- decisionPointList = new Vector();
- loopingStates = new Vector();
- statesToBackfill = new Vector();
+ decisionPointStack = new Stack<>();
+ decisionPointList = new Vector<>();
+ loopingStates = new Vector<>();
+ statesToBackfill = new Vector<>();
short[] state;
boolean sawEarlyBreak = false;
@@ -972,8 +972,8 @@
// if the character we're on is a period, we end up down here
else {
- int rowNum = ((Integer)decisionPointList.lastElement()).intValue();
- state = (short[])tempStateTable.elementAt(rowNum);
+ int rowNum = decisionPointList.lastElement().intValue();
+ state = tempStateTable.elementAt(rowNum);
// if the period is followed by an asterisk, then just set the current
// state to loop back on itself
@@ -1001,7 +1001,9 @@
// of the current desicion point list onto the stack (this is
// the same thing we do on an opening brace)
if (p + 1 < rule.length() && rule.charAt(p + 1) == '*') {
- decisionPointStack.push(decisionPointList.clone());
+ @SuppressWarnings("unchecked")
+ Vector<Integer> clone = (Vector<Integer>)decisionPointList.clone();
+ decisionPointStack.push(clone);
}
// create a new state, add it to the list of states to backfill
@@ -1040,7 +1042,9 @@
// it, preventing it from being affected by whatever's inside the parentheses.
// This decision point list is restored when a } is encountered.
else if (c == '{') {
- decisionPointStack.push(decisionPointList.clone());
+ @SuppressWarnings("unchecked")
+ Vector<Integer> clone = (Vector<Integer>)decisionPointList.clone();
+ decisionPointStack.push(clone);
}
// a } marks the end of an optional run of characters. Pop the last decision
@@ -1053,7 +1057,7 @@
// on the character categories that caused us to enter this state
if (c == '*') {
for (int i = lastState + 1; i < tempStateTable.size(); i++) {
- Vector temp = new Vector();
+ Vector<Integer> temp = new Vector<>();
temp.addElement(new Integer(i));
updateStateTable(temp, pendingChars, (short)(lastState + 1));
}
@@ -1063,7 +1067,7 @@
// it with the current decision point list (this causes the divergent
// paths through the state table to come together again on the next
// new state)
- Vector temp = (Vector)decisionPointStack.pop();
+ Vector<Integer> temp = decisionPointStack.pop();
for (int i = 0; i < decisionPointList.size(); i++)
temp.addElement(decisionPointList.elementAt(i));
decisionPointList = temp;
@@ -1123,8 +1127,10 @@
// stack (this keeps track of the active decision point list before
// the () expression), followed by an empty decision point list
// (this will hold the exit points)
- decisionPointStack.push(decisionPointList.clone());
- decisionPointStack.push(new Vector());
+ @SuppressWarnings("unchecked")
+ Vector<Integer> clone = (Vector<Integer>)decisionPointList.clone();
+ decisionPointStack.push(clone);
+ decisionPointStack.push(new Vector<Integer>());
}
// a | separates alternative character sequences in a () expression. When
@@ -1133,8 +1139,8 @@
else if (c == '|') {
// pick out the top two decision point lists on the stack
- Vector oneDown = (Vector)decisionPointStack.pop();
- Vector twoDown = (Vector)decisionPointStack.peek();
+ Vector<Integer> oneDown = decisionPointStack.pop();
+ Vector<Integer> twoDown = decisionPointStack.peek();
decisionPointStack.push(oneDown);
// append the current decision point list to the list below it
@@ -1142,7 +1148,9 @@
// current decision point list to its state before the () expression
for (int i = 0; i < decisionPointList.size(); i++)
oneDown.addElement(decisionPointList.elementAt(i));
- decisionPointList = (Vector)twoDown.clone();
+ @SuppressWarnings("unchecked")
+ Vector<Integer> clone = (Vector<Integer>)twoDown.clone();
+ decisionPointList = clone;
}
// a ) marks the end of a sequence of characters. We do one of two things
@@ -1160,7 +1168,7 @@
// pull the exit point list off the stack, merge it with the current
// decision point list, and make the merged version the current
// decision point list
- Vector exitPoints = (Vector)decisionPointStack.pop();
+ Vector<Integer> exitPoints = decisionPointStack.pop();
for (int i = 0; i < decisionPointList.size(); i++)
exitPoints.addElement(decisionPointList.elementAt(i));
decisionPointList = exitPoints;
@@ -1176,16 +1184,18 @@
// now exitPoints and decisionPointList have to point to equivalent
// vectors, but not the SAME vector
- exitPoints = (Vector)decisionPointList.clone();
+ @SuppressWarnings("unchecked")
+ Vector<Integer> clone = (Vector<Integer>)decisionPointList.clone();
+ exitPoints = clone;
// pop the original decision point list off the stack
- Vector temp = (Vector)decisionPointStack.pop();
+ Vector<Integer> temp = decisionPointStack.pop();
// we squirreled away the row number of our entry point list
// at the beginning of the original decision point list. Fish
// that state number out and retrieve the entry point list
- int tempStateNum = ((Integer)temp.firstElement()).intValue();
- short[] tempState = (short[])tempStateTable.elementAt(tempStateNum);
+ int tempStateNum = temp.firstElement().intValue();
+ short[] tempState = tempStateTable.elementAt(tempStateNum);
// merge the original decision point list with the current
// decision point list
@@ -1217,8 +1227,8 @@
else if (c == '/') {
sawEarlyBreak = true;
for (int i = 0; i < decisionPointList.size(); i++) {
- state = (short[])tempStateTable.elementAt(((Integer)decisionPointList.
- elementAt(i)).intValue());
+ state = tempStateTable.elementAt(decisionPointList.
+ elementAt(i).intValue());
state[numCategories] |= LOOKAHEAD_STATE_FLAG;
}
}
@@ -1261,8 +1271,8 @@
// signals that these states cause the break position to be updated to the
// position of the slash rather than the current break position.
for (int i = 0; i < decisionPointList.size(); i++) {
- int rowNum = ((Integer)decisionPointList.elementAt(i)).intValue();
- state = (short[])tempStateTable.elementAt(rowNum);
+ int rowNum = decisionPointList.elementAt(i).intValue();
+ state = tempStateTable.elementAt(rowNum);
state[numCategories] |= END_STATE_FLAG;
if (sawEarlyBreak) {
state[numCategories] |= LOOKAHEAD_STATE_FLAG;
@@ -1279,7 +1289,7 @@
* list of the columns that need updating.
* @param newValue Update the cells specfied above to contain this value
*/
- private void updateStateTable(Vector rows,
+ private void updateStateTable(Vector<Integer> rows,
String pendingChars,
short newValue) {
// create a dummy state that has the specified row number (newValue) in
@@ -1292,7 +1302,7 @@
// go through the list of rows to update, and update them by calling
// mergeStates() to merge them the the dummy state we created
for (int i = 0; i < rows.size(); i++) {
- mergeStates(((Integer)rows.elementAt(i)).intValue(), newValues, rows);
+ mergeStates(rows.elementAt(i).intValue(), newValues, rows);
}
}
@@ -1318,8 +1328,8 @@
*/
private void mergeStates(int rowNum,
short[] newValues,
- Vector rowsBeingUpdated) {
- short[] oldValues = (short[])(tempStateTable.elementAt(rowNum));
+ Vector<Integer> rowsBeingUpdated) {
+ short[] oldValues = tempStateTable.elementAt(rowNum);
boolean isLoopingState = loopingStates.contains(new Integer(rowNum));
// for each of the cells in the rows we're reconciling, do...
@@ -1375,7 +1385,7 @@
// add this pair of row numbers to the merge list (create it first
// if we haven't created the merge list yet)
if (mergeList == null) {
- mergeList = new Vector();
+ mergeList = new Vector<>();
}
mergeList.addElement(new int[] { oldRowNum, newRowNum, combinedRowNum });
@@ -1384,7 +1394,7 @@
// state table and update the original row (oldValues) to point
// to the new, merged, state
short[] newRow = new short[numCategories + 1];
- short[] oldRow = (short[])(tempStateTable.elementAt(oldRowNum));
+ short[] oldRow = tempStateTable.elementAt(oldRowNum);
System.arraycopy(oldRow, 0, newRow, 0, numCategories + 1);
tempStateTable.addElement(newRow);
oldValues[i] = (short)combinedRowNum;
@@ -1408,7 +1418,7 @@
// now (groan) do the same thing for all the entries on the
// decision point stack
for (int k = 0; k < decisionPointStack.size(); k++) {
- Vector dpl = (Vector)decisionPointStack.elementAt(k);
+ Vector<Integer> dpl = decisionPointStack.elementAt(k);
if ((dpl.contains(new Integer(oldRowNum))
|| dpl.contains(new Integer(newRowNum)))
&& !dpl.contains(new Integer(combinedRowNum))
@@ -1420,8 +1430,8 @@
// FINALLY (puff puff puff), call mergeStates() recursively to copy
// the row referred to by newValues into the new row and resolve any
// conflicts that come up at that level
- mergeStates(combinedRowNum, (short[])(tempStateTable.elementAt(
- newValues[i])), rowsBeingUpdated);
+ mergeStates(combinedRowNum, tempStateTable.elementAt(
+ newValues[i]), rowsBeingUpdated);
}
}
}
@@ -1445,7 +1455,7 @@
else {
int[] entry;
for (int i = 0; i < mergeList.size(); i++) {
- entry = (int[])(mergeList.elementAt(i));
+ entry = mergeList.elementAt(i);
// we have a hit if the two row numbers match the two row numbers
// in the beginning of the entry (the two that combine), in either
@@ -1477,20 +1487,21 @@
* @param endStates The list of states to treat as end states (states that
* can exit the loop).
*/
- private void setLoopingStates(Vector newLoopingStates, Vector endStates) {
+ private void setLoopingStates(Vector<Integer> newLoopingStates,
+ Vector<Integer> endStates) {
// if the current list of looping states isn't empty, we have to backfill
// values from the looping states into the states that are waiting to be
// backfilled
if (!loopingStates.isEmpty()) {
- int loopingState = ((Integer)loopingStates.lastElement()).intValue();
+ int loopingState = loopingStates.lastElement().intValue();
int rowNum;
// don't backfill into an end state OR any state reachable from an end state
// (since the search for reachable states is recursive, it's split out into
// a separate function, eliminateBackfillStates(), below)
for (int i = 0; i < endStates.size(); i++) {
- eliminateBackfillStates(((Integer)endStates.elementAt(i)).intValue());
+ eliminateBackfillStates(endStates.elementAt(i).intValue());
}
// we DON'T actually backfill the states that need to be backfilled here.
@@ -1501,8 +1512,8 @@
// for backfilling by putting the row number of the state to copy from
// into the flag cell at the end of the row
for (int i = 0; i < statesToBackfill.size(); i++) {
- rowNum = ((Integer)statesToBackfill.elementAt(i)).intValue();
- short[] state = (short[])tempStateTable.elementAt(rowNum);
+ rowNum = statesToBackfill.elementAt(i).intValue();
+ short[] state = tempStateTable.elementAt(rowNum);
state[numCategories] =
(short)((state[numCategories] & ALL_FLAGS) | loopingState);
}
@@ -1511,7 +1522,9 @@
}
if (newLoopingStates != null) {
- loopingStates = (Vector)newLoopingStates.clone();
+ @SuppressWarnings("unchecked")
+ Vector<Integer> clone = (Vector<Integer>)newLoopingStates.clone();
+ loopingStates = clone;
}
}
@@ -1530,7 +1543,7 @@
// then go through and recursively call this function for every
// state that the base state points to
- short[] state = (short[])tempStateTable.elementAt(baseState);
+ short[] state = tempStateTable.elementAt(baseState);
for (int i = 0; i < numCategories; i++) {
if (state[i] != 0) {
eliminateBackfillStates(state[i]);
@@ -1551,7 +1564,7 @@
// for each state in the state table...
for (int i = 0; i < tempStateTable.size(); i++) {
- state = (short[])tempStateTable.elementAt(i);
+ state = tempStateTable.elementAt(i);
// check the state's flag word to see if it's marked for backfilling
// (it's marked for backfilling if any bits other than the two high-order
@@ -1563,7 +1576,7 @@
// load up the state to copy from (if we haven't already)
if (fromState != loopingStateRowNum) {
loopingStateRowNum = fromState;
- loopingState = (short[])tempStateTable.elementAt(loopingStateRowNum);
+ loopingState = tempStateTable.elementAt(loopingStateRowNum);
}
// clear out the backfill part of the flag word
@@ -1594,7 +1607,7 @@
backfillLoopingStates();
int[] rowNumMap = new int[tempStateTable.size()];
- Stack rowsToFollow = new Stack();
+ Stack<Integer> rowsToFollow = new Stack<>();
rowsToFollow.push(new Integer(1));
rowNumMap[1] = 1;
@@ -1602,8 +1615,8 @@
// (the reachable states will have their row numbers in the row number
// map, and the nonreachable states will have zero in the row number map)
while (rowsToFollow.size() != 0) {
- int rowNum = ((Integer)rowsToFollow.pop()).intValue();
- short[] row = (short[])(tempStateTable.elementAt(rowNum));
+ int rowNum = rowsToFollow.pop().intValue();
+ short[] row = tempStateTable.elementAt(rowNum);
for (int i = 0; i < numCategories; i++) {
if (row[i] != 0) {
@@ -1632,7 +1645,7 @@
if (rowNumMap[i] == 0) {
continue;
}
- state1 = (short[])tempStateTable.elementAt(i);
+ state1 = tempStateTable.elementAt(i);
for (int j = 0; j < numCategories; j++) {
if (state1[j] != 0) {
++stateClasses[i];
@@ -1663,10 +1676,10 @@
for (int i = 0; i < stateClasses.length; i++) {
if (stateClasses[i] == currentClass) {
if (state1 == null) {
- state1 = (short[])tempStateTable.elementAt(i);
+ state1 = tempStateTable.elementAt(i);
}
else {
- state2 = (short[])tempStateTable.elementAt(i);
+ state2 = tempStateTable.elementAt(i);
for (int j = 0; j < state2.length; j++) {
if ((j == numCategories && state1[j] != state2[j] && forward)
|| (j != numCategories && stateClasses[state1[j]]
@@ -1733,7 +1746,7 @@
int p = 0;
int p2 = 0;
for (int i = 0; i < tempStateTable.size(); i++) {
- short[] row = (short[])(tempStateTable.elementAt(i));
+ short[] row = tempStateTable.elementAt(i);
if (row == null) {
continue;
}
@@ -1752,7 +1765,7 @@
backwardsStateTable = new short[newRowNum * numCategories];
int p = 0;
for (int i = 0; i < tempStateTable.size(); i++) {
- short[] row = (short[])(tempStateTable.elementAt(i));
+ short[] row = tempStateTable.elementAt(i);
if (row == null) {
continue;
}
@@ -1769,12 +1782,12 @@
* table and any additional rules (identified by the ! on the front)
* supplied in the description
*/
- private void buildBackwardsStateTable(Vector tempRuleList) {
+ private void buildBackwardsStateTable(Vector<String> tempRuleList) {
// create the temporary state table and seed it with two rows (row 0
// isn't used for anything, and we have to create row 1 (the initial
// state) before we can do anything else
- tempStateTable = new Vector();
+ tempStateTable = new Vector<>();
tempStateTable.addElement(new short[numCategories + 1]);
tempStateTable.addElement(new short[numCategories + 1]);
@@ -1786,7 +1799,7 @@
// the same syntax as the normal break rules, but begin with '!' to distinguish
// them from normal break rules
for (int i = 0; i < tempRuleList.size(); i++) {
- String rule = (String)tempRuleList.elementAt(i);
+ String rule = tempRuleList.elementAt(i);
if (rule.charAt(0) == '!') {
parseRule(rule.substring(1), false);
}
@@ -1831,7 +1844,7 @@
for (int i = 0; i < numCategories + 1; i++)
tempStateTable.addElement(new short[numCategories + 1]);
- short[] state = (short[])tempStateTable.elementAt(backTableOffset - 1);
+ short[] state = tempStateTable.elementAt(backTableOffset - 1);
for (int i = 0; i < numCategories; i++)
state[i] = (short)(i + backTableOffset);
@@ -1855,7 +1868,7 @@
for (int nextColumn = 0; nextColumn < numCategories; nextColumn++) {
int cellValue = lookupState(nextRow, nextColumn);
if (cellValue != 0) {
- state = (short[])tempStateTable.elementAt(nextColumn +
+ state = tempStateTable.elementAt(nextColumn +
backTableOffset);
state[column] = (short)(column + backTableOffset);
}
@@ -1876,9 +1889,9 @@
// populated that is also populated in row 1 of the rule-based
// sub-table, copy the value from row 1 over the value in the
// auto-generated sub-table
- state = (short[])tempStateTable.elementAt(1);
+ state = tempStateTable.elementAt(1);
for (int i = backTableOffset - 1; i < tempStateTable.size(); i++) {
- short[] state2 = (short[])tempStateTable.elementAt(i);
+ short[] state2 = tempStateTable.elementAt(i);
for (int j = 0; j < numCategories; j++) {
if (state[j] != 0 && state2[j] != 0) {
state2[j] = state[j];
@@ -1890,9 +1903,9 @@
// an end state, fill in all unpopulated cells with the values
// of the corresponding cells in the first row of the auto-
// generated sub-table.
- state = (short[])tempStateTable.elementAt(backTableOffset - 1);
+ state = tempStateTable.elementAt(backTableOffset - 1);
for (int i = 1; i < backTableOffset - 1; i++) {
- short[] state2 = (short[])tempStateTable.elementAt(i);
+ short[] state2 = tempStateTable.elementAt(i);
if ((state2[numCategories] & END_STATE_FLAG) == 0) {
for (int j = 0; j < numCategories; j++) {
if (state2[j] == 0) {
diff --git a/make/tools/src/build/tools/generatebreakiteratordata/SupplementaryCharacterData.java b/make/tools/src/build/tools/generatebreakiteratordata/SupplementaryCharacterData.java
index 3501119..e9c585f 100644
--- a/make/tools/src/build/tools/generatebreakiteratordata/SupplementaryCharacterData.java
+++ b/make/tools/src/build/tools/generatebreakiteratordata/SupplementaryCharacterData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -128,7 +128,7 @@
int new_index = 0;
int loop_count = dataCount - 1;
long data = tempTable[old_index];
- int start = (int)((long)(data>>32)) & CODEPOINT_MASK;
+ int start = (int)(data>>32) & CODEPOINT_MASK;
int end = (int)(data>>8) & CODEPOINT_MASK;
/*
@@ -142,7 +142,7 @@
newTempTable[new_index++] = composeEntry(start, (int)data);
for (int i = 0; i < loop_count; i++) {
data = tempTable[++old_index];
- int nextStart = (int)((long)(data>>32)) & CODEPOINT_MASK;
+ int nextStart = (int)(data>>32) & CODEPOINT_MASK;
/*
* If the previous end code point is not equal to the previous start
diff --git a/make/tools/src/build/tools/generatecharacter/GenerateCharacter.java b/make/tools/src/build/tools/generatecharacter/GenerateCharacter.java
index 2f7828b..6ae5c5e 100644
--- a/make/tools/src/build/tools/generatecharacter/GenerateCharacter.java
+++ b/make/tools/src/build/tools/generatecharacter/GenerateCharacter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -1290,7 +1290,7 @@
else if (bits == 32 || bits < 8)
result.append(hex8((int)val));
else {
- result.append(hex16((long)val));
+ result.append(hex16(val));
if (!Csyntax)
result.append("L");
}
diff --git a/make/tools/src/build/tools/generatecharacter/SpecialCaseMap.java b/make/tools/src/build/tools/generatecharacter/SpecialCaseMap.java
index 0493175..c96d04d 100644
--- a/make/tools/src/build/tools/generatecharacter/SpecialCaseMap.java
+++ b/make/tools/src/build/tools/generatecharacter/SpecialCaseMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -39,7 +39,7 @@
* <p>
* @author John O'Conner
*/
-public class SpecialCaseMap implements Comparable {
+public class SpecialCaseMap implements Comparable<SpecialCaseMap> {
SpecialCaseMap() {
chSource = 0xFFFF;
@@ -55,7 +55,7 @@
*/
public static SpecialCaseMap[] readSpecFile(File file, int plane) throws FileNotFoundException {
- ArrayList caseMaps = new ArrayList(150);
+ ArrayList<SpecialCaseMap> caseMaps = new ArrayList<>(150);
int count = 0;
BufferedReader f = new BufferedReader(new FileReader(file));
String line = null;
@@ -69,7 +69,7 @@
SpecialCaseMap item = parse(line.trim());
if (item != null) {
if(item.getCharSource() >> 16 < plane) continue;
- if((int)(item.getCharSource() >> 16) > plane) break;
+ if(item.getCharSource() >> 16 > plane) break;
caseMaps.add(item);
++count;
}
@@ -83,7 +83,7 @@
}
- /**
+ /**
* Given one line of a Unicode special casing data file as a String, parse the line
* and return a SpecialCaseMap object that contains the case mapping.
*
@@ -177,25 +177,25 @@
else return -1;
}
- /*
+ /*
* Extracts and returns the high surrogate value from a UTF-32 code point.
* If argument is a BMP character, then it is converted to a char and returned;
* otherwise the high surrogate value is extracted.
* @param codePoint a UTF-32 codePoint with value greater than 0xFFFF.
* @return the high surrogate value that helps create <code>codePoint</code>; else
* the char representation of <code>codePoint</code> if it is a BMP character.
- * @since 1.5
+ * @since 1.5
*/
- static char getHighSurrogate(int codePoint) {
- char high = (char)codePoint;
- if (codePoint > 0xFFFF) {
- high = (char)((codePoint - 0x10000)/0x0400 + 0xD800);
- }
- return high;
+ static char getHighSurrogate(int codePoint) {
+ char high = (char)codePoint;
+ if (codePoint > 0xFFFF) {
+ high = (char)((codePoint - 0x10000)/0x0400 + 0xD800);
}
+ return high;
+ }
- /*
+ /*
* Extracts and returns the low surrogate value from a UTF-32 code point.
* If argument is a BMP character, then it is converted to a char and returned;
* otherwise the high surrogate value is extracted.
@@ -204,29 +204,28 @@
* the char representation of <code>codePoint</code> if it is a BMP character.
* @since 1.5
*/
- static char getLowSurrogate(int codePoint) {
- char low = (char)codePoint;
- if(codePoint > 0xFFFF) {
- low = (char)((codePoint - 0x10000)%0x0400 + 0xDC00);
- }
- return low;
+ static char getLowSurrogate(int codePoint) {
+ char low = (char)codePoint;
+ if(codePoint > 0xFFFF) {
+ low = (char)((codePoint - 0x10000)%0x0400 + 0xDC00);
}
+ return low;
+ }
- static String hex6(int n) {
- String str = Integer.toHexString(n & 0xFFFFFF).toUpperCase();
- return "000000".substring(Math.min(6, str.length())) + str;
+ static String hex6(int n) {
+ String str = Integer.toHexString(n & 0xFFFFFF).toUpperCase();
+ return "000000".substring(Math.min(6, str.length())) + str;
+ }
+ static String hex6(char[] map){
+ StringBuffer buff = new StringBuffer();
+ int x=0;
+ buff.append(hex6(map[x++]));
+ while(x<map.length) {
+ buff.append(" " + hex6(map[x++]));
}
-
- static String hex6(char[] map){
- StringBuffer buff = new StringBuffer();
- int x=0;
- buff.append(hex6(map[x++]));
- while(x<map.length) {
- buff.append(" " + hex6(map[x++]));
- }
- return buff.toString();
- }
+ return buff.toString();
+ }
void setCharSource(int ch) {
chSource = ch;
@@ -302,56 +301,62 @@
static String CONTEXT_MODERN = "MODERN";
static String CONTEXT_NONMODERN = "NON_MODERN";
- public int compareTo(Object otherObject) {
- SpecialCaseMap other = (SpecialCaseMap)otherObject;
- if (chSource < other.chSource) {
+ public int compareTo(SpecialCaseMap otherObject) {
+ if (chSource < otherObject.chSource) {
return -1;
}
- else if (chSource > other.chSource) {
+ else if (chSource > otherObject.chSource) {
return 1;
}
else return 0;
}
public boolean equals(Object o1) {
- boolean bEqual = false;
- if (0 == compareTo(o1)) {
- bEqual = true;
- }
+ if (this == o1) {
+ return true;
+ }
+ if (o1 == null || !(o1 instanceof SpecialCaseMap)) {
+ return false;
+ }
+ SpecialCaseMap other = (SpecialCaseMap)o1;
+ boolean bEqual = false;
+ if (0 == compareTo(other)) {
+ bEqual = true;
+ }
return bEqual;
}
- public String toString() {
- StringBuffer buff = new StringBuffer();
- buff.append(hex6(getCharSource()));
- buff.append("|" + hex6(lowerCaseMap));
- buff.append("|" + hex6(upperCaseMap));
- buff.append("|" + hex6(titleCaseMap));
- buff.append("|" + context);
- return buff.toString();
- }
+ public String toString() {
+ StringBuffer buff = new StringBuffer();
+ buff.append(hex6(getCharSource()));
+ buff.append("|" + hex6(lowerCaseMap));
+ buff.append("|" + hex6(upperCaseMap));
+ buff.append("|" + hex6(titleCaseMap));
+ buff.append("|" + context);
+ return buff.toString();
+ }
- public int hashCode() {
- return (int)chSource;
- }
+ public int hashCode() {
+ return chSource;
+ }
- public static void main(String[] args) {
- SpecialCaseMap[] spec = null;
- if (args.length == 2 ) {
- try {
- File file = new File(args[0]);
- int plane = Integer.parseInt(args[1]);
- spec = SpecialCaseMap.readSpecFile(file, plane);
- System.out.println("SpecialCaseMap[" + spec.length + "]:");
- for (int x=0; x<spec.length; x++) {
- System.out.println(spec[x].toString());
- }
- }
- catch(Exception e) {
- e.printStackTrace();
- }
+ public static void main(String[] args) {
+ SpecialCaseMap[] spec = null;
+ if (args.length == 2 ) {
+ try {
+ File file = new File(args[0]);
+ int plane = Integer.parseInt(args[1]);
+ spec = SpecialCaseMap.readSpecFile(file, plane);
+ System.out.println("SpecialCaseMap[" + spec.length + "]:");
+ for (int x=0; x<spec.length; x++) {
+ System.out.println(spec[x].toString());
}
-
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
}
+ }
+
}
diff --git a/make/tools/src/build/tools/generatecharacter/UnicodeSpec.java b/make/tools/src/build/tools/generatecharacter/UnicodeSpec.java
index 7d85fca..2993fc9 100644
--- a/make/tools/src/build/tools/generatecharacter/UnicodeSpec.java
+++ b/make/tools/src/build/tools/generatecharacter/UnicodeSpec.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -391,31 +391,31 @@
*/
public static UnicodeSpec[] readSpecFile(File file, int plane) throws FileNotFoundException {
- ArrayList list = new ArrayList(3000);
+ ArrayList<UnicodeSpec> list = new ArrayList<>(3000);
UnicodeSpec[] result = null;
int count = 0;
BufferedReader f = new BufferedReader(new FileReader(file));
- String line = null;
+ String line = null;
loop:
while(true) {
try {
line = f.readLine();
}
catch (IOException e) {
- break loop;
- }
+ break loop;
+ }
if (line == null) break loop;
UnicodeSpec item = parse(line.trim());
- int specPlane = (int)(item.getCodePoint() >>> 16);
- if (specPlane < plane) continue;
- if (specPlane > plane) break;
+ int specPlane = item.getCodePoint() >>> 16;
+ if (specPlane < plane) continue;
+ if (specPlane > plane) break;
if (item != null) {
- list.add(item);
+ list.add(item);
}
}
- result = new UnicodeSpec[list.size()];
- list.toArray(result);
+ result = new UnicodeSpec[list.size()];
+ list.toArray(result);
return result;
}
diff --git a/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java b/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java
index c05f1ba..3c6aebf 100644
--- a/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java
+++ b/make/tools/src/build/tools/generatecurrencydata/GenerateCurrencyData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -250,10 +250,10 @@
return Integer.parseInt(numericCode);
}
- static HashMap specialCaseMap = new HashMap();
+ static HashMap<String, Integer> specialCaseMap = new HashMap<>();
private static int makeSpecialCaseEntry(String currencyInfo) throws Exception {
- Integer oldEntry = (Integer) specialCaseMap.get(currencyInfo);
+ Integer oldEntry = specialCaseMap.get(currencyInfo);
if (oldEntry != null) {
return oldEntry.intValue();
}
diff --git a/make/tools/src/build/tools/hasher/Hasher.java b/make/tools/src/build/tools/hasher/Hasher.java
index 1e2b418..bf04197 100644
--- a/make/tools/src/build/tools/hasher/Hasher.java
+++ b/make/tools/src/build/tools/hasher/Hasher.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, 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
@@ -51,15 +51,15 @@
boolean verbose = false;
- List keys = new ArrayList(); // Key strings
- List values = new ArrayList(); // Value expressions
- String pkg = null; // Package prefix for generated class
- String cln = null; // Name of generated class
- String vtype = "String"; // Value type
- int maxBits = 11; // lg table size
- int maxDepth = 3; // Max chain depth
- boolean inner = false; // Generating an inner class?
- boolean empty = false; // Generating an empty table?
+ List<String> keys = new ArrayList<>(); // Key strings
+ List<String> values = new ArrayList<>(); // Value expressions
+ String pkg = null; // Package prefix for generated class
+ String cln = null; // Name of generated class
+ String vtype = "String"; // Value type
+ int maxBits = 11; // lg table size
+ int maxDepth = 3; // Max chain depth
+ boolean inner = false; // Generating an inner class?
+ boolean empty = false; // Generating an empty table?
void usage() {
err.println("usage: java Hasher [options] [[pkgName.]ClassName]");
@@ -76,9 +76,9 @@
}
Hasher(String[] args) {
- List as = Arrays.asList(args);
- for (Iterator i = as.iterator(); i.hasNext();) {
- String a = (String)i.next();
+ List<String> as = Arrays.asList(args);
+ for (Iterator<String> i = as.iterator(); i.hasNext();) {
+ String a = i.next();
if (a.equals("-e")) {
empty = true;
} else if (a.equals("-i")) {
@@ -88,15 +88,15 @@
} else if (a.equals("-md")) {
if (!i.hasNext())
usage();
- maxDepth = Integer.parseInt((String)i.next());
+ maxDepth = Integer.parseInt(i.next());
} else if (a.equals("-mb")) {
if (!i.hasNext())
usage();
- maxBits = Integer.parseInt((String)i.next());
+ maxBits = Integer.parseInt(i.next());
} else if (a.equals("-t")) {
if (!i.hasNext())
usage();
- vtype = (String)i.next();
+ vtype = i.next();
} else if (a.startsWith("-")) {
usage();
} else {
@@ -153,8 +153,8 @@
int nw = keys.size();
for (int i = 0; i < nw; i++) {
- String w = (String)keys.get(i);
- String v = (String)values.get(i);
+ String w = keys.get(i);
+ String v = values.get(i);
int h = hash(w);
if (ht[h] == null)
ht[h] = new Object[] { w, v };
@@ -217,7 +217,7 @@
if (verbose)
err.println();
for (int i = 0, n = keys.size(); i < n; i++) {
- String w = (String)keys.get(i);
+ String w = keys.get(i);
String v = get(w);
if (verbose)
err.println(hash(w) + "\t" + w);
diff --git a/make/tools/src/build/tools/jarsplit/JarSplit.java b/make/tools/src/build/tools/jarsplit/JarSplit.java
index a9f91e8..a0999de 100644
--- a/make/tools/src/build/tools/jarsplit/JarSplit.java
+++ b/make/tools/src/build/tools/jarsplit/JarSplit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -43,7 +43,8 @@
/* classlist[0] contains class file list
* classlist[1] contains non-class file list
*/
- private static Vector<String>[] classlist = (Vector<String>[])(new Vector[2]);
+ @SuppressWarnings("unchecked")
+ private static Vector<String>[] classlist = new Vector<>[2];
/* The 2 class list name passed as arguments. */
private static String[] fileNamelist = new String[2];
diff --git a/make/tools/src/build/tools/javazic/Gen.java b/make/tools/src/build/tools/javazic/Gen.java
index d8078e4..8f3a8c5 100644
--- a/make/tools/src/build/tools/javazic/Gen.java
+++ b/make/tools/src/build/tools/javazic/Gen.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -30,14 +30,9 @@
import java.io.FileOutputStream;
import java.io.DataOutputStream;
import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
import sun.util.calendar.ZoneInfoFile;
/**
@@ -105,14 +100,13 @@
/* if DST offset is 0, this means DST isn't used.
* (NOT: offset's index is 0.)
*/
- if ((dstoffset =
- ((Integer)dstOffsets.get(i)).intValue()) == -1) {
+ if ((dstoffset = dstOffsets.get(i).intValue()) == -1) {
dstoffset = 0;
}
- dos.writeLong((((Long)transitions.get(i)).longValue() << 12)
+ dos.writeLong((transitions.get(i).longValue() << 12)
| (dstoffset << 4)
- | ((Integer)offsets.get(i)).intValue());
+ | offsets.get(i).intValue());
}
diff --git a/make/tools/src/build/tools/javazic/GenDoc.java b/make/tools/src/build/tools/javazic/GenDoc.java
index d487ebd..c598b9b 100644
--- a/make/tools/src/build/tools/javazic/GenDoc.java
+++ b/make/tools/src/build/tools/javazic/GenDoc.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -31,12 +31,8 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -189,7 +185,7 @@
out.write(header1 + new Date() + header3 + zonename + header4);
out.write(body1 + "<FONT size=\"+2\"><B>" + zonename + "</B></FONT>");
- LatitudeAndLongitude location = (LatitudeAndLongitude)mapList.get(zonename);
+ LatitudeAndLongitude location = mapList.get(zonename);
if (location != null) {
int deg, min, sec;
@@ -608,12 +604,12 @@
"<BR>\n\n" + "<TABLE BORDER=\"0\" WIDTH=\"100%\">\n" +
"<TR>\n<TD NOWRAP>\n");
- Set aliasSet = a.keySet();
+ Set<String> aliasSet = a.keySet();
len = aliasSet.size();
- Object aliasNames[] = aliasSet.toArray();
+ String aliasNames[] = aliasSet.toArray(new String[0]);
for (int i = 0; i < len; i++) {
- displayNameList.put(transform((String)aliasNames[i]),
- (String)aliasNames[i]);
+ displayNameList.put(transform(aliasNames[i]),
+ aliasNames[i]);
}
o = displayNameList.keySet().toArray();
diff --git a/make/tools/src/build/tools/javazic/Main.java b/make/tools/src/build/tools/javazic/Main.java
index 95ab91e..a91ab91 100644
--- a/make/tools/src/build/tools/javazic/Main.java
+++ b/make/tools/src/build/tools/javazic/Main.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -26,7 +26,6 @@
package build.tools.javazic;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
diff --git a/make/tools/src/build/tools/javazic/Mappings.java b/make/tools/src/build/tools/javazic/Mappings.java
index 8860220..954d3d5 100644
--- a/make/tools/src/build/tools/javazic/Mappings.java
+++ b/make/tools/src/build/tools/javazic/Mappings.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -26,9 +26,6 @@
package build.tools.javazic;
import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
diff --git a/make/tools/src/build/tools/javazic/Simple.java b/make/tools/src/build/tools/javazic/Simple.java
index 773c616..69c7fe7 100644
--- a/make/tools/src/build/tools/javazic/Simple.java
+++ b/make/tools/src/build/tools/javazic/Simple.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -29,10 +29,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -51,22 +48,19 @@
/**
* Zone records which are applied for given year.
*/
- private static Map<String,ZoneRec> lastZoneRecs
- = new HashMap<String,ZoneRec>();
+ private static Map<String,ZoneRec> lastZoneRecs = new HashMap<>();
/**
* Rule records which are applied for given year.
*/
- private static Map<String,List<RuleRec>> lastRules
- = new TreeMap<String,List<RuleRec>>();
+ private static Map<String,List<RuleRec>> lastRules = new TreeMap<>();
/**
* zone IDs sorted by their GMT offsets. If zone's GMT
* offset will change in the future, its last known offset is
* used.
*/
- private SortedMap<Integer, Set<String>> zonesByOffset
- = new TreeMap<Integer, Set<String>>();
+ private SortedMap<Integer, Set<String>> zonesByOffset = new TreeMap<>();
/**
* Sets last Rule records and Zone records for given timezone to
@@ -86,7 +80,7 @@
int lastKnownOffset = tz.getRawOffset();
Set<String> set = zonesByOffset.get(lastKnownOffset);
if (set == null) {
- set = new TreeSet<String>();
+ set = new TreeSet<>();
zonesByOffset.put(lastKnownOffset, set);
}
set.add(zonename);
@@ -101,16 +95,11 @@
*/
int generateSrc(Mappings map) {
try {
- String outputDir = Main.getOutputDir();
- File outD = new File(outputDir);
-
- if (!outputDir.endsWith(File.separator)) {
- outputDir += outD.separator;
- }
+ File outD = new File(Main.getOutputDir());
outD.mkdirs();
FileWriter fw =
- new FileWriter(outputDir + "TimeZoneData.java", false);
+ new FileWriter(new File(outD, "TimeZoneData.java"), false);
BufferedWriter out = new BufferedWriter(fw);
out.write("import java.util.SimpleTimeZone;\n\n");
diff --git a/make/tools/src/build/tools/javazic/Time.java b/make/tools/src/build/tools/javazic/Time.java
index 985682e..66458a0 100644
--- a/make/tools/src/build/tools/javazic/Time.java
+++ b/make/tools/src/build/tools/javazic/Time.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -268,16 +268,16 @@
if (index < time.length()) {
char c = time.charAt(index++);
if (c == 's') {
- tm.setType(tm.STD);
+ tm.setType(Time.STD);
} else if (c == 'u' || c == 'g' || c == 'z') {
- tm.setType(tm.UTC);
+ tm.setType(Time.UTC);
} else if (c == 'w') {
- tm.setType(tm.WALL);
+ tm.setType(Time.WALL);
} else {
Main.panic("unknown time mode: "+c);
}
} else {
- tm.setType(tm.WALL);
+ tm.setType(Time.WALL);
}
return tm;
}
diff --git a/make/tools/src/build/tools/javazic/Zoneinfo.java b/make/tools/src/build/tools/javazic/Zoneinfo.java
index 727fa72..5614a3c 100644
--- a/make/tools/src/build/tools/javazic/Zoneinfo.java
+++ b/make/tools/src/build/tools/javazic/Zoneinfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -29,9 +29,7 @@
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -407,9 +405,9 @@
if (!zrec.hasUntil()) {
if (tz.getNTransitions() > 0) {
if (stdOffset == 0) {
- tz.setDSTType(tz.X_DST);
+ tz.setDSTType(Timezone.X_DST);
} else {
- tz.setDSTType(tz.LAST_DST);
+ tz.setDSTType(Timezone.LAST_DST);
}
long time = Time.getLocalTime(maxYear,
Month.JANUARY, 1, 0);
@@ -419,7 +417,7 @@
tz.getDstOffsetIndex(stdOffset));
tz.addUsedRec(zrec);
} else {
- tz.setDSTType(tz.NO_DST);
+ tz.setDSTType(Timezone.NO_DST);
}
break;
}
@@ -527,7 +525,7 @@
if (year == endYear && !zrec.hasUntil()) {
if (tz.getNTransitions() > 0) {
// Assume that this Zone stopped DST
- tz.setDSTType(tz.X_DST);
+ tz.setDSTType(Timezone.X_DST);
long time = Time.getLocalTime(maxYear, Month.JANUARY,
1, 0);
time -= zrec.getGmtOffset();
@@ -536,7 +534,7 @@
tz.getDstOffsetIndex(0));
usedZone = true;
} else {
- tz.setDSTType(tz.NO_DST);
+ tz.setDSTType(Timezone.NO_DST);
}
}
}
@@ -552,8 +550,8 @@
}
}
- if (tz.getDSTType() == tz.UNDEF_DST) {
- tz.setDSTType(tz.DST);
+ if (tz.getDSTType() == Timezone.UNDEF_DST) {
+ tz.setDSTType(Timezone.DST);
}
tz.optimize();
tz.checksum();
diff --git a/make/tools/src/build/tools/jdwpgen/AbstractCommandNode.java b/make/tools/src/build/tools/jdwpgen/AbstractCommandNode.java
index eaef0ef..f12e7a9 100644
--- a/make/tools/src/build/tools/jdwpgen/AbstractCommandNode.java
+++ b/make/tools/src/build/tools/jdwpgen/AbstractCommandNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -25,7 +25,6 @@
package build.tools.jdwpgen;
-import java.util.*;
import java.io.*;
class AbstractCommandNode extends AbstractNamedNode {
@@ -35,8 +34,8 @@
" Command</a> (" + nameNode.value() + ")</h5>");
writer.println(comment());
writer.println("<dl>");
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).document(writer);
+ for (Node node : components) {
+ node.document(writer);
}
writer.println("</dl>");
}
diff --git a/make/tools/src/build/tools/jdwpgen/AbstractGroupNode.java b/make/tools/src/build/tools/jdwpgen/AbstractGroupNode.java
index 872df76..83e8d43 100644
--- a/make/tools/src/build/tools/jdwpgen/AbstractGroupNode.java
+++ b/make/tools/src/build/tools/jdwpgen/AbstractGroupNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -25,14 +25,13 @@
package build.tools.jdwpgen;
-import java.util.*;
import java.io.*;
abstract class AbstractGroupNode extends AbstractTypeListNode {
void document(PrintWriter writer) {
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).document(writer);
+ for (Node node : components) {
+ node.document(writer);
}
}
diff --git a/make/tools/src/build/tools/jdwpgen/AbstractNamedNode.java b/make/tools/src/build/tools/jdwpgen/AbstractNamedNode.java
index 4de00d8..b5ad7ac 100644
--- a/make/tools/src/build/tools/jdwpgen/AbstractNamedNode.java
+++ b/make/tools/src/build/tools/jdwpgen/AbstractNamedNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -38,10 +38,10 @@
}
void prune() {
- Iterator it = components.iterator();
+ Iterator<Node> it = components.iterator();
if (it.hasNext()) {
- Node nameNode = (Node)it.next();
+ Node nameNode = it.next();
if (nameNode instanceof NameNode) {
this.nameNode = (NameNode)nameNode;
@@ -64,8 +64,8 @@
void document(PrintWriter writer) {
writer.println("<h4><a name=" + name + ">" + name +
" Command Set</a></h4>");
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).document(writer);
+ for (Node node : components) {
+ node.document(writer);
}
}
@@ -90,8 +90,8 @@
writer.print("class " + javaClassName());
writer.println(javaClassImplements() + " {");
genJavaClassSpecifics(writer, depth+1);
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).genJava(writer, depth+1);
+ for (Node node : components) {
+ node.genJava(writer, depth+1);
}
indent(writer, depth);
writer.println("}");
diff --git a/make/tools/src/build/tools/jdwpgen/AbstractTypeListNode.java b/make/tools/src/build/tools/jdwpgen/AbstractTypeListNode.java
index 7dc6770..b9d9907 100644
--- a/make/tools/src/build/tools/jdwpgen/AbstractTypeListNode.java
+++ b/make/tools/src/build/tools/jdwpgen/AbstractTypeListNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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 @@
void document(PrintWriter writer) {
writer.println("<dt>" + name() + " Data");
- if (components.size() == 0) {
+ if (components.isEmpty()) {
writer.println("<dd>(None)");
} else {
writer.println("<dd><table border=1 cellpadding=3 cellspacing=0 width=\"90%\" summary=\"\"><tr>");
@@ -49,24 +49,24 @@
}
writer.println("<th width=\"15%\"><th width=\"65%\">");
writer.println("");
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).document(writer);
+ for (Node node : components) {
+ node.document(writer);
}
writer.println("</table>");
}
}
void genJavaClassBodyComponents(PrintWriter writer, int depth) {
- for (Iterator it = components.iterator(); it.hasNext();) {
- TypeNode tn = (TypeNode)it.next();
+ for (Node node : components) {
+ TypeNode tn = (TypeNode)node;
tn.genJavaDeclaration(writer, depth);
}
}
void genJavaReads(PrintWriter writer, int depth) {
- for (Iterator it = components.iterator(); it.hasNext();) {
- TypeNode tn = (TypeNode)it.next();
+ for (Node node : components) {
+ TypeNode tn = (TypeNode)node;
tn.genJavaRead(writer, depth, tn.name());
}
}
@@ -88,7 +88,7 @@
String javaParams() {
StringBuffer sb = new StringBuffer();
- for (Iterator it = components.iterator(); it.hasNext();) {
+ for (Iterator<Node> it = components.iterator(); it.hasNext();) {
TypeNode tn = (TypeNode)it.next();
sb.append(tn.javaParam());
if (it.hasNext()) {
@@ -99,8 +99,8 @@
}
void genJavaWrites(PrintWriter writer, int depth) {
- for (Iterator it = components.iterator(); it.hasNext();) {
- TypeNode tn = (TypeNode)it.next();
+ for (Node node : components) {
+ TypeNode tn = (TypeNode)node;
tn.genJavaWrite(writer, depth, tn.name());
}
}
@@ -111,8 +111,8 @@
writer.println();
indent(writer, depth);
writer.println(className + "(" + javaParams() + ") {");
- for (Iterator it = components.iterator(); it.hasNext();) {
- TypeNode tn = (TypeNode)it.next();
+ for (Node node : components) {
+ TypeNode tn = (TypeNode)node;
indent(writer, depth+1);
writer.println("this." + tn.name() + " = " + tn.name() + ";");
}
diff --git a/make/tools/src/build/tools/jdwpgen/AltNode.java b/make/tools/src/build/tools/jdwpgen/AltNode.java
index 78843a2..d9dca77 100644
--- a/make/tools/src/build/tools/jdwpgen/AltNode.java
+++ b/make/tools/src/build/tools/jdwpgen/AltNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -100,7 +100,7 @@
indent(writer, depth+1);
writer.print("return new " + select.name() + "(");
writer.print("ALT_ID, new " + javaClassName() + "(");
- for (Iterator it = components.iterator(); it.hasNext();) {
+ for (Iterator<Node> it = components.iterator(); it.hasNext();) {
TypeNode tn = (TypeNode)it.next();
writer.print(tn.name());
if (it.hasNext()) {
diff --git a/make/tools/src/build/tools/jdwpgen/CommandSetNode.java b/make/tools/src/build/tools/jdwpgen/CommandSetNode.java
index 7db81bd..6850aa3 100644
--- a/make/tools/src/build/tools/jdwpgen/CommandSetNode.java
+++ b/make/tools/src/build/tools/jdwpgen/CommandSetNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -25,7 +25,6 @@
package build.tools.jdwpgen;
-import java.util.*;
import java.io.*;
class CommandSetNode extends AbstractNamedNode {
@@ -43,8 +42,8 @@
" Command Set</a> (" +
nameNode.value() + ")</h4>");
writer.println(comment());
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).document(writer);
+ for (Node node : components) {
+ node.document(writer);
}
}
@@ -53,8 +52,8 @@
writer.println(name() + "</a> Command Set (" +
nameNode.value() + ")");
writer.println("<ul>");
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).documentIndex(writer);
+ for (Node node : components) {
+ node.documentIndex(writer);
}
writer.println("</ul>");
}
diff --git a/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java b/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java
index 6145bfd..ac3d4d9 100644
--- a/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java
+++ b/make/tools/src/build/tools/jdwpgen/ConstantSetNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -33,14 +33,11 @@
/**
* The mapping between a constant and its value.
*/
- protected static final Map<String, String> constantMap = new HashMap<String, String>();
+ protected static final Map<String, String> constantMap = new HashMap<>();
void prune() {
- List<Node> addons = new ArrayList<Node>();
+ List<Node> addons = new ArrayList<>();
- for (Iterator it = components.iterator(); it.hasNext(); ) {
- Node node = (Node)it.next();
- }
if (!addons.isEmpty()) {
components.addAll(addons);
}
@@ -63,8 +60,8 @@
writer.println("<dd><table border=1 cellpadding=3 cellspacing=0 width=\"90%\" summary=\"\"><tr>");
writer.println("<th width=\"20%\"><th width=\"5%\"><th width=\"65%\">");
ConstantNode n;
- for (Iterator it = components.iterator(); it.hasNext();) {
- n = ((ConstantNode)it.next());
+ for (Node node : components) {
+ n = (ConstantNode)node;
writer.println("<a NAME=\"" + name + "_" + n.name + "\"></a>");
n.document(writer);
}
diff --git a/make/tools/src/build/tools/jdwpgen/ErrorSetNode.java b/make/tools/src/build/tools/jdwpgen/ErrorSetNode.java
index 6e4396f..a997779 100644
--- a/make/tools/src/build/tools/jdwpgen/ErrorSetNode.java
+++ b/make/tools/src/build/tools/jdwpgen/ErrorSetNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -25,7 +25,6 @@
package build.tools.jdwpgen;
-import java.util.*;
import java.io.*;
class ErrorSetNode extends AbstractSimpleNode {
@@ -41,12 +40,12 @@
void document(PrintWriter writer) {
writer.println("<dt>" + "Error Data");
- if (components.size() == 0) {
+ if (components.isEmpty()) {
writer.println("<dd>(None)");
} else {
writer.println("<dd><table border=1 cellpadding=3 cellspacing=0 width=\"90%\" summary=\"\">");
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).document(writer);
+ for (Node node : components) {
+ node.document(writer);
}
writer.println("</table>");
}
diff --git a/make/tools/src/build/tools/jdwpgen/Node.java b/make/tools/src/build/tools/jdwpgen/Node.java
index 1ac9e32..fe46eb0 100644
--- a/make/tools/src/build/tools/jdwpgen/Node.java
+++ b/make/tools/src/build/tools/jdwpgen/Node.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -34,7 +34,7 @@
String kind;
List<Node> components;
int lineno;
- List<String> commentList = new ArrayList<String>();
+ List<String> commentList = new ArrayList<>();
Node parent = null;
Context context = null;
@@ -50,8 +50,8 @@
}
void parentAndExtractComments() {
- for (Iterator it = components.iterator(); it.hasNext();) {
- Node node = (Node)it.next();
+ for (Iterator<Node> it = components.iterator(); it.hasNext();) {
+ Node node = it.next();
if (node instanceof CommentNode) {
it.remove();
commentList.add(((CommentNode)node).text());
@@ -63,16 +63,14 @@
}
void prune() {
- for (Iterator it = components.iterator(); it.hasNext();) {
- Node node = (Node)it.next();
+ for (Node node : components) {
node.prune();
}
}
void constrain(Context ctx) {
context = ctx;
- for (Iterator it = components.iterator(); it.hasNext();) {
- Node node = (Node)it.next();
+ for (Node node : components) {
constrainComponent(ctx, node);
}
}
@@ -109,9 +107,9 @@
if (commentList.size() > 0) {
indent(writer, depth);
writer.println("/**");
- for (Iterator it = commentList.iterator(); it.hasNext();) {
+ for (String comment : commentList) {
indent(writer, depth);
- writer.println(" * " + (String)it.next());
+ writer.println(" * " + comment);
}
indent(writer, depth);
writer.println(" */");
@@ -123,15 +121,13 @@
}
void genJava(PrintWriter writer, int depth) {
- for (Iterator it = components.iterator(); it.hasNext();) {
- Node node = (Node)it.next();
+ for (Node node : components) {
node.genJava(writer, depth);
}
}
void genCInclude(PrintWriter writer) {
- for (Iterator it = components.iterator(); it.hasNext();) {
- Node node = (Node)it.next();
+ for (Node node : components) {
node.genCInclude(writer);
}
}
@@ -184,8 +180,7 @@
}
void genJavaPreDef(PrintWriter writer, int depth) {
- for (Iterator it = components.iterator(); it.hasNext();) {
- Node node = (Node)it.next();
+ for (Node node : components) {
node.genJavaPreDef(writer, depth);
}
}
diff --git a/make/tools/src/build/tools/jdwpgen/OutNode.java b/make/tools/src/build/tools/jdwpgen/OutNode.java
index f711b25..1a0b426 100644
--- a/make/tools/src/build/tools/jdwpgen/OutNode.java
+++ b/make/tools/src/build/tools/jdwpgen/OutNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -48,8 +48,8 @@
indent(writer, depth);
writer.print(
"static " + cmdName + " process(VirtualMachineImpl vm");
- for (Iterator it = components.iterator(); it.hasNext();) {
- TypeNode tn = (TypeNode)it.next();
+ for (Node node : components) {
+ TypeNode tn = (TypeNode)node;
writer.println(", ");
indent(writer, depth+5);
writer.print(tn.javaParam());
@@ -59,8 +59,8 @@
writer.println("throws JDWPException {");
indent(writer, depth+1);
writer.print("PacketStream ps = enqueueCommand(vm");
- for (Iterator it = components.iterator(); it.hasNext();) {
- TypeNode tn = (TypeNode)it.next();
+ for (Node node : components) {
+ TypeNode tn = (TypeNode)node;
writer.print(", ");
writer.print(tn.name());
}
@@ -76,8 +76,8 @@
indent(writer, depth);
writer.print(
"static PacketStream enqueueCommand(VirtualMachineImpl vm");
- for (Iterator it = components.iterator(); it.hasNext();) {
- TypeNode tn = (TypeNode)it.next();
+ for (Node node : components) {
+ TypeNode tn = (TypeNode)node;
writer.println(", ");
indent(writer, depth+5);
writer.print(tn.javaParam());
diff --git a/make/tools/src/build/tools/jdwpgen/RootNode.java b/make/tools/src/build/tools/jdwpgen/RootNode.java
index 4388929..80ad655 100644
--- a/make/tools/src/build/tools/jdwpgen/RootNode.java
+++ b/make/tools/src/build/tools/jdwpgen/RootNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -42,11 +42,11 @@
void document(PrintWriter writer) {
writer.println("<html><head><title>" + comment() + "</title></head>");
writer.println("<body bgcolor=\"white\">");
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).documentIndex(writer);
+ for (Node node : components) {
+ node.documentIndex(writer);
}
- for (Iterator it = components.iterator(); it.hasNext();) {
- ((Node)it.next()).document(writer);
+ for (Node node : components) {
+ node.document(writer);
}
writer.println("</body></html>");
}
diff --git a/make/tools/src/build/tools/jdwpgen/SelectNode.java b/make/tools/src/build/tools/jdwpgen/SelectNode.java
index ce660b4..506f33b 100644
--- a/make/tools/src/build/tools/jdwpgen/SelectNode.java
+++ b/make/tools/src/build/tools/jdwpgen/SelectNode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, 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
@@ -34,10 +34,10 @@
void prune() {
super.prune();
- Iterator it = components.iterator();
+ Iterator<Node> it = components.iterator();
if (it.hasNext()) {
- Node typeNode = (Node)it.next();
+ Node typeNode = it.next();
if (typeNode instanceof ByteTypeNode ||
typeNode instanceof IntTypeNode) {
@@ -131,8 +131,8 @@
typeNode.genJavaRead(writer, depth, typeNode.name());
indent(writer, depth);
writer.println("switch (" + typeNode.name() + ") {");
- for (Iterator it = components.iterator(); it.hasNext();) {
- AltNode alt = (AltNode)it.next();
+ for (Node node : components) {
+ AltNode alt = (AltNode)node;
alt.genJavaReadsSelectCase(writer, depth+1, commonVar());
}
indent(writer, depth);
diff --git a/make/tools/src/build/tools/makeclasslist/MakeClasslist.java b/make/tools/src/build/tools/makeclasslist/MakeClasslist.java
index 3f985fd..d7d7b25 100644
--- a/make/tools/src/build/tools/makeclasslist/MakeClasslist.java
+++ b/make/tools/src/build/tools/makeclasslist/MakeClasslist.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -38,7 +38,7 @@
public class MakeClasslist {
public static void main(String[] args) throws IOException {
- List/*<String>*/ classes = new ArrayList();
+ List<String> classes = new ArrayList<>();
String origJavaHome = System.getProperty("java.home");
String javaHome = origJavaHome.toLowerCase();
if (javaHome.endsWith("jre")) {
@@ -84,10 +84,9 @@
}
}
- Set/*<String>*/ seenClasses = new HashSet();
+ Set<String> seenClasses = new HashSet<>();
- for (Iterator iter = classes.iterator(); iter.hasNext(); ) {
- String str = (String) iter.next();
+ for (String str : seenClasses) {
if (seenClasses.add(str)) {
System.out.println(str);
}
@@ -109,13 +108,13 @@
// completePackage(seenClasses, rtJar, "java/lang");
}
- private static void completePackage(Set seenClasses,
+ private static void completePackage(Set<String> seenClasses,
JarFile jar,
String packageName) {
int len = packageName.length();
- Enumeration entries = jar.entries();
+ Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
- JarEntry entry = (JarEntry) entries.nextElement();
+ JarEntry entry = entries.nextElement();
String name = entry.getName();
if (name.startsWith(packageName) &&
name.endsWith(".class") &&
diff --git a/make/tools/src/build/tools/stripproperties/StripProperties.java b/make/tools/src/build/tools/stripproperties/StripProperties.java
index dcf7114..57563e2 100644
--- a/make/tools/src/build/tools/stripproperties/StripProperties.java
+++ b/make/tools/src/build/tools/stripproperties/StripProperties.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -246,7 +246,7 @@
throws IOException {
BufferedWriter awriter;
awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
- for (Enumeration e = properties.keys(); e.hasMoreElements();) {
+ for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
String key = (String)e.nextElement();
String val = (String)properties.get(key);
key = saveConvert(key, true);
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java
index f8d0e0c..164870e 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -45,7 +45,7 @@
* attribute layouts.
* @author John Rose
*/
-class Attribute implements Comparable {
+class Attribute implements Comparable<Attribute> {
// Attribute instance fields.
Layout def; // the name and format of this attr
@@ -99,8 +99,7 @@
return this == def.canon;
}
- public int compareTo(Object o) {
- Attribute that = (Attribute) o;
+ public int compareTo(Attribute that) {
return this.def.compareTo(that.def);
}
@@ -447,7 +446,7 @@
* and format. The formats are specified in a "little language".
*/
public static
- class Layout implements Comparable {
+ class Layout implements Comparable<Layout> {
int ctype; // attribute context type, e.g., ATTR_CONTEXT_CODE
String name; // name of attribute
boolean hasRefs; // this kind of attr contains CP refs?
@@ -540,8 +539,7 @@
* 37 + layout.hashCode())
* 37 + ctype);
}
- public int compareTo(Object o) {
- Layout that = (Layout) o;
+ public int compareTo(Layout that) {
int r;
r = this.name.compareTo(that.name);
if (r != 0) return r;
@@ -663,6 +661,8 @@
public static
class FormatException extends IOException {
+ private static final long serialVersionUID = -2542243830788066513L;
+
private int ctype;
private String name;
String layout;
diff --git a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
index 62378d2..8d472b9 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java
@@ -1704,7 +1704,7 @@
for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
assert(attrIndexLimit[i] == 0);
attrIndexLimit[i] = 32; // just for the sake of predefs.
- attrDefs.set(i, new ArrayList<Attribute.Layout>(Collections.nCopies(
+ attrDefs.set(i, new ArrayList<>(Collections.nCopies(
attrIndexLimit[i], (Attribute.Layout)null)));
}
@@ -1892,7 +1892,7 @@
return testBit(archiveOptions, mask);
}
- protected List getPredefinedAttrs(int ctype) {
+ protected List<Attribute.Layout> getPredefinedAttrs(int ctype) {
assert(attrIndexLimit[ctype] != 0);
List<Attribute.Layout> res = new ArrayList<>(attrIndexLimit[ctype]);
// Remove nulls and non-predefs.
@@ -2649,7 +2649,7 @@
// Utilities for reallocating:
protected static Object[] realloc(Object[] a, int len) {
- java.lang.Class elt = a.getClass().getComponentType();
+ java.lang.Class<?> elt = a.getClass().getComponentType();
Object[] na = (Object[]) java.lang.reflect.Array.newInstance(elt, len);
System.arraycopy(a, 0, na, 0, Math.min(a.length, len));
return na;
diff --git a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
index eef5d20..ce29f1f 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -52,7 +52,7 @@
long inPos;
DataInputStream in;
Map<Attribute.Layout, Attribute> attrDefs;
- Map attrCommands;
+ Map<Attribute.Layout, String> attrCommands;
String unknownAttrCommand = "error";;
ClassReader(Class cls, InputStream in) throws IOException {
@@ -82,7 +82,7 @@
this.attrDefs = attrDefs;
}
- public void setAttrCommands(Map attrCommands) {
+ public void setAttrCommands(Map<Attribute.Layout, String> attrCommands) {
this.attrCommands = attrCommands;
}
@@ -348,8 +348,8 @@
int length = readInt();
// See if there is a special command that applies.
if (attrCommands != null) {
- Object lkey = Attribute.keyForLookup(ctype, name);
- String cmd = (String) attrCommands.get(lkey);
+ Attribute.Layout lkey = Attribute.keyForLookup(ctype, name);
+ String cmd = attrCommands.get(lkey);
if (cmd != null) {
switch (cmd) {
case "pass":
@@ -483,6 +483,8 @@
}
static class ClassFormatException extends IOException {
+ private static final long serialVersionUID = -3564121733989501833L;
+
public ClassFormatException(String message) {
super(message);
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java b/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java
index c8c5414..37424d1 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -36,7 +36,6 @@
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.List;
import static com.sun.java.util.jar.pack.Constants.*;
/**
@@ -165,14 +164,13 @@
}
void writeMembers(boolean doMethods) throws IOException {
- List mems;
+ List<? extends Class.Member> mems;
if (!doMethods)
mems = cls.getFields();
else
mems = cls.getMethods();
writeShort(mems.size());
- for (Iterator i = mems.iterator(); i.hasNext(); ) {
- Class.Member m = (Class.Member) i.next();
+ for (Class.Member m : mems) {
writeMember(m, doMethods);
}
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Code.java b/src/share/classes/com/sun/java/util/jar/pack/Code.java
index 788eada..e84cdaa 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Code.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Code.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -125,7 +125,7 @@
return expandInstructionMap(getInsnMap());
}
- void addFixups(Collection moreFixups) {
+ void addFixups(Collection<Fixups.Fixup> moreFixups) {
if (fixups == null) {
fixups = new Fixups(bytes);
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Coding.java b/src/share/classes/com/sun/java/util/jar/pack/Coding.java
index 2f73b8e..29dcb83 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Coding.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Coding.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -37,7 +37,7 @@
* varying degrees of length variability, and varying amounts of signed-ness.
* @author John Rose
*/
-class Coding implements Comparable, CodingMethod, Histogram.BitMetric {
+class Coding implements Comparable<Coding>, CodingMethod, Histogram.BitMetric {
/*
Coding schema for single integers, parameterized by (B,H,S):
@@ -605,8 +605,7 @@
public int byteMin(int b) { return byteMin[b-1]; }
public int byteMax(int b) { return byteMax[b-1]; }
- public int compareTo(Object x) {
- Coding that = (Coding) x;
+ public int compareTo(Coding that) {
int dkey = this.del - that.del;
if (dkey == 0)
dkey = this.B - that.B;
diff --git a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
index 3b851ef..acade5b 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -72,7 +72,7 @@
return e;
}
/** Factory for literal constants (String, Integer, etc.). */
- public static synchronized LiteralEntry getLiteralEntry(Comparable value) {
+ public static synchronized LiteralEntry getLiteralEntry(Comparable<?> value) {
Map<Object, LiteralEntry> literalEntries = Utils.getLiteralEntries();
LiteralEntry e = literalEntries.get(value);
if (e == null) {
@@ -140,7 +140,7 @@
/** Entries in the constant pool. */
public static abstract
- class Entry implements Comparable {
+ class Entry implements Comparable<Object> {
protected final byte tag; // a CONSTANT_foo code
protected int valueHash; // cached hashCode
@@ -257,7 +257,7 @@
super(tag);
}
- public abstract Comparable literalValue();
+ public abstract Comparable<?> literalValue();
}
public static
@@ -280,15 +280,17 @@
public int compareTo(Object o) {
int x = superCompareTo(o);
if (x == 0) {
- x = ((Comparable)value).compareTo(((NumberEntry)o).value);
+ @SuppressWarnings("unchecked")
+ Comparable<Number> compValue = (Comparable<Number>)value;
+ x = compValue.compareTo(((NumberEntry)o).value);
}
return x;
}
public Number numberValue() {
return value;
}
- public Comparable literalValue() {
- return (Comparable) value;
+ public Comparable<?> literalValue() {
+ return (Comparable<?>) value;
}
public String stringValue() {
return value.toString();
@@ -319,7 +321,7 @@
}
return x;
}
- public Comparable literalValue() {
+ public Comparable<?> literalValue() {
return ref.stringValue();
}
public String stringValue() {
@@ -728,7 +730,7 @@
/** An Index is a mapping between CP entries and small integers. */
public static final
- class Index extends AbstractList {
+ class Index extends AbstractList<Entry> {
protected String debugName;
protected Entry[] cpMap;
protected boolean flattenSigs;
@@ -758,7 +760,7 @@
public int size() {
return cpMap.length;
}
- public Object get(int i) {
+ public Entry get(int i) {
return cpMap[i];
}
public Entry getEntry(int i) {
@@ -803,13 +805,7 @@
assert(index >= 0);
return index;
}
- public boolean contains(Object e) {
- return findIndexOf((Entry)e) >= 0;
- }
- public int indexOf(Object e) {
- return findIndexOf((Entry)e);
- }
- public int lastIndexOf(Object e) {
+ public int lastIndexOf(Entry e) {
return indexOf(e);
}
@@ -862,14 +858,14 @@
indexValue[probe] = i;
}
}
- public Object[] toArray(Object[] a) {
+ public Entry[] toArray(Entry[] a) {
int sz = size();
if (a.length < sz) return super.toArray(a);
System.arraycopy(cpMap, 0, a, 0, sz);
if (a.length > sz) a[sz] = null;
return a;
}
- public Object[] toArray() {
+ public Entry[] toArray() {
return toArray(new Entry[size()]);
}
public Object clone() {
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/src/share/classes/com/sun/java/util/jar/pack/Constants.java
index 2e4cb37..8dc6560 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Constants.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Constants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -153,11 +153,11 @@
public static final int NO_MODTIME = 0; // null modtime value
// some comstantly empty containers
- public final static int[] noInts = {};
- public final static byte[] noBytes = {};
- public final static Object[] noValues = {};
- public final static String[] noStrings = {};
- public final static List emptyList = Arrays.asList(noValues);
+ public final static int[] noInts = {};
+ public final static byte[] noBytes = {};
+ public final static Object[] noValues = {};
+ public final static String[] noStrings = {};
+ public final static List<Object> emptyList = Arrays.asList(noValues);
// meta-coding
public final static int
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Fixups.java b/src/share/classes/com/sun/java/util/jar/pack/Fixups.java
index 15c5208..0c99351 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Fixups.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Fixups.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -42,7 +42,7 @@
*
* @author John Rose
*/
-final class Fixups extends AbstractCollection {
+final class Fixups extends AbstractCollection<Fixups.Fixup> {
byte[] bytes; // the subject of the relocations
int head; // desc locating first reloc
int tail; // desc locating last reloc
@@ -66,11 +66,11 @@
// If there are no bytes, all descs are kept in bigDescs.
this((byte[])null);
}
- Fixups(byte[] bytes, Collection fixups) {
+ Fixups(byte[] bytes, Collection<Fixup> fixups) {
this(bytes);
addAll(fixups);
}
- Fixups(Collection fixups) {
+ Fixups(Collection<Fixup> fixups) {
this((byte[])null);
addAll(fixups);
}
@@ -108,8 +108,7 @@
public void clear() {
if (bytes != null) {
// Clean the bytes:
- for (Iterator i = iterator(); i.hasNext(); ) {
- Fixup fx = (Fixup) i.next();
+ for (Fixup fx : this) {
//System.out.println("clean "+fx);
storeIndex(fx.location(), fx.format(), 0);
}
@@ -124,15 +123,14 @@
return bytes;
}
- @SuppressWarnings("unchecked")
public void setBytes(byte[] newBytes) {
if (bytes == newBytes) return;
- ArrayList old = null;
- assert((old = new ArrayList(this)) != null);
+ ArrayList<Fixup> old = null;
+ assert((old = new ArrayList<>(this)) != null);
if (bytes == null || newBytes == null) {
// One or the other representations is deficient.
// Construct a checkpoint.
- ArrayList save = new ArrayList(this);
+ ArrayList<Fixup> save = new ArrayList<>(this);
clear();
bytes = newBytes;
addAll(save);
@@ -140,7 +138,7 @@
// assume newBytes is some sort of bitwise copy of the old bytes
bytes = newBytes;
}
- assert(old.equals(new ArrayList(this)));
+ assert(old.equals(new ArrayList<>(this)));
}
static final int LOC_SHIFT = 1;
@@ -236,7 +234,7 @@
/** Simple and necessary tuple to present each fixup. */
public static
- class Fixup implements Comparable {
+ class Fixup implements Comparable<Fixup> {
int desc; // location and format of reloc
Entry entry; // which entry to plug into the bytes
Fixup(int desc, Entry entry) {
@@ -254,9 +252,6 @@
// Ordering depends only on location.
return this.location() - that.location();
}
- public int compareTo(Object that) {
- return compareTo((Fixup)that);
- }
public boolean equals(Object x) {
if (!(x instanceof Fixup)) return false;
Fixup that = (Fixup) x;
@@ -268,13 +263,13 @@
}
private
- class Itr implements Iterator {
+ class Itr implements Iterator<Fixup> {
int index = 0; // index into entries
int bigIndex = BIGSIZE+1; // index into bigDescs
int next = head; // desc pointing to next fixup
public boolean hasNext() { return index < size; }
public void remove() { throw new UnsupportedOperationException(); }
- public Object next() {
+ public Fixup next() {
int thisIndex = index;
return new Fixup(nextDesc(), entries[thisIndex]);
}
@@ -298,7 +293,7 @@
}
}
- public Iterator iterator() {
+ public Iterator<Fixup> iterator() {
return new Itr();
}
public void add(int location, int format, Entry entry) {
@@ -308,11 +303,8 @@
addDesc(f.desc, f.entry);
return true;
}
- public boolean add(Object fixup) {
- return add((Fixup) fixup);
- }
- @SuppressWarnings("unchecked")
- public boolean addAll(Collection c) {
+
+ public boolean addAll(Collection<? extends Fixup> c) {
if (c instanceof Fixups) {
// Use knowledge of Itr structure to avoid building little structs.
Fixups that = (Fixups) c;
@@ -453,8 +445,7 @@
void finishRefs(ConstantPool.Index ix) {
if (isEmpty())
return;
- for (Iterator i = iterator(); i.hasNext(); ) {
- Fixup fx = (Fixup) i.next();
+ for (Fixup fx : this) {
int index = ix.indexOf(fx.entry);
//System.out.println("finish "+fx+" = "+index);
// Note that the iterator has already fetched the
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Instruction.java b/src/share/classes/com/sun/java/util/jar/pack/Instruction.java
index e0744e2..8d94768 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Instruction.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Instruction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -657,6 +657,8 @@
}
}
static class FormatException extends IOException {
+ private static final long serialVersionUID = 3175572275651367015L;
+
FormatException(String message) {
super(message);
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java b/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java
index 7339682..c097f9e 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java
@@ -292,7 +292,7 @@
}
ZipEntry z = new ZipEntry(name);
- z.setTime( (long)mtime * 1000);
+ z.setTime(mtime * 1000);
if (size == 0) {
z.setMethod(ZipOutputStream.STORED);
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Package.java b/src/share/classes/com/sun/java/util/jar/pack/Package.java
index 2a75f74..2abe545 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Package.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Package.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -188,7 +188,7 @@
}
public final
- class Class extends Attribute.Holder implements Comparable {
+ class Class extends Attribute.Holder implements Comparable<Class> {
public Package getPackage() { return Package.this; }
// Optional file characteristics and data source (a "class stub")
@@ -247,8 +247,7 @@
}
// Note: equals and hashCode are identity-based.
- public int compareTo(Object o) {
- Class that = (Class)o;
+ public int compareTo(Class that) {
String n0 = this.getName();
String n1 = that.getName();
return n0.compareTo(n1);
@@ -488,7 +487,7 @@
}
public abstract
- class Member extends Attribute.Holder implements Comparable {
+ class Member extends Attribute.Holder implements Comparable<Member> {
DescriptorEntry descriptor;
protected Member(int flags, DescriptorEntry descriptor) {
@@ -549,7 +548,7 @@
return descriptor.getLiteralTag();
}
- public int compareTo(Object o) {
+ public int compareTo(Member o) {
Field that = (Field)o;
return this.order - that.order;
}
@@ -582,7 +581,7 @@
}
// Sort methods in a canonical order (by type, then by name).
- public int compareTo(Object o) {
+ public int compareTo(Member o) {
Method that = (Method)o;
return this.getDescriptor().compareTo(that.getDescriptor());
}
@@ -608,11 +607,10 @@
public void trimToSize() {
super.trimToSize();
for (int isM = 0; isM <= 1; isM++) {
- ArrayList members = (isM == 0) ? fields : methods;
+ ArrayList<? extends Member> members = (isM == 0) ? fields : methods;
if (members == null) continue;
members.trimToSize();
- for (Iterator i = members.iterator(); i.hasNext(); ) {
- Member m = (Member)i.next();
+ for (Member m : members) {
m.trimToSize();
}
}
@@ -625,10 +623,9 @@
if ("InnerClass".equals(attrName))
innerClasses = null;
for (int isM = 0; isM <= 1; isM++) {
- ArrayList members = (isM == 0) ? fields : methods;
+ ArrayList<? extends Member> members = (isM == 0) ? fields : methods;
if (members == null) continue;
- for (Iterator i = members.iterator(); i.hasNext(); ) {
- Member m = (Member)i.next();
+ for (Member m : members) {
m.strip(attrName);
}
}
@@ -641,10 +638,9 @@
refs.add(superClass);
refs.addAll(Arrays.asList(interfaces));
for (int isM = 0; isM <= 1; isM++) {
- ArrayList members = (isM == 0) ? fields : methods;
+ ArrayList<? extends Member> members = (isM == 0) ? fields : methods;
if (members == null) continue;
- for (Iterator i = members.iterator(); i.hasNext(); ) {
- Member m = (Member)i.next();
+ for (Member m : members) {
boolean ok = false;
try {
m.visitRefs(mode, refs);
@@ -747,13 +743,13 @@
return classStubs;
}
- public final class File implements Comparable {
+ public final class File implements Comparable<File> {
String nameString; // true name of this file
Utf8Entry name;
int modtime = NO_MODTIME;
int options = 0; // random flag bits, such as deflate_hint
Class stubClass; // if this is a stub, here's the class
- ArrayList prepend = new ArrayList(); // list of byte[]
+ ArrayList<byte[]> prepend = new ArrayList<>(); // list of byte[]
java.io.ByteArrayOutputStream append = new ByteArrayOutputStream();
File(Utf8Entry name) {
@@ -798,8 +794,7 @@
return nameString.hashCode();
}
// Simple alphabetic sort. PackageWriter uses a better comparator.
- public int compareTo(Object o) {
- File that = (File)o;
+ public int compareTo(File that) {
return this.nameString.compareTo(that.nameString);
}
public String toString() {
@@ -834,8 +829,7 @@
public long getFileLength() {
long len = 0;
if (prepend == null || append == null) return 0;
- for (Iterator i = prepend.iterator(); i.hasNext(); ) {
- byte[] block = (byte[]) i.next();
+ for (byte[] block : prepend) {
len += block.length;
}
len += append.size();
@@ -843,8 +837,7 @@
}
public void writeTo(OutputStream out) throws IOException {
if (prepend == null || append == null) return;
- for (Iterator i = prepend.iterator(); i.hasNext(); ) {
- byte[] block = (byte[]) i.next();
+ for (byte[] block : prepend) {
out.write(block);
}
append.writeTo(out);
@@ -860,8 +853,7 @@
InputStream in = new ByteArrayInputStream(append.toByteArray());
if (prepend.isEmpty()) return in;
List<InputStream> isa = new ArrayList<>(prepend.size()+1);
- for (Iterator i = prepend.iterator(); i.hasNext(); ) {
- byte[] bytes = (byte[]) i.next();
+ for (byte[] bytes : prepend) {
isa.add(new ByteArrayInputStream(bytes));
}
isa.add(in);
@@ -926,7 +918,7 @@
}
static
- class InnerClass implements Comparable {
+ class InnerClass implements Comparable<InnerClass> {
final ClassEntry thisClass;
final ClassEntry outerClass;
final Utf8Entry name;
@@ -977,8 +969,7 @@
public int hashCode() {
return thisClass.hashCode();
}
- public int compareTo(Object o) {
- InnerClass that = (InnerClass)o;
+ public int compareTo(InnerClass that) {
return this.thisClass.compareTo(that.thisClass);
}
@@ -1108,7 +1099,7 @@
return ConstantPool.getUtf8Entry(s);
}
- static LiteralEntry getRefLiteral(Comparable s) {
+ static LiteralEntry getRefLiteral(Comparable<?> s) {
return ConstantPool.getLiteralEntry(s);
}
@@ -1199,7 +1190,6 @@
// compress better. It also moves classes to the end of the
// file order. It also removes JAR directory entries, which
// are useless.
- @SuppressWarnings("unchecked")
void reorderFiles(boolean keepClassOrder, boolean stripDirectories) {
// First reorder the classes, if that is allowed.
if (!keepClassOrder) {
@@ -1226,10 +1216,8 @@
// This keeps files of similar format near each other.
// Put class files at the end, keeping their fixed order.
// Be sure the JAR file's required manifest stays at the front. (4893051)
- Collections.sort(files, new Comparator() {
- public int compare(Object o0, Object o1) {
- File r0 = (File) o0;
- File r1 = (File) o1;
+ Collections.sort(files, new Comparator<File>() {
+ public int compare(File r0, File r1) {
// Get the file name.
String f0 = r0.nameString;
String f1 = r1.nameString;
diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
index be9b485..a6886b4 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java
@@ -750,7 +750,7 @@
file_options.readFrom(in);
file_bits.setInputStreamFrom(in);
- Iterator nextClass = pkg.getClasses().iterator();
+ Iterator<Class> nextClass = pkg.getClasses().iterator();
// Compute file lengths before reading any file bits.
long totalFileLength = 0;
@@ -790,14 +790,14 @@
pkg.addFile(file);
if (file.isClassStub()) {
assert(file.getFileLength() == 0);
- Class cls = (Class) nextClass.next();
+ Class cls = nextClass.next();
cls.initFile(file);
}
}
// Do the rest of the classes.
while (nextClass.hasNext()) {
- Class cls = (Class) nextClass.next();
+ Class cls = nextClass.next();
cls.initFile(null); // implicitly initialize to a trivial one
cls.file.modtime = pkg.default_modtime;
}
@@ -1006,14 +1006,14 @@
if (k >= 0)
return k;
if (e.tag == CONSTANT_Utf8) {
- Entry se = (Entry) utf8Signatures.get(e);
+ Entry se = utf8Signatures.get(e);
return pkg.cp.untypedIndexOf(se);
}
return -1;
}
Comparator<Entry> entryOutputOrder = new Comparator<Entry>() {
- public int compare(Entry e0, Entry e1) {
+ public int compare(Entry e0, Entry e1) {
int k0 = getOutputIndex(e0);
int k1 = getOutputIndex(e1);
if (k0 >= 0 && k1 >= 0)
@@ -1332,7 +1332,8 @@
// classes, fields, methods, and codes.
// The holders is a global list, already collected,
// of attribute "customers".
- void countAndReadAttrs(int ctype, Collection holders) throws IOException {
+ void countAndReadAttrs(int ctype, Collection<? extends Attribute.Holder> holders)
+ throws IOException {
// class_attr_bands:
// *class_flags :UNSIGNED5
// *class_attr_count :UNSIGNED5
@@ -1386,7 +1387,8 @@
// Read flags and count the attributes that are to be placed
// on the given holders.
- void countAttrs(int ctype, Collection holders) throws IOException {
+ void countAttrs(int ctype, Collection<? extends Attribute.Holder> holders)
+ throws IOException {
// Here, xxx stands for one of class, field, method, code.
MultiBand xxx_attr_bands = attrBands[ctype];
long flagMask = attrFlagMask[ctype];
@@ -1414,8 +1416,7 @@
xxx_flags_lo.expectLength(holders.size());
xxx_flags_lo.readFrom(in);
assert((flagMask & overflowMask) == overflowMask);
- for (Iterator i = holders.iterator(); i.hasNext(); ) {
- Attribute.Holder h = (Attribute.Holder) i.next();
+ for (Attribute.Holder h : holders) {
int flags = xxx_flags_lo.getInt();
h.flags = flags;
if ((flags & overflowMask) != 0)
@@ -1433,8 +1434,7 @@
// (class/field/method/code), and also we accumulate (b) a total
// count for each attribute type.
int[] totalCounts = new int[defs.length];
- for (Iterator i = holders.iterator(); i.hasNext(); ) {
- Attribute.Holder h = (Attribute.Holder) i.next();
+ for (Attribute.Holder h : holders) {
assert(h.attributes == null);
// System.out.println("flags="+h.flags+" using fm="+flagMask);
long attrBits = ((h.flags & flagMask) << 32) >>> 32;
@@ -1582,13 +1582,12 @@
ATTR_CONTEXT_NAME[ctype]+" attribute");
}
- @SuppressWarnings("unchecked")
- void readAttrs(int ctype, Collection holders) throws IOException {
+ void readAttrs(int ctype, Collection<? extends Attribute.Holder> holders)
+ throws IOException {
// Decode band values into attributes.
Set<Attribute.Layout> sawDefs = new HashSet<>();
ByteArrayOutputStream buf = new ByteArrayOutputStream();
- for (Iterator i = holders.iterator(); i.hasNext(); ) {
- final Attribute.Holder h = (Attribute.Holder) i.next();
+ for (final Attribute.Holder h : holders) {
if (h.attributes == null) continue;
for (ListIterator<Attribute> j = h.attributes.listIterator(); j.hasNext(); ) {
Attribute a = j.next();
diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
index e2bad89..16824ad 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java
@@ -720,7 +720,6 @@
Utils.log.info("Wrote "+numFiles+" resource files");
}
- @SuppressWarnings("unchecked")
void collectAttributeLayouts() {
maxFlags = new int[ATTR_CONTEXT_LIMIT];
allLayouts = new FixedList<>(ATTR_CONTEXT_LIMIT);
@@ -781,26 +780,27 @@
avHiBits &= (1L<<attrIndexLimit[i])-1;
int nextLoBit = 0;
Map<Attribute.Layout, int[]> defMap = allLayouts.get(i);
- Map.Entry[] layoutsAndCounts = new Map.Entry[defMap.size()];
+ @SuppressWarnings("unchecked")
+ Map.Entry<Attribute.Layout, int[]>[] layoutsAndCounts =
+ new Map.Entry<>[defMap.size()];
defMap.entrySet().toArray(layoutsAndCounts);
// Sort by count, most frequent first.
// Predefs. participate in this sort, though it does not matter.
- Arrays.sort(layoutsAndCounts, new Comparator<Object>() {
- public int compare(Object o0, Object o1) {
- Map.Entry e0 = (Map.Entry) o0;
- Map.Entry e1 = (Map.Entry) o1;
+ Arrays.sort(layoutsAndCounts,
+ new Comparator<Map.Entry<Attribute.Layout, int[]>>() {
+ public int compare(Map.Entry<Attribute.Layout, int[]> e0,
+ Map.Entry<Attribute.Layout, int[]> e1) {
// Primary sort key is count, reversed.
- int r = - ( ((int[])e0.getValue())[0]
- - ((int[])e1.getValue())[0] );
+ int r = -(e0.getValue()[0] - e1.getValue()[0]);
if (r != 0) return r;
- return ((Comparable)e0.getKey()).compareTo(e1.getKey());
+ return e0.getKey().compareTo(e1.getKey());
}
});
attrCounts[i] = new int[attrIndexLimit[i]+layoutsAndCounts.length];
for (int j = 0; j < layoutsAndCounts.length; j++) {
- Map.Entry e = layoutsAndCounts[j];
- Attribute.Layout def = (Attribute.Layout) e.getKey();
- int count = ((int[])e.getValue())[0];
+ Map.Entry<Attribute.Layout, int[]> e = layoutsAndCounts[j];
+ Attribute.Layout def = e.getKey();
+ int count = e.getValue()[0];
int index;
Integer predefIndex = attrIndexTable.get(def);
if (predefIndex != null) {
@@ -881,7 +881,6 @@
Attribute.Layout[] attrDefsWritten;
- @SuppressWarnings("unchecked")
void writeAttrDefs() throws IOException {
List<Object[]> defList = new ArrayList<>();
for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
@@ -906,20 +905,19 @@
int numAttrDefs = defList.size();
Object[][] defs = new Object[numAttrDefs][];
defList.toArray(defs);
- Arrays.sort(defs, new Comparator() {
- public int compare(Object o0, Object o1) {
- Object[] a0 = (Object[]) o0;
- Object[] a1 = (Object[]) o1;
+ Arrays.sort(defs, new Comparator<Object[]>() {
+ public int compare(Object[] a0, Object[] a1) {
// Primary sort key is attr def header.
+ @SuppressWarnings("unchecked")
int r = ((Comparable)a0[0]).compareTo(a1[0]);
if (r != 0) return r;
- Object ind0 = attrIndexTable.get(a0[1]);
- Object ind1 = attrIndexTable.get(a1[1]);
+ Integer ind0 = attrIndexTable.get(a0[1]);
+ Integer ind1 = attrIndexTable.get(a1[1]);
// Secondary sort key is attribute index.
// (This must be so, in order to keep overflow attr order.)
assert(ind0 != null);
assert(ind1 != null);
- return ((Comparable)ind0).compareTo(ind1);
+ return ind0.compareTo(ind1);
}
});
attrDefsWritten = new Attribute.Layout[numAttrDefs];
diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java b/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java
index aefac52..93b743b 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -69,8 +69,7 @@
* Get the set of options for the pack and unpack engines.
* @return A sorted association of option key strings to option values.
*/
- @SuppressWarnings("unchecked")
- public SortedMap properties() {
+ public SortedMap<String, String> properties() {
return props;
}
@@ -157,7 +156,6 @@
// All the worker bees.....
// The packer worker.
- @SuppressWarnings("unchecked")
private class DoPack {
final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
@@ -199,9 +197,8 @@
};
for (int i = 0; i < ctypes.length; i++) {
String pfx = keys[i];
- Map<Object, Object> map = props.prefixMap(pfx);
- for (Object k : map.keySet()) {
- String key = (String)k;
+ Map<String, String> map = props.prefixMap(pfx);
+ for (String key : map.keySet()) {
assert(key.startsWith(pfx));
String name = key.substring(pfx.length());
String layout = props.getProperty(key);
diff --git a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
index f1877c3..07887b9 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java
@@ -27,7 +27,6 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
-import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
@@ -47,8 +46,8 @@
* Control block for publishing Pack200 options to the other classes.
*/
-final class PropMap implements SortedMap<Object, Object> {
- private final TreeMap<Object, Object> theMap = new TreeMap<>();;
+final class PropMap implements SortedMap<String, String> {
+ private final TreeMap<String, String> theMap = new TreeMap<>();;
private final List<PropertyChangeListener> listenerList = new ArrayList<>(1);
void addListener(PropertyChangeListener listener) {
@@ -68,12 +67,12 @@
}
// Override:
- public Object put(Object key, Object value) {
- Object oldValue = theMap.put(key, value);
+ public String put(String key, String value) {
+ String oldValue = theMap.put(key, value);
if (value != oldValue && !listenerList.isEmpty()) {
// Post the property change event.
PropertyChangeEvent event =
- new PropertyChangeEvent(this, (String) key,
+ new PropertyChangeEvent(this, key,
oldValue, value);
for (PropertyChangeListener listener : listenerList) {
listener.propertyChange(event);
@@ -85,7 +84,7 @@
// All this other stuff is private to the current package.
// Outide clients of Pack200 do not need to use it; they can
// get by with generic SortedMap functionality.
- private static Map<Object, Object> defaultProps;
+ private static Map<String, String> defaultProps;
static {
Properties props = new Properties();
@@ -141,7 +140,9 @@
}
}
- defaultProps = (new HashMap<>(props)); // shrink to fit
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ HashMap<String, String> temp = new HashMap(props); // shrink to fit
+ defaultProps = temp;
}
PropMap() {
@@ -151,7 +152,7 @@
// Return a view of this map which includes only properties
// that begin with the given prefix. This is easy because
// the map is sorted, and has a subMap accessor.
- SortedMap<Object, Object> prefixMap(String prefix) {
+ SortedMap<String, String> prefixMap(String prefix) {
int len = prefix.length();
if (len == 0)
return this;
@@ -162,7 +163,7 @@
}
String getProperty(String s) {
- return (String) get(s);
+ return get(s);
}
String getProperty(String s, String defaultVal) {
String val = getProperty(s);
@@ -171,13 +172,13 @@
return val;
}
String setProperty(String s, String val) {
- return (String) put(s, val);
+ return put(s, val);
}
// Get sequence of props for "prefix", and "prefix.*".
- List getProperties(String prefix) {
- Collection<Object> values = prefixMap(prefix).values();
- List<Object> res = new ArrayList<>(values.size());
+ List<String> getProperties(String prefix) {
+ Collection<String> values = prefixMap(prefix).values();
+ List<String> res = new ArrayList<>(values.size());
res.addAll(values);
while (res.remove(null));
return res;
@@ -241,8 +242,8 @@
}
void list(PrintWriter out) {
out.println("#"+Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT+"[");
- Set defaults = defaultProps.entrySet();
- for (Map.Entry e : theMap.entrySet()) {
+ Set<Map.Entry<String, String>> defaults = defaultProps.entrySet();
+ for (Map.Entry<String, String> e : theMap.entrySet()) {
if (defaults.contains(e)) continue;
out.println(" " + e.getKey() + " = " + e.getValue());
}
@@ -270,18 +271,17 @@
}
@Override
- public Object get(Object key) {
+ public String get(Object key) {
return theMap.get(key);
}
@Override
- public Object remove(Object key) {
+ public String remove(Object key) {
return theMap.remove(key);
}
@Override
- @SuppressWarnings("unchecked")
- public void putAll(Map m) {
+ public void putAll(Map<? extends String, ? extends String> m) {
theMap.putAll(m);
}
@@ -291,48 +291,47 @@
}
@Override
- public Set<Object> keySet() {
+ public Set<String> keySet() {
return theMap.keySet();
}
@Override
- public Collection<Object> values() {
+ public Collection<String> values() {
return theMap.values();
}
@Override
- public Set<Map.Entry<Object, Object>> entrySet() {
+ public Set<Map.Entry<String, String>> entrySet() {
return theMap.entrySet();
}
@Override
- @SuppressWarnings("unchecked")
- public Comparator<Object> comparator() {
- return (Comparator<Object>) theMap.comparator();
+ public Comparator<? super String> comparator() {
+ return theMap.comparator();
}
@Override
- public SortedMap<Object, Object> subMap(Object fromKey, Object toKey) {
+ public SortedMap<String, String> subMap(String fromKey, String toKey) {
return theMap.subMap(fromKey, toKey);
}
@Override
- public SortedMap<Object, Object> headMap(Object toKey) {
+ public SortedMap<String, String> headMap(String toKey) {
return theMap.headMap(toKey);
}
@Override
- public SortedMap<Object, Object> tailMap(Object fromKey) {
+ public SortedMap<String, String> tailMap(String fromKey) {
return theMap.tailMap(fromKey);
}
@Override
- public Object firstKey() {
+ public String firstKey() {
return theMap.firstKey();
}
@Override
- public Object lastKey() {
+ public String lastKey() {
return theMap.lastKey();
}
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/TLGlobals.java b/src/share/classes/com/sun/java/util/jar/pack/TLGlobals.java
index 0e40bde..fc9d099 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/TLGlobals.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/TLGlobals.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 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
@@ -67,7 +67,7 @@
props = new PropMap();
}
- SortedMap<Object, Object> getPropMap() {
+ SortedMap<String, String> getPropMap() {
return props;
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java b/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
index c14faec..5727d32 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java
@@ -81,8 +81,7 @@
* Get the set of options for the pack and unpack engines.
* @return A sorted association of option key strings to option values.
*/
- @SuppressWarnings("unchecked")
- public SortedMap properties() {
+ public SortedMap<String, String> properties() {
return props;
}
diff --git a/src/share/classes/com/sun/java/util/jar/pack/Utils.java b/src/share/classes/com/sun/java/util/jar/pack/Utils.java
index 00a043f..f9d26eb 100644
--- a/src/share/classes/com/sun/java/util/jar/pack/Utils.java
+++ b/src/share/classes/com/sun/java/util/jar/pack/Utils.java
@@ -253,8 +253,8 @@
}
static void copyJarFile(JarFile in, JarOutputStream out) throws IOException {
byte[] buffer = new byte[1 << 14];
- for (Enumeration e = in.entries(); e.hasMoreElements(); ) {
- JarEntry je = (JarEntry) e.nextElement();
+ for (Enumeration<JarEntry> e = in.entries(); e.hasMoreElements(); ) {
+ JarEntry je = e.nextElement();
out.putNextEntry(je);
InputStream ein = in.getInputStream(je);
for (int nr; 0 < (nr = ein.read(buffer)); ) {
diff --git a/src/share/classes/com/sun/jndi/ldap/Filter.java b/src/share/classes/com/sun/jndi/ldap/Filter.java
index 467b8db..0eb1caa 100644
--- a/src/share/classes/com/sun/jndi/ldap/Filter.java
+++ b/src/share/classes/com/sun/jndi/ldap/Filter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -632,15 +632,17 @@
}
}
+ // The complex filter types look like:
+ // "&(type=val)(type=val)"
+ // "|(type=val)(type=val)"
+ // "!(type=val)"
+ //
+ // The filtOffset[0] pointing to the '&', '|', or '!'.
+ //
private static void encodeComplexFilter(BerEncoder ber, byte[] filter,
int filterType, int filtOffset[], int filtEnd)
throws IOException, NamingException {
- //
- // We have a complex filter of type "&(type=val)(type=val)"
- // with filtOffset[0] pointing to the &
- //
-
if (dbg) {
dprint("encComplexFilter: ", filter, filtOffset[0], filtEnd);
dprint(", type: " + Integer.toString(filterType, 16));
@@ -652,7 +654,7 @@
ber.beginSeq(filterType);
int[] parens = findRightParen(filter, filtOffset, filtEnd);
- encodeFilterList(ber, filter, parens[0], parens[1]);
+ encodeFilterList(ber, filter, filterType, parens[0], parens[1]);
ber.endSeq();
@@ -706,7 +708,7 @@
// Encode filter list of type "(filter1)(filter2)..."
//
private static void encodeFilterList(BerEncoder ber, byte[] filter,
- int start, int end) throws IOException, NamingException {
+ int filterType, int start, int end) throws IOException, NamingException {
if (dbg) {
dprint("encFilterList: ", filter, start, end);
@@ -714,12 +716,16 @@
}
int filtOffset[] = new int[1];
-
- for (filtOffset[0] = start; filtOffset[0] < end;
- filtOffset[0]++) {
+ int listNumber = 0;
+ for (filtOffset[0] = start; filtOffset[0] < end; filtOffset[0]++) {
if (Character.isSpaceChar((char)filter[filtOffset[0]]))
continue;
+ if ((filterType == LDAP_FILTER_NOT) && (listNumber > 0)) {
+ throw new InvalidSearchFilterException(
+ "Filter (!) cannot be followed by more than one filters");
+ }
+
if (filter[filtOffset[0]] == '(') {
continue;
}
@@ -733,6 +739,8 @@
newfilter[0] = (byte)'(';
newfilter[len+1] = (byte)')';
encodeFilter(ber, newfilter, 0, newfilter.length);
+
+ listNumber++;
}
if (dbg) {
diff --git a/src/share/classes/java/lang/Math.java b/src/share/classes/java/lang/Math.java
index 5d1be0c..177d710 100644
--- a/src/share/classes/java/lang/Math.java
+++ b/src/share/classes/java/lang/Math.java
@@ -50,34 +50,34 @@
*
* <p>The quality of implementation specifications concern two
* properties, accuracy of the returned result and monotonicity of the
- * method. Accuracy of the floating-point {@code Math} methods
- * is measured in terms of <i>ulps</i>, units in the last place. For
- * a given floating-point format, an ulp of a specific real number
- * value is the distance between the two floating-point values
- * bracketing that numerical value. When discussing the accuracy of a
- * method as a whole rather than at a specific argument, the number of
- * ulps cited is for the worst-case error at any argument. If a
- * method always has an error less than 0.5 ulps, the method always
- * returns the floating-point number nearest the exact result; such a
- * method is <i>correctly rounded</i>. A correctly rounded method is
- * generally the best a floating-point approximation can be; however,
- * it is impractical for many floating-point methods to be correctly
- * rounded. Instead, for the {@code Math} class, a larger error
- * bound of 1 or 2 ulps is allowed for certain methods. Informally,
- * with a 1 ulp error bound, when the exact result is a representable
- * number, the exact result should be returned as the computed result;
- * otherwise, either of the two floating-point values which bracket
- * the exact result may be returned. For exact results large in
- * magnitude, one of the endpoints of the bracket may be infinite.
- * Besides accuracy at individual arguments, maintaining proper
- * relations between the method at different arguments is also
- * important. Therefore, most methods with more than 0.5 ulp errors
- * are required to be <i>semi-monotonic</i>: whenever the mathematical
- * function is non-decreasing, so is the floating-point approximation,
- * likewise, whenever the mathematical function is non-increasing, so
- * is the floating-point approximation. Not all approximations that
- * have 1 ulp accuracy will automatically meet the monotonicity
- * requirements.
+ * method. Accuracy of the floating-point {@code Math} methods is
+ * measured in terms of <i>ulps</i>, units in the last place. For a
+ * given floating-point format, an {@linkplain #ulp(double) ulp} of a
+ * specific real number value is the distance between the two
+ * floating-point values bracketing that numerical value. When
+ * discussing the accuracy of a method as a whole rather than at a
+ * specific argument, the number of ulps cited is for the worst-case
+ * error at any argument. If a method always has an error less than
+ * 0.5 ulps, the method always returns the floating-point number
+ * nearest the exact result; such a method is <i>correctly
+ * rounded</i>. A correctly rounded method is generally the best a
+ * floating-point approximation can be; however, it is impractical for
+ * many floating-point methods to be correctly rounded. Instead, for
+ * the {@code Math} class, a larger error bound of 1 or 2 ulps is
+ * allowed for certain methods. Informally, with a 1 ulp error bound,
+ * when the exact result is a representable number, the exact result
+ * should be returned as the computed result; otherwise, either of the
+ * two floating-point values which bracket the exact result may be
+ * returned. For exact results large in magnitude, one of the
+ * endpoints of the bracket may be infinite. Besides accuracy at
+ * individual arguments, maintaining proper relations between the
+ * method at different arguments is also important. Therefore, most
+ * methods with more than 0.5 ulp errors are required to be
+ * <i>semi-monotonic</i>: whenever the mathematical function is
+ * non-decreasing, so is the floating-point approximation, likewise,
+ * whenever the mathematical function is non-increasing, so is the
+ * floating-point approximation. Not all approximations that have 1
+ * ulp accuracy will automatically meet the monotonicity requirements.
*
* @author unascribed
* @author Joseph D. Darcy
@@ -940,11 +940,11 @@
}
/**
- * Returns the size of an ulp of the argument. An ulp of a
- * {@code double} value is the positive distance between this
- * floating-point value and the {@code double} value next
- * larger in magnitude. Note that for non-NaN <i>x</i>,
- * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
+ * Returns the size of an ulp of the argument. An ulp, unit in
+ * the last place, of a {@code double} value is the positive
+ * distance between this floating-point value and the {@code
+ * double} value next larger in magnitude. Note that for non-NaN
+ * <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
*
* <p>Special Cases:
* <ul>
@@ -967,11 +967,11 @@
}
/**
- * Returns the size of an ulp of the argument. An ulp of a
- * {@code float} value is the positive distance between this
- * floating-point value and the {@code float} value next
- * larger in magnitude. Note that for non-NaN <i>x</i>,
- * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
+ * Returns the size of an ulp of the argument. An ulp, unit in
+ * the last place, of a {@code float} value is the positive
+ * distance between this floating-point value and the {@code
+ * float} value next larger in magnitude. Note that for non-NaN
+ * <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
*
* <p>Special Cases:
* <ul>
diff --git a/src/share/classes/java/lang/StrictMath.java b/src/share/classes/java/lang/StrictMath.java
index b829a81..42c701f 100644
--- a/src/share/classes/java/lang/StrictMath.java
+++ b/src/share/classes/java/lang/StrictMath.java
@@ -932,11 +932,11 @@
}
/**
- * Returns the size of an ulp of the argument. An ulp of a
- * {@code double} value is the positive distance between this
- * floating-point value and the {@code double} value next
- * larger in magnitude. Note that for non-NaN <i>x</i>,
- * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
+ * Returns the size of an ulp of the argument. An ulp, unit in
+ * the last place, of a {@code double} value is the positive
+ * distance between this floating-point value and the {@code
+ * double} value next larger in magnitude. Note that for non-NaN
+ * <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
*
* <p>Special Cases:
* <ul>
@@ -959,11 +959,11 @@
}
/**
- * Returns the size of an ulp of the argument. An ulp of a
- * {@code float} value is the positive distance between this
- * floating-point value and the {@code float} value next
- * larger in magnitude. Note that for non-NaN <i>x</i>,
- * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
+ * Returns the size of an ulp of the argument. An ulp, unit in
+ * the last place, of a {@code float} value is the positive
+ * distance between this floating-point value and the {@code
+ * float} value next larger in magnitude. Note that for non-NaN
+ * <i>x</i>, <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
*
* <p>Special Cases:
* <ul>
diff --git a/src/share/classes/java/lang/reflect/Constructor.java b/src/share/classes/java/lang/reflect/Constructor.java
index 8ff6d41..ba4231c 100644
--- a/src/share/classes/java/lang/reflect/Constructor.java
+++ b/src/share/classes/java/lang/reflect/Constructor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -27,13 +27,12 @@
import sun.reflect.ConstructorAccessor;
import sun.reflect.Reflection;
+import sun.reflect.annotation.AnnotationParser;
import sun.reflect.generics.repository.ConstructorRepository;
import sun.reflect.generics.factory.CoreReflectionFactory;
import sun.reflect.generics.factory.GenericsFactory;
import sun.reflect.generics.scope.ConstructorScope;
import java.lang.annotation.Annotation;
-import java.util.Map;
-import sun.reflect.annotation.AnnotationParser;
import java.lang.annotation.AnnotationFormatError;
import java.lang.reflect.Modifier;
@@ -57,11 +56,7 @@
* @author Kenneth Russell
* @author Nakul Saraiya
*/
-public final
- class Constructor<T> extends AccessibleObject implements
- GenericDeclaration,
- Member {
-
+public final class Constructor<T> extends Executable {
private Class<T> clazz;
private int slot;
private Class<?>[] parameterTypes;
@@ -82,7 +77,8 @@
}
// Accessor for generic info repository
- private ConstructorRepository getGenericInfo() {
+ @Override
+ ConstructorRepository getGenericInfo() {
// lazily initialize repository if necessary
if (genericInfo == null) {
// create and cache generic info repository
@@ -111,8 +107,7 @@
int slot,
String signature,
byte[] annotations,
- byte[] parameterAnnotations)
- {
+ byte[] parameterAnnotations) {
this.clazz = declaringClass;
this.parameterTypes = parameterTypes;
this.exceptionTypes = checkedExceptions;
@@ -137,21 +132,31 @@
// objects be fabricated for each reflective call on Class
// objects.)
Constructor<T> res = new Constructor<>(clazz,
- parameterTypes,
- exceptionTypes, modifiers, slot,
- signature,
- annotations,
- parameterAnnotations);
+ parameterTypes,
+ exceptionTypes, modifiers, slot,
+ signature,
+ annotations,
+ parameterAnnotations);
res.root = this;
// Might as well eagerly propagate this if already present
res.constructorAccessor = constructorAccessor;
return res;
}
+ @Override
+ boolean hasGenericInformation() {
+ return (getSignature() != null);
+ }
+
+ @Override
+ byte[] getAnnotationBytes() {
+ return annotations;
+ }
+
/**
- * Returns the {@code Class} object representing the class that declares
- * the constructor represented by this {@code Constructor} object.
+ * {@inheritDoc}
*/
+ @Override
public Class<T> getDeclaringClass() {
return clazz;
}
@@ -160,36 +165,25 @@
* Returns the name of this constructor, as a string. This is
* the binary name of the constructor's declaring class.
*/
+ @Override
public String getName() {
return getDeclaringClass().getName();
}
/**
- * Returns the Java language modifiers for the constructor
- * represented by this {@code Constructor} object, as an integer. The
- * {@code Modifier} class should be used to decode the modifiers.
- *
- * @see Modifier
+ * {@inheritDoc}
*/
+ @Override
public int getModifiers() {
return modifiers;
}
/**
- * Returns an array of {@code TypeVariable} objects that represent the
- * type variables declared by the generic declaration represented by this
- * {@code GenericDeclaration} object, in declaration order. Returns an
- * array of length 0 if the underlying generic declaration declares no type
- * variables.
- *
- * @return an array of {@code TypeVariable} objects that represent
- * the type variables declared by this generic declaration
- * @throws GenericSignatureFormatError if the generic
- * signature of this generic declaration does not conform to
- * the format specified in
- * <cite>The Java™ Virtual Machine Specification</cite>
+ * {@inheritDoc}
+ * @throws GenericSignatureFormatError {@inheritDoc}
* @since 1.5
*/
+ @Override
public TypeVariable<Constructor<T>>[] getTypeParameters() {
if (getSignature() != null) {
return (TypeVariable<Constructor<T>>[])getGenericInfo().getTypeParameters();
@@ -199,98 +193,45 @@
/**
- * Returns an array of {@code Class} objects that represent the formal
- * parameter types, in declaration order, of the constructor
- * represented by this {@code Constructor} object. Returns an array of
- * length 0 if the underlying constructor takes no parameters.
- *
- * @return the parameter types for the constructor this object
- * represents
+ * {@inheritDoc}
*/
+ @Override
public Class<?>[] getParameterTypes() {
return (Class<?>[]) parameterTypes.clone();
}
-
/**
- * Returns an array of {@code Type} objects that represent the formal
- * parameter types, in declaration order, of the method represented by
- * this {@code Constructor} object. Returns an array of length 0 if the
- * underlying method takes no parameters.
- *
- * <p>If a formal parameter type is a parameterized type,
- * the {@code Type} object returned for it must accurately reflect
- * the actual type parameters used in the source code.
- *
- * <p>If a formal parameter type is a type variable or a parameterized
- * type, it is created. Otherwise, it is resolved.
- *
- * @return an array of {@code Type}s that represent the formal
- * parameter types of the underlying method, in declaration order
- * @throws GenericSignatureFormatError
- * if the generic method signature does not conform to the format
- * specified in
- * <cite>The Java™ Virtual Machine Specification</cite>
- * @throws TypeNotPresentException if any of the parameter
- * types of the underlying method refers to a non-existent type
- * declaration
- * @throws MalformedParameterizedTypeException if any of
- * the underlying method's parameter types refer to a parameterized
- * type that cannot be instantiated for any reason
+ * {@inheritDoc}
+ * @throws GenericSignatureFormatError {@inheritDoc}
+ * @throws TypeNotPresentException {@inheritDoc}
+ * @throws MalformedParameterizedTypeException {@inheritDoc}
* @since 1.5
*/
+ @Override
public Type[] getGenericParameterTypes() {
- if (getSignature() != null)
- return getGenericInfo().getParameterTypes();
- else
- return getParameterTypes();
+ return super.getGenericParameterTypes();
}
-
/**
- * Returns an array of {@code Class} objects that represent the types
- * of exceptions declared to be thrown by the underlying constructor
- * represented by this {@code Constructor} object. Returns an array of
- * length 0 if the constructor declares no exceptions in its {@code throws} clause.
- *
- * @return the exception types declared as being thrown by the
- * constructor this object represents
+ * {@inheritDoc}
*/
+ @Override
public Class<?>[] getExceptionTypes() {
return (Class<?>[])exceptionTypes.clone();
}
/**
- * Returns an array of {@code Type} objects that represent the
- * exceptions declared to be thrown by this {@code Constructor} object.
- * Returns an array of length 0 if the underlying method declares
- * no exceptions in its {@code throws} clause.
- *
- * <p>If an exception type is a type variable or a parameterized
- * type, it is created. Otherwise, it is resolved.
- *
- * @return an array of Types that represent the exception types
- * thrown by the underlying method
- * @throws GenericSignatureFormatError
- * if the generic method signature does not conform to the format
- * specified in
- * <cite>The Java™ Virtual Machine Specification</cite>
- * @throws TypeNotPresentException if the underlying method's
- * {@code throws} clause refers to a non-existent type declaration
- * @throws MalformedParameterizedTypeException if
- * the underlying method's {@code throws} clause refers to a
- * parameterized type that cannot be instantiated for any reason
+ * {@inheritDoc}
+ * @throws GenericSignatureFormatError {@inheritDoc}
+ * @throws TypeNotPresentException {@inheritDoc}
+ * @throws MalformedParameterizedTypeException {@inheritDoc}
* @since 1.5
*/
- public Type[] getGenericExceptionTypes() {
- Type[] result;
- if (getSignature() != null &&
- ( (result = getGenericInfo().getExceptionTypes()).length > 0 ))
- return result;
- else
- return getExceptionTypes();
- }
+ @Override
+ public Type[] getGenericExceptionTypes() {
+ return super.getGenericExceptionTypes();
+ }
/**
* Compares this {@code Constructor} against the specified object.
@@ -302,16 +243,7 @@
if (obj != null && obj instanceof Constructor) {
Constructor<?> other = (Constructor<?>)obj;
if (getDeclaringClass() == other.getDeclaringClass()) {
- /* Avoid unnecessary cloning */
- Class<?>[] params1 = parameterTypes;
- Class<?>[] params2 = other.parameterTypes;
- if (params1.length == params2.length) {
- for (int i = 0; i < params1.length; i++) {
- if (params1[i] != params2[i])
- return false;
- }
- return true;
- }
+ return equalParamTypes(parameterTypes, other.parameterTypes);
}
}
return false;
@@ -342,34 +274,14 @@
* constructor has default (package) access.
*/
public String toString() {
- try {
- StringBuffer sb = new StringBuffer();
- int mod = getModifiers() & Modifier.constructorModifiers();
- if (mod != 0) {
- sb.append(Modifier.toString(mod) + " ");
- }
- sb.append(Field.getTypeName(getDeclaringClass()));
- sb.append("(");
- Class<?>[] params = parameterTypes; // avoid clone
- for (int j = 0; j < params.length; j++) {
- sb.append(Field.getTypeName(params[j]));
- if (j < (params.length - 1))
- sb.append(",");
- }
- sb.append(")");
- Class<?>[] exceptions = exceptionTypes; // avoid clone
- if (exceptions.length > 0) {
- sb.append(" throws ");
- for (int k = 0; k < exceptions.length; k++) {
- sb.append(exceptions[k].getName());
- if (k < (exceptions.length - 1))
- sb.append(",");
- }
- }
- return sb.toString();
- } catch (Exception e) {
- return "<" + e + ">";
- }
+ return sharedToString(Modifier.constructorModifiers(),
+ parameterTypes,
+ exceptionTypes);
+ }
+
+ @Override
+ void specificToStringHeader(StringBuilder sb) {
+ sb.append(Field.getTypeName(getDeclaringClass()));
}
/**
@@ -405,56 +317,14 @@
*
* @since 1.5
*/
+ @Override
public String toGenericString() {
- try {
- StringBuilder sb = new StringBuilder();
- int mod = getModifiers() & Modifier.constructorModifiers();
- if (mod != 0) {
- sb.append(Modifier.toString(mod) + " ");
- }
- TypeVariable<?>[] typeparms = getTypeParameters();
- if (typeparms.length > 0) {
- boolean first = true;
- sb.append("<");
- for(TypeVariable<?> typeparm: typeparms) {
- if (!first)
- sb.append(",");
- // Class objects can't occur here; no need to test
- // and call Class.getName().
- sb.append(typeparm.toString());
- first = false;
- }
- sb.append("> ");
- }
- sb.append(Field.getTypeName(getDeclaringClass()));
- sb.append("(");
- Type[] params = getGenericParameterTypes();
- for (int j = 0; j < params.length; j++) {
- String param = (params[j] instanceof Class<?>)?
- Field.getTypeName((Class<?>)params[j]):
- (params[j].toString());
- if (isVarArgs() && (j == params.length - 1)) // replace T[] with T...
- param = param.replaceFirst("\\[\\]$", "...");
- sb.append(param);
- if (j < (params.length - 1))
- sb.append(",");
- }
- sb.append(")");
- Type[] exceptions = getGenericExceptionTypes();
- if (exceptions.length > 0) {
- sb.append(" throws ");
- for (int k = 0; k < exceptions.length; k++) {
- sb.append((exceptions[k] instanceof Class)?
- ((Class<?>)exceptions[k]).getName():
- exceptions[k].toString());
- if (k < (exceptions.length - 1))
- sb.append(",");
- }
- }
- return sb.toString();
- } catch (Exception e) {
- return "<" + e + ">";
- }
+ return sharedToGenericString(Modifier.constructorModifiers());
+ }
+
+ @Override
+ void specificToGenericStringHeader(StringBuilder sb) {
+ specificToStringHeader(sb);
}
/**
@@ -526,29 +396,21 @@
}
/**
- * Returns {@code true} if this constructor was declared to take
- * a variable number of arguments; returns {@code false}
- * otherwise.
- *
- * @return {@code true} if an only if this constructor was declared to
- * take a variable number of arguments.
+ * {@inheritDoc}
* @since 1.5
*/
+ @Override
public boolean isVarArgs() {
- return (getModifiers() & Modifier.VARARGS) != 0;
+ return super.isVarArgs();
}
/**
- * Returns {@code true} if this constructor is a synthetic
- * constructor; returns {@code false} otherwise.
- *
- * @return true if and only if this constructor is a synthetic
- * constructor as defined by
- * <cite>The Java™ Language Specification</cite>.
+ * {@inheritDoc}
* @since 1.5
*/
+ @Override
public boolean isSynthetic() {
- return Modifier.isSynthetic(getModifiers());
+ return super.isSynthetic();
}
// NOTE that there is no synchronization used here. It is correct
@@ -592,9 +454,9 @@
return slot;
}
- String getSignature() {
- return signature;
- }
+ String getSignature() {
+ return signature;
+ }
byte[] getRawAnnotations() {
return annotations;
@@ -604,80 +466,50 @@
return parameterAnnotations;
}
+
/**
- * @throws NullPointerException {@inheritDoc}
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
- if (annotationClass == null)
- throw new NullPointerException();
-
- return (T) declaredAnnotations().get(annotationClass);
+ return super.getAnnotation(annotationClass);
}
/**
+ * {@inheritDoc}
* @since 1.5
*/
public Annotation[] getDeclaredAnnotations() {
- return AnnotationParser.toArray(declaredAnnotations());
- }
-
- private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
-
- private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
- if (declaredAnnotations == null) {
- declaredAnnotations = AnnotationParser.parseAnnotations(
- annotations, sun.misc.SharedSecrets.getJavaLangAccess().
- getConstantPool(getDeclaringClass()),
- getDeclaringClass());
- }
- return declaredAnnotations;
+ return super.getDeclaredAnnotations();
}
/**
- * Returns an array of arrays that represent the annotations on the formal
- * parameters, in declaration order, of the method represented by
- * this {@code Constructor} object. (Returns an array of length zero if the
- * underlying method is parameterless. If the method has one or more
- * parameters, a nested array of length zero is returned for each parameter
- * with no annotations.) The annotation objects contained in the returned
- * arrays are serializable. The caller of this method is free to modify
- * the returned arrays; it will have no effect on the arrays returned to
- * other callers.
- *
- * @return an array of arrays that represent the annotations on the formal
- * parameters, in declaration order, of the method represented by this
- * Constructor object
+ * {@inheritDoc}
* @since 1.5
*/
+ @Override
public Annotation[][] getParameterAnnotations() {
- int numParameters = parameterTypes.length;
- if (parameterAnnotations == null)
- return new Annotation[numParameters][0];
+ return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
+ }
- Annotation[][] result = AnnotationParser.parseParameterAnnotations(
- parameterAnnotations,
- sun.misc.SharedSecrets.getJavaLangAccess().
- getConstantPool(getDeclaringClass()),
- getDeclaringClass());
- if (result.length != numParameters) {
- Class<?> declaringClass = getDeclaringClass();
- if (declaringClass.isEnum() ||
- declaringClass.isAnonymousClass() ||
- declaringClass.isLocalClass() )
- ; // Can't do reliable parameter counting
- else {
- if (!declaringClass.isMemberClass() || // top-level
- // Check for the enclosing instance parameter for
- // non-static member classes
- (declaringClass.isMemberClass() &&
- ((declaringClass.getModifiers() & Modifier.STATIC) == 0) &&
- result.length + 1 != numParameters) ) {
- throw new AnnotationFormatError(
- "Parameter annotations don't match number of parameters");
- }
+ @Override
+ void handleParameterNumberMismatch(int resultLength, int numParameters) {
+ Class<?> declaringClass = getDeclaringClass();
+ if (declaringClass.isEnum() ||
+ declaringClass.isAnonymousClass() ||
+ declaringClass.isLocalClass() )
+ return ; // Can't do reliable parameter counting
+ else {
+ if (!declaringClass.isMemberClass() || // top-level
+ // Check for the enclosing instance parameter for
+ // non-static member classes
+ (declaringClass.isMemberClass() &&
+ ((declaringClass.getModifiers() & Modifier.STATIC) == 0) &&
+ resultLength + 1 != numParameters) ) {
+ throw new AnnotationFormatError(
+ "Parameter annotations don't match number of parameters");
}
}
- return result;
}
}
diff --git a/src/share/classes/java/lang/reflect/Executable.java b/src/share/classes/java/lang/reflect/Executable.java
new file mode 100644
index 0000000..883c8af
--- /dev/null
+++ b/src/share/classes/java/lang/reflect/Executable.java
@@ -0,0 +1,394 @@
+/*
+ * Copyright (c) 2011, 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 java.lang.reflect;
+
+import java.lang.annotation.*;
+import java.util.Map;
+import sun.reflect.annotation.AnnotationParser;
+import sun.reflect.generics.repository.ConstructorRepository;
+import sun.reflect.generics.factory.CoreReflectionFactory;
+import sun.reflect.generics.factory.GenericsFactory;
+import sun.reflect.generics.scope.ConstructorScope;
+
+/**
+ * A shared superclass for the common functionality of {@link Method}
+ * and {@link Constructor}.
+ *
+ * @since 1.8
+ */
+public abstract class Executable extends AccessibleObject
+ implements Member, GenericDeclaration {
+ /*
+ * Only grant package-visibility to the constructor.
+ */
+ Executable() {}
+
+ /**
+ * Accessor method to allow code sharing
+ */
+ abstract byte[] getAnnotationBytes();
+
+ /**
+ * Does the Executable have generic information.
+ */
+ abstract boolean hasGenericInformation();
+
+ abstract ConstructorRepository getGenericInfo();
+
+ boolean equalParamTypes(Class<?>[] params1, Class<?>[] params2) {
+ /* Avoid unnecessary cloning */
+ if (params1.length == params2.length) {
+ for (int i = 0; i < params1.length; i++) {
+ if (params1[i] != params2[i])
+ return false;
+ }
+ }
+ return true;
+ }
+
+ Annotation[][] parseParameterAnnotations(byte[] parameterAnnotations) {
+ return AnnotationParser.parseParameterAnnotations(
+ parameterAnnotations,
+ sun.misc.SharedSecrets.getJavaLangAccess().
+ getConstantPool(getDeclaringClass()),
+ getDeclaringClass());
+ }
+
+ void separateWithCommas(Class<?>[] types, StringBuilder sb) {
+ for (int j = 0; j < types.length; j++) {
+ sb.append(Field.getTypeName(types[j]));
+ if (j < (types.length - 1))
+ sb.append(",");
+ }
+
+ }
+
+ void printModifiersIfNonzero(StringBuilder sb, int mask) {
+ int mod = getModifiers() & mask;
+ if (mod != 0) {
+ sb.append(Modifier.toString(mod)).append(' ');
+ }
+ }
+
+ String sharedToString(int modifierMask,
+ Class<?>[] parameterTypes,
+ Class<?>[] exceptionTypes) {
+ try {
+ StringBuilder sb = new StringBuilder();
+
+ printModifiersIfNonzero(sb, modifierMask);
+ specificToStringHeader(sb);
+
+ sb.append('(');
+ separateWithCommas(parameterTypes, sb);
+ sb.append(')');
+ if (exceptionTypes.length > 0) {
+ sb.append(" throws ");
+ separateWithCommas(exceptionTypes, sb);
+ }
+ return sb.toString();
+ } catch (Exception e) {
+ return "<" + e + ">";
+ }
+ }
+
+ /**
+ * Generate toString header information specific to a method or
+ * constructor.
+ */
+ abstract void specificToStringHeader(StringBuilder sb);
+
+ String sharedToGenericString(int modifierMask) {
+ try {
+ StringBuilder sb = new StringBuilder();
+
+ printModifiersIfNonzero(sb, modifierMask);
+
+ TypeVariable<?>[] typeparms = getTypeParameters();
+ if (typeparms.length > 0) {
+ boolean first = true;
+ sb.append('<');
+ for(TypeVariable<?> typeparm: typeparms) {
+ if (!first)
+ sb.append(',');
+ // Class objects can't occur here; no need to test
+ // and call Class.getName().
+ sb.append(typeparm.toString());
+ first = false;
+ }
+ sb.append("> ");
+ }
+
+ specificToGenericStringHeader(sb);
+
+ sb.append('(');
+ Type[] params = getGenericParameterTypes();
+ for (int j = 0; j < params.length; j++) {
+ String param = (params[j] instanceof Class)?
+ Field.getTypeName((Class)params[j]):
+ (params[j].toString());
+ if (isVarArgs() && (j == params.length - 1)) // replace T[] with T...
+ param = param.replaceFirst("\\[\\]$", "...");
+ sb.append(param);
+ if (j < (params.length - 1))
+ sb.append(',');
+ }
+ sb.append(')');
+ Type[] exceptions = getGenericExceptionTypes();
+ if (exceptions.length > 0) {
+ sb.append(" throws ");
+ for (int k = 0; k < exceptions.length; k++) {
+ sb.append((exceptions[k] instanceof Class)?
+ ((Class)exceptions[k]).getName():
+ exceptions[k].toString());
+ if (k < (exceptions.length - 1))
+ sb.append(',');
+ }
+ }
+ return sb.toString();
+ } catch (Exception e) {
+ return "<" + e + ">";
+ }
+ }
+
+ /**
+ * Generate toGenericString header information specific to a
+ * method or constructor.
+ */
+ abstract void specificToGenericStringHeader(StringBuilder sb);
+
+ /**
+ * Returns the {@code Class} object representing the class or interface
+ * that declares the method represented by this executable object.
+ */
+ public abstract Class<?> getDeclaringClass();
+
+ /**
+ * Returns the name of the executable represented by this object.
+ */
+ public abstract String getName();
+
+ /**
+ * Returns the Java language {@linkplain Modifier modifiers} for
+ * the executable represented by this object.
+ */
+ public abstract int getModifiers();
+
+ /**
+ * Returns an array of {@code TypeVariable} objects that represent the
+ * type variables declared by the generic declaration represented by this
+ * {@code GenericDeclaration} object, in declaration order. Returns an
+ * array of length 0 if the underlying generic declaration declares no type
+ * variables.
+ *
+ * @return an array of {@code TypeVariable} objects that represent
+ * the type variables declared by this generic declaration
+ * @throws GenericSignatureFormatError if the generic
+ * signature of this generic declaration does not conform to
+ * the format specified in
+ * <cite>The Java™ Virtual Machine Specification</cite>
+ */
+ public abstract TypeVariable<?>[] getTypeParameters();
+
+ /**
+ * Returns an array of {@code Class} objects that represent the formal
+ * parameter types, in declaration order, of the executable
+ * represented by this object. Returns an array of length
+ * 0 if the underlying method takes no parameters.
+ *
+ * @return the parameter types for the method this object
+ * represents
+ */
+ public abstract Class<?>[] getParameterTypes();
+
+ /**
+ * Returns an array of {@code Type} objects that represent the formal
+ * parameter types, in declaration order, of the method represented by
+ * this executable object. Returns an array of length 0 if the
+ * underlying method takes no parameters.
+ *
+ * <p>If a formal parameter type is a parameterized type,
+ * the {@code Type} object returned for it must accurately reflect
+ * the actual type parameters used in the source code.
+ *
+ * <p>If a formal parameter type is a type variable or a parameterized
+ * type, it is created. Otherwise, it is resolved.
+ *
+ * @return an array of {@code Type}s that represent the formal
+ * parameter types of the underlying method, in declaration order
+ * @throws GenericSignatureFormatError
+ * if the generic method signature does not conform to the format
+ * specified in
+ * <cite>The Java™ Virtual Machine Specification</cite>
+ * @throws TypeNotPresentException if any of the parameter
+ * types of the underlying method refers to a non-existent type
+ * declaration
+ * @throws MalformedParameterizedTypeException if any of
+ * the underlying method's parameter types refer to a parameterized
+ * type that cannot be instantiated for any reason
+ */
+ public Type[] getGenericParameterTypes() {
+ if (hasGenericInformation())
+ return getGenericInfo().getParameterTypes();
+ else
+ return getParameterTypes();
+ }
+
+ /**
+ * Returns an array of {@code Class} objects that represent the
+ * types of exceptions declared to be thrown by the underlying
+ * executable represented by this object. Returns an array of
+ * length 0 if the executable declares no exceptions in its {@code
+ * throws} clause.
+ *
+ * @return the exception types declared as being thrown by the
+ * executable this object represents
+ */
+ public abstract Class<?>[] getExceptionTypes();
+
+ /**
+ * Returns an array of {@code Type} objects that represent the
+ * exceptions declared to be thrown by this executable object.
+ * Returns an array of length 0 if the underlying executable declares
+ * no exceptions in its {@code throws} clause.
+ *
+ * <p>If an exception type is a type variable or a parameterized
+ * type, it is created. Otherwise, it is resolved.
+ *
+ * @return an array of Types that represent the exception types
+ * thrown by the underlying method
+ * @throws GenericSignatureFormatError
+ * if the generic method signature does not conform to the format
+ * specified in
+ * <cite>The Java™ Virtual Machine Specification</cite>
+ * @throws TypeNotPresentException if the underlying method's
+ * {@code throws} clause refers to a non-existent type declaration
+ * @throws MalformedParameterizedTypeException if
+ * the underlying method's {@code throws} clause refers to a
+ * parameterized type that cannot be instantiated for any reason
+ */
+ public Type[] getGenericExceptionTypes() {
+ Type[] result;
+ if (hasGenericInformation() &&
+ ((result = getGenericInfo().getExceptionTypes()).length > 0))
+ return result;
+ else
+ return getExceptionTypes();
+ }
+
+ /**
+ * Returns a string describing this {@code Executable}, including
+ * any type parameters.
+ */
+ public abstract String toGenericString();
+
+ /**
+ * Returns {@code true} if this executable was declared to take a
+ * variable number of arguments; returns {@code false} otherwise.
+ *
+ * @return {@code true} if an only if this executable was declared
+ * to take a variable number of arguments.
+ */
+ public boolean isVarArgs() {
+ return (getModifiers() & Modifier.VARARGS) != 0;
+ }
+
+ /**
+ * Returns {@code true} if this executable is a synthetic
+ * construct; returns {@code false} otherwise.
+ *
+ * @return true if and only if this executable is a synthetic
+ * construct as defined by
+ * <cite>The Java™ Language Specification</cite>.
+ */
+ public boolean isSynthetic() {
+ return Modifier.isSynthetic(getModifiers());
+ }
+
+ /**
+ * Returns an array of arrays that represent the annotations on
+ * the formal parameters, in declaration order, of the executable
+ * represented by this object. (Returns an array of length zero if
+ * the underlying method is parameterless. If the executable has
+ * one or more parameters, a nested array of length zero is
+ * returned for each parameter with no annotations.) The
+ * annotation objects contained in the returned arrays are
+ * serializable. The caller of this method is free to modify the
+ * returned arrays; it will have no effect on the arrays returned
+ * to other callers.
+ *
+ * @return an array of arrays that represent the annotations on the formal
+ * parameters, in declaration order, of the exectuable represented by this
+ * object
+ */
+ public abstract Annotation[][] getParameterAnnotations();
+
+ Annotation[][] sharedGetParameterAnnotations(Class<?>[] parameterTypes,
+ byte[] parameterAnnotations) {
+ int numParameters = parameterTypes.length;
+ if (parameterAnnotations == null)
+ return new Annotation[numParameters][0];
+
+ Annotation[][] result = parseParameterAnnotations(parameterAnnotations);
+
+ if (result.length != numParameters)
+ handleParameterNumberMismatch(result.length, numParameters);
+ return result;
+ }
+
+ abstract void handleParameterNumberMismatch(int resultLength, int numParameters);
+
+ /**
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+ if (annotationClass == null)
+ throw new NullPointerException();
+
+ return (T) declaredAnnotations().get(annotationClass);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Annotation[] getDeclaredAnnotations() {
+ return AnnotationParser.toArray(declaredAnnotations());
+ }
+
+ private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
+
+ private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
+ if (declaredAnnotations == null) {
+ declaredAnnotations = AnnotationParser.parseAnnotations(
+ getAnnotationBytes(),
+ sun.misc.SharedSecrets.getJavaLangAccess().
+ getConstantPool(getDeclaringClass()),
+ getDeclaringClass());
+ }
+ return declaredAnnotations;
+ }
+}
diff --git a/src/share/classes/java/lang/reflect/Method.java b/src/share/classes/java/lang/reflect/Method.java
index 0a1f7a3..2edd6c0 100644
--- a/src/share/classes/java/lang/reflect/Method.java
+++ b/src/share/classes/java/lang/reflect/Method.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -36,7 +36,6 @@
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationFormatError;
import java.nio.ByteBuffer;
-import java.util.Map;
/**
* A {@code Method} provides information about, and access to, a single method
@@ -58,9 +57,7 @@
* @author Kenneth Russell
* @author Nakul Saraiya
*/
-public final
- class Method extends AccessibleObject implements GenericDeclaration,
- Member {
+public final class Method extends Executable {
private Class<?> clazz;
private int slot;
// This is guaranteed to be interned by the VM in the 1.4
@@ -83,8 +80,8 @@
// potentially many Method objects pointing to it.)
private Method root;
- // Generics infrastructure
+ // Generics infrastructure
private String getGenericSignature() {return signature;}
// Accessor for factory
@@ -94,7 +91,8 @@
}
// Accessor for generic info repository
- private MethodRepository getGenericInfo() {
+ @Override
+ MethodRepository getGenericInfo() {
// lazily initialize repository if necessary
if (genericInfo == null) {
// create and cache generic info repository
@@ -119,8 +117,7 @@
String signature,
byte[] annotations,
byte[] parameterAnnotations,
- byte[] annotationDefault)
- {
+ byte[] annotationDefault) {
this.clazz = declaringClass;
this.name = name;
this.parameterTypes = parameterTypes;
@@ -156,10 +153,20 @@
return res;
}
+ @Override
+ boolean hasGenericInformation() {
+ return (getGenericSignature() != null);
+ }
+
+ @Override
+ byte[] getAnnotationBytes() {
+ return annotations;
+ }
+
/**
- * Returns the {@code Class} object representing the class or interface
- * that declares the method represented by this {@code Method} object.
+ * {@inheritDoc}
*/
+ @Override
public Class<?> getDeclaringClass() {
return clazz;
}
@@ -168,36 +175,25 @@
* Returns the name of the method represented by this {@code Method}
* object, as a {@code String}.
*/
+ @Override
public String getName() {
return name;
}
/**
- * Returns the Java language modifiers for the method represented
- * by this {@code Method} object, as an integer. The {@code Modifier} class should
- * be used to decode the modifiers.
- *
- * @see Modifier
+ * {@inheritDoc}
*/
+ @Override
public int getModifiers() {
return modifiers;
}
/**
- * Returns an array of {@code TypeVariable} objects that represent the
- * type variables declared by the generic declaration represented by this
- * {@code GenericDeclaration} object, in declaration order. Returns an
- * array of length 0 if the underlying generic declaration declares no type
- * variables.
- *
- * @return an array of {@code TypeVariable} objects that represent
- * the type variables declared by this generic declaration
- * @throws GenericSignatureFormatError if the generic
- * signature of this generic declaration does not conform to
- * the format specified in
- * <cite>The Java™ Virtual Machine Specification</cite>
+ * {@inheritDoc}
+ * @throws GenericSignatureFormatError {@inheritDoc}
* @since 1.5
*/
+ @Override
public TypeVariable<Method>[] getTypeParameters() {
if (getGenericSignature() != null)
return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
@@ -245,99 +241,45 @@
} else { return getReturnType();}
}
-
/**
- * Returns an array of {@code Class} objects that represent the formal
- * parameter types, in declaration order, of the method
- * represented by this {@code Method} object. Returns an array of length
- * 0 if the underlying method takes no parameters.
- *
- * @return the parameter types for the method this object
- * represents
+ * {@inheritDoc}
*/
+ @Override
public Class<?>[] getParameterTypes() {
return (Class<?>[]) parameterTypes.clone();
}
/**
- * Returns an array of {@code Type} objects that represent the formal
- * parameter types, in declaration order, of the method represented by
- * this {@code Method} object. Returns an array of length 0 if the
- * underlying method takes no parameters.
- *
- * <p>If a formal parameter type is a parameterized type,
- * the {@code Type} object returned for it must accurately reflect
- * the actual type parameters used in the source code.
- *
- * <p>If a formal parameter type is a type variable or a parameterized
- * type, it is created. Otherwise, it is resolved.
- *
- * @return an array of Types that represent the formal
- * parameter types of the underlying method, in declaration order
- * @throws GenericSignatureFormatError
- * if the generic method signature does not conform to the format
- * specified in
- * <cite>The Java™ Virtual Machine Specification</cite>
- * @throws TypeNotPresentException if any of the parameter
- * types of the underlying method refers to a non-existent type
- * declaration
- * @throws MalformedParameterizedTypeException if any of
- * the underlying method's parameter types refer to a parameterized
- * type that cannot be instantiated for any reason
+ * {@inheritDoc}
+ * @throws GenericSignatureFormatError {@inheritDoc}
+ * @throws TypeNotPresentException {@inheritDoc}
+ * @throws MalformedParameterizedTypeException {@inheritDoc}
* @since 1.5
*/
+ @Override
public Type[] getGenericParameterTypes() {
- if (getGenericSignature() != null)
- return getGenericInfo().getParameterTypes();
- else
- return getParameterTypes();
+ return super.getGenericParameterTypes();
}
-
/**
- * Returns an array of {@code Class} objects that represent
- * the types of the exceptions declared to be thrown
- * by the underlying method
- * represented by this {@code Method} object. Returns an array of length
- * 0 if the method declares no exceptions in its {@code throws} clause.
- *
- * @return the exception types declared as being thrown by the
- * method this object represents
+ * {@inheritDoc}
*/
+ @Override
public Class<?>[] getExceptionTypes() {
return (Class<?>[]) exceptionTypes.clone();
}
/**
- * Returns an array of {@code Type} objects that represent the
- * exceptions declared to be thrown by this {@code Method} object.
- * Returns an array of length 0 if the underlying method declares
- * no exceptions in its {@code throws} clause.
- *
- * <p>If an exception type is a type variable or a parameterized
- * type, it is created. Otherwise, it is resolved.
- *
- * @return an array of Types that represent the exception types
- * thrown by the underlying method
- * @throws GenericSignatureFormatError
- * if the generic method signature does not conform to the format
- * specified in
- * <cite>The Java™ Virtual Machine Specification</cite>
- * @throws TypeNotPresentException if the underlying method's
- * {@code throws} clause refers to a non-existent type declaration
- * @throws MalformedParameterizedTypeException if
- * the underlying method's {@code throws} clause refers to a
- * parameterized type that cannot be instantiated for any reason
+ * {@inheritDoc}
+ * @throws GenericSignatureFormatError {@inheritDoc}
+ * @throws TypeNotPresentException {@inheritDoc}
+ * @throws MalformedParameterizedTypeException {@inheritDoc}
* @since 1.5
*/
- public Type[] getGenericExceptionTypes() {
- Type[] result;
- if (getGenericSignature() != null &&
- ((result = getGenericInfo().getExceptionTypes()).length > 0))
- return result;
- else
- return getExceptionTypes();
- }
+ @Override
+ public Type[] getGenericExceptionTypes() {
+ return super.getGenericExceptionTypes();
+ }
/**
* Compares this {@code Method} against the specified object. Returns
@@ -352,16 +294,7 @@
&& (getName() == other.getName())) {
if (!returnType.equals(other.getReturnType()))
return false;
- /* Avoid unnecessary cloning */
- Class<?>[] params1 = parameterTypes;
- Class<?>[] params2 = other.parameterTypes;
- if (params1.length == params2.length) {
- for (int i = 0; i < params1.length; i++) {
- if (params1[i] != params2[i])
- return false;
- }
- return true;
- }
+ return equalParamTypes(parameterTypes, other.parameterTypes);
}
}
return false;
@@ -399,35 +332,16 @@
* {@code synchronized}, {@code native}, {@code strictfp}.
*/
public String toString() {
- try {
- StringBuilder sb = new StringBuilder();
- int mod = getModifiers() & Modifier.methodModifiers();
- if (mod != 0) {
- sb.append(Modifier.toString(mod)).append(' ');
- }
- sb.append(Field.getTypeName(getReturnType())).append(' ');
- sb.append(Field.getTypeName(getDeclaringClass())).append('.');
- sb.append(getName()).append('(');
- Class<?>[] params = parameterTypes; // avoid clone
- for (int j = 0; j < params.length; j++) {
- sb.append(Field.getTypeName(params[j]));
- if (j < (params.length - 1))
- sb.append(',');
- }
- sb.append(')');
- Class<?>[] exceptions = exceptionTypes; // avoid clone
- if (exceptions.length > 0) {
- sb.append(" throws ");
- for (int k = 0; k < exceptions.length; k++) {
- sb.append(exceptions[k].getName());
- if (k < (exceptions.length - 1))
- sb.append(',');
- }
- }
- return sb.toString();
- } catch (Exception e) {
- return "<" + e + ">";
- }
+ return sharedToString(Modifier.methodModifiers(),
+ parameterTypes,
+ exceptionTypes);
+ }
+
+ @Override
+ void specificToStringHeader(StringBuilder sb) {
+ sb.append(Field.getTypeName(getReturnType())).append(' ');
+ sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+ sb.append(getName());
}
/**
@@ -468,62 +382,20 @@
*
* @since 1.5
*/
+ @Override
public String toGenericString() {
- try {
- StringBuilder sb = new StringBuilder();
- int mod = getModifiers() & Modifier.methodModifiers();
- if (mod != 0) {
- sb.append(Modifier.toString(mod)).append(' ');
- }
- TypeVariable<?>[] typeparms = getTypeParameters();
- if (typeparms.length > 0) {
- boolean first = true;
- sb.append('<');
- for(TypeVariable<?> typeparm: typeparms) {
- if (!first)
- sb.append(',');
- // Class objects can't occur here; no need to test
- // and call Class.getName().
- sb.append(typeparm.toString());
- first = false;
- }
- sb.append("> ");
- }
+ return sharedToGenericString(Modifier.methodModifiers());
+ }
- Type genRetType = getGenericReturnType();
- sb.append( ((genRetType instanceof Class<?>)?
- Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
- .append(' ');
+ @Override
+ void specificToGenericStringHeader(StringBuilder sb) {
+ Type genRetType = getGenericReturnType();
+ sb.append( ((genRetType instanceof Class<?>)?
+ Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
+ .append(' ');
- sb.append(Field.getTypeName(getDeclaringClass())).append('.');
- sb.append(getName()).append('(');
- Type[] params = getGenericParameterTypes();
- for (int j = 0; j < params.length; j++) {
- String param = (params[j] instanceof Class)?
- Field.getTypeName((Class)params[j]):
- (params[j].toString());
- if (isVarArgs() && (j == params.length - 1)) // replace T[] with T...
- param = param.replaceFirst("\\[\\]$", "...");
- sb.append(param);
- if (j < (params.length - 1))
- sb.append(',');
- }
- sb.append(')');
- Type[] exceptions = getGenericExceptionTypes();
- if (exceptions.length > 0) {
- sb.append(" throws ");
- for (int k = 0; k < exceptions.length; k++) {
- sb.append((exceptions[k] instanceof Class)?
- ((Class)exceptions[k]).getName():
- exceptions[k].toString());
- if (k < (exceptions.length - 1))
- sb.append(',');
- }
- }
- return sb.toString();
- } catch (Exception e) {
- return "<" + e + ">";
- }
+ sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+ sb.append(getName());
}
/**
@@ -614,28 +486,21 @@
}
/**
- * Returns {@code true} if this method was declared to take
- * a variable number of arguments; returns {@code false}
- * otherwise.
- *
- * @return {@code true} if an only if this method was declared to
- * take a variable number of arguments.
+ * {@inheritDoc}
* @since 1.5
*/
+ @Override
public boolean isVarArgs() {
- return (getModifiers() & Modifier.VARARGS) != 0;
+ return super.isVarArgs();
}
/**
- * Returns {@code true} if this method is a synthetic
- * method; returns {@code false} otherwise.
- *
- * @return true if and only if this method is a synthetic
- * method as defined by the Java Language Specification.
+ * {@inheritDoc}
* @since 1.5
*/
+ @Override
public boolean isSynthetic() {
- return Modifier.isSynthetic(getModifiers());
+ return super.isSynthetic();
}
// NOTE that there is no synchronization used here. It is correct
@@ -675,36 +540,6 @@
}
/**
- * @throws NullPointerException {@inheritDoc}
- * @since 1.5
- */
- public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
- if (annotationClass == null)
- throw new NullPointerException();
-
- return (T) declaredAnnotations().get(annotationClass);
- }
-
- /**
- * @since 1.5
- */
- public Annotation[] getDeclaredAnnotations() {
- return AnnotationParser.toArray(declaredAnnotations());
- }
-
- private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations;
-
- private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
- if (declaredAnnotations == null) {
- declaredAnnotations = AnnotationParser.parseAnnotations(
- annotations, sun.misc.SharedSecrets.getJavaLangAccess().
- getConstantPool(getDeclaringClass()),
- getDeclaringClass());
- }
- return declaredAnnotations;
- }
-
- /**
* Returns the default value for the annotation member represented by
* this {@code Method} instance. If the member is of a primitive type,
* an instance of the corresponding wrapper type is returned. Returns
@@ -734,34 +569,33 @@
}
/**
- * Returns an array of arrays that represent the annotations on the formal
- * parameters, in declaration order, of the method represented by
- * this {@code Method} object. (Returns an array of length zero if the
- * underlying method is parameterless. If the method has one or more
- * parameters, a nested array of length zero is returned for each parameter
- * with no annotations.) The annotation objects contained in the returned
- * arrays are serializable. The caller of this method is free to modify
- * the returned arrays; it will have no effect on the arrays returned to
- * other callers.
- *
- * @return an array of arrays that represent the annotations on the formal
- * parameters, in declaration order, of the method represented by this
- * Method object
+ * {@inheritDoc}
+ * @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
- public Annotation[][] getParameterAnnotations() {
- int numParameters = parameterTypes.length;
- if (parameterAnnotations == null)
- return new Annotation[numParameters][0];
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+ return super.getAnnotation(annotationClass);
+ }
- Annotation[][] result = AnnotationParser.parseParameterAnnotations(
- parameterAnnotations,
- sun.misc.SharedSecrets.getJavaLangAccess().
- getConstantPool(getDeclaringClass()),
- getDeclaringClass());
- if (result.length != numParameters)
- throw new java.lang.annotation.AnnotationFormatError(
- "Parameter annotations don't match number of parameters");
- return result;
+ /**
+ * {@inheritDoc}
+ * @since 1.5
+ */
+ public Annotation[] getDeclaredAnnotations() {
+ return super.getDeclaredAnnotations();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @since 1.5
+ */
+ @Override
+ public Annotation[][] getParameterAnnotations() {
+ return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations);
+ }
+
+ @Override
+ void handleParameterNumberMismatch(int resultLength, int numParameters) {
+ throw new AnnotationFormatError("Parameter annotations don't match number of parameters");
}
}
diff --git a/src/share/classes/java/net/SocketPermission.java b/src/share/classes/java/net/SocketPermission.java
index 41fbdbf..a0fdbb8 100644
--- a/src/share/classes/java/net/SocketPermission.java
+++ b/src/share/classes/java/net/SocketPermission.java
@@ -956,10 +956,16 @@
String thisHost = hostname;
String thatHost = that.hostname;
- if (thisHost == null)
+ if (thisHost == null) {
return false;
- else
+ } else if (this.wildcard) {
+ final int cnameLength = this.cname.length();
+ return thatHost.regionMatches(true,
+ (thatHost.length() - cnameLength),
+ this.cname, 0, cnameLength);
+ } else {
return thisHost.equalsIgnoreCase(thatHost);
+ }
}
/**
diff --git a/src/share/classes/java/security/KeyStore.java b/src/share/classes/java/security/KeyStore.java
index af44dd7..26faa9c 100644
--- a/src/share/classes/java/security/KeyStore.java
+++ b/src/share/classes/java/security/KeyStore.java
@@ -113,14 +113,8 @@
* // get user password and file input stream
* char[] password = getPassword();
*
- * java.io.FileInputStream fis = null;
- * try {
- * fis = new java.io.FileInputStream("keyStoreName");
+ * try (FileInputStream fis = new FileInputStream("keyStoreName")) {
* ks.load(fis, password);
- * } finally {
- * if (fis != null) {
- * fis.close();
- * }
* }
* </pre>
*
@@ -146,14 +140,8 @@
* ks.setEntry("secretKeyAlias", skEntry, protParam);
*
* // store away the keystore
- * java.io.FileOutputStream fos = null;
- * try {
- * fos = new java.io.FileOutputStream("newKeyStoreName");
+ * try (FileOutputStream fos = new FileOutputStream("newKeyStoreName")) {
* ks.store(fos, password);
- * } finally {
- * if (fos != null) {
- * fos.close();
- * }
* }
* </pre>
*
diff --git a/src/share/classes/java/security/cert/X509CRL.java b/src/share/classes/java/security/cert/X509CRL.java
index 0998f36..4c5a4c8 100644
--- a/src/share/classes/java/security/cert/X509CRL.java
+++ b/src/share/classes/java/security/cert/X509CRL.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -94,15 +94,9 @@
* CRLs are instantiated using a certificate factory. The following is an
* example of how to instantiate an X.509 CRL:
* <pre><code>
- * InputStream inStream = null;
- * try {
- * inStream = new FileInputStream("fileName-of-crl");
+ * try (InputStream inStream = new FileInputStream("fileName-of-crl")) {
* CertificateFactory cf = CertificateFactory.getInstance("X.509");
* X509CRL crl = (X509CRL)cf.generateCRL(inStream);
- * } finally {
- * if (inStream != null) {
- * inStream.close();
- * }
* }
* </code></pre>
*
diff --git a/src/share/classes/java/security/cert/X509Certificate.java b/src/share/classes/java/security/cert/X509Certificate.java
index cb0e548..60367d4 100644
--- a/src/share/classes/java/security/cert/X509Certificate.java
+++ b/src/share/classes/java/security/cert/X509Certificate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -89,15 +89,9 @@
* Certificates are instantiated using a certificate factory. The following is
* an example of how to instantiate an X.509 certificate:
* <pre>
- * InputStream inStream = null;
- * try {
- * inStream = new FileInputStream("fileName-of-cert");
+ * try (InputStream inStream = new FileInputStream("fileName-of-cert")) {
* CertificateFactory cf = CertificateFactory.getInstance("X.509");
* X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream);
- * } finally {
- * if (inStream != null) {
- * inStream.close();
- * }
* }
* </pre>
*
diff --git a/src/share/classes/java/security/cert/X509Extension.java b/src/share/classes/java/security/cert/X509Extension.java
index 6f6c51b..e2c362e 100644
--- a/src/share/classes/java/security/cert/X509Extension.java
+++ b/src/share/classes/java/security/cert/X509Extension.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -85,16 +85,10 @@
* Here is sample code to get a Set of critical extensions from an
* X509Certificate and print the OIDs:
* <pre><code>
- * InputStream inStrm = null;
* X509Certificate cert = null;
- * try {
- * inStrm = new FileInputStream("DER-encoded-Cert");
+ * try (InputStream inStrm = new FileInputStream("DER-encoded-Cert")) {
* CertificateFactory cf = CertificateFactory.getInstance("X.509");
* cert = (X509Certificate)cf.generateCertificate(inStrm);
- * } finally {
- * if (inStrm != null) {
- * inStrm.close();
- * }
* }<p>
*
* Set<String> critSet = cert.getCriticalExtensionOIDs();
@@ -120,23 +114,16 @@
* Here is sample code to get a Set of non-critical extensions from an
* X509CRL revoked certificate entry and print the OIDs:
* <pre><code>
- * InputStream inStrm = null;
* CertificateFactory cf = null;
* X509CRL crl = null;
- * try {
- * inStrm = new FileInputStream("DER-encoded-CRL");
+ * try (InputStream inStrm = new FileInputStream("DER-encoded-CRL")) {
* cf = CertificateFactory.getInstance("X.509");
* crl = (X509CRL)cf.generateCRL(inStrm);
- * } finally {
- * if (inStrm != null) {
- * inStrm.close();
- * }
* }<p>
*
* byte[] certData = <DER-encoded certificate data>
* ByteArrayInputStream bais = new ByteArrayInputStream(certData);
* X509Certificate cert = (X509Certificate)cf.generateCertificate(bais);
- * bais.close();
* X509CRLEntry badCert =
* crl.getRevokedCertificate(cert.getSerialNumber());<p>
*
diff --git a/src/share/classes/sun/launcher/LauncherHelper.java b/src/share/classes/sun/launcher/LauncherHelper.java
index 6999b2c..24eeaca 100644
--- a/src/share/classes/sun/launcher/LauncherHelper.java
+++ b/src/share/classes/sun/launcher/LauncherHelper.java
@@ -396,7 +396,11 @@
if (mainAttrs == null) {
abort(ostream, null, "java.launcher.jar.error3", jarname);
}
- return mainAttrs.getValue(MAIN_CLASS).trim();
+ String mainValue = mainAttrs.getValue(MAIN_CLASS);
+ if (mainValue == null) {
+ abort(ostream, null, "java.launcher.jar.error3", jarname);
+ }
+ return mainValue.trim();
} finally {
if (jarFile != null) {
jarFile.close();
diff --git a/src/share/classes/sun/launcher/resources/launcher.properties b/src/share/classes/sun/launcher/resources/launcher.properties
index 26d3ecc..b1677c0 100644
--- a/src/share/classes/sun/launcher/resources/launcher.properties
+++ b/src/share/classes/sun/launcher/resources/launcher.properties
@@ -72,7 +72,7 @@
\ load Java programming language agent, see java.lang.instrument\n\
\ -splash:<imagepath>\n\
\ show splash screen with specified image\n\
-See http://java.sun.com/javase/reference for more details.
+See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
# Translators please note do not translate the options themselves
java.launcher.X.usage=\
diff --git a/src/share/classes/sun/net/httpserver/ServerConfig.java b/src/share/classes/sun/net/httpserver/ServerConfig.java
index 0ada03d..1b79163 100644
--- a/src/share/classes/sun/net/httpserver/ServerConfig.java
+++ b/src/share/classes/sun/net/httpserver/ServerConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -25,8 +25,6 @@
package sun.net.httpserver;
-import com.sun.net.httpserver.*;
-import com.sun.net.httpserver.spi.*;
import java.util.logging.Logger;
import java.security.PrivilegedAction;
@@ -59,48 +57,46 @@
static long maxReqTime;
static long maxRspTime;
static long timerMillis;
- static boolean debug = false;
+ static boolean debug;
+
+ // the value of the TCP_NODELAY socket-level option
+ static boolean noDelay;
static {
+ java.security.AccessController.doPrivileged(
+ new PrivilegedAction<Void>() {
+ @Override
+ public Void run () {
+ idleInterval = Long.getLong("sun.net.httpserver.idleInterval",
+ DEFAULT_IDLE_INTERVAL) * 1000;
- idleInterval = ((Long)java.security.AccessController.doPrivileged(
- new sun.security.action.GetLongAction(
- "sun.net.httpserver.idleInterval",
- DEFAULT_IDLE_INTERVAL))).longValue() * 1000;
+ clockTick = Integer.getInteger("sun.net.httpserver.clockTick",
+ DEFAULT_CLOCK_TICK);
- clockTick = ((Integer)java.security.AccessController.doPrivileged(
- new sun.security.action.GetIntegerAction(
- "sun.net.httpserver.clockTick",
- DEFAULT_CLOCK_TICK))).intValue();
+ maxIdleConnections = Integer.getInteger(
+ "sun.net.httpserver.maxIdleConnections",
+ DEFAULT_MAX_IDLE_CONNECTIONS);
- maxIdleConnections = ((Integer)java.security.AccessController.doPrivileged(
- new sun.security.action.GetIntegerAction(
- "sun.net.httpserver.maxIdleConnections",
- DEFAULT_MAX_IDLE_CONNECTIONS))).intValue();
+ drainAmount = Long.getLong("sun.net.httpserver.drainAmount",
+ DEFAULT_DRAIN_AMOUNT);
- drainAmount = ((Long)java.security.AccessController.doPrivileged(
- new sun.security.action.GetLongAction(
- "sun.net.httpserver.drainAmount",
- DEFAULT_DRAIN_AMOUNT))).longValue();
+ maxReqTime = Long.getLong("sun.net.httpserver.maxReqTime",
+ DEFAULT_MAX_REQ_TIME);
- maxReqTime = ((Long)java.security.AccessController.doPrivileged(
- new sun.security.action.GetLongAction(
- "sun.net.httpserver.maxReqTime",
- DEFAULT_MAX_REQ_TIME))).longValue();
+ maxRspTime = Long.getLong("sun.net.httpserver.maxRspTime",
+ DEFAULT_MAX_RSP_TIME);
- maxRspTime = ((Long)java.security.AccessController.doPrivileged(
- new sun.security.action.GetLongAction(
- "sun.net.httpserver.maxRspTime",
- DEFAULT_MAX_RSP_TIME))).longValue();
+ timerMillis = Long.getLong("sun.net.httpserver.timerMillis",
+ DEFAULT_TIMER_MILLIS);
- timerMillis = ((Long)java.security.AccessController.doPrivileged(
- new sun.security.action.GetLongAction(
- "sun.net.httpserver.timerMillis",
- DEFAULT_TIMER_MILLIS))).longValue();
+ debug = Boolean.getBoolean("sun.net.httpserver.debug");
- debug = ((Boolean)java.security.AccessController.doPrivileged(
- new sun.security.action.GetBooleanAction(
- "sun.net.httpserver.debug"))).booleanValue();
+ noDelay = Boolean.getBoolean("sun.net.httpserver.nodelay");
+
+ return null;
+ }
+ });
+
}
@@ -172,4 +168,8 @@
static long getTimerMillis () {
return timerMillis;
}
+
+ static boolean noDelay() {
+ return noDelay;
+ }
}
diff --git a/src/share/classes/sun/net/httpserver/ServerImpl.java b/src/share/classes/sun/net/httpserver/ServerImpl.java
index 0fa61a8..5b53389 100644
--- a/src/share/classes/sun/net/httpserver/ServerImpl.java
+++ b/src/share/classes/sun/net/httpserver/ServerImpl.java
@@ -27,8 +27,6 @@
import java.net.*;
import java.io.*;
-import java.nio.*;
-import java.security.*;
import java.nio.channels.*;
import java.util.*;
import java.util.concurrent.*;
@@ -36,7 +34,6 @@
import java.util.logging.Level;
import javax.net.ssl.*;
import com.sun.net.httpserver.*;
-import com.sun.net.httpserver.spi.*;
import sun.net.httpserver.HttpConnection.State;
/**
@@ -358,6 +355,12 @@
continue;
}
SocketChannel chan = schan.accept();
+
+ // Set TCP_NODELAY, if appropriate
+ if (ServerConfig.noDelay()) {
+ chan.socket().setTcpNoDelay(true);
+ }
+
if (chan == null) {
continue; /* cancel something ? */
}
diff --git a/src/share/classes/sun/reflect/generics/reflectiveObjects/NotImplementedException.java b/src/share/classes/sun/reflect/generics/reflectiveObjects/NotImplementedException.java
index 9eadf58..85bcbc5 100644
--- a/src/share/classes/sun/reflect/generics/reflectiveObjects/NotImplementedException.java
+++ b/src/share/classes/sun/reflect/generics/reflectiveObjects/NotImplementedException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -26,4 +26,6 @@
package sun.reflect.generics.reflectiveObjects;
/** Temporary class used to indicate missing functionality */
-public class NotImplementedException extends RuntimeException {}
+public class NotImplementedException extends RuntimeException {
+ private static final long serialVersionUID = -9177857708926624790L;
+}
diff --git a/src/share/classes/sun/reflect/misc/ConstructorUtil.java b/src/share/classes/sun/reflect/misc/ConstructorUtil.java
index cc95503..e0e4233 100644
--- a/src/share/classes/sun/reflect/misc/ConstructorUtil.java
+++ b/src/share/classes/sun/reflect/misc/ConstructorUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -32,13 +32,13 @@
private ConstructorUtil() {
}
- public static Constructor getConstructor(Class cls, Class[] params)
+ public static Constructor<?> getConstructor(Class<?> cls, Class<?>[] params)
throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls);
return cls.getConstructor(params);
}
- public static Constructor[] getConstructors(Class cls) {
+ public static Constructor<?>[] getConstructors(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
return cls.getConstructors();
}
diff --git a/src/share/classes/sun/reflect/misc/FieldUtil.java b/src/share/classes/sun/reflect/misc/FieldUtil.java
index cf4bc2d..d0cb48f 100644
--- a/src/share/classes/sun/reflect/misc/FieldUtil.java
+++ b/src/share/classes/sun/reflect/misc/FieldUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -35,18 +35,18 @@
private FieldUtil() {
}
- public static Field getField(Class cls, String name)
+ public static Field getField(Class<?> cls, String name)
throws NoSuchFieldException {
ReflectUtil.checkPackageAccess(cls);
return cls.getField(name);
}
- public static Field[] getFields(Class cls) {
+ public static Field[] getFields(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
return cls.getFields();
}
- public static Field[] getDeclaredFields(Class cls) {
+ public static Field[] getDeclaredFields(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
return cls.getDeclaredFields();
}
diff --git a/src/share/classes/sun/reflect/misc/MethodUtil.java b/src/share/classes/sun/reflect/misc/MethodUtil.java
index 52f2b1e..5784ced 100644
--- a/src/share/classes/sun/reflect/misc/MethodUtil.java
+++ b/src/share/classes/sun/reflect/misc/MethodUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -36,17 +36,13 @@
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
-import java.net.HttpURLConnection;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Modifier;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import sun.misc.IOUtils;
-import sun.net.www.ParseUtil;
-import sun.security.util.SecurityConstants;
class Trampoline {
@@ -68,13 +64,13 @@
super();
}
- public static Method getMethod(Class<?> cls, String name, Class[] args)
+ public static Method getMethod(Class<?> cls, String name, Class<?>[] args)
throws NoSuchMethodException {
ReflectUtil.checkPackageAccess(cls);
return cls.getMethod(name, args);
}
- public static Method[] getMethods(Class cls) {
+ public static Method[] getMethods(Class<?> cls) {
ReflectUtil.checkPackageAccess(cls);
return cls.getMethods();
}
@@ -85,7 +81,7 @@
* Class.getMethods() and walking towards Object until
* we're done.
*/
- public static Method[] getPublicMethods(Class cls) {
+ public static Method[] getPublicMethods(Class<?> cls) {
// compatibility for update release
if (System.getSecurityManager() == null) {
return cls.getMethods();
@@ -105,11 +101,11 @@
/*
* Process the immediate interfaces of this class or interface.
*/
- private static void getInterfaceMethods(Class cls,
+ private static void getInterfaceMethods(Class<?> cls,
Map<Signature, Method> sigs) {
- Class[] intfs = cls.getInterfaces();
+ Class<?>[] intfs = cls.getInterfaces();
for (int i=0; i < intfs.length; i++) {
- Class intf = intfs[i];
+ Class<?> intf = intfs[i];
boolean done = getInternalPublicMethods(intf, sigs);
if (!done) {
getInterfaceMethods(intf, sigs);
@@ -121,7 +117,7 @@
*
* Process the methods in this class or interface
*/
- private static boolean getInternalPublicMethods(Class cls,
+ private static boolean getInternalPublicMethods(Class<?> cls,
Map<Signature, Method> sigs) {
Method[] methods = null;
try {
@@ -150,7 +146,7 @@
*/
boolean done = true;
for (int i=0; i < methods.length; i++) {
- Class dc = methods[i].getDeclaringClass();
+ Class<?> dc = methods[i].getDeclaringClass();
if (!Modifier.isPublic(dc.getModifiers())) {
done = false;
break;
@@ -171,7 +167,7 @@
* stripping away inherited methods.
*/
for (int i=0; i < methods.length; i++) {
- Class dc = methods[i].getDeclaringClass();
+ Class<?> dc = methods[i].getDeclaringClass();
if (cls.equals(dc)) {
addMethod(sigs, methods[i]);
}
@@ -301,12 +297,12 @@
}
- protected synchronized Class loadClass(String name, boolean resolve)
+ protected synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
// First, check if the class has already been loaded
ReflectUtil.checkPackageAccess(name);
- Class c = findLoadedClass(name);
+ Class<?> c = findLoadedClass(name);
if (c == null) {
try {
c = findClass(name);
@@ -324,7 +320,7 @@
}
- protected Class findClass(final String name)
+ protected Class<?> findClass(final String name)
throws ClassNotFoundException
{
if (!name.startsWith(MISC_PKG)) {
@@ -347,7 +343,7 @@
/*
* Define the proxy classes
*/
- private Class defineClass(String name, URL url) throws IOException {
+ private Class<?> defineClass(String name, URL url) throws IOException {
byte[] b = getBytes(url);
CodeSource cs = new CodeSource(null, (java.security.cert.Certificate[])null);
if (!name.equals(TRAMPOLINE)) {
@@ -389,7 +385,7 @@
return perms;
}
- private static Class getTrampolineClass() {
+ private static Class<?> getTrampolineClass() {
try {
return Class.forName(TRAMPOLINE, true, new MethodUtil());
} catch (ClassNotFoundException e) {
diff --git a/src/share/classes/sun/reflect/misc/ReflectUtil.java b/src/share/classes/sun/reflect/misc/ReflectUtil.java
index 94d0b18..8b1efd5 100644
--- a/src/share/classes/sun/reflect/misc/ReflectUtil.java
+++ b/src/share/classes/sun/reflect/misc/ReflectUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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
@@ -34,13 +34,13 @@
private ReflectUtil() {
}
- public static Class forName(String name)
+ public static Class<?> forName(String name)
throws ClassNotFoundException {
checkPackageAccess(name);
return Class.forName(name);
}
- public static Object newInstance(Class cls)
+ public static Object newInstance(Class<?> cls)
throws InstantiationException, IllegalAccessException {
checkPackageAccess(cls);
return cls.newInstance();
@@ -50,8 +50,8 @@
* Reflection.ensureMemberAccess is overly-restrictive
* due to a bug. We awkwardly work around it for now.
*/
- public static void ensureMemberAccess(Class currentClass,
- Class memberClass,
+ public static void ensureMemberAccess(Class<?> currentClass,
+ Class<?> memberClass,
Object target,
int modifiers)
throws IllegalAccessException
@@ -102,8 +102,8 @@
}
}
- private static boolean isSubclassOf(Class queryClass,
- Class ofClass)
+ private static boolean isSubclassOf(Class<?> queryClass,
+ Class<?> ofClass)
{
while (queryClass != null) {
if (queryClass == ofClass) {
@@ -115,7 +115,7 @@
}
- public static void checkPackageAccess(Class clazz) {
+ public static void checkPackageAccess(Class<?> clazz) {
checkPackageAccess(clazz.getName());
}
@@ -136,7 +136,7 @@
}
}
- public static boolean isPackageAccessible(Class clazz) {
+ public static boolean isPackageAccessible(Class<?> clazz) {
try {
checkPackageAccess(clazz);
} catch (SecurityException e) {
diff --git a/src/share/classes/sun/security/ssl/SSLContextImpl.java b/src/share/classes/sun/security/ssl/SSLContextImpl.java
index 205c80e..b802604 100644
--- a/src/share/classes/sun/security/ssl/SSLContextImpl.java
+++ b/src/share/classes/sun/security/ssl/SSLContextImpl.java
@@ -567,42 +567,46 @@
}
FileInputStream fs = null;
- if (defaultKeyStore.length() != 0 && !NONE.equals(defaultKeyStore)) {
- fs = AccessController.doPrivileged(
- new PrivilegedExceptionAction<FileInputStream>() {
- public FileInputStream run() throws Exception {
- return new FileInputStream(defaultKeyStore);
- }
- });
- }
-
- String defaultKeyStorePassword = props.get("keyStorePasswd");
- char[] passwd = null;
- if (defaultKeyStorePassword.length() != 0) {
- passwd = defaultKeyStorePassword.toCharArray();
- }
-
- /**
- * Try to initialize key store.
- */
KeyStore ks = null;
- if ((defaultKeyStoreType.length()) != 0) {
- if (debug != null && Debug.isOn("defaultctx")) {
- System.out.println("init keystore");
- }
- if (defaultKeyStoreProvider.length() == 0) {
- ks = KeyStore.getInstance(defaultKeyStoreType);
- } else {
- ks = KeyStore.getInstance(defaultKeyStoreType,
- defaultKeyStoreProvider);
+ char[] passwd = null;
+ try {
+ if (defaultKeyStore.length() != 0 &&
+ !NONE.equals(defaultKeyStore)) {
+ fs = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<FileInputStream>() {
+ public FileInputStream run() throws Exception {
+ return new FileInputStream(defaultKeyStore);
+ }
+ });
}
- // if defaultKeyStore is NONE, fs will be null
- ks.load(fs, passwd);
- }
- if (fs != null) {
- fs.close();
- fs = null;
+ String defaultKeyStorePassword = props.get("keyStorePasswd");
+ if (defaultKeyStorePassword.length() != 0) {
+ passwd = defaultKeyStorePassword.toCharArray();
+ }
+
+ /**
+ * Try to initialize key store.
+ */
+ if ((defaultKeyStoreType.length()) != 0) {
+ if (debug != null && Debug.isOn("defaultctx")) {
+ System.out.println("init keystore");
+ }
+ if (defaultKeyStoreProvider.length() == 0) {
+ ks = KeyStore.getInstance(defaultKeyStoreType);
+ } else {
+ ks = KeyStore.getInstance(defaultKeyStoreType,
+ defaultKeyStoreProvider);
+ }
+
+ // if defaultKeyStore is NONE, fs will be null
+ ks.load(fs, passwd);
+ }
+ } finally {
+ if (fs != null) {
+ fs.close();
+ fs = null;
+ }
}
/*
diff --git a/src/share/classes/sun/security/ssl/SSLSocketImpl.java b/src/share/classes/sun/security/ssl/SSLSocketImpl.java
index d12eaf1..8990793 100644
--- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java
+++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java
@@ -2443,11 +2443,12 @@
entrySet, HandshakeCompletedEvent e) {
super("HandshakeCompletedNotify-Thread");
- targets = entrySet;
+ targets = new HashSet<>(entrySet); // clone the entry set
event = e;
}
public void run() {
+ // Don't need to synchronize, as it only runs in one thread.
for (Map.Entry<HandshakeCompletedListener,AccessControlContext>
entry : targets) {
diff --git a/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java b/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
index ee2142c..fbd6801 100644
--- a/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
+++ b/src/share/classes/sun/security/ssl/TrustManagerFactoryImpl.java
@@ -164,72 +164,75 @@
* If none exists, we use an empty keystore.
*/
- storeFileName = props.get("trustStore");
- if (!"NONE".equals(storeFileName)) {
- if (storeFileName != null) {
- storeFile = new File(storeFileName);
- fis = getFileInputStream(storeFile);
- } else {
- String javaHome = props.get("javaHome");
- storeFile = new File(javaHome + sep + "lib" + sep
- + "security" + sep +
- "jssecacerts");
- if ((fis = getFileInputStream(storeFile)) == null) {
- storeFile = new File(javaHome + sep + "lib" + sep
- + "security" + sep +
- "cacerts");
+ try {
+ storeFileName = props.get("trustStore");
+ if (!"NONE".equals(storeFileName)) {
+ if (storeFileName != null) {
+ storeFile = new File(storeFileName);
fis = getFileInputStream(storeFile);
+ } else {
+ String javaHome = props.get("javaHome");
+ storeFile = new File(javaHome + sep + "lib" + sep
+ + "security" + sep +
+ "jssecacerts");
+ if ((fis = getFileInputStream(storeFile)) == null) {
+ storeFile = new File(javaHome + sep + "lib" + sep
+ + "security" + sep +
+ "cacerts");
+ fis = getFileInputStream(storeFile);
+ }
+ }
+
+ if (fis != null) {
+ storeFileName = storeFile.getPath();
+ } else {
+ storeFileName = "No File Available, using empty keystore.";
}
}
- if (fis != null) {
- storeFileName = storeFile.getPath();
- } else {
- storeFileName = "No File Available, using empty keystore.";
- }
- }
-
- defaultTrustStoreType = props.get("trustStoreType");
- defaultTrustStoreProvider = props.get("trustStoreProvider");
- if (debug != null && Debug.isOn(dbgname)) {
- System.out.println("trustStore is: " + storeFileName);
- System.out.println("trustStore type is : " +
- defaultTrustStoreType);
- System.out.println("trustStore provider is : " +
- defaultTrustStoreProvider);
- }
-
- /*
- * Try to initialize trust store.
- */
- if (defaultTrustStoreType.length() != 0) {
+ defaultTrustStoreType = props.get("trustStoreType");
+ defaultTrustStoreProvider = props.get("trustStoreProvider");
if (debug != null && Debug.isOn(dbgname)) {
- System.out.println("init truststore");
+ System.out.println("trustStore is: " + storeFileName);
+ System.out.println("trustStore type is : " +
+ defaultTrustStoreType);
+ System.out.println("trustStore provider is : " +
+ defaultTrustStoreProvider);
}
- if (defaultTrustStoreProvider.length() == 0) {
- ks = KeyStore.getInstance(defaultTrustStoreType);
- } else {
- ks = KeyStore.getInstance(defaultTrustStoreType,
- defaultTrustStoreProvider);
- }
- char[] passwd = null;
- String defaultTrustStorePassword = props.get("trustStorePasswd");
- if (defaultTrustStorePassword.length() != 0)
- passwd = defaultTrustStorePassword.toCharArray();
- // if trustStore is NONE, fis will be null
- ks.load(fis, passwd);
+ /*
+ * Try to initialize trust store.
+ */
+ if (defaultTrustStoreType.length() != 0) {
+ if (debug != null && Debug.isOn(dbgname)) {
+ System.out.println("init truststore");
+ }
+ if (defaultTrustStoreProvider.length() == 0) {
+ ks = KeyStore.getInstance(defaultTrustStoreType);
+ } else {
+ ks = KeyStore.getInstance(defaultTrustStoreType,
+ defaultTrustStoreProvider);
+ }
+ char[] passwd = null;
+ String defaultTrustStorePassword =
+ props.get("trustStorePasswd");
+ if (defaultTrustStorePassword.length() != 0)
+ passwd = defaultTrustStorePassword.toCharArray();
- // Zero out the temporary password storage
- if (passwd != null) {
- for (int i = 0; i < passwd.length; i++) {
- passwd[i] = (char)0;
+ // if trustStore is NONE, fis will be null
+ ks.load(fis, passwd);
+
+ // Zero out the temporary password storage
+ if (passwd != null) {
+ for (int i = 0; i < passwd.length; i++) {
+ passwd[i] = (char)0;
+ }
}
}
- }
-
- if (fis != null) {
- fis.close();
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
}
return ks;
diff --git a/src/share/classes/sun/util/locale/LocaleObjectCache.java b/src/share/classes/sun/util/locale/LocaleObjectCache.java
index 35504bc..88920aa 100644
--- a/src/share/classes/sun/util/locale/LocaleObjectCache.java
+++ b/src/share/classes/sun/util/locale/LocaleObjectCache.java
@@ -66,14 +66,14 @@
CacheEntry<K, V> newEntry = new CacheEntry<>(key, newVal, queue);
- while (value == null) {
- cleanStaleEntries();
- entry = map.putIfAbsent(key, newEntry);
- if (entry == null) {
+ entry = map.putIfAbsent(key, newEntry);
+ if (entry == null) {
+ value = newVal;
+ } else {
+ value = entry.get();
+ if (value == null) {
+ map.put(key, newEntry);
value = newVal;
- break;
- } else {
- value = entry.get();
}
}
}
diff --git a/test/ProblemList.txt b/test/ProblemList.txt
index c672c7f..2b9eaa9 100644
--- a/test/ProblemList.txt
+++ b/test/ProblemList.txt
@@ -349,10 +349,19 @@
# Only print test left, excluding just because all print tests have been
javax/print/attribute/MediaMappingsTest.java generic-all
+# Filed 7058852
+javax/sound/sampled/FileWriter/AlawEncoderSync.java generic-all
+
############################################################################
# jdk_net
+# Filed 7052625
+com/sun/net/httpserver/bugs/6725892/Test.java generic-all
+
+# Filed 7036666
+com/sun/net/httpserver/Test9a.java generic-all
+
############################################################################
# jdk_io
@@ -528,9 +537,6 @@
sun/security/provider/PolicyFile/getinstance/getinstance.sh solaris-sparc
sun/security/tools/jarsigner/samename.sh solaris-sparc
-# Timed out, Solaris 10 64bit sparcv9
-com/sun/crypto/provider/Cipher/DES/PaddingTest.java generic-all
-
# Othervm, sparc, NoRouteToHostException: Cannot assign requested address
sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all
@@ -605,6 +611,18 @@
# Filed 6952105
com/sun/jdi/SuspendThreadTest.java generic-all
+# Filed 6653793
+com/sun/jdi/RedefineCrossEvent.java generic-all
+
+# Filed 6987312
+com/sun/jdi/DoubleAgentTest.java generic-all
+
+# Filed 7020857
+com/sun/jdi/FieldWatchpoints.java generic-all
+
+# Filed 6402201
+com/sun/jdi/ProcessAttachTest.sh generic-all
+
# Filed 6986875
sun/tools/jps/jps-Vvml.sh generic-all
@@ -626,18 +644,8 @@
# 11 separate stacktraces created... file reuse problem?
java/util/zip/ZipFile/ReadLongZipFileName.java generic-all
-# Assert error, failures, on Linux Fedora 9 -server
-# Windows samevm failure, assert error "Passed = 134, failed = 2"
-java/util/Arrays/ArrayObjectMethods.java generic-all
-
-# Windows 2000, -client, samevm, java.lang.Error: Completed != 2
+# Filed 6772009
java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
-# Windows X64, Executor Stuck samevm mode:
-java/util/concurrent/FutureTask/BlockingTaskExecutor.java generic-all
-
-# Problems on windows, jmap.exe hangs? (these run jmap), fails on Solaris 10 x86
-java/util/concurrent/locks/Lock/TimedAcquireLeak.java generic-all
-
############################################################################
diff --git a/test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java b/test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java
index fa61e3f..bbd6621 100644
--- a/test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java
+++ b/test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -23,16 +23,17 @@
/*
* @test
- * @bug 0000000 6296075
+ * @bug 0000000 6296075 6330275
* @summary PaddingTest
* @author Jan Luehe
*/
import java.io.*;
-import java.security.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;
-import com.sun.crypto.provider.*;
+import java.util.Arrays;
public class PaddingTest {
@@ -80,7 +81,7 @@
public void run() throws Exception {
for (int l=0; l<numFiles; l++) {
- pinfile = new String(dataDir + "plain" + l + ".txt");
+ pinfile = dataDir + "plain" + l + ".txt";
for (int i=0; i<crypts.length; i++) {
for (int j=0; j<modes.length; j++) {
for (int k=0; k<paddings.length; k++) {
@@ -89,14 +90,12 @@
System.out.println
(crypts[i]+" "+modes[j]+" " + paddings[k]+ " " +
"plain" + l + " test");
- cfile = new String
- ("c" + l + "_" +
+ cfile = "c" + l + "_" +
crypts[i] + "_" +
modes[j] + "_" +
- paddings[k] + ".bin");
- poutfile = new String
- ("p" + l +
- "_" + crypts[i] + modes[j] + paddings[k] + ".txt");
+ paddings[k] + ".bin";
+ poutfile = "p" + l +
+ "_" + crypts[i] + modes[j] + paddings[k] + ".txt";
init(crypts[i], modes[j], paddings[k]);
padding = paddings[k];
@@ -108,10 +107,7 @@
}
public void init(String crypt, String mode, String padding)
- throws Exception {
-
- SunJCE jce = new SunJCE();
- Security.addProvider(jce);
+ throws Exception {
KeySpec desKeySpec = null;
SecretKeyFactory factory = null;
@@ -148,82 +144,60 @@
int len;
int totalInputLen = 0;
- BufferedInputStream pin = null;
- BufferedOutputStream cout = null;
- BufferedInputStream cin = null;
- BufferedOutputStream pout = null;
-
try {
- pin = new BufferedInputStream(new FileInputStream(pinfile));
- cout = new BufferedOutputStream(new FileOutputStream(cfile));
- cipher.init(Cipher.ENCRYPT_MODE, cipherKey, params);
+ try (FileInputStream fin = new FileInputStream(pinfile);
+ BufferedInputStream pin = new BufferedInputStream(fin);
+ FileOutputStream fout = new FileOutputStream(cfile);
+ BufferedOutputStream cout = new BufferedOutputStream(fout)) {
+ cipher.init(Cipher.ENCRYPT_MODE, cipherKey, params);
- while ((len = pin.read(input, 0, bufferLen)) > 0) {
- totalInputLen += len;
- byte[] output = cipher.update(input, 0, len);
- cout.write(output, 0, output.length);
- cout.flush();
+ while ((len = pin.read(input, 0, bufferLen)) > 0) {
+ totalInputLen += len;
+ byte[] output = cipher.update(input, 0, len);
+ cout.write(output, 0, output.length);
+ }
+
+ len = cipher.getOutputSize(0);
+
+ byte[] out = new byte[len];
+ len = cipher.doFinal(out, 0);
+ cout.write(out, 0, len);
}
- len = cipher.getOutputSize(0);
+ try (FileInputStream fin = new FileInputStream(cfile);
+ BufferedInputStream cin = new BufferedInputStream(fin);
+ FileOutputStream fout = new FileOutputStream(poutfile);
+ BufferedOutputStream pout = new BufferedOutputStream(fout)) {
+ cipher.init(Cipher.DECRYPT_MODE, cipherKey, params);
- byte[] out = new byte[len];
- len = cipher.doFinal(out, 0);
- cout.write(out, 0, len);
- cout.flush();
+ byte[] output = null;
+ while ((len = cin.read(input, 0, bufferLen)) > 0) {
+ output = cipher.update(input, 0, len);
+ pout.write(output, 0, output.length);
+ }
- cin = new BufferedInputStream(new FileInputStream(cfile));
- pout = new BufferedOutputStream(new FileOutputStream(poutfile));
- cipher.init(Cipher.DECRYPT_MODE, cipherKey, params);
-
- byte[] output = null;
- while ((len = cin.read(input, 0, bufferLen)) > 0) {
- output = cipher.update(input, 0, len);
- pout.write(output, 0, output.length);
- pout.flush();
+ len = cipher.getOutputSize(0);
+ byte[] out = new byte[len];
+ len = cipher.doFinal(out, 0);
+ pout.write(out, 0, len);
}
- len = cipher.getOutputSize(0);
- out = new byte[len];
- len = cipher.doFinal(out, 0);
- pout.write(out, 0, len);
- pout.flush();
-
- Process child = Runtime.getRuntime().exec
- ("diff " + pinfile + " " + poutfile);
- InputStream in = child.getInputStream();
- byte[] data = new byte[64];
-
- while((len = in.read(data)) != -1)
- System.out.write(data, 0, len);
- in.close();
- child.waitFor();
- System.out.println("child exited with " + child.exitValue());
- }
- catch (IllegalBlockSizeException ex) {
- if ((totalInputLen % 8 != 0) && (padding.equals("NoPadding")))
+ diff(pinfile, poutfile);
+ } catch (IllegalBlockSizeException ex) {
+ if ((totalInputLen % 8 != 0) && (padding.equals("NoPadding"))) {
return;
- else {
+ } else {
System.out.println("Test failed!");
throw ex;
}
}
- finally {
- try {
- if (pin != null)
- pin.close();
- if (pout != null)
- pout.close();
- if (cin != null)
- cin.close();
- if (cout != null)
- cout.close();
- }
- catch (IOException e) {
- e.printStackTrace();
- return;
- }
- }
}
+ private static void diff(String fname1, String fname2) throws Exception {
+ if (!Arrays.equals(Files.readAllBytes(Paths.get(fname1)),
+ Files.readAllBytes(Paths.get(fname1)))) {
+ throw new Exception(
+ "files " + fname1 + " and " + fname2 + " differ");
+ }
+ }
}
diff --git a/test/com/sun/jndi/ldap/InvalidLdapFilters.java b/test/com/sun/jndi/ldap/InvalidLdapFilters.java
index e0e0e90..a28b2d9 100644
--- a/test/com/sun/jndi/ldap/InvalidLdapFilters.java
+++ b/test/com/sun/jndi/ldap/InvalidLdapFilters.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 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
@@ -23,8 +23,10 @@
/**
* @test
- * @bug 6916202
+ * @bug 6916202 7041125
* @summary More cases of invalid ldap filters accepted and processed
+ * LDAP API does not catch malformed filters that contain two operands
+ * for the ! operator
* @run main/othervm InvalidLdapFilters valid (cn=Babs)
* @run main/othervm InvalidLdapFilters valid (&(cn=Bob))
* @run main/othervm InvalidLdapFilters valid (&(objectClass=*)(uid=*))
@@ -34,6 +36,7 @@
* @run main/othervm InvalidLdapFilters valid (!(!(cn=Tim)))
* @run main/othervm InvalidLdapFilters valid (!(&(objectClass=*)(uid=*)))
* @run main/othervm InvalidLdapFilters valid (!(|(objectClass=*)(uid=*)))
+ * @run main/othervm InvalidLdapFilters valid (&(objectClass=*)(!(uid=*)))
* @run main/othervm InvalidLdapFilters valid (o=univ*of*mich*)
* @run main/othervm InvalidLdapFilters valid (seeAlso=)
* @run main/othervm InvalidLdapFilters valid (cn:caseExactMatch:=Flintstone)
@@ -75,6 +78,8 @@
"((objectCategory=person)(cn=u)(!(cn=u2*)))"
* @run main/othervm InvalidLdapFilters invalid
"((&(objectClass=user)(cn=andy*)(cn=steve*)(cn=bob*)))"
+ * @run main/othervm InvalidLdapFilters invalid
+ (&(objectClass=Person)(!(sn=Jensen)(cn=Bab)))
*
* @author Xuelei Fan
*/
diff --git a/test/com/sun/net/httpserver/Test1.java b/test/com/sun/net/httpserver/Test1.java
index c8d784d..e0da2ce 100644
--- a/test/com/sun/net/httpserver/Test1.java
+++ b/test/com/sun/net/httpserver/Test1.java
@@ -26,6 +26,7 @@
* @bug 6270015
* @run main/othervm Test1
* @run main/othervm -Dsun.net.httpserver.maxReqTime=10 Test1
+ * @run main/othervm -Dsun.net.httpserver.nodelay=true Test1
* @summary Light weight HTTP server
*/
@@ -42,6 +43,10 @@
* - send/receive large/small file
* - chunked encoding
* - via http and https
+ *
+ * The test is also run with sun.net.httpserver.nodelay simply to exercise
+ * this option. There is no specific pass or failure related to running with
+ * this option.
*/
public class Test1 extends Test {
diff --git a/test/java/net/SocketPermission/Wildcard.java b/test/java/net/SocketPermission/Wildcard.java
new file mode 100644
index 0000000..d99fb4f
--- /dev/null
+++ b/test/java/net/SocketPermission/Wildcard.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 7021280
+ * @summary SocketPermission should accept wildcards
+ */
+
+import java.net.SocketPermission;
+
+public class Wildcard
+{
+ public static void main(String[] args) throws Exception {
+ SocketPermission star_All =
+ new SocketPermission("*.blabla.bla", "listen,accept,connect");
+ SocketPermission www_All =
+ new SocketPermission("bla.blabla.bla", "listen,accept,connect");
+
+ if (!star_All.implies(www_All)) {
+ throw new RuntimeException(
+ "Failed: " + star_All + " does not imply " + www_All);
+ }
+ }
+}
diff --git a/test/java/util/Locale/LocaleCategory.sh b/test/java/util/Locale/LocaleCategory.sh
index 8544f4d..bbe32ff 100644
--- a/test/java/util/Locale/LocaleCategory.sh
+++ b/test/java/util/Locale/LocaleCategory.sh
@@ -34,7 +34,7 @@
PS=":"
FS="/"
;;
- Windows* )
+ Windows* | CYGWIN* )
PS=";"
FS="\\"
;;
diff --git a/test/java/util/concurrent/Executors/AutoShutdown.java b/test/java/util/concurrent/Executors/AutoShutdown.java
index eff5759..449b81d 100644
--- a/test/java/util/concurrent/Executors/AutoShutdown.java
+++ b/test/java/util/concurrent/Executors/AutoShutdown.java
@@ -67,6 +67,11 @@
e1 = e2 = null;
for (int i = 0; i < 10 && Thread.activeCount() > count0; i++)
tryWaitForFinalizersToRun();
+ for (int i = 0; i < 10; ++i) { // give JVM a chance to settle.
+ if (Thread.activeCount() == count0)
+ return;
+ Thread.sleep(1000);
+ }
equal(Thread.activeCount(), count0);
}
diff --git a/test/java/util/concurrent/Phaser/Arrive.java b/test/java/util/concurrent/Phaser/Arrive.java
index 0787176..1a93153 100644
--- a/test/java/util/concurrent/Phaser/Arrive.java
+++ b/test/java/util/concurrent/Phaser/Arrive.java
@@ -45,9 +45,12 @@
public class Arrive {
void test(String[] args) throws Throwable {
+ for (int i = 0; i < 100; ++i)
+ doTest(args);
+ }
+ void doTest(String[] args) throws Throwable {
final int n = ThreadLocalRandom.current().nextInt(1, 10);
- final int nthreads = n*3/2;
- final Phaser startingGate = new Phaser(nthreads);
+ final Phaser startingGate = new Phaser(n);
final Phaser phaser = new Phaser(n);
final List<Thread> threads = new ArrayList<Thread>();
final AtomicInteger count0 = new AtomicInteger(0);
@@ -64,14 +67,14 @@
else
fail();
}};
- for (int i = 0; i < nthreads; i++)
+ for (int i = 0; i < n; i++)
threads.add(new Thread(task));
for (Thread thread : threads)
thread.start();
for (Thread thread : threads)
thread.join();
equal(count0.get(), n);
- equal(count1.get(), nthreads-n);
+ equal(count1.get(), 0);
equal(phaser.getPhase(), 1);
}
diff --git a/test/tools/launcher/Arrrghs.java b/test/tools/launcher/Arrrghs.java
index c9b82e7..f505b7e 100644
--- a/test/tools/launcher/Arrrghs.java
+++ b/test/tools/launcher/Arrrghs.java
@@ -24,7 +24,7 @@
/**
* @test
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
- * 6894719 6968053
+ * 6894719 6968053 7067922
* @summary Argument parsing validation.
* @compile -XDignore.symbol.file Arrrghs.java TestHelper.java
* @run main Arrrghs
@@ -362,6 +362,16 @@
tr.checkPositive();
System.out.println(tr);
}
+
+ static void test7067922() {
+ // a missing manifest entry 7067922
+ TestHelper.TestResult tr = null;
+ TestHelper.createJar("cvf", "missingmainentry.jar", ".");
+ tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "missingmainentry.jar");
+ tr.contains("no main manifest attribute");
+ System.out.println(tr);
+ }
+
/**
* @param args the command line arguments
* @throws java.io.FileNotFoundException
@@ -374,6 +384,7 @@
runBasicErrorMessageTests();
runMainMethodTests();
test6894719();
+ test7067922();
runDiagOptionTests();
if (TestHelper.testExitValue > 0) {
System.out.println("Total of " + TestHelper.testExitValue + " failed");
diff --git a/test/tools/launcher/TestHelper.java b/test/tools/launcher/TestHelper.java
index ca20e3e..f299736 100644
--- a/test/tools/launcher/TestHelper.java
+++ b/test/tools/launcher/TestHelper.java
@@ -171,15 +171,15 @@
if (jarName.exists()) {
jarName.delete();
}
- PrintStream ps = new PrintStream(new FileOutputStream(mainClass + ".java"));
- ps.println("public class Foo {");
- if (mainDefs != null) {
- for (String x : mainDefs) {
- ps.println(x);
+ try (PrintStream ps = new PrintStream(new FileOutputStream(mainClass + ".java"))) {
+ ps.println("public class Foo {");
+ if (mainDefs != null) {
+ for (String x : mainDefs) {
+ ps.println(x);
+ }
}
+ ps.println("}");
}
- ps.println("}");
- ps.close();
String compileArgs[] = {
mainClass + ".java"
@@ -196,12 +196,20 @@
mEntry,
mainClass.getName() + ".class"
};
+ createJar(jarArgs);
+ }
+
+ static void createJar(String... args) {
sun.tools.jar.Main jarTool =
new sun.tools.jar.Main(System.out, System.err, "JarCreator");
- if (!jarTool.run(jarArgs)) {
- throw new RuntimeException("jar creation failed " + jarName);
+ if (!jarTool.run(args)) {
+ String message = "jar creation failed with command:";
+ for (String x : args) {
+ message = message.concat(" " + x);
+ }
+ throw new RuntimeException(message);
}
- }
+ }
static void copyFile(File src, File dst) throws IOException {
Path parent = dst.toPath().getParent();