--- a/jdk/make/java/java/FILES_java.gmk Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/make/java/java/FILES_java.gmk Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/make/java/jli/Makefile Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/make/java/jli/mapfile-vers Sun Aug 31 11:59:20 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/nio/FILES_java.gmk Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/make/java/nio/FILES_java.gmk Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/make/java/nio/mapfile-linux Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/bin/emessages.h Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/bin/java.c Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/bin/java.h Sun Aug 31 11:59:20 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/com/sun/tools/hat/internal/parser/HprofReader.java Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/com/sun/tools/hat/internal/parser/HprofReader.java Sun Aug 31 11:59:20 2008 -0700
@@ -120,7 +120,7 @@
private int version; // The version of .hprof being read
private int debugLevel;
- private int currPos; // Current position in the file
+ private long currPos; // Current position in the file
private int dumpsToSkip;
private boolean callStack; // If true, read the call stack of objects
@@ -196,7 +196,9 @@
break;
}
in.readInt(); // Timestamp of this record
- int length = in.readInt();
+ // Length of record: readInt() will return negative value for record
+ // length >2GB. so store 32bit value in long to keep it unsigned.
+ long length = in.readInt() & 0xffffffffL;
if (debugLevel > 0) {
System.out.println("Read record type " + type
+ ", length " + length
@@ -211,7 +213,7 @@
switch (type) {
case HPROF_UTF8: {
long id = readID();
- byte[] chars = new byte[length - identifierSize];
+ byte[] chars = new byte[(int)length - identifierSize];
in.readFully(chars);
names.put(new Long(id), new String(chars));
break;
@@ -351,8 +353,8 @@
return snapshot;
}
- private void skipBytes(int length) throws IOException {
- in.skipBytes(length);
+ private void skipBytes(long length) throws IOException {
+ in.skipBytes((int)length);
}
private int readVersionHeader() throws IOException {
@@ -381,7 +383,7 @@
throw new IOException("Version string not recognized at byte " + (pos+3));
}
- private void readHeapDump(int bytesLeft, int posAtEnd) throws IOException {
+ private void readHeapDump(long bytesLeft, long posAtEnd) throws IOException {
while (bytesLeft > 0) {
int type = in.readUnsignedByte();
if (debugLevel > 0) {
--- a/jdk/src/share/classes/java/lang/Thread.java Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/java/lang/Thread.java Sun Aug 31 11:59:20 2008 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-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,7 +30,6 @@
import java.security.PrivilegedAction;
import java.util.Map;
import java.util.HashMap;
-import java.util.Collections;
import java.util.concurrent.locks.LockSupport;
import sun.misc.SoftCache;
import sun.nio.ch.Interruptible;
@@ -120,6 +119,10 @@
* Every thread has a name for identification purposes. More than
* one thread may have the same name. If a name is not specified when
* a thread is created, a new name is generated for it.
+ * <p>
+ * Unless otherwise noted, passing a {@code null} argument to a constructor
+ * or method in this class will cause a {@link NullPointerException} to be
+ * thrown.
*
* @author unascribed
* @see Runnable
@@ -348,6 +351,10 @@
*/
private void init(ThreadGroup g, Runnable target, String name,
long stackSize) {
+ if (name == null) {
+ throw new NullPointerException("name cannot be null");
+ }
+
Thread parent = currentThread();
SecurityManager security = System.getSecurityManager();
if (g == null) {
@@ -379,7 +386,6 @@
}
}
-
g.addUnstarted();
this.group = g;
@@ -403,160 +409,175 @@
tid = nextThreadID();
}
- /**
- * Allocates a new <code>Thread</code> object. This constructor has
- * the same effect as <code>Thread(null, null,</code>
- * <i>gname</i><code>)</code>, where <b><i>gname</i></b> is
- * a newly generated name. Automatically generated names are of the
- * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
- *
- * @see #Thread(ThreadGroup, Runnable, String)
+ /**
+ * Allocates a new {@code Thread} object. This constructor has the same
+ * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread}
+ * {@code (null, null, gname)}, where {@code gname} is a newly generated
+ * name. Automatically generated names are of the form
+ * {@code "Thread-"+}<i>n</i>, where <i>n</i> is an integer.
*/
public Thread() {
init(null, null, "Thread-" + nextThreadNum(), 0);
}
/**
- * Allocates a new <code>Thread</code> object. This constructor has
- * the same effect as <code>Thread(null, target,</code>
- * <i>gname</i><code>)</code>, where <i>gname</i> is
- * a newly generated name. Automatically generated names are of the
- * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
+ * Allocates a new {@code Thread} object. This constructor has the same
+ * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread}
+ * {@code (null, target, gname)}, where {@code gname} is a newly generated
+ * name. Automatically generated names are of the form
+ * {@code "Thread-"+}<i>n</i>, where <i>n</i> is an integer.
*
- * @param target the object whose <code>run</code> method is called.
- * @see #Thread(ThreadGroup, Runnable, String)
+ * @param target
+ * the object whose {@code run} method is invoked when this thread
+ * is started. If {@code null}, this classes {@code run} method does
+ * nothing.
*/
public Thread(Runnable target) {
init(null, target, "Thread-" + nextThreadNum(), 0);
}
/**
- * Allocates a new <code>Thread</code> object. This constructor has
- * the same effect as <code>Thread(group, target,</code>
- * <i>gname</i><code>)</code>, where <i>gname</i> is
- * a newly generated name. Automatically generated names are of the
- * form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
+ * Allocates a new {@code Thread} object. This constructor has the same
+ * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread}
+ * {@code (group, target, gname)} ,where {@code gname} is a newly generated
+ * name. Automatically generated names are of the form
+ * {@code "Thread-"+}<i>n</i>, where <i>n</i> is an integer.
*
- * @param group the thread group.
- * @param target the object whose <code>run</code> method is called.
- * @exception SecurityException if the current thread cannot create a
- * thread in the specified thread group.
- * @see #Thread(ThreadGroup, Runnable, String)
+ * @param group
+ * the thread group. If {@code null} and there is a security
+ * manager, the group is determined by {@linkplain
+ * SecurityManager#getThreadGroup SecurityManager.getThreadGroup()}.
+ * If there is not a security manager or {@code
+ * SecurityManager.getThreadGroup()} returns {@code null}, the group
+ * is set to the current thread's thread group.
+ *
+ * @param target
+ * the object whose {@code run} method is invoked when this thread
+ * is started. If {@code null}, this thread's run method is invoked.
+ *
+ * @throws SecurityException
+ * if the current thread cannot create a thread in the specified
+ * thread group
*/
public Thread(ThreadGroup group, Runnable target) {
init(group, target, "Thread-" + nextThreadNum(), 0);
}
/**
- * Allocates a new <code>Thread</code> object. This constructor has
- * the same effect as <code>Thread(null, null, name)</code>.
+ * Allocates a new {@code Thread} object. This constructor has the same
+ * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread}
+ * {@code (null, null, name)}.
*
- * @param name the name of the new thread.
- * @see #Thread(ThreadGroup, Runnable, String)
+ * @param name
+ * the name of the new thread
*/
public Thread(String name) {
init(null, null, name, 0);
}
/**
- * Allocates a new <code>Thread</code> object. This constructor has
- * the same effect as <code>Thread(group, null, name)</code>
+ * Allocates a new {@code Thread} object. This constructor has the same
+ * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread}
+ * {@code (group, null, name)}.
*
- * @param group the thread group.
- * @param name the name of the new thread.
- * @exception SecurityException if the current thread cannot create a
- * thread in the specified thread group.
- * @see #Thread(ThreadGroup, Runnable, String)
+ * @param group
+ * the thread group. If {@code null} and there is a security
+ * manager, the group is determined by {@linkplain
+ * SecurityManager#getThreadGroup SecurityManager.getThreadGroup()}.
+ * If there is not a security manager or {@code
+ * SecurityManager.getThreadGroup()} returns {@code null}, the group
+ * is set to the current thread's thread group.
+ *
+ * @param name
+ * the name of the new thread
+ *
+ * @throws SecurityException
+ * if the current thread cannot create a thread in the specified
+ * thread group
*/
public Thread(ThreadGroup group, String name) {
init(group, null, name, 0);
}
/**
- * Allocates a new <code>Thread</code> object. This constructor has
- * the same effect as <code>Thread(null, target, name)</code>.
+ * Allocates a new {@code Thread} object. This constructor has the same
+ * effect as {@linkplain #Thread(ThreadGroup,Runnable,String) Thread}
+ * {@code (null, target, name)}.
*
- * @param target the object whose <code>run</code> method is called.
- * @param name the name of the new thread.
- * @see #Thread(ThreadGroup, Runnable, String)
+ * @param target
+ * the object whose {@code run} method is invoked when this thread
+ * is started. If {@code null}, this thread's run method is invoked.
+ *
+ * @param name
+ * the name of the new thread
*/
public Thread(Runnable target, String name) {
init(null, target, name, 0);
}
/**
- * Allocates a new <code>Thread</code> object so that it has
- * <code>target</code> as its run object, has the specified
- * <code>name</code> as its name, and belongs to the thread group
- * referred to by <code>group</code>.
- * <p>
- * If <code>group</code> is <code>null</code> and there is a
- * security manager, the group is determined by the security manager's
- * <code>getThreadGroup</code> method. If <code>group</code> is
- * <code>null</code> and there is not a security manager, or the
- * security manager's <code>getThreadGroup</code> method returns
- * <code>null</code>, the group is set to be the same ThreadGroup
- * as the thread that is creating the new thread.
+ * Allocates a new {@code Thread} object so that it has {@code target}
+ * as its run object, has the specified {@code name} as its name,
+ * and belongs to the thread group referred to by {@code group}.
*
- * <p>If there is a security manager, its <code>checkAccess</code>
- * method is called with the ThreadGroup as its argument.
- * <p>In addition, its <code>checkPermission</code>
- * method is called with the
- * <code>RuntimePermission("enableContextClassLoaderOverride")</code>
+ * <p>If there is a security manager, its
+ * {@link SecurityManager#checkAccess(ThreadGroup) checkAccess}
+ * method is invoked with the ThreadGroup as its argument.
+ *
+ * <p>In addition, its {@code checkPermission} method is invoked with
+ * the {@code RuntimePermission("enableContextClassLoaderOverride")}
* permission when invoked directly or indirectly by the constructor
- * of a subclass which overrides the <code>getContextClassLoader</code>
- * or <code>setContextClassLoader</code> methods.
- * This may result in a SecurityException.
-
- * <p>
- * If the <code>target</code> argument is not <code>null</code>, the
- * <code>run</code> method of the <code>target</code> is called when
- * this thread is started. If the target argument is
- * <code>null</code>, this thread's <code>run</code> method is called
- * when this thread is started.
- * <p>
- * The priority of the newly created thread is set equal to the
+ * of a subclass which overrides the {@code getContextClassLoader}
+ * or {@code setContextClassLoader} methods.
+ *
+ * <p>The priority of the newly created thread is set equal to the
* priority of the thread creating it, that is, the currently running
- * thread. The method <code>setPriority</code> may be used to
- * change the priority to a new value.
- * <p>
- * The newly created thread is initially marked as being a daemon
+ * thread. The method {@linkplain #setPriority setPriority} may be
+ * used to change the priority to a new value.
+ *
+ * <p>The newly created thread is initially marked as being a daemon
* thread if and only if the thread creating it is currently marked
- * as a daemon thread. The method <code>setDaemon </code> may be used
- * to change whether or not a thread is a daemon.
+ * as a daemon thread. The method {@linkplain #setDaemon setDaemon}
+ * may be used to change whether or not a thread is a daemon.
*
- * @param group the thread group.
- * @param target the object whose <code>run</code> method is called.
- * @param name the name of the new thread.
- * @exception SecurityException if the current thread cannot create a
- * thread in the specified thread group or cannot
- * override the context class loader methods.
- * @see Runnable#run()
- * @see #run()
- * @see #setDaemon(boolean)
- * @see #setPriority(int)
- * @see ThreadGroup#checkAccess()
- * @see SecurityManager#checkAccess
+ * @param group
+ * the thread group. If {@code null} and there is a security
+ * manager, the group is determined by {@linkplain
+ * SecurityManager#getThreadGroup SecurityManager.getThreadGroup()}.
+ * If there is not a security manager or {@code
+ * SecurityManager.getThreadGroup()} returns {@code null}, the group
+ * is set to the current thread's thread group.
+ *
+ * @param target
+ * the object whose {@code run} method is invoked when this thread
+ * is started. If {@code null}, this thread's run method is invoked.
+ *
+ * @param name
+ * the name of the new thread
+ *
+ * @throws SecurityException
+ * if the current thread cannot create a thread in the specified
+ * thread group or cannot override the context class loader methods.
*/
public Thread(ThreadGroup group, Runnable target, String name) {
init(group, target, name, 0);
}
/**
- * Allocates a new <code>Thread</code> object so that it has
- * <code>target</code> as its run object, has the specified
- * <code>name</code> as its name, belongs to the thread group referred to
- * by <code>group</code>, and has the specified <i>stack size</i>.
+ * Allocates a new {@code Thread} object so that it has {@code target}
+ * as its run object, has the specified {@code name} as its name,
+ * and belongs to the thread group referred to by {@code group}, and has
+ * the specified <i>stack size</i>.
*
* <p>This constructor is identical to {@link
* #Thread(ThreadGroup,Runnable,String)} with the exception of the fact
* that it allows the thread stack size to be specified. The stack size
* is the approximate number of bytes of address space that the virtual
* machine is to allocate for this thread's stack. <b>The effect of the
- * <tt>stackSize</tt> parameter, if any, is highly platform dependent.</b>
+ * {@code stackSize} parameter, if any, is highly platform dependent.</b>
*
* <p>On some platforms, specifying a higher value for the
- * <tt>stackSize</tt> parameter may allow a thread to achieve greater
+ * {@code stackSize} parameter may allow a thread to achieve greater
* recursion depth before throwing a {@link StackOverflowError}.
* Similarly, specifying a lower value may allow a greater number of
* threads to exist concurrently without throwing an {@link
@@ -564,9 +585,9 @@
* the relationship between the value of the <tt>stackSize</tt> parameter
* and the maximum recursion depth and concurrency level are
* platform-dependent. <b>On some platforms, the value of the
- * <tt>stackSize</tt> parameter may have no effect whatsoever.</b>
+ * {@code stackSize} parameter may have no effect whatsoever.</b>
*
- * <p>The virtual machine is free to treat the <tt>stackSize</tt>
+ * <p>The virtual machine is free to treat the {@code stackSize}
* parameter as a suggestion. If the specified value is unreasonably low
* for the platform, the virtual machine may instead use some
* platform-specific minimum value; if the specified value is unreasonably
@@ -574,9 +595,9 @@
* maximum. Likewise, the virtual machine is free to round the specified
* value up or down as it sees fit (or to ignore it completely).
*
- * <p>Specifying a value of zero for the <tt>stackSize</tt> parameter will
+ * <p>Specifying a value of zero for the {@code stackSize} parameter will
* cause this constructor to behave exactly like the
- * <tt>Thread(ThreadGroup, Runnable, String)</tt> constructor.
+ * {@code Thread(ThreadGroup, Runnable, String)} constructor.
*
* <p><i>Due to the platform-dependent nature of the behavior of this
* constructor, extreme care should be exercised in its use.
@@ -588,15 +609,32 @@
*
* <p>Implementation note: Java platform implementers are encouraged to
* document their implementation's behavior with respect to the
- * <tt>stackSize parameter</tt>.
+ * {@code stackSize} parameter.
+ *
+ *
+ * @param group
+ * the thread group. If {@code null} and there is a security
+ * manager, the group is determined by {@linkplain
+ * SecurityManager#getThreadGroup SecurityManager.getThreadGroup()}.
+ * If there is not a security manager or {@code
+ * SecurityManager.getThreadGroup()} returns {@code null}, the group
+ * is set to the current thread's thread group.
*
- * @param group the thread group.
- * @param target the object whose <code>run</code> method is called.
- * @param name the name of the new thread.
- * @param stackSize the desired stack size for the new thread, or
- * zero to indicate that this parameter is to be ignored.
- * @exception SecurityException if the current thread cannot create a
- * thread in the specified thread group.
+ * @param target
+ * the object whose {@code run} method is invoked when this thread
+ * is started. If {@code null}, this thread's run method is invoked.
+ *
+ * @param name
+ * the name of the new thread
+ *
+ * @param stackSize
+ * the desired stack size for the new thread, or zero to indicate
+ * that this parameter is to be ignored.
+ *
+ * @throws SecurityException
+ * if the current thread cannot create a thread in the specified
+ * thread group
+ *
* @since 1.4
*/
public Thread(ThreadGroup group, Runnable target, String name,
@@ -669,6 +707,7 @@
* @see #stop()
* @see #Thread(ThreadGroup, Runnable, String)
*/
+ @Override
public void run() {
if (target != null) {
target.run();
@@ -1386,28 +1425,25 @@
* Returns the context ClassLoader for this Thread. The context
* ClassLoader is provided by the creator of the thread for use
* by code running in this thread when loading classes and resources.
- * If not set, the default is the ClassLoader context of the parent
- * Thread. The context ClassLoader of the primordial thread is
- * typically set to the class loader used to load the application.
+ * If not {@linkplain #setContextClassLoader set}, the default is the
+ * ClassLoader context of the parent Thread. The context ClassLoader of the
+ * primordial thread is typically set to the class loader used to load the
+ * application.
*
- * <p>First, if there is a security manager, and the caller's class
- * loader is not null and the caller's class loader is not the same as or
- * an ancestor of the context class loader for the thread whose
- * context class loader is being requested, then the security manager's
- * <code>checkPermission</code>
- * method is called with a
- * <code>RuntimePermission("getClassLoader")</code> permission
- * to see if it's ok to get the context ClassLoader..
+ * <p>If a security manager is present, and the invoker's class loader is not
+ * {@code null} and is not the same as or an ancestor of the context class
+ * loader, then this method invokes the security manager's {@link
+ * SecurityManager#checkPermission(java.security.Permission) checkPermission}
+ * method with a {@link RuntimePermission RuntimePermission}{@code
+ * ("getClassLoader")} permission to verify that retrieval of the context
+ * class loader is permitted.
*
- * @return the context ClassLoader for this Thread
+ * @return the context ClassLoader for this Thread, or {@code null}
+ * indicating the system class loader (or, failing that, the
+ * bootstrap class loader)
*
- * @throws SecurityException
- * if a security manager exists and its
- * <code>checkPermission</code> method doesn't allow
- * getting the context ClassLoader.
- * @see #setContextClassLoader
- * @see SecurityManager#checkPermission
- * @see RuntimePermission
+ * @throws SecurityException
+ * if the current thread cannot get the context ClassLoader
*
* @since 1.2
*/
@@ -1428,21 +1464,22 @@
/**
* Sets the context ClassLoader for this Thread. The context
* ClassLoader can be set when a thread is created, and allows
- * the creator of the thread to provide the appropriate class loader
- * to code running in the thread when loading classes and resources.
- *
- * <p>First, if there is a security manager, its <code>checkPermission</code>
- * method is called with a
- * <code>RuntimePermission("setContextClassLoader")</code> permission
- * to see if it's ok to set the context ClassLoader..
+ * the creator of the thread to provide the appropriate class loader,
+ * through {@code getContextClassLoader}, to code running in the thread
+ * when loading classes and resources.
*
- * @param cl the context ClassLoader for this Thread
+ * <p>If a security manager is present, its {@link
+ * SecurityManager#checkPermission(java.security.Permission) checkPermission}
+ * method is invoked with a {@link RuntimePermission RuntimePermission}{@code
+ * ("setContextClassLoader")} permission to see if setting the context
+ * ClassLoader is permitted.
*
- * @exception SecurityException if the current thread cannot set the
- * context ClassLoader.
- * @see #getContextClassLoader
- * @see SecurityManager#checkPermission
- * @see RuntimePermission
+ * @param cl
+ * the context ClassLoader for this Thread, or null indicating the
+ * system class loader (or, failing that, the bootstrap class loader)
+ *
+ * @throws SecurityException
+ * if the current thread cannot set the context ClassLoader
*
* @since 1.2
*/
--- a/jdk/src/share/classes/java/lang/management/PlatformComponent.java Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/java/lang/management/PlatformComponent.java Sun Aug 31 11:59:20 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/nio/Bits.java Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/java/nio/Bits.java Sun Aug 31 11:59:20 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 Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/java/nio/Direct-X-Buffer.java Sun Aug 31 11:59:20 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/java/nio/charset/Charset.java Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/java/nio/charset/Charset.java Sun Aug 31 11:59:20 2008 -0700
@@ -85,6 +85,9 @@
* <li> The dash character <tt>'-'</tt>
* (<tt>'\u002d'</tt>, <small>HYPHEN-MINUS</small>),
*
+ * <li> The plus character <tt>'+'</tt>
+ * (<tt>'\u002b'</tt>, <small>PLUS SIGN</small>),
+ *
* <li> The period character <tt>'.'</tt>
* (<tt>'\u002e'</tt>, <small>FULL STOP</small>),
*
@@ -307,6 +310,7 @@
if (c >= 'a' && c <= 'z') continue;
if (c >= '0' && c <= '9') continue;
if (c == '-' && i != 0) continue;
+ if (c == '+' && i != 0) continue;
if (c == ':' && i != 0) continue;
if (c == '_' && i != 0) continue;
if (c == '.' && i != 0) continue;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/misc/JavaNioAccess.java Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java Sun Aug 31 11:59:20 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/nio/cs/ext/ExtendedCharsets.java Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java Sun Aug 31 11:59:20 2008 -0700
@@ -916,7 +916,7 @@
"ccsid01140",
"cp01140",
"1140",
- // "ebcdic-us-037+euro"
+ "ebcdic-us-037+euro"
});
charset("IBM01141", "IBM1141",
@@ -925,7 +925,7 @@
"ccsid01141",
"cp01141",
"1141",
- // "ebcdic-de-273+euro"
+ "ebcdic-de-273+euro"
});
charset("IBM01142", "IBM1142",
@@ -934,8 +934,8 @@
"ccsid01142",
"cp01142",
"1142",
- // "ebcdic-no-277+euro",
- // "ebcdic-dk-277+euro"
+ "ebcdic-no-277+euro",
+ "ebcdic-dk-277+euro"
});
charset("IBM01143", "IBM1143",
@@ -944,8 +944,8 @@
"ccsid01143",
"cp01143",
"1143",
- // "ebcdic-fi-278+euro",
- // "ebcdic-se-278+euro"
+ "ebcdic-fi-278+euro",
+ "ebcdic-se-278+euro"
});
charset("IBM01144", "IBM1144",
@@ -954,7 +954,7 @@
"ccsid01144",
"cp01144",
"1144",
- // "ebcdic-it-280+euro"
+ "ebcdic-it-280+euro"
});
charset("IBM01145", "IBM1145",
@@ -963,7 +963,7 @@
"ccsid01145",
"cp01145",
"1145",
- // "ebcdic-es-284+euro"
+ "ebcdic-es-284+euro"
});
charset("IBM01146", "IBM1146",
@@ -972,7 +972,7 @@
"ccsid01146",
"cp01146",
"1146",
- // "ebcdic-gb-285+euro"
+ "ebcdic-gb-285+euro"
});
charset("IBM01147", "IBM1147",
@@ -981,7 +981,7 @@
"ccsid01147",
"cp01147",
"1147",
- // "ebcdic-fr-277+euro"
+ "ebcdic-fr-277+euro"
});
charset("IBM01148", "IBM1148",
@@ -990,7 +990,7 @@
"ccsid01148",
"cp01148",
"1148",
- // "ebcdic-international-500+euro"
+ "ebcdic-international-500+euro"
});
charset("IBM01149", "IBM1149",
@@ -999,7 +999,7 @@
"ccsid01149",
"cp01149",
"1149",
- // "ebcdic-s-871+euro"
+ "ebcdic-s-871+euro"
});
// Macintosh MacOS/Apple char encodingd
--- a/jdk/src/share/classes/sun/nio/cs/standard-charsets Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/sun/nio/cs/standard-charsets Sun Aug 31 11:59:20 2008 -0700
@@ -314,6 +314,7 @@
alias ccsid00858
alias cp00858
alias 858
+ alias PC-Multilingual-850+euro
charset IBM862 IBM862
alias cp862 #JDK historical
--- a/jdk/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/share/classes/sun/reflect/generics/factory/CoreReflectionFactory.java Sun Aug 31 11:59:20 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/solaris/bin/java_md.c Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/solaris/bin/java_md.c Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java Sun Aug 31 11:59:20 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/sun/nio/ch/EPollArrayWrapper.c Wed Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/solaris/native/sun/nio/ch/EPollArrayWrapper.c Sun Aug 31 11:59:20 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 Jul 05 16:41:01 2017 +0200
+++ b/jdk/src/windows/bin/java_md.c Sun Aug 31 11:59:20 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;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ThreadGroup/NullThreadName.java Sun Aug 31 11:59:20 2008 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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 6576763
+ * @summary (thread) Thread constructors throw undocumented NPE for null name
+ */
+
+/*
+ * Verify that threads constructed with a null thread name do not get added
+ * to the list of unstarted thread for a thread group. We can do this by
+ * checking that a daemon threadGroup is desroyed after its final valid thread
+ * has completed.
+ */
+
+import java.util.concurrent.CountDownLatch;
+import static java.lang.System.out;
+
+public class NullThreadName
+{
+ static CountDownLatch done = new CountDownLatch(1);
+
+ public static void main(String args[]) throws Exception {
+ ThreadGroup tg = new ThreadGroup("chegar-threads");
+ Thread goodThread = new Thread(tg, new GoodThread(), "goodThread");
+ try {
+ Thread badThread = new Thread(tg, new Runnable(){
+ @Override
+ public void run() {} }, null);
+ } catch (NullPointerException npe) {
+ out.println("OK, caught expected " + npe);
+ }
+ tg.setDaemon(true);
+ goodThread.start();
+
+ done.await();
+
+ int count = 0;
+ while (goodThread.isAlive()) {
+ /* Hold off a little to allow the thread to complete */
+ out.println("GoodThread still alive, sleeping...");
+ try { Thread.sleep(2000); }
+ catch (InterruptedException unused) {}
+
+ /* do not wait forever */
+ if (count++ > 5)
+ throw new AssertionError("GoodThread is still alive!");
+ }
+
+ if (!tg.isDestroyed()) {
+ throw new AssertionError("Failed: Thread group is not destroyed.");
+ }
+ }
+
+ static class GoodThread implements Runnable
+ {
+ @Override
+ public void run() {
+ out.println("Good Thread started...");
+ out.println("Good Thread finishing");
+ done.countDown();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java Sun Aug 31 11:59:20 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/nio/BufferPoolMXBean/Basic.java Sun Aug 31 11:59:20 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/nio/cs/CheckICNE.java Sun Aug 31 11:59:20 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 4849617
+ @summary Checks "+" is a legal character for charset name
+ */
+import java.nio.charset.*;
+
+public class CheckICNE {
+ static int failed = 0;
+ public static void main (String[] args) throws Exception {
+ try {
+ Charset.forName("abc+");
+ } catch (UnsupportedCharsetException uce) {}
+
+ try {
+ java.nio.charset.Charset.forName("+abc");
+ } catch (IllegalCharsetNameException icne) {}
+
+ String[] euros = {"PC-Multilingual-850+euro",
+ "ebcdic-us-037+euro",
+ "ebcdic-de-273+euro",
+ "ebcdic-no-277+euro",
+ "ebcdic-dk-277+euro",
+ "ebcdic-fi-278+euro",
+ "ebcdic-se-278+euro",
+ "ebcdic-it-280+euro",
+ "ebcdic-es-284+euro",
+ "ebcdic-gb-285+euro",
+ "ebcdic-fr-277+euro",
+ "ebcdic-international-500+euro",
+ "ebcdic-s-871+euro"
+ };
+
+ System.out.println("Test Passed!");
+ }
+}