--- a/jdk/make/GenerateData.gmk Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/make/GenerateData.gmk Tue Jul 01 10:20:56 2014 -0700
@@ -62,7 +62,7 @@
##########################################################################################
-GENDATA_CURDATA := $(JDK_OUTPUTDIR)/lib/currency.data
+GENDATA_CURDATA := $(JDK_OUTPUTDIR)/classes/java/util/currency.data
$(GENDATA_CURDATA): $(JDK_TOPDIR)/make/data/currency/CurrencyData.properties $(BUILD_TOOLS)
$(MKDIR) -p $(@D)
--- a/jdk/make/Setup.gmk Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/make/Setup.gmk Tue Jul 01 10:20:56 2014 -0700
@@ -27,7 +27,7 @@
# To build with all warnings enabled, do the following:
# make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000"
-JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,auxiliaryclass,cast,classfile,dep-ann,divzero,empty,fallthrough,finally,overloads,serial,static,try,varargs -Werror
+JAVAC_WARNINGS := -Xlint:all,-deprecation,-rawtypes,-unchecked -Werror
# Any java code executed during a JDK build to build other parts of the JDK must be
# executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this
--- a/jdk/make/profile-includes.txt Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/make/profile-includes.txt Tue Jul 01 10:20:56 2014 -0700
@@ -56,7 +56,6 @@
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
calendars.properties \
classlist \
- currency.data \
ext/localedata.jar \
ext/meta-index \
ext/sunec.jar \
--- a/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/make/src/native/genconstants/ch/genSocketOptionRegistry.c Tue Jul 01 10:20:56 2014 -0700
@@ -110,6 +110,7 @@
emit_inet("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IP, IP_MULTICAST_LOOP);
#ifdef AF_INET6
+ emit_inet6("StandardSocketOptions.IP_TOS", IPPROTO_IPV6, IPV6_TCLASS);
emit_inet6("StandardSocketOptions.IP_MULTICAST_IF", IPPROTO_IPV6, IPV6_MULTICAST_IF);
emit_inet6("StandardSocketOptions.IP_MULTICAST_TTL", IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
emit_inet6("StandardSocketOptions.IP_MULTICAST_LOOP", IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
--- a/jdk/src/macosx/classes/sun/font/CStrike.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/macosx/classes/sun/font/CStrike.java Tue Jul 01 10:20:56 2014 -0700
@@ -415,7 +415,7 @@
generalCache = new HashMap<Integer, Long>();
}
- generalCache.put(new Integer(index), new Long(value));
+ generalCache.put(new Integer(index), Long.valueOf(value));
}
public synchronized void dispose() {
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java Tue Jul 01 10:20:56 2014 -0700
@@ -616,7 +616,7 @@
return index;
}
- Long l1 = new Long(stream.getStreamPosition());
+ Long l1 = stream.getStreamPosition();
imageStartPosition.add(l1);
++index;
}
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Tue Jul 01 10:20:56 2014 -0700
@@ -367,10 +367,10 @@
// Now we are at the first image if there are any, so add it
// to the list
if (hasNextImage()) {
- imagePositions.add(new Long(iis.getStreamPosition()));
+ imagePositions.add(iis.getStreamPosition());
}
} else { // Not tables only, so add original pos to the list
- imagePositions.add(new Long(savePos));
+ imagePositions.add(savePos);
// And set current image since we've read it now
currentImage = 0;
}
@@ -498,7 +498,7 @@
if (!hasNextImage()) {
throw new IndexOutOfBoundsException();
}
- pos = new Long(iis.getStreamPosition());
+ pos = iis.getStreamPosition();
imagePositions.add(pos);
if (seekForwardOnly) {
iis.flushBefore(pos.longValue());
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Tue Jul 01 10:20:56 2014 -0700
@@ -1102,8 +1102,7 @@
"PasswordField.selectionBackground", SelectionBackgroundColor,
"PasswordField.selectionForeground", SelectionTextColor,
"PasswordField.caretForeground",WindowTextColor,
- "PasswordField.echoChar", new XPValue(new Character((char)0x25CF),
- new Character('*')),
+ "PasswordField.echoChar", new XPValue((char)0x25CF, '*'),
// *** ProgressBar
"ProgressBar.font", ControlFont,
--- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpCounter64.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpCounter64.java Tue Jul 01 10:20:56 2014 -0700
@@ -84,7 +84,7 @@
* @return The <CODE>Long</CODE> representation of the value.
*/
public Long toLong() {
- return new Long(value) ;
+ return value;
}
/**
--- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpInt.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpInt.java Tue Jul 01 10:20:56 2014 -0700
@@ -130,7 +130,7 @@
* @return The <CODE>Long</CODE> representation of the value.
*/
public Long toLong() {
- return new Long(value) ;
+ return value;
}
/**
--- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java Tue Jul 01 10:20:56 2014 -0700
@@ -140,7 +140,7 @@
public Byte[] toByte() {
Byte[] result = new Byte[value.length] ;
for (int i = 0 ; i < value.length ; i++) {
- result[i] = new Byte(value[i]) ;
+ result[i] = value[i];
}
return result ;
}
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMibGroup.java Tue Jul 01 10:20:56 2014 -0700
@@ -136,7 +136,7 @@
*/
public boolean isNestedArc(long arc) {
if (subgroups == null) return false;
- Object obj = subgroups.get(new Long(arc));
+ Object obj = subgroups.get(arc);
// if the arc is registered in the hashtable,
// it leads to a subgroup.
return (obj != null);
@@ -260,7 +260,7 @@
*
*/
void registerNestedArc(long arc) {
- Long obj = new Long(arc);
+ Long obj = arc;
if (subgroups == null) subgroups = new Hashtable<>();
// registers the arc in the hashtable.
subgroups.put(obj,obj);
--- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/SnmpAdaptorServer.java Tue Jul 01 10:20:56 2014 -0700
@@ -858,7 +858,7 @@
*/
@Override
public Long getSnmpOutTraps() {
- return new Long(snmpOutTraps);
+ return (long)snmpOutTraps;
}
/**
@@ -868,7 +868,7 @@
*/
@Override
public Long getSnmpOutGetResponses() {
- return new Long(snmpOutGetResponses);
+ return (long)snmpOutGetResponses;
}
/**
@@ -878,7 +878,7 @@
*/
@Override
public Long getSnmpOutGenErrs() {
- return new Long(snmpOutGenErrs);
+ return (long)snmpOutGenErrs;
}
/**
@@ -888,7 +888,7 @@
*/
@Override
public Long getSnmpOutBadValues() {
- return new Long(snmpOutBadValues);
+ return (long)snmpOutBadValues;
}
/**
@@ -898,7 +898,7 @@
*/
@Override
public Long getSnmpOutNoSuchNames() {
- return new Long(snmpOutNoSuchNames);
+ return (long)snmpOutNoSuchNames;
}
/**
@@ -908,7 +908,7 @@
*/
@Override
public Long getSnmpOutTooBigs() {
- return new Long(snmpOutTooBigs);
+ return (long)snmpOutTooBigs;
}
/**
@@ -918,7 +918,7 @@
*/
@Override
public Long getSnmpInASNParseErrs() {
- return new Long(snmpInASNParseErrs);
+ return (long)snmpInASNParseErrs;
}
/**
@@ -928,7 +928,7 @@
*/
@Override
public Long getSnmpInBadCommunityUses() {
- return new Long(snmpInBadCommunityUses);
+ return (long)snmpInBadCommunityUses;
}
/**
@@ -939,7 +939,7 @@
*/
@Override
public Long getSnmpInBadCommunityNames() {
- return new Long(snmpInBadCommunityNames);
+ return (long)snmpInBadCommunityNames;
}
/**
@@ -949,7 +949,7 @@
*/
@Override
public Long getSnmpInBadVersions() {
- return new Long(snmpInBadVersions);
+ return (long)snmpInBadVersions;
}
/**
@@ -959,7 +959,7 @@
*/
@Override
public Long getSnmpOutPkts() {
- return new Long(snmpOutPkts);
+ return (long)snmpOutPkts;
}
/**
@@ -969,7 +969,7 @@
*/
@Override
public Long getSnmpInPkts() {
- return new Long(snmpInPkts);
+ return (long)snmpInPkts;
}
/**
@@ -979,7 +979,7 @@
*/
@Override
public Long getSnmpInGetRequests() {
- return new Long(snmpInGetRequests);
+ return (long)snmpInGetRequests;
}
/**
@@ -989,7 +989,7 @@
*/
@Override
public Long getSnmpInGetNexts() {
- return new Long(snmpInGetNexts);
+ return (long)snmpInGetNexts;
}
/**
@@ -999,7 +999,7 @@
*/
@Override
public Long getSnmpInSetRequests() {
- return new Long(snmpInSetRequests);
+ return (long)snmpInSetRequests;
}
/**
@@ -1009,7 +1009,7 @@
*/
@Override
public Long getSnmpInTotalSetVars() {
- return new Long(snmpInTotalSetVars);
+ return (long)snmpInTotalSetVars;
}
/**
@@ -1019,7 +1019,7 @@
*/
@Override
public Long getSnmpInTotalReqVars() {
- return new Long(snmpInTotalReqVars);
+ return (long)snmpInTotalReqVars;
}
/**
@@ -1032,7 +1032,7 @@
*/
@Override
public Long getSnmpSilentDrops() {
- return new Long(snmpSilentDrops);
+ return (long)snmpSilentDrops;
}
/**
@@ -1045,7 +1045,7 @@
*/
@Override
public Long getSnmpProxyDrops() {
- return new Long(0);
+ return 0L;
}
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapPoolManager.java Tue Jul 01 10:20:56 2014 -0700
@@ -421,7 +421,7 @@
try {
return Long.getLong(propName, defVal);
} catch (SecurityException e) {
- return new Long(defVal);
+ return defVal;
}
}
});
--- a/jdk/src/share/classes/com/sun/jndi/ldap/NamingEventNotifier.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/NamingEventNotifier.java Tue Jul 01 10:20:56 2014 -0700
@@ -221,7 +221,7 @@
return;
NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_ADDED,
- newBd, null, new Long(changeID));
+ newBd, null, changeID);
support.queueEvent(e, namingListeners);
}
@@ -233,7 +233,7 @@
return;
NamingEvent e = new NamingEvent(eventSrc, NamingEvent.OBJECT_REMOVED,
- null, oldBd, new Long(changeID));
+ null, oldBd, changeID);
support.queueEvent(e, namingListeners);
}
@@ -248,7 +248,7 @@
Binding oldBd = new Binding(newBd.getName(), null, newBd.isRelative());
NamingEvent e = new NamingEvent(
- eventSrc, NamingEvent.OBJECT_CHANGED, newBd, oldBd, new Long(changeID));
+ eventSrc, NamingEvent.OBJECT_CHANGED, newBd, oldBd, changeID);
support.queueEvent(e, namingListeners);
}
@@ -273,7 +273,7 @@
}
NamingEvent e = new NamingEvent(
- eventSrc, NamingEvent.OBJECT_RENAMED, newBd, oldBd, new Long(changeID));
+ eventSrc, NamingEvent.OBJECT_RENAMED, newBd, oldBd, changeID);
support.queueEvent(e, namingListeners);
}
--- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java Tue Jul 01 10:20:56 2014 -0700
@@ -379,7 +379,7 @@
// used for substring comparisons (where proto has "*" wildcards
private boolean substringMatch(String proto, String value) {
// simple case 1: "*" means attribute presence is being tested
- if(proto.equals(new Character(WILDCARD_TOKEN).toString())) {
+ if(proto.equals(Character.toString(WILDCARD_TOKEN))) {
if(debug) {System.out.println("simple presence assertion");}
return true;
}
--- a/jdk/src/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/auth/SolarisNumericGroupPrincipal.java Tue Jul 01 10:20:56 2014 -0700
@@ -110,7 +110,7 @@
*
*/
public SolarisNumericGroupPrincipal(long name, boolean primaryGroup) {
- this.name = (new Long(name)).toString();
+ this.name = Long.toString(name);
this.primaryGroup = primaryGroup;
}
@@ -137,7 +137,7 @@
* <code>SolarisNumericGroupPrincipal</code> as a long.
*/
public long longValue() {
- return ((new Long(name)).longValue());
+ return Long.parseLong(name);
}
/**
--- a/jdk/src/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/auth/SolarisNumericUserPrincipal.java Tue Jul 01 10:20:56 2014 -0700
@@ -96,7 +96,7 @@
* represented as a long.
*/
public SolarisNumericUserPrincipal(long name) {
- this.name = (new Long(name)).toString();
+ this.name = Long.toString(name);
}
/**
@@ -122,7 +122,7 @@
* <code>SolarisNumericUserPrincipal</code> as a long.
*/
public long longValue() {
- return ((new Long(name)).longValue());
+ return Long.parseLong(name);
}
/**
--- a/jdk/src/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/auth/UnixNumericGroupPrincipal.java Tue Jul 01 10:20:56 2014 -0700
@@ -102,7 +102,7 @@
*
*/
public UnixNumericGroupPrincipal(long name, boolean primaryGroup) {
- this.name = (new Long(name)).toString();
+ this.name = Long.toString(name);
this.primaryGroup = primaryGroup;
}
@@ -129,7 +129,7 @@
* <code>UnixNumericGroupPrincipal</code> as a long.
*/
public long longValue() {
- return ((new Long(name)).longValue());
+ return Long.parseLong(name);
}
/**
--- a/jdk/src/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/auth/UnixNumericUserPrincipal.java Tue Jul 01 10:20:56 2014 -0700
@@ -87,7 +87,7 @@
* represented as a long.
*/
public UnixNumericUserPrincipal(long name) {
- this.name = (new Long(name)).toString();
+ this.name = Long.toString(name);
}
/**
@@ -113,7 +113,7 @@
* <code>UnixNumericUserPrincipal</code> as a long.
*/
public long longValue() {
- return ((new Long(name)).longValue());
+ return Long.parseLong(name);
}
/**
--- a/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java Tue Jul 01 10:20:56 2014 -0700
@@ -1460,7 +1460,7 @@
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO,
"DIGEST39:Incorrect padding: {0}",
- new Byte(msgWithPadding[msgWithPadding.length - 1]));
+ msgWithPadding[msgWithPadding.length - 1]);
}
return EMPTY_BYTE_ARRAY;
}
--- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java Tue Jul 01 10:20:56 2014 -0700
@@ -241,7 +241,7 @@
"KRB5CLNT05:Challenge [unwrapped]:", gssOutToken);
}
logger.log(Level.FINE, "KRB5CLNT06:Server protections: {0}",
- new Byte(gssOutToken[0]));
+ gssOutToken[0]);
}
// Client selects preferred protection
@@ -293,7 +293,7 @@
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,
"KRB5CLNT08:Selected protection: {0}; privacy: {1}; integrity: {2}",
- new Object[]{new Byte(selectedQop),
+ new Object[]{selectedQop,
Boolean.valueOf(privacy),
Boolean.valueOf(integrity)});
}
--- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java Tue Jul 01 10:20:56 2014 -0700
@@ -221,7 +221,7 @@
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,
"KRB5SRV06:Supported protections: {0}; recv max buf size: {1}",
- new Object[]{new Byte(allQop),
+ new Object[]{allQop,
new Integer(recvMaxBufSize)});
}
@@ -288,7 +288,7 @@
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,
"KRB5SRV10:Selected protection: {0}; privacy: {1}; integrity: {2}",
- new Object[]{new Byte(selectedQop),
+ new Object[]{selectedQop,
Boolean.valueOf(privacy),
Boolean.valueOf(integrity)});
logger.log(Level.FINE,
--- a/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -77,7 +77,7 @@
if (logger.isLoggable(Level.FINE)) {
logger.logp(Level.FINE, myClassName, "constructor",
- "SASLIMPL02:Preferred qop mask: {0}", new Byte(allQop));
+ "SASLIMPL02:Preferred qop mask: {0}", allQop);
if (qop.length > 0) {
StringBuilder str = new StringBuilder();
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/BreakpointSpec.java Tue Jul 01 10:20:56 2014 -0700
@@ -142,8 +142,8 @@
refSpec.toString()));
} else if (e instanceof LineNotFoundException) {
return (MessageOutput.format("No code at line",
- new Object [] {new Long (lineNumber()),
- refSpec.toString()}));
+ new Object [] {Long.valueOf(lineNumber()),
+ refSpec.toString()}));
} else if (e instanceof InvalidTypeException) {
return (MessageOutput.format("Breakpoints can be located only in classes.",
refSpec.toString()));
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/Commands.java Tue Jul 01 10:20:56 2014 -0700
@@ -935,7 +935,7 @@
try {
methodInfo = loc.sourceName() +
MessageOutput.format("line number",
- new Object [] {new Long(lineNumber)});
+ new Object [] {Long.valueOf(lineNumber)});
} catch (AbsentInformationException e) {
methodInfo = MessageOutput.format("unknown");
}
@@ -946,7 +946,7 @@
meth.declaringType().name(),
meth.name(),
methodInfo,
- new Long(pc)});
+ Long.valueOf(pc)});
} else {
MessageOutput.println("stack frame dump",
new Object [] {new Integer(frameNumber + 1),
@@ -1015,7 +1015,7 @@
new Object [] {loc.declaringType().name(),
loc.method().name(),
new Integer (loc.lineNumber()),
- new Long (loc.codeIndex())});
+ Long.valueOf(loc.codeIndex())});
}
void listBreakpoints() {
--- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaLazyReadObject.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/JavaLazyReadObject.java Tue Jul 01 10:20:56 2014 -0700
@@ -102,7 +102,7 @@
if ((id & ~Snapshot.SMALL_ID_MASK) == 0) {
return new Integer((int)id);
} else {
- return new Long(id);
+ return id;
}
}
--- a/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/model/Snapshot.java Tue Jul 01 10:20:56 2014 -0700
@@ -583,7 +583,7 @@
if (identifierSize == 4) {
return new Integer((int)id);
} else {
- return new Long(id);
+ return id;
}
}
--- a/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java Tue Jul 01 10:20:56 2014 -0700
@@ -215,7 +215,7 @@
long id = readID();
byte[] chars = new byte[(int)length - identifierSize];
in.readFully(chars);
- names.put(new Long(id), new String(chars));
+ names.put(id, new String(chars));
break;
}
case HPROF_LOAD_CLASS: {
@@ -223,7 +223,7 @@
long classID = readID();
int stackTraceSerialNo = in.readInt();
long classNameID = readID();
- Long classIdI = new Long(classID);
+ Long classIdI = classID;
String nm = getNameFromID(classNameID).replace('/', '.');
classNameFromObjectID.put(classIdI, nm);
if (classNameFromSerialNo != null) {
@@ -303,7 +303,7 @@
warn("Weird stack frame line number: " + lineNumber);
lineNumber = StackFrame.LINE_NUMBER_UNKNOWN;
}
- stackFrames.put(new Long(id),
+ stackFrames.put(id,
new StackFrame(methodName, methodSig,
className, sourceFile,
lineNumber));
@@ -319,7 +319,7 @@
StackFrame[] frames = new StackFrame[in.readInt()];
for (int i = 0; i < frames.length; i++) {
long fid = readID();
- frames[i] = stackFrames.get(new Long(fid));
+ frames[i] = stackFrames.get(fid);
if (frames[i] == null) {
throw new IOException("Stack frame " + toHex(fid) + " not found");
}
@@ -619,7 +619,7 @@
}
private String getNameFromID(long id) throws IOException {
- return getNameFromID(new Long(id));
+ return getNameFromID(Long.valueOf(id));
}
private String getNameFromID(Long id) throws IOException {
@@ -703,7 +703,7 @@
String signature = "" + ((char) type);
fields[i] = new JavaField(fieldName, signature);
}
- String name = classNameFromObjectID.get(new Long(id));
+ String name = classNameFromObjectID.get(id);
if (name == null) {
warn("Class name not found for " + toHex(id));
name = "unknown-name@" + toHex(id);
--- a/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java Tue Jul 01 10:20:56 2014 -0700
@@ -63,9 +63,9 @@
}
Long count = referrersStat.get(cl);
if (count == null) {
- count = new Long(1);
+ count = 1L;
} else {
- count = new Long(count.longValue() + 1);
+ count = count + 1L;
}
referrersStat.put(cl, count);
}
@@ -75,9 +75,9 @@
JavaClass cl = obj.getClazz();
Long count = refereesStat.get(cl);
if (count == null) {
- count = new Long(1);
+ count = 1L;
} else {
- count = new Long(count.longValue() + 1);
+ count = count + 1L;
}
refereesStat.put(cl, count);
}
--- a/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -781,7 +781,7 @@
type.setSignature(signature);
}
- typesByID.put(new Long(id), type);
+ typesByID.put(id, type);
typesBySignature.add(type);
if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
@@ -809,7 +809,7 @@
if (comp == 0) {
matches++;
iter.remove();
- typesByID.remove(new Long(type.ref()));
+ typesByID.remove(type.ref());
if ((vm.traceFlags & VirtualMachine.TRACE_REFTYPES) != 0) {
vm.printTrace("Uncaching ReferenceType, sig=" + signature +
", id=" + type.ref());
@@ -895,7 +895,7 @@
ReferenceTypeImpl retType = null;
synchronized (this) {
if (typesByID != null) {
- retType = (ReferenceTypeImpl)typesByID.get(new Long(id));
+ retType = (ReferenceTypeImpl)typesByID.get(id);
}
if (retType == null) {
retType = addReferenceType(id, tag, signature);
@@ -1247,7 +1247,7 @@
return null;
}
ObjectReferenceImpl object = null;
- Long key = new Long(id);
+ Long key = id;
/*
* Attempt to retrieve an existing object object reference
@@ -1313,7 +1313,7 @@
// Handle any queue elements that are not strongly reachable
processQueue();
- SoftObjectReference ref = objectsByID.remove(new Long(object.ref()));
+ SoftObjectReference ref = objectsByID.remove(object.ref());
if (ref != null) {
batchForDispose(ref);
} else {
--- a/jdk/src/share/classes/java/awt/AWTEvent.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/AWTEvent.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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
@@ -388,6 +388,8 @@
/**
* Returns the event type.
+ *
+ * @return the event's type id
*/
public int getID() {
return id;
@@ -446,6 +448,9 @@
/**
* Returns whether this event has been consumed.
+ *
+ * @return {@code true} if this event has been consumed;
+ * otherwise {@code false}
*/
protected boolean isConsumed() {
return consumed;
--- a/jdk/src/share/classes/java/awt/AWTEventMulticaster.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/AWTEventMulticaster.java Tue Jul 01 10:20:56 2014 -0700
@@ -110,7 +110,15 @@
TextListener, InputMethodListener, HierarchyListener,
HierarchyBoundsListener, MouseWheelListener {
- protected final EventListener a, b;
+ /**
+ * A variable in the event chain (listener-a)
+ */
+ protected final EventListener a;
+
+ /**
+ * A variable in the event chain (listener-b)
+ */
+ protected final EventListener b;
/**
* Creates an event multicaster instance which chains listener-a
@@ -537,6 +545,7 @@
* returns the resulting multicast listener.
* @param a component-listener-a
* @param b component-listener-b
+ * @return the resulting listener
*/
public static ComponentListener add(ComponentListener a, ComponentListener b) {
return (ComponentListener)addInternal(a, b);
@@ -547,6 +556,7 @@
* returns the resulting multicast listener.
* @param a container-listener-a
* @param b container-listener-b
+ * @return the resulting listener
*/
public static ContainerListener add(ContainerListener a, ContainerListener b) {
return (ContainerListener)addInternal(a, b);
@@ -557,6 +567,7 @@
* returns the resulting multicast listener.
* @param a focus-listener-a
* @param b focus-listener-b
+ * @return the resulting listener
*/
public static FocusListener add(FocusListener a, FocusListener b) {
return (FocusListener)addInternal(a, b);
@@ -567,6 +578,7 @@
* returns the resulting multicast listener.
* @param a key-listener-a
* @param b key-listener-b
+ * @return the resulting listener
*/
public static KeyListener add(KeyListener a, KeyListener b) {
return (KeyListener)addInternal(a, b);
@@ -577,6 +589,7 @@
* returns the resulting multicast listener.
* @param a mouse-listener-a
* @param b mouse-listener-b
+ * @return the resulting listener
*/
public static MouseListener add(MouseListener a, MouseListener b) {
return (MouseListener)addInternal(a, b);
@@ -587,6 +600,7 @@
* returns the resulting multicast listener.
* @param a mouse-motion-listener-a
* @param b mouse-motion-listener-b
+ * @return the resulting listener
*/
public static MouseMotionListener add(MouseMotionListener a, MouseMotionListener b) {
return (MouseMotionListener)addInternal(a, b);
@@ -597,6 +611,7 @@
* returns the resulting multicast listener.
* @param a window-listener-a
* @param b window-listener-b
+ * @return the resulting listener
*/
public static WindowListener add(WindowListener a, WindowListener b) {
return (WindowListener)addInternal(a, b);
@@ -607,6 +622,7 @@
* and returns the resulting multicast listener.
* @param a window-state-listener-a
* @param b window-state-listener-b
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -620,6 +636,7 @@
* and returns the resulting multicast listener.
* @param a window-focus-listener-a
* @param b window-focus-listener-b
+ * @return the resulting listener
* @since 1.4
*/
public static WindowFocusListener add(WindowFocusListener a,
@@ -632,6 +649,7 @@
* returns the resulting multicast listener.
* @param a action-listener-a
* @param b action-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ActionListener add(ActionListener a, ActionListener b) {
@@ -643,6 +661,7 @@
* returns the resulting multicast listener.
* @param a item-listener-a
* @param b item-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ItemListener add(ItemListener a, ItemListener b) {
@@ -654,11 +673,21 @@
* returns the resulting multicast listener.
* @param a adjustment-listener-a
* @param b adjustment-listener-b
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static AdjustmentListener add(AdjustmentListener a, AdjustmentListener b) {
return (AdjustmentListener)addInternal(a, b);
}
+
+ /**
+ * Adds text-listener-a with text-listener-b and
+ * returns the resulting multicast listener.
+ *
+ * @param a text-listener-a
+ * @param b text-listener-b
+ * @return the resulting listener
+ */
@SuppressWarnings("overloads")
public static TextListener add(TextListener a, TextListener b) {
return (TextListener)addInternal(a, b);
@@ -669,6 +698,7 @@
* returns the resulting multicast listener.
* @param a input-method-listener-a
* @param b input-method-listener-b
+ * @return the resulting listener
*/
public static InputMethodListener add(InputMethodListener a, InputMethodListener b) {
return (InputMethodListener)addInternal(a, b);
@@ -679,6 +709,7 @@
* returns the resulting multicast listener.
* @param a hierarchy-listener-a
* @param b hierarchy-listener-b
+ * @return the resulting listener
* @since 1.3
*/
@SuppressWarnings("overloads")
@@ -691,6 +722,7 @@
* returns the resulting multicast listener.
* @param a hierarchy-bounds-listener-a
* @param b hierarchy-bounds-listener-b
+ * @return the resulting listener
* @since 1.3
*/
public static HierarchyBoundsListener add(HierarchyBoundsListener a, HierarchyBoundsListener b) {
@@ -702,6 +734,7 @@
* returns the resulting multicast listener.
* @param a mouse-wheel-listener-a
* @param b mouse-wheel-listener-b
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -715,6 +748,7 @@
* returns the resulting multicast listener.
* @param l component-listener-l
* @param oldl the component-listener being removed
+ * @return the resulting listener
*/
public static ComponentListener remove(ComponentListener l, ComponentListener oldl) {
return (ComponentListener) removeInternal(l, oldl);
@@ -725,6 +759,7 @@
* returns the resulting multicast listener.
* @param l container-listener-l
* @param oldl the container-listener being removed
+ * @return the resulting listener
*/
public static ContainerListener remove(ContainerListener l, ContainerListener oldl) {
return (ContainerListener) removeInternal(l, oldl);
@@ -735,6 +770,7 @@
* returns the resulting multicast listener.
* @param l focus-listener-l
* @param oldl the focus-listener being removed
+ * @return the resulting listener
*/
public static FocusListener remove(FocusListener l, FocusListener oldl) {
return (FocusListener) removeInternal(l, oldl);
@@ -745,6 +781,7 @@
* returns the resulting multicast listener.
* @param l key-listener-l
* @param oldl the key-listener being removed
+ * @return the resulting listener
*/
public static KeyListener remove(KeyListener l, KeyListener oldl) {
return (KeyListener) removeInternal(l, oldl);
@@ -755,6 +792,7 @@
* returns the resulting multicast listener.
* @param l mouse-listener-l
* @param oldl the mouse-listener being removed
+ * @return the resulting listener
*/
public static MouseListener remove(MouseListener l, MouseListener oldl) {
return (MouseListener) removeInternal(l, oldl);
@@ -765,6 +803,7 @@
* and returns the resulting multicast listener.
* @param l mouse-motion-listener-l
* @param oldl the mouse-motion-listener being removed
+ * @return the resulting listener
*/
public static MouseMotionListener remove(MouseMotionListener l, MouseMotionListener oldl) {
return (MouseMotionListener) removeInternal(l, oldl);
@@ -775,6 +814,7 @@
* returns the resulting multicast listener.
* @param l window-listener-l
* @param oldl the window-listener being removed
+ * @return the resulting listener
*/
public static WindowListener remove(WindowListener l, WindowListener oldl) {
return (WindowListener) removeInternal(l, oldl);
@@ -785,6 +825,7 @@
* and returns the resulting multicast listener.
* @param l window-state-listener-l
* @param oldl the window-state-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -798,6 +839,7 @@
* and returns the resulting multicast listener.
* @param l window-focus-listener-l
* @param oldl the window-focus-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
public static WindowFocusListener remove(WindowFocusListener l,
@@ -810,6 +852,7 @@
* returns the resulting multicast listener.
* @param l action-listener-l
* @param oldl the action-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ActionListener remove(ActionListener l, ActionListener oldl) {
@@ -821,6 +864,7 @@
* returns the resulting multicast listener.
* @param l item-listener-l
* @param oldl the item-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static ItemListener remove(ItemListener l, ItemListener oldl) {
@@ -832,11 +876,21 @@
* returns the resulting multicast listener.
* @param l adjustment-listener-l
* @param oldl the adjustment-listener being removed
+ * @return the resulting listener
*/
@SuppressWarnings("overloads")
public static AdjustmentListener remove(AdjustmentListener l, AdjustmentListener oldl) {
return (AdjustmentListener) removeInternal(l, oldl);
}
+
+ /**
+ * Removes the old text-listener from text-listener-l and
+ * returns the resulting multicast listener.
+ *
+ * @param l text-listener-l
+ * @param oldl the text-listener being removed
+ * @return the resulting listener
+ */
@SuppressWarnings("overloads")
public static TextListener remove(TextListener l, TextListener oldl) {
return (TextListener) removeInternal(l, oldl);
@@ -847,6 +901,7 @@
* returns the resulting multicast listener.
* @param l input-method-listener-l
* @param oldl the input-method-listener being removed
+ * @return the resulting listener
*/
public static InputMethodListener remove(InputMethodListener l, InputMethodListener oldl) {
return (InputMethodListener) removeInternal(l, oldl);
@@ -857,6 +912,7 @@
* returns the resulting multicast listener.
* @param l hierarchy-listener-l
* @param oldl the hierarchy-listener being removed
+ * @return the resulting listener
* @since 1.3
*/
@SuppressWarnings("overloads")
@@ -870,6 +926,7 @@
* listener.
* @param l hierarchy-bounds-listener-l
* @param oldl the hierarchy-bounds-listener being removed
+ * @return the resulting listener
* @since 1.3
*/
public static HierarchyBoundsListener remove(HierarchyBoundsListener l, HierarchyBoundsListener oldl) {
@@ -881,6 +938,7 @@
* and returns the resulting multicast listener.
* @param l mouse-wheel-listener-l
* @param oldl the mouse-wheel-listener being removed
+ * @return the resulting listener
* @since 1.4
*/
@SuppressWarnings("overloads")
@@ -898,6 +956,7 @@
* a new AWTEventMulticaster instance which chains a with b.
* @param a event listener-a
* @param b event listener-b
+ * @return the resulting listener
*/
protected static EventListener addInternal(EventListener a, EventListener b) {
if (a == null) return b;
@@ -915,6 +974,7 @@
* Else, returns listener l.
* @param l the listener being removed from
* @param oldl the listener being removed
+ * @return the resulting listener
*/
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
if (l == oldl || l == null) {
@@ -927,9 +987,14 @@
}
- /* Serialization support.
- */
-
+ /**
+ * Serialization support. Saves all Serializable listeners
+ * to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream to put before each serializable listener
+ * @throws IOException if serialization fails
+ */
protected void saveInternal(ObjectOutputStream s, String k) throws IOException {
if (a instanceof AWTEventMulticaster) {
((AWTEventMulticaster)a).saveInternal(s, k);
@@ -948,6 +1013,14 @@
}
}
+ /**
+ * Saves a Serializable listener chain to a serialization stream.
+ *
+ * @param s the stream to save to
+ * @param k a prefix stream to put before each serializable listener
+ * @param l the listener chain to save
+ * @throws IOException if serialization fails
+ */
protected static void save(ObjectOutputStream s, String k, EventListener l) throws IOException {
if (l == null) {
return;
--- a/jdk/src/share/classes/java/awt/AWTKeyStroke.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/AWTKeyStroke.java Tue Jul 01 10:20:56 2014 -0700
@@ -802,6 +802,7 @@
* <code>AWTKeyStroke</code>) which is equal to this instance.
*
* @return a cached instance which is equal to this instance
+ * @throws java.io.ObjectStreamException if a serialization problem occurs
*/
protected Object readResolve() throws java.io.ObjectStreamException {
synchronized (AWTKeyStroke.class) {
--- a/jdk/src/share/classes/java/awt/AlphaComposite.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/AlphaComposite.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -621,7 +621,9 @@
/**
* Creates an <code>AlphaComposite</code> object with the specified rule.
+ *
* @param rule the compositing rule
+ * @return the {@code AlphaComposite} object created
* @throws IllegalArgumentException if <code>rule</code> is not one of
* the following: {@link #CLEAR}, {@link #SRC}, {@link #DST},
* {@link #SRC_OVER}, {@link #DST_OVER}, {@link #SRC_IN},
@@ -664,10 +666,12 @@
* the constant alpha to multiply with the alpha of the source.
* The source is multiplied with the specified alpha before being composited
* with the destination.
+ *
* @param rule the compositing rule
* @param alpha the constant alpha to be multiplied with the alpha of
* the source. <code>alpha</code> must be a floating point number in the
* inclusive range [0.0, 1.0].
+ * @return the {@code AlphaComposite} object created
* @throws IllegalArgumentException if
* <code>alpha</code> is less than 0.0 or greater than 1.0, or if
* <code>rule</code> is not one of
--- a/jdk/src/share/classes/java/awt/BorderLayout.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/BorderLayout.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -367,6 +367,8 @@
/**
* Returns the horizontal gap between components.
+ *
+ * @return the horizontal gap between components
* @since 1.1
*/
public int getHgap() {
@@ -375,6 +377,7 @@
/**
* Sets the horizontal gap between components.
+ *
* @param hgap the horizontal gap between components
* @since 1.1
*/
@@ -384,6 +387,8 @@
/**
* Returns the vertical gap between components.
+ *
+ * @return the vertical gap between components
* @since 1.1
*/
public int getVgap() {
@@ -392,6 +397,7 @@
/**
* Sets the vertical gap between components.
+ *
* @param vgap the vertical gap between components
* @since 1.1
*/
--- a/jdk/src/share/classes/java/awt/Button.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Button.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -238,6 +238,8 @@
* Returns the command name of the action event fired by this button.
* If the command name is <code>null</code> (default) then this method
* returns the label of the button.
+ *
+ * @return the action command name (or label) for this button
*/
public String getActionCommand() {
return (actionCommand == null? label : actionCommand);
--- a/jdk/src/share/classes/java/awt/Checkbox.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Checkbox.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -713,6 +713,9 @@
*/
private static final long serialVersionUID = 7881579233144754107L;
+ /**
+ * Constructor for {@code AccessibleAWTCheckbox}
+ */
public AccessibleAWTCheckbox() {
super();
Checkbox.this.addItemListener(this);
--- a/jdk/src/share/classes/java/awt/CheckboxGroup.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/CheckboxGroup.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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,6 +91,10 @@
}
/**
+ * Returns the current choice from this check box group
+ * or {@code null} if none of checkboxes are selected.
+ *
+ * @return the selected checkbox
* @deprecated As of JDK version 1.1,
* replaced by <code>getSelectedCheckbox()</code>.
*/
@@ -120,6 +124,11 @@
}
/**
+ * Sets the currently selected check box in this group
+ * to be the specified check box and unsets all others.
+ *
+ * @param box the {@code Checkbox} to set as the
+ * current selection.
* @deprecated As of JDK version 1.1,
* replaced by <code>setSelectedCheckbox(Checkbox)</code>.
*/
--- a/jdk/src/share/classes/java/awt/Choice.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Choice.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -156,6 +156,7 @@
/**
* Returns the number of items in this <code>Choice</code> menu.
+ *
* @return the number of items in this <code>Choice</code> menu
* @see #getItem
* @since 1.1
@@ -165,6 +166,9 @@
}
/**
+ * Returns the number of items in this {@code Choice} menu.
+ *
+ * @return the number of items in this {@code Choice} menu
* @deprecated As of JDK version 1.1,
* replaced by <code>getItemCount()</code>.
*/
@@ -176,8 +180,10 @@
/**
* Gets the string at the specified index in this
* <code>Choice</code> menu.
- * @param index the index at which to begin
- * @see #getItemCount
+ *
+ * @param index the index at which to begin
+ * @return the item at the specified index
+ * @see #getItemCount
*/
public String getItem(int index) {
return getItemImpl(index);
@@ -759,6 +765,9 @@
*/
private static final long serialVersionUID = 7175603582428509322L;
+ /**
+ * Constructor for {@code AccessibleAWTChoice}
+ */
public AccessibleAWTChoice() {
super();
}
--- a/jdk/src/share/classes/java/awt/Component.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Component.java Tue Jul 01 10:20:56 2014 -0700
@@ -1075,6 +1075,7 @@
* @deprecated As of JDK version 1.1,
* programs should not directly manipulate peers;
* replaced by <code>boolean isDisplayable()</code>.
+ * @return the peer for this component
*/
@Deprecated
public ComponentPeer getPeer() {
@@ -1132,6 +1133,8 @@
/**
* Gets the <code>DropTarget</code> associated with this
* <code>Component</code>.
+ *
+ * @return the drop target
*/
public synchronized DropTarget getDropTarget() { return dropTarget; }
@@ -1498,6 +1501,11 @@
}
/**
+ * Enables or disables this component.
+ *
+ * @param b {@code true} to enable this component;
+ * otherwise {@code false}
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setEnabled(boolean)</code>.
*/
@@ -1656,6 +1664,11 @@
}
/**
+ * Makes this component visible or invisible.
+ *
+ * @param b {@code true} to make this component visible;
+ * otherwise {@code false}
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setVisible(boolean)</code>.
*/
@@ -2068,6 +2081,9 @@
/**
+ * Returns the location of this component's top left corner.
+ *
+ * @return the location of this component's top left corner
* @deprecated As of JDK version 1.1,
* replaced by <code>getLocation()</code>.
*/
@@ -2102,6 +2118,13 @@
}
/**
+ * Moves this component to a new location.
+ *
+ * @param x the <i>x</i>-coordinate of the new location's
+ * top-left corner in the parent's coordinate space
+ * @param y the <i>y</i>-coordinate of the new location's
+ * top-left corner in the parent's coordinate space
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setLocation(int, int)</code>.
*/
@@ -2150,6 +2173,11 @@
}
/**
+ * Returns the size of this component in the form of a
+ * {@code Dimension} object.
+ *
+ * @return the {@code Dimension} object that indicates the
+ * size of this component
* @deprecated As of JDK version 1.1,
* replaced by <code>getSize()</code>.
*/
@@ -2177,6 +2205,10 @@
}
/**
+ * Resizes this component.
+ *
+ * @param width the new width of the component
+ * @param height the new height of the component
* @deprecated As of JDK version 1.1,
* replaced by <code>setSize(int, int)</code>.
*/
@@ -2208,6 +2240,10 @@
}
/**
+ * Resizes this component so that it has width {@code d.width}
+ * and height {@code d.height}.
+ *
+ * @param d the new size of this component
* @deprecated As of JDK version 1.1,
* replaced by <code>setSize(Dimension)</code>.
*/
@@ -2231,6 +2267,9 @@
}
/**
+ * Returns the bounding rectangle of this component.
+ *
+ * @return the bounding rectangle for this component
* @deprecated As of JDK version 1.1,
* replaced by <code>getBounds()</code>.
*/
@@ -2265,6 +2304,13 @@
}
/**
+ * Reshapes the bounding rectangle for this component.
+ *
+ * @param x the <i>x</i> coordinate of the upper left corner of the rectangle
+ * @param y the <i>y</i> coordinate of the upper left corner of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setBounds(int, int, int, int)</code>.
*/
@@ -2631,6 +2677,9 @@
/**
+ * Returns the component's preferred size.
+ *
+ * @return the component's preferred size
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize()</code>.
*/
@@ -2701,6 +2750,9 @@
}
/**
+ * Returns the minimum size of this component.
+ *
+ * @return the minimum size of this component
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize()</code>.
*/
@@ -2781,6 +2833,8 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @return the horizontal alignment of this component
*/
public float getAlignmentX() {
return CENTER_ALIGNMENT;
@@ -2792,6 +2846,8 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @return the vertical alignment of this component
*/
public float getAlignmentY() {
return CENTER_ALIGNMENT;
@@ -3157,8 +3213,10 @@
* not have a cursor set, the cursor of its parent is returned.
* If no cursor is set in the entire hierarchy,
* <code>Cursor.DEFAULT_CURSOR</code> is returned.
+ *
+ * @return the cursor for this component
* @see #setCursor
- * @since 1.1
+ * @since 1.1
*/
public Cursor getCursor() {
return getCursor_NoClientCode();
@@ -3942,6 +4000,7 @@
* a lost state.
*/
protected boolean validatedContents; // = false
+
/**
* Size of the back buffers. (Note: these fields were added in 6.0
* but kept package-private to avoid exposing them in the spec.
@@ -3949,7 +4008,15 @@
* protected when they were introduced in 1.4, but now we just have
* to live with that decision.)
*/
+
+ /**
+ * The width of the back buffers
+ */
int width;
+
+ /**
+ * The height of the back buffers
+ */
int height;
/**
@@ -4304,6 +4371,8 @@
/**
* Creates the back buffers
+ *
+ * @param numBuffers the number of buffers to create
*/
protected void createBackBuffers(int numBuffers) {
if (numBuffers == 0) {
@@ -4593,6 +4662,9 @@
* better performance is desired, or if page-flipping is used as the
* buffer strategy.
*
+ * @param ignoreRepaint {@code true} if the paint messages from the OS
+ * should be ignored; otherwise {@code false}
+ *
* @since 1.4
* @see #getIgnoreRepaint
* @see Canvas#createBufferStrategy
@@ -4619,8 +4691,11 @@
* Checks whether this component "contains" the specified point,
* where <code>x</code> and <code>y</code> are defined to be
* relative to the coordinate system of this component.
+ *
* @param x the <i>x</i> coordinate of the point
* @param y the <i>y</i> coordinate of the point
+ * @return {@code true} if the point is within the component;
+ * otherwise {@code false}
* @see #getComponentAt(int, int)
* @since 1.1
*/
@@ -4629,6 +4704,12 @@
}
/**
+ * Checks whether the point is inside of this component.
+ *
+ * @param x the <i>x</i> coordinate of the point
+ * @param y the <i>y</i> coordinate of the point
+ * @return {@code true} if the point is within the component;
+ * otherwise {@code false}
* @deprecated As of JDK version 1.1,
* replaced by contains(int, int).
*/
@@ -4641,7 +4722,10 @@
* Checks whether this component "contains" the specified point,
* where the point's <i>x</i> and <i>y</i> coordinates are defined
* to be relative to the coordinate system of this component.
+ *
* @param p the point
+ * @return {@code true} if the point is within the component;
+ * otherwise {@code false}
* @throws NullPointerException if {@code p} is {@code null}
* @see #getComponentAt(Point)
* @since 1.1
@@ -4676,6 +4760,13 @@
}
/**
+ * Returns the component occupying the position specified (this component,
+ * or immediate child component, or null if neither
+ * of the first two occupies the location).
+ *
+ * @param x the <i>x</i> coordinate to search for components at
+ * @param y the <i>y</i> coordinate to search for components at
+ * @return the component at the specified location or {@code null}
* @deprecated As of JDK version 1.1,
* replaced by getComponentAt(int, int).
*/
@@ -4687,15 +4778,17 @@
/**
* Returns the component or subcomponent that contains the
* specified point.
- * @param p the point
- * @see java.awt.Component#contains
- * @since 1.1
+ * @param p the point
+ * @return the component at the specified location or {@code null}
+ * @see java.awt.Component#contains
+ * @since 1.1
*/
public Component getComponentAt(Point p) {
return getComponentAt(p.x, p.y);
}
/**
+ * @param e the event to deliver
* @deprecated As of JDK version 1.1,
* replaced by <code>dispatchEvent(AWTEvent e)</code>.
*/
@@ -6746,6 +6839,8 @@
}
/**
+ * @param evt the event to handle
+ * @return {@code true} if the event was handled, {@code false} otherwise
* @deprecated As of JDK version 1.1
* replaced by processEvent(AWTEvent).
*/
@@ -6789,6 +6884,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6798,6 +6897,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseMotionEvent(MouseEvent).
*/
@@ -6807,6 +6910,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6816,6 +6923,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseMotionEvent(MouseEvent).
*/
@@ -6825,6 +6936,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6834,6 +6949,10 @@
}
/**
+ * @param evt the event to handle
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processMouseEvent(MouseEvent).
*/
@@ -6843,6 +6962,9 @@
}
/**
+ * @param evt the event to handle
+ * @param key the key pressed
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processKeyEvent(KeyEvent).
*/
@@ -6852,6 +6974,9 @@
}
/**
+ * @param evt the event to handle
+ * @param key the key pressed
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processKeyEvent(KeyEvent).
*/
@@ -6861,6 +6986,9 @@
}
/**
+ * @param evt the event to handle
+ * @param what the object acted on
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* should register this component as ActionListener on component
* which fires action events.
@@ -7070,6 +7198,9 @@
}
/**
+ * @param evt the event to handle
+ * @param what the object focused
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processFocusEvent(FocusEvent).
*/
@@ -7079,6 +7210,9 @@
}
/**
+ * @param evt the event to handle
+ * @param what the object focused
+ * @return {@code false}
* @deprecated As of JDK version 1.1,
* replaced by processFocusEvent(FocusEvent).
*/
@@ -8390,6 +8524,7 @@
* Returns an array of all the listeners which have been associated
* with the named property.
*
+ * @param propertyName the property name
* @return all of the <code>PropertyChangeListener</code>s associated with
* the named property; if no such listeners have been added or
* if <code>propertyName</code> is <code>null</code>, an empty
@@ -8400,8 +8535,7 @@
* @see #getPropertyChangeListeners
* @since 1.4
*/
- public PropertyChangeListener[] getPropertyChangeListeners(
- String propertyName) {
+ public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
synchronized (getObjectLock()) {
if (changeSupport == null) {
return new PropertyChangeListener[0];
@@ -8506,7 +8640,7 @@
if (changeSupport == null || oldValue == newValue) {
return;
}
- firePropertyChange(propertyName, new Character(oldValue), new Character(newValue));
+ firePropertyChange(propertyName, Character.valueOf(oldValue), Character.valueOf(newValue));
}
/**
@@ -8879,6 +9013,7 @@
* This method changes layout-related information, and therefore,
* invalidates the component hierarchy.
*
+ * @param o the orientation to be set
*
* @see ComponentOrientation
* @see #invalidate
@@ -8906,6 +9041,7 @@
* subclasses that wish to respect orientation should call this method to
* get the component's orientation before performing layout or drawing.
*
+ * @return the orientation to order the elements or text
* @see ComponentOrientation
*
* @author Laura Werner, IBM
@@ -9063,7 +9199,16 @@
*/
private volatile transient int propertyListenersCount = 0;
+ /**
+ * A component listener to track show/hide/resize events
+ * and convert them to PropertyChange events.
+ */
protected ComponentListener accessibleAWTComponentHandler = null;
+
+ /**
+ * A listener to track focus events
+ * and convert them to PropertyChange events.
+ */
protected FocusListener accessibleAWTFocusHandler = null;
/**
--- a/jdk/src/share/classes/java/awt/ComponentOrientation.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/ComponentOrientation.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, 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
@@ -126,6 +126,8 @@
* Are lines horizontal?
* This will return true for horizontal, left-to-right writing
* systems such as Roman.
+ *
+ * @return {@code true} if this orientation has horizontal lines
*/
public boolean isHorizontal() {
return (orientation & HORIZ_BIT) != 0;
@@ -136,6 +138,8 @@
* Vertical Lines: Do lines run left-to-right?<br>
* This will return true for horizontal, left-to-right writing
* systems such as Roman.
+ *
+ * @return {@code true} if this orientation is left-to-right
*/
public boolean isLeftToRight() {
return (orientation & LTR_BIT) != 0;
@@ -143,7 +147,9 @@
/**
* Returns the orientation that is appropriate for the given locale.
+ *
* @param locale the specified locale
+ * @return the orientation for the locale
*/
public static ComponentOrientation getOrientation(Locale locale) {
// A more flexible implementation would consult a ResourceBundle
@@ -171,6 +177,8 @@
* <li>Return the default locale's orientation.
* </ol>
*
+ * @param bdl the bundle to use
+ * @return the orientation
* @deprecated As of J2SE 1.4, use {@link #getOrientation(java.util.Locale)}.
*/
@Deprecated
--- a/jdk/src/share/classes/java/awt/Container.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Container.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -310,6 +310,9 @@
}
/**
+ * Returns the number of components in this container.
+ *
+ * @return the number of components in this container
* @deprecated As of JDK version 1.1,
* replaced by getComponentCount().
*/
@@ -391,8 +394,11 @@
}
/**
+ * Returns the insets for this container.
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>getInsets()</code>.
+ * @return the insets for this container
*/
@Deprecated
public Insets insets() {
@@ -438,6 +444,9 @@
* displayed, the hierarchy must be validated thereafter in order to
* display the added component.
*
+ * @param name the name of the component to be added
+ * @param comp the component to be added
+ * @return the component added
* @exception NullPointerException if {@code comp} is {@code null}
* @see #add(Component, Object)
* @see #invalidate
@@ -1471,8 +1480,10 @@
/**
* Gets the layout manager for this container.
+ *
* @see #doLayout
* @see #setLayout
+ * @return the current layout manager for this container
*/
public LayoutManager getLayout() {
return layoutMgr;
@@ -3854,6 +3865,10 @@
*/
private volatile transient int propertyListenersCount = 0;
+ /**
+ * The handler to fire {@code PropertyChange}
+ * when children are added or removed
+ */
protected ContainerListener accessibleContainerHandler = null;
/**
--- a/jdk/src/share/classes/java/awt/Cursor.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Cursor.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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
@@ -294,6 +294,7 @@
* @return the system specific custom cursor named
* @exception HeadlessException if
* <code>GraphicsEnvironment.isHeadless</code> returns true
+ * @exception AWTException in case of erroneous retrieving of the cursor
*/
static public Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
@@ -378,6 +379,8 @@
/**
* Return the system default cursor.
+ *
+ * @return the default cursor
*/
static public Cursor getDefaultCursor() {
return getPredefinedCursor(Cursor.DEFAULT_CURSOR);
@@ -416,6 +419,8 @@
/**
* Returns the type for this cursor.
+ *
+ * @return the cursor type
*/
public int getType() {
return type;
--- a/jdk/src/share/classes/java/awt/DisplayMode.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/DisplayMode.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, 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,6 +125,8 @@
/**
* Returns whether the two display modes are equal.
+ *
+ * @param dm the display mode to compare to
* @return whether the two display modes are equal
*/
public boolean equals(DisplayMode dm) {
--- a/jdk/src/share/classes/java/awt/EventQueue.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/EventQueue.java Tue Jul 01 10:20:56 2014 -0700
@@ -222,6 +222,9 @@
});
}
+ /**
+ * Initializes a new instance of {@code EventQueue}.
+ */
public EventQueue() {
for (int i = 0; i < NUM_PRIORITIES; i++) {
queues[i] = new Queue();
--- a/jdk/src/share/classes/java/awt/Frame.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Frame.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -1089,6 +1089,9 @@
}
/**
+ * Sets the cursor for this frame to the specified type.
+ *
+ * @param cursorType the cursor type
* @deprecated As of JDK version 1.1,
* replaced by <code>Component.setCursor(Cursor)</code>.
*/
@@ -1103,6 +1106,7 @@
/**
* @deprecated As of JDK version 1.1,
* replaced by <code>Component.getCursor()</code>.
+ * @return the cursor type for this frame
*/
@Deprecated
public int getCursorType() {
@@ -1124,6 +1128,8 @@
* ownerless {@code Dialog}s (introduced in release 1.6), use {@link
* Window#getOwnerlessWindows Window.getOwnerlessWindows}.
*
+ * @return the array of all {@code Frame}s created by this application
+ *
* @see Window#getWindows()
* @see Window#getOwnerlessWindows
*
--- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java Tue Jul 01 10:20:56 2014 -0700
@@ -357,6 +357,8 @@
* <p>Notice that an application can supersede the registration
* of an earlier created font with a new one.
* </ul>
+ *
+ * @param font the font to be registered
* @return true if the <code>font</code> is successfully
* registered in this <code>GraphicsEnvironment</code>.
* @throws NullPointerException if <code>font</code> is null
--- a/jdk/src/share/classes/java/awt/GridBagLayout.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/GridBagLayout.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -981,9 +981,15 @@
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #getLayoutInfo(java.awt.Container, int) getLayoutInfo} instead.
- * This method is the same as <code>getLayoutInfo</code>;
- * refer to <code>getLayoutInfo</code> for details on parameters
- * and return value.
+ *
+ * Fills in an instance of {@code GridBagLayoutInfo} for the
+ * current set of managed children. This method is the same
+ * as {@code getLayoutInfo}; refer to {@code getLayoutInfo}
+ * description for details.
+ *
+ * @param parent the layout container
+ * @param sizeflag either {@code PREFERREDSIZE} or {@code MINSIZE}
+ * @return the {@code GridBagLayoutInfo} for the set of children
*/
protected GridBagLayoutInfo GetLayoutInfo(Container parent, int sizeflag) {
synchronized (parent.getTreeLock()) {
@@ -1611,13 +1617,17 @@
}
/**
+ * Adjusts the x, y, width, and height fields to the correct
+ * values depending on the constraint geometry and pads.
+ * <p>
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #adjustForGravity(java.awt.GridBagConstraints, java.awt.Rectangle)
* adjustForGravity} instead.
- * This method is the same as <code>adjustForGravity</code>;
- * refer to <code>adjustForGravity</code> for details
- * on parameters.
+ * This method is the same as <code>adjustForGravity</code>
+ *
+ * @param constraints the constraints to be applied
+ * @param r the {@code Rectangle} to be adjusted
*/
protected void AdjustForGravity(GridBagConstraints constraints,
Rectangle r) {
@@ -1995,9 +2005,12 @@
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #getMinSize(java.awt.Container, GridBagLayoutInfo) getMinSize} instead.
- * This method is the same as <code>getMinSize</code>;
- * refer to <code>getMinSize</code> for details on parameters
- * and return value.
+ * This method is the same as <code>getMinSize</code>
+ *
+ * @param parent the layout container
+ * @param info the layout info for this parent
+ * @return a <code>Dimension</code> object containing the
+ * minimum size
*/
protected Dimension GetMinSize(Container parent, GridBagLayoutInfo info) {
Dimension d = new Dimension();
@@ -2035,9 +2048,9 @@
* This method is obsolete and supplied for backwards
* compatibility only; new code should call {@link
* #arrangeGrid(Container) arrangeGrid} instead.
- * This method is the same as <code>arrangeGrid</code>;
- * refer to <code>arrangeGrid</code> for details on the
- * parameter.
+ * This method is the same as <code>arrangeGrid</code>
+ *
+ * @param parent the layout container
*/
protected void ArrangeGrid(Container parent) {
Component comp;
--- a/jdk/src/share/classes/java/awt/HeadlessException.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/HeadlessException.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, 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,24 @@
* JDK 1.4 serialVersionUID
*/
private static final long serialVersionUID = 167183644944358563L;
+
+ /**
+ * Constructs new {@code HeadlessException}
+ */
public HeadlessException() {}
+
+ /**
+ * Create a new instance with the specified detailed error message.
+ *
+ * @param msg the error message
+ */
public HeadlessException(String msg) {
super(msg);
}
+
+ /**
+ * {@inheritDoc}
+ */
public String getMessage() {
String superMessage = super.getMessage();
String headlessMessage = GraphicsEnvironment.getHeadlessMessage();
--- a/jdk/src/share/classes/java/awt/ItemSelectable.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/ItemSelectable.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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,6 +39,8 @@
/**
* Returns the selected items or <code>null</code> if no
* items are selected.
+ *
+ * @return the list of selected objects, or {@code null}
*/
public Object[] getSelectedObjects();
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Tue Jul 01 10:20:56 2014 -0700
@@ -1459,6 +1459,7 @@
* Returns an array of all the <code>PropertyChangeListener</code>s
* associated with the named property.
*
+ * @param propertyName the property name
* @return all of the <code>PropertyChangeListener</code>s associated with
* the named property or an empty array if no such listeners have
* been added.
@@ -1628,6 +1629,7 @@
* Returns an array of all the <code>VetoableChangeListener</code>s
* associated with the named property.
*
+ * @param propertyName the property name
* @return all of the <code>VetoableChangeListener</code>s associated with
* the named property or an empty array if no such listeners have
* been added.
--- a/jdk/src/share/classes/java/awt/Label.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Label.java Tue Jul 01 10:20:56 2014 -0700
@@ -193,7 +193,8 @@
* Gets the current alignment of this label. Possible values are
* <code>Label.LEFT</code>, <code>Label.RIGHT</code>, and
* <code>Label.CENTER</code>.
- * @see java.awt.Label#setAlignment
+ * @return the alignment of this label
+ * @see java.awt.Label#setAlignment
*/
public int getAlignment() {
return alignment;
@@ -321,6 +322,9 @@
*/
private static final long serialVersionUID = -3568967560160480438L;
+ /**
+ * Constructor for the accessible label.
+ */
public AccessibleAWTLabel() {
super();
}
--- a/jdk/src/share/classes/java/awt/LayoutManager.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/LayoutManager.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -61,7 +61,9 @@
/**
* Calculates the preferred size dimensions for the specified
* container, given the components it contains.
- * @param parent the container to be laid out
+ *
+ * @param parent the container to be laid out
+ * @return the preferred dimension for the container
*
* @see #minimumLayoutSize
*/
@@ -70,7 +72,10 @@
/**
* Calculates the minimum size dimensions for the specified
* container, given the components it contains.
- * @param parent the component to be laid out
+ *
+ * @param parent the component to be laid out
+ * @return the minimum dimension for the container
+ *
* @see #preferredLayoutSize
*/
Dimension minimumLayoutSize(Container parent);
--- a/jdk/src/share/classes/java/awt/LayoutManager2.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/LayoutManager2.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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
@@ -55,8 +55,11 @@
/**
* Calculates the maximum size dimensions for the specified container,
* given the components it contains.
+ *
* @see java.awt.Component#getMaximumSize
* @see LayoutManager
+ * @param target the target container
+ * @return the maximum size of the container
*/
public Dimension maximumLayoutSize(Container target);
@@ -66,6 +69,9 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @param target the target container
+ * @return the x-axis alignment preference
*/
public float getLayoutAlignmentX(Container target);
@@ -75,12 +81,16 @@
* components. The value should be a number between 0 and 1
* where 0 represents alignment along the origin, 1 is aligned
* the furthest away from the origin, 0.5 is centered, etc.
+ *
+ * @param target the target container
+ * @return the y-axis alignment preference
*/
public float getLayoutAlignmentY(Container target);
/**
* Invalidates the layout, indicating that if the layout manager
* has cached information it should be discarded.
+ * @param target the target container
*/
public void invalidateLayout(Container target);
--- a/jdk/src/share/classes/java/awt/List.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/List.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -282,6 +282,9 @@
}
/**
+ * Returns the number of items in the list.
+ *
+ * @return the number of items in the list
* @deprecated As of JDK version 1.1,
* replaced by <code>getItemCount()</code>.
*/
@@ -333,7 +336,10 @@
}
/**
- * @deprecated replaced by <code>add(String)</code>.
+ * Adds the specified item to the end of the list.
+ *
+ * @param item the item to be added
+ * @deprecated replaced by <code>add(String)</code>.
*/
@Deprecated
public void addItem(String item) {
@@ -358,7 +364,12 @@
}
/**
- * @deprecated replaced by <code>add(String, int)</code>.
+ * Adds the specified item to the the list
+ * at the position indicated by the index.
+ *
+ * @param item the item to be added
+ * @param index the position at which to add the item
+ * @deprecated replaced by <code>add(String, int)</code>.
*/
@Deprecated
public synchronized void addItem(String item, int index) {
@@ -455,8 +466,11 @@
}
/**
- * @deprecated replaced by <code>remove(String)</code>
- * and <code>remove(int)</code>.
+ * Removes the item at the specified position.
+ *
+ * @param position the index of the item to delete
+ * @deprecated replaced by <code>remove(String)</code>
+ * and <code>remove(int)</code>.
*/
@Deprecated
public void delItem(int position) {
@@ -646,6 +660,10 @@
}
/**
+ * Determines if the specified item in the list is selected.
+ *
+ * @param index specifies the item to be checked
+ * @return {@code true} if the item is selected; otherwise {@code false}
* @deprecated As of JDK version 1.1,
* replaced by <code>isIndexSelected(int)</code>.
*/
@@ -672,6 +690,7 @@
/**
* Determines whether this list allows multiple selections.
+ *
* @return <code>true</code> if this list allows multiple
* selections; otherwise, <code>false</code>
* @see #setMultipleMode
@@ -682,6 +701,10 @@
}
/**
+ * Determines whether this list allows multiple selections.
+ *
+ * @return {@code true} if this list allows multiple
+ * selections; otherwise {@code false}
* @deprecated As of JDK version 1.1,
* replaced by <code>isMultipleMode()</code>.
*/
@@ -709,6 +732,9 @@
}
/**
+ * Enables or disables multiple selection mode for this list.
+ *
+ * @param b {@code true} to enable multiple mode, {@code false} otherwise
* @deprecated As of JDK version 1.1,
* replaced by <code>setMultipleMode(boolean)</code>.
*/
@@ -760,6 +786,11 @@
}
/**
+ * Returns the preferred size of this component
+ * assuming it has the specified number of rows.
+ *
+ * @param rows the number of rows
+ * @return the preferred dimensions for displaying this list
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize(int)</code>.
*/
@@ -810,6 +841,11 @@
}
/**
+ * Returns the minimum dimensions for the list
+ * with the specified number of rows.
+ *
+ * @param rows the number of rows in the list
+ * @return the minimum dimensions for displaying this list
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize(int)</code>.
*/
@@ -1146,6 +1182,10 @@
}
/**
+ * Deletes the list items in the specified index range.
+ *
+ * @param start the beginning index of the range to delete
+ * @param end the ending index of the range to delete
* @deprecated As of JDK version 1.1,
* Not for public use in the future.
* This method is expected to be retained only as a package
@@ -1290,6 +1330,9 @@
*/
private static final long serialVersionUID = 7924617370136012829L;
+ /**
+ * Constructs new {@code AccessibleAWTList}
+ */
public AccessibleAWTList() {
super();
List.this.addActionListener(this);
@@ -1491,6 +1534,13 @@
private List parent;
private int indexInParent;
+ /**
+ * Constructs new {@code AccessibleAWTListChild} with the given
+ * parent {@code List} and 0-based index of this object in the parent.
+ *
+ * @param parent the parent {@code List}
+ * @param indexInParent the index in the parent
+ */
public AccessibleAWTListChild(List parent, int indexInParent) {
this.parent = parent;
this.setAccessibleParent(parent);
--- a/jdk/src/share/classes/java/awt/MediaTracker.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/MediaTracker.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -643,9 +643,11 @@
* image is considered to have finished loading. Use the
* <code>statusID</code>, <code>isErrorID</code>, and
* <code>isErrorAny</code> methods to check for errors.
- * @param id the identifier of the images to check
- * @param ms the length of time, in milliseconds, to wait
- * for the loading to complete
+ * @param id the identifier of the images to check
+ * @param ms the length of time, in milliseconds, to wait
+ * for the loading to complete
+ * @return {@code true} if the loading completed in time;
+ * otherwise {@code false}
* @see java.awt.MediaTracker#waitForAll
* @see java.awt.MediaTracker#waitForID(int)
* @see java.awt.MediaTracker#statusID
--- a/jdk/src/share/classes/java/awt/Menu.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Menu.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -213,7 +213,7 @@
/**
* Get the number of items in this menu.
- * @return the number of items in this menu.
+ * @return the number of items in this menu
* @since 1.1
*/
public int getItemCount() {
@@ -221,6 +221,9 @@
}
/**
+ * Returns the number of items in this menu.
+ *
+ * @return the number of items in this menu
* @deprecated As of JDK version 1.1,
* replaced by <code>getItemCount()</code>.
*/
--- a/jdk/src/share/classes/java/awt/MenuBar.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/MenuBar.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -279,6 +279,9 @@
}
/**
+ * Gets the number of menus on the menu bar.
+ *
+ * @return the number of menus on the menu bar.
* @deprecated As of JDK version 1.1,
* replaced by <code>getMenuCount()</code>.
*/
@@ -338,10 +341,11 @@
* or <code>null</code> if none of the menu items being managed
* by this menu bar is associated with the specified menu
* shortcut.
- * @param s the specified menu shortcut.
- * @see java.awt.MenuItem
- * @see java.awt.MenuShortcut
- * @since 1.1
+ * @param s the specified menu shortcut.
+ * @return the menu item for the specified shortcut.
+ * @see java.awt.MenuItem
+ * @see java.awt.MenuShortcut
+ * @since 1.1
*/
public MenuItem getShortcutMenuItem(MenuShortcut s) {
int nmenus = getMenuCount();
--- a/jdk/src/share/classes/java/awt/MenuComponent.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/MenuComponent.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -220,6 +220,7 @@
/**
* @deprecated As of JDK version 1.1,
* programs should not directly manipulate peers.
+ * @return the peer for this component
*/
@Deprecated
public MenuComponentPeer getPeer() {
--- a/jdk/src/share/classes/java/awt/MenuContainer.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/MenuContainer.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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,10 +31,25 @@
*/
public interface MenuContainer {
+
+ /**
+ * Returns the font in use by this container.
+ *
+ * @return the menu font
+ */
Font getFont();
+
+ /**
+ * Removes the specified menu component from the menu.
+ *
+ * @param comp the menu component to remove
+ */
void remove(MenuComponent comp);
/**
+ * Posts an event to the listeners.
+ *
+ * @param evt the event to dispatch
* @deprecated As of JDK version 1.1
* replaced by dispatchEvent(AWTEvent).
*/
--- a/jdk/src/share/classes/java/awt/MenuItem.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/MenuItem.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -264,6 +264,9 @@
/**
* Checks whether this menu item is enabled.
+ *
+ * @return {@code true} if the item is enabled;
+ * otherwise {@code false}
* @see java.awt.MenuItem#setEnabled
* @since 1.0
*/
@@ -296,6 +299,10 @@
}
/**
+ * Sets whether or not this menu item can be chosen.
+ *
+ * @param b if {@code true}, enables this menu item;
+ * otherwise disables
* @deprecated As of JDK version 1.1,
* replaced by <code>setEnabled(boolean)</code>.
*/
@@ -494,8 +501,10 @@
/**
* Gets the command name of the action event that is fired
* by this menu item.
- * @see java.awt.MenuItem#setActionCommand
- * @since 1.1
+ *
+ * @return the action command name
+ * @see java.awt.MenuItem#setActionCommand
+ * @since 1.1
*/
public String getActionCommand() {
return getActionCommandImpl();
--- a/jdk/src/share/classes/java/awt/PrintGraphics.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/PrintGraphics.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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,6 +35,8 @@
/**
* Returns the PrintJob object from which this PrintGraphics
* object originated.
+ *
+ * @return the print job for this object
*/
public PrintJob getPrintJob();
--- a/jdk/src/share/classes/java/awt/PrintJob.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/PrintJob.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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,6 +42,7 @@
* object is disposed. This graphics object will also implement
* the PrintGraphics interface.
* @see PrintGraphics
+ * @return the graphics context for printing the next page
*/
public abstract Graphics getGraphics();
@@ -49,6 +50,8 @@
* Returns the dimensions of the page in pixels.
* The resolution of the page is chosen so that it
* is similar to the screen resolution.
+ *
+ * @return the page dimension
*/
public abstract Dimension getPageDimension();
@@ -56,11 +59,16 @@
* Returns the resolution of the page in pixels per inch.
* Note that this doesn't have to correspond to the physical
* resolution of the printer.
+ *
+ * @return the page resolution
*/
public abstract int getPageResolution();
/**
* Returns true if the last page will be printed first.
+ *
+ * @return {@code true} if the last page will be printed first;
+ * otherwise {@code false}
*/
public abstract boolean lastPageFirst();
--- a/jdk/src/share/classes/java/awt/Robot.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Robot.java Tue Jul 01 10:20:56 2014 -0700
@@ -498,6 +498,8 @@
/**
* Returns the number of milliseconds this Robot sleeps after generating an event.
+ *
+ * @return the delay duration in milliseconds
*/
public synchronized int getAutoDelay() {
return autoDelay;
@@ -505,7 +507,10 @@
/**
* Sets the number of milliseconds this Robot sleeps after generating an event.
- * @throws IllegalArgumentException If <code>ms</code> is not between 0 and 60,000 milliseconds inclusive
+ *
+ * @param ms the delay duration in milliseconds
+ * @throws IllegalArgumentException If {@code ms}
+ * is not between 0 and 60,000 milliseconds inclusive
*/
public synchronized void setAutoDelay(int ms) {
checkDelayArgument(ms);
@@ -523,9 +528,11 @@
* Sleeps for the specified time.
* To catch any <code>InterruptedException</code>s that occur,
* <code>Thread.sleep()</code> may be used instead.
- * @param ms time to sleep in milliseconds
- * @throws IllegalArgumentException if <code>ms</code> is not between 0 and 60,000 milliseconds inclusive
- * @see java.lang.Thread#sleep
+ *
+ * @param ms time to sleep in milliseconds
+ * @throws IllegalArgumentException if {@code ms}
+ * is not between 0 and 60,000 milliseconds inclusive
+ * @see java.lang.Thread#sleep
*/
public synchronized void delay(int ms) {
checkDelayArgument(ms);
--- a/jdk/src/share/classes/java/awt/ScrollPane.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/ScrollPane.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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
@@ -323,7 +323,9 @@
* represents the state of the vertical scrollbar.
* The declared return type of this method is
* <code>Adjustable</code> to maintain backward compatibility.
+ *
* @see java.awt.ScrollPaneAdjustable
+ * @return the vertical scrollbar state
*/
public Adjustable getVAdjustable() {
return vAdjustable;
@@ -334,7 +336,9 @@
* represents the state of the horizontal scrollbar.
* The declared return type of this method is
* <code>Adjustable</code> to maintain backward compatibility.
+ *
* @see java.awt.ScrollPaneAdjustable
+ * @return the horizontal scrollbar state
*/
public Adjustable getHAdjustable() {
return hAdjustable;
@@ -657,6 +661,9 @@
* Indicates whether or not scrolling will take place in response to
* the mouse wheel. Wheel scrolling is enabled by default.
*
+ * @return {@code true} if the wheel scrolling enabled;
+ * otherwise {@code false}
+ *
* @see #setWheelScrollingEnabled(boolean)
* @since 1.4
*/
--- a/jdk/src/share/classes/java/awt/Scrollbar.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Scrollbar.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -656,6 +656,9 @@
}
/**
+ * Returns the visible amount of this scroll bar.
+ *
+ * @return the visible amount of this scroll bar
* @deprecated As of JDK version 1.1,
* replaced by <code>getVisibleAmount()</code>.
*/
@@ -729,6 +732,10 @@
}
/**
+ * Sets the unit increment for this scroll bar.
+ *
+ * @param v the increment value
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setUnitIncrement(int)</code>.
*/
@@ -768,6 +775,9 @@
}
/**
+ * Returns the unit increment for this scrollbar.
+ *
+ * @return the unit increment for this scrollbar
* @deprecated As of JDK version 1.1,
* replaced by <code>getUnitIncrement()</code>.
*/
@@ -797,6 +807,9 @@
}
/**
+ * Sets the block increment for this scroll bar.
+ *
+ * @param v the block increment
* @deprecated As of JDK version 1.1,
* replaced by <code>setBlockIncrement()</code>.
*/
@@ -833,6 +846,10 @@
}
/**
+ * Returns the block increment of this scroll bar.
+ *
+ * @return the block increment of this scroll bar
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>getBlockIncrement()</code>.
*/
--- a/jdk/src/share/classes/java/awt/TextArea.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/TextArea.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -314,6 +314,11 @@
}
/**
+ * Inserts the specified text at the specified position
+ * in this text area.
+ *
+ * @param str the non-{@code null} text to insert
+ * @param pos the position at which to insert
* @deprecated As of JDK version 1.1,
* replaced by <code>insert(String, int)</code>.
*/
@@ -342,6 +347,9 @@
}
/**
+ * Appends the given text to the text area's current text.
+ *
+ * @param str the text to append
* @deprecated As of JDK version 1.1,
* replaced by <code>append(String)</code>.
*/
@@ -378,6 +386,15 @@
}
/**
+ * Replaces a range of characters between
+ * the indicated start and end positions
+ * with the specified replacement text (the text at the end
+ * position will not be replaced).
+ *
+ * @param str the non-{@code null} text to use as
+ * the replacement
+ * @param start the start position
+ * @param end the end position
* @deprecated As of JDK version 1.1,
* replaced by <code>replaceRange(String, int, int)</code>.
*/
@@ -492,6 +509,12 @@
}
/**
+ * Determines the preferred size of the text area with the specified
+ * number of rows and columns.
+ *
+ * @param rows the number of rows
+ * @param columns the number of columns
+ * @return the preferred dimensions needed for the text area
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize(int, int)</code>.
*/
@@ -544,6 +567,12 @@
}
/**
+ * Determines the minimum size of the text area with the specified
+ * number of rows and columns.
+ *
+ * @param rows the number of rows
+ * @param columns the number of columns
+ * @return the minimum size for the text area
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize(int, int)</code>.
*/
--- a/jdk/src/share/classes/java/awt/TextComponent.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/TextComponent.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -107,6 +107,9 @@
// the background color of non-editable TextComponents.
boolean backgroundSetByClientCode = false;
+ /**
+ * A list of listeners that will receive events from this object.
+ */
transient protected TextListener textListener;
/*
--- a/jdk/src/share/classes/java/awt/TextField.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/TextField.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -272,6 +272,10 @@
}
/**
+ * Sets the character to be echoed when protected input is displayed.
+ *
+ * @param c the echo character for this text field
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>setEchoChar(char)</code>.
*/
@@ -368,6 +372,12 @@
}
/**
+ * Returns the preferred size for this text field
+ * with the specified number of columns.
+ *
+ * @param columns the number of columns
+ * @return the preferred size for the text field
+ *
* @deprecated As of JDK version 1.1,
* replaced by <code>getPreferredSize(int)</code>.
*/
@@ -407,8 +417,9 @@
/**
* Gets the minimum dimensions for a text field with
* the specified number of columns.
- * @param columns the number of columns in
- * this text field.
+ * @param columns the number of columns in
+ * this text field.
+ * @return the minimum size for this text field
* @since 1.1
*/
public Dimension getMinimumSize(int columns) {
@@ -416,6 +427,11 @@
}
/**
+ * Returns the minimum dimensions for a text field with
+ * the specified number of columns.
+ *
+ * @param columns the number of columns
+ * @return the minimum size for this text field
* @deprecated As of JDK version 1.1,
* replaced by <code>getMinimumSize(int)</code>.
*/
--- a/jdk/src/share/classes/java/awt/Toolkit.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Toolkit.java Tue Jul 01 10:20:56 2014 -0700
@@ -422,7 +422,8 @@
* and allows the Component and Container classes to be extended directly
* to create windowless components that are defined entirely in java.
*
- * @param target The Component to be created.
+ * @param target The Component to be created.
+ * @return the peer for the specified component
*/
protected LightweightPeer createComponent(Component target) {
if (lightweightMarker == null) {
@@ -1370,6 +1371,9 @@
* {@link java.awt.event.KeyEvent#VK_SCROLL_LOCK VK_SCROLL_LOCK}, and
* {@link java.awt.event.KeyEvent#VK_KANA_LOCK VK_KANA_LOCK}.
*
+ * @param keyCode the key code
+ * @return {@code true} if the given key is currently in its "on" state;
+ * otherwise {@code false}
* @exception java.lang.IllegalArgumentException if <code>keyCode</code>
* is not one of the valid key codes
* @exception java.lang.UnsupportedOperationException if the host system doesn't
@@ -1404,6 +1408,8 @@
* involve event processing and therefore may not be immediately
* observable through getLockingKeyState.
*
+ * @param keyCode the key code
+ * @param on the state of the key
* @exception java.lang.IllegalArgumentException if <code>keyCode</code>
* is not one of the valid key codes
* @exception java.lang.UnsupportedOperationException if the host system doesn't
@@ -1429,6 +1435,9 @@
/**
* Give native peers the ability to query the native container
* given a native component (eg the direct parent may be lightweight).
+ *
+ * @param c the component to fetch the container for
+ * @return the native container object for the component
*/
protected static Container getNativeContainer(Component c) {
return c.getNativeContainer();
@@ -1449,6 +1458,7 @@
* @param name a localized description of the cursor, for Java Accessibility use
* @exception IndexOutOfBoundsException if the hotSpot values are outside
* the bounds of the cursor
+ * @return the cursor created
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
@@ -1675,6 +1685,11 @@
/**
* Gets a property with the specified key and default.
* This method returns defaultValue if the property is not found.
+ *
+ * @param key the key
+ * @param defaultValue the default value
+ * @return the value of the property or the default value
+ * if the property was not found
*/
public static String getProperty(String key, String defaultValue) {
// first try platform specific bundle
@@ -1738,6 +1753,9 @@
* Creates the peer for a DragSourceContext.
* Always throws InvalidDndOperationException if
* GraphicsEnvironment.isHeadless() returns true.
+ *
+ * @param dge the {@code DragGestureEvent}
+ * @return the peer created
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException;
@@ -1775,6 +1793,9 @@
* representation for an underlying platform dependent desktop setting.
* For more information on desktop properties supported by the AWT see
* <a href="doc-files/DesktopProperties.html">AWT Desktop Properties</a>.
+ *
+ * @param propertyName the property name
+ * @return the value for the specified desktop property
*/
public final synchronized Object getDesktopProperty(String propertyName) {
// This is a workaround for headless toolkits. It would be
@@ -1818,6 +1839,9 @@
/**
* Sets the named desktop property to the specified value and fires a
* property change event to notify any listeners that the value has changed.
+ *
+ * @param name the property name
+ * @param newValue the new property value
*/
protected final void setDesktopProperty(String name, Object newValue) {
// This is a workaround for headless toolkits. It would be
--- a/jdk/src/share/classes/java/awt/Window.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/Window.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2014, 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
@@ -1452,6 +1452,8 @@
/**
* Returns the owner of this window.
+ *
+ * @return the owner of this window
* @since 1.2
*/
public Window getOwner() {
@@ -1464,6 +1466,8 @@
/**
* Return an array containing all the windows this
* window currently owns.
+ *
+ * @return the array of all the owned windows
* @since 1.2
*/
public Window[] getOwnedWindows() {
@@ -1586,6 +1590,7 @@
* dialogs such as component positions, {@code LayoutManager}s
* or serialization.
*
+ * @return the array of all the {@code Window}s created by the application
* @see Frame#getFrames
* @see Window#getOwnerlessWindows
*
@@ -1608,6 +1613,8 @@
* dialogs such as component positions, {@code LayoutManager}s
* or serialization.
*
+ * @return the array of all the ownerless {@code Window}s
+ * created by this application
* @see Frame#getFrames
* @see Window#getWindows()
*
@@ -2849,6 +2856,7 @@
*
* This method can only be called while the window is not displayable.
*
+ * @param type the window type
* @throws IllegalComponentStateException if the window
* is displayable.
* @throws IllegalArgumentException if the type is {@code null}
@@ -2874,6 +2882,7 @@
/**
* Returns the type of the window.
*
+ * @return the type of the window
* @see #setType
* @since 1.7
*/
--- a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java Tue Jul 01 10:20:56 2014 -0700
@@ -337,7 +337,7 @@
* the specified parameter.
*/
public ParameterBlock add(byte b) {
- return add(new Byte(b));
+ return add(Byte.valueOf(b));
}
/**
@@ -348,7 +348,7 @@
* the specified parameter.
*/
public ParameterBlock add(char c) {
- return add(new Character(c));
+ return add(Character.valueOf(c));
}
/**
@@ -359,7 +359,7 @@
* the specified parameter.
*/
public ParameterBlock add(short s) {
- return add(new Short(s));
+ return add(Short.valueOf(s));
}
/**
@@ -381,7 +381,7 @@
* the specified parameter.
*/
public ParameterBlock add(long l) {
- return add(new Long(l));
+ return add(Long.valueOf(l));
}
/**
@@ -441,7 +441,7 @@
* the specified parameter.
*/
public ParameterBlock set(byte b, int index) {
- return set(new Byte(b), index);
+ return set(Byte.valueOf(b), index);
}
/**
@@ -457,7 +457,7 @@
* the specified parameter.
*/
public ParameterBlock set(char c, int index) {
- return set(new Character(c), index);
+ return set(Character.valueOf(c), index);
}
/**
@@ -473,7 +473,7 @@
* the specified parameter.
*/
public ParameterBlock set(short s, int index) {
- return set(new Short(s), index);
+ return set(Short.valueOf(s), index);
}
/**
@@ -505,7 +505,7 @@
* the specified parameter.
*/
public ParameterBlock set(long l, int index) {
- return set(new Long(l), index);
+ return set(Long.valueOf(l), index);
}
/**
--- a/jdk/src/share/classes/java/beans/Statement.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/beans/Statement.java Tue Jul 01 10:20:56 2014 -0700
@@ -248,7 +248,7 @@
// ignored elsewhere.
if (target == Character.class && arguments.length == 1 &&
argClasses[0] == String.class) {
- return new Character(((String)arguments[0]).charAt(0));
+ return ((String)arguments[0]).charAt(0);
}
try {
m = ConstructorFinder.findConstructor((Class)target, argClasses);
--- a/jdk/src/share/classes/java/lang/ClassLoader.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java Tue Jul 01 10:20:56 2014 -0700
@@ -1859,18 +1859,17 @@
String name = NativeLibrary.findBuiltinLib(file.getName());
boolean isBuiltin = (name != null);
if (!isBuiltin) {
- boolean exists = AccessController.doPrivileged(
- new PrivilegedAction<Object>() {
- public Object run() {
- return file.exists() ? Boolean.TRUE : null;
- }})
- != null;
- if (!exists) {
- return false;
- }
- try {
- name = file.getCanonicalPath();
- } catch (IOException e) {
+ name = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
+ try {
+ return file.exists() ? file.getCanonicalPath() : null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ });
+ if (name == null) {
return false;
}
}
--- a/jdk/src/share/classes/java/lang/Package.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/lang/Package.java Tue Jul 01 10:20:56 2014 -0700
@@ -107,6 +107,7 @@
* loader to be found.
*
* @see ClassLoader#definePackage
+ * @since 1.2
*/
public class Package implements java.lang.reflect.AnnotatedElement {
/**
--- a/jdk/src/share/classes/java/lang/SafeVarargs.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/lang/SafeVarargs.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, 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 @@
* <li> the declaration is a fixed arity method or constructor
*
* <li> the declaration is a variable arity method that is neither
- * {@code static} nor {@code final}.
+ * {@code static} nor {@code final} nor {@code private}.
*
* </ul>
*
--- a/jdk/src/share/classes/java/text/DecimalFormat.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/text/DecimalFormat.java Tue Jul 01 10:20:56 2014 -0700
@@ -2094,7 +2094,7 @@
}
return gotDouble ?
- (Number)new Double(doubleResult) : (Number)new Long(longResult);
+ (Number)new Double(doubleResult) : (Number)Long.valueOf(longResult);
}
}
--- a/jdk/src/share/classes/java/util/Collections.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/util/Collections.java Tue Jul 01 10:20:56 2014 -0700
@@ -3031,9 +3031,11 @@
final Collection<E> c;
final Class<E> type;
- void typeCheck(Object o) {
+ @SuppressWarnings("unchecked")
+ E typeCheck(Object o) {
if (o != null && !type.isInstance(o))
throw new ClassCastException(badElementMsg(o));
+ return (E) o;
}
private String badElementMsg(Object o) {
@@ -3042,10 +3044,8 @@
}
CheckedCollection(Collection<E> c, Class<E> type) {
- if (c==null || type == null)
- throw new NullPointerException();
- this.c = c;
- this.type = type;
+ this.c = Objects.requireNonNull(c, "c");
+ this.type = Objects.requireNonNull(type, "type");
}
public int size() { return c.size(); }
@@ -3077,10 +3077,7 @@
public void remove() { it.remove(); }};
}
- public boolean add(E e) {
- typeCheck(e);
- return c.add(e);
- }
+ public boolean add(E e) { return c.add(typeCheck(e)); }
private E[] zeroLengthElementArray; // Lazily initialized
@@ -3091,7 +3088,7 @@
@SuppressWarnings("unchecked")
Collection<E> checkedCopyOf(Collection<? extends E> coll) {
- Object[] a = null;
+ Object[] a;
try {
E[] z = zeroLengthElementArray();
a = coll.toArray(z);
@@ -3187,11 +3184,7 @@
public E peek() {return queue.peek();}
public E poll() {return queue.poll();}
public E remove() {return queue.remove();}
-
- public boolean offer(E e) {
- typeCheck(e);
- return add(e);
- }
+ public boolean offer(E e) {return queue.offer(typeCheck(e));}
}
/**
@@ -3440,13 +3433,11 @@
public int lastIndexOf(Object o) { return list.lastIndexOf(o); }
public E set(int index, E element) {
- typeCheck(element);
- return list.set(index, element);
+ return list.set(index, typeCheck(element));
}
public void add(int index, E element) {
- typeCheck(element);
- list.add(index, element);
+ list.add(index, typeCheck(element));
}
public boolean addAll(int index, Collection<? extends E> c) {
@@ -3467,13 +3458,11 @@
public void remove() { i.remove(); }
public void set(E e) {
- typeCheck(e);
- i.set(e);
+ i.set(typeCheck(e));
}
public void add(E e) {
- typeCheck(e);
- i.add(e);
+ i.add(typeCheck(e));
}
@Override
@@ -3487,10 +3476,19 @@
return new CheckedList<>(list.subList(fromIndex, toIndex), type);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @throws ClassCastException if the class of an element returned by the
+ * operator prevents it from being added to this collection. The
+ * exception may be thrown after some elements of the list have
+ * already been replaced.
+ */
@Override
public void replaceAll(UnaryOperator<E> operator) {
- list.replaceAll(operator);
- }
+ list.replaceAll(e -> typeCheck(operator.apply(e)));
+ }
+
@Override
public void sort(Comparator<? super E> c) {
list.sort(c);
--- a/jdk/src/share/classes/java/util/Currency.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/java/util/Currency.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, 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
@@ -212,13 +212,9 @@
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
- String homeDir = System.getProperty("java.home");
try {
- String dataFile = homeDir + File.separator +
- "lib" + File.separator + "currency.data";
try (DataInputStream dis = new DataInputStream(
- new BufferedInputStream(
- new FileInputStream(dataFile)))) {
+ new BufferedInputStream(getClass().getResourceAsStream("/java/util/currency.data")))) {
if (dis.readInt() != MAGIC_NUMBER) {
throw new InternalError("Currency data is possibly corrupted");
}
@@ -248,7 +244,7 @@
// look for the properties file for overrides
String propsFile = System.getProperty("java.util.currency.data");
if (propsFile == null) {
- propsFile = homeDir + File.separator + "lib" +
+ propsFile = System.getProperty("java.home") + File.separator + "lib" +
File.separator + "currency.properties";
}
try {
--- a/jdk/src/share/classes/javax/crypto/CipherInputStream.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/crypto/CipherInputStream.java Tue Jul 01 10:20:56 2014 -0700
@@ -170,7 +170,6 @@
* @return the next byte of data, or <code>-1</code> if the end of the
* stream is reached.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public int read() throws IOException {
if (ostart >= ofinish) {
@@ -196,7 +195,6 @@
* the stream has been reached.
* @exception IOException if an I/O error occurs.
* @see java.io.InputStream#read(byte[], int, int)
- * @since JCE1.2
*/
public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
@@ -217,7 +215,6 @@
* the stream has been reached.
* @exception IOException if an I/O error occurs.
* @see java.io.InputStream#read()
- * @since JCE1.2
*/
public int read(byte b[], int off, int len) throws IOException {
if (ostart >= ofinish) {
@@ -254,7 +251,6 @@
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public long skip(long n) throws IOException {
int available = ofinish - ostart;
@@ -277,7 +273,6 @@
* @return the number of bytes that can be read from this input stream
* without blocking.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public int available() throws IOException {
return (ofinish - ostart);
@@ -292,7 +287,6 @@
* stream.
*
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void close() throws IOException {
if (closed) {
@@ -321,7 +315,6 @@
* <code>mark</code> and <code>reset</code> methods.
* @see java.io.InputStream#mark(int)
* @see java.io.InputStream#reset()
- * @since JCE1.2
*/
public boolean markSupported() {
return false;
--- a/jdk/src/share/classes/javax/crypto/CipherOutputStream.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/crypto/CipherOutputStream.java Tue Jul 01 10:20:56 2014 -0700
@@ -114,7 +114,6 @@
*
* @param b the <code>byte</code>.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void write(int b) throws IOException {
ibuffer[0] = (byte) b;
@@ -138,7 +137,6 @@
* @exception NullPointerException if <code>b</code> is null.
* @exception IOException if an I/O error occurs.
* @see javax.crypto.CipherOutputStream#write(byte[], int, int)
- * @since JCE1.2
*/
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
@@ -152,7 +150,6 @@
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void write(byte b[], int off, int len) throws IOException {
obuffer = cipher.update(b, off, len);
@@ -174,7 +171,6 @@
* the cipher's block size, no bytes will be written out.
*
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void flush() throws IOException {
if (obuffer != null) {
@@ -198,7 +194,6 @@
* stream.
*
* @exception IOException if an I/O error occurs.
- * @since JCE1.2
*/
public void close() throws IOException {
if (closed) {
--- a/jdk/src/share/classes/javax/management/loading/MLet.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/management/loading/MLet.java Tue Jul 01 10:20:56 2014 -0700
@@ -1307,11 +1307,11 @@
if (type.compareTo("java.lang.Boolean") == 0)
return Boolean.valueOf(param);
if (type.compareTo("java.lang.Byte") == 0)
- return new Byte(param);
+ return Byte.valueOf(param);
if (type.compareTo("java.lang.Short") == 0)
- return new Short(param);
+ return Short.valueOf(param);
if (type.compareTo("java.lang.Long") == 0)
- return new Long(param);
+ return Long.valueOf(param);
if (type.compareTo("java.lang.Integer") == 0)
return new Integer(param);
if (type.compareTo("java.lang.Float") == 0)
--- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Tue Jul 01 10:20:56 2014 -0700
@@ -544,7 +544,7 @@
}
// convert seconds to milliseconds for time comparison
- currencyPeriod = ((new Long(expTime)).longValue()) * 1000;
+ currencyPeriod = Long.parseLong(expTime) * 1000;
if (currencyPeriod < 0) {
/* if currencyTimeLimit is -1 then value is never cached */
returnCachedValue = false;
@@ -580,7 +580,7 @@
if (tStamp == null)
tStamp = "0";
- long lastTime = (new Long(tStamp)).longValue();
+ long lastTime = Long.parseLong(tStamp);
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
--- a/jdk/src/share/classes/javax/naming/InitialContext.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/naming/InitialContext.java Tue Jul 01 10:20:56 2014 -0700
@@ -125,7 +125,7 @@
* @see Context
* @see NamingManager#setInitialContextFactoryBuilder
* NamingManager.setInitialContextFactoryBuilder
- * @since JNDI 1.1 / Java 2 Platform, Standard Edition, v 1.3
+ * @since 1.3, JNDI 1.1
*/
public class InitialContext implements Context {
--- a/jdk/src/share/classes/javax/security/auth/Subject.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/security/auth/Subject.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, 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
@@ -142,7 +142,9 @@
* <p> The newly constructed Sets check whether this {@code Subject}
* has been set read-only before permitting subsequent modifications.
* The newly created Sets also prevent illegal modifications
- * by ensuring that callers have sufficient permissions.
+ * by ensuring that callers have sufficient permissions. These Sets
+ * also prohibit null elements, and attempts to add or query a null
+ * element will result in a {@code NullPointerException}.
*
* <p> To modify the Principals Set, the caller must have
* {@code AuthPermission("modifyPrincipals")}.
@@ -170,7 +172,9 @@
* These newly created Sets check whether this {@code Subject}
* has been set read-only before permitting subsequent modifications.
* The newly created Sets also prevent illegal modifications
- * by ensuring that callers have sufficient permissions.
+ * by ensuring that callers have sufficient permissions. These Sets
+ * also prohibit null elements, and attempts to add or query a null
+ * element will result in a {@code NullPointerException}.
*
* <p> To modify the Principals Set, the caller must have
* {@code AuthPermission("modifyPrincipals")}.
@@ -194,17 +198,16 @@
*
* @exception NullPointerException if the specified
* {@code principals}, {@code pubCredentials},
- * or {@code privCredentials} are {@code null}.
+ * or {@code privCredentials} are {@code null},
+ * or a null value exists within any of these three
+ * Sets.
*/
public Subject(boolean readOnly, Set<? extends Principal> principals,
Set<?> pubCredentials, Set<?> privCredentials)
{
-
- if (principals == null ||
- pubCredentials == null ||
- privCredentials == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.input.s."));
+ collectionNullClean(principals);
+ collectionNullClean(pubCredentials);
+ collectionNullClean(privCredentials);
this.principals = Collections.synchronizedSet(new SecureSet<Principal>
(this, PRINCIPAL_SET, principals));
@@ -287,18 +290,17 @@
sm.checkPermission(AuthPermissionHolder.GET_SUBJECT_PERMISSION);
}
- if (acc == null) {
- throw new NullPointerException(ResourcesMgr.getString
+ Objects.requireNonNull(acc, ResourcesMgr.getString
("invalid.null.AccessControlContext.provided"));
- }
// return the Subject from the DomainCombiner of the provided context
return AccessController.doPrivileged
(new java.security.PrivilegedAction<Subject>() {
public Subject run() {
DomainCombiner dc = acc.getDomainCombiner();
- if (!(dc instanceof SubjectDomainCombiner))
+ if (!(dc instanceof SubjectDomainCombiner)) {
return null;
+ }
SubjectDomainCombiner sdc = (SubjectDomainCombiner)dc;
return sdc.getSubject();
}
@@ -347,9 +349,9 @@
if (sm != null) {
sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION);
}
- if (action == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.action.provided"));
+
+ Objects.requireNonNull(action,
+ ResourcesMgr.getString("invalid.null.action.provided"));
// set up the new Subject-based AccessControlContext
// for doPrivileged
@@ -410,9 +412,8 @@
sm.checkPermission(AuthPermissionHolder.DO_AS_PERMISSION);
}
- if (action == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.action.provided"));
+ Objects.requireNonNull(action,
+ ResourcesMgr.getString("invalid.null.action.provided"));
// set up the new Subject-based AccessControlContext for doPrivileged
final AccessControlContext currentAcc = AccessController.getContext();
@@ -467,9 +468,8 @@
sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION);
}
- if (action == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.action.provided"));
+ Objects.requireNonNull(action,
+ ResourcesMgr.getString("invalid.null.action.provided"));
// set up the new Subject-based AccessControlContext
// for doPrivileged
@@ -534,9 +534,8 @@
sm.checkPermission(AuthPermissionHolder.DO_AS_PRIVILEGED_PERMISSION);
}
- if (action == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.action.provided"));
+ Objects.requireNonNull(action,
+ ResourcesMgr.getString("invalid.null.action.provided"));
// set up the new Subject-based AccessControlContext for doPrivileged
final AccessControlContext callerAcc =
@@ -557,13 +556,14 @@
return java.security.AccessController.doPrivileged
(new java.security.PrivilegedAction<AccessControlContext>() {
public AccessControlContext run() {
- if (subject == null)
+ if (subject == null) {
return new AccessControlContext(acc, null);
- else
+ } else {
return new AccessControlContext
(acc,
new SubjectDomainCombiner(subject));
}
+ }
});
}
@@ -615,9 +615,8 @@
*/
public <T extends Principal> Set<T> getPrincipals(Class<T> c) {
- if (c == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.Class.provided"));
+ Objects.requireNonNull(c,
+ ResourcesMgr.getString("invalid.null.Class.provided"));
// always return an empty Set instead of null
// so LoginModules can add to the Set if necessary
@@ -711,9 +710,8 @@
*/
public <T> Set<T> getPublicCredentials(Class<T> c) {
- if (c == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.Class.provided"));
+ Objects.requireNonNull(c,
+ ResourcesMgr.getString("invalid.null.Class.provided"));
// always return an empty Set instead of null
// so LoginModules can add to the Set if necessary
@@ -758,9 +756,8 @@
// would do is protect the set operations themselves
// (like size()), which don't seem security-sensitive.
- if (c == null)
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.Class.provided"));
+ Objects.requireNonNull(c,
+ ResourcesMgr.getString("invalid.null.Class.provided"));
// always return an empty Set instead of null
// so LoginModules can add to the Set if necessary
@@ -790,11 +787,13 @@
*/
public boolean equals(Object o) {
- if (o == null)
+ if (o == null) {
return false;
+ }
- if (this == o)
+ if (this == o) {
return true;
+ }
if (o instanceof Subject) {
@@ -969,11 +968,10 @@
Set<Principal> inputPrincs = (Set<Principal>)gf.get("principals", null);
+ Objects.requireNonNull(inputPrincs,
+ ResourcesMgr.getString("invalid.null.input.s."));
+
// Rewrap the principals into a SecureSet
- if (inputPrincs == null) {
- throw new NullPointerException
- (ResourcesMgr.getString("invalid.null.input.s."));
- }
try {
principals = Collections.synchronizedSet(new SecureSet<Principal>
(this, PRINCIPAL_SET, inputPrincs));
@@ -993,13 +991,43 @@
}
/**
+ * Tests for null-clean collections (both non-null reference and
+ * no null elements)
+ *
+ * @param coll A {@code Collection} to be tested for null references
+ *
+ * @exception NullPointerException if the specified collection is either
+ * {@code null} or contains a {@code null} element
+ */
+ private static void collectionNullClean(Collection<?> coll) {
+ boolean hasNullElements = false;
+
+ Objects.requireNonNull(coll,
+ ResourcesMgr.getString("invalid.null.input.s."));
+
+ try {
+ hasNullElements = coll.contains(null);
+ } catch (NullPointerException npe) {
+ // A null-hostile collection may choose to throw
+ // NullPointerException if contains(null) is called on it
+ // rather than returning false.
+ // If this happens we know the collection is null-clean.
+ hasNullElements = false;
+ } finally {
+ if (hasNullElements) {
+ throw new NullPointerException
+ (ResourcesMgr.getString("invalid.null.input.s."));
+ }
+ }
+ }
+
+ /**
* Prevent modifications unless caller has permission.
*
* @serial include
*/
private static class SecureSet<E>
- extends AbstractSet<E>
- implements java.io.Serializable {
+ implements Set<E>, java.io.Serializable {
private static final long serialVersionUID = 7911754171111800359L;
@@ -1098,6 +1126,9 @@
public boolean add(E o) {
+ Objects.requireNonNull(o,
+ ResourcesMgr.getString("invalid.null.input.s."));
+
if (subject.isReadOnly()) {
throw new IllegalStateException
(ResourcesMgr.getString("Subject.is.read.only"));
@@ -1133,12 +1164,16 @@
// check for duplicates
if (!elements.contains(o))
return elements.add(o);
- else
+ else {
return false;
}
+ }
public boolean remove(Object o) {
+ Objects.requireNonNull(o,
+ ResourcesMgr.getString("invalid.null.input.s."));
+
final Iterator<E> e = iterator();
while (e.hasNext()) {
E next;
@@ -1153,12 +1188,7 @@
});
}
- if (next == null) {
- if (o == null) {
- e.remove();
- return true;
- }
- } else if (next.equals(o)) {
+ if (next.equals(o)) {
e.remove();
return true;
}
@@ -1167,6 +1197,10 @@
}
public boolean contains(Object o) {
+
+ Objects.requireNonNull(o,
+ ResourcesMgr.getString("invalid.null.input.s."));
+
final Iterator<E> e = iterator();
while (e.hasNext()) {
E next;
@@ -1194,19 +1228,28 @@
});
}
- if (next == null) {
- if (o == null) {
- return true;
- }
- } else if (next.equals(o)) {
+ if (next.equals(o)) {
return true;
}
}
return false;
}
+ public boolean addAll(Collection<? extends E> c) {
+ boolean result = false;
+
+ collectionNullClean(c);
+
+ for (E item : c) {
+ result |= this.add(item);
+ }
+
+ return result;
+ }
+
public boolean removeAll(Collection<?> c) {
- Objects.requireNonNull(c);
+ collectionNullClean(c);
+
boolean modified = false;
final Iterator<E> e = iterator();
while (e.hasNext()) {
@@ -1224,30 +1267,34 @@
Iterator<?> ce = c.iterator();
while (ce.hasNext()) {
- Object o = ce.next();
- if (next == null) {
- if (o == null) {
+ if (next.equals(ce.next())) {
e.remove();
modified = true;
break;
}
- } else if (next.equals(o)) {
- e.remove();
- modified = true;
- break;
- }
}
}
return modified;
}
+ public boolean containsAll(Collection<?> c) {
+ collectionNullClean(c);
+
+ for (Object item : c) {
+ if (this.contains(item) == false) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
public boolean retainAll(Collection<?> c) {
- Objects.requireNonNull(c);
+ collectionNullClean(c);
+
boolean modified = false;
- boolean retain = false;
final Iterator<E> e = iterator();
while (e.hasNext()) {
- retain = false;
E next;
if (which != Subject.PRIV_CREDENTIAL_SET) {
next = e.next();
@@ -1260,26 +1307,12 @@
});
}
- Iterator<?> ce = c.iterator();
- while (ce.hasNext()) {
- Object o = ce.next();
- if (next == null) {
- if (o == null) {
- retain = true;
- break;
- }
- } else if (next.equals(o)) {
- retain = true;
- break;
+ if (c.contains(next) == false) {
+ e.remove();
+ modified = true;
}
}
- if (!retain) {
- e.remove();
- retain = false;
- modified = true;
- }
- }
return modified;
}
@@ -1301,6 +1334,73 @@
}
}
+ public boolean isEmpty() {
+ return elements.isEmpty();
+ }
+
+ public Object[] toArray() {
+ final Iterator<E> e = iterator();
+ while (e.hasNext()) {
+ // The next() method performs a security manager check
+ // on each element in the SecureSet. If we make it all
+ // the way through we should be able to simply return
+ // element's toArray results. Otherwise we'll let
+ // the SecurityException pass up the call stack.
+ e.next();
+ }
+
+ return elements.toArray();
+ }
+
+ public <T> T[] toArray(T[] a) {
+ final Iterator<E> e = iterator();
+ while (e.hasNext()) {
+ // The next() method performs a security manager check
+ // on each element in the SecureSet. If we make it all
+ // the way through we should be able to simply return
+ // element's toArray results. Otherwise we'll let
+ // the SecurityException pass up the call stack.
+ e.next();
+ }
+
+ return elements.toArray(a);
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+
+ if (!(o instanceof Set)) {
+ return false;
+ }
+
+ Collection<?> c = (Collection<?>) o;
+ if (c.size() != size()) {
+ return false;
+ }
+
+ try {
+ return containsAll(c);
+ } catch (ClassCastException unused) {
+ return false;
+ } catch (NullPointerException unused) {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ int h = 0;
+ Iterator<E> i = iterator();
+ while (i.hasNext()) {
+ E obj = i.next();
+ if (obj != null) {
+ h += obj.hashCode();
+ }
+ }
+ return h;
+ }
+
/**
* Writes this object out to a stream (i.e., serializes it).
*
@@ -1338,12 +1438,16 @@
which = fields.get("which", 0);
LinkedList<E> tmp = (LinkedList<E>) fields.get("elements", null);
+
+ Subject.collectionNullClean(tmp);
+
if (tmp.getClass() != LinkedList.class) {
elements = new LinkedList<E>(tmp);
} else {
elements = tmp;
}
}
+
}
/**
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Tue Jul 01 10:20:56 2014 -0700
@@ -458,7 +458,7 @@
Integer fiveHundred = new Integer(500);
// *** Shared Longs
- Long oneThousand = new Long(1000);
+ Long oneThousand = 1000L;
LazyValue dialogPlain12 = t ->
new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalBorders.java Tue Jul 01 10:20:56 2014 -0700
@@ -56,6 +56,9 @@
static Object NO_BUTTON_ROLLOVER =
new StringUIClientPropertyKey("NoButtonRollover");
+ /**
+ * The class represents the 3D border.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class Flush3DBorder extends AbstractBorder implements UIResource{
public void paintBorder(Component c, Graphics g, int x, int y,
@@ -73,9 +76,15 @@
}
}
+ /**
+ * The class represents the border of a {@code JButton}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class ButtonBorder extends AbstractBorder implements UIResource {
+ /**
+ * The border insets.
+ */
protected static Insets borderInsets = new Insets( 3, 3, 3, 3 );
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
@@ -188,6 +197,9 @@
}
}
+ /**
+ * The class represents the border of a {@code JInternalFrame}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class InternalFrameBorder extends AbstractBorder implements UIResource {
private static final int corner = 14;
@@ -470,6 +482,9 @@
}
}
+ /**
+ * The class represents the border of an option dialog.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class OptionDialogBorder extends AbstractBorder implements UIResource {
int titleHeight = 0;
@@ -532,8 +547,15 @@
}
}
+ /**
+ * The class represents the border of a {@code JMenuBar}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class MenuBarBorder extends AbstractBorder implements UIResource {
+
+ /**
+ * The border insets.
+ */
protected static Insets borderInsets = new Insets( 1, 0, 1, 0 );
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
@@ -569,8 +591,15 @@
}
}
+ /**
+ * The class represents the border of a {@code JMenuItem}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class MenuItemBorder extends AbstractBorder implements UIResource {
+
+ /**
+ * The border insets.
+ */
protected static Insets borderInsets = new Insets( 2, 2, 2, 2 );
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
@@ -617,8 +646,15 @@
}
}
+ /**
+ * The class represents the border of a {@code JPopupMenu}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class PopupMenuBorder extends AbstractBorder implements UIResource {
+
+ /**
+ * The border insets.
+ */
protected static Insets borderInsets = new Insets( 3, 1, 2, 1 );
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
@@ -642,6 +678,9 @@
}
}
+ /**
+ * The class represents the border of a rollover {@code Button}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class RolloverButtonBorder extends ButtonBorder {
@@ -693,9 +732,15 @@
}
}
+ /**
+ * The class represents the border of a {@code JToolBar}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants
{
+ /**
+ * The instance of {@code MetalBumps}.
+ */
protected MetalBumps bumps = new MetalBumps( 10, 10,
MetalLookAndFeel.getControlHighlight(),
MetalLookAndFeel.getControlDarkShadow(),
@@ -779,7 +824,9 @@
private static Border buttonBorder;
/**
- * Returns a border instance for a JButton
+ * Returns a border instance for a {@code JButton}.
+ *
+ * @return a border instance for a {@code JButton}
* @since 1.3
*/
public static Border getButtonBorder() {
@@ -794,7 +841,9 @@
private static Border textBorder;
/**
- * Returns a border instance for a text component
+ * Returns a border instance for a text component.
+ *
+ * @return a border instance for a text component
* @since 1.3
*/
public static Border getTextBorder() {
@@ -809,7 +858,9 @@
private static Border textFieldBorder;
/**
- * Returns a border instance for a JTextField
+ * Returns a border instance for a {@code JTextField}.
+ *
+ * @return a border instance for a {@code JTextField}
* @since 1.3
*/
public static Border getTextFieldBorder() {
@@ -821,6 +872,9 @@
return textFieldBorder;
}
+ /**
+ * The class represents the border of a {@code JTestField}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class TextFieldBorder extends Flush3DBorder {
@@ -846,6 +900,9 @@
}
}
+ /**
+ * The class represents the border of a {@code JScrollPane}.
+ */
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class ScrollPaneBorder extends AbstractBorder implements UIResource {
public void paintBorder(Component c, Graphics g, int x, int y,
@@ -892,7 +949,9 @@
private static Border toggleButtonBorder;
/**
- * Returns a border instance for a JToggleButton
+ * Returns a border instance for a {@code JToggleButton}.
+ *
+ * @return a border instance for a {@code JToggleButton}
* @since 1.3
*/
public static Border getToggleButtonBorder() {
@@ -942,6 +1001,10 @@
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
public static class TableHeaderBorder extends javax.swing.border.AbstractBorder {
+
+ /**
+ * The border insets.
+ */
protected Insets editorBorderInsets = new Insets( 2, 2, 2, 0 );
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
@@ -964,7 +1027,9 @@
}
/**
- * Returns a border instance for a Desktop Icon
+ * Returns a border instance for a Desktop Icon.
+ *
+ * @return a border instance for a Desktop Icon
* @since 1.3
*/
public static Border getDesktopIconBorder() {
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -52,10 +52,22 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
public class MetalButtonUI extends BasicButtonUI {
+
// NOTE: These are not really needed, but at this point we can't pull
// them. Their values are updated purely for historical reasons.
+ /**
+ * The color of the focused button.
+ */
protected Color focusColor;
+
+ /**
+ * The color of the selected button.
+ */
protected Color selectColor;
+
+ /**
+ * The color of the disabled color.
+ */
protected Color disabledTextColor;
private static final Object METAL_BUTTON_UI_KEY = new Object();
@@ -63,6 +75,13 @@
// ********************************
// Create PLAF
// ********************************
+
+ /**
+ * Returns an instance of {@code MetalButtonUI}.
+ *
+ * @param c a component
+ * @return an instance of {@code MetalButtonUI}
+ */
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MetalButtonUI metalButtonUI =
@@ -96,17 +115,33 @@
// ********************************
// Default Accessors
// ********************************
+
+ /**
+ * Returns the color of the selected button.
+ *
+ * @return the color of the selected button
+ */
protected Color getSelectColor() {
selectColor = UIManager.getColor(getPropertyPrefix() + "select");
return selectColor;
}
+ /**
+ * Returns the color of a disabled text.
+ *
+ * @return the color of a disabled text
+ */
protected Color getDisabledTextColor() {
disabledTextColor = UIManager.getColor(getPropertyPrefix() +
"disabledText");
return disabledTextColor;
}
+ /**
+ * Returns the color of the focused button.
+ *
+ * @return the color of the focused button
+ */
protected Color getFocusColor() {
focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
return focusColor;
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxIcon.java Tue Jul 01 10:20:56 2014 -0700
@@ -49,6 +49,11 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalCheckBoxIcon implements Icon, UIResource, Serializable {
+ /**
+ * Returns the size of the control.
+ *
+ * @return the size of the control
+ */
protected int getControlSize() { return 13; }
public void paintIcon(Component c, Graphics g, int x, int y) {
@@ -91,6 +96,14 @@
}
}
+ /**
+ * Paints {@code MetalCheckBoxIcon}.
+ *
+ * @param c a component
+ * @param g an instance of {@code Graphics}
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ */
protected void drawCheck(Component c, Graphics g, int x, int y) {
int controlSize = getControlSize();
g.fillRect( x+3, y+5, 2, controlSize-8 );
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -67,6 +67,13 @@
// ********************************
// Create PlAF
// ********************************
+
+ /**
+ * Returns an instance of {@code MetalCheckBoxUI}.
+ *
+ * @param b a component
+ * @return a new instance of {@code MetalCheckBoxUI}
+ */
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
MetalCheckBoxUI checkboxUI =
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxButton.java Tue Jul 01 10:20:56 2014 -0700
@@ -50,19 +50,72 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
public class MetalComboBoxButton extends JButton {
+
+ /**
+ * The instance of {@code JComboBox}.
+ */
protected JComboBox comboBox;
+
+ /**
+ * The instance of {@code JList}.
+ */
protected JList listBox;
+
+ /**
+ * The instance of {@code CellRendererPane}.
+ */
protected CellRendererPane rendererPane;
+
+ /**
+ * The icon.
+ */
protected Icon comboIcon;
+
+ /**
+ * The {@code iconOnly} value.
+ */
protected boolean iconOnly = false;
+ /**
+ * Returns the {@code JComboBox}.
+ *
+ * @return the {@code JComboBox}
+ */
public final JComboBox getComboBox() { return comboBox;}
+
+ /**
+ * Sets the {@code JComboBox}.
+ *
+ * @param cb the {@code JComboBox}
+ */
public final void setComboBox( JComboBox cb ) { comboBox = cb;}
+ /**
+ * Returns the icon of the {@code JComboBox}.
+ *
+ * @return the icon of the {@code JComboBox}
+ */
public final Icon getComboIcon() { return comboIcon;}
+
+ /**
+ * Sets the icon of the {@code JComboBox}.
+ *
+ * @param i the icon of the {@code JComboBox}
+ */
public final void setComboIcon( Icon i ) { comboIcon = i;}
+ /**
+ * Returns the {@code isIconOnly} value.
+ *
+ * @return the {@code isIconOnly} value
+ */
public final boolean isIconOnly() { return iconOnly;}
+
+ /**
+ * If {@code isIconOnly} is {@code true} then only icon is painted.
+ *
+ * @param isIconOnly if {@code true} then only icon is painted
+ */
public final void setIconOnly( boolean isIconOnly ) { iconOnly = isIconOnly;}
MetalComboBoxButton() {
@@ -75,6 +128,14 @@
setModel( model );
}
+ /**
+ * Constructs a new instance of {@code MetalComboBoxButton}.
+ *
+ * @param cb an instance of {@code JComboBox}
+ * @param i an icon
+ * @param pane an instance of {@code CellRendererPane}
+ * @param list an instance of {@code JList}
+ */
public MetalComboBoxButton( JComboBox cb, Icon i,
CellRendererPane pane, JList list ) {
this();
@@ -85,6 +146,15 @@
setEnabled( comboBox.isEnabled() );
}
+ /**
+ * Constructs a new instance of {@code MetalComboBoxButton}.
+ *
+ * @param cb an instance of {@code JComboBox}
+ * @param i an icon
+ * @param onlyIcon if {@code true} only icon is painted
+ * @param pane an instance of {@code CellRendererPane}
+ * @param list an instance of {@code JList}
+ */
public MetalComboBoxButton( JComboBox cb, Icon i, boolean onlyIcon,
CellRendererPane pane, JList list ) {
this( cb, i, pane, list );
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxEditor.java Tue Jul 01 10:20:56 2014 -0700
@@ -50,6 +50,9 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalComboBoxEditor extends BasicComboBoxEditor {
+ /**
+ * Constructs a new instance of {@code MetalComboBoxEditor}.
+ */
public MetalComboBoxEditor() {
super();
//editor.removeFocusListener(this);
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -54,6 +54,12 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalComboBoxUI extends BasicComboBoxUI {
+ /**
+ * Constructs an instance of {@code MetalComboBoxUI}.
+ *
+ * @param c a component
+ * @return an instance of {@code MetalComboBoxUI}
+ */
public static ComponentUI createUI(JComponent c) {
return new MetalComboBoxUI();
}
@@ -234,6 +240,7 @@
* override. All the functionality of this method is in the
* MetalPropertyChangeListener.
*
+ * @param e an instance of {@code PropertyChangeEvent}
* @deprecated As of Java 2 platform v1.4.
*/
@Deprecated
@@ -251,11 +258,23 @@
public void layoutContainer( Container parent ) {
layoutComboBox( parent, this );
}
+
+ /**
+ * Lays out the parent container.
+ *
+ * @param parent a container
+ */
public void superLayout( Container parent ) {
super.layoutContainer( parent );
}
}
+ /**
+ * Lays out the {@code JComboBox} in the {@code parent} container.
+ *
+ * @param parent a container
+ * @param manager an instance of {@code MetalComboBoxLayoutManager}
+ */
// This is here because of a bug in the compiler.
// When a protected-inner-class-savvy compiler comes out we
// should move this into MetalComboBoxLayoutManager.
@@ -367,6 +386,11 @@
@Deprecated
public class MetalComboPopup extends BasicComboPopup {
+ /**
+ * Constructs a new instance of {@code MetalComboPopup}.
+ *
+ * @param cBox an instance of {@code JComboBox}
+ */
public MetalComboPopup( JComboBox cBox) {
super( cBox );
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalDesktopIconUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalDesktopIconUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -48,10 +48,19 @@
TitleListener titleListener;
private int width;
+ /**
+ * Constructs a new instance of {@code MetalDesktopIconUI}.
+ *
+ * @param c a component
+ * @return a new instance of {@code MetalDesktopIconUI}
+ */
public static ComponentUI createUI(JComponent c) {
return new MetalDesktopIconUI();
}
+ /**
+ * Constructs a new instance of {@code MetalDesktopIconUI}.
+ */
public MetalDesktopIconUI() {
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -138,13 +138,21 @@
}
}
- //
- // ComponentUI Interface Implementation methods
- //
+ /**
+ * Constructs a new instance of {@code MetalFileChooserUI}.
+ *
+ * @param c a component
+ * @return a new instance of {@code MetalFileChooserUI}
+ */
public static ComponentUI createUI(JComponent c) {
return new MetalFileChooserUI((JFileChooser) c);
}
+ /**
+ * Constructs a new instance of {@code MetalFileChooserUI}.
+ *
+ * @param filechooser a {@code JFileChooser}
+ */
public MetalFileChooserUI(JFileChooser filechooser) {
super(filechooser);
}
@@ -446,6 +454,11 @@
groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}
+ /**
+ * Returns the button panel.
+ *
+ * @return the button panel
+ */
protected JPanel getButtonPanel() {
if (buttonPanel == null) {
buttonPanel = new JPanel();
@@ -453,6 +466,11 @@
return buttonPanel;
}
+ /**
+ * Returns the bottom panel.
+ *
+ * @return the bottom panel
+ */
protected JPanel getBottomPanel() {
if(bottomPanel == null) {
bottomPanel = new JPanel();
@@ -503,20 +521,42 @@
SwingUtilities.replaceUIActionMap(fc, actionMap);
}
+ /**
+ * Returns an instance of {@code ActionMap}.
+ *
+ * @return an instance of {@code ActionMap}
+ */
protected ActionMap getActionMap() {
return createActionMap();
}
+ /**
+ * Constructs an instance of {@code ActionMap}.
+ *
+ * @return an instance of {@code ActionMap}
+ */
protected ActionMap createActionMap() {
ActionMap map = new ActionMapUIResource();
FilePane.addActionsToMap(map, filePane.getActions());
return map;
}
+ /**
+ * Constructs a details view.
+ *
+ * @param fc a {@code JFileChooser}
+ * @return the list
+ */
protected JPanel createList(JFileChooser fc) {
return filePane.createList();
}
+ /**
+ * Constructs a details view.
+ *
+ * @param fc a {@code JFileChooser}
+ * @return the details view
+ */
protected JPanel createDetailsView(JFileChooser fc) {
return filePane.createDetailsView();
}
@@ -533,7 +573,12 @@
// Obsolete class, not used in this version.
protected class SingleClickListener extends MouseAdapter {
- public SingleClickListener(JList list) {
+ /**
+ * Constructs an instance of {@code SingleClickListener}.
+ *
+ * @param list an instance of {@code JList}
+ */
+ public SingleClickListener(JList list) {
}
}
@@ -788,11 +833,16 @@
};
}
-
+ /**
+ * Removes control buttons from bottom panel.
+ */
protected void removeControlButtons() {
getBottomPanel().remove(getButtonPanel());
}
+ /**
+ * Adds control buttons to bottom panel.
+ */
protected void addControlButtons() {
getBottomPanel().add(getButtonPanel());
}
@@ -842,15 +892,31 @@
}
}
+ /**
+ * Returns the directory name.
+ *
+ * @return the directory name
+ */
public String getDirectoryName() {
// PENDING(jeff) - get the name from the directory combobox
return null;
}
+ /**
+ * Sets the directory name.
+ *
+ * @param dirname the directory name
+ */
public void setDirectoryName(String dirname) {
// PENDING(jeff) - set the name in the directory combobox
}
+ /**
+ * Constructs a new instance of {@code DirectoryComboBoxRenderer}.
+ *
+ * @param fc a {@code JFileChooser}
+ * @return a new instance of {@code DirectoryComboBoxRenderer}
+ */
protected DirectoryComboBoxRenderer createDirectoryComboBoxRenderer(JFileChooser fc) {
return new DirectoryComboBoxRenderer();
}
@@ -906,9 +972,12 @@
}
- //
- // DataModel for DirectoryComboxbox
- //
+ /**
+ * Constructs a new instance of {@code DataModel} for {@code DirectoryComboBox}.
+ *
+ * @param fc a {@code JFileChooser}
+ * @return a new instance of {@code DataModel} for {@code DirectoryComboBox}
+ */
protected DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc) {
return new DirectoryComboBoxModel();
}
@@ -924,6 +993,9 @@
JFileChooser chooser = getFileChooser();
FileSystemView fsv = chooser.getFileSystemView();
+ /**
+ * Constructs an instance of {@code DirectoryComboBoxModel}.
+ */
public DirectoryComboBoxModel() {
// Add the current directory to the model, and make it the
// selectedDirectory
@@ -1017,6 +1089,12 @@
}
}
+ /**
+ * Returns the depth of {@code i}-th file.
+ *
+ * @param i an index
+ * @return the depth of {@code i}-th file
+ */
public int getDepth(int i) {
return (depths != null && i >= 0 && i < depths.length) ? depths[i] : 0;
}
@@ -1039,9 +1117,11 @@
}
}
- //
- // Renderer for Types ComboBox
- //
+ /**
+ * Constructs a {@code Renderer} for types {@code ComboBox}.
+ *
+ * @return a {@code Renderer} for types {@code ComboBox}
+ */
protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
return new FilterComboBoxRenderer();
}
@@ -1065,9 +1145,11 @@
}
}
- //
- // DataModel for Types Comboxbox
- //
+ /**
+ * Constructs a {@code DataModel} for types {@code ComboBox}.
+ *
+ * @return a {@code DataModel} for types {@code ComboBox}
+ */
protected FilterComboBoxModel createFilterComboBoxModel() {
return new FilterComboBoxModel();
}
@@ -1077,7 +1159,15 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
protected class FilterComboBoxModel extends AbstractListModel<Object> implements ComboBoxModel<Object>, PropertyChangeListener {
+
+ /**
+ * An array of file filters.
+ */
protected FileFilter[] filters;
+
+ /**
+ * Constructs an instance of {@code FilterComboBoxModel}.
+ */
protected FilterComboBoxModel() {
super();
filters = getFileChooser().getChoosableFileFilters();
@@ -1142,6 +1232,11 @@
}
}
+ /**
+ * Invokes when {@code ListSelectionEvent} occurs.
+ *
+ * @param e an instance of {@code ListSelectionEvent}
+ */
public void valueChanged(ListSelectionEvent e) {
JFileChooser fc = getFileChooser();
File f = fc.getSelectedFile();
@@ -1155,6 +1250,10 @@
*/
@SuppressWarnings("serial") // Superclass is not serializable across versions
protected class DirectoryComboBoxAction extends AbstractAction {
+
+ /**
+ * Constructs a new instance of {@code DirectoryComboBoxAction}.
+ */
protected DirectoryComboBoxAction() {
super("DirectoryComboBoxAction");
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java Tue Jul 01 10:20:56 2014 -0700
@@ -90,10 +90,22 @@
private static Icon oceanVerticalSliderThumb;
// Constants
+ /**
+ * {@code DARK} is used for the property {@code Tree.expandedIcon}.
+ */
public static final boolean DARK = false;
+
+ /**
+ * {@code LIGHT} is used for the property {@code Tree.collapsedIcon}.
+ */
public static final boolean LIGHT = true;
// Accessor functions for Icons. Does the caching work.
+ /**
+ * Returns the instance of {@code FileChooserDetailViewIcon}.
+ *
+ * @return the instance of {@code FileChooserDetailViewIcon}
+ */
public static Icon getFileChooserDetailViewIcon() {
if (fileChooserDetailViewIcon == null) {
fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
@@ -101,6 +113,11 @@
return fileChooserDetailViewIcon;
}
+ /**
+ * Returns the instance of {@code FileChooserHomeFolderIcon}.
+ *
+ * @return the instance of {@code FileChooserHomeFolderIcon}
+ */
public static Icon getFileChooserHomeFolderIcon() {
if (fileChooserHomeFolderIcon == null) {
fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
@@ -108,6 +125,11 @@
return fileChooserHomeFolderIcon;
}
+ /**
+ * Returns the instance of {@code FileChooserListViewIcon}.
+ *
+ * @return the instance of {@code FileChooserListViewIcon}
+ */
public static Icon getFileChooserListViewIcon() {
if (fileChooserListViewIcon == null) {
fileChooserListViewIcon = new FileChooserListViewIcon();
@@ -115,6 +137,11 @@
return fileChooserListViewIcon;
}
+ /**
+ * Returns the instance of {@code FileChooserNewFolderIcon}.
+ *
+ * @return the instance of {@code FileChooserNewFolderIcon}
+ */
public static Icon getFileChooserNewFolderIcon() {
if (fileChooserNewFolderIcon == null) {
fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
@@ -122,6 +149,11 @@
return fileChooserNewFolderIcon;
}
+ /**
+ * Returns the instance of {@code FileChooserUpFolderIcon}.
+ *
+ * @return the instance of {@code FileChooserUpFolderIcon}
+ */
public static Icon getFileChooserUpFolderIcon() {
if (fileChooserUpFolderIcon == null) {
fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
@@ -129,14 +161,31 @@
return fileChooserUpFolderIcon;
}
+ /**
+ * Constructs a new instance of {@code InternalFrameAltMaximizeIcon}.
+ *
+ * @param size the size of the icon
+ * @return a new instance of {@code InternalFrameAltMaximizeIcon}
+ */
public static Icon getInternalFrameAltMaximizeIcon(int size) {
return new InternalFrameAltMaximizeIcon(size);
}
+ /**
+ * Constructs a new instance of {@code InternalFrameCloseIcon}.
+ *
+ * @param size the size of the icon
+ * @return a new instance of {@code InternalFrameCloseIcon}
+ */
public static Icon getInternalFrameCloseIcon(int size) {
return new InternalFrameCloseIcon(size);
}
+ /**
+ * Returns the instance of {@code InternalFrameDefaultMenuIcon}.
+ *
+ * @return the instance of {@code InternalFrameDefaultMenuIcon}
+ */
public static Icon getInternalFrameDefaultMenuIcon() {
if (internalFrameDefaultMenuIcon == null) {
internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
@@ -144,14 +193,31 @@
return internalFrameDefaultMenuIcon;
}
+ /**
+ * Constructs a new instance of {@code InternalFrameMaximizeIcon}.
+ *
+ * @param size the size of the icon
+ * @return a new instance of {@code InternalFrameMaximizeIcon}
+ */
public static Icon getInternalFrameMaximizeIcon(int size) {
return new InternalFrameMaximizeIcon(size);
}
+ /**
+ * Constructs a new instance of {@code InternalFrameMinimizeIcon}.
+ *
+ * @param size the size of the icon
+ * @return a new instance of {@code InternalFrameMinimizeIcon}
+ */
public static Icon getInternalFrameMinimizeIcon(int size) {
return new InternalFrameMinimizeIcon(size);
}
+ /**
+ * Returns the instance of {@code RadioButtonIcon}.
+ *
+ * @return the instance of {@code RadioButtonIcon}
+ */
public static Icon getRadioButtonIcon() {
if (radioButtonIcon == null) {
radioButtonIcon = new RadioButtonIcon();
@@ -161,6 +227,8 @@
/**
* Returns a checkbox icon.
+ *
+ * @return a checkbox icon
* @since 1.3
*/
public static Icon getCheckBoxIcon() {
@@ -170,6 +238,11 @@
return checkBoxIcon;
}
+ /**
+ * Returns the instance of {@code TreeComputerIcon}.
+ *
+ * @return the instance of {@code TreeComputerIcon}
+ */
public static Icon getTreeComputerIcon() {
if ( treeComputerIcon == null ) {
treeComputerIcon = new TreeComputerIcon();
@@ -177,6 +250,11 @@
return treeComputerIcon;
}
+ /**
+ * Returns the instance of {@code TreeFloppyDriveIcon}.
+ *
+ * @return the instance of {@code TreeFloppyDriveIcon}
+ */
public static Icon getTreeFloppyDriveIcon() {
if ( treeFloppyDriveIcon == null ) {
treeFloppyDriveIcon = new TreeFloppyDriveIcon();
@@ -184,10 +262,20 @@
return treeFloppyDriveIcon;
}
+ /**
+ * Constructs a new instance of {@code TreeFolderIcon}.
+ *
+ * @return a new instance of {@code TreeFolderIcon}
+ */
public static Icon getTreeFolderIcon() {
return new TreeFolderIcon();
}
+ /**
+ * Returns the instance of {@code TreeHardDriveIcon}.
+ *
+ * @return the instance of {@code TreeHardDriveIcon}
+ */
public static Icon getTreeHardDriveIcon() {
if ( treeHardDriveIcon == null ) {
treeHardDriveIcon = new TreeHardDriveIcon();
@@ -195,14 +283,30 @@
return treeHardDriveIcon;
}
+ /**
+ * Constructs a new instance of {@code TreeLeafIcon}.
+ *
+ * @return a new instance of {@code TreeLeafIcon}
+ */
public static Icon getTreeLeafIcon() {
return new TreeLeafIcon();
}
+ /**
+ * Constructs a new instance of {@code TreeControlIcon}.
+ *
+ * @param isCollapsed if {@code true} the icon is collapsed
+ * @return a new instance of {@code TreeControlIcon}
+ */
public static Icon getTreeControlIcon( boolean isCollapsed ) {
return new TreeControlIcon( isCollapsed );
}
+ /**
+ * Returns an icon to be used by {@code JMenu}.
+ *
+ * @return an icon to be used by {@code JMenu}
+ */
public static Icon getMenuArrowIcon() {
if (menuArrowIcon == null) {
menuArrowIcon = new MenuArrowIcon();
@@ -220,6 +324,11 @@
return null;
}
+ /**
+ * Returns an icon to be used by {@code JMenuItem}.
+ *
+ * @return an icon to be used by {@code JMenuItem}
+ */
public static Icon getMenuItemArrowIcon() {
if (menuItemArrowIcon == null) {
menuItemArrowIcon = new MenuItemArrowIcon();
@@ -227,6 +336,11 @@
return menuItemArrowIcon;
}
+ /**
+ * Returns an icon to be used by {@code JCheckBoxMenuItem}.
+ *
+ * @return an icon to be used by {@code JCheckBoxMenuItem}
+ */
public static Icon getCheckBoxMenuItemIcon() {
if (checkBoxMenuItemIcon == null) {
checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
@@ -234,6 +348,11 @@
return checkBoxMenuItemIcon;
}
+ /**
+ * Returns an icon to be used by {@code JRadioButtonMenuItem}.
+ *
+ * @return an icon to be used by {@code JRadioButtonMenuItem}
+ */
public static Icon getRadioButtonMenuItemIcon() {
if (radioButtonMenuItemIcon == null) {
radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
@@ -241,6 +360,11 @@
return radioButtonMenuItemIcon;
}
+ /**
+ * Returns a thumb icon to be used by horizontal slider.
+ *
+ * @return a thumb icon to be used by horizontal slider
+ */
public static Icon getHorizontalSliderThumbIcon() {
if (MetalLookAndFeel.usingOcean()) {
if (oceanHorizontalSliderThumb == null) {
@@ -253,6 +377,11 @@
return new HorizontalSliderThumbIcon();
}
+ /**
+ * Returns a thumb icon to be used by vertical slider.
+ *
+ * @return a thumb icon to be used by vertical slider
+ */
public static Icon getVerticalSliderThumbIcon() {
if (MetalLookAndFeel.usingOcean()) {
if (oceanVerticalSliderThumb == null) {
@@ -1621,7 +1750,18 @@
}
+ /**
+ * Returns a shift of the icon.
+ *
+ * @return a shift of the icon
+ */
public int getShift() { return 0; }
+
+ /**
+ * Returns an additional height of the icon.
+ *
+ * @return an additional height of the icon
+ */
public int getAdditionalHeight() { return 0; }
public int getIconWidth() { return folderIcon16Size.width; }
@@ -1719,7 +1859,18 @@
}
+ /**
+ * Returns a shift of the icon.
+ *
+ * @return a shift of the icon
+ */
public int getShift() { return 0; }
+
+ /**
+ * Returns an additional height of the icon.
+ *
+ * @return an additional height of the icon
+ */
public int getAdditionalHeight() { return 0; }
public int getIconWidth() { return fileIcon16Size.width; }
@@ -1727,6 +1878,9 @@
}
+ /**
+ * The class represents a tree leaf icon.
+ */
public static class TreeLeafIcon extends FileIcon16 {
public int getShift() { return 2; }
public int getAdditionalHeight() { return 4; }
@@ -1748,12 +1902,20 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
public static class TreeControlIcon implements Icon, Serializable {
- // This data member should not have been exposed. It's called
- // isLight, but now it really means isCollapsed. Since we can't change
- // any APIs... that's life.
+
+ /**
+ * if {@code true} the icon is collapsed.
+ * NOTE: This data member should not have been exposed. It's called
+ * {@code isLight}, but now it really means {@code isCollapsed}.
+ * Since we can't change any APIs... that's life.
+ */
protected boolean isLight;
-
+ /**
+ * Constructs an instance of {@code TreeControlIcon}.
+ *
+ * @param isCollapsed if {@code true} the icon is collapsed
+ */
public TreeControlIcon( boolean isCollapsed ) {
isLight = isCollapsed;
}
@@ -1811,6 +1973,14 @@
}
}
+ /**
+ * Paints the {@code TreeControlIcon}.
+ *
+ * @param c a component
+ * @param g an instance of {@code Graphics}
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ */
public void paintMe(Component c, Graphics g, int x, int y) {
g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
@@ -1823,7 +1993,7 @@
g.drawLine( xoff + 6, 4, xoff + 9, 4 ); // top
g.drawLine( xoff + 10, 5, xoff + 10, 5 ); // top right dot
g.drawLine( xoff + 11, 6, xoff + 11, 9 ); // right
- g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // botom right dot
+ g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // bottom right dot
g.drawLine( xoff + 6, 11, xoff + 9, 11 ); // bottom
g.drawLine( xoff + 5, 10, xoff + 5, 10 ); // bottom left dot
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java Tue Jul 01 10:20:56 2014 -0700
@@ -46,8 +46,19 @@
@SuppressWarnings("serial") // Superclass is not serializable across versions
public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane {
+ /**
+ * The value {@code isPalette}
+ */
protected boolean isPalette = false;
+
+ /**
+ * The palette close icon.
+ */
protected Icon paletteCloseIcon;
+
+ /**
+ * The height of the palette title.
+ */
protected int paletteTitleHeight;
private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0);
@@ -94,6 +105,11 @@
private Color activeBumpsShadow = MetalLookAndFeel.
getPrimaryControlDarkShadow();
+ /**
+ * Constructs a new instance of {@code MetalInternalFrameTitlePane}
+ *
+ * @param f an instance of {@code JInternalFrame}
+ */
public MetalInternalFrameTitlePane(JInternalFrame f) {
super( f );
}
@@ -307,6 +323,11 @@
}
}
+ /**
+ * Paints palette.
+ *
+ * @param g a instance of {@code Graphics}
+ */
public void paintPalette(Graphics g) {
boolean leftToRight = MetalUtils.isLeftToRight(frame);
@@ -471,6 +492,11 @@
bumps.paintIcon(this, g, bumpXOffset, bumpYOffset);
}
+ /**
+ * If {@code b} is {@code true}, sets palette icons.
+ *
+ * @param b if {@code true}, sets palette icons
+ */
public void setPalette(boolean b) {
isPalette = b;
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -47,6 +47,9 @@
private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0);
+ /**
+ * The property {@code JInternalFrame.isPalette}.
+ */
protected static String IS_PALETTE = "JInternalFrame.isPalette";
private static String IS_PALETTE_KEY = "JInternalFrame.isPalette";
private static String FRAME_TYPE = "JInternalFrame.frameType";
@@ -54,10 +57,22 @@
private static String PALETTE_FRAME = "palette";
private static String OPTION_DIALOG = "optionDialog";
+
+ /**
+ * Constructs a new {@code MetalInternalFrameUI} instance.
+ *
+ * @param b an internal frame
+ */
public MetalInternalFrameUI(JInternalFrame b) {
super(b);
}
+ /**
+ * Constructs a new {@code MetalInternalFrameUI} instance.
+ *
+ * @param c a component
+ * @return a new {@code MetalInternalFrameUI} instance
+ */
public static ComponentUI createUI(JComponent c) {
return new MetalInternalFrameUI( (JInternalFrame) c);
}
@@ -152,6 +167,11 @@
}
}
+ /**
+ * If {@code isPalette} is {@code true}, sets palette border and title
+ *
+ * @param isPalette if {@code true}, sets palette border and title
+ */
// this should be deprecated - jcs
public void setPalette(boolean isPalette) {
if (isPalette) {
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -56,6 +56,12 @@
private static final Object METAL_LABEL_UI_KEY = new Object();
+ /**
+ * Returns an instance of {@code MetalLabelUI}.
+ *
+ * @param c a component
+ * @return an instance of {@code MetalLabelUI}
+ */
public static ComponentUI createUI(JComponent c) {
if (System.getSecurityManager() != null) {
AppContext appContext = AppContext.getAppContext();
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -43,6 +43,12 @@
public class MetalPopupMenuSeparatorUI extends MetalSeparatorUI
{
+ /**
+ * Constructs a new {@code MetalPopupMenuSeparatorUI} instance.
+ *
+ * @param c a component
+ * @return a new {@code MetalPopupMenuSeparatorUI} instance
+ */
public static ComponentUI createUI( JComponent c )
{
return new MetalPopupMenuSeparatorUI();
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalProgressBarUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -50,6 +50,12 @@
private Rectangle innards;
private Rectangle box;
+ /**
+ * Constructs an instance of {@code MetalProgressBarUI}.
+ *
+ * @param c a component
+ * @return an instance of {@code MetalProgressBarUI}
+ */
public static ComponentUI createUI(JComponent c) {
return new MetalProgressBarUI();
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -58,8 +58,19 @@
private static final Object METAL_RADIO_BUTTON_UI_KEY = new Object();
+ /**
+ * The color of the focused radio button.
+ */
protected Color focusColor;
+
+ /**
+ * The color of the selected radio button.
+ */
protected Color selectColor;
+
+ /**
+ * The color of a disabled text.
+ */
protected Color disabledTextColor;
private boolean defaults_initialized = false;
@@ -67,6 +78,13 @@
// ********************************
// Create PlAF
// ********************************
+
+ /**
+ * Returns an instance of {@code MetalRadioButtonUI}.
+ *
+ * @param c a component
+ * @return an instance of {@code MetalRadioButtonUI}
+ */
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
MetalRadioButtonUI metalRadioButtonUI =
@@ -100,14 +118,30 @@
// ********************************
// Default Accessors
// ********************************
+
+ /**
+ * Returns the color of the selected {@code JRadioButton}.
+ *
+ * @return the color of the selected {@code JRadioButton}
+ */
protected Color getSelectColor() {
return selectColor;
}
+ /**
+ * Returns the color of the disabled text.
+ *
+ * @return the color of the disabled text
+ */
protected Color getDisabledTextColor() {
return disabledTextColor;
}
+ /**
+ * Returns the color of the focused {@code JRadioButton}.
+ *
+ * @return the color of the focused {@code JRadioButton}
+ */
protected Color getFocusColor() {
return focusColor;
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollBarUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -59,17 +59,42 @@
private static Color thumbShadow;
private static Color thumbHighlightColor;
-
+ /**
+ * The metal bumps.
+ */
protected MetalBumps bumps;
+ /**
+ * The increase button.
+ */
protected MetalScrollButton increaseButton;
+
+ /**
+ * The decrease button.
+ */
protected MetalScrollButton decreaseButton;
+ /**
+ * The width of the scroll bar.
+ */
protected int scrollBarWidth;
+ /**
+ * The property {@code JScrollBar.isFreeStanding}.
+ */
public static final String FREE_STANDING_PROP = "JScrollBar.isFreeStanding";
+
+ /**
+ * The value of the property {@code JScrollBar.isFreeStanding}.
+ */
protected boolean isFreeStanding = true;
+ /**
+ * Constructs a new {@code MetalScrollBarUI} instance.
+ *
+ * @param c a component
+ * @return a new {@code MetalScrollBarUI} instance
+ */
public static ComponentUI createUI( JComponent c )
{
return new MetalScrollBarUI();
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollButton.java Tue Jul 01 10:20:56 2014 -0700
@@ -59,6 +59,13 @@
private int buttonWidth;
+ /**
+ * Constructs an instance of {@code MetalScrollButton}.
+ *
+ * @param direction the direction
+ * @param width the width
+ * @param freeStanding the free standing value
+ */
public MetalScrollButton( int direction, int width, boolean freeStanding )
{
super( direction );
@@ -70,6 +77,11 @@
isFreeStanding = freeStanding;
}
+ /**
+ * Sets the free standing value.
+ *
+ * @param freeStanding the free standing value
+ */
public void setFreeStanding( boolean freeStanding )
{
isFreeStanding = freeStanding;
@@ -115,14 +127,10 @@
g.setColor( arrowColor );
int startY = ((h+1) - arrowHeight) / 2;
int startX = (w / 2);
- // System.out.println( "startX :" + startX + " startY :"+startY);
+
for (int line = 0; line < arrowHeight; line++) {
g.drawLine( startX-line, startY+line, startX +line+1, startY+line);
}
- /* g.drawLine( 7, 6, 8, 6 );
- g.drawLine( 6, 7, 9, 7 );
- g.drawLine( 5, 8, 10, 8 );
- g.drawLine( 4, 9, 11, 9 );*/
if (isEnabled) {
g.setColor( highlightColor );
@@ -167,17 +175,10 @@
int startY = (((h+1) - arrowHeight) / 2)+ arrowHeight-1;
int startX = (w / 2);
- // System.out.println( "startX2 :" + startX + " startY2 :"+startY);
-
for (int line = 0; line < arrowHeight; line++) {
g.drawLine( startX-line, startY-line, startX +line+1, startY-line);
}
- /* g.drawLine( 4, 5, 11, 5 );
- g.drawLine( 5, 6, 10, 6 );
- g.drawLine( 6, 7, 9, 7 );
- g.drawLine( 7, 8, 8, 8 ); */
-
if (isEnabled) {
g.setColor( highlightColor );
@@ -219,18 +220,10 @@
int startX = (((w+1) - arrowHeight) / 2) + arrowHeight-1;
int startY = (h / 2);
- //System.out.println( "startX2 :" + startX + " startY2 :"+startY);
-
for (int line = 0; line < arrowHeight; line++) {
g.drawLine( startX-line, startY-line, startX -line, startY+line+1);
}
-
-/* g.drawLine( 5, 4, 5, 11 );
- g.drawLine( 6, 5, 6, 10 );
- g.drawLine( 7, 6, 7, 9 );
- g.drawLine( 8, 7, 8, 8 );*/
-
if (isEnabled) {
g.setColor( highlightColor );
@@ -274,11 +267,6 @@
g.drawLine( startX+line, startY-line, startX +line, startY+line+1);
}
- /* g.drawLine( 6, 7, 6, 8 );
- g.drawLine( 7, 6, 7, 9 );
- g.drawLine( 8, 5, 8, 10 );
- g.drawLine( 9, 4, 9, 11 );*/
-
if (isEnabled) {
g.setColor( highlightColor );
@@ -341,6 +329,11 @@
return new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE );
}
+ /**
+ * Returns the width of the button.
+ *
+ * @return the width of the button
+ */
public int getButtonWidth() {
return buttonWidth;
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -56,6 +56,12 @@
private PropertyChangeListener scrollBarSwapListener;
+ /**
+ * Constructs a new {@code MetalScrollPaneUI}.
+ *
+ * @param x a component
+ * @return a new {@code MetalScrollPaneUI}
+ */
public static ComponentUI createUI(JComponent x) {
return new MetalScrollPaneUI();
}
@@ -97,6 +103,7 @@
}
/**
+ * @param scrollPane an instance of the {@code JScrollPane}
* @deprecated - Replaced by {@link #uninstallListeners(JComponent)}
*/
@Deprecated
@@ -136,6 +143,11 @@
}
}
+ /**
+ * Returns a new {@code PropertyChangeListener} for scroll bar swap events.
+ *
+ * @return a new {@code PropertyChangeListener} for scroll bar swap events.
+ */
protected PropertyChangeListener createScrollBarSwapListener() {
return new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSeparatorUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -53,6 +53,12 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalSeparatorUI extends BasicSeparatorUI
{
+ /**
+ * Constructs a new {@code MetalSeparatorUI} instance.
+ *
+ * @param c a component
+ * @return a new {@code MetalSeparatorUI} instance.
+ */
public static ComponentUI createUI( JComponent c )
{
return new MetalSeparatorUI();
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -53,13 +53,42 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalSliderUI extends BasicSliderUI {
+ /**
+ * The buffer of a tick.
+ */
protected final int TICK_BUFFER = 4;
+
+ /**
+ * The value of the property {@code JSlider.isFilled}.
+ * By default, {@code false} if the property is not set,
+ * {@code true} for Ocean theme.
+ */
protected boolean filledSlider = false;
+
// NOTE: these next five variables are currently unused.
+ /**
+ * The color of a thumb
+ */
protected static Color thumbColor;
+
+ /**
+ * The color of highlighting.
+ */
protected static Color highlightColor;
+
+ /**
+ * The color of dark shadow.
+ */
protected static Color darkShadowColor;
+
+ /**
+ * The width of a track.
+ */
protected static int trackWidth;
+
+ /**
+ * The length of a tick.
+ */
protected static int tickLength;
private int safeLength;
@@ -80,13 +109,24 @@
private static Icon SAFE_HORIZ_THUMB_ICON;
private static Icon SAFE_VERT_THUMB_ICON;
-
+ /**
+ * Property for {@code JSlider.isFilled}.
+ */
protected final String SLIDER_FILL = "JSlider.isFilled";
+ /**
+ * Constructs a {@code MetalSliderUI} instance.
+ *
+ * @param c a component
+ * @return a {@code MetalSliderUI} instance
+ */
public static ComponentUI createUI(JComponent c) {
return new MetalSliderUI();
}
+ /**
+ * Constructs a {@code MetalSliderUI} instance.
+ */
public MetalSliderUI() {
super( null );
}
@@ -126,10 +166,19 @@
prepareFilledSliderField();
}
+ /**
+ * Constructs {@code MetalPropertyListener}.
+ *
+ * @param slider a {@code JSlider}
+ * @return the {@code MetalPropertyListener}
+ */
protected PropertyChangeListener createPropertyChangeListener( JSlider slider ) {
return new MetalPropertyListener();
}
+ /**
+ * {@code PropertyListener} for {@code JSlider.isFilled}.
+ */
protected class MetalPropertyListener extends BasicSliderUI.PropertyChangeHandler {
public void propertyChange( PropertyChangeEvent e ) { // listen for slider fill
super.propertyChange( e );
@@ -485,6 +534,8 @@
/**
* Returns the shorter dimension of the track.
+ *
+ * @return the shorter dimension of the track
*/
protected int getTrackWidth() {
// This strange calculation is here to keep the
@@ -504,6 +555,8 @@
/**
* Returns the longer dimension of the slide bar. (The slide bar is only the
* part that runs directly under the thumb)
+ *
+ * @return the longer dimension of the slide bar
*/
protected int getTrackLength() {
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
@@ -514,6 +567,8 @@
/**
* Returns the amount that the thumb goes past the slide bar.
+ *
+ * @return the amount that the thumb goes past the slide bar
*/
protected int getThumbOverhang() {
return (int)(getThumbSize().getHeight()-getTrackWidth())/2;
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalSplitPaneUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -49,15 +49,20 @@
/**
- * Creates a new MetalSplitPaneUI instance
- */
+ * Creates a new {@code MetalSplitPaneUI} instance
+ *
+ * @param x a component
+ * @return a new {@code MetalSplitPaneUI} instance
+ */
public static ComponentUI createUI(JComponent x) {
return new MetalSplitPaneUI();
}
/**
- * Creates the default divider.
- */
+ * Creates the default divider.
+ *
+ * @return the default divider
+ */
public BasicSplitPaneDivider createDefaultDivider() {
return new MetalSplitPaneDivider(this);
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -50,12 +50,27 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalTabbedPaneUI extends BasicTabbedPaneUI {
+ /**
+ * The minimum width of a pane.
+ */
protected int minTabWidth = 40;
// Background color for unselected tabs that don't have an explicitly
// set color.
private Color unselectedBackground;
+
+ /**
+ * The color of tab's background.
+ */
protected Color tabAreaBackground;
+
+ /**
+ * The color of the selected pane.
+ */
protected Color selectColor;
+
+ /**
+ * The color of the highlight.
+ */
protected Color selectHighlight;
private boolean tabsOpaque = true;
@@ -65,6 +80,12 @@
// Selected border color for ocean.
private Color oceanSelectedBorderColor;
+ /**
+ * Constructs {@code MetalTabbedPaneUI}.
+ *
+ * @param x a component
+ * @return an instance of {@code MetalTabbedPaneUI}
+ */
public static ComponentUI createUI( JComponent x ) {
return new MetalTabbedPaneUI();
}
@@ -116,6 +137,19 @@
}
+ /**
+ * Paints the top tab border.
+ *
+ * @param tabIndex a tab index
+ * @param g an instance of {@code Graphics}
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ * @param w a width
+ * @param h a height
+ * @param btm bottom
+ * @param rght right
+ * @param isSelected a selection
+ */
protected void paintTopTabBorder( int tabIndex, Graphics g,
int x, int y, int w, int h,
int btm, int rght,
@@ -286,6 +320,15 @@
g.translate( -x, -y );
}
+ /**
+ * Returns {@code true} if the gap should be filled.
+ *
+ * @param currentRun the current run
+ * @param tabIndex the tab index
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ * @return {@code true} if the gap should be filled
+ */
protected boolean shouldFillGap( int currentRun, int tabIndex, int x, int y ) {
boolean result = false;
@@ -322,6 +365,14 @@
return result;
}
+ /**
+ * Returns the color of the gap.
+ *
+ * @param currentRun the current run
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ * @return the color of the gap
+ */
protected Color getColorForGap( int currentRun, int x, int y ) {
final int shadowWidth = 4;
int selectedIndex = tabPane.getSelectedIndex();
@@ -349,6 +400,19 @@
return tabPane.getBackground();
}
+ /**
+ * Paints the left tab border.
+ *
+ * @param tabIndex a tab index
+ * @param g an instance of {@code Graphics}
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ * @param w a width
+ * @param h a height
+ * @param btm bottom
+ * @param rght right
+ * @param isSelected a selection
+ */
protected void paintLeftTabBorder( int tabIndex, Graphics g,
int x, int y, int w, int h,
int btm, int rght,
@@ -466,6 +530,19 @@
}
+ /**
+ * Paints the bottom tab border.
+ *
+ * @param tabIndex a tab index
+ * @param g an instance of {@code Graphics}
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ * @param w a width
+ * @param h a height
+ * @param btm bottom
+ * @param rght right
+ * @param isSelected a selection
+ */
protected void paintBottomTabBorder( int tabIndex, Graphics g,
int x, int y, int w, int h,
int btm, int rght,
@@ -623,6 +700,19 @@
g.translate( -x, -y );
}
+ /**
+ * Paints the right tab border.
+ *
+ * @param tabIndex a tab index
+ * @param g an instance of {@code Graphics}
+ * @param x an X coordinate
+ * @param y an Y coordinate
+ * @param w a width
+ * @param h a height
+ * @param btm bottom
+ * @param rght right
+ * @param isSelected a selection
+ */
protected void paintRightTabBorder( int tabIndex, Graphics g,
int x, int y, int w, int h,
int btm, int rght,
@@ -842,6 +932,9 @@
super.paint( g, c );
}
+ /**
+ * Paints highlights below tab.
+ */
protected void paintHighlightBelowTab( ) {
}
@@ -1158,7 +1251,13 @@
return 0;
}
- // Don't rotate runs!
+ /**
+ * Returns {@code true} if tab runs should be rotated.
+ *
+ * @param tabPlacement a tab placement
+ * @param selectedRun a selected run
+ * @return {@code true} if tab runs should be rotated.
+ */
protected boolean shouldRotateTabRuns( int tabPlacement, int selectedRun ) {
return false;
}
@@ -1200,6 +1299,9 @@
*/
public class TabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout {
+ /**
+ * Constructs {@code TabbedPaneLayout}.
+ */
public TabbedPaneLayout() {
MetalTabbedPaneUI.this.super();
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTextFieldUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -50,6 +50,12 @@
@SuppressWarnings("serial") // Same-version serialization only
public class MetalTextFieldUI extends BasicTextFieldUI {
+ /**
+ * Constructs {@code MetalTextFieldUI}.
+ *
+ * @param c a component
+ * @return the instance of {@code MetalTextFieldUI}
+ */
public static ComponentUI createUI(JComponent c) {
return new MetalTextFieldUI();
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -60,8 +60,19 @@
private static final Object METAL_TOGGLE_BUTTON_UI_KEY = new Object();
+ /**
+ * The color of a focused toggle button.
+ */
protected Color focusColor;
+
+ /**
+ * The color of a selected button.
+ */
protected Color selectColor;
+
+ /**
+ * The color of a disabled text.
+ */
protected Color disabledTextColor;
private boolean defaults_initialized = false;
@@ -69,6 +80,13 @@
// ********************************
// Create PLAF
// ********************************
+
+ /**
+ * Constructs the {@code MetalToogleButtonUI}.
+ *
+ * @param b a component
+ * @return the {@code MetalToogleButtonUI}.
+ */
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
MetalToggleButtonUI metalToggleButtonUI =
@@ -101,14 +119,29 @@
// ********************************
// Default Accessors
// ********************************
+ /**
+ * Returns the color of a selected button.
+ *
+ * @return the color of a selected button
+ */
protected Color getSelectColor() {
return selectColor;
}
+ /**
+ * Returns the color of a disabled text.
+ *
+ * @return the color of a disabled text
+ */
protected Color getDisabledTextColor() {
return disabledTextColor;
}
+ /**
+ * Returns the color of a focused toggle button.
+ *
+ * @return the color of a focused toggle button
+ */
protected Color getFocusColor() {
return focusColor;
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolBarUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -158,6 +158,12 @@
return false;
}
+ /**
+ * Constructs an instance of {@code MetalToolBarUI}.
+ *
+ * @param c a component
+ * @return an instance of {@code MetalToolBarUI}
+ */
public static ComponentUI createUI( JComponent c )
{
return new MetalToolBarUI();
@@ -269,6 +275,11 @@
return new MetalDockingListener( toolBar );
}
+ /**
+ * Sets the offset of the mouse cursor inside the DragWindow.
+ *
+ * @param p the offset
+ */
protected void setDragOffset(Point p) {
if (!GraphicsEnvironment.isHeadless()) {
if (dragWindow == null) {
@@ -346,17 +357,29 @@
}
}
- // No longer used. Cannot remove for compatibility reasons
+ /**
+ * No longer used. The class cannot be removed for compatibility reasons.
+ */
protected class MetalContainerListener
extends BasicToolBarUI.ToolBarContListener {}
- // No longer used. Cannot remove for compatibility reasons
+ /**
+ * No longer used. The class cannot be removed for compatibility reasons.
+ */
protected class MetalRolloverListener
extends BasicToolBarUI.PropertyListener {}
+ /**
+ * {@code DockingListener} for {@code MetalToolBarUI}.
+ */
protected class MetalDockingListener extends DockingListener {
private boolean pressedInBumps = false;
+ /**
+ * Constructs the {@code MetalDockingListener}.
+ *
+ * @param t an instance of {@code JToolBar}
+ */
public MetalDockingListener(JToolBar t) {
super(t);
}
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolTipUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalToolTipUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -58,13 +58,26 @@
private Font smallFont;
// Refer to note in getAcceleratorString about this field.
private JToolTip tip;
+
+ /**
+ * The space between strings.
+ */
public static final int padSpaceBetweenStrings = 12;
private String acceleratorDelimiter;
+ /**
+ * Constructs an instance of the {@code MetalToolTipUI}.
+ */
public MetalToolTipUI() {
super();
}
+ /**
+ * Returns an instance of the {@code MetalToolTipUI}.
+ *
+ * @param c a component
+ * @return an instance of the {@code MetalToolTipUI}.
+ */
public static ComponentUI createUI(JComponent c) {
return sharedInstance;
}
@@ -148,6 +161,12 @@
return d;
}
+ /**
+ * If the accelerator is hidden, the method returns {@code true},
+ * otherwise, returns {@code false}.
+ *
+ * @return {@code true} if the accelerator is hidden.
+ */
protected boolean isAcceleratorHidden() {
Boolean b = (Boolean)UIManager.get("ToolTip.hideAccelerator");
return b != null && b.booleanValue();
@@ -162,6 +181,11 @@
return retValue;
}
+ /**
+ * Returns the accelerator string.
+ *
+ * @return the accelerator string.
+ */
// NOTE: This requires the tip field to be set before this is invoked.
// As MetalToolTipUI is shared between all JToolTips the tip field is
// set appropriately before this is invoked. Unfortunately this means
--- a/jdk/src/share/classes/javax/swing/plaf/metal/MetalTreeUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/metal/MetalTreeUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -93,20 +93,26 @@
private int lineStyle = LEG_LINE_STYLE;
private PropertyChangeListener lineStyleListener = new LineListener();
- // Boilerplate
+ /**
+ * Constructs the {@code MetalTreeUI}.
+ *
+ * @param x a component
+ * @return the instance of the {@code MetalTreeUI}
+ */
public static ComponentUI createUI(JComponent x) {
return new MetalTreeUI();
}
- public MetalTreeUI()
- {
+ /**
+ * Constructs the {@code MetalTreeUI}.
+ */
+ public MetalTreeUI() {
super();
}
- protected int getHorizontalLegBuffer()
- {
- return 3;
- }
+ protected int getHorizontalLegBuffer() {
+ return 3;
+ }
public void installUI( JComponent c ) {
super.installUI( c );
@@ -123,24 +129,36 @@
super.uninstallUI(c);
}
- /** this function converts between the string passed into the client property
- * and the internal representation (currently and int)
- *
- */
+ /**
+ * Converts between the string passed into the client property
+ * and the internal representation (currently and int)
+ *
+ * @param lineStyleFlag a flag
+ */
protected void decodeLineStyle(Object lineStyleFlag) {
- if ( lineStyleFlag == null ||
- lineStyleFlag.equals(LEG_LINE_STYLE_STRING)){
- lineStyle = LEG_LINE_STYLE; // default case
- } else {
- if ( lineStyleFlag.equals(NO_STYLE_STRING) ) {
- lineStyle = NO_LINE_STYLE;
- } else if ( lineStyleFlag.equals(HORIZ_STYLE_STRING) ) {
- lineStyle = HORIZ_LINE_STYLE;
- }
- }
-
+ if ( lineStyleFlag == null ||
+ lineStyleFlag.equals(LEG_LINE_STYLE_STRING)) {
+ lineStyle = LEG_LINE_STYLE; // default case
+ } else {
+ if ( lineStyleFlag.equals(NO_STYLE_STRING) ) {
+ lineStyle = NO_LINE_STYLE;
+ } else if ( lineStyleFlag.equals(HORIZ_STYLE_STRING) ) {
+ lineStyle = HORIZ_LINE_STYLE;
+ }
+ }
}
+ /**
+ * Returns {@code true} if a point with X coordinate {@code mouseX}
+ * and Y coordinate {@code mouseY} is in expanded control.
+ *
+ * @param row a row
+ * @param rowLevel a row level
+ * @param mouseX X coordinate
+ * @param mouseY Y coordinate
+ * @return {@code true} if a point with X coordinate {@code mouseX}
+ * and Y coordinate {@code mouseY} is in expanded control.
+ */
protected boolean isLocationInExpandControl(int row, int rowLevel,
int mouseX, int mouseY) {
if(tree != null && !isLeaf(row)) {
@@ -175,6 +193,12 @@
}
}
+ /**
+ * Paints the horizontal separators.
+ *
+ * @param g an instance of {@code Graphics}
+ * @param c a component
+ */
protected void paintHorizontalSeparators(Graphics g, JComponent c) {
g.setColor( lineColor );
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, 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
@@ -421,6 +421,13 @@
* @param property The name of a bean style property or client property
* @param defaultColor The color to return if no color was obtained from
* the component.
+ * @param saturationOffset additively modifies the HSB saturation component
+ * of the color returned (ignored if default color is returned).
+ * @param brightnessOffset additively modifies the HSB brightness component
+ * of the color returned (ignored if default color is returned).
+ * @param alphaOffset additively modifies the ARGB alpha component of the
+ * color returned (ignored if default color is returned).
+ *
* @return The color that was obtained from the component or defaultColor
*/
protected final Color getComponentColor(JComponent c, String property,
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, 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
@@ -513,6 +513,13 @@
/**
* Returns the Icon used in calculating the
* preferred/minimum/maximum size.
+ *
+ * @param b specifies the {@code AbstractButton}
+ * used when calculating the preferred/minimum/maximum
+ * size.
+ *
+ * @return the Icon used in calculating the
+ * preferred/minimum/maximum size.
*/
protected Icon getSizingIcon(AbstractButton b) {
Icon icon = getEnabledIcon(b, b.getIcon());
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, 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
@@ -137,6 +137,9 @@
* @param iconR Rectangle to place icon bounds in
* @param textR Rectangle to place text in
* @param iconTextGap gap between icon and text
+ *
+ * @return by reference, the location to
+ * place the icon and text.
*/
public String layoutText(SynthContext ss, FontMetrics fm,
String text, Icon icon, int hAlign,
@@ -166,6 +169,8 @@
* @param font Font to use
* @param metrics FontMetrics, may be ignored
* @param text Text to get size of.
+ *
+ * @return the size of the passed in string.
*/
public int computeStringWidth(SynthContext ss, Font font,
FontMetrics metrics, String text) {
@@ -187,6 +192,8 @@
* @param iconTextGap gap between icon and text
* @param mnemonicIndex Index into text to render the mnemonic at, -1
* indicates no mnemonic.
+ *
+ * @return the minimum size needed to properly render an icon and text.
*/
public Dimension getMinimumSize(SynthContext ss, Font font, String text,
Icon icon, int hAlign, int vAlign, int hTextPosition,
@@ -218,6 +225,8 @@
* @param iconTextGap gap between icon and text
* @param mnemonicIndex Index into text to render the mnemonic at, -1
* indicates no mnemonic.
+ *
+ * @return the maximum size needed to properly render an icon and text.
*/
public Dimension getMaximumSize(SynthContext ss, Font font, String text,
Icon icon, int hAlign, int vAlign, int hTextPosition,
@@ -263,6 +272,8 @@
* @param iconTextGap gap between icon and text
* @param mnemonicIndex Index into text to render the mnemonic at, -1
* indicates no mnemonic.
+ *
+ * @return the preferred size needed to properly render an icon and text.
*/
public Dimension getPreferredSize(SynthContext ss, Font font, String text,
Icon icon, int hAlign, int vAlign, int hTextPosition,
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, 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,6 +78,9 @@
/**
* Installs default setting. This method is called when a
* {@code LookAndFeel} is installed.
+ *
+ * @param c specifies the {@code JSeparator} for the installed
+ * {@code LookAndFeel}.
*/
public void installDefaults(JSeparator c) {
updateStyle(c);
@@ -109,6 +112,9 @@
/**
* Uninstalls default setting. This method is called when a
* {@code LookAndFeel} is uninstalled.
+ *
+ * @param c specifies the {@code JSeparator} for the (un)installed
+ * {@code LookAndFeel}.
*/
public void uninstallDefaults(JSeparator c) {
SynthContext context = getContext(c, ENABLED);
@@ -121,6 +127,9 @@
/**
* Installs listeners. This method is called when a
* {@code LookAndFeel} is installed.
+ *
+ * @param c specifies the {@code JSeparator} for the installed
+ * {@code LookAndFeel}.
*/
public void installListeners(JSeparator c) {
c.addPropertyChangeListener(this);
@@ -129,6 +138,9 @@
/**
* Uninstalls listeners. This method is called when a
* {@code LookAndFeel} is uninstalled.
+ *
+ * @param c specifies the {@code JSeparator} for the (un)installed
+ * {@code LookAndFeel}.
*/
public void uninstallListeners(JSeparator c) {
c.removePropertyChangeListener(this);
--- a/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java Tue Jul 01 10:20:56 2014 -0700
@@ -716,6 +716,8 @@
/**
* Creates a new default list selection model.
+ *
+ * @return a newly created default list selection model.
*/
protected ListSelectionModel createSelectionModel() {
return new DefaultListSelectionModel();
--- a/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java Tue Jul 01 10:20:56 2014 -0700
@@ -335,6 +335,8 @@
*
* @see #setColumnCount
* @since 1.3
+ *
+ * @param rowCount number of rows in the model
*/
public void setRowCount(int rowCount) {
setNumRows(rowCount);
@@ -577,6 +579,9 @@
* element going to row 0, etc. This method will send a
* <code>tableChanged</code> notification message to all the listeners.
*
+ * @param columnName identifier of the newly created column
+ * @param columnData new data to be added to the column
+ *
* @see #addColumn(Object, Vector)
*/
public void addColumn(Object columnName, Object[] columnData) {
--- a/jdk/src/share/classes/javax/swing/table/JTableHeader.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/JTableHeader.java Tue Jul 01 10:20:56 2014 -0700
@@ -336,6 +336,10 @@
* Returns the index of the column that <code>point</code> lies in, or -1 if it
* lies out of bounds.
*
+ * @param point if this <code>point</code> lies within a column, the index of
+ * that column will be returned; otherwise it is out of bounds
+ * and -1 is returned
+ *
* @return the index of the column that <code>point</code> lies in, or -1 if it
* lies out of bounds
*/
@@ -352,6 +356,8 @@
* When the <code>column</code> parameter is out of bounds this method uses the
* same conventions as the <code>JTable</code> method <code>getCellRect</code>.
*
+ * @param column index of the column
+ *
* @return the rectangle containing the header tile at <code>column</code>
* @see JTable#getCellRect
*/
@@ -883,6 +889,10 @@
/**
* Constructs an AccessiblJTableHeaaderEntry
* @since 1.4
+ *
+ * @param c the column index
+ * @param p the parent <code>JTableHeader</code>
+ * @param t the table <code>JTable</code>
*/
public AccessibleJTableHeaderEntry(int c, JTableHeader p, JTable t) {
parent = p;
--- a/jdk/src/share/classes/javax/swing/table/TableCellRenderer.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/TableCellRenderer.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -86,6 +86,9 @@
* drawing the header, the value of
* <code>row</code> is -1
* @param column the column index of the cell being drawn
+ *
+ * @return the component used for drawing the cell.
+ *
* @see javax.swing.JComponent#isPaintingForPrint()
*/
Component getTableCellRendererComponent(JTable table, Object value,
--- a/jdk/src/share/classes/javax/swing/table/TableColumn.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/TableColumn.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -201,6 +201,11 @@
* Cover method, using a default width of 75, a <code>null</code>
* renderer and a <code>null</code> editor.
* @see #TableColumn(int, int, TableCellRenderer, TableCellEditor)
+ *
+ * @param modelIndex the index of the column in the model
+ * that supplies the data for this column in the table;
+ * the model index remains the same even when columns
+ * are reordered in the view
*/
public TableColumn(int modelIndex) {
this(modelIndex, 75, null, null);
@@ -210,6 +215,12 @@
* Cover method, using a <code>null</code> renderer and a
* <code>null</code> editor.
* @see #TableColumn(int, int, TableCellRenderer, TableCellEditor)
+ *
+ * @param modelIndex the index of the column in the model
+ * that supplies the data for this column in the table;
+ * the model index remains the same even when columns
+ * are reordered in the view
+ * @param width this column's preferred width and initial width
*/
public TableColumn(int modelIndex, int width) {
this(modelIndex, width, null, null);
--- a/jdk/src/share/classes/javax/swing/table/TableColumnModel.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/TableColumnModel.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -162,6 +162,9 @@
* model. If the column index for a given X coordinate in 2D space is
* required, <code>JTable.columnAtPoint</code> can be used instead.
*
+ * @param xPosition width from the start of the first column in
+ * the model.
+ *
* @return the index of the column; or -1 if no column is found
* @see javax.swing.JTable#columnAtPoint
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/BufferedMonitoredVm.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004, 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 sun.jvmstat.monitor;
+
+import sun.jvmstat.monitor.*;
+
+/**
+ * Interface to support asynchronous polling of the exported
+ * instrumentation of a target Java Virtual Machine.
+ *
+ * @author Brian Doherty
+ * @since 1.5
+ */
+public interface BufferedMonitoredVm extends MonitoredVm {
+
+ /**
+ * Interface to get the bytes associated with the instrumentation
+ * for the target Java Virtual Machine.
+ *
+ * @return byte[] - a byte array containing the current bytes
+ * for the instrumentation exported by the
+ * target Java Virtual Machine.
+ */
+ byte[] getBytes();
+
+ /**
+ * Interface to get the the size of the instrumentation buffer
+ * for the target Java Virtual Machine.
+ *
+ * @return int - the size of the instrumentation buffer for the
+ * target Java Virtual Machine.
+ */
+ int getCapacity();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/META-INF/services/sun.jvmstat.monitor.MonitoredHostService Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,3 @@
+sun.jvmstat.perfdata.monitor.protocol.file.MonitoredHostFileService
+sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostLocalService
+sun.jvmstat.perfdata.monitor.protocol.rmi.MonitoredHostRmiService
--- a/jdk/src/share/classes/sun/jvmstat/monitor/MonitoredHost.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/MonitoredHost.java Tue Jul 01 10:20:56 2014 -0700
@@ -25,9 +25,11 @@
package sun.jvmstat.monitor;
-import java.util.*;
-import java.net.*;
-import java.lang.reflect.*;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.Set;
import sun.jvmstat.monitor.event.HostListener;
@@ -52,31 +54,6 @@
new HashMap<HostIdentifier, MonitoredHost>();
/*
- * The monitoring implementation override mechanism. The value of
- * this property is used as the class name for the concrete MonitoredHost
- * subclass that implements the monitoring APIs. Setting this property
- * will cause the remaining override mechanisms to be ignored. When
- * this mechanism is used, the HostIdentifier scheme name, which
- * indicates the communications protocol, is not used to locate a
- * the protocol specific package. However, the HostIdentifier is
- * still passed to the corresponding single arg constructor.
- * This property is not expected to be set in normal circumstances.
- */
- private static final String IMPL_OVERRIDE_PROP_NAME =
- "sun.jvmstat.monitor.MonitoredHost";
-
- /*
- * The monitoring package name override mechanism. The value
- * the this property is used as base package name for the
- * monitoring implementation package. This property is not
- * expected to be set under normal circumstances.
- */
- private static final String IMPL_PKG_PROP_NAME =
- "sun.jvmstat.monitor.package";
- private static final String IMPL_PACKAGE =
- System.getProperty(IMPL_PKG_PROP_NAME, "sun.jvmstat.perfdata");
-
- /*
* The default optimized local protocol override mechanism. The value
* of this property is used to construct the default package name
* for the default optimized local protocol as follows:
@@ -100,15 +77,6 @@
private static final String REMOTE_PROTOCOL =
System.getProperty(REMOTE_PROTOCOL_PROP_NAME, "rmi");
- /*
- * The default class name of the MonitoredHost implementation subclass.
- * There is no override mechanism for this variable, other than the
- * IMPL_OVERRIDE_PROP_NAME override, which is larger in scope. A concrete
- * instance of this class is expected to be found in:
- * <IMPL_PACKAGE>.monitor.protocol.<protocol>.<MONITORED_HOST_CLASS>
- */
- private static final String MONITORED_HOST_CLASS = "MonitoredHostProvider";
-
/**
* The HostIdentifier for this MonitoredHost instance.
*/
@@ -165,6 +133,13 @@
return getMonitoredHost(hostId);
}
+
+ /*
+ * Load the MonitoredHostServices
+ */
+ private static ServiceLoader<MonitoredHostService> monitoredHostServiceLoader =
+ ServiceLoader.load(MonitoredHostService.class, MonitoredHostService.class.getClassLoader());
+
/**
* Factory method to construct a MonitoredHost instance to manage the
* connection to the host indicated by <tt>hostId</tt>.
@@ -177,11 +152,6 @@
*/
public static MonitoredHost getMonitoredHost(HostIdentifier hostId)
throws MonitorException {
- /*
- * determine the class name to load. If the system property is set,
- * use the indicated class. otherwise, use the default class.
- */
- String classname = System.getProperty(IMPL_OVERRIDE_PROP_NAME);
MonitoredHost mh = null;
synchronized(monitoredHosts) {
@@ -197,50 +167,21 @@
hostId = resolveHostId(hostId);
- if (classname == null) {
- // construct the class name
- classname = IMPL_PACKAGE + ".monitor.protocol."
- + hostId.getScheme() + "." + MONITORED_HOST_CLASS;
+ for (MonitoredHostService mhs : monitoredHostServiceLoader) {
+ if (mhs.getScheme().equals(hostId.getScheme())) {
+ mh = mhs.getMonitoredHost(hostId);
+ }
}
- try {
- // run the constructor taking a single String parameter.
- Class<?> c = Class.forName(classname);
-
- Constructor cons = c.getConstructor(
- new Class[] { hostId.getClass() }
- );
-
- mh = (MonitoredHost)cons.newInstance(new Object[] { hostId } );
+ if (mh == null) {
+ throw new IllegalArgumentException("Could not find MonitoredHost for scheme: " + hostId.getScheme());
+ }
- synchronized(monitoredHosts) {
- monitoredHosts.put(mh.hostId, mh);
- }
- return mh;
- } catch (ClassNotFoundException e) {
- // from Class.forName();
- throw new IllegalArgumentException("Could not find " + classname
- + ": " + e.getMessage(), e);
- } catch (NoSuchMethodException e) {
- // from Class.getConstructor();
- throw new IllegalArgumentException(
- "Expected constructor missing in " + classname + ": "
- + e.getMessage(), e);
- } catch (IllegalAccessException e) {
- // from Constructor.newInstance()
- throw new IllegalArgumentException(
- "Unexpected constructor access in " + classname + ": "
- + e.getMessage(), e);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(classname + "is abstract: "
- + e.getMessage(), e);
- } catch (InvocationTargetException e) {
- Throwable cause = e.getCause();
- if (cause instanceof MonitorException) {
- throw (MonitorException)cause;
- }
- throw new RuntimeException("Unexpected exception", e);
+ synchronized(monitoredHosts) {
+ monitoredHosts.put(mh.hostId, mh);
}
+
+ return mh;
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/monitor/MonitoredHostService.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014, 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 sun.jvmstat.monitor;
+
+public interface MonitoredHostService {
+
+ /**
+ * Construct a MonitoredHost instance to manage the
+ * connection to the host indicated by <tt>hostId</tt>.
+ *
+ * @param hostId the identifier for the target host.
+ * @return MonitoredHost - The MonitoredHost object needed to attach to
+ * the target host.
+ *
+ * @throws MonitorException Thrown if monitoring errors occur.
+ */
+ public MonitoredHost getMonitoredHost(HostIdentifier hostId) throws MonitorException;
+
+ /**
+ * Get the scheme that this service supports.
+ *
+ * @return scheme name
+ */
+ public String getScheme();
+}
--- a/jdk/src/share/classes/sun/jvmstat/monitor/remote/BufferedMonitoredVm.java Tue Jun 24 12:27:37 2014 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 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 sun.jvmstat.monitor.remote;
-
-import sun.jvmstat.monitor.*;
-
-/**
- * Interface to support asynchronous polling of the exported
- * instrumentation of a target Java Virtual Machine.
- *
- * @author Brian Doherty
- * @since 1.5
- */
-public interface BufferedMonitoredVm extends MonitoredVm {
-
- /**
- * Interface to get the bytes associated with the instrumentation
- * for the target Java Virtual Machine.
- *
- * @return byte[] - a byte array containing the current bytes
- * for the instrumentation exported by the
- * target Java Virtual Machine.
- */
- byte[] getBytes();
-
- /**
- * Interface to get the the size of the instrumentation buffer
- * for the target Java Virtual Machine.
- *
- * @return int - the size of the instrumentation buffer for the
- * target Java Virtual Machine.
- */
- int getCapacity();
-}
--- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfLongMonitor.java Tue Jul 01 10:20:56 2014 -0700
@@ -66,7 +66,7 @@
* return type is guaranteed to be of type Long.
*/
public Object getValue() {
- return new Long(lb.get(0));
+ return Long.valueOf(lb.get(0));
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/file/MonitoredHostFileService.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, 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 sun.jvmstat.perfdata.monitor.protocol.file;
+
+import sun.jvmstat.monitor.HostIdentifier;
+import sun.jvmstat.monitor.MonitorException;
+import sun.jvmstat.monitor.MonitoredHost;
+import sun.jvmstat.monitor.MonitoredHostService;
+
+public final class MonitoredHostFileService implements MonitoredHostService {
+
+ @Override
+ public MonitoredHost getMonitoredHost(HostIdentifier hostId)
+ throws MonitorException {
+ return new MonitoredHostProvider(hostId);
+ }
+
+ @Override
+ public String getScheme() {
+ return "file";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostLocalService.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, 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 sun.jvmstat.perfdata.monitor.protocol.local;
+
+import sun.jvmstat.monitor.HostIdentifier;
+import sun.jvmstat.monitor.MonitorException;
+import sun.jvmstat.monitor.MonitoredHost;
+import sun.jvmstat.monitor.MonitoredHostService;
+
+public final class MonitoredHostLocalService implements MonitoredHostService {
+
+ @Override
+ public MonitoredHost getMonitoredHost(HostIdentifier hostId)
+ throws MonitorException {
+ return new MonitoredHostProvider(hostId);
+ }
+
+ @Override
+ public String getScheme() {
+ return "local";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostRmiService.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014, 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 sun.jvmstat.perfdata.monitor.protocol.rmi;
+
+import sun.jvmstat.monitor.HostIdentifier;
+import sun.jvmstat.monitor.MonitorException;
+import sun.jvmstat.monitor.MonitoredHost;
+import sun.jvmstat.monitor.MonitoredHostService;
+
+public final class MonitoredHostRmiService implements MonitoredHostService {
+
+ @Override
+ public MonitoredHost getMonitoredHost(HostIdentifier hostId) throws MonitorException {
+ return new MonitoredHostProvider(hostId);
+ }
+
+ @Override
+ public String getScheme() {
+ return "rmi";
+ }
+
+}
--- a/jdk/src/share/classes/sun/management/GcInfoCompositeData.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/GcInfoCompositeData.java Tue Jul 01 10:20:56 2014 -0700
@@ -105,10 +105,10 @@
try {
baseGcInfoItemValues = new Object[] {
- new Long(info.getId()),
- new Long(info.getStartTime()),
- new Long(info.getEndTime()),
- new Long(info.getDuration()),
+ info.getId(),
+ info.getStartTime(),
+ info.getEndTime(),
+ info.getDuration(),
memoryUsageMapType.toOpenTypeData(info.getMemoryUsageBeforeGc()),
memoryUsageMapType.toOpenTypeData(info.getMemoryUsageAfterGc()),
};
--- a/jdk/src/share/classes/sun/management/HotspotThread.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/HotspotThread.java Tue Jul 01 10:20:56 2014 -0700
@@ -60,7 +60,7 @@
int numThreads = getInternalThreadTimes0(names, times);
Map<String, Long> result = new HashMap<>(numThreads);
for (int i = 0; i < numThreads; i++) {
- result.put(names[i], new Long(times[i]));
+ result.put(names[i], times[i]);
}
return result;
}
--- a/jdk/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java Tue Jul 01 10:20:56 2014 -0700
@@ -60,7 +60,7 @@
final Object[] memoryNotifInfoItemValues = {
memoryNotifInfo.getPoolName(),
MemoryUsageCompositeData.toCompositeData(memoryNotifInfo.getUsage()),
- new Long(memoryNotifInfo.getCount()),
+ memoryNotifInfo.getCount(),
};
try {
--- a/jdk/src/share/classes/sun/management/MemoryUsageCompositeData.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/MemoryUsageCompositeData.java Tue Jul 01 10:20:56 2014 -0700
@@ -56,10 +56,10 @@
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// memoryUsageItemNames!
final Object[] memoryUsageItemValues = {
- new Long(usage.getInit()),
- new Long(usage.getUsed()),
- new Long(usage.getCommitted()),
- new Long(usage.getMax()),
+ usage.getInit(),
+ usage.getUsed(),
+ usage.getCommitted(),
+ usage.getMax(),
};
try {
--- a/jdk/src/share/classes/sun/management/ThreadInfoCompositeData.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/ThreadInfoCompositeData.java Tue Jul 01 10:20:56 2014 -0700
@@ -108,16 +108,16 @@
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// threadInfoItemNames!
final Object[] threadInfoItemValues = {
- new Long(threadInfo.getThreadId()),
+ threadInfo.getThreadId(),
threadInfo.getThreadName(),
threadInfo.getThreadState().name(),
- new Long(threadInfo.getBlockedTime()),
- new Long(threadInfo.getBlockedCount()),
- new Long(threadInfo.getWaitedTime()),
- new Long(threadInfo.getWaitedCount()),
+ threadInfo.getBlockedTime(),
+ threadInfo.getBlockedCount(),
+ threadInfo.getWaitedTime(),
+ threadInfo.getWaitedCount(),
lockInfoData,
threadInfo.getLockName(),
- new Long(threadInfo.getLockOwnerId()),
+ threadInfo.getLockOwnerId(),
threadInfo.getLockOwnerName(),
stackTraceData,
threadInfo.isSuspended(),
--- a/jdk/src/share/classes/sun/management/counter/perf/LongCounterSnapshot.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/counter/perf/LongCounterSnapshot.java Tue Jul 01 10:20:56 2014 -0700
@@ -43,7 +43,7 @@
}
public Object getValue() {
- return new Long(value);
+ return Long.valueOf(value);
}
/**
--- a/jdk/src/share/classes/sun/management/counter/perf/PerfLongCounter.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/counter/perf/PerfLongCounter.java Tue Jul 01 10:20:56 2014 -0700
@@ -42,7 +42,7 @@
}
public Object getValue() {
- return new Long(lb.get(0));
+ return Long.valueOf(lb.get(0));
}
/**
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmClassLoadingImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmClassLoadingImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -129,21 +129,21 @@
* Getter for the "JvmClassesUnloadedCount" variable.
*/
public Long getJvmClassesUnloadedCount() throws SnmpStatusException {
- return new Long(getClassLoadingMXBean().getUnloadedClassCount());
+ return getClassLoadingMXBean().getUnloadedClassCount();
}
/**
* Getter for the "JvmClassesTotalLoadedCount" variable.
*/
public Long getJvmClassesTotalLoadedCount() throws SnmpStatusException {
- return new Long(getClassLoadingMXBean().getTotalLoadedClassCount());
+ return getClassLoadingMXBean().getTotalLoadedClassCount();
}
/**
* Getter for the "JvmClassesLoadedCount" variable.
*/
public Long getJvmClassesLoadedCount() throws SnmpStatusException {
- return new Long(getClassLoadingMXBean().getLoadedClassCount());
+ return (long)getClassLoadingMXBean().getLoadedClassCount();
}
}
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmCompilationImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmCompilationImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -115,7 +115,7 @@
t = getCompilationMXBean().getTotalCompilationTime();
else
t = 0;
- return new Long(t);
+ return t;
}
/**
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmMemGCEntryImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmMemGCEntryImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -70,7 +70,7 @@
*/
// Don't bother to uses the request contextual cache for this.
public Long getJvmMemGCTimeMs() throws SnmpStatusException {
- return new Long(gcm.getCollectionTime());
+ return gcm.getCollectionTime();
}
/**
@@ -78,7 +78,7 @@
*/
// Don't bother to uses the request contextual cache for this.
public Long getJvmMemGCCount() throws SnmpStatusException {
- return new Long(gcm.getCollectionCount());
+ return gcm.getCollectionCount();
}
/**
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolEntryImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmMemPoolEntryImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -191,7 +191,7 @@
*/
public Long getJvmMemPoolMaxSize() throws SnmpStatusException {
final long val = getMemoryUsage().getMax();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -200,7 +200,7 @@
*/
public Long getJvmMemPoolUsed() throws SnmpStatusException {
final long val = getMemoryUsage().getUsed();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -209,7 +209,7 @@
*/
public Long getJvmMemPoolInitSize() throws SnmpStatusException {
final long val = getMemoryUsage().getInit();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -218,7 +218,7 @@
*/
public Long getJvmMemPoolCommitted() throws SnmpStatusException {
final long val = getMemoryUsage().getCommitted();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -227,7 +227,7 @@
*/
public Long getJvmMemPoolPeakMaxSize() throws SnmpStatusException {
final long val = getPeakMemoryUsage().getMax();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -236,7 +236,7 @@
*/
public Long getJvmMemPoolPeakUsed() throws SnmpStatusException {
final long val = getPeakMemoryUsage().getUsed();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -245,7 +245,7 @@
*/
public Long getJvmMemPoolPeakCommitted() throws SnmpStatusException {
final long val = getPeakMemoryUsage().getCommitted();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -254,7 +254,7 @@
*/
public Long getJvmMemPoolCollectMaxSize() throws SnmpStatusException {
final long val = getCollectMemoryUsage().getMax();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -263,7 +263,7 @@
*/
public Long getJvmMemPoolCollectUsed() throws SnmpStatusException {
final long val = getCollectMemoryUsage().getUsed();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -272,7 +272,7 @@
*/
public Long getJvmMemPoolCollectCommitted() throws SnmpStatusException {
final long val = getCollectMemoryUsage().getCommitted();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -283,7 +283,7 @@
if (!pool.isUsageThresholdSupported())
return JvmMemoryImpl.Long0;
final long val = pool.getUsageThreshold();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -334,7 +334,7 @@
if (!pool.isUsageThresholdSupported())
return JvmMemoryImpl.Long0;
final long val = pool.getUsageThresholdCount();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -345,7 +345,7 @@
if (!pool.isCollectionUsageThresholdSupported())
return JvmMemoryImpl.Long0;
final long val = pool.getCollectionUsageThreshold();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -399,7 +399,7 @@
if (!pool.isCollectionUsageThresholdSupported())
return JvmMemoryImpl.Long0;
final long val = pool.getCollectionUsageThresholdCount();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return JvmMemoryImpl.Long0;
}
@@ -450,7 +450,7 @@
*/
public synchronized Long getJvmMemPoolPeakReset()
throws SnmpStatusException {
- return new Long(jvmMemPoolPeakReset);
+ return jvmMemPoolPeakReset;
}
/**
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmMemoryImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmMemoryImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -222,7 +222,7 @@
}
}
- static final Long Long0 = new Long(0);
+ static final Long Long0 = 0L;
/**
* Getter for the "JvmMemoryNonHeapMaxSize" variable.
@@ -230,7 +230,7 @@
public Long getJvmMemoryNonHeapMaxSize()
throws SnmpStatusException {
final long val = getNonHeapMemoryUsage().getMax();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -239,7 +239,7 @@
*/
public Long getJvmMemoryNonHeapCommitted() throws SnmpStatusException {
final long val = getNonHeapMemoryUsage().getCommitted();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -248,7 +248,7 @@
*/
public Long getJvmMemoryNonHeapUsed() throws SnmpStatusException {
final long val = getNonHeapMemoryUsage().getUsed();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -257,7 +257,7 @@
*/
public Long getJvmMemoryNonHeapInitSize() throws SnmpStatusException {
final long val = getNonHeapMemoryUsage().getInit();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -266,7 +266,7 @@
*/
public Long getJvmMemoryHeapMaxSize() throws SnmpStatusException {
final long val = getHeapMemoryUsage().getMax();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -320,7 +320,7 @@
*/
public Long getJvmMemoryHeapCommitted() throws SnmpStatusException {
final long val = getHeapMemoryUsage().getCommitted();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -359,7 +359,7 @@
*/
public Long getJvmMemoryHeapUsed() throws SnmpStatusException {
final long val = getHeapMemoryUsage().getUsed();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -368,7 +368,7 @@
*/
public Long getJvmMemoryHeapInitSize() throws SnmpStatusException {
final long val = getHeapMemoryUsage().getInit();
- if (val > -1) return new Long(val);
+ if (val > -1) return val;
else return Long0;
}
@@ -380,11 +380,11 @@
final long val = ManagementFactory.getMemoryMXBean().
getObjectPendingFinalizationCount();
- if (val > -1) return new Long((int)val);
+ if (val > -1) return Long.valueOf((int) val);
// Should never happen... but stay safe all the same.
//
- else return new Long(0);
+ else return 0L;
}
static final MibLogger log = new MibLogger(JvmMemoryImpl.class);
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmRuntimeImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmRuntimeImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -259,14 +259,14 @@
* Getter for the "JvmRTUptimeMs" variable.
*/
public Long getJvmRTUptimeMs() throws SnmpStatusException {
- return new Long(getRuntimeMXBean().getUptime());
+ return getRuntimeMXBean().getUptime();
}
/**
* Getter for the "JvmRTStartTimeMs" variable.
*/
public Long getJvmRTStartTimeMs() throws SnmpStatusException {
- return new Long(getRuntimeMXBean().getStartTime());
+ return getRuntimeMXBean().getStartTime();
}
/**
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -139,7 +139,7 @@
"Unexpected exception: " + r);
log.debug("getJvmThreadInstState",r);
}
- Byte[] result = { new Byte(bitmap[0]), new Byte(bitmap[1]) };
+ Byte[] result = {bitmap[0], bitmap[1]};
return result;
}
}
@@ -231,7 +231,7 @@
log.debug("getJvmThreadInstCpuTimeNs",
"Operation not supported: " + e);
}
- return new Long(l);
+ return l;
}
/**
@@ -248,14 +248,14 @@
//Monitoring is disabled
if(l == -1) l = 0;
}
- return new Long(l);
+ return l;
}
/**
* Getter for the "JvmThreadInstBlockCount" variable.
*/
public Long getJvmThreadInstBlockCount() throws SnmpStatusException {
- return new Long(info.getBlockedCount());
+ return info.getBlockedCount();
}
/**
@@ -272,14 +272,14 @@
//Monitoring is disabled
if(l == -1) l = 0;
}
- return new Long(l);
+ return l;
}
/**
* Getter for the "JvmThreadInstWaitCount" variable.
*/
public Long getJvmThreadInstWaitCount() throws SnmpStatusException {
- return new Long(info.getWaitedCount());
+ return info.getWaitedCount();
}
/**
@@ -294,7 +294,7 @@
* Getter for the "JvmThreadInstId" variable.
*/
public Long getJvmThreadInstId() throws SnmpStatusException {
- return new Long(info.getThreadId());
+ return info.getThreadId();
}
/**
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmThreadingImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmThreadingImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -303,28 +303,28 @@
* Getter for the "JvmThreadTotalStartedCount" variable.
*/
public Long getJvmThreadTotalStartedCount() throws SnmpStatusException {
- return new Long(getThreadMXBean().getTotalStartedThreadCount());
+ return getThreadMXBean().getTotalStartedThreadCount();
}
/**
* Getter for the "JvmThreadPeakCount" variable.
*/
public Long getJvmThreadPeakCount() throws SnmpStatusException {
- return new Long(getThreadMXBean().getPeakThreadCount());
+ return (long)getThreadMXBean().getPeakThreadCount();
}
/**
* Getter for the "JvmThreadDaemonCount" variable.
*/
public Long getJvmThreadDaemonCount() throws SnmpStatusException {
- return new Long(getThreadMXBean().getDaemonThreadCount());
+ return (long)getThreadMXBean().getDaemonThreadCount();
}
/**
* Getter for the "JvmThreadCount" variable.
*/
public Long getJvmThreadCount() throws SnmpStatusException {
- return new Long(getThreadMXBean().getThreadCount());
+ return (long)getThreadMXBean().getThreadCount();
}
/**
@@ -332,7 +332,7 @@
*/
public synchronized Long getJvmThreadPeakCountReset()
throws SnmpStatusException {
- return new Long(jvmThreadPeakCountReset);
+ return jvmThreadPeakCountReset;
}
/**
--- a/jdk/src/share/classes/sun/misc/Launcher.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/misc/Launcher.java Tue Jul 01 10:20:56 2014 -0700
@@ -207,7 +207,7 @@
* look in the extension directory itself.
*/
public String findLibrary(String name) {
- name = System.mapLibraryName(name);
+ final String libname = System.mapLibraryName(name);
URL[] urls = super.getURLs();
File prevDir = null;
for (int i = 0; i < urls.length; i++) {
@@ -216,17 +216,26 @@
if (dir != null && !dir.equals(prevDir)) {
// Look in architecture-specific subdirectory first
// Read from the saved system properties to avoid deadlock
- String arch = VM.getSavedProperty("os.arch");
- if (arch != null) {
- File file = new File(new File(dir, arch), name);
- if (file.exists()) {
- return file.getAbsolutePath();
- }
- }
- // Then check the extension directory
- File file = new File(dir, name);
- if (file.exists()) {
- return file.getAbsolutePath();
+ final String arch = VM.getSavedProperty("os.arch");
+ String pathname = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
+ if (arch != null) {
+ File file = new File(new File(dir, arch), libname);
+ if (file.exists()) {
+ return file.getAbsolutePath();
+ }
+ }
+ // Then check the extension directory
+ File file = new File(dir, libname);
+ if (file.exists()) {
+ return file.getAbsolutePath();
+ }
+ return null;
+ }
+ });
+ if (pathname != null) {
+ return pathname;
}
}
prevDir = dir;
--- a/jdk/src/share/classes/sun/misc/ProxyGenerator.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/misc/ProxyGenerator.java Tue Jul 01 10:20:56 2014 -0700
@@ -1885,7 +1885,7 @@
"late constant pool addition: " + key);
}
short i = addEntry(new ValueEntry(key));
- map.put(key, new Short(i));
+ map.put(key, i);
return i;
}
}
@@ -1903,7 +1903,7 @@
throw new InternalError("late constant pool addition");
}
short i = addEntry(e);
- map.put(e, new Short(i));
+ map.put(e, i);
return i;
}
}
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -195,15 +195,8 @@
synchronized (stateLock) {
ensureOpen();
- if (name == StandardSocketOptions.IP_TOS) {
- // IPv4 only; no-op for IPv6
- if (family == StandardProtocolFamily.INET) {
- Net.setSocketOption(fd, family, name, value);
- }
- return this;
- }
-
- if (name == StandardSocketOptions.IP_MULTICAST_TTL ||
+ if (name == StandardSocketOptions.IP_TOS ||
+ name == StandardSocketOptions.IP_MULTICAST_TTL ||
name == StandardSocketOptions.IP_MULTICAST_LOOP)
{
// options are protocol dependent
@@ -256,16 +249,8 @@
synchronized (stateLock) {
ensureOpen();
- if (name == StandardSocketOptions.IP_TOS) {
- // IPv4 only; always return 0 on IPv6
- if (family == StandardProtocolFamily.INET) {
- return (T) Net.getSocketOption(fd, family, name);
- } else {
- return (T) Integer.valueOf(0);
- }
- }
-
- if (name == StandardSocketOptions.IP_MULTICAST_TTL ||
+ if (name == StandardSocketOptions.IP_TOS ||
+ name == StandardSocketOptions.IP_MULTICAST_TTL ||
name == StandardSocketOptions.IP_MULTICAST_LOOP)
{
return (T) Net.getSocketOption(fd, family, name);
--- a/jdk/src/share/classes/sun/nio/ch/Net.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/nio/ch/Net.java Tue Jul 01 10:20:56 2014 -0700
@@ -352,7 +352,8 @@
}
boolean mayNeedConversion = (family == UNSPEC);
- setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg);
+ boolean isIPv6 = (family == StandardProtocolFamily.INET6);
+ setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg, isIPv6);
}
static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
@@ -499,7 +500,7 @@
throws IOException;
private static native void setIntOption0(FileDescriptor fd, boolean mayNeedConversion,
- int level, int opt, int arg)
+ int level, int opt, int arg, boolean isIPv6)
throws IOException;
static native int poll(FileDescriptor fd, int events, long timeout)
--- a/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -133,6 +133,14 @@
synchronized (stateLock) {
if (!isOpen())
throw new ClosedChannelException();
+
+ if (name == StandardSocketOptions.IP_TOS) {
+ ProtocolFamily family = Net.isIPv6Available() ?
+ StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
+ Net.setSocketOption(fd, family, name, value);
+ return this;
+ }
+
if (name == StandardSocketOptions.SO_REUSEADDR &&
Net.useExclusiveBind())
{
@@ -177,6 +185,7 @@
HashSet<SocketOption<?>> set = new HashSet<SocketOption<?>>(2);
set.add(StandardSocketOptions.SO_RCVBUF);
set.add(StandardSocketOptions.SO_REUSEADDR);
+ set.add(StandardSocketOptions.IP_TOS);
return Collections.unmodifiableSet(set);
}
}
--- a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Tue Jul 01 10:20:56 2014 -0700
@@ -173,14 +173,14 @@
if (!isOpen())
throw new ClosedChannelException();
- // special handling for IP_TOS: no-op when IPv6
if (name == StandardSocketOptions.IP_TOS) {
- if (!Net.isIPv6Available())
- Net.setSocketOption(fd, StandardProtocolFamily.INET, name, value);
+ ProtocolFamily family = Net.isIPv6Available() ?
+ StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
+ Net.setSocketOption(fd, family, name, value);
return this;
- } else if (name == StandardSocketOptions.SO_REUSEADDR &&
- Net.useExclusiveBind())
- {
+ }
+
+ if (name == StandardSocketOptions.SO_REUSEADDR && Net.useExclusiveBind()) {
// SO_REUSEADDR emulated when using exclusive bind
isReuseAddress = (Boolean)value;
return this;
@@ -215,8 +215,9 @@
// special handling for IP_TOS: always return 0 when IPv6
if (name == StandardSocketOptions.IP_TOS) {
- return (Net.isIPv6Available()) ? (T) Integer.valueOf(0) :
- (T) Net.getSocketOption(fd, StandardProtocolFamily.INET, name);
+ ProtocolFamily family = Net.isIPv6Available() ?
+ StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
+ return (T) Net.getSocketOption(fd, family, name);
}
// no options that require special handling
--- a/jdk/src/share/classes/sun/nio/ch/Util.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java Tue Jul 01 10:20:56 2014 -0700
@@ -329,7 +329,7 @@
try {
dbb = (MappedByteBuffer)directByteBufferConstructor.newInstance(
new Object[] { new Integer(size),
- new Long(addr),
+ addr,
fd,
unmapper });
} catch (InstantiationException |
@@ -374,7 +374,7 @@
try {
dbb = (MappedByteBuffer)directByteBufferRConstructor.newInstance(
new Object[] { new Integer(size),
- new Long(addr),
+ addr,
fd,
unmapper });
} catch (InstantiationException |
--- a/jdk/src/share/classes/sun/security/action/GetLongAction.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/security/action/GetLongAction.java Tue Jul 01 10:20:56 2014 -0700
@@ -106,7 +106,7 @@
public Long run() {
Long value = Long.getLong(theProp);
if ((value == null) && defaultSet)
- return new Long(defaultVal);
+ return defaultVal;
return value;
}
}
--- a/jdk/src/share/classes/sun/security/jgss/wrapper/GSSNameElement.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/security/jgss/wrapper/GSSNameElement.java Tue Jul 01 10:20:56 2014 -0700
@@ -203,7 +203,7 @@
}
public int hashCode() {
- return new Long(pName).hashCode();
+ return Long.hashCode(pName);
}
public byte[] export() throws GSSException {
--- a/jdk/src/share/classes/sun/security/krb5/internal/KerberosTime.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/security/krb5/internal/KerberosTime.java Tue Jul 01 10:20:56 2014 -0700
@@ -188,8 +188,8 @@
}
public int getMicroSeconds() {
- Long temp_long = new Long((kerberosTime % 1000L) * 1000L);
- return temp_long.intValue() + microSeconds;
+ int temp_int = (int) ((kerberosTime % 1000L) * 1000L);
+ return temp_int + microSeconds;
}
/**
@@ -250,8 +250,7 @@
}
public int getSeconds() {
- Long temp_long = new Long(kerberosTime / 1000L);
- return temp_long.intValue();
+ return (int) (kerberosTime / 1000L);
}
/**
--- a/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java Tue Jul 01 10:20:56 2014 -0700
@@ -334,15 +334,29 @@
* returns null.
*/
Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception {
- PrincipalName cpname = readPrincipal(version);
- if (DEBUG)
+ PrincipalName cpname = null;
+ try {
+ cpname = readPrincipal(version);
+ } catch (Exception e) {
+ // Do not return here. All data for this cred should be fully
+ // consumed so that we can read the next one.
+ }
+ if (DEBUG) {
System.out.println(">>>DEBUG <CCacheInputStream> client principal is " + cpname);
- PrincipalName spname = readPrincipal(version);
- if (DEBUG)
+ }
+ PrincipalName spname = null;
+ try {
+ spname = readPrincipal(version);
+ } catch (Exception e) {
+ // same as above
+ }
+ if (DEBUG) {
System.out.println(">>>DEBUG <CCacheInputStream> server principal is " + spname);
+ }
EncryptionKey key = readKey(version);
- if (DEBUG)
+ if (DEBUG) {
System.out.println(">>>DEBUG <CCacheInputStream> key type: " + key.getEType());
+ }
long times[] = readTimes();
KerberosTime authtime = new KerberosTime(times[0]);
KerberosTime starttime =
@@ -375,6 +389,11 @@
byte[] ticketData = readData();
byte[] ticketData2 = readData();
+ // Skip this cred if either cpname or spname isn't created.
+ if (cpname == null || spname == null) {
+ return null;
+ }
+
try {
return new Credentials(cpname, spname, key, authtime, starttime,
endtime, renewTill, skey, tFlags,
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS9Attribute.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/security/pkcs/PKCS9Attribute.java Tue Jul 01 10:20:56 2014 -0700
@@ -309,26 +309,26 @@
*/
private static final Byte[][] PKCS9_VALUE_TAGS = {
null,
- {new Byte(DerValue.tag_IA5String)}, // EMailAddress
- {new Byte(DerValue.tag_IA5String), // UnstructuredName
- new Byte(DerValue.tag_PrintableString)},
- {new Byte(DerValue.tag_ObjectId)}, // ContentType
- {new Byte(DerValue.tag_OctetString)}, // MessageDigest
- {new Byte(DerValue.tag_UtcTime)}, // SigningTime
- {new Byte(DerValue.tag_Sequence)}, // Countersignature
- {new Byte(DerValue.tag_PrintableString),
- new Byte(DerValue.tag_T61String)}, // ChallengePassword
- {new Byte(DerValue.tag_PrintableString),
- new Byte(DerValue.tag_T61String)}, // UnstructuredAddress
- {new Byte(DerValue.tag_SetOf)}, // ExtendedCertificateAttributes
- {new Byte(DerValue.tag_Sequence)}, // issuerAndSerialNumber
+ {DerValue.tag_IA5String}, // EMailAddress
+ {DerValue.tag_IA5String, // UnstructuredName
+ DerValue.tag_PrintableString},
+ {DerValue.tag_ObjectId}, // ContentType
+ {DerValue.tag_OctetString}, // MessageDigest
+ {DerValue.tag_UtcTime}, // SigningTime
+ {DerValue.tag_Sequence}, // Countersignature
+ {DerValue.tag_PrintableString,
+ DerValue.tag_T61String}, // ChallengePassword
+ {DerValue.tag_PrintableString,
+ DerValue.tag_T61String}, // UnstructuredAddress
+ {DerValue.tag_SetOf}, // ExtendedCertificateAttributes
+ {DerValue.tag_Sequence}, // issuerAndSerialNumber
null,
null,
null,
- {new Byte(DerValue.tag_Sequence)}, // extensionRequest
- {new Byte(DerValue.tag_Sequence)}, // SMIMECapability
- {new Byte(DerValue.tag_Sequence)}, // SigningCertificate
- {new Byte(DerValue.tag_Sequence)} // SignatureTimestampToken
+ {DerValue.tag_Sequence}, // extensionRequest
+ {DerValue.tag_Sequence}, // SMIMECapability
+ {DerValue.tag_Sequence}, // SigningCertificate
+ {DerValue.tag_Sequence} // SignatureTimestampToken
};
private static final Class<?>[] VALUE_CLASSES = new Class<?>[18];
@@ -511,7 +511,7 @@
// check for illegal element tags
Byte tag;
for (int i=0; i < elems.length; i++) {
- tag = new Byte(elems[i].tag);
+ tag = elems[i].tag;
if (indexOf(tag, PKCS9_VALUE_TAGS[index], 0) == -1)
throwTagException(tag);
--- a/jdk/src/share/classes/sun/security/tools/keytool/Main.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/security/tools/keytool/Main.java Tue Jul 01 10:20:56 2014 -0700
@@ -1675,7 +1675,7 @@
Object[] source = {new Integer(keysize),
privKey.getAlgorithm(),
chain[0].getSigAlgName(),
- new Long(validity),
+ validity,
x500Name};
System.err.println(form.format(source));
}
--- a/jdk/src/share/classes/sun/security/x509/AVA.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/security/x509/AVA.java Tue Jul 01 10:20:56 2014 -0700
@@ -517,7 +517,7 @@
if (hexDigits.indexOf(Character.toUpperCase((char)c2)) >= 0) {
int hi = Character.digit((char)c1, 16);
int lo = Character.digit((char)c2, 16);
- return new Byte((byte)((hi<<4) + lo));
+ return (byte)((hi<<4) + lo);
} else {
throw new IOException
("escaped hex value must include two valid digits");
--- a/jdk/src/share/classes/sun/tools/java/BinaryConstantPool.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/tools/java/BinaryConstantPool.java Tue Jul 01 10:20:56 2014 -0700
@@ -66,7 +66,7 @@
cpool[i] = new Float(in.readFloat());
break;
case CONSTANT_LONG:
- cpool[i++] = new Long(in.readLong());
+ cpool[i++] = in.readLong();
break;
case CONSTANT_DOUBLE:
cpool[i++] = new Double(in.readDouble());
--- a/jdk/src/share/classes/sun/tools/jconsole/MemoryPoolProxy.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/tools/jconsole/MemoryPoolProxy.java Tue Jul 01 10:20:56 2014 -0700
@@ -56,7 +56,7 @@
ObjectName mbeanName = new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE +
",name=" + name);
if (client.isRegistered(mbeanName)) {
- gcMBeans.put(mbeanName, new Long(0));
+ gcMBeans.put(mbeanName, 0L);
}
} catch (Exception e) {
assert false;
@@ -97,7 +97,7 @@
Long gcCount = e.getValue();
Long newCount = gc.getCollectionCount();
if (newCount > gcCount) {
- gcMBeans.put(e.getKey(), new Long(newCount));
+ gcMBeans.put(e.getKey(), newCount);
lastGcInfo = gc.getLastGcInfo();
if (lastGcInfo.getEndTime() > lastGcEndTime) {
gcId = lastGcInfo.getId();
--- a/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java Tue Jul 01 10:20:56 2014 -0700
@@ -342,14 +342,14 @@
Object result;
if (primitiveToWrapper.containsKey(type)) {
if (type.equals(Character.TYPE.getName())) {
- result = new Character(value.charAt(0));
+ result = value.charAt(0);
} else {
result = newStringConstructor(
((Class<?>) primitiveToWrapper.get(type)).getName(),
value);
}
} else if (type.equals(Character.class.getName())) {
- result = new Character(value.charAt(0));
+ result = value.charAt(0);
} else if (Number.class.isAssignableFrom(Utils.getClass(type))) {
result = createNumberFromStringValue(value);
} else if (value == null || value.equals("null")) {
--- a/jdk/src/share/classes/sun/tools/tree/BitNotExpression.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/tools/tree/BitNotExpression.java Tue Jul 01 10:20:56 2014 -0700
@@ -83,7 +83,7 @@
asm.add(where, opc_ldc, new Integer(-1));
asm.add(where, opc_ixor);
} else {
- asm.add(where, opc_ldc2_w, new Long(-1));
+ asm.add(where, opc_ldc2_w, -1L);
asm.add(where, opc_lxor);
}
}
--- a/jdk/src/share/classes/sun/tools/tree/IncDecExpression.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/tools/tree/IncDecExpression.java Tue Jul 01 10:20:56 2014 -0700
@@ -131,7 +131,7 @@
asm.add(where, inc ? opc_iadd : opc_isub);
break;
case TC_LONG:
- asm.add(where, opc_ldc2_w, new Long(1));
+ asm.add(where, opc_ldc2_w, 1L);
asm.add(where, inc ? opc_ladd : opc_lsub);
break;
case TC_FLOAT:
--- a/jdk/src/share/classes/sun/tools/tree/LongExpression.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/share/classes/sun/tools/tree/LongExpression.java Tue Jul 01 10:20:56 2014 -0700
@@ -50,7 +50,7 @@
* Get the value
*/
public Object getValue() {
- return new Long(value);
+ return value;
}
/**
@@ -71,7 +71,7 @@
* Code
*/
public void codeValue(Environment env, Context ctx, Assembler asm) {
- asm.add(where, opc_ldc2_w, new Long(value));
+ asm.add(where, opc_ldc2_w, value);
}
/**
--- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java Tue Jul 01 10:20:56 2014 -0700
@@ -747,7 +747,7 @@
nmt = systemRootModFile.lastModified();
isSystemRootModified = systemRootModTime == nmt;
}
- return new Long(nmt);
+ return nmt;
}
});
try {
--- a/jdk/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFocusProxyWindow.java Tue Jul 01 10:20:56 2014 -0700
@@ -38,8 +38,9 @@
public XFocusProxyWindow(XWindowPeer owner) {
super(new XCreateWindowParams(new Object[] {
BOUNDS, new Rectangle(-1, -1, 1, 1),
- PARENT_WINDOW, new Long(owner.getWindow()),
- EVENT_MASK, new Long(XConstants.FocusChangeMask | XConstants.KeyPressMask | XConstants.KeyReleaseMask)
+ PARENT_WINDOW, Long.valueOf(owner.getWindow()),
+ EVENT_MASK, Long.valueOf(XConstants.FocusChangeMask | XConstants
+ .KeyPressMask | XConstants.KeyReleaseMask)
}));
this.owner = owner;
}
--- a/jdk/src/solaris/native/java/net/net_util_md.c Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/solaris/native/java/net/net_util_md.c Tue Jul 01 10:20:56 2014 -0700
@@ -1317,7 +1317,7 @@
* or sending UDP packet.
* 2. IPv6 on Linux: By default Linux ignores flowinfo
* field so enable IPV6_FLOWINFO_SEND so that flowinfo
- * will be examined.
+ * will be examined. We also set the IPv4 TOS option in this case.
* 3. IPv4: set socket option based on ToS and Precedence
* fields (otherwise get invalid argument)
*/
@@ -1333,8 +1333,10 @@
#if defined(AF_INET6) && defined(__linux__)
if (ipv6_available()) {
int optval = 1;
- return setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
- (void *)&optval, sizeof(optval));
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_FLOWINFO_SEND,
+ (void *)&optval, sizeof(optval)) < 0) {
+ return -1;
+ }
}
#endif
--- a/jdk/src/solaris/native/sun/nio/ch/Net.c Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/solaris/native/sun/nio/ch/Net.c Tue Jul 01 10:20:56 2014 -0700
@@ -435,7 +435,8 @@
JNIEXPORT void JNICALL
Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
- jboolean mayNeedConversion, jint level, jint opt, jint arg)
+ jboolean mayNeedConversion, jint level,
+ jint opt, jint arg, jboolean isIPv6)
{
int result;
struct linger linger;
@@ -478,6 +479,12 @@
JNU_JAVANETPKG "SocketException",
"sun.nio.ch.Net.setIntOption");
}
+#ifdef __linux__
+ if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS && isIPv6) {
+ // set the V4 option also
+ setsockopt(fdval(env, fdo), IPPROTO_IP, IP_TOS, parg, arglen);
+ }
+#endif
}
JNIEXPORT jint JNICALL
--- a/jdk/src/solaris/native/sun/security/smartcardio/MUSCLE/pcsclite.h Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/solaris/native/sun/security/smartcardio/MUSCLE/pcsclite.h Tue Jul 01 10:20:56 2014 -0700
@@ -75,6 +75,13 @@
}
SCARD_READERSTATE_A;
+typedef struct _SCARD_IO_REQUEST
+{
+ unsigned long dwProtocol; /* Protocol identifier */
+ unsigned long cbPciLength; /* Protocol Control Inf Length */
+}
+SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
+
#else // __APPLE__
#pragma pack(1)
@@ -88,6 +95,13 @@
unsigned char rgbAtr[MAX_ATR_SIZE];
}
SCARD_READERSTATE_A;
+
+typedef struct _SCARD_IO_REQUEST
+{
+ uint32_t dwProtocol; /* Protocol identifier */
+ uint32_t cbPciLength; /* Protocol Control Inf Length */
+}
+SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
#pragma pack()
#endif // __APPLE__
@@ -95,13 +109,6 @@
typedef SCARD_READERSTATE_A SCARD_READERSTATE, *PSCARD_READERSTATE_A,
*LPSCARD_READERSTATE_A;
-typedef struct _SCARD_IO_REQUEST
-{
- unsigned long dwProtocol; /* Protocol identifier */
- unsigned long cbPciLength; /* Protocol Control Inf Length */
-}
-SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST;
-
typedef const SCARD_IO_REQUEST *LPCSCARD_IO_REQUEST;
extern SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci,
--- a/jdk/src/windows/native/sun/nio/ch/Net.c Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/src/windows/native/sun/nio/ch/Net.c Tue Jul 01 10:20:56 2014 -0700
@@ -319,7 +319,7 @@
JNIEXPORT void JNICALL
Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
- jboolean mayNeedConversion, jint level, jint opt, jint arg)
+ jboolean mayNeedConversion, jint level, jint opt, jint arg, jboolean ipv6)
{
struct linger linger;
char *parg;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/corba/se/impl/io/CustomOutputStream.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+import java.io.Serializable;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.Principal;
+import org.omg.CORBA_2_3.portable.OutputStream;
+import org.omg.CORBA_2_3.portable.InputStream;
+
+public class CustomOutputStream extends OutputStream {
+
+ @Override
+ public void write_value(Serializable value, Class clz) {
+ }
+
+ @Override
+ public InputStream create_input_stream() {
+ return null;
+ }
+
+ @Override
+ public void write_boolean(boolean value) {
+ }
+
+ @Override
+ public void write_char(char value) {
+ }
+
+ @Override
+ public void write_wchar(char value) {
+ }
+
+ @Override
+ public void write_octet(byte value) {
+ }
+
+ @Override
+ public void write_short(short value) {
+ }
+
+ @Override
+ public void write_ushort(short value) {
+ }
+
+ @Override
+ public void write_long(int value) {
+ }
+
+ @Override
+ public void write_ulong(int value) {
+ }
+
+ @Override
+ public void write_longlong(long value) {
+ }
+
+ @Override
+ public void write_ulonglong(long value) {
+ }
+
+ @Override
+ public void write_float(float value) {
+ }
+
+ @Override
+ public void write_double(double value) {
+ }
+
+ @Override
+ public void write_string(String value) {
+ }
+
+ @Override
+ public void write_wstring(String value) {
+ }
+
+ @Override
+ public void write_boolean_array(boolean[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_char_array(char[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_wchar_array(char[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_octet_array(byte[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_short_array(short[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_ushort_array(short[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_long_array(int[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_ulong_array(int[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_longlong_array(long[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_ulonglong_array(long[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_float_array(float[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_double_array(double[] value, int offset,
+ int length) {
+ }
+
+ @Override
+ public void write_Object(org.omg.CORBA.Object value) {
+ }
+
+ @Override
+ public void write_TypeCode(TypeCode value) {
+ }
+
+ @Override
+ public void write_any(Any value) {
+ }
+
+ @Override
+ public void write_Principal(Principal value) {
+ }
+
+ @Override
+ public void write(int b) throws java.io.IOException {
+ }
+
+ @Override
+ public void write_fixed(java.math.BigDecimal value) {
+ }
+
+ @Override
+ public void write_Context(org.omg.CORBA.Context ctx,
+ org.omg.CORBA.ContextList contexts) {
+ }
+
+ @Override
+ public org.omg.CORBA.ORB orb() {
+ return null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/corba/se/impl/io/HookPutFieldsTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2014, 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 7095856
+ * @summary OutputStreamHook doesn't handle null values
+ */
+
+import java.net.InetAddress;
+import javax.rmi.CORBA.Util;
+import javax.rmi.CORBA.ValueHandler;
+
+public class HookPutFieldsTest {
+
+ public static void main(String[] args ) throws Exception {
+ CustomOutputStream os = new CustomOutputStream();
+ InetAddress a = InetAddress.getByAddress(null, new byte[] {1,2,3,4});
+ ValueHandler vh = Util.createValueHandler();
+ vh.writeValue(os, a);
+ }
+}
--- a/jdk/test/com/sun/jdi/ExclusiveBind.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/jdi/ExclusiveBind.java Tue Jul 01 10:20:56 2014 -0700
@@ -68,7 +68,9 @@
private static ProcessBuilder prepareLauncher(String address, boolean suspend, String class_name) throws Exception {
List<String> args = new ArrayList<>();
for(String dbgOption : VMConnection.getDebuggeeVMOptions().split(" ")) {
- args.add(dbgOption);
+ if (!dbgOption.trim().isEmpty()) {
+ args.add(dbgOption);
+ }
}
String lib = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=";
if (suspend) {
--- a/jdk/test/com/sun/jdi/VMConnection.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/jdi/VMConnection.java Tue Jul 01 10:20:56 2014 -0700
@@ -59,13 +59,13 @@
retVal += "-classpath " + testClasses;
String vmOpts = System.getProperty("test.vm.opts");
- System.out.println("vmOpts: "+vmOpts);
- if (vmOpts != null) {
+ System.out.println("vmOpts: '" + vmOpts + "'");
+ if (vmOpts != null && !vmOpts.trim().isEmpty()) {
retVal += " " + vmOpts;
}
String javaOpts = System.getProperty("test.java.opts");
- System.out.println("javaOpts: "+javaOpts);
- if (javaOpts != null) {
+ System.out.println("javaOpts: '" + javaOpts + "'");
+ if (javaOpts != null && !javaOpts.trim().isEmpty()) {
retVal += " " + javaOpts;
}
--- a/jdk/test/com/sun/tools/attach/Application.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/tools/attach/Application.java Tue Jul 01 10:20:56 2014 -0700
@@ -23,41 +23,21 @@
/*
* A simple "Application" used by the Attach API unit tests. This application is
- * launched by the test. It binds to a random port and shuts down when somebody
- * connects to that port.
- * Used port and pid are written both to stdout and to a specified file.
+ * launched by the test.
*/
-import java.net.Socket;
-import java.net.ServerSocket;
-import java.io.PrintWriter;
-import jdk.testlibrary.ProcessTools;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
public class Application {
- public static void main(String args[]) throws Exception {
- // bind to a random port
- if (args.length < 1) {
- System.err.println("First argument should be path to output file.");
- }
- String outFileName = args[0];
+ public static final String READY_MSG="ready";
+ public static final String SHUTDOWN_MSG="shutdown";
- ServerSocket ss = new ServerSocket(0);
- int port = ss.getLocalPort();
- int pid = ProcessTools.getProcessId();
-
- System.out.println("shutdownPort=" + port);
- System.out.println("pid=" + pid);
+ public static void main(String args[]) throws Exception {
+ System.out.println(READY_MSG);
System.out.flush();
- try (PrintWriter writer = new PrintWriter(outFileName)) {
- writer.println("shutdownPort=" + port);
- writer.println("pid=" + pid);
- writer.println("done");
- writer.flush();
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
+ while (!br.readLine().equals(SHUTDOWN_MSG));
}
-
- // wait for test harness to connect
- Socket s = ss.accept();
- s.close();
- ss.close();
}
}
--- a/jdk/test/com/sun/tools/attach/BasicTests.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/tools/attach/BasicTests.java Tue Jul 01 10:20:56 2014 -0700
@@ -38,7 +38,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build jdk.testlibrary.* Agent BadAgent RedefineAgent Application Shutdown RedefineDummy RunnerUtil
+ * @run build jdk.testlibrary.* Agent BadAgent RedefineAgent Application RedefineDummy RunnerUtil
* @run main BasicTests
*
* This test will perform a number of basic attach tests.
@@ -55,21 +55,18 @@
* 5. Shut down the Application.
*/
public static void main(String args[]) throws Throwable {
- final String pidFile = "TestsBasic.Application.pid";
ProcessThread processThread = null;
- RunnerUtil.ProcessInfo info = null;
try {
buildJars();
- processThread = RunnerUtil.startApplication(pidFile);
- info = RunnerUtil.readProcessInfo(pidFile);
- runTests(info.pid);
+ processThread = RunnerUtil.startApplication();
+ runTests(processThread.getPid());
} catch (Throwable t) {
System.out.println("TestBasic got unexpected exception: " + t);
t.printStackTrace();
throw t;
} finally {
// Make sure the Application process is stopped.
- RunnerUtil.stopApplication(info.shutdownPort, processThread);
+ RunnerUtil.stopApplication(processThread);
}
}
@@ -78,7 +75,7 @@
* The reason for running the tests in a separate process
* is that we need to modify the class path.
*/
- private static void runTests(int pid) throws Throwable {
+ private static void runTests(long pid) throws Throwable {
final String sep = File.separator;
// Need to add jdk/lib/tools.jar to classpath.
@@ -92,7 +89,7 @@
"-classpath",
classpath,
"BasicTests$TestMain",
- Integer.toString(pid),
+ Long.toString(pid),
testClassDir + "Agent.jar",
testClassDir + "BadAgent.jar",
testClassDir + "RedefineAgent.jar" };
--- a/jdk/test/com/sun/tools/attach/PermissionTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/tools/attach/PermissionTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -23,7 +23,6 @@
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.AttachNotSupportedException;
-import java.util.Properties;
import java.io.File;
import jdk.testlibrary.OutputAnalyzer;
import jdk.testlibrary.ProcessTools;
@@ -34,7 +33,7 @@
* @bug 6173612 6273707 6277253 6335921 6348630 6342019 6381757
* @summary Basic unit tests for the VM attach mechanism.
* @library /lib/testlibrary
- * @run build jdk.testlibrary.* Application Shutdown
+ * @run build jdk.testlibrary.* Application
* @run main PermissionTest
*
* Unit test for Attach API -
@@ -51,20 +50,17 @@
* 4. Shut down the Application.
*/
public static void main(String args[]) throws Throwable {
- final String pidFile ="TestPermission.Application.pid";
ProcessThread processThread = null;
- RunnerUtil.ProcessInfo info = null;
try {
- processThread = RunnerUtil.startApplication(pidFile);
- info = RunnerUtil.readProcessInfo(pidFile);
- runTests(info.pid);
+ processThread = RunnerUtil.startApplication();
+ runTests(processThread.getPid());
} catch (Throwable t) {
System.out.println("TestPermission got unexpected exception: " + t);
t.printStackTrace();
throw t;
} finally {
// Make sure the Application process is stopped.
- RunnerUtil.stopApplication(info.shutdownPort, processThread);
+ RunnerUtil.stopApplication(processThread);
}
}
@@ -72,7 +68,7 @@
* Runs the actual test the nested class TestMain.
* The test is run in a separate process because we need to add to the classpath.
*/
- private static void runTests(int pid) throws Throwable {
+ private static void runTests(long pid) throws Throwable {
final String sep = File.separator;
// Need to add jdk/lib/tools.jar to classpath.
@@ -88,7 +84,7 @@
"-Djava.security.manager",
String.format("-Djava.security.policy=%sjava.policy.deny", testSrc),
"PermissionTest$TestMain",
- Integer.toString(pid),
+ Long.toString(pid),
"true" };
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
@@ -100,7 +96,7 @@
"-Djava.security.manager",
String.format("-Djava.security.policy=%sjava.policy.allow", testSrc),
"PermissionTest$TestMain",
- Integer.toString(pid),
+ Long.toString(pid),
"false" };
output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
--- a/jdk/test/com/sun/tools/attach/RunnerUtil.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/tools/attach/RunnerUtil.java Tue Jul 01 10:20:56 2014 -0700
@@ -25,10 +25,7 @@
import java.io.File;
import java.nio.file.Files;
import java.util.Arrays;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import jdk.testlibrary.OutputAnalyzer;
import jdk.testlibrary.ProcessTools;
import jdk.testlibrary.Utils;
import jdk.testlibrary.ProcessThread;
@@ -49,12 +46,12 @@
*
* The Application will write its pid and shutdownPort in the given outFile.
*/
- public static ProcessThread startApplication(String outFile, String... additionalOpts) throws Throwable {
+ public static ProcessThread startApplication(String... additionalOpts) throws Throwable {
String classpath = System.getProperty("test.class.path", ".");
- String[] myArgs = concat(additionalOpts, new String [] { "-Dattach.test=true", "-classpath", classpath, "Application", outFile });
+ String[] myArgs = concat(additionalOpts, new String [] { "-Dattach.test=true", "-classpath", classpath, "Application" });
String[] args = Utils.addTestJavaOpts(myArgs);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
- ProcessThread pt = new ProcessThread("runApplication", pb);
+ ProcessThread pt = new ProcessThread("runApplication", (line) -> line.equals(Application.READY_MSG), pb);
pt.start();
return pt;
}
@@ -81,23 +78,16 @@
*
* If the nice shutdown fails, then an Exception is thrown and the test should fail.
*
- * @param port The shut down port.
* @param processThread The process to stop.
*/
- public static void stopApplication(int port, ProcessThread processThread) throws Throwable {
+ public static void stopApplication(ProcessThread processThread) throws Throwable {
if (processThread == null) {
System.out.println("RunnerUtil.stopApplication ignored since proc is null");
return;
}
try {
- System.out.println("RunnerUtil.stopApplication waiting to for shutdown");
- OutputAnalyzer output = ProcessTools.executeTestJvm(
- "-classpath",
- System.getProperty("test.class.path", "."),
- "Shutdown",
- Integer.toString(port));
- // Verify that both the Shutdown command and the Application finished ok.
- output.shouldHaveExitValue(0);
+ System.out.println("RunnerUtil.stopApplication waiting for shutdown");
+ processThread.sendMessage(Application.SHUTDOWN_MSG);
processThread.joinAndThrow();
processThread.getOutput().shouldHaveExitValue(0);
} catch (Throwable t) {
@@ -120,59 +110,6 @@
}
/**
- * Read process info for the running Application.
- * The Application writes its info to a file with this format:
- * shutdownPort=42994
- * pid=19597
- * done
- *
- * The final "done" is used to make sure the complete file has been written
- * before we try to read it.
- * This function will wait until the file is available.
- *
- * @param filename Path to file to read.
- * @return The ProcessInfo containing pid and shutdownPort.
- */
- public static ProcessInfo readProcessInfo(String filename) throws Throwable {
- System.out.println("Reading port and pid from file: " + filename);
- File file = new File(filename);
- String content = null;
-
- // Read file or wait for it to be created.
- long startTime = System.currentTimeMillis();
- long lastWarningTime = 0;
- while (true) {
- content = readFile(file);
- if (content != null && content.indexOf("done") >= 0) {
- break;
- }
- Thread.sleep(100);
- long elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
- if (elapsedTime > lastWarningTime) {
- lastWarningTime = elapsedTime;
- System.out.println("Waited " + elapsedTime + " seconds for file.");
- }
- }
-
- ProcessInfo info = new ProcessInfo();
- // search for a line with format: key=nnn
- Pattern pattern = Pattern.compile("(\\w*)=([0-9]+)\\r?\\n");
- Matcher matcher = pattern.matcher(content);
- while (matcher.find()) {
- String key = matcher.group(1);
- int value = Integer.parseInt(matcher.group(2));
- if ("pid".equals(key)) {
- info.pid = value;
- } else if ("shutdownPort".equals(key)) {
- info.shutdownPort = value;
- }
- }
- System.out.println("processInfo.pid:" + info.pid);
- System.out.println("processInfo.shutdownPort:" + info.shutdownPort);
- return info;
- }
-
- /**
* Read the content of a file.
* @param file The file to read.
* @return The file content or null if file does not exists.
@@ -190,13 +127,4 @@
throw e;
}
}
-
- /**
- * Helper class with info of the running Application.
- */
- public static class ProcessInfo {
- public int pid = -1;
- public int shutdownPort = -1;
- }
-
}
--- a/jdk/test/com/sun/tools/attach/Shutdown.java Tue Jun 24 12:27:37 2014 +0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-/*
- *
- *
- * Utility used by the unit tests for the attach mechanism. Connects to a
- * given port which triggers the listener to shutdown.
- */
-import java.net.Socket;
-import java.net.InetSocketAddress;
-import java.io.IOException;
-
-public class Shutdown {
- public static void main(String args[]) throws IOException {
- int port = Integer.parseInt(args[0]);
-
- System.out.println("Connecting to port " + port +
- " to shutdown Application ...");
-
- Socket s = new Socket();
- s.connect( new InetSocketAddress(port) );
- s.close();
- }
-}
--- a/jdk/test/com/sun/tools/attach/StartManagementAgent.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/tools/attach/StartManagementAgent.java Tue Jul 01 10:20:56 2014 -0700
@@ -40,7 +40,7 @@
* @test
* @summary Test for VirtualMachine.startManagementAgent and VirtualMachine.startLocalManagementAgent
* @library /lib/testlibrary
- * @run build Application Shutdown
+ * @run build Application jdk.testlibrary.*
* @run main StartManagementAgent
*/
@@ -51,20 +51,17 @@
*/
public class StartManagementAgent {
public static void main(String[] args) throws Throwable {
- final String pidFile = "StartManagementAgent.Application.pid";
ProcessThread processThread = null;
- RunnerUtil.ProcessInfo info = null;
try {
- processThread = RunnerUtil.startApplication(pidFile);
- info = RunnerUtil.readProcessInfo(pidFile);
- runTests(info.pid);
+ processThread = RunnerUtil.startApplication();
+ runTests(processThread.getPid());
} catch (Throwable t) {
System.out.println("StartManagementAgent got unexpected exception: " + t);
t.printStackTrace();
throw t;
} finally {
// Make sure the Application process is stopped.
- RunnerUtil.stopApplication(info.shutdownPort, processThread);
+ RunnerUtil.stopApplication(processThread);
}
}
@@ -104,7 +101,7 @@
private static final int MAX_RETRIES = 10;
- public static void runTests(int pid) throws Exception {
+ public static void runTests(long pid) throws Exception {
VirtualMachine vm = VirtualMachine.attach(""+pid);
try {
--- a/jdk/test/com/sun/tools/attach/TempDirTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/com/sun/tools/attach/TempDirTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -38,7 +38,7 @@
* @bug 8033104
* @summary Test to make sure attach and jvmstat works correctly when java.io.tmpdir is set
* @library /lib/testlibrary
- * @run build jdk.testlibrary.* Application Shutdown RunnerUtil
+ * @run build jdk.testlibrary.* Application RunnerUtil
* @run main/timeout=200 TempDirTest
*/
@@ -90,22 +90,20 @@
final String pidFile = "TempDirTest.Application.pid-" + counter++;
ProcessThread processThread = null;
- RunnerUtil.ProcessInfo info = null;
try {
String[] tmpDirArg = null;
if (targetTmpDir != null) {
tmpDirArg = new String[] {"-Djava.io.tmpdir=" + targetTmpDir};
}
- processThread = RunnerUtil.startApplication(pidFile, tmpDirArg);
- info = RunnerUtil.readProcessInfo(pidFile);
- launchTests(info.pid, clientTmpDir);
+ processThread = RunnerUtil.startApplication(tmpDirArg);
+ launchTests(processThread.getPid(), clientTmpDir);
} catch (Throwable t) {
System.out.println("TempDirTest got unexpected exception: " + t);
t.printStackTrace();
throw t;
} finally {
// Make sure the Application process is stopped.
- RunnerUtil.stopApplication(info.shutdownPort, processThread);
+ RunnerUtil.stopApplication(processThread);
}
elapsedTime = (System.currentTimeMillis() - startTime) / 1000;
@@ -119,7 +117,7 @@
* is that we need to modify the class path and
* the -Djava.io.tmpdir property.
*/
- private static void launchTests(int pid, Path clientTmpDir) throws Throwable {
+ private static void launchTests(long pid, Path clientTmpDir) throws Throwable {
final String sep = File.separator;
// Need to add jdk/lib/tools.jar to classpath.
@@ -139,7 +137,7 @@
"-classpath",
classpath,
"TempDirTest$TestMain",
- Integer.toString(pid) });
+ Long.toString(pid) });
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
--- a/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java Tue Jul 01 10:20:56 2014 -0700
@@ -34,6 +34,7 @@
import java.lang.management.*;
import java.util.concurrent.Phaser;
+import java.util.function.Supplier;
public class SynchronizationStatistics {
private static class LockerThread extends Thread {
@@ -86,6 +87,8 @@
private static void testBlockingOnSimpleMonitor() throws Exception {
System.out.println("testBlockingOnSimpleMonitor");
final Object lock1 = new Object();
+ System.out.println("Lock1 = " + lock1);
+
final Phaser p = new Phaser(2);
LockerThread lt = newLockerThread(new Runnable() {
@Override
@@ -110,12 +113,12 @@
}
p.arriveAndAwaitAdvance(); // phase[2]
- testBlocked(ti, mbean.getThreadInfo(tid), lockName, lock1);
+ testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock1);
p.arriveAndDeregister(); // phase[3]
lt.join();
- System.out.println("OK");
+ printok();
}
/**
@@ -128,6 +131,9 @@
final Object lock1 = new Object();
final Object lock2 = new Object();
+ System.out.println("Lock1 = " + lock1);
+ System.out.println("Lock2 = " + lock2);
+
final Phaser p = new Phaser(2);
LockerThread lt = newLockerThread(new Runnable() {
@Override
@@ -149,7 +155,6 @@
lt.start();
long tid = lt.getId();
ThreadInfo ti = mbean.getThreadInfo(tid);
- ThreadInfo ti1 = null;
String lockName = null;
synchronized(lock1) {
p.arriveAndAwaitAdvance(); // phase[1]
@@ -158,9 +163,7 @@
}
p.arriveAndAwaitAdvance(); // phase[2]
- ti1 = mbean.getThreadInfo(tid);
- testBlocked(ti, ti1, lockName, lock1);
- ti = ti1;
+ ti = testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock1);
synchronized(lock2) {
p.arriveAndAwaitAdvance(); // phase [3]
@@ -168,12 +171,12 @@
lockName = mbean.getThreadInfo(tid).getLockName();
}
p.arriveAndAwaitAdvance(); // phase [4]
- testBlocked(ti, mbean.getThreadInfo(tid), lockName, lock2);
+ testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock2);
p.arriveAndDeregister();
lt.join();
- System.out.println("OK");
+ printok();
}
/**
@@ -209,13 +212,12 @@
}
p.arriveAndAwaitAdvance(); // phase[2]
- ThreadInfo ti2 = mbean.getThreadInfo(lt.getId());
+ testWaited(ti1, () -> mbean.getThreadInfo(lt.getId()), 1);
p.arriveAndDeregister(); // phase[3]
lt.join();
- testWaited(ti1, ti2, 1);
- System.out.println("OK");
+ printok();
}
/**
@@ -256,12 +258,12 @@
int phase = p.getPhase();
while ((p.arriveAndAwaitAdvance() - phase) < 3); // phase[2-4]
- ThreadInfo ti2 = mbean.getThreadInfo(lt.getId());
+ testWaited(ti1, () -> mbean.getThreadInfo(lt.getId()), 3);
p.arriveAndDeregister(); // phase[5]
lt.join();
- testWaited(ti1, ti2, 3);
- System.out.println("OK");
+
+ printok();
}
/**
@@ -331,44 +333,85 @@
}
p.arriveAndAwaitAdvance(); // phase[4]
- ThreadInfo ti2 = mbean.getThreadInfo(lt.getId());
+ testWaited(ti1, () -> mbean.getThreadInfo(lt.getId()), 3);
p.arriveAndDeregister(); // phase[5]
lt.join();
- testWaited(ti1, ti2, 3);
- System.out.println("OK");
+ printok();
+ }
+
+ private static void printok() {
+ System.out.println("OK\n");
}
- private static void testWaited(ThreadInfo ti1, ThreadInfo ti2, int waited) throws Error {
- long waitCntDiff = ti2.getWaitedCount() - ti1.getWaitedCount();
- long waitTimeDiff = ti2.getWaitedTime() - ti1.getWaitedTime();
- if (waitCntDiff < waited) {
- throw new Error("Unexpected diff in waited count. Expecting at least "
- + waited + " , got " + waitCntDiff);
- }
- if (waitTimeDiff <= 0) {
- throw new Error("Unexpected diff in waited time. Expecting increasing " +
- "value, got " + waitTimeDiff + "ms");
- }
+ private static void testWaited(ThreadInfo ti1, Supplier<ThreadInfo> ti2, int waited)
+ throws InterruptedException {
+ boolean error;
+ do {
+ error = false;
+ ThreadInfo ti = ti2.get();
+ long waitCntDiff = ti.getWaitedCount() - ti1.getWaitedCount();
+ long waitTimeDiff = ti.getWaitedTime() - ti1.getWaitedTime();
+ if (waitCntDiff < waited) {
+ System.err.println(
+ "Unexpected diff in waited count. Expecting at least "
+ + waited + " , got " + waitCntDiff
+ );
+ error = true;
+ }
+ if (waitTimeDiff <= 0) {
+ System.err.println(
+ "Unexpected diff in waited time. Expecting increasing " +
+ "value, got " + waitTimeDiff + "ms"
+ );
+ error = true;
+ }
+ if (error) {
+ System.err.println("Retrying in 20ms ...");
+ Thread.sleep(20);
+ }
+ } while (error);
}
- private static void testBlocked(ThreadInfo ti1, ThreadInfo ti2,
+ private static ThreadInfo testBlocked(ThreadInfo ti1, Supplier<ThreadInfo> ti2,
String lockName, final Object lock)
- throws Error {
- long blkCntDiff = ti2.getBlockedCount() - ti1.getBlockedCount();
- long blkTimeDiff = ti2.getBlockedTime() - ti1.getBlockedTime();
- if (blkCntDiff < 1) {
- throw new Error("Unexpected diff in blocked count. Expecting at least 1, " +
- "got " + blkCntDiff);
- }
- if (blkTimeDiff < 0) {
- throw new Error("Unexpected diff in blocked time. Expecting a positive " +
- "number, got " + blkTimeDiff);
- }
- if (!lockName.equals(lock.toString())) {
- throw new Error("Unexpected blocked monitor name. Expecting " +
- lock.toString() + ", got " +
- lockName);
- }
+ throws InterruptedException {
+ boolean error;
+ ThreadInfo ti = null;
+ do {
+ error = false;
+ ti = ti2.get();
+ long blkCntDiff = ti.getBlockedCount() - ti1.getBlockedCount();
+ long blkTimeDiff = ti.getBlockedTime() - ti1.getBlockedTime();
+
+ System.out.println("testBlocked: [" + blkCntDiff + ", " + blkTimeDiff + ", " + lockName + "]");
+
+ if (blkCntDiff < 1) {
+ System.err.println(
+ "Unexpected diff in blocked count. Expecting at least 1, " +
+ "got " + blkCntDiff
+ );
+ error = true;
+ }
+ if (blkTimeDiff < 0) {
+ System.err.println(
+ "Unexpected diff in blocked time. Expecting a positive " +
+ "number, got " + blkTimeDiff
+ );
+ error = true;
+ }
+ if (!lockName.equals(lock.toString())) {
+ System.err.println(
+ "Unexpected blocked monitor name. Expecting " +
+ lock.toString() + ", got " + lockName
+ );
+ error = true;
+ }
+ if (error) {
+ System.err.println("Retrying in 20ms ...");
+ Thread.sleep(20);
+ }
+ } while (error);
+ return ti;
}
}
--- a/jdk/test/java/net/URLPermission/nstest/lookup.sh Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh Tue Jul 01 10:20:56 2014 -0700
@@ -24,9 +24,9 @@
# @test
# @library /lib/testlibrary
+# @build jdk.testlibrary.*
# @compile -XDignore.symbol.file=true SimpleNameService.java
# LookupTest.java SimpleNameServiceDescriptor.java
-# @build jdk.testlibrary.*
# @run shell/timeout=50 lookup.sh
#
@@ -42,8 +42,7 @@
;;
esac
-
-port=`${TESTJAVA}/bin/java -cp ${TESTCLASSES} LookupTest -getport`
+port=`${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} LookupTest -getport`
cat << POLICY > policy
grant {
@@ -60,4 +59,4 @@
${TESTJAVA}/bin/java ${TESTVMOPTS} \
-Djava.security.policy=file:./policy \
-Dsun.net.spi.nameservice.provider.1=simple,sun \
- -cp ${TESTCLASSES}${PS}${TESTSRC} LookupTest -runtest ${port}
+ -cp ${TESTCLASSPATH}${PS}${TESTSRC} LookupTest -runtest ${port}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Collections/CheckedListReplaceAll.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014, 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 8047795
+ * @summary Ensure that replaceAll operator cannot add bad elements
+ * @author Mike Duigou
+ */
+
+import java.util.*;
+import java.util.function.UnaryOperator;
+
+public class CheckedListReplaceAll {
+ public static void main(String[] args) {
+ List unwrapped = Arrays.asList(new Object[]{1, 2, 3});
+ List<Object> wrapped = Collections.checkedList(unwrapped, Integer.class);
+
+ UnaryOperator evil = e -> (((int) e) % 2 != 0) ? e : "evil";
+
+ try {
+ wrapped.replaceAll(evil);
+ System.out.printf("Bwahaha! I have defeated you! %s\n", wrapped);
+ throw new RuntimeException("String added to checked List<Integer>");
+ } catch (ClassCastException thwarted) {
+ thwarted.printStackTrace(System.out);
+ System.out.println("Curses! Foiled again!");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Collections/CheckedMapReplaceAll.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 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 8047795
+ * @summary Ensure that replaceAll operator cannot add bad elements
+ * @author Mike Duigou
+ */
+
+import java.util.*;
+import java.util.function.BiFunction;
+
+public class CheckedMapReplaceAll {
+ public static void main(String[] args) {
+ Map<Integer,Double> unwrapped = new HashMap<>();
+ unwrapped.put(1, 1.0);
+ unwrapped.put(2, 2.0);
+ unwrapped.put(3, 3.0);
+
+ Map<Integer,Double> wrapped = Collections.checkedMap(unwrapped, Integer.class, Double.class);
+
+ BiFunction evil = (k, v) -> (((int)k) % 2 != 0) ? v : "evil";
+
+ try {
+ wrapped.replaceAll(evil);
+ System.out.printf("Bwahaha! I have defeated you! %s\n", wrapped);
+ throw new RuntimeException("String added to checked Map<Integer,Double>");
+ } catch (ClassCastException thwarted) {
+ thwarted.printStackTrace(System.out);
+ System.out.println("Curses! Foiled again!");
+ }
+ }
+}
--- a/jdk/test/java/util/Collections/CheckedQueue.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/java/util/Collections/CheckedQueue.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, 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,55 +23,40 @@
/*
* @test
- * @bug 5020931
+ * @bug 5020931 8048207
* @summary Unit test for Collections.checkedQueue
+ * @run testng CheckedQueue
*/
-import java.lang.reflect.Method;
import java.util.Collections;
-import java.util.Iterator;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
-public class CheckedQueue {
- static int status = 0;
-
- public static void main(String[] args) throws Exception {
- new CheckedQueue();
- }
-
- public CheckedQueue() throws Exception {
- run();
- }
-
- private void run() throws Exception {
- Method[] methods = this.getClass().getDeclaredMethods();
+import org.testng.annotations.Test;
+import static org.testng.Assert.fail;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
- String methodName = method.getName();
- if (methodName.startsWith("test")) {
- try {
- Object obj = method.invoke(this, new Object[0]);
- } catch(Exception e) {
- throw new Exception(this.getClass().getName() + "." +
- methodName + " test failed, test exception "
- + "follows\n" + e.getCause());
- }
- }
- }
- }
+public class CheckedQueue {
/**
* This test adds items to a queue.
*/
- private void test00() {
+ @Test
+ public void testAdd() {
int arrayLength = 10;
- ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength);
+ Queue<String> abq = Collections.checkedQueue(new ArrayBlockingQueue<>(arrayLength), String.class);
for (int i = 0; i < arrayLength; i++) {
- abq.add(new String(Integer.toString(i)));
+ abq.add(Integer.toString(i));
+ }
+
+ try {
+ abq.add("full");
+ } catch (IllegalStateException full) {
+
}
}
@@ -80,23 +65,17 @@
* {@code String}s gets the checked queue, and attempt to add an Integer to
* the checked queue.
*/
- private void test01() throws Exception {
+ @Test(expectedExceptions = ClassCastException.class)
+ public void testAddFail1() {
int arrayLength = 10;
ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(arrayLength + 1);
for (int i = 0; i < arrayLength; i++) {
- abq.add(new String(Integer.toString(i)));
+ abq.add(Integer.toString(i));
}
Queue q = Collections.checkedQueue(abq, String.class);
-
- try {
- q.add(new Integer(0));
- throw new Exception(this.getClass().getName() + "." + "test01 test"
- + " failed, should throw ClassCastException.");
- } catch(ClassCastException cce) {
- // Do nothing.
- }
+ q.add(0);
}
/**
@@ -104,47 +83,40 @@
* {@code String}, gets the checked queue, and attempt to add an Integer to
* the checked queue.
*/
- private void test02() throws Exception {
+ @Test(expectedExceptions = ClassCastException.class)
+ public void testAddFail2() {
ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1);
Queue q = Collections.checkedQueue(abq, String.class);
- try {
- q.add(new Integer(0));
- throw new Exception(this.getClass().getName() + "." + "test02 test"
- + " failed, should throw ClassCastException.");
- } catch(ClassCastException e) {
- // Do nothing.
- }
+ q.add(0);
}
/**
* This test tests the Collections.checkedQueue method call for nulls in
* each and both of the parameters.
*/
- private void test03() throws Exception {
+ @Test
+ public void testArgs() {
ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1);
Queue q;
try {
q = Collections.checkedQueue(null, String.class);
- throw new Exception(this.getClass().getName() + "." + "test03 test"
- + " failed, should throw NullPointerException.");
+ fail( "should throw NullPointerException.");
} catch(NullPointerException npe) {
// Do nothing
}
try {
q = Collections.checkedQueue(abq, null);
- throw new Exception(this.getClass().getName() + "." + "test03 test"
- + " failed, should throw NullPointerException.");
+ fail( "should throw NullPointerException.");
} catch(Exception e) {
// Do nothing
}
try {
q = Collections.checkedQueue(null, null);
- throw new Exception(this.getClass().getName() + "." + "test03 test"
- + " failed, should throw NullPointerException.");
+ fail( "should throw NullPointerException.");
} catch(Exception e) {
// Do nothing
}
@@ -153,38 +125,28 @@
/**
* This test tests the CheckedQueue.offer method.
*/
- private void test04() throws Exception {
+ @Test
+ public void testOffer() {
ArrayBlockingQueue<String> abq = new ArrayBlockingQueue(1);
Queue q = Collections.checkedQueue(abq, String.class);
try {
q.offer(null);
- throw new Exception(this.getClass().getName() + "." + "test04 test"
- + " failed, should throw NullPointerException.");
+ fail("should throw NullPointerException.");
} catch (NullPointerException npe) {
// Do nothing
}
try {
- q.offer(new Integer(0));
- throw new Exception(this.getClass().getName() + "." + "test04 test"
- + " failed, should throw ClassCastException.");
+ q.offer(0);
+ fail("should throw ClassCastException.");
} catch (ClassCastException cce) {
// Do nothing
}
- q.offer(new String("0"));
+ assertTrue(q.offer("0"), "queue should have room");
- try {
- q.offer(new String("1"));
- throw new Exception(this.getClass().getName() + "." + "test04 test"
- + " failed, should throw IllegalStateException.");
- } catch(IllegalStateException ise) {
- // Do nothing
- }
- }
-
- private void test05() {
-
+ // no room at the inn!
+ assertFalse(q.offer("1"), "queue should be full");
}
}
--- a/jdk/test/java/util/Currency/CheckDataVersion.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/java/util/Currency/CheckDataVersion.java Tue Jul 01 10:20:56 2014 -0700
@@ -64,7 +64,8 @@
public Object run() {
try {
String sep = File.separator;
- DataInputStream dis = new DataInputStream(new FileInputStream(System.getProperty("java.home")+sep+"lib"+sep+"currency.data"));
+ DataInputStream dis = new DataInputStream(
+ new BufferedInputStream(getClass().getResourceAsStream("/java/util/currency.data")));
int magic = dis.readInt();
if (magic != 0x43757244) {
throw new RuntimeException("The magic number in the JRE's currency data is incorrect. Expected: 0x43757244, Got: 0x"+magic);
--- a/jdk/test/java/util/Currency/CurrencyTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/java/util/Currency/CurrencyTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, 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,7 +23,7 @@
/*
* @test
* @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531
- * 6488442 7036905
+ * 6488442 7036905 8039317
* @summary Basic tests for Currency class.
*/
--- a/jdk/test/java/util/Currency/ValidateISO4217.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/java/util/Currency/ValidateISO4217.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, 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,6 +23,7 @@
/*
* @test
* @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
+ * 8039317
* @summary Validate ISO 4217 data for Currency class.
*/
--- a/jdk/test/javax/management/MBeanServer/MBeanFallbackTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/javax/management/MBeanServer/MBeanFallbackTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -35,7 +35,7 @@
* @author Jaroslav Bachorik
* @run clean MBeanFallbackTest
* @run build MBeanFallbackTest
- * @run main MBeanFallbackTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true MBeanFallbackTest
*/
public class MBeanFallbackTest {
private static interface PrivateMBean {
@@ -51,7 +51,6 @@
private static int failures = 0;
public static void main(String[] args) throws Exception {
- System.setProperty("jdk.jmx.mbeans.allowNonPublic", "true");
testPrivate(PrivateMBean.class, new Private());
if (failures == 0)
--- a/jdk/test/javax/management/ObjectName/SerialCompatTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/javax/management/ObjectName/SerialCompatTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -28,7 +28,7 @@
* @author Eamonn McManus, Daniel Fuchs
* @run clean SerialCompatTest
* @run build SerialCompatTest
- * @run main/othervm SerialCompatTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true -Djmx.serial.form=1.0 SerialCompatTest
*/
import java.io.*;
@@ -223,8 +223,6 @@
}
public static void main(String[] args) throws Exception {
- System.setProperty("jmx.serial.form", "1.0");
-
/* Check that we really are in jmx.serial.form=1.0 mode.
The property is frozen the first time the ObjectName class
is referenced so checking that it is set to the correct
--- a/jdk/test/javax/management/mxbean/MXBeanFallbackTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/javax/management/mxbean/MXBeanFallbackTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -30,7 +30,7 @@
* @author Jaroslav Bachorik
* @run clean MXBeanFallbackTest
* @run build MXBeanFallbackTest
- * @run main MXBeanFallbackTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true MXBeanFallbackTest
*/
import javax.management.MBeanServer;
@@ -40,7 +40,6 @@
public class MXBeanFallbackTest {
public static void main(String[] args) throws Exception {
- System.setProperty("jdk.jmx.mbeans.allowNonPublic", "true");
testPrivateMXBean("Private", new Private());
if (failures == 0)
--- a/jdk/test/javax/management/proxy/JMXProxyFallbackTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/javax/management/proxy/JMXProxyFallbackTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -36,7 +36,7 @@
* @author Jaroslav Bachorik
* @run clean JMXProxyFallbackTest
* @run build JMXProxyFallbackTest
- * @run main JMXProxyFallbackTest
+ * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true JMXProxyFallbackTest
*/
public class JMXProxyFallbackTest {
private static interface PrivateMBean {
@@ -56,7 +56,6 @@
private static int failures = 0;
public static void main(String[] args) throws Exception {
- System.setProperty("jdk.jmx.mbeans.allowNonPublic", "true");
testPrivate(PrivateMBean.class);
testPrivate(PrivateMXBean.class);
--- a/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java Tue Jul 01 10:20:56 2014 -0700
@@ -38,7 +38,7 @@
public class RMIConnector_NPETest {
public static void main(String argv[]) throws Exception {
RMID rmid = RMID.createRMID();
- rmid.start();
+ rmid.start(Long.MAX_VALUE);
int rmidPort = rmid.getPort();
Exception failureCause = null;
RMIConnector agent = null;
--- a/jdk/test/javax/security/auth/Subject/Generic.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/javax/security/auth/Subject/Generic.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014 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
@@ -28,7 +28,7 @@
*/
import java.security.*;
-import javax.security.auth.*;
+import javax.security.auth.Subject;
public class Generic {
public static void main(String[] args) throws Exception {
--- a/jdk/test/javax/security/auth/Subject/Serial.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/javax/security/auth/Subject/Serial.java Tue Jul 01 10:20:56 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, 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,7 +29,7 @@
* @run main/othervm/policy=Serial.policy Serial
*/
-import javax.security.auth.*;
+import javax.security.auth.Subject;
import java.io.*;
import java.util.*;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/Subject/Subject.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+/*
+ * An implementation of the Subject class that provides basic functionality
+ * for the construction of Subject objects with null Principal elements.
+ * This is a helper class for serialization tests tied to bug 8015081
+ * (see SubjectNullTests.java).
+ */
+package jjjjj.security.auth;
+
+import sun.misc.HexDumpEncoder;
+import javax.management.remote.JMXPrincipal;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.x500.X500Principal;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.lang.Exception;
+import java.lang.RuntimeException;
+import java.security.Principal;
+import java.util.AbstractSet;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Set;
+
+import java.io.FileOutputStream;
+
+public class Subject implements java.io.Serializable {
+
+ private static final long serialVersionUID = -8308522755600156056L;
+
+ Set<Principal> principals;
+ private volatile boolean readOnly = false;
+ private static final int PRINCIPAL_SET = 1;
+
+ public Subject(Set<? extends Principal> principals) {
+ this.principals = Collections.synchronizedSet(new SecureSet<Principal>
+ (this, PRINCIPAL_SET, principals));
+ }
+
+ public Set<Principal> getPrincipals() {
+ return principals;
+ }
+
+ private static class SecureSet<E>
+ extends AbstractSet<E>
+ implements java.io.Serializable {
+
+ private static final long serialVersionUID = 7911754171111800359L;
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("this$0", Subject.class),
+ new ObjectStreamField("elements", LinkedList.class),
+ new ObjectStreamField("which", int.class)
+ };
+
+ Subject subject;
+ LinkedList<E> elements;
+ private int which;
+
+ SecureSet(Subject subject, int which, Set<? extends E> set) {
+ this.subject = subject;
+ this.which = which;
+ this.elements = new LinkedList<E>(set);
+ }
+
+ public Iterator<E> iterator() {
+ return elements.iterator();
+ }
+
+ public int size() {
+ return elements.size();
+ }
+
+ private void writeObject(java.io.ObjectOutputStream oos)
+ throws java.io.IOException {
+
+ ObjectOutputStream.PutField fields = oos.putFields();
+ fields.put("this$0", subject);
+ fields.put("elements", elements);
+ fields.put("which", which);
+ oos.writeFields();
+ }
+ }
+
+ public static byte[] enc(Object obj) {
+ try {
+ HexDumpEncoder hex = new HexDumpEncoder();
+ ByteArrayOutputStream bout;
+ bout = new ByteArrayOutputStream();
+ new ObjectOutputStream(bout).writeObject(obj);
+ byte[] data = bout.toByteArray();
+ for (int i = 0; i < data.length - 5; i++) {
+ if (data[i] == 'j' && data[i + 1] == 'j' && data[i + 2] == 'j'
+ && data[i + 3] == 'j' && data[i + 4] == 'j') {
+ System.arraycopy("javax".getBytes(), 0, data, i, 5);
+ }
+ }
+ return data;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/Subject/SubjectNullTests.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,852 @@
+/*
+ * Copyright (c) 2014, 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 8015081
+ * @compile Subject.java
+ * @compile SubjectNullTests.java
+ * @build SubjectNullTests
+ * @run main SubjectNullTests
+ * @summary javax.security.auth.Subject.toString() throws NPE
+ */
+
+import java.io.File;
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.management.remote.JMXPrincipal;
+import javax.security.auth.Subject;
+import javax.security.auth.x500.X500Principal;
+import javax.security.auth.kerberos.KerberosPrincipal;
+
+public class SubjectNullTests {
+
+ // Value templates for the constructor
+ private static Principal[] princVals = {
+ new X500Principal("CN=Tom Sawyer, ST=Missouri, C=US"),
+ new JMXPrincipal("Huckleberry Finn"),
+ new KerberosPrincipal("mtwain/author@LITERATURE.US")
+ };
+ private static String[] pubVals = {"tsawyer", "hfinn", "mtwain"};
+ private static String[] privVals = {"th3R!v3r", "oNth3R4ft", "5Cl3M3nz"};
+
+ // Templates for collection-based modifiers for the Subject
+ private static Principal[] tmplAddPrincs = {
+ new X500Principal("CN=John Doe, O=Bogus Corp."),
+ new KerberosPrincipal("jdoe/admin@BOGUSCORP.COM")
+ };
+ private static String[] tmplAddPubVals = {"jdoe", "djoe"};
+ private static String[] tmplAddPrvVals = {"b4dpa55w0rd", "pass123"};
+
+ /**
+ * Byte arrays used for deserialization:
+ * These byte arrays contain serialized Subjects and SecureSets,
+ * either with or without nulls. These use
+ * jjjjj.security.auth.Subject, which is a modified Subject
+ * implementation that allows the addition of null elements
+ */
+ private static final byte[] SUBJ_NO_NULL =
+ jjjjj.security.auth.Subject.enc(makeSubjWithNull(false));
+ private static final byte[] SUBJ_WITH_NULL =
+ jjjjj.security.auth.Subject.enc(makeSubjWithNull(true));
+ private static final byte[] PRIN_NO_NULL =
+ jjjjj.security.auth.Subject.enc(makeSecSetWithNull(false));
+ private static final byte[] PRIN_WITH_NULL =
+ jjjjj.security.auth.Subject.enc(makeSecSetWithNull(true));
+
+ /**
+ * Method to allow creation of a subject that can optionally
+ * insert a null reference into the principals Set.
+ */
+ private static jjjjj.security.auth.Subject makeSubjWithNull(
+ boolean nullPrinc) {
+ Set<Principal> setPrinc = new HashSet<>(Arrays.asList(princVals));
+ if (nullPrinc) {
+ setPrinc.add(null);
+ }
+
+ return (new jjjjj.security.auth.Subject(setPrinc));
+ }
+
+ /**
+ * Method to allow creation of a SecureSet that can optionally
+ * insert a null reference.
+ */
+ private static Set<Principal> makeSecSetWithNull(boolean nullPrinc) {
+ Set<Principal> setPrinc = new HashSet<>(Arrays.asList(princVals));
+ if (nullPrinc) {
+ setPrinc.add(null);
+ }
+
+ jjjjj.security.auth.Subject subj =
+ new jjjjj.security.auth.Subject(setPrinc);
+
+ return subj.getPrincipals();
+ }
+
+ /**
+ * Construct a subject, and optionally place a null in any one
+ * of the three Sets used to initialize a Subject's values
+ */
+ private static Subject makeSubj(boolean nullPrinc, boolean nullPub,
+ boolean nullPriv) {
+ Set<Principal> setPrinc = new HashSet<>(Arrays.asList(princVals));
+ Set<String> setPubCreds = new HashSet<>(Arrays.asList(pubVals));
+ Set<String> setPrvCreds = new HashSet<>(Arrays.asList(privVals));
+
+ if (nullPrinc) {
+ setPrinc.add(null);
+ }
+
+ if (nullPub) {
+ setPubCreds.add(null);
+ }
+
+ if (nullPriv) {
+ setPrvCreds.add(null);
+ }
+
+ return (new Subject(false, setPrinc, setPubCreds, setPrvCreds));
+ }
+
+ /**
+ * Provide a simple interface for abstracting collection-on-collection
+ * functions
+ */
+ public interface Function {
+ boolean execCollection(Set<?> subjSet, Collection<?> actorData);
+ }
+
+ public static final Function methAdd = new Function() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean execCollection(Set<?> subjSet, Collection<?> actorData) {
+ return subjSet.addAll((Collection)actorData);
+ }
+ };
+
+ public static final Function methContains = new Function() {
+ @Override
+ public boolean execCollection(Set<?> subjSet, Collection<?> actorData) {
+ return subjSet.containsAll(actorData);
+ }
+ };
+
+ public static final Function methRemove = new Function() {
+ @Override
+ public boolean execCollection(Set<?> subjSet, Collection<?> actorData) {
+ return subjSet.removeAll(actorData);
+ }
+ };
+
+ public static final Function methRetain = new Function() {
+ @Override
+ public boolean execCollection(Set<?> subjSet, Collection<?> actorData) {
+ return subjSet.retainAll(actorData);
+ }
+ };
+
+ /**
+ * Run a test using a specified Collection method upon a Subject's
+ * SecureSet fields. This method expects NullPointerExceptions
+ * to be thrown, and throws RuntimeException when the operation
+ * succeeds
+ */
+ private static void nullTestCollection(Function meth, Set<?> subjSet,
+ Collection<?> actorData) {
+ try {
+ meth.execCollection(subjSet, actorData);
+ throw new RuntimeException("Failed to throw NullPointerException");
+ } catch (NullPointerException npe) {
+ System.out.println("Caught expected NullPointerException [PASS]");
+ }
+ }
+
+ /**
+ * Run a test using a specified Collection method upon a Subject's
+ * SecureSet fields. This method expects the function and arguments
+ * passed in to complete without exception. It returns false
+ * if either an exception occurs or the result of the operation is
+ * false.
+ */
+ private static boolean validTestCollection(Function meth, Set<?> subjSet,
+ Collection<?> actorData) {
+ boolean result = false;
+
+ try {
+ result = meth.execCollection(subjSet, actorData);
+ } catch (Exception exc) {
+ System.out.println("Caught exception " + exc);
+ }
+
+ return result;
+ }
+
+ /**
+ * Deserialize an object from a byte array.
+ *
+ * @param type The {@code Class} that the serialized file is supposed
+ * to contain.
+ * @param serBuffer The byte array containing the serialized object data
+ *
+ * @return An object of the type specified in the {@code type} parameter
+ */
+ private static <T> T deserializeBuffer(Class<T> type, byte[] serBuffer)
+ throws IOException, ClassNotFoundException {
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(serBuffer);
+ ObjectInputStream ois = new ObjectInputStream(bis);
+
+ T newObj = type.cast(ois.readObject());
+ ois.close();
+ bis.close();
+
+ return newObj;
+ }
+
+ private static void testCTOR() {
+ System.out.println("------ constructor ------");
+
+ try {
+ // Case 1: Create a subject with a null principal
+ // Expected result: NullPointerException
+ Subject mtSubj = makeSubj(true, false, false);
+ throw new RuntimeException(
+ "constructor [principal w/ null]: Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println("constructor [principal w/ null]: " +
+ "NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 2: Create a subject with a null public credential element
+ // Expected result: NullPointerException
+ Subject mtSubj = makeSubj(false, true, false);
+ throw new RuntimeException(
+ "constructor [pub cred w/ null]: Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println("constructor [pub cred w/ null]: " +
+ "NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 3: Create a subject with a null private credential element
+ // Expected result: NullPointerException
+ Subject mtSubj = makeSubj(false, false, true);
+ throw new RuntimeException(
+ "constructor [priv cred w/ null]: Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println("constructor [priv cred w/ null]: " +
+ "NullPointerException [PASS]");
+ }
+
+ // Case 4: Create a new subject using the principals, public
+ // and private credentials from another well-formed subject
+ // Expected result: Successful construction
+ Subject srcSubj = makeSubj(false, false, false);
+ Subject mtSubj = new Subject(false, srcSubj.getPrincipals(),
+ srcSubj.getPublicCredentials(),
+ srcSubj.getPrivateCredentials());
+ System.out.println("Construction from another well-formed Subject's " +
+ "principals/creds [PASS]");
+ }
+
+ @SuppressWarnings("unchecked")
+ private static void testDeserialize() throws Exception {
+ System.out.println("------ deserialize -----");
+
+ Subject subj = null;
+ Set<Principal> prin = null;
+
+ // Case 1: positive deserialization test of a Subject
+ // Expected result: well-formed Subject
+ subj = deserializeBuffer(Subject.class, SUBJ_NO_NULL);
+ System.out.println("Positive deserialization test (Subject) passed");
+
+ // Case 2: positive deserialization test of a SecureSet
+ // Expected result: well-formed Set
+ prin = deserializeBuffer(Set.class, PRIN_NO_NULL);
+ System.out.println("Positive deserialization test (SecureSet) passed");
+
+ System.out.println(
+ "* Testing deserialization with null-poisoned objects");
+ // Case 3: deserialization test of a null-poisoned Subject
+ // Expected result: NullPointerException
+ try {
+ subj = deserializeBuffer(Subject.class, SUBJ_WITH_NULL);
+ throw new RuntimeException("Failed to throw NullPointerException");
+ } catch (NullPointerException npe) {
+ System.out.println("Caught expected NullPointerException [PASS]");
+ }
+
+ // Case 4: deserialization test of a null-poisoned SecureSet
+ // Expected result: NullPointerException
+ try {
+ prin = deserializeBuffer(Set.class, PRIN_WITH_NULL);
+ throw new RuntimeException("Failed to throw NullPointerException");
+ } catch (NullPointerException npe) {
+ System.out.println("Caught expected NullPointerException [PASS]");
+ }
+ }
+
+ private static void testAdd() {
+ System.out.println("------ add() ------");
+ // Create a well formed subject
+ Subject mtSubj = makeSubj(false, false, false);
+
+ try {
+ // Case 1: Attempt to add null values to principal
+ // Expected result: NullPointerException
+ mtSubj.getPrincipals().add(null);
+ throw new RuntimeException(
+ "PRINCIPAL add(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PRINCIPAL add(null): NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 2: Attempt to add null into the public creds
+ // Expected result: NullPointerException
+ mtSubj.getPublicCredentials().add(null);
+ throw new RuntimeException(
+ "PUB CRED add(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PUB CRED add(null): NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 3: Attempt to add null into the private creds
+ // Expected result: NullPointerException
+ mtSubj.getPrivateCredentials().add(null);
+ throw new RuntimeException(
+ "PRIV CRED add(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PRIV CRED add(null): NullPointerException [PASS]");
+ }
+ }
+
+ private static void testRemove() {
+ System.out.println("------ remove() ------");
+ // Create a well formed subject
+ Subject mtSubj = makeSubj(false, false, false);
+
+ try {
+ // Case 1: Attempt to remove null values from principal
+ // Expected result: NullPointerException
+ mtSubj.getPrincipals().remove(null);
+ throw new RuntimeException(
+ "PRINCIPAL remove(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PRINCIPAL remove(null): NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 2: Attempt to remove null from the public creds
+ // Expected result: NullPointerException
+ mtSubj.getPublicCredentials().remove(null);
+ throw new RuntimeException(
+ "PUB CRED remove(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PUB CRED remove(null): NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 3: Attempt to remove null from the private creds
+ // Expected result: NullPointerException
+ mtSubj.getPrivateCredentials().remove(null);
+ throw new RuntimeException(
+ "PRIV CRED remove(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PRIV CRED remove(null): NullPointerException [PASS]");
+ }
+ }
+
+ private static void testContains() {
+ System.out.println("------ contains() ------");
+ // Create a well formed subject
+ Subject mtSubj = makeSubj(false, false, false);
+
+ try {
+ // Case 1: Attempt to check for null values in principals
+ // Expected result: NullPointerException
+ mtSubj.getPrincipals().contains(null);
+ throw new RuntimeException(
+ "PRINCIPAL contains(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PRINCIPAL contains(null): NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 2: Attempt to check for null in public creds
+ // Expected result: NullPointerException
+ mtSubj.getPublicCredentials().contains(null);
+ throw new RuntimeException(
+ "PUB CRED contains(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PUB CRED contains(null): NullPointerException [PASS]");
+ }
+
+ try {
+ // Case 3: Attempt to check for null in private creds
+ // Expected result: NullPointerException
+ mtSubj.getPrivateCredentials().contains(null);
+ throw new RuntimeException(
+ "PRIV CRED contains(null): Failed to throw NPE");
+ } catch (NullPointerException npe) {
+ System.out.println(
+ "PRIV CRED contains(null): NullPointerException [PASS]");
+ }
+ }
+
+ private static void testAddAll() {
+ // Create a well formed subject and additional collections
+ Subject mtSubj = makeSubj(false, false, false);
+ Set<Principal> morePrincs = new HashSet<>(Arrays.asList(tmplAddPrincs));
+ Set<Object> morePubVals = new HashSet<>(Arrays.asList(tmplAddPubVals));
+ Set<Object> morePrvVals = new HashSet<>(Arrays.asList(tmplAddPrvVals));
+
+ // Run one success test for each Subject family to verify the
+ // overloaded method works as intended.
+ Set<Principal> setPrin = mtSubj.getPrincipals();
+ Set<Object> setPubCreds = mtSubj.getPublicCredentials();
+ Set<Object> setPrvCreds = mtSubj.getPrivateCredentials();
+ int prinOrigSize = setPrin.size();
+ int pubOrigSize = setPubCreds.size();
+ int prvOrigSize = setPrvCreds.size();
+
+ System.out.println("------ addAll() -----");
+
+ // Add the new members, then check the resulting size of the
+ // Subject attributes to verify they've increased by the proper
+ // amounts.
+ if ((validTestCollection(methAdd, setPrin, morePrincs) != true) ||
+ (setPrin.size() != prinOrigSize + morePrincs.size()))
+ {
+ throw new RuntimeException("Failed addAll() on principals");
+ }
+ if ((validTestCollection(methAdd, setPubCreds,
+ morePubVals) != true) ||
+ (setPubCreds.size() != pubOrigSize + morePubVals.size()))
+ {
+ throw new RuntimeException("Failed addAll() on public creds");
+ }
+ if ((validTestCollection(methAdd, setPrvCreds,
+ morePrvVals) != true) ||
+ (setPrvCreds.size() != prvOrigSize + morePrvVals.size()))
+ {
+ throw new RuntimeException("Failed addAll() on private creds");
+ }
+ System.out.println("Positive addAll() test passed");
+
+ // Now add null elements into each container, then retest
+ morePrincs.add(null);
+ morePubVals.add(null);
+ morePrvVals.add(null);
+
+ System.out.println("* Testing addAll w/ null values on Principals");
+ nullTestCollection(methAdd, mtSubj.getPrincipals(), null);
+ nullTestCollection(methAdd, mtSubj.getPrincipals(), morePrincs);
+
+ System.out.println("* Testing addAll w/ null values on Public Creds");
+ nullTestCollection(methAdd, mtSubj.getPublicCredentials(), null);
+ nullTestCollection(methAdd, mtSubj.getPublicCredentials(),
+ morePubVals);
+
+ System.out.println("* Testing addAll w/ null values on Private Creds");
+ nullTestCollection(methAdd, mtSubj.getPrivateCredentials(), null);
+ nullTestCollection(methAdd, mtSubj.getPrivateCredentials(),
+ morePrvVals);
+ }
+
+ private static void testRemoveAll() {
+ // Create a well formed subject and additional collections
+ Subject mtSubj = makeSubj(false, false, false);
+ Set<Principal> remPrincs = new HashSet<>();
+ Set<Object> remPubVals = new HashSet<>();
+ Set<Object> remPrvVals = new HashSet<>();
+
+ remPrincs.add(new KerberosPrincipal("mtwain/author@LITERATURE.US"));
+ remPubVals.add("mtwain");
+ remPrvVals.add("5Cl3M3nz");
+
+ // Run one success test for each Subject family to verify the
+ // overloaded method works as intended.
+ Set<Principal> setPrin = mtSubj.getPrincipals();
+ Set<Object> setPubCreds = mtSubj.getPublicCredentials();
+ Set<Object> setPrvCreds = mtSubj.getPrivateCredentials();
+ int prinOrigSize = setPrin.size();
+ int pubOrigSize = setPubCreds.size();
+ int prvOrigSize = setPrvCreds.size();
+
+ System.out.println("------ removeAll() -----");
+
+ // Remove the specified members, then check the resulting size of the
+ // Subject attributes to verify they've decreased by the proper
+ // amounts.
+ if ((validTestCollection(methRemove, setPrin, remPrincs) != true) ||
+ (setPrin.size() != prinOrigSize - remPrincs.size()))
+ {
+ throw new RuntimeException("Failed removeAll() on principals");
+ }
+ if ((validTestCollection(methRemove, setPubCreds,
+ remPubVals) != true) ||
+ (setPubCreds.size() != pubOrigSize - remPubVals.size()))
+ {
+ throw new RuntimeException("Failed removeAll() on public creds");
+ }
+ if ((validTestCollection(methRemove, setPrvCreds,
+ remPrvVals) != true) ||
+ (setPrvCreds.size() != prvOrigSize - remPrvVals.size()))
+ {
+ throw new RuntimeException("Failed removeAll() on private creds");
+ }
+ System.out.println("Positive removeAll() test passed");
+
+ // Now add null elements into each container, then retest
+ remPrincs.add(null);
+ remPubVals.add(null);
+ remPrvVals.add(null);
+
+ System.out.println("* Testing removeAll w/ null values on Principals");
+ nullTestCollection(methRemove, mtSubj.getPrincipals(), null);
+ nullTestCollection(methRemove, mtSubj.getPrincipals(), remPrincs);
+
+ System.out.println(
+ "* Testing removeAll w/ null values on Public Creds");
+ nullTestCollection(methRemove, mtSubj.getPublicCredentials(), null);
+ nullTestCollection(methRemove, mtSubj.getPublicCredentials(),
+ remPubVals);
+
+ System.out.println(
+ "* Testing removeAll w/ null values on Private Creds");
+ nullTestCollection(methRemove, mtSubj.getPrivateCredentials(), null);
+ nullTestCollection(methRemove, mtSubj.getPrivateCredentials(),
+ remPrvVals);
+ }
+
+ private static void testContainsAll() {
+ // Create a well formed subject and additional collections
+ Subject mtSubj = makeSubj(false, false, false);
+ Set<Principal> testPrincs = new HashSet<>(Arrays.asList(princVals));
+ Set<Object> testPubVals = new HashSet<>(Arrays.asList(pubVals));
+ Set<Object> testPrvVals = new HashSet<>(Arrays.asList(privVals));
+
+ System.out.println("------ containsAll() -----");
+
+ // Run one success test for each Subject family to verify the
+ // overloaded method works as intended.
+ if ((validTestCollection(methContains, mtSubj.getPrincipals(),
+ testPrincs) == false) &&
+ (validTestCollection(methContains, mtSubj.getPublicCredentials(),
+ testPubVals) == false) &&
+ (validTestCollection(methContains,
+ mtSubj.getPrivateCredentials(), testPrvVals) == false)) {
+ throw new RuntimeException("Valid containsAll() check failed");
+ }
+ System.out.println("Positive containsAll() test passed");
+
+ // Now let's add a null into each collection and watch the fireworks.
+ testPrincs.add(null);
+ testPubVals.add(null);
+ testPrvVals.add(null);
+
+ System.out.println(
+ "* Testing containsAll w/ null values on Principals");
+ nullTestCollection(methContains, mtSubj.getPrincipals(), null);
+ nullTestCollection(methContains, mtSubj.getPrincipals(), testPrincs);
+
+ System.out.println(
+ "* Testing containsAll w/ null values on Public Creds");
+ nullTestCollection(methContains, mtSubj.getPublicCredentials(),
+ null);
+ nullTestCollection(methContains, mtSubj.getPublicCredentials(),
+ testPubVals);
+
+ System.out.println(
+ "* Testing containsAll w/ null values on Private Creds");
+ nullTestCollection(methContains, mtSubj.getPrivateCredentials(),
+ null);
+ nullTestCollection(methContains, mtSubj.getPrivateCredentials(),
+ testPrvVals);
+ }
+
+ private static void testRetainAll() {
+ // Create a well formed subject and additional collections
+ Subject mtSubj = makeSubj(false, false, false);
+ Set<Principal> remPrincs = new HashSet<>(Arrays.asList(tmplAddPrincs));
+ Set<Object> remPubVals = new HashSet<>(Arrays.asList(tmplAddPubVals));
+ Set<Object> remPrvVals = new HashSet<>(Arrays.asList(tmplAddPrvVals));
+
+ // Add in values that exist within the Subject
+ remPrincs.add(princVals[2]);
+ remPubVals.add(pubVals[2]);
+ remPrvVals.add(privVals[2]);
+
+ // Run one success test for each Subject family to verify the
+ // overloaded method works as intended.
+ Set<Principal> setPrin = mtSubj.getPrincipals();
+ Set<Object> setPubCreds = mtSubj.getPublicCredentials();
+ Set<Object> setPrvCreds = mtSubj.getPrivateCredentials();
+ int prinOrigSize = setPrin.size();
+ int pubOrigSize = setPubCreds.size();
+ int prvOrigSize = setPrvCreds.size();
+
+ System.out.println("------ retainAll() -----");
+
+ // Retain the specified members (those that exist in the Subject)
+ // and validate the results.
+ if (validTestCollection(methRetain, setPrin, remPrincs) == false ||
+ setPrin.size() != 1 || setPrin.contains(princVals[2]) == false)
+ {
+ throw new RuntimeException("Failed retainAll() on principals");
+ }
+
+ if (validTestCollection(methRetain, setPubCreds,
+ remPubVals) == false ||
+ setPubCreds.size() != 1 ||
+ setPubCreds.contains(pubVals[2]) == false)
+ {
+ throw new RuntimeException("Failed retainAll() on public creds");
+ }
+ if (validTestCollection(methRetain, setPrvCreds,
+ remPrvVals) == false ||
+ setPrvCreds.size() != 1 ||
+ setPrvCreds.contains(privVals[2]) == false)
+ {
+ throw new RuntimeException("Failed retainAll() on private creds");
+ }
+ System.out.println("Positive retainAll() test passed");
+
+ // Now add null elements into each container, then retest
+ remPrincs.add(null);
+ remPubVals.add(null);
+ remPrvVals.add(null);
+
+ System.out.println("* Testing retainAll w/ null values on Principals");
+ nullTestCollection(methRetain, mtSubj.getPrincipals(), null);
+ nullTestCollection(methRetain, mtSubj.getPrincipals(), remPrincs);
+
+ System.out.println(
+ "* Testing retainAll w/ null values on Public Creds");
+ nullTestCollection(methRetain, mtSubj.getPublicCredentials(), null);
+ nullTestCollection(methRetain, mtSubj.getPublicCredentials(),
+ remPubVals);
+
+ System.out.println(
+ "* Testing retainAll w/ null values on Private Creds");
+ nullTestCollection(methRetain, mtSubj.getPrivateCredentials(), null);
+ nullTestCollection(methRetain, mtSubj.getPrivateCredentials(),
+ remPrvVals);
+ }
+
+ private static void testIsEmpty() {
+ Subject populatedSubj = makeSubj(false, false, false);
+ Subject emptySubj = new Subject();
+
+ System.out.println("------ isEmpty() -----");
+
+ if (populatedSubj.getPrincipals().isEmpty()) {
+ throw new RuntimeException(
+ "Populated Subject Principals incorrectly returned empty");
+ }
+ if (emptySubj.getPrincipals().isEmpty() == false) {
+ throw new RuntimeException(
+ "Empty Subject Principals incorrectly returned non-empty");
+ }
+ System.out.println("isEmpty() test passed");
+ }
+
+ private static void testSecureSetEquals() {
+ System.out.println("------ SecureSet.equals() -----");
+
+ Subject subj = makeSubj(false, false, false);
+ Subject subjComp = makeSubj(false, false, false);
+
+ // Case 1: null comparison [expect false]
+ if (subj.getPublicCredentials().equals(null) != false) {
+ throw new RuntimeException(
+ "equals(null) incorrectly returned true");
+ }
+
+ // Case 2: Self-comparison [expect true]
+ Set<Principal> princs = subj.getPrincipals();
+ princs.equals(subj.getPrincipals());
+
+ // Case 3: Comparison with non-Set type [expect false]
+ List<Principal> listPrinc = new LinkedList<>(Arrays.asList(princVals));
+ if (subj.getPublicCredentials().equals(listPrinc) != false) {
+ throw new RuntimeException(
+ "equals([Non-Set]) incorrectly returned true");
+ }
+
+ // Case 4: SecureSets of differing sizes [expect false]
+ Subject subj1princ = new Subject();
+ Subject subj2princ = new Subject();
+ subj1princ.getPrincipals().add(
+ new X500Principal("CN=Tom Sawyer, ST=Missouri, C=US"));
+ subj1princ.getPrincipals().add(
+ new X500Principal("CN=John Doe, O=Bogus Corp."));
+ subj2princ.getPrincipals().add(
+ new X500Principal("CN=Tom Sawyer, ST=Missouri, C=US"));
+ if (subj1princ.getPrincipals().equals(
+ subj2princ.getPrincipals()) != false) {
+ throw new RuntimeException(
+ "equals([differing sizes]) incorrectly returned true");
+ }
+
+ // Case 5: Content equality test [expect true]
+ Set<Principal> equalSet = new HashSet<>(Arrays.asList(princVals));
+ if (subj.getPrincipals().equals(equalSet) != true) {
+ throw new RuntimeException(
+ "equals([equivalent set]) incorrectly returned false");
+ }
+
+ // Case 5: Content inequality test [expect false]
+ // Note: to not fall into the size inequality check the two
+ // sets need to have the same number of elements.
+ Set<Principal> inequalSet =
+ new HashSet<Principal>(Arrays.asList(tmplAddPrincs));
+ inequalSet.add(new JMXPrincipal("Samuel Clemens"));
+
+ if (subj.getPrincipals().equals(inequalSet) != false) {
+ throw new RuntimeException(
+ "equals([equivalent set]) incorrectly returned false");
+ }
+ System.out.println("SecureSet.equals() tests passed");
+ }
+
+ private static void testSecureSetHashCode() {
+ System.out.println("------ SecureSet.hashCode() -----");
+
+ Subject subj = makeSubj(false, false, false);
+
+ // Make sure two other Set types that we know are equal per
+ // SecureSet.equals() and verify their hashCodes are also the same
+ Set<Principal> equalHashSet = new HashSet<>(Arrays.asList(princVals));
+
+ if (subj.getPrincipals().hashCode() != equalHashSet.hashCode()) {
+ throw new RuntimeException(
+ "SecureSet and HashSet hashCodes() differ");
+ }
+ System.out.println("SecureSet.hashCode() tests passed");
+ }
+
+ private static void testToArray() {
+ System.out.println("------ toArray() -----");
+
+ Subject subj = makeSubj(false, false, false);
+
+ // Case 1: no-parameter toArray with equality comparison
+ // Expected result: true
+ List<Object> alSubj = Arrays.asList(subj.getPrincipals().toArray());
+ List<Principal> alPrincs = Arrays.asList(princVals);
+
+ if (alSubj.size() != alPrincs.size() ||
+ alSubj.containsAll(alPrincs) != true) {
+ throw new RuntimeException(
+ "Unexpected inequality on returned toArray()");
+ }
+
+ // Case 2: generic-type toArray where passed array is of sufficient
+ // size.
+ // Expected result: returned Array is reference-equal to input param
+ // and content equal to data used to construct the originating Subject.
+ Principal[] pBlock = new Principal[3];
+ Principal[] pBlockRef = subj.getPrincipals().toArray(pBlock);
+ alSubj = Arrays.asList((Object[])pBlockRef);
+
+ if (pBlockRef != pBlock) {
+ throw new RuntimeException(
+ "Unexpected reference-inequality on returned toArray(T[])");
+ } else if (alSubj.size() != alPrincs.size() ||
+ alSubj.containsAll(alPrincs) != true) {
+ throw new RuntimeException(
+ "Unexpected content-inequality on returned toArray(T[])");
+ }
+
+ // Case 3: generic-type toArray where passed array is of
+ // insufficient size.
+ // Expected result: returned Array is not reference-equal to
+ // input param but is content equal to data used to construct the
+ // originating Subject.
+ pBlock = new Principal[1];
+ pBlockRef = subj.getPrincipals().toArray(pBlock);
+ alSubj = Arrays.asList((Object[])pBlockRef);
+
+ if (pBlockRef == pBlock) {
+ throw new RuntimeException(
+ "Unexpected reference-equality on returned toArray(T[])");
+ } else if (alSubj.size() != alPrincs.size() ||
+ alSubj.containsAll(alPrincs) != true) {
+ throw new RuntimeException(
+ "Unexpected content-inequality on returned toArray(T[])");
+ }
+ System.out.println("toArray() tests passed");
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ testCTOR();
+
+ testDeserialize();
+
+ testAdd();
+
+ testRemove();
+
+ testContains();
+
+ testAddAll();
+
+ testRemoveAll();
+
+ testContainsAll();
+
+ testRetainAll();
+
+ testIsEmpty();
+
+ testSecureSetEquals();
+
+ testSecureSetHashCode();
+
+ testToArray();
+ }
+}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessThread.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessThread.java Tue Jul 01 10:20:56 2014 -0700
@@ -23,11 +23,11 @@
package jdk.testlibrary;
-import static jdk.testlibrary.Asserts.assertNotEquals;
-import static jdk.testlibrary.Asserts.assertTrue;
+import java.io.PrintWriter;
-import java.util.List;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Predicate;
/**
* The helper class for starting and stopping {@link Process} in a separate thread.
@@ -54,6 +54,29 @@
super(new ProcessRunnable(pb), threadName);
}
+
+ /**
+ * Creates a new {@code ProcessThread} object.
+ *
+ * @param threadName The name of thread
+ * @param waitfor A predicate to determine whether the target process has been initialized
+ * @param cmd The string array of program and its arguments to pass to {@link ProcessBuilder}
+ */
+ public ProcessThread(String threadName, Predicate<String> waitfor, String... cmd) {
+ super(new ProcessRunnable(new ProcessBuilder(cmd), threadName, waitfor), threadName);
+ }
+
+ /**
+ * Creates a new {@code ProcessThread} object.
+ *
+ * @param threadName The name of thread.
+ * @param waitfor A predicate to determine whether the target process has been initialized
+ * @param pb The ProcessBuilder to execute.
+ */
+ public ProcessThread(String threadName, Predicate<String> waitfor, ProcessBuilder pb) {
+ super(new ProcessRunnable(pb, threadName, waitfor), threadName);
+ }
+
/**
* Stops {@link Process} started by {@code ProcessRunnable}.
*
@@ -71,6 +94,18 @@
}
/**
+ * Returns the PID associated with this process thread
+ * @return The PID associated with this process thread
+ */
+ public long getPid() throws InterruptedException {
+ return ((ProcessRunnable)getRunnable()).getPid();
+ }
+
+ public void sendMessage(String message) throws InterruptedException {
+ ((ProcessRunnable)getRunnable()).sendMessage(message);
+ }
+
+ /**
* {@link Runnable} interface for starting and stopping {@link Process}.
*/
static class ProcessRunnable extends XRun {
@@ -79,6 +114,8 @@
private final CountDownLatch latch;
private volatile Process process;
private volatile OutputAnalyzer output;
+ private final Predicate<String> waitfor;
+ private final String name;
/**
* Creates a new {@code ProcessRunnable} object.
@@ -86,9 +123,21 @@
* @param pb The {@link ProcessBuilder} to run.
*/
public ProcessRunnable(ProcessBuilder pb) {
- super();
+ this(pb, "", null);
+ }
+
+ /**
+ * Creates a new {@code ProcessRunnable} object.
+ *
+ * @param pb The {@link ProcessBuilder} to run.
+ * @param name An optional process name; may be null
+ * @param waitfor A predicate to determine whether the target process has been initialized; may be null
+ */
+ public ProcessRunnable(ProcessBuilder pb, String name, Predicate<String> waitfor) {
this.processBuilder = pb;
this.latch = new CountDownLatch(1);
+ this.name = name;
+ this.waitfor = waitfor;
}
/**
@@ -99,7 +148,9 @@
*/
@Override
public void xrun() throws Throwable {
- this.process = processBuilder.start();
+ this.process = ProcessTools.startProcess(
+ name, processBuilder, waitfor, -1, TimeUnit.SECONDS
+ );
// Release when process is started
latch.countDown();
@@ -138,6 +189,26 @@
public OutputAnalyzer getOutput() {
return output;
}
+
+ /**
+ * Returns the PID associated with this process runnable
+ * @return The PID associated with this process runnable
+ */
+ public long getPid() throws InterruptedException {
+ return getProcess().getPid();
+ }
+
+ public void sendMessage(String message) throws InterruptedException {
+ try (PrintWriter pw = new PrintWriter(this.getProcess().getOutputStream())) {
+ pw.println(message);
+ pw.flush();
+ }
+ }
+
+ private Process getProcess() throws InterruptedException {
+ latch.await();
+ return process;
+ }
}
}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Tue Jul 01 10:20:56 2014 -0700
@@ -41,6 +41,8 @@
import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
import java.util.function.Consumer;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
import sun.management.VMManagement;
@@ -135,6 +137,7 @@
long timeout,
TimeUnit unit)
throws IOException, InterruptedException, TimeoutException {
+ System.out.println("["+name+"]:" + processBuilder.command().stream().collect(Collectors.joining(" ")));
Process p = processBuilder.start();
StreamPumper stdout = new StreamPumper(p.getInputStream());
StreamPumper stderr = new StreamPumper(p.getErrorStream());
--- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -122,7 +122,6 @@
);
final AtomicReference<String> port = new AtomicReference<>();
- final AtomicReference<String> pid = new AtomicReference<>();
serverPrc = ProcessTools.startProcess(
"Launcher",
@@ -130,12 +129,10 @@
(String line) -> {
if (line.startsWith("port:")) {
port.set(line.split("\\:")[1]);
- } else if (line.startsWith("pid:")) {
- pid.set(line.split("\\:")[1]);
- } else if (line.startsWith("waiting")) {
+ } else if (line.startsWith("waiting")) {
return true;
- }
- return false;
+ }
+ return false;
},
5,
TimeUnit.SECONDS
@@ -143,7 +140,7 @@
System.out.println("Attaching test manager:");
System.out.println("=========================");
- System.out.println(" PID : " + pid.get());
+ System.out.println(" PID : " + serverPrc.getPid());
System.out.println(" shutdown port : " + port.get());
ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
@@ -156,7 +153,7 @@
File.separator +
"tools.jar",
"TestManager",
- pid.get(),
+ String.valueOf(serverPrc.getPid()),
port.get(),
"true"
);
--- a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -109,7 +109,6 @@
Process serverPrc = null, clientPrc = null;
try {
final AtomicReference<String> port = new AtomicReference<>();
- final AtomicReference<String> pid = new AtomicReference<>();
serverPrc = ProcessTools.startProcess(
"TestApplication(" + testId + ")",
@@ -117,12 +116,10 @@
(String line) -> {
if (line.startsWith("port:")) {
port.set(line.split("\\:")[1]);
- } else if (line.startsWith("pid:")) {
- pid.set(line.split("\\:")[1]);
- } else if (line.startsWith("waiting")) {
- return true;
- }
- return false;
+ } else if (line.startsWith("waiting")) {
+ return true;
+ }
+ return false;
},
5,
TimeUnit.SECONDS
@@ -130,7 +127,7 @@
System.out.println("Attaching test manager:");
System.out.println("=========================");
- System.out.println(" PID : " + pid.get());
+ System.out.println(" PID : " + serverPrc.getPid());
System.out.println(" shutdown port : " + port.get());
ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
@@ -143,7 +140,7 @@
File.separator +
"tools.jar",
"TestManager",
- pid.get(),
+ String.valueOf(serverPrc.getPid()),
port.get(),
"true"
);
--- a/jdk/test/sun/management/jmxremote/bootstrap/TestApplication.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/management/jmxremote/bootstrap/TestApplication.java Tue Jul 01 10:20:56 2014 -0700
@@ -26,16 +26,13 @@
*
* A test "application" used by unit tests -
* LocalManagementTest.java, CustomLauncherTest.java.
- * This application binds to some random port, prints its pid and
- * the port number to standard output, waits for somebody to connect,
- * and then shuts down.
+ * This application binds to some random port, prints the port number
+ * to standard output, waits for somebody to connect, and then shuts down.
*/
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
-import jdk.testlibrary.ProcessTools;
-
public class TestApplication {
public static void main(String[] args) throws IOException {
// Some tests require the application to exit immediately
@@ -47,16 +44,8 @@
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
- int pid = -1;
- try {
- pid = ProcessTools.getProcessId();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
// signal test that we are started - do not remove these lines!!
System.out.println("port:" + port);
- System.out.println("pid:" + pid);
System.out.println("waiting for the manager ...");
System.out.flush();
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java Tue Jul 01 10:20:56 2014 -0700
@@ -31,7 +31,6 @@
}
public static void main(String args[]) throws Exception {
- System.out.println("pid:" + ProcessTools.getProcessId());
System.out.println("main enter");
System.out.flush();
doSomething();
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -38,6 +38,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import javax.management.*;
@@ -52,7 +53,7 @@
* @bug 7110104
* @library /lib/testlibrary
* @build jdk.testlibrary.* JMXStartStopTest JMXStartStopDoSomething
- * @run main/othervm JMXStartStopTest
+ * @run main/othervm/timeout=600 JMXStartStopTest
* @summary Makes sure that enabling/disabling the management agent through
* JCMD achieves the desired results
*/
@@ -132,13 +133,13 @@
}
- private static void testConnectLocal(int pid)
+ private static void testConnectLocal(long pid)
throws Exception {
String jmxUrlStr = null;
try {
- jmxUrlStr = sun.management.ConnectorAddressLink.importFrom(pid);
+ jmxUrlStr = sun.management.ConnectorAddressLink.importFrom((int)pid);
dbg_print("Local Service URL: " +jmxUrlStr);
if ( jmxUrlStr == null ) {
throw new Exception("No Service URL. Local agent not started?");
@@ -290,11 +291,14 @@
public static void main(String args[]) throws Exception {
for (Method m : JMXStartStopTest.class.getDeclaredMethods()) {
if (m.getName().startsWith("test_")) {
+ long t1 = System.currentTimeMillis();
try {
m.invoke(null);
- System.out.println("=== PASSED\n");
+ System.out.println("=== PASSED");
} catch (Throwable e) {
failures.add(new Failure(e, m.getName() + " failed"));
+ } finally {
+ System.out.println("(took " + (System.currentTimeMillis() - t1) + "ms)\n");
}
}
}
@@ -313,7 +317,7 @@
private final ProcessBuilder pb;
private final String name;
private final AtomicBoolean started = new AtomicBoolean(false);
- private volatile int pid = -1;
+ private volatile long pid = -1;
public Something(ProcessBuilder pb, String name) {
this.pb = pb;
@@ -326,15 +330,11 @@
p = ProcessTools.startProcess(
"JMXStartStopDoSomething",
pb,
- (line) -> {
- if (line.toLowerCase().startsWith("pid:")) {
- pid = Integer.parseInt(line.split("\\:")[1]);
- }
- return line.equals("main enter");
- },
+ (line) -> line.equals("main enter"),
5,
TimeUnit.SECONDS
);
+ pid = p.getPid();
} catch (TimeoutException e) {
p.destroy();
p.waitFor();
@@ -343,7 +343,7 @@
}
}
- public int getPid() {
+ public long getPid() {
return pid;
}
@@ -585,11 +585,11 @@
testConnect(pa.getPort1(), pa.getPort2());
- final boolean[] checks = new boolean[3];
+ final AtomicInteger checks = new AtomicInteger();
jcmd(
line -> {
if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
- checks[0] = true;
+ checks.getAndUpdate((op) -> op | 1);
}
},
CMD_START,
@@ -600,7 +600,7 @@
jcmd(
line -> {
if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
- checks[1] = true;
+ checks.getAndUpdate((op) -> op | 2);
}
},
CMD_START,
@@ -611,12 +611,14 @@
jcmd(CMD_STOP);
jcmd(CMD_STOP);
+ int busyPort;
try (ServerSocket ss = new ServerSocket(0))
{
+ busyPort = ss.getLocalPort();
jcmd(
line -> {
- if (line.contains("Port already in use: " + ss.getLocalPort())) {
- checks[2] = true;
+ if (line.contains("Port already in use: " + busyPort)) {
+ checks.getAndUpdate((op) -> op | 4);
}
},
CMD_START,
@@ -624,19 +626,18 @@
"jmxremote.rmi.port=" + pa.getPort2(),
"jmxremote.authenticate=false",
"jmxremote.ssl=false");
-
- if (!checks[0]) {
- throw new Exception("Starting agent on port " + pa.getPort1() + " should " +
- "report an invalid agent state");
- }
- if (!checks[1]) {
- throw new Exception("Starting agent on poprt " + pa.getPort2() + " should " +
- "report an invalid agent state");
- }
- if (!checks[2]) {
- throw new Exception("Starting agent on port " + ss.getLocalPort() + " should " +
- "report port in use");
- }
+ }
+ if ((checks.get() & 1) == 0) {
+ throw new Exception("Starting agent on port " + pa.getPort1() + " should " +
+ "report an invalid agent state");
+ }
+ if ((checks.get() & 2) == 0) {
+ throw new Exception("Starting agent on poprt " + pa.getPort2() + " should " +
+ "report an invalid agent state");
+ }
+ if ((checks.get() & 4) == 0) {
+ throw new Exception("Starting agent on port " + busyPort + " should " +
+ "report port in use");
}
} finally {
s.stop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/ccache/EmptyRealmCC.java Tue Jul 01 10:20:56 2014 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2014, 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 8048073
+ * @summary Cannot read ccache entry with a realm-less service name
+ * @compile -XDignore.symbol.file EmptyRealmCC.java
+ * @run main EmptyRealmCC
+ */
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import sun.security.krb5.internal.ccache.CredentialsCache;
+
+public class EmptyRealmCC {
+ public static void main(String[] args) throws Exception {
+ byte[] ccache = TimeInCCache.ccache;
+
+ // The service name starts at 0x52:
+ //
+ // 0050: 00 00 00 02 00 00 00 0A 4D 41 58 49 2E 4C
+ // ----------- -----------
+ // 0060: 4F 43 41 4C 00 00 00 06 6B 72 62 74 67 74 00 00
+ // ----------- -----
+ // 0070: 00 0A 4D 41 58 49 2E 4C 4F 43 41 4C
+ // -----
+ //
+ // which contains 2 (the length of names), a 10-byte realm, a 6-byte
+ // name[0], and a 10-byte name[1].
+
+ // We will empty the realm, and pack the realm string to another
+ // name (6-byte ".LOCAL"). Finally "krbtgt/MAXI.LOCAL@MAXI.LOCAL"
+ // becomes ".LOCAL/krbtgt/MAXI.LOCAL@".
+
+ // length of names is now 3
+ ccache[0x55] = 3;
+ // The empty realm
+ System.arraycopy(new byte[4], 0, ccache, 0x56, 4);
+ // Length of inserted name is 6
+ System.arraycopy(new byte[]{0,0,0,6}, 0, ccache, 0x5A, 4);
+
+ Files.write(Paths.get("tmpcc"), TimeInCCache.ccache);
+ if (CredentialsCache.getInstance("tmpcc").getCredsList() != null) {
+ throw new Exception("Nothing should be there");
+ }
+ }
+}
--- a/jdk/test/sun/security/krb5/ccache/TimeInCCache.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/security/krb5/ccache/TimeInCCache.java Tue Jul 01 10:20:56 2014 -0700
@@ -28,16 +28,14 @@
*/
import java.io.ByteArrayInputStream;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import sun.security.krb5.internal.ccache.CCacheInputStream;
import sun.security.krb5.internal.ccache.Credentials;
public class TimeInCCache {
- // Attention: this field is also used by CorruptedCC.java test
+ // Attention: this field is also used by 2 other tests:
+ // CorruptedCC.java and EmptyRealmCC.java
public static byte[] ccache;
static {
--- a/jdk/test/sun/tools/jstat/JStatInterval.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/tools/jstat/JStatInterval.java Tue Jul 01 10:20:56 2014 -0700
@@ -42,14 +42,12 @@
import java.util.concurrent.atomic.AtomicInteger;
public class JStatInterval {
- private static final String PID = "PID";
private static final String READY = "READY";
private static final String ERROR = "!ERROR";
public static class Application {
public static void main(String[] args) {
try {
- System.out.println(PID + ":" + ProcessTools.getProcessId());
System.out.println(READY);
System.out.flush();
int exitCode = System.in.read();
@@ -69,15 +67,12 @@
"-XX:+UsePerfData",
Application.class.getName()
);
- AtomicInteger pid = new AtomicInteger(-1);
AtomicBoolean error = new AtomicBoolean(false);
Process app = ProcessTools.startProcess(
"application",
pb,
line -> {
- if (line.startsWith(PID)) {
- pid.set(Integer.parseInt(line.split("\\:")[1]));
- } else if (line.equals(READY)) {
+ if (line.equals(READY)) {
return true;
} else if (line.equals(ERROR)) {
error.set(true);
@@ -92,7 +87,7 @@
throw new Error("Unable to start the monitored application.");
}
- String pidStr = String.valueOf(pid.get());
+ String pidStr = String.valueOf(app.getPid());
JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK("jstat");
l.addToolArg("-compiler");
l.addToolArg(pidStr);
--- a/jdk/test/sun/tools/jstatd/JstatdTest.java Tue Jun 24 12:27:37 2014 +0400
+++ b/jdk/test/sun/tools/jstatd/JstatdTest.java Tue Jul 01 10:20:56 2014 -0700
@@ -22,12 +22,12 @@
*/
import java.io.File;
+import java.io.IOException;
import java.net.UnknownHostException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.Arrays;
-import java.util.regex.Pattern;
import static jdk.testlibrary.Asserts.*;
import jdk.testlibrary.JDKToolLauncher;
@@ -69,7 +69,7 @@
private boolean useDefaultPort = true;
private String port;
private String serverName;
- private String jstatdPid;
+ private Long jstatdPid;
private boolean withExternalRegistry = false;
public void setServerName(String serverName) {
@@ -84,67 +84,26 @@
this.withExternalRegistry = withExternalRegistry;
}
- /**
- * Parse pid from jps output
- */
- private String parsePid(String tool, OutputAnalyzer output) throws Exception {
- String[] lines = output.getOutput().split(Utils.NEW_LINE);
- String pid = null;
- int count = 0;
- String processName = tool;
- if (tool == "rmiregistry") {
- processName = "registryimpl";
- }
+ private Long waitOnTool(ProcessThread thread) throws Throwable {
+ long pid = thread.getPid();
- Pattern toolInJpsPattern =
- Pattern.compile("^\\d+\\s{1}" + processName + "\\s{1}.*-dparent\\.pid\\." + ProcessTools.getProcessId() + ".*");
- for (String line : lines) {
- if (toolInJpsPattern.matcher(line.toLowerCase()).matches()) {
- pid = line.split(" ")[0];
- count++;
+ Throwable t = thread.getUncaught();
+ if (t != null) {
+ if (t.getMessage().contains(
+ "java.rmi.server.ExportException: Port already in use")) {
+ System.out.println("Port already in use. Trying to restart with a new one...");
+ Thread.sleep(100);
+ return null;
+ } else {
+ // Something unexpected has happened
+ throw new Throwable(t);
}
}
- if (count > 1) {
- throw new Exception("Expected one " + tool
- + " process, got " + count + ". Test will be canceled.");
- }
+ System.out.println(thread.getName() + " pid: " + pid);
return pid;
}
- private String getToolPid(String tool)
- throws Exception {
- OutputAnalyzer output = runJps();
- return parsePid(tool, output);
- }
-
- private String waitOnTool(String tool, TestThread thread) throws Throwable {
- while (true) {
- String pid = getToolPid(tool);
-
- if (pid != null) {
- System.out.println(tool + " pid: " + pid);
- return pid;
- }
-
- Throwable t = thread.getUncaught();
- if (t != null) {
- if (t.getMessage().contains(
- "java.rmi.server.ExportException: Port already in use")) {
- System.out.println("Port already in use. Trying to restart with a new one...");
- Thread.sleep(100);
- return null;
- } else {
- // Something unexpected has happened
- throw new Throwable(t);
- }
- }
-
- System.out.println("Waiting until " + tool + " is running...");
- Thread.sleep(100);
- }
- }
-
private void log(String caption, String... cmd) {
System.out.println(Utils.NEW_LINE + caption + ":");
System.out.println(Arrays.toString(cmd).replace(",", ""));
@@ -180,12 +139,29 @@
log("Start jps", cmd);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
- OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
+ OutputAnalyzer output = waitForJstatdRMI(processBuilder);
System.out.println(output.getOutput());
return output;
}
+ private OutputAnalyzer waitForJstatdRMI(ProcessBuilder pb) throws IOException, InterruptedException {
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+
+ while (output.getExitValue() != 0) {
+ String out = output.getOutput();
+
+ if (out.contains("RMI Registry not available") ||
+ out.contains("RMI Server JStatRemoteHost not available")) {
+ Thread.sleep(100);
+ output = new OutputAnalyzer(pb.start());
+ } else {
+ output.shouldHaveExitValue(0);
+ }
+ }
+ return output;
+ }
+
/**
* Verifies output form jps contains pids and programs' name information.
* The function will discard any lines that come before the first line with pid.
@@ -235,7 +211,7 @@
log("Start jstat", cmd);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
- OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
+ OutputAnalyzer output = waitForJstatdRMI(processBuilder);
System.out.println(output.getOutput());
return output;
@@ -323,7 +299,7 @@
try {
jstatdThread.start();
// Make sure jstatd is up and running
- jstatdPid = waitOnTool("jstatd", jstatdThread);
+ jstatdPid = waitOnTool(jstatdThread);
if (jstatdPid == null) {
// The port is already in use. Cancel and try with new one.
jstatdThread.stopProcess();
@@ -344,7 +320,7 @@
try {
while (jstatdThread == null) {
if (!useDefaultPort || withExternalRegistry) {
- port = Integer.toString(Utils.getFreePort());
+ port = String.valueOf(Utils.getFreePort());
}
if (withExternalRegistry) {