--- a/jdk/make/java/java/FILES_java.gmk Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/make/java/java/FILES_java.gmk Wed Aug 27 10:28:26 2008 -0700
@@ -449,6 +449,7 @@
sun/misc/JavaLangAccess.java \
sun/misc/JavaIOAccess.java \
sun/misc/JavaIODeleteOnExitAccess.java \
- sun/misc/JavaIOFileDescriptorAccess.java
+ sun/misc/JavaIOFileDescriptorAccess.java \
+ sun/misc/JavaNioAccess.java
FILES_java = $(JAVA_JAVA_java)
--- a/jdk/make/java/jli/Makefile Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/make/java/jli/Makefile Wed Aug 27 10:28:26 2008 -0700
@@ -113,7 +113,11 @@
JAVALIB =
OTHER_LCF = -export:JLI_Launch \
-export:JLI_ManifestIterate \
- -export:JLI_SetTraceLauncher
+ -export:JLI_SetTraceLauncher \
+ -export:JLI_ReportErrorMessage \
+ -export:JLI_ReportErrorMessageSys \
+ -export:JLI_ReportMessage \
+ -export:JLI_ReportExceptionDescription
endif
--- a/jdk/make/java/jli/mapfile-vers Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/make/java/jli/mapfile-vers Wed Aug 27 10:28:26 2008 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,10 @@
JLI_Launch;
JLI_ManifestIterate;
JLI_SetTraceLauncher;
+ JLI_ReportErrorMessage;
+ JLI_ReportErrorMessageSys;
+ JLI_ReportMessage;
+ JLI_ReportExceptionDescription;
local:
*;
};
--- a/jdk/make/java/net/mapfile-vers Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/make/java/net/mapfile-vers Wed Aug 27 10:28:26 2008 -0700
@@ -57,7 +57,7 @@
Java_java_net_Inet6AddressImpl_isReachable0;
Java_java_net_NetworkInterface_init;
Java_java_net_NetworkInterface_getByName0;
- Java_java_net_NetworkInterface_getByIndex;
+ Java_java_net_NetworkInterface_getByIndex0;
Java_java_net_NetworkInterface_getByInetAddress0;
Java_java_net_NetworkInterface_getAll;
Java_java_net_NetworkInterface_isUp0;
--- a/jdk/make/java/nio/FILES_java.gmk Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/make/java/nio/FILES_java.gmk Wed Aug 27 10:28:26 2008 -0700
@@ -26,6 +26,7 @@
FILES_src = \
java/nio/Bits.java \
java/nio/Buffer.java \
+ java/nio/BufferPoolMXBean.java \
java/nio/ByteOrder.java \
java/nio/MappedByteBuffer.java \
java/nio/StringCharBuffer.java \
--- a/jdk/make/java/nio/mapfile-linux Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/make/java/nio/mapfile-linux Wed Aug 27 10:28:26 2008 -0700
@@ -18,6 +18,8 @@
Java_sun_nio_ch_EPollArrayWrapper_fdLimit;
Java_sun_nio_ch_EPollArrayWrapper_init;
Java_sun_nio_ch_EPollArrayWrapper_interrupt;
+ Java_sun_nio_ch_EPollArrayWrapper_offsetofData;
+ Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent;
Java_sun_nio_ch_FileChannelImpl_close0;
Java_sun_nio_ch_FileChannelImpl_force0;
Java_sun_nio_ch_FileChannelImpl_initIDs;
--- a/jdk/src/share/bin/emessages.h Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/bin/emessages.h Wed Aug 27 10:28:26 2008 -0700
@@ -25,8 +25,8 @@
/*
* This file primarily consists of all the error and warning messages, that
- * are used in ReportErrorMessage. All message must be defined here, in order
- * to help in I18N/L10N the messages.
+ * are used in JLI_ReportErrorMessage. All message must be defined here, in
+ * order to help with localizing the messages.
*/
#ifndef _EMESSAGES_H
--- a/jdk/src/share/bin/java.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/bin/java.c Wed Aug 27 10:28:26 2008 -0700
@@ -148,7 +148,7 @@
static jboolean IsWildCardEnabled();
#define ARG_CHECK(n, f, a) if (n < 1) { \
- ReportErrorMessage(f, a); \
+ JLI_ReportErrorMessage(f, a); \
printUsage = JNI_TRUE; \
*pret = 1; \
return JNI_TRUE; \
@@ -326,15 +326,15 @@
start = CounterGet();
if (!InitializeJVM(&vm, &env, &ifn)) {
- ReportErrorMessage(JVM_ERROR1);
+ JLI_ReportErrorMessage(JVM_ERROR1);
exit(1);
}
if (printVersion || showVersion) {
PrintJavaVersion(env, showVersion);
if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
if (printVersion) {
@@ -347,8 +347,8 @@
if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) {
PrintUsage(env, printXUsage);
if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
ret=1;
}
goto leave;
@@ -397,43 +397,43 @@
if (jarfile != 0) {
mainClassName = GetMainClassName(env, jarfile);
if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
if (mainClassName == NULL) {
- ReportErrorMessage(JAR_ERROR1,jarfile, GEN_ERROR);
+ JLI_ReportErrorMessage(JAR_ERROR1,jarfile, GEN_ERROR);
goto leave;
}
classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
if (classname == NULL) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */
- ReportExceptionDescription(env);
- ReportErrorMessage(CLS_ERROR1, classname);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(CLS_ERROR1, classname);
goto leave;
}
(*env)->ReleaseStringUTFChars(env, mainClassName, classname);
} else {
mainClassName = NewPlatformString(env, classname);
if (mainClassName == NULL) {
- ReportErrorMessage(CLS_ERROR2, classname, GEN_ERROR);
+ JLI_ReportErrorMessage(CLS_ERROR2, classname, GEN_ERROR);
goto leave;
}
classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
if (classname == NULL) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */
- ReportExceptionDescription(env);
- ReportErrorMessage(CLS_ERROR1, classname);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(CLS_ERROR1, classname);
goto leave;
}
(*env)->ReleaseStringUTFChars(env, mainClassName, classname);
@@ -444,10 +444,10 @@
"([Ljava/lang/String;)V");
if (mainID == NULL) {
if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
} else {
- ReportErrorMessage(CLS_ERROR3);
+ JLI_ReportErrorMessage(CLS_ERROR3);
}
goto leave;
}
@@ -459,8 +459,8 @@
mainID, JNI_TRUE);
if( obj == NULL) { /* exception occurred */
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
@@ -469,14 +469,14 @@
(*env)->GetObjectClass(env, obj),
"getModifiers", "()I");
if ((*env)->ExceptionOccurred(env)) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
mods = (*env)->CallIntMethod(env, obj, mid);
if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */
- ReportErrorMessage(CLS_ERROR4);
+ JLI_ReportErrorMessage(CLS_ERROR4);
goto leave;
}
}
@@ -484,8 +484,8 @@
/* Build argument array */
mainArgs = NewPlatformStringArray(env, argv, argc);
if (mainArgs == NULL) {
- ReportExceptionDescription(env);
- ReportErrorMessage(JNI_ERROR);
+ JLI_ReportExceptionDescription(env);
+ JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
@@ -506,7 +506,7 @@
* launcher's return code except by calling System.exit.
*/
if ((*vm)->DetachCurrentThread(vm) != 0) {
- ReportErrorMessage(JVM_ERROR2);
+ JLI_ReportErrorMessage(JVM_ERROR2);
ret = 1;
goto leave;
}
@@ -635,7 +635,7 @@
if (loopCount > knownVMsCount) {
if (!speculative) {
- ReportErrorMessage(CFG_ERROR1);
+ JLI_ReportErrorMessage(CFG_ERROR1);
exit(1);
} else {
return "ERROR";
@@ -645,7 +645,7 @@
if (nextIdx < 0) {
if (!speculative) {
- ReportErrorMessage(CFG_ERROR2, knownVMs[jvmidx].alias);
+ JLI_ReportErrorMessage(CFG_ERROR2, knownVMs[jvmidx].alias);
exit(1);
} else {
return "ERROR";
@@ -660,7 +660,7 @@
switch (knownVMs[jvmidx].flag) {
case VM_WARN:
if (!speculative) {
- ReportErrorMessage(CFG_WARN1, jvmtype, knownVMs[0].name + 1);
+ JLI_ReportErrorMessage(CFG_WARN1, jvmtype, knownVMs[0].name + 1);
}
/* fall through */
case VM_IGNORE:
@@ -670,7 +670,7 @@
break;
case VM_ERROR:
if (!speculative) {
- ReportErrorMessage(CFG_ERROR3, jvmtype);
+ JLI_ReportErrorMessage(CFG_ERROR3, jvmtype);
exit(1);
} else {
return "ERROR";
@@ -879,9 +879,9 @@
if (jarflag && operand) {
if ((res = JLI_ParseManifest(operand, &info)) != 0) {
if (res == -1)
- ReportErrorMessage(JAR_ERROR2, operand);
+ JLI_ReportErrorMessage(JAR_ERROR2, operand);
else
- ReportErrorMessage(JAR_ERROR3, operand);
+ JLI_ReportErrorMessage(JAR_ERROR3, operand);
exit(1);
}
@@ -948,7 +948,7 @@
* Check for correct syntax of the version specification (JSR 56).
*/
if (!JLI_ValidVersionString(info.jre_version)) {
- ReportErrorMessage(SPC_ERROR1, info.jre_version);
+ JLI_ReportErrorMessage(SPC_ERROR1, info.jre_version);
exit(1);
}
@@ -970,7 +970,7 @@
JLI_MemFree(new_argv);
return;
} else {
- ReportErrorMessage(CFG_ERROR4, info.jre_version);
+ JLI_ReportErrorMessage(CFG_ERROR4, info.jre_version);
exit(1);
}
}
@@ -1040,7 +1040,7 @@
* command line options.
*/
} else if (JLI_StrCmp(arg, "-fullversion") == 0) {
- ReportMessage("%s full version \"%s\"", _launcher_name, GetFullVersion());
+ JLI_ReportMessage("%s full version \"%s\"", _launcher_name, GetFullVersion());
return JNI_FALSE;
} else if (JLI_StrCmp(arg, "-verbosegc") == 0) {
AddOption("-verbose:gc", NULL);
@@ -1080,7 +1080,7 @@
JLI_StrCmp(arg, "-cs") == 0 ||
JLI_StrCmp(arg, "-noasyncgc") == 0) {
/* No longer supported */
- ReportErrorMessage(ARG_WARN, arg);
+ JLI_ReportErrorMessage(ARG_WARN, arg);
} else if (JLI_StrCCmp(arg, "-version:") == 0 ||
JLI_StrCmp(arg, "-no-jre-restrict-search") == 0 ||
JLI_StrCmp(arg, "-jre-restrict-search") == 0 ||
@@ -1143,12 +1143,12 @@
#define NULL_CHECK0(e) if ((e) == 0) { \
- ReportErrorMessage(JNI_ERROR); \
+ JLI_ReportErrorMessage(JNI_ERROR); \
return 0; \
}
#define NULL_CHECK(e) if ((e) == 0) { \
- ReportErrorMessage(JNI_ERROR); \
+ JLI_ReportErrorMessage(JNI_ERROR); \
return; \
}
@@ -1351,7 +1351,7 @@
char *arg = argv[i];
if (arg[0] == '-' && arg[1] == 'J') {
if (arg[2] == '\0') {
- ReportErrorMessage(ARG_ERROR3);
+ JLI_ReportErrorMessage(ARG_ERROR3);
exit(1);
}
*nargv++ = arg + 2;
@@ -1418,7 +1418,7 @@
}
if (!GetApplicationHome(home, sizeof(home))) {
- ReportErrorMessage(CFG_ERROR5);
+ JLI_ReportErrorMessage(CFG_ERROR5);
return JNI_FALSE;
}
@@ -1691,7 +1691,7 @@
jvmCfg = fopen(jvmCfgName, "r");
if (jvmCfg == NULL) {
if (!speculative) {
- ReportErrorMessage(CFG_ERROR6, jvmCfgName);
+ JLI_ReportErrorMessage(CFG_ERROR6, jvmCfgName);
exit(1);
} else {
return -1;
@@ -1703,7 +1703,7 @@
if (line[0] == '#')
continue;
if (line[0] != '-') {
- ReportErrorMessage(CFG_WARN2, lineno, jvmCfgName);
+ JLI_ReportErrorMessage(CFG_WARN2, lineno, jvmCfgName);
}
if (cnt >= knownVMsLimit) {
GrowKnownVMs(cnt);
@@ -1711,13 +1711,13 @@
line[JLI_StrLen(line)-1] = '\0'; /* remove trailing newline */
tmpPtr = line + JLI_StrCSpn(line, whiteSpace);
if (*tmpPtr == 0) {
- ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
+ JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
} else {
/* Null-terminate this string for JLI_StringDup below */
*tmpPtr++ = 0;
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
if (*tmpPtr == 0) {
- ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
+ JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
} else {
if (!JLI_StrCCmp(tmpPtr, "KNOWN")) {
vmType = VM_KNOWN;
@@ -1727,7 +1727,7 @@
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
}
if (*tmpPtr == 0) {
- ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
+ JLI_ReportErrorMessage(CFG_WARN3, lineno, jvmCfgName);
} else {
/* Null terminate altVMName */
altVMName = tmpPtr;
@@ -1747,7 +1747,7 @@
tmpPtr += JLI_StrSpn(tmpPtr, whiteSpace);
}
if (*tmpPtr == 0) {
- ReportErrorMessage(CFG_WARN4, lineno, jvmCfgName);
+ JLI_ReportErrorMessage(CFG_WARN4, lineno, jvmCfgName);
} else {
/* Null terminate server class VM name */
serverClassVMName = tmpPtr;
@@ -1756,7 +1756,7 @@
vmType = VM_IF_SERVER_CLASS;
}
} else {
- ReportErrorMessage(CFG_WARN5, lineno, &jvmCfgName[0]);
+ JLI_ReportErrorMessage(CFG_WARN5, lineno, &jvmCfgName[0]);
vmType = VM_KNOWN;
}
}
@@ -2019,7 +2019,7 @@
* A utility procedure to always print to stderr
*/
void
-ReportMessage(const char* fmt, ...)
+JLI_ReportMessage(const char* fmt, ...)
{
va_list vl;
va_start(vl, fmt);
--- a/jdk/src/share/bin/java.h Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/bin/java.h Wed Aug 27 10:28:26 2008 -0700
@@ -121,24 +121,20 @@
char jvmpath[],
jint so_jvmpath,
char **original_argv);
+/* Reports an error message to stderr or a window as appropriate. */
+void JLI_ReportErrorMessage(const char * message, ...);
-/*
- * Report an error message to stderr or a window as appropriate.
- */
-void ReportErrorMessage(const char * message, ...);
-void ReportErrorMessageSys(const char * format, ...);
+/* Reports a system error message to stderr or a window */
+void JLI_ReportErrorMessageSys(const char * message, ...);
+
+/* Reports an error message only to stderr. */
+void JLI_ReportMessage(const char * message, ...);
/*
- * Report an error message only to stderr.
- */
-void ReportMessage(const char * message, ...);
-
-/*
- * Report an exception which terminates the vm to stderr or a window
+ * Reports an exception which terminates the vm to stderr or a window
* as appropriate.
*/
-void ReportExceptionDescription(JNIEnv * env);
-
+void JLI_ReportExceptionDescription(JNIEnv * env);
void PrintMachineDependentOptions();
const char *jlong_format_specifier();
--- a/jdk/src/share/classes/java/lang/management/PlatformComponent.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/java/lang/management/PlatformComponent.java Wed Aug 27 10:28:26 2008 -0700
@@ -32,6 +32,7 @@
import java.util.Set;
import java.util.logging.LoggingMXBean;
import java.util.logging.LogManager;
+import java.nio.BufferPoolMXBean;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -188,6 +189,23 @@
}
}),
+
+ /**
+ * Buffer pools.
+ */
+ BUFFER_POOL(
+ "java.nio.BufferPoolMXBean",
+ "java.nio", "BufferPool", keyProperties("name"),
+ new MXBeanFetcher<BufferPoolMXBean>() {
+ public List<BufferPoolMXBean> getMXBeans() {
+ List<BufferPoolMXBean> pools = new ArrayList<BufferPoolMXBean>(2);
+ pools.add( sun.misc.SharedSecrets.getJavaNioAccess().getDirectBufferPoolMXBean() );
+ pools.add( sun.nio.ch.FileChannelImpl.getMappedBufferPoolMXBean() );
+ return pools;
+ }
+ }),
+
+
// Sun Platform Extension
/**
--- a/jdk/src/share/classes/java/net/NetworkInterface.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/java/net/NetworkInterface.java Wed Aug 27 10:28:26 2008 -0700
@@ -203,11 +203,17 @@
}
/**
- * Get the index of this network interface.
+ * Returns the index of this network interface. The index is an integer greater
+ * or equal to zero, or {@code -1} for unknown. This is a system specific value
+ * and interfaces with the same name can have different indexes on different
+ * machines.
*
- * @return the index of this network interface
+ * @return the index of this network interface or {@code -1} if the index is
+ * unknown
+ * @see #getByIndex(int)
+ * @since 1.7
*/
- int getIndex() {
+ public int getIndex() {
return index;
}
@@ -249,11 +255,18 @@
* Get a network interface given its index.
*
* @param index an integer, the index of the interface
- * @return the NetworkInterface obtained from its index
- * @exception SocketException if an I/O error occurs.
+ * @return the NetworkInterface obtained from its index, or {@code null} if
+ * there is no interface with such an index on the system
+ * @throws SocketException if an I/O error occurs.
+ * @throws IllegalArgumentException if index has a negative value
+ * @see #getIndex()
+ * @since 1.7
*/
- native static NetworkInterface getByIndex(int index)
- throws SocketException;
+ public static NetworkInterface getByIndex(int index) throws SocketException {
+ if (index < 0)
+ throw new IllegalArgumentException("Interface index can't be negative");
+ return getByIndex0(index);
+ }
/**
* Convenience method to search for a network interface that
@@ -325,6 +338,9 @@
private native static NetworkInterface getByName0(String name)
throws SocketException;
+ private native static NetworkInterface getByIndex0(int index)
+ throws SocketException;
+
private native static NetworkInterface getByInetAddress0(InetAddress addr)
throws SocketException;
--- a/jdk/src/share/classes/java/net/ServerSocket.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/java/net/ServerSocket.java Wed Aug 27 10:28:26 2008 -0700
@@ -142,14 +142,18 @@
* as its argument to ensure the operation is allowed.
* This could result in a SecurityException.
*
- * <P>The <code>backlog</code> argument must be a positive
- * value greater than 0. If the value passed is equal or less
- * than 0, then the default value will be assumed.
+ * The <code>backlog</code> argument is the requested maximum number of
+ * pending connections on the socket. Its exact semantics are implementation
+ * specific. In particular, an implementation may impose a maximum length
+ * or may choose to ignore the parameter altogther. The value provided
+ * should be greater than <code>0</code>. If it is less than or equal to
+ * <code>0</code>, then an implementation specific default will be used.
* <P>
*
* @param port the port number, or <code>0</code> to use a port
* number that is automatically allocated.
- * @param backlog the maximum length of the queue.
+ * @param backlog requested maximum length of the queue of incoming
+ * connections.
*
* @exception IOException if an I/O error occurs when opening the socket.
* @exception SecurityException
@@ -187,13 +191,17 @@
* as its argument to ensure the operation is allowed.
* This could result in a SecurityException.
*
- * <P>The <code>backlog</code> argument must be a positive
- * value greater than 0. If the value passed is equal or less
- * than 0, then the default value will be assumed.
+ * The <code>backlog</code> argument is the requested maximum number of
+ * pending connections on the socket. Its exact semantics are implementation
+ * specific. In particular, an implementation may impose a maximum length
+ * or may choose to ignore the parameter altogther. The value provided
+ * should be greater than <code>0</code>. If it is less than or equal to
+ * <code>0</code>, then an implementation specific default will be used.
* <P>
* @param port the port number, or <code>0</code> to use a port
* number that is automatically allocated.
- * @param backlog the listen backlog
+ * @param backlog requested maximum length of the queue of incoming
+ * connections.
* @param bindAddr the local InetAddress the server will bind to
*
* @throws SecurityException if a security manager exists and
@@ -321,11 +329,15 @@
* If the address is <code>null</code>, then the system will pick up
* an ephemeral port and a valid local address to bind the socket.
* <P>
- * The <code>backlog</code> argument must be a positive
- * value greater than 0. If the value passed is equal or less
- * than 0, then the default value will be assumed.
+ * The <code>backlog</code> argument is the requested maximum number of
+ * pending connections on the socket. Its exact semantics are implementation
+ * specific. In particular, an implementation may impose a maximum length
+ * or may choose to ignore the parameter altogther. The value provided
+ * should be greater than <code>0</code>. If it is less than or equal to
+ * <code>0</code>, then an implementation specific default will be used.
* @param endpoint The IP address & port number to bind to.
- * @param backlog The listen backlog length.
+ * @param backlog requested maximum length of the queue of
+ * incoming connections.
* @throws IOException if the bind operation fails, or if the socket
* is already bound.
* @throws SecurityException if a <code>SecurityManager</code> is present and
--- a/jdk/src/share/classes/java/nio/Bits.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/java/nio/Bits.java Wed Aug 27 10:28:26 2008 -0700
@@ -29,6 +29,8 @@
import java.security.PrivilegedAction;
import sun.misc.Unsafe;
import sun.misc.VM;
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
/**
* Access to bits, native and otherwise.
@@ -625,13 +627,15 @@
// direct buffer memory. This value may be changed during VM
// initialization if it is launched with "-XX:MaxDirectMemorySize=<size>".
private static volatile long maxMemory = VM.maxDirectMemory();
- private static volatile long reservedMemory = 0;
+ private static volatile long reservedMemory;
+ private static volatile long usedMemory;
+ private static volatile long count;
private static boolean memoryLimitSet = false;
// These methods should be called whenever direct memory is allocated or
// freed. They allow the user to control the amount of direct memory
// which a process may access. All sizes are specified in bytes.
- static void reserveMemory(long size) {
+ static void reserveMemory(long size, int cap) {
synchronized (Bits.class) {
if (!memoryLimitSet && VM.isBooted()) {
@@ -640,6 +644,8 @@
}
if (size <= maxMemory - reservedMemory) {
reservedMemory += size;
+ usedMemory += cap;
+ count++;
return;
}
}
@@ -655,17 +661,71 @@
if (reservedMemory + size > maxMemory)
throw new OutOfMemoryError("Direct buffer memory");
reservedMemory += size;
+ usedMemory += cap;
+ count++;
}
}
- static synchronized void unreserveMemory(long size) {
+ static synchronized void unreserveMemory(long size, int cap) {
if (reservedMemory > 0) {
reservedMemory -= size;
+ usedMemory -= cap;
+ count--;
assert (reservedMemory > -1);
}
}
+ // -- Management interface for monitoring of direct buffer usage --
+
+ static {
+ // setup access to this package in SharedSecrets
+ sun.misc.SharedSecrets.setJavaNioAccess(
+ new sun.misc.JavaNioAccess() {
+ @Override
+ public BufferPoolMXBean getDirectBufferPoolMXBean() {
+ return LazyInitialization.directBufferPoolMXBean;
+ }
+ }
+ );
+ }
+
+ // Lazy initialization of management interface
+ private static class LazyInitialization {
+ static final BufferPoolMXBean directBufferPoolMXBean = directBufferPoolMXBean();
+
+ private static BufferPoolMXBean directBufferPoolMXBean() {
+ final String pool = "direct";
+ final ObjectName obj;
+ try {
+ obj = new ObjectName("java.nio:type=BufferPool,name=" + pool);
+ } catch (MalformedObjectNameException x) {
+ throw new AssertionError(x);
+ }
+ return new BufferPoolMXBean() {
+ @Override
+ public ObjectName getObjectName() {
+ return obj;
+ }
+ @Override
+ public String getName() {
+ return pool;
+ }
+ @Override
+ public long getCount() {
+ return Bits.count;
+ }
+ @Override
+ public long getTotalCapacity() {
+ return Bits.usedMemory;
+ }
+ @Override
+ public long getMemoryUsed() {
+ return Bits.reservedMemory;
+ }
+ };
+ }
+ }
// -- Bulk get/put acceleration --
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/nio/BufferPoolMXBean.java Wed Aug 27 10:28:26 2008 -0700
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.nio;
+
+import java.lang.management.PlatformManagedObject;
+
+/**
+ * The management interface for a buffer pool.
+ *
+ * <p> A class implementing this interface is an <a href=
+ * "java.lang.management.ManagementFactory.html#MXBean">MXBean</a>. A Java
+ * virtual machine has one or more implementations of this interface. The {@link
+ * java.lang.management.ManagementFactory#getPlatformMXBeans getPlatformMXBeans}
+ * method can be used to obtain the list of {@code BufferPoolMXBean} objects
+ * representing the management interfaces for pools of buffers as follows:
+ * <pre>
+ * List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
+ * </pre>
+ *
+ * <p> The management interfaces are also registered with the platform {@link
+ * javax.management.MBeanServer MBeanServer}. The {@link
+ * javax.management.ObjectName ObjectName} that uniquely identifies the
+ * management interface within the {@code MBeanServer} takes the form:
+ * <blockquote>
+ * <tt>java.nio:type=BufferPool</tt><tt>,name=</tt><i>pool name</i>
+ * </blockquote>
+ * where <em>pool name</em> is the {@link #getName name} of the buffer pool.
+ *
+ * @since 1.7
+ */
+
+public interface BufferPoolMXBean extends PlatformManagedObject {
+
+ /**
+ * Returns the name representing this buffer pool.
+ *
+ * @return The name of this buffer pool.
+ */
+ String getName();
+
+ /**
+ * Returns an estimate of the number of buffers in the pool.
+ *
+ * @return An estimate of the number of buffers in this pool
+ */
+ long getCount();
+
+ /**
+ * Returns an estimate of the total capacity of the buffers in this pool.
+ * A buffer's capacity is the number of elements it contains and the value
+ * returned by this method is an estimate of the total capacity of buffers
+ * in the pool in bytes.
+ *
+ * @return An estimate of the total capacity of the buffers in this pool
+ * in bytes
+ */
+ long getTotalCapacity();
+
+ /**
+ * Returns an estimate of the memory that the Java virtual machine is using
+ * for this buffer pool. The value returned by this method may differ
+ * from the estimate of the total {@link #getTotalCapacity capacity} of
+ * the buffers in this pool. This difference is explained by alignment,
+ * memory allocator, and other implementation specific reasons.
+ *
+ * @return An estimate of the memory that the Java virtual machine is using
+ * for this buffer pool in bytes, or {@code -1L} if an estimate of
+ * the memory usage is not available
+ */
+ long getMemoryUsed();
+}
--- a/jdk/src/share/classes/java/nio/Direct-X-Buffer.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/java/nio/Direct-X-Buffer.java Wed Aug 27 10:28:26 2008 -0700
@@ -71,11 +71,13 @@
private static Unsafe unsafe = Unsafe.getUnsafe();
private long address;
+ private long size;
private int capacity;
- private Deallocator(long address, int capacity) {
+ private Deallocator(long address, long size, int capacity) {
assert (address != 0);
this.address = address;
+ this.size = size;
this.capacity = capacity;
}
@@ -86,7 +88,7 @@
}
unsafe.freeMemory(address);
address = 0;
- Bits.unreserveMemory(capacity);
+ Bits.unreserveMemory(size, capacity);
}
}
@@ -110,23 +112,25 @@
Direct$Type$Buffer$RW$(int cap) { // package-private
#if[rw]
super(-1, 0, cap, cap, false);
- Bits.reserveMemory(cap);
int ps = Bits.pageSize();
+ int size = cap + ps;
+ Bits.reserveMemory(size, cap);
+
long base = 0;
try {
- base = unsafe.allocateMemory(cap + ps);
+ base = unsafe.allocateMemory(size);
} catch (OutOfMemoryError x) {
- Bits.unreserveMemory(cap);
+ Bits.unreserveMemory(size, cap);
throw x;
}
- unsafe.setMemory(base, cap + ps, (byte) 0);
+ unsafe.setMemory(base, size, (byte) 0);
if (base % ps != 0) {
// Round up to page boundary
address = base + ps - (base & (ps - 1));
} else {
address = base;
}
- cleaner = Cleaner.create(this, new Deallocator(base, cap));
+ cleaner = Cleaner.create(this, new Deallocator(base, size, cap));
#else[rw]
super(cap);
#end[rw]
--- a/jdk/src/share/classes/javax/net/ssl/SSLServerSocket.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/javax/net/ssl/SSLServerSocket.java Wed Aug 27 10:28:26 2008 -0700
@@ -108,9 +108,12 @@
* <P>
* A port number of <code>0</code> creates a socket on any free port.
* <P>
- * The <code>backlog</code> argument must be a positive
- * value greater than 0. If the value passed if equal or less
- * than 0, then the default value will be assumed.
+ * The <code>backlog</code> argument is the requested maximum number of
+ * pending connections on the socket. Its exact semantics are implementation
+ * specific. In particular, an implementation may impose a maximum length
+ * or may choose to ignore the parameter altogther. The value provided
+ * should be greater than <code>0</code>. If it is less than or equal to
+ * <code>0</code>, then an implementation specific default will be used.
* <P>
* If there is a security manager, its <code>checkListen</code>
* method is called with the <code>port</code> argument as its
@@ -118,8 +121,8 @@
* in a SecurityException.
*
* @param port the port on which to listen
- * @param backlog how many connections may be pending before
- * the system should start rejecting new requests
+ * @param backlog requested maximum length of the queue of incoming
+ * connections.
* @throws IOException if an I/O error occurs when creating the socket
* @throws SecurityException if a security manager exists and its
* <code>checkListen</code> method doesn't allow the operation.
@@ -150,16 +153,19 @@
* <P>
* A port number of <code>0</code> creates a socket on any free port.
* <P>
- * <P>The <code>backlog</code> argument must be a positive
- * value greater than 0. If the value passed if equal or less
- * than 0, then the default value will be assumed.
+ * The <code>backlog</code> argument is the requested maximum number of
+ * pending connections on the socket. Its exact semantics are implementation
+ * specific. In particular, an implementation may impose a maximum length
+ * or may choose to ignore the parameter altogther. The value provided
+ * should be greater than <code>0</code>. If it is less than or equal to
+ * <code>0</code>, then an implementation specific default will be used.
* <P>
* If <i>address</i> is null, it will default accepting connections
* on any/all local addresses.
*
* @param port the port on which to listen
- * @param backlog how many connections may be pending before
- * the system should start rejecting new requests
+ * @param backlog requested maximum length of the queue of incoming
+ * connections.
* @param address the address of the network interface through
* which connections will be accepted
* @throws IOException if an I/O error occurs when creating the socket
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/misc/JavaNioAccess.java Wed Aug 27 10:28:26 2008 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.misc;
+
+import java.nio.BufferPoolMXBean;
+
+public interface JavaNioAccess {
+ BufferPoolMXBean getDirectBufferPoolMXBean();
+}
--- a/jdk/src/share/classes/sun/misc/SharedSecrets.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java Wed Aug 27 10:28:26 2008 -0700
@@ -46,6 +46,7 @@
private static JavaIOAccess javaIOAccess;
private static JavaIODeleteOnExitAccess javaIODeleteOnExitAccess;
private static JavaNetAccess javaNetAccess;
+ private static JavaNioAccess javaNioAccess;
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
public static JavaUtilJarAccess javaUtilJarAccess() {
@@ -77,6 +78,20 @@
return javaNetAccess;
}
+ public static void setJavaNioAccess(JavaNioAccess jna) {
+ javaNioAccess = jna;
+ }
+
+ public static JavaNioAccess getJavaNioAccess() {
+ if (javaNioAccess == null) {
+ // Ensure java.nio.ByteOrder is initialized; we know that
+ // this class initializes java.nio.Bits that provides the
+ // shared secret.
+ unsafe.ensureClassInitialized(java.nio.ByteOrder.class);
+ }
+ return javaNioAccess;
+ }
+
public static void setJavaIOAccess(JavaIOAccess jia) {
javaIOAccess = jia;
}
--- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java Wed Aug 27 10:28:26 2008 -0700
@@ -32,6 +32,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
+import java.nio.BufferPoolMXBean;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.ArrayList;
@@ -43,10 +44,12 @@
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
+
import sun.misc.Cleaner;
import sun.security.action.GetPropertyAction;
-
public class FileChannelImpl
extends FileChannel
{
@@ -681,14 +684,26 @@
private static class Unmapper
implements Runnable
{
+ // keep track of mapped buffer usage
+ static volatile int count;
+ static volatile long totalSize;
+ static volatile long totalCapacity;
private long address;
private long size;
+ private int cap;
- private Unmapper(long address, long size) {
+ private Unmapper(long address, long size, int cap) {
assert (address != 0);
this.address = address;
this.size = size;
+ this.cap = cap;
+
+ synchronized (Unmapper.class) {
+ count++;
+ totalSize += size;
+ totalCapacity += cap;
+ }
}
public void run() {
@@ -696,8 +711,13 @@
return;
unmap0(address, size);
address = 0;
+
+ synchronized (Unmapper.class) {
+ count--;
+ totalSize -= size;
+ totalCapacity -= cap;
+ }
}
-
}
private static void unmap(MappedByteBuffer bb) {
@@ -786,7 +806,7 @@
assert (IOStatus.checkAll(addr));
assert (addr % allocationGranularity == 0);
int isize = (int)size;
- Unmapper um = new Unmapper(addr, size + pagePosition);
+ Unmapper um = new Unmapper(addr, size + pagePosition, isize);
if ((!writable) || (imode == MAP_RO))
return Util.newMappedByteBufferR(isize, addr + pagePosition, um);
else
@@ -797,6 +817,49 @@
}
}
+ /**
+ * Returns the management interface for mapped buffers
+ */
+ public static BufferPoolMXBean getMappedBufferPoolMXBean() {
+ return LazyInitialization.mappedBufferPoolMXBean;
+ }
+
+ // Lazy initialization of management interface
+ private static class LazyInitialization {
+ static final BufferPoolMXBean mappedBufferPoolMXBean = mappedBufferPoolMXBean();
+
+ private static BufferPoolMXBean mappedBufferPoolMXBean() {
+ final String pool = "mapped";
+ final ObjectName obj;
+ try {
+ obj = new ObjectName("java.nio:type=BufferPool,name=" + pool);
+ } catch (MalformedObjectNameException x) {
+ throw new AssertionError(x);
+ }
+ return new BufferPoolMXBean() {
+ @Override
+ public ObjectName getObjectName() {
+ return obj;
+ }
+ @Override
+ public String getName() {
+ return pool;
+ }
+ @Override
+ public long getCount() {
+ return Unmapper.count;
+ }
+ @Override
+ public long getTotalCapacity() {
+ return Unmapper.totalCapacity;
+ }
+ @Override
+ public long getMemoryUsed() {
+ return Unmapper.totalSize;
+ }
+ };
+ }
+ }
// -- Locks --
--- a/jdk/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java Wed Aug 27 10:28:26 2008 -0700
@@ -25,6 +25,7 @@
package sun.reflect.generics.factory;
+import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
@@ -118,7 +119,10 @@
}
public Type makeArrayType(Type componentType){
- return GenericArrayTypeImpl.make(componentType);
+ if (componentType instanceof Class<?>)
+ return Array.newInstance((Class<?>) componentType, 0).getClass();
+ else
+ return GenericArrayTypeImpl.make(componentType);
}
public Type makeByte(){return byte.class;}
--- a/jdk/src/share/classes/sun/security/util/DerIndefLenConverter.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/share/classes/sun/security/util/DerIndefLenConverter.java Wed Aug 27 10:28:26 2008 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2008 Sun Microsystems, Inc. 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
@@ -50,6 +50,7 @@
private byte[] data, newData;
private int newDataPos, dataPos, dataSize, index;
+ private int unresolved = 0;
private ArrayList<Object> ndefsList = new ArrayList<Object>();
@@ -113,6 +114,7 @@
numOfEncapsulatedLenBytes;
byte[] sectionLenBytes = getLengthBytes(sectionLen);
ndefsList.set(index, sectionLenBytes);
+ unresolved--;
// Add the number of bytes required to represent this section
// to the total number of length bytes,
@@ -149,6 +151,7 @@
int lenByte = data[dataPos++] & 0xff;
if (isIndefinite(lenByte)) {
ndefsList.add(new Integer(dataPos));
+ unresolved++;
return curLen;
}
if (isLongForm(lenByte)) {
@@ -308,15 +311,21 @@
dataPos=0; index=0;
dataSize = data.length;
int len=0;
+ int unused = 0;
// parse and set up the vectors of all the indefinite-lengths
while (dataPos < dataSize) {
parseTag();
len = parseLength();
parseValue(len);
+ if (unresolved == 0) {
+ unused = dataSize - dataPos;
+ dataSize = dataPos;
+ break;
+ }
}
- newData = new byte[dataSize + numOfTotalLenBytes];
+ newData = new byte[dataSize + numOfTotalLenBytes + unused];
dataPos=0; newDataPos=0; index=0;
// write out the new byte array replacing all the indefinite-lengths
@@ -325,6 +334,8 @@
writeTag();
writeLengthAndValue();
}
+ System.arraycopy(indefData, dataSize,
+ newData, dataSize + numOfTotalLenBytes, unused);
return newData;
}
--- a/jdk/src/solaris/bin/java_md.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/solaris/bin/java_md.c Wed Aug 27 10:28:26 2008 -0700
@@ -289,13 +289,13 @@
if (wanted == running) {
/* Find out where the JRE is that we will be using. */
if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
- ReportErrorMessage(JRE_ERROR1);
+ JLI_ReportErrorMessage(JRE_ERROR1);
exit(2);
}
/* Find the specified JVM type */
if (ReadKnownVMs(jrepath, arch, JNI_FALSE) < 1) {
- ReportErrorMessage(CFG_ERROR7);
+ JLI_ReportErrorMessage(CFG_ERROR7);
exit(1);
}
@@ -303,7 +303,7 @@
jvmtype = CheckJvmType(_argcp, _argvp, JNI_FALSE);
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) {
- ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
+ JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
exit(4);
}
} else { /* do the same speculatively or exit */
@@ -330,7 +330,7 @@
EndDataModelSpeculate: /* give up and let other code report error message */
;
#else
- ReportErrorMessage(JRE_ERROR2, wanted);
+ JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1);
#endif
}
@@ -391,7 +391,7 @@
break;
default:
- ReportErrorMessage(JRE_ERROR3, __LINE__);
+ JLI_ReportErrorMessage(JRE_ERROR3, __LINE__);
exit(1); /* unknown value in wanted */
break;
}
@@ -553,17 +553,17 @@
(void)fflush(stdout);
(void)fflush(stderr);
execve(newexec, argv, newenvp);
- ReportErrorMessageSys(JRE_ERROR4, newexec);
+ JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
#ifdef DUAL_MODE
if (running != wanted) {
- ReportErrorMessage(JRE_ERROR5, wanted, running);
+ JLI_ReportErrorMessage(JRE_ERROR5, wanted, running);
# ifdef __solaris__
# ifdef __sparc
- ReportErrorMessage(JRE_ERROR6);
+ JLI_ReportErrorMessage(JRE_ERROR6);
# else
- ReportErrorMessage(JRE_ERROR7);
+ JLI_ReportErrorMessage(JRE_ERROR7);
# endif
}
# endif
@@ -627,7 +627,7 @@
}
if (!speculative)
- ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
+ JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE;
found:
@@ -680,13 +680,13 @@
if(length > 0) {
location = JLI_StrStr(buf, "sparcv8plus ");
if(location == NULL) {
- ReportErrorMessage(JVM_ERROR3);
+ JLI_ReportErrorMessage(JVM_ERROR3);
return JNI_FALSE;
}
}
}
#endif
- ReportErrorMessage(DLL_ERROR1, __LINE__);
+ JLI_ReportErrorMessage(DLL_ERROR1, __LINE__);
goto error;
}
@@ -703,7 +703,7 @@
return JNI_TRUE;
error:
- ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
+ JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror());
return JNI_FALSE;
}
@@ -848,7 +848,7 @@
fptr = (int (*)())dlsym(RTLD_DEFAULT, "main");
if (fptr == NULL) {
- ReportErrorMessage(DLL_ERROR3, dlerror());
+ JLI_ReportErrorMessage(DLL_ERROR3, dlerror());
return JNI_FALSE;
}
@@ -885,7 +885,7 @@
return exec_path;
}
-void ReportErrorMessage(const char* fmt, ...) {
+void JLI_ReportErrorMessage(const char* fmt, ...) {
va_list vl;
va_start(vl, fmt);
vfprintf(stderr, fmt, vl);
@@ -893,7 +893,7 @@
va_end(vl);
}
-void ReportErrorMessageSys(const char* fmt, ...) {
+void JLI_ReportErrorMessageSys(const char* fmt, ...) {
va_list vl;
char *emsg;
@@ -912,7 +912,7 @@
va_end(vl);
}
-void ReportExceptionDescription(JNIEnv * env) {
+void JLI_ReportExceptionDescription(JNIEnv * env) {
(*env)->ExceptionDescribe(env);
}
@@ -1078,7 +1078,7 @@
* Resolve the real path to the directory containing the selected JRE.
*/
if (realpath(jre, wanted) == NULL) {
- ReportErrorMessage(JRE_ERROR9, jre);
+ JLI_ReportErrorMessage(JRE_ERROR9, jre);
exit(1);
}
@@ -1087,7 +1087,7 @@
*/
SetExecname(argv);
if (execname == NULL) {
- ReportErrorMessage(JRE_ERROR10);
+ JLI_ReportErrorMessage(JRE_ERROR10);
exit(1);
}
@@ -1106,7 +1106,7 @@
* can be so deadly.
*/
if (JLI_StrLen(wanted) + JLI_StrLen(progname) + 6 > PATH_MAX) {
- ReportErrorMessage(JRE_ERROR11);
+ JLI_ReportErrorMessage(JRE_ERROR11);
exit(1);
}
@@ -1126,7 +1126,7 @@
(void)fflush(stdout);
(void)fflush(stderr);
execv(wanted, argv);
- ReportErrorMessageSys(JRE_ERROR12, wanted);
+ JLI_ReportErrorMessageSys(JRE_ERROR12, wanted);
exit(1);
}
--- a/jdk/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java Wed Aug 27 10:28:26 2008 -0700
@@ -69,11 +69,11 @@
static final int EPOLL_CTL_MOD = 3;
// Miscellaneous constants
- static final short SIZE_EPOLLEVENT = 12;
- static final short EVENT_OFFSET = 0;
- static final short DATA_OFFSET = 4;
- static final short FD_OFFSET = 4;
- static final int NUM_EPOLLEVENTS = Math.min(fdLimit(), 8192);
+ static final int SIZE_EPOLLEVENT = sizeofEPollEvent();
+ static final int EVENT_OFFSET = 0;
+ static final int DATA_OFFSET = offsetofData();
+ static final int FD_OFFSET = DATA_OFFSET;
+ static final int NUM_EPOLLEVENTS = Math.min(fdLimit(), 8192);
// Base address of the native pollArray
private final long pollArrayAddress;
@@ -280,6 +280,8 @@
private native void epollCtl(int epfd, int opcode, int fd, int events);
private native int epollWait(long pollAddress, int numfds, long timeout,
int epfd) throws IOException;
+ private static native int sizeofEPollEvent();
+ private static native int offsetofData();
private static native int fdLimit();
private static native void interrupt(int fd);
private static native void init();
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c Wed Aug 27 10:28:26 2008 -0700
@@ -206,10 +206,10 @@
/*
* Class: java_net_NetworkInterface
- * Method: getByIndex
+ * Method: getByIndex0
* Signature: (Ljava/lang/String;)Ljava/net/NetworkInterface;
*/
-JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex
+JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0
(JNIEnv *env, jclass cls, jint index) {
netif *ifs, *curr;
--- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c Wed Aug 27 10:28:26 2008 -0700
@@ -1741,7 +1741,7 @@
* (for IF).
*/
if (index > 0) {
- ni = Java_java_net_NetworkInterface_getByIndex(env, ni_class,
+ ni = Java_java_net_NetworkInterface_getByIndex0(env, ni_class,
index);
if (ni == NULL) {
char errmsg[255];
--- a/jdk/src/solaris/native/sun/nio/ch/EPollArrayWrapper.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/solaris/native/sun/nio/ch/EPollArrayWrapper.c Wed Aug 27 10:28:26 2008 -0700
@@ -48,10 +48,18 @@
__uint64_t u64;
} epoll_data_t;
+
+/* x86-64 has same alignment as 32-bit */
+#ifdef __x86_64__
+#define EPOLL_PACKED __attribute__((packed))
+#else
+#define EPOLL_PACKED
+#endif
+
struct epoll_event {
__uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
-} __attribute__ ((__packed__));
+} EPOLL_PACKED;
#ifdef __cplusplus
}
@@ -143,6 +151,18 @@
return (jint)rlp.rlim_max;
}
+JNIEXPORT jint JNICALL
+Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent(JNIEnv* env, jclass this)
+{
+ return sizeof(struct epoll_event);
+}
+
+JNIEXPORT jint JNICALL
+Java_sun_nio_ch_EPollArrayWrapper_offsetofData(JNIEnv* env, jclass this)
+{
+ return offsetof(struct epoll_event, data);
+}
+
JNIEXPORT void JNICALL
Java_sun_nio_ch_EPollArrayWrapper_epollCtl(JNIEnv *env, jobject this, jint epfd,
jint opcode, jint fd, jint events)
--- a/jdk/src/windows/bin/java_md.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/windows/bin/java_md.c Wed Aug 27 10:28:26 2008 -0700
@@ -105,26 +105,26 @@
}
}
if (running != wanted) {
- ReportErrorMessage(JRE_ERROR2, wanted);
+ JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1);
}
/* Find out where the JRE is that we will be using. */
if (!GetJREPath(jrepath, so_jrepath)) {
- ReportErrorMessage(JRE_ERROR1);
+ JLI_ReportErrorMessage(JRE_ERROR1);
exit(2);
}
/* Find the specified JVM type */
if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
- ReportErrorMessage(CFG_ERROR7);
+ JLI_ReportErrorMessage(CFG_ERROR7);
exit(1);
}
jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE);
jvmpath[0] = '\0';
if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
- ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
+ JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
exit(4);
}
/* If we got here, jvmpath has been correctly initialized. */
@@ -160,7 +160,7 @@
goto found;
}
- ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
+ JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL);
return JNI_FALSE;
found:
@@ -212,7 +212,7 @@
JLI_TraceLauncher("CRT path is %s\n", crtpath);
if (_access(crtpath, 0) == 0) {
if (LoadLibrary(crtpath) == 0) {
- ReportErrorMessage(DLL_ERROR4, crtpath);
+ JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
return JNI_FALSE;
}
}
@@ -220,7 +220,7 @@
/* Load the Java VM DLL */
if ((handle = LoadLibrary(jvmpath)) == 0) {
- ReportErrorMessage(DLL_ERROR4, (char *)jvmpath);
+ JLI_ReportErrorMessage(DLL_ERROR4, (char *)jvmpath);
return JNI_FALSE;
}
@@ -230,7 +230,7 @@
ifn->GetDefaultJavaVMInitArgs =
(void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) {
- ReportErrorMessage(JNI_ERROR1, (char *)jvmpath);
+ JLI_ReportErrorMessage(JNI_ERROR1, (char *)jvmpath);
return JNI_FALSE;
}
@@ -292,19 +292,19 @@
/* Find the current version of the JRE */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) {
- ReportErrorMessage(REG_ERROR1, JRE_KEY);
+ JLI_ReportErrorMessage(REG_ERROR1, JRE_KEY);
return JNI_FALSE;
}
if (!GetStringFromRegistry(key, "CurrentVersion",
version, sizeof(version))) {
- ReportErrorMessage(REG_ERROR2, JRE_KEY);
+ JLI_ReportErrorMessage(REG_ERROR2, JRE_KEY);
RegCloseKey(key);
return JNI_FALSE;
}
if (JLI_StrCmp(version, GetDotVersion()) != 0) {
- ReportErrorMessage(REG_ERROR3, JRE_KEY, version, GetDotVersion()
+ JLI_ReportErrorMessage(REG_ERROR3, JRE_KEY, version, GetDotVersion()
);
RegCloseKey(key);
return JNI_FALSE;
@@ -312,13 +312,13 @@
/* Find directory where the current version is installed. */
if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) {
- ReportErrorMessage(REG_ERROR1, JRE_KEY, version);
+ JLI_ReportErrorMessage(REG_ERROR1, JRE_KEY, version);
RegCloseKey(key);
return JNI_FALSE;
}
if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) {
- ReportErrorMessage(REG_ERROR4, JRE_KEY, version);
+ JLI_ReportErrorMessage(REG_ERROR4, JRE_KEY, version);
RegCloseKey(key);
RegCloseKey(subkey);
return JNI_FALSE;
@@ -370,7 +370,7 @@
}
void
-ReportErrorMessage(const char* fmt, ...) {
+JLI_ReportErrorMessage(const char* fmt, ...) {
va_list vl;
va_start(vl,fmt);
@@ -394,12 +394,12 @@
}
/*
- * Just like ReportErrorMessage, except that it concatenates the system
+ * Just like JLI_ReportErrorMessage, except that it concatenates the system
* error message if any, its upto the calling routine to correctly
* format the separation of the messages.
*/
void
-ReportErrorMessageSys(const char *fmt, ...)
+JLI_ReportErrorMessageSys(const char *fmt, ...)
{
va_list vl;
@@ -462,7 +462,7 @@
va_end(vl);
}
-void ReportExceptionDescription(JNIEnv * env) {
+void JLI_ReportExceptionDescription(JNIEnv * env) {
if (IsJavaw()) {
/*
* This code should be replaced by code which opens a window with
@@ -733,7 +733,7 @@
*/
len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
if (len == 0 || len > MAXPATHLEN) {
- ReportErrorMessageSys(JRE_ERROR9, progname);
+ JLI_ReportErrorMessageSys(JRE_ERROR9, progname);
exit(1);
}
@@ -766,7 +766,7 @@
* If it weren't for this semantic flaw, the code below would be ...
*
* execv(path, argv);
- * ReportErrorMessage("Error: Exec of %s failed\n", path);
+ * JLI_ReportErrorMessage("Error: Exec of %s failed\n", path);
* exit(1);
*
* The incorrect exec semantics could be addressed by:
@@ -876,7 +876,7 @@
(LPCTSTR)NULL, /* current directory */
(LPSTARTUPINFO)&si, /* (in) startup information */
(LPPROCESS_INFORMATION)&pi)) { /* (out) process information */
- ReportErrorMessageSys(SYS_ERROR1, path);
+ JLI_ReportErrorMessageSys(SYS_ERROR1, path);
exit(1);
}
@@ -884,7 +884,7 @@
if (GetExitCodeProcess(pi.hProcess, &exitCode) == FALSE)
exitCode = 1;
} else {
- ReportErrorMessage(SYS_ERROR2);
+ JLI_ReportErrorMessage(SYS_ERROR2);
exitCode = 1;
}
--- a/jdk/src/windows/native/java/net/NetworkInterface.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/windows/native/java/net/NetworkInterface.c Wed Aug 27 10:28:26 2008 -0700
@@ -554,11 +554,11 @@
ni_childsID = (*env)->GetFieldID(env, ni_class, "childs", "[Ljava/net/NetworkInterface;");
ni_ctor = (*env)->GetMethodID(env, ni_class, "<init>", "()V");
- ni_iacls = (*env)->FindClass(env, "Ljava/net/InetAddress;");
+ ni_iacls = (*env)->FindClass(env, "java/net/InetAddress");
ni_iacls = (*env)->NewGlobalRef(env, ni_iacls);
ni_iaAddr = (*env)->GetFieldID(env, ni_iacls, "address", "I");
- ni_ia4cls = (*env)->FindClass(env, "Ljava/net/Inet4Address;");
+ ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address");
ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls);
ni_ia4Ctor = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
@@ -762,17 +762,17 @@
/*
* Class: NetworkInterface
- * Method: getByIndex
+ * Method: getByIndex0
* Signature: (I)LNetworkInterface;
*/
-JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex
+JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0
(JNIEnv *env, jclass cls, jint index)
{
netif *ifList, *curr;
jobject netifObj = NULL;
if (os_supports_ipv6 && ipv6_available()) {
- return Java_java_net_NetworkInterface_getByIndex_XP (env, cls, index);
+ return Java_java_net_NetworkInterface_getByIndex0_XP (env, cls, index);
}
/* get the list of interfaces */
--- a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c Wed Aug 27 10:28:26 2008 -0700
@@ -576,10 +576,10 @@
/*
* Class: NetworkInterface
- * Method: getByIndex
+ * Method: getByIndex0_XP
* Signature: (I)LNetworkInterface;
*/
-JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex_XP
+JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0_XP
(JNIEnv *env, jclass cls, jint index)
{
netif *ifList, *curr;
--- a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c Wed Aug 27 10:28:26 2008 -0700
@@ -2090,7 +2090,7 @@
* (for IF).
*/
if (index > 0) {
- ni = Java_java_net_NetworkInterface_getByIndex(env, ni_class,
+ ni = Java_java_net_NetworkInterface_getByIndex0(env, ni_class,
index);
if (ni == NULL) {
char errmsg[255];
--- a/jdk/src/windows/native/java/net/net_util_md.h Wed Aug 27 10:12:22 2008 -0700
+++ b/jdk/src/windows/native/java/net/net_util_md.h Wed Aug 27 10:28:26 2008 -0700
@@ -329,7 +329,7 @@
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0_XP
(JNIEnv *env, jclass cls, jstring name);
-JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex_XP
+JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0_XP
(JNIEnv *env, jclass cls, jint index);
JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0_XP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java Wed Aug 27 10:28:26 2008 -0700
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 5041784
+ * @summary Check that plain arrays like String[] are never represented as
+ * GenericArrayType.
+ * @author Eamonn McManus
+ */
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.GenericDeclaration;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class TestPlainArrayNotGeneric {
+ public String[] m1(List<String> p1) {return null;}
+ public List<String> m2(String[] p1) {return null;}
+ public void m3(List<String> p1, String[] p2) {}
+ public void m4(List<String[]> p1) {}
+ public TestPlainArrayNotGeneric(List<String[]> p1) {}
+ public TestPlainArrayNotGeneric(List<String> p1, String[] p2) {}
+
+ public <T extends List<String[]>> T m5(T p1) {return null;}
+ public <T extends Object> T[] m6(T[] p1, List<T[]> p2) {return null;}
+
+ public List<? extends Object[]> m6(List<? extends Object[]> p1) {return null;}
+ public <T extends List<? extends Object[]>> T m7(T[] p1) {return null;}
+ public List<? super Object[]> m8(List<? super Object[]> p1) {return null;}
+ public <T extends List<? super Object[]>> T[] m9(T[] p1) {return null;}
+
+ public static interface XMap extends Map<List<String[]>, String[]> {}
+ public static interface YMap<K extends List<String[]>, V>
+ extends Map<K[], V[]> {}
+
+
+ private static String lastFailure;
+ private static int failureCount;
+
+ public static void main(String[] args) throws Exception {
+ checkClass(TestPlainArrayNotGeneric.class);
+
+ if (failureCount == 0)
+ System.out.println("TEST PASSED");
+ else
+ throw new Exception("TEST FAILED: Last failure: " + lastFailure);
+ }
+
+ private static void checkClass(Class<?> c) throws Exception {
+ Method[] methods = c.getMethods();
+ for (Method m : methods) {
+ check(m.getGenericReturnType(), "return type of method " + m);
+ check(m.getGenericParameterTypes(), "parameter", "method " + m);
+ check(m.getTypeParameters(), "type parameter", "method " + m);
+ }
+
+ Constructor[] constructors = c.getConstructors();
+ for (Constructor constr : constructors) {
+ check(constr.getGenericParameterTypes(), "parameter",
+ "constructor " + constr);
+ check(constr.getTypeParameters(), "type parameter",
+ "constructor " + constr);
+ }
+
+ Class<?>[] inners = c.getDeclaredClasses();
+ for (Class inner : inners)
+ checkClass(inner);
+ }
+
+ private static void check(Type[] types, String elementKind, String what) {
+ for (int i = 0; i < types.length; i++) {
+ Type t = types[i];
+ check(t, elementKind + " " + (i+1) + " of " + what);
+ }
+ }
+
+ private static final Set<Type> checking = new HashSet<Type>();
+
+ private static void check(Type t, String what) {
+ if (t == null || !checking.add(t))
+ return;
+ // Avoid infinite recursion. t can be null e.g. for superclass of Object.
+ try {
+ check2(t, what);
+ } finally {
+ checking.remove(t);
+ }
+ }
+
+ private static void check2(Type t, String what) {
+ if (t instanceof ParameterizedType) {
+ ParameterizedType pt = (ParameterizedType) t;
+ check(pt.getActualTypeArguments(), "type argument", what);
+ } else if (t instanceof TypeVariable) {
+ TypeVariable<?> tv = (TypeVariable<?>) t;
+ check(tv.getBounds(), "bound", what);
+ GenericDeclaration gd = tv.getGenericDeclaration();
+ if (gd instanceof Type)
+ check((Type) gd, "declaration containing " + what);
+ } else if (t instanceof WildcardType) {
+ WildcardType wt = (WildcardType) t;
+ check(wt.getLowerBounds(), "lower bound", "wildcard type in " + what);
+ check(wt.getUpperBounds(), "upper bound", "wildcard type in " + what);
+ } else if (t instanceof Class<?>) {
+ Class<?> c = (Class<?>) t;
+ check(c.getGenericInterfaces(), "superinterface", c.toString());
+ check(c.getGenericSuperclass(), "superclass of " + c);
+ check(c.getTypeParameters(), "type parameter", c.toString());
+ } else if (t instanceof GenericArrayType) {
+ GenericArrayType gat = (GenericArrayType) t;
+ Type comp = gat.getGenericComponentType();
+ if (comp instanceof Class) {
+ fail("Type " + t + " uses GenericArrayType when plain " +
+ "array would do, in " + what);
+ } else
+ check(comp, "component type of " + what);
+ } else {
+ fail("TEST BUG: mutant Type " + t + " (a " + t.getClass().getName() + ")");
+ }
+ }
+
+ private static void fail(String why) {
+ System.out.println("FAIL: " + why);
+ lastFailure = why;
+ failureCount++;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/NetworkInterface/IndexTest.java Wed Aug 27 10:28:26 2008 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 6717876
+ * @summary Make java.net.NetworkInterface.getIndex() public
+ */
+
+import java.net.*;
+import java.util.Enumeration;
+
+public class IndexTest {
+ public static void main(String[] args) throws Exception {
+ Enumeration<NetworkInterface> netifs = NetworkInterface.getNetworkInterfaces();
+ NetworkInterface nif = null;
+ while (netifs.hasMoreElements()) {
+ nif = netifs.nextElement();
+ int index = nif.getIndex();
+ if (index >= 0) {
+ NetworkInterface nif2 = NetworkInterface.getByIndex(index);
+ if (! nif.equals(nif2)) {
+ throw new RuntimeException("both interfaces should be equal");
+ }
+ }
+ }
+ try {
+ nif = NetworkInterface.getByIndex(-1);
+ throw new RuntimeException("Should have thrown IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // OK
+ }
+ // In all likelyhood, this interface should not exist.
+ nif = NetworkInterface.getByIndex(Integer.MAX_VALUE - 1);
+ if (nif != null) {
+ throw new RuntimeException("getByIndex() should have returned null");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/BufferPoolMXBean/Basic.java Wed Aug 27 10:28:26 2008 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2007-2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @bug 6606598
+ * @summary Unit test for java.nio.BufferPoolMXBean
+ */
+
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.BufferPoolMXBean;
+import java.nio.channels.FileChannel;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.lang.management.ManagementFactory;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.util.*;
+
+public class Basic {
+
+ // static fields to ensure buffers aren't GC'ed
+ static List<ByteBuffer> buffers;
+ static MappedByteBuffer mbb;
+
+ // check counters
+ static void check(List<BufferPoolMXBean> pools,
+ int minBufferCount,
+ long minTotalCapacity)
+ {
+ int bufferCount = 0;
+ long totalCap = 0;
+ long totalMem = 0;
+ for (BufferPoolMXBean pool: pools) {
+ bufferCount += pool.getCount();
+ totalCap += pool.getTotalCapacity();
+ totalMem += pool.getMemoryUsed();
+ }
+ if (bufferCount < minBufferCount)
+ throw new RuntimeException("Count less than expected");
+ if (totalMem < minTotalCapacity)
+ throw new RuntimeException("Memory usage less than expected");
+ if (totalCap < minTotalCapacity)
+ throw new RuntimeException("Total capacity less than expected");
+ }
+
+ public static void main(String[] args) throws Exception {
+ Random rand = new Random();
+
+ // allocate a few direct buffers
+ int bufferCount = 5 + rand.nextInt(20);
+ buffers = new ArrayList<ByteBuffer>(bufferCount);
+ long totalCapacity = 0L;
+ for (int i=0; i<bufferCount; i++) {
+ int cap = 1024 + rand.nextInt(4096);
+ buffers.add( ByteBuffer.allocateDirect(cap) );
+ totalCapacity += cap;
+ }
+
+ // map a file
+ File f = File.createTempFile("blah", null);
+ f.deleteOnExit();
+ RandomAccessFile raf = new RandomAccessFile(f, "rw");
+ FileChannel fc = raf.getChannel();
+ mbb = fc.map(FileChannel.MapMode.READ_WRITE, 10, 100);
+ bufferCount++;
+ totalCapacity += mbb.capacity();
+
+ // direct
+ List<BufferPoolMXBean> pools =
+ ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
+ check(pools, bufferCount, totalCapacity);
+
+ // using MBeanServer
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ Set<ObjectName> mbeans = server.queryNames(
+ new ObjectName("java.nio:type=BufferPool,*"), null);
+ pools = new ArrayList<BufferPoolMXBean>();
+ for (ObjectName name: mbeans) {
+ BufferPoolMXBean pool = ManagementFactory
+ .newPlatformMXBeanProxy(server, name.toString(), BufferPoolMXBean.class);
+ pools.add(pool);
+ }
+ check(pools, bufferCount, totalCapacity);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/DerValue/Indefinite.java Wed Aug 27 10:28:26 2008 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6731685
+ * @summary CertificateFactory.generateCertificates throws IOException on PKCS7 cert chain
+ */
+
+import java.io.*;
+import sun.security.util.*;
+
+public class Indefinite {
+
+ public static void main(String[] args) throws Exception {
+ byte[] input = {
+ // An OCTET-STRING in 2 parts
+ 4, (byte)0x80, 4, 2, 'a', 'b', 4, 2, 'c', 'd', 0, 0,
+ // Garbage follows, may be falsely recognized as EOC
+ 0, 0, 0, 0
+ };
+ new DerValue(new ByteArrayInputStream(input));
+ }
+}