From 8bb6a4e5840d869f44d3ff4a1bc01e7238924278 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Wed, 29 Jan 2014 20:41:33 +0100 Subject: [PATCH 01/30] 8033154: PPC64: Fix AIX build after integration into jdk9/dev Reviewed-by: alanb --- jdk/make/lib/NioLibraries.gmk | 2 +- .../aix/native/sun/nio/ch/AixNativeThread.c | 76 +++++++++++++++++++ jdk/src/share/lib/security/java.security-aix | 9 ++- .../solaris/classes/sun/net/PortConfig.java | 8 ++ jdk/src/solaris/native/sun/nio/ch/Net.c | 12 +++ 5 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 jdk/src/aix/native/sun/nio/ch/AixNativeThread.c diff --git a/jdk/make/lib/NioLibraries.gmk b/jdk/make/lib/NioLibraries.gmk index 5c648c2dbe6..6c9c46a3f3d 100644 --- a/jdk/make/lib/NioLibraries.gmk +++ b/jdk/make/lib/NioLibraries.gmk @@ -120,7 +120,7 @@ ifeq ($(OPENJDK_TARGET_OS), aix) BUILD_LIBNIO_FILES += \ AixPollPort.c \ InheritedChannel.c \ - NativeThread.c \ + AixNativeThread.c \ PollArrayWrapper.c \ UnixAsynchronousServerSocketChannelImpl.c \ UnixAsynchronousSocketChannelImpl.c \ diff --git a/jdk/src/aix/native/sun/nio/ch/AixNativeThread.c b/jdk/src/aix/native/sun/nio/ch/AixNativeThread.c new file mode 100644 index 00000000000..c0d5857962a --- /dev/null +++ b/jdk/src/aix/native/sun/nio/ch/AixNativeThread.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include +#include +#include "jni.h" +#include "jni_util.h" +#include "jvm.h" +#include "jlong.h" +#include "sun_nio_ch_NativeThread.h" + +#include +#include + +/* Also defined in src/aix/native/java/net/aix_close.c */ +#define INTERRUPT_SIGNAL (SIGRTMAX - 1) + +static void +nullHandler(int sig) +{ +} + + +JNIEXPORT void JNICALL +Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl) +{ + /* Install the null handler for INTERRUPT_SIGNAL. This might overwrite the + * handler previously installed by java/net/aix_close.c, but that's okay + * since neither handler actually does anything. We install our own + * handler here simply out of paranoia; ultimately the two mechanisms + * should somehow be unified, perhaps within the VM. + */ + + sigset_t ss; + struct sigaction sa, osa; + sa.sa_handler = nullHandler; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0) + JNU_ThrowIOExceptionWithLastError(env, "sigaction"); +} + +JNIEXPORT jlong JNICALL +Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl) +{ + return (long)pthread_self(); +} + +JNIEXPORT void JNICALL +Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread) +{ + if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL)) + JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed"); +} diff --git a/jdk/src/share/lib/security/java.security-aix b/jdk/src/share/lib/security/java.security-aix index fd49537f609..2734cb43a90 100644 --- a/jdk/src/share/lib/security/java.security-aix +++ b/jdk/src/share/lib/security/java.security-aix @@ -182,6 +182,7 @@ package.access=sun.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ com.sun.media.sound.,\ + com.sun.naming.internal.,\ com.sun.proxy.,\ com.sun.corba.se.,\ com.sun.org.apache.bcel.internal.,\ @@ -205,7 +206,7 @@ package.access=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ + oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ @@ -228,6 +229,7 @@ package.definition=sun.,\ com.sun.istack.internal.,\ com.sun.jmx.,\ com.sun.media.sound.,\ + com.sun.naming.internal.,\ com.sun.proxy.,\ com.sun.corba.se.,\ com.sun.org.apache.bcel.internal.,\ @@ -251,7 +253,7 @@ package.definition=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ + oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ @@ -470,7 +472,7 @@ krb5.kdc.bad.policy = tryLast # jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 # # -jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024 +jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 # Algorithm restrictions for Secure Socket Layer/Transport Layer Security # (SSL/TLS) processing @@ -494,4 +496,3 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024 # # Example: # jdk.tls.disabledAlgorithms=MD5, SHA1, DSA, RSA keySize < 2048 - diff --git a/jdk/src/solaris/classes/sun/net/PortConfig.java b/jdk/src/solaris/classes/sun/net/PortConfig.java index 0f4ca744257..1825b0b59a0 100644 --- a/jdk/src/solaris/classes/sun/net/PortConfig.java +++ b/jdk/src/solaris/classes/sun/net/PortConfig.java @@ -55,6 +55,14 @@ public final class PortConfig { } else if (os.contains("OS X")) { defaultLower = 49152; defaultUpper = 65535; + } else if (os.startsWith("AIX")) { + // The ephemeral port is OS version dependent on AIX: + // http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.rsct315.admin/bl503_ephport.htm + // However, on AIX 5.3 / 6.1 / 7.1 we always see the + // settings below by using: + // /usr/sbin/no -a | fgrep ephemeral + defaultLower = 32768; + defaultUpper = 65535; } else { throw new InternalError( "sun.net.PortConfig: unknown OS"); diff --git a/jdk/src/solaris/native/sun/nio/ch/Net.c b/jdk/src/solaris/native/sun/nio/ch/Net.c index 4bb21396036..92f6f19a43e 100644 --- a/jdk/src/solaris/native/sun/nio/ch/Net.c +++ b/jdk/src/solaris/native/sun/nio/ch/Net.c @@ -78,6 +78,18 @@ #define MCAST_UNBLOCK_SOURCE 65 #define MCAST_JOIN_SOURCE_GROUP 66 #define MCAST_LEAVE_SOURCE_GROUP 67 + + /* This means we're on AIX 5.3 and 'group_source_req' and 'ip_mreq_source' aren't defined as well */ + struct group_source_req { + uint32_t gsr_interface; + struct sockaddr_storage gsr_group; + struct sockaddr_storage gsr_source; + }; + struct ip_mreq_source { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_sourceaddr; /* IP address of source */ + struct in_addr imr_interface; /* local IP address of interface */ + }; #endif #endif /* _AIX */ From 1754033d0285873062a8e55d568ae1f93a8e3848 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 6 Feb 2014 10:43:09 +0000 Subject: [PATCH 02/30] 8033758: gcc warnings compiling jdk/src/share/back Reviewed-by: dholmes, sla --- jdk/src/share/back/ArrayTypeImpl.c | 2 +- jdk/src/share/back/error_messages.c | 2 +- jdk/src/share/back/util.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/back/ArrayTypeImpl.c b/jdk/src/share/back/ArrayTypeImpl.c index 1f3a312a8f3..1d3813cec9e 100644 --- a/jdk/src/share/back/ArrayTypeImpl.c +++ b/jdk/src/share/back/ArrayTypeImpl.c @@ -112,7 +112,7 @@ writeNewObjectArray(JNIEnv *env, PacketOutputStream *out, WITH_LOCAL_REFS(env, 1) { jarray array; - jclass componentClass; + jclass componentClass = NULL; jdwpError serror; serror = getComponentClass(env, arrayClass, diff --git a/jdk/src/share/back/error_messages.c b/jdk/src/share/back/error_messages.c index 2ec5bbfa2e5..d6207965497 100644 --- a/jdk/src/share/back/error_messages.c +++ b/jdk/src/share/back/error_messages.c @@ -140,7 +140,7 @@ jdiAssertionFailed(char *fileName, int lineNumber, char *msg) const char * jvmtiErrorText(jvmtiError error) { - switch (error) { + switch ((int)error) { CASE_RETURN_TEXT(JVMTI_ERROR_NONE) CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD) CASE_RETURN_TEXT(JVMTI_ERROR_INVALID_THREAD_GROUP) diff --git a/jdk/src/share/back/util.c b/jdk/src/share/back/util.c index 40cca3c0fe8..b5975b3e817 100644 --- a/jdk/src/share/back/util.c +++ b/jdk/src/share/back/util.c @@ -2122,7 +2122,7 @@ jvmti2EventIndex(jvmtiEvent kind) jdwpError map2jdwpError(jvmtiError error) { - switch ( error ) { + switch ( (int)error ) { case JVMTI_ERROR_NONE: return JDWP_ERROR(NONE); case AGENT_ERROR_INVALID_THREAD: From 591146122883b0cae0ee8069bae65f836813d01a Mon Sep 17 00:00:00 2001 From: Vinnie Ryan Date: Thu, 6 Feb 2014 12:24:42 +0000 Subject: [PATCH 03/30] 8033757: Redo JDK-8011983 (due to bad merge with JDK-8031586) Reviewed-by: alanb --- .../native/com/sun/security/auth/module/nt.c | 112 ++++++++---------- 1 file changed, 50 insertions(+), 62 deletions(-) diff --git a/jdk/src/windows/native/com/sun/security/auth/module/nt.c b/jdk/src/windows/native/com/sun/security/auth/module/nt.c index 72c0ef84f33..03a5c7afeb0 100644 --- a/jdk/src/windows/native/com/sun/security/auth/module/nt.c +++ b/jdk/src/windows/native/com/sun/security/auth/module/nt.c @@ -43,6 +43,12 @@ BOOL getImpersonationToken(PHANDLE impersonationToken); BOOL getTextualSid(PSID pSid, LPTSTR TextualSid, LPDWORD lpdwBufferLen); void DisplayErrorText(DWORD dwLastError); +static void throwIllegalArgumentException(JNIEnv *env, const char *msg) { + jclass clazz = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (clazz != NULL) + (*env)->ThrowNew(env, clazz, msg); +} + JNIEXPORT jlong JNICALL Java_com_sun_security_auth_module_NTSystem_getImpersonationToken0 (JNIEnv *env, jobject obj) { @@ -62,7 +68,6 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent long i, j = 0; HANDLE tokenHandle = INVALID_HANDLE_VALUE; - BOOL systemError = FALSE; LPTSTR userName = NULL; // user name LPTSTR userSid = NULL; // user sid @@ -116,70 +121,59 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent fid = (*env)->GetFieldID(env, cls, "userName", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - // Unable to find exception class - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: userName"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: userName"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, userName); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); fid = (*env)->GetFieldID(env, cls, "userSID", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: userSID"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: userSID"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, userSid); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); fid = (*env)->GetFieldID(env, cls, "domain", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: domain"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: domain"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, domainName); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); if (domainSid != NULL) { fid = (*env)->GetFieldID(env, cls, "domainSID", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: domainSID"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: domainSID"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, domainSid); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); } fid = (*env)->GetFieldID(env, cls, "primaryGroupID", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: PrimaryGroupID"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: PrimaryGroupID"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, primaryGroup); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); // primary group may or may not be part of supplementary groups @@ -204,19 +198,14 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent fid = (*env)->GetFieldID(env, cls, "groupIDs", "[Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: groupIDs"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "groupIDs"); + goto cleanup; } stringClass = (*env)->FindClass(env, "java/lang/String"); - if (stringClass == 0) { - goto out; - } + if (stringClass == NULL) + goto cleanup; if (pIndex == -1) { // primary group not in groups array @@ -226,6 +215,8 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent // allocate one less array entry and do not add into new array jgroups = (*env)->NewObjectArray(env, numGroups-1, stringClass, 0); } + if (jgroups == NULL) + goto cleanup; for (i = 0, j = 0; i < (long)numGroups; i++) { if (pIndex == i) { @@ -233,12 +224,14 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent continue; } jstr = (*env)->NewStringUTF(env, groups[i]); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectArrayElement(env, jgroups, j++, jstr); } (*env)->SetObjectField(env, obj, fid, jgroups); } -out: +cleanup: if (userName != NULL) { HeapFree(GetProcessHeap(), 0, userName); } @@ -264,11 +257,6 @@ out: } CloseHandle(tokenHandle); - if (systemError && debug) { - printf(" [getCurrent] System Error: "); - printf("unable to find IllegalArgumentException class\n"); - } - return; } @@ -336,7 +324,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -369,7 +357,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -411,7 +399,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } // ok not to have a domain SID (no error) - goto out; + goto cleanup; } bufSize = 0; @@ -422,7 +410,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, printf(" [getUser] domainSid: %s\n", *domainSid); } -out: +cleanup: if (tokenUserInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenUserInfo); } @@ -466,7 +454,7 @@ BOOL getPrimaryGroup(HANDLE tokenHandle, LPTSTR *primaryGroup) { DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -481,7 +469,7 @@ BOOL getPrimaryGroup(HANDLE tokenHandle, LPTSTR *primaryGroup) { printf(" [getPrimaryGroup] primaryGroup: %s\n", *primaryGroup); } -out: +cleanup: if (tokenGroupInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenGroupInfo); } @@ -519,7 +507,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -528,7 +516,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { if (tokenGroupInfo->GroupCount == 0) { // no groups - goto out; + goto cleanup; } // return group info @@ -545,7 +533,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { } } -out: +cleanup: if (tokenGroupInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenGroupInfo); } From 2ffde4a99337600f90ce0815a2e7f72be6788aba Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 6 Feb 2014 14:45:12 +0000 Subject: [PATCH 04/30] 8033778: ObjectIn/OutputStream improvements Co-authored-by: Robert Stupp Reviewed-by: smarks, psandoz, mduigou, plevart --- .../classes/java/io/ObjectInputStream.java | 50 ++++++------ .../classes/java/io/ObjectOutputStream.java | 54 +++++++------ .../classes/java/io/ObjectStreamClass.java | 81 +++++++++++-------- .../classes/java/io/ObjectStreamField.java | 41 +--------- .../java/io/SerialCallbackContext.java | 2 +- 5 files changed, 107 insertions(+), 121 deletions(-) diff --git a/jdk/src/share/classes/java/io/ObjectInputStream.java b/jdk/src/share/classes/java/io/ObjectInputStream.java index 15ecd9bee65..e662270bdb7 100644 --- a/jdk/src/share/classes/java/io/ObjectInputStream.java +++ b/jdk/src/share/classes/java/io/ObjectInputStream.java @@ -39,7 +39,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicBoolean; import static java.io.ObjectStreamClass.processQueue; import sun.reflect.misc.ReflectUtil; @@ -534,7 +533,7 @@ public class ObjectInputStream if (ctx == null) { throw new NotActiveException("not in call to readObject"); } - Object curObj = ctx.getObj(); + ctx.checkAndSetUsed(); ObjectStreamClass curDesc = ctx.getDesc(); bin.setBlockDataMode(false); GetFieldImpl getField = new GetFieldImpl(curDesc); @@ -1597,7 +1596,7 @@ public class ObjectInputStream int descHandle = handles.assign(unshared ? unsharedMarker : desc); passHandle = NULL_HANDLE; - ObjectStreamClass readDesc = null; + ObjectStreamClass readDesc; try { readDesc = readClassDescriptor(); } catch (ClassNotFoundException ex) { @@ -1976,29 +1975,34 @@ public class ObjectInputStream } int primDataSize = desc.getPrimDataSize(); - if (primVals == null || primVals.length < primDataSize) { - primVals = new byte[primDataSize]; - } - bin.readFully(primVals, 0, primDataSize, false); - if (obj != null) { - desc.setPrimFieldValues(obj, primVals); - } - - int objHandle = passHandle; - ObjectStreamField[] fields = desc.getFields(false); - Object[] objVals = new Object[desc.getNumObjFields()]; - int numPrimFields = fields.length - objVals.length; - for (int i = 0; i < objVals.length; i++) { - ObjectStreamField f = fields[numPrimFields + i]; - objVals[i] = readObject0(f.isUnshared()); - if (f.getField() != null) { - handles.markDependency(objHandle, passHandle); + if (primDataSize > 0) { + if (primVals == null || primVals.length < primDataSize) { + primVals = new byte[primDataSize]; + } + bin.readFully(primVals, 0, primDataSize, false); + if (obj != null) { + desc.setPrimFieldValues(obj, primVals); } } - if (obj != null) { - desc.setObjFieldValues(obj, objVals); + + int numObjFields = desc.getNumObjFields(); + if (numObjFields > 0) { + int objHandle = passHandle; + ObjectStreamField[] fields = desc.getFields(false); + Object[] objVals = new Object[numObjFields]; + int numPrimFields = fields.length - objVals.length; + for (int i = 0; i < objVals.length; i++) { + ObjectStreamField f = fields[numPrimFields + i]; + objVals[i] = readObject0(f.isUnshared()); + if (f.getField() != null) { + handles.markDependency(objHandle, passHandle); + } + } + if (obj != null) { + desc.setObjFieldValues(obj, objVals); + } + passHandle = objHandle; } - passHandle = objHandle; } /** diff --git a/jdk/src/share/classes/java/io/ObjectOutputStream.java b/jdk/src/share/classes/java/io/ObjectOutputStream.java index 612bb4eb16b..ac75a017626 100644 --- a/jdk/src/share/classes/java/io/ObjectOutputStream.java +++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java @@ -35,7 +35,6 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import static java.io.ObjectStreamClass.processQueue; -import java.io.SerialCallbackContext; import sun.reflect.misc.ReflectUtil; /** @@ -458,7 +457,7 @@ public class ObjectOutputStream if (ctx == null) { throw new NotActiveException("not in call to writeObject"); } - Object curObj = ctx.getObj(); + ctx.checkAndSetUsed(); ObjectStreamClass curDesc = ctx.getDesc(); curPut = new PutFieldImpl(curDesc); } @@ -1527,29 +1526,34 @@ public class ObjectOutputStream desc.checkDefaultSerialize(); int primDataSize = desc.getPrimDataSize(); - if (primVals == null || primVals.length < primDataSize) { - primVals = new byte[primDataSize]; - } - desc.getPrimFieldValues(obj, primVals); - bout.write(primVals, 0, primDataSize, false); - - ObjectStreamField[] fields = desc.getFields(false); - Object[] objVals = new Object[desc.getNumObjFields()]; - int numPrimFields = fields.length - objVals.length; - desc.getObjFieldValues(obj, objVals); - for (int i = 0; i < objVals.length; i++) { - if (extendedDebugInfo) { - debugInfoStack.push( - "field (class \"" + desc.getName() + "\", name: \"" + - fields[numPrimFields + i].getName() + "\", type: \"" + - fields[numPrimFields + i].getType() + "\")"); + if (primDataSize > 0) { + if (primVals == null || primVals.length < primDataSize) { + primVals = new byte[primDataSize]; } - try { - writeObject0(objVals[i], - fields[numPrimFields + i].isUnshared()); - } finally { + desc.getPrimFieldValues(obj, primVals); + bout.write(primVals, 0, primDataSize, false); + } + + int numObjFields = desc.getNumObjFields(); + if (numObjFields > 0) { + ObjectStreamField[] fields = desc.getFields(false); + Object[] objVals = new Object[numObjFields]; + int numPrimFields = fields.length - objVals.length; + desc.getObjFieldValues(obj, objVals); + for (int i = 0; i < objVals.length; i++) { if (extendedDebugInfo) { - debugInfoStack.pop(); + debugInfoStack.push( + "field (class \"" + desc.getName() + "\", name: \"" + + fields[numPrimFields + i].getName() + "\", type: \"" + + fields[numPrimFields + i].getType() + "\")"); + } + try { + writeObject0(objVals[i], + fields[numPrimFields + i].isUnshared()); + } finally { + if (extendedDebugInfo) { + debugInfoStack.pop(); + } } } } @@ -2464,7 +2468,9 @@ public class ObjectOutputStream StringBuilder buffer = new StringBuilder(); if (!stack.isEmpty()) { for(int i = stack.size(); i > 0; i-- ) { - buffer.append(stack.get(i-1) + ((i != 1) ? "\n" : "")); + buffer.append(stack.get(i - 1)); + if (i != 1) + buffer.append('\n'); } } return buffer.toString(); diff --git a/jdk/src/share/classes/java/io/ObjectStreamClass.java b/jdk/src/share/classes/java/io/ObjectStreamClass.java index 5667690a749..0ae46f05de3 100644 --- a/jdk/src/share/classes/java/io/ObjectStreamClass.java +++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java @@ -1471,43 +1471,56 @@ public class ObjectStreamClass implements Serializable { return name1.equals(name2); } + /** + * Returns JVM type signature for given primitive. + */ + private static String getPrimitiveSignature(Class cl) { + if (cl == Integer.TYPE) + return "I"; + else if (cl == Byte.TYPE) + return "B"; + else if (cl == Long.TYPE) + return "J"; + else if (cl == Float.TYPE) + return "F"; + else if (cl == Double.TYPE) + return "D"; + else if (cl == Short.TYPE) + return "S"; + else if (cl == Character.TYPE) + return "C"; + else if (cl == Boolean.TYPE) + return "Z"; + else if (cl == Void.TYPE) + return "V"; + else + throw new InternalError(); + } + /** * Returns JVM type signature for given class. */ - private static String getClassSignature(Class cl) { - StringBuilder sbuf = new StringBuilder(); - while (cl.isArray()) { - sbuf.append('['); - cl = cl.getComponentType(); - } - if (cl.isPrimitive()) { - if (cl == Integer.TYPE) { - sbuf.append('I'); - } else if (cl == Byte.TYPE) { - sbuf.append('B'); - } else if (cl == Long.TYPE) { - sbuf.append('J'); - } else if (cl == Float.TYPE) { - sbuf.append('F'); - } else if (cl == Double.TYPE) { - sbuf.append('D'); - } else if (cl == Short.TYPE) { - sbuf.append('S'); - } else if (cl == Character.TYPE) { - sbuf.append('C'); - } else if (cl == Boolean.TYPE) { - sbuf.append('Z'); - } else if (cl == Void.TYPE) { - sbuf.append('V'); - } else { - throw new InternalError(); - } - } else { - sbuf.append('L' + cl.getName().replace('.', '/') + ';'); - } - return sbuf.toString(); + static String getClassSignature(Class cl) { + if (cl.isPrimitive()) + return getPrimitiveSignature(cl); + else + return appendClassSignature(new StringBuilder(), cl).toString(); } + private static StringBuilder appendClassSignature(StringBuilder sbuf, Class cl) { + while (cl.isArray()) { + sbuf.append('['); + cl = cl.getComponentType(); + } + + if (cl.isPrimitive()) + sbuf.append(getPrimitiveSignature(cl)); + else + sbuf.append('L').append(cl.getName().replace('.', '/')).append(';'); + + return sbuf; + } + /** * Returns JVM type signature for given list of parameters and return type. */ @@ -1517,10 +1530,10 @@ public class ObjectStreamClass implements Serializable { StringBuilder sbuf = new StringBuilder(); sbuf.append('('); for (int i = 0; i < paramTypes.length; i++) { - sbuf.append(getClassSignature(paramTypes[i])); + appendClassSignature(sbuf, paramTypes[i]); } sbuf.append(')'); - sbuf.append(getClassSignature(retType)); + appendClassSignature(sbuf, retType); return sbuf.toString(); } diff --git a/jdk/src/share/classes/java/io/ObjectStreamField.java b/jdk/src/share/classes/java/io/ObjectStreamField.java index 981e4ba8ca2..f77c312da74 100644 --- a/jdk/src/share/classes/java/io/ObjectStreamField.java +++ b/jdk/src/share/classes/java/io/ObjectStreamField.java @@ -91,7 +91,7 @@ public class ObjectStreamField this.name = name; this.type = type; this.unshared = unshared; - signature = getClassSignature(type).intern(); + signature = ObjectStreamClass.getClassSignature(type).intern(); field = null; } @@ -137,7 +137,7 @@ public class ObjectStreamField name = field.getName(); Class ftype = field.getType(); type = (showType || ftype.isPrimitive()) ? ftype : Object.class; - signature = getClassSignature(ftype).intern(); + signature = ObjectStreamClass.getClassSignature(ftype).intern(); } /** @@ -286,41 +286,4 @@ public class ObjectStreamField String getSignature() { return signature; } - - /** - * Returns JVM type signature for given class. - */ - private static String getClassSignature(Class cl) { - StringBuilder sbuf = new StringBuilder(); - while (cl.isArray()) { - sbuf.append('['); - cl = cl.getComponentType(); - } - if (cl.isPrimitive()) { - if (cl == Integer.TYPE) { - sbuf.append('I'); - } else if (cl == Byte.TYPE) { - sbuf.append('B'); - } else if (cl == Long.TYPE) { - sbuf.append('J'); - } else if (cl == Float.TYPE) { - sbuf.append('F'); - } else if (cl == Double.TYPE) { - sbuf.append('D'); - } else if (cl == Short.TYPE) { - sbuf.append('S'); - } else if (cl == Character.TYPE) { - sbuf.append('C'); - } else if (cl == Boolean.TYPE) { - sbuf.append('Z'); - } else if (cl == Void.TYPE) { - sbuf.append('V'); - } else { - throw new InternalError(); - } - } else { - sbuf.append('L' + cl.getName().replace('.', '/') + ';'); - } - return sbuf.toString(); - } } diff --git a/jdk/src/share/classes/java/io/SerialCallbackContext.java b/jdk/src/share/classes/java/io/SerialCallbackContext.java index 748d38edb36..15c36b02dee 100644 --- a/jdk/src/share/classes/java/io/SerialCallbackContext.java +++ b/jdk/src/share/classes/java/io/SerialCallbackContext.java @@ -60,7 +60,7 @@ final class SerialCallbackContext { return desc; } - private void checkAndSetUsed() throws NotActiveException { + public void checkAndSetUsed() throws NotActiveException { if (thread != Thread.currentThread()) { throw new NotActiveException( "not in readObject invocation or fields already read"); From 41ef9eed31f741118e7b54c94c7407de60996024 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 6 Feb 2014 15:43:35 +0000 Subject: [PATCH 05/30] 8033366: Add configure option to allow RMIConnector IIOP transport be selected compiled in or not Reviewed-by: dfuchs --- jdk/make/CompileJavaClasses.gmk | 4 ++++ jdk/make/GenerateClasses.gmk | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/jdk/make/CompileJavaClasses.gmk b/jdk/make/CompileJavaClasses.gmk index 5a725b502e6..f5e6184eadf 100644 --- a/jdk/make/CompileJavaClasses.gmk +++ b/jdk/make/CompileJavaClasses.gmk @@ -44,6 +44,10 @@ EXCLUDES += com/sun/pept \ com/sun/tools/example/debug/event \ com/sun/tools/example/debug/gui +ifeq ($(RMICONNECTOR_IIOP), false) + EXCLUDES += com/sun/jmx/remote/protocol/iiop +endif + ifdef OPENJDK EXCLUDES += sun/dc \ com/sun/jmx/snmp \ diff --git a/jdk/make/GenerateClasses.gmk b/jdk/make/GenerateClasses.gmk index 1503c0b8dd4..1ae80cd27d0 100644 --- a/jdk/make/GenerateClasses.gmk +++ b/jdk/make/GenerateClasses.gmk @@ -89,21 +89,25 @@ GENCLASSES += $(RMI_11) # For RMI/IIOP call rmic a second time with -standardPackage option # so that *_tie classes are generated in package without the prefix # org.omg.stub (6375696) -JMAN_RMI_CLASSES := javax.management.remote.rmi.RMIConnectionImpl \ +JMX_RMI_CLASSES := javax.management.remote.rmi.RMIConnectionImpl \ javax.management.remote.rmi.RMIServerImpl +GENRMIIIOPCLASSES := +ifneq ($(RMICONNECTOR_IIOP), false) + GENRMIIIOPCLASSES := $(RMICONNECTOR_IIOP) +endif $(eval $(call SetupRMICompilation,RMI_IIOP, \ - CLASSES := $(JMAN_RMI_CLASSES), \ + CLASSES := $(JMX_RMI_CLASSES), \ CLASSES_DIR := $(CLASSES_DIR), \ STUB_CLASSES_DIR := $(STUB_CLASSES_DIR), \ RUN_V12 := true, \ - RUN_IIOP := true, \ - RUN_IIOP_STDPKG := true)) + RUN_IIOP := $(GENRMIIIOPCLASSES), \ + RUN_IIOP_STDPKG := $(GENRMIIIOPCLASSES))) GENCLASSES += $(RMI_IIOP) # Keep generated RMI/JRMP Stub source files and copy them to RMIC_GENSRC_DIR # so that javadoc can include them in the API (4997471) $(eval $(call SetupRMICompilation,RMI_SRC, \ - CLASSES := $(JMAN_RMI_CLASSES), \ + CLASSES := $(JMX_RMI_CLASSES), \ CLASSES_DIR := $(CLASSES_DIR), \ STUB_CLASSES_DIR := $(RMIC_GENSRC_DIR), \ RUN_V12 := true, \ From 81c4d4ed416f217ce6516f5d3d80e73a2db768b5 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Thu, 6 Feb 2014 11:01:27 -0500 Subject: [PATCH 06/30] 8033565: Remove unused nativeNewStringPlatform Remove also nativeGetStringPlatformChars Reviewed-by: mchung, dholmes, alanb --- jdk/src/share/native/common/jni_util.c | 168 ++++++++++---------- jdk/src/share/native/common/jni_util.h | 4 - jdk/src/solaris/native/common/jni_util_md.c | 8 - jdk/src/windows/native/common/jni_util_md.c | 96 ----------- 4 files changed, 81 insertions(+), 195 deletions(-) diff --git a/jdk/src/share/native/common/jni_util.c b/jdk/src/share/native/common/jni_util.c index de3509b7a59..6837dd67983 100644 --- a/jdk/src/share/native/common/jni_util.c +++ b/jdk/src/share/native/common/jni_util.c @@ -719,52 +719,49 @@ NewStringPlatform(JNIEnv *env, const char *str) JNIEXPORT jstring JNICALL JNU_NewStringPlatform(JNIEnv *env, const char *str) { - jstring result; - result = nativeNewStringPlatform(env, str); - if (result == NULL) { - jbyteArray hab = 0; - int len; + jstring result = NULL; + jbyteArray hab = 0; + int len; - if (fastEncoding == NO_ENCODING_YET) { - initializeEncoding(env); - JNU_CHECK_EXCEPTION_RETURN(env, NULL); - } + if (fastEncoding == NO_ENCODING_YET) { + initializeEncoding(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); + } - if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) - return newString8859_1(env, str); - if (fastEncoding == FAST_646_US) - return newString646_US(env, str); - if (fastEncoding == FAST_CP1252) - return newStringCp1252(env, str); + if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) + return newString8859_1(env, str); + if (fastEncoding == FAST_646_US) + return newString646_US(env, str); + if (fastEncoding == FAST_CP1252) + return newStringCp1252(env, str); - if ((*env)->EnsureLocalCapacity(env, 2) < 0) - return NULL; + if ((*env)->EnsureLocalCapacity(env, 2) < 0) + return NULL; - len = (int)strlen(str); - hab = (*env)->NewByteArray(env, len); - if (hab != 0) { - jclass strClazz = JNU_ClassString(env); - CHECK_NULL_RETURN(strClazz, 0); - (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str); - if (jnuEncodingSupported(env)) { - result = (*env)->NewObject(env, strClazz, - String_init_ID, hab, jnuEncoding); - } else { - /*If the encoding specified in sun.jnu.encoding is not endorsed - by "Charset.isSupported" we have to fall back to use String(byte[]) - explicitly here without specifying the encoding name, in which the - StringCoding class will pickup the iso-8859-1 as the fallback - converter for us. - */ - jmethodID mid = (*env)->GetMethodID(env, strClazz, - "", "([B)V"); - if (mid != NULL) { - result = (*env)->NewObject(env, strClazz, mid, hab); - } + len = (int)strlen(str); + hab = (*env)->NewByteArray(env, len); + if (hab != 0) { + jclass strClazz = JNU_ClassString(env); + CHECK_NULL_RETURN(strClazz, 0); + (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str); + if (jnuEncodingSupported(env)) { + result = (*env)->NewObject(env, strClazz, + String_init_ID, hab, jnuEncoding); + } else { + /*If the encoding specified in sun.jnu.encoding is not endorsed + by "Charset.isSupported" we have to fall back to use String(byte[]) + explicitly here without specifying the encoding name, in which the + StringCoding class will pickup the iso-8859-1 as the fallback + converter for us. + */ + jmethodID mid = (*env)->GetMethodID(env, strClazz, + "", "([B)V"); + if (mid != NULL) { + result = (*env)->NewObject(env, strClazz, mid, hab); } - (*env)->DeleteLocalRef(env, hab); - return result; } + (*env)->DeleteLocalRef(env, hab); + return result; } return NULL; } @@ -778,56 +775,53 @@ GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) JNIEXPORT const char * JNICALL JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) { - char *result = nativeGetStringPlatformChars(env, jstr, isCopy); - if (result == NULL) { + char *result = NULL; + jbyteArray hab = 0; - jbyteArray hab = 0; + if (isCopy) + *isCopy = JNI_TRUE; - if (isCopy) - *isCopy = JNI_TRUE; - - if (fastEncoding == NO_ENCODING_YET) { - initializeEncoding(env); - JNU_CHECK_EXCEPTION_RETURN(env, 0); - } - - if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) - return getString8859_1Chars(env, jstr); - if (fastEncoding == FAST_646_US) - return getString646_USChars(env, jstr); - if (fastEncoding == FAST_CP1252) - return getStringCp1252Chars(env, jstr); - - if ((*env)->EnsureLocalCapacity(env, 2) < 0) - return 0; - - if (jnuEncodingSupported(env)) { - hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding); - } else { - jmethodID mid; - jclass strClazz = JNU_ClassString(env); - CHECK_NULL_RETURN(strClazz, 0); - mid = (*env)->GetMethodID(env, strClazz, - "getBytes", "()[B"); - if (mid != NULL) { - hab = (*env)->CallObjectMethod(env, jstr, mid); - } - } - - if (!(*env)->ExceptionCheck(env)) { - jint len = (*env)->GetArrayLength(env, hab); - result = MALLOC_MIN4(len); - if (result == 0) { - JNU_ThrowOutOfMemoryError(env, 0); - (*env)->DeleteLocalRef(env, hab); - return 0; - } - (*env)->GetByteArrayRegion(env, hab, 0, len, (jbyte *)result); - result[len] = 0; /* NULL-terminate */ - } - - (*env)->DeleteLocalRef(env, hab); + if (fastEncoding == NO_ENCODING_YET) { + initializeEncoding(env); + JNU_CHECK_EXCEPTION_RETURN(env, 0); } + + if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) + return getString8859_1Chars(env, jstr); + if (fastEncoding == FAST_646_US) + return getString646_USChars(env, jstr); + if (fastEncoding == FAST_CP1252) + return getStringCp1252Chars(env, jstr); + + if ((*env)->EnsureLocalCapacity(env, 2) < 0) + return 0; + + if (jnuEncodingSupported(env)) { + hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding); + } else { + jmethodID mid; + jclass strClazz = JNU_ClassString(env); + CHECK_NULL_RETURN(strClazz, 0); + mid = (*env)->GetMethodID(env, strClazz, + "getBytes", "()[B"); + if (mid != NULL) { + hab = (*env)->CallObjectMethod(env, jstr, mid); + } + } + + if (!(*env)->ExceptionCheck(env)) { + jint len = (*env)->GetArrayLength(env, hab); + result = MALLOC_MIN4(len); + if (result == 0) { + JNU_ThrowOutOfMemoryError(env, 0); + (*env)->DeleteLocalRef(env, hab); + return 0; + } + (*env)->GetByteArrayRegion(env, hab, 0, len, (jbyte *)result); + result[len] = 0; /* NULL-terminate */ + } + + (*env)->DeleteLocalRef(env, hab); return result; } diff --git a/jdk/src/share/native/common/jni_util.h b/jdk/src/share/native/common/jni_util.h index b8d23cd1c21..770934bdd5e 100644 --- a/jdk/src/share/native/common/jni_util.h +++ b/jdk/src/share/native/common/jni_util.h @@ -363,10 +363,6 @@ enum { FAST_646_US /* US-ASCII : ISO646-US */ }; -jstring nativeNewStringPlatform(JNIEnv *env, const char *str); - -char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy); - int getFastEncoding(); void initializeEncoding(); diff --git a/jdk/src/solaris/native/common/jni_util_md.c b/jdk/src/solaris/native/common/jni_util_md.c index 42ab2de0037..90b89676caa 100644 --- a/jdk/src/solaris/native/common/jni_util_md.c +++ b/jdk/src/solaris/native/common/jni_util_md.c @@ -29,14 +29,6 @@ #include "jni_util.h" #include "dlfcn.h" -jstring nativeNewStringPlatform(JNIEnv *env, const char *str) { - return NULL; -} - -char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) { - return NULL; -} - void* getProcessHandle() { static void *procHandle = NULL; if (procHandle != NULL) { diff --git a/jdk/src/windows/native/common/jni_util_md.c b/jdk/src/windows/native/common/jni_util_md.c index cdaaa2b5574..80f1b355fe5 100644 --- a/jdk/src/windows/native/common/jni_util_md.c +++ b/jdk/src/windows/native/common/jni_util_md.c @@ -42,102 +42,6 @@ static void getParent(const TCHAR *path, TCHAR *dest) { *lastSlash = 0; } -BOOL useNativeConverter(JNIEnv *env) { - static BOOL initialized; - static BOOL useNative; - if (!initialized) { - HMODULE jvm = GetModuleHandle("jvm"); - useNative = FALSE; - if (jvm != NULL) { - TCHAR *jvmPath = NULL; - int bufferSize = MAX_PATH; - while (jvmPath == NULL) { - DWORD result; - jvmPath = malloc(bufferSize); - if (jvmPath == NULL) - return FALSE; - result = GetModuleFileName(jvm, jvmPath, bufferSize); - if (result == 0) - return FALSE; - if (result == bufferSize) { // didn't fit - bufferSize += MAX_PATH; // increase buffer size, try again - free(jvmPath); - jvmPath = NULL; - } - } - - getParent(jvmPath, jvmPath); - useNative = (!strcmp("kernel", jvmPath + strlen(jvmPath) - - strlen("kernel"))); // true if jvm.dll lives in "kernel" - if (useNative) - setlocale(LC_ALL, ""); - free(jvmPath); - } - initialized = TRUE; - } - return useNative; -} - -jstring nativeNewStringPlatform(JNIEnv *env, const char *str) { - static jmethodID String_char_constructor; - if (useNativeConverter(env)) { - // use native Unicode conversion so Kernel isn't required during - // System.initProperties - jcharArray chars = 0; - wchar_t *utf16; - int len; - jstring result = NULL; - - if (getFastEncoding() == NO_ENCODING_YET) - initializeEncoding(env); - - len = mbstowcs(NULL, str, strlen(str)); - if (len == -1) - return NULL; - utf16 = calloc(len + 1, 2); - if (mbstowcs(utf16, str, len) == -1) - return NULL; - chars = (*env)->NewCharArray(env, len); - if (chars == NULL) - return NULL; - (*env)->SetCharArrayRegion(env, chars, 0, len, utf16); - if (String_char_constructor == NULL) - String_char_constructor = (*env)->GetMethodID(env, - JNU_ClassString(env), "", "([C)V"); - result = (*env)->NewObject(env, JNU_ClassString(env), - String_char_constructor, chars); - free(utf16); - return result; - } - else - return NULL; -} - - -char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) { - if (useNativeConverter(env)) { - // use native Unicode conversion so Kernel isn't required during - // System.initProperties - char *result = NULL; - size_t len; - const jchar* utf16 = (*env)->GetStringChars(env, jstr, NULL); - len = wcstombs(NULL, utf16, (*env)->GetStringLength(env, jstr) * 4) + 1; - if (len == -1) - return NULL; - result = (char*) malloc(len); - if (result != NULL) { - if (wcstombs(result, utf16, len) == -1) - return NULL; - (*env)->ReleaseStringChars(env, jstr, utf16); - if (isCopy) - *isCopy = JNI_TRUE; - } - return result; - } - else - return NULL; -} - void* getProcessHandle() { return (void*)GetModuleHandle(NULL); } From 79938735a28be015c5a076ef0caa7f8b6ebbfc7b Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Thu, 6 Feb 2014 10:06:09 -0800 Subject: [PATCH 07/30] 8033370: [parfait] warning from b126 for solaris/native/sun/util/locale/provider: JNI exception pending Reviewed-by: msheppar --- jdk/make/mapfiles/libjava/mapfile-vers | 2 - .../provider/HostLocaleProviderAdapter_md.c | 31 ++++-- .../HostLocaleProviderAdapterImpl.java | 92 +--------------- .../provider/HostLocaleProviderAdapter_md.c | 77 ------------- .../windows/native/java/lang/java_props_md.c | 72 +++++++++---- .../provider/HostLocaleProviderAdapter_md.c | 102 +++++++++++++----- 6 files changed, 155 insertions(+), 221 deletions(-) delete mode 100644 jdk/src/solaris/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index ea2276f6521..84278c1e3ed 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -285,8 +285,6 @@ SUNWprivate_1.1 { # Java_sun_misc_VM_unsuspendSomeThreads; threads.c # Java_sun_misc_VM_unsuspendThreads; threads.c - Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPattern; - # Outcalls from libjvm done using dlsym(). VerifyClassCodes; diff --git a/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c b/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c index 5cac939a239..dc99519221a 100644 --- a/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c +++ b/jdk/src/macosx/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c @@ -24,6 +24,7 @@ */ #include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h" +#include "jni_util.h" #include #include @@ -63,6 +64,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte localeString = getMacOSXLocale(posixCat); if (localeString == NULL) { localeString = getPosixLocale(posixCat); + if (localeString == NULL) { + JNU_ThrowOutOfMemoryError(env, NULL); + return NULL; + } } ret = (*env)->NewStringUTF(env, localeString); free(localeString); @@ -127,6 +132,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) { CFLocaleRef cflocale = CFLocaleCopyCurrent(); + jstring tmp_string; if (cflocale != NULL) { CFDateFormatterRef df = CFDateFormatterCreate(kCFAllocatorDefault, cflocale, @@ -138,13 +144,18 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA if (amStr != NULL) { CFStringGetCString(amStr, buf, BUFLEN, kCFStringEncodingUTF8); CFRelease(amStr); - (*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewStringUTF(env, buf)); + tmp_string = (*env)->NewStringUTF(env, buf); + if (tmp_string != NULL) { + (*env)->SetObjectArrayElement(env, ampms, 0, tmp_string); + } } - CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol); - if (pmStr != NULL) { - CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8); - CFRelease(pmStr); - (*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf)); + if (!(*env)->ExceptionCheck(env)){ + CFStringRef pmStr = CFDateFormatterCopyProperty(df, kCFDateFormatterPMSymbol); + if (pmStr != NULL) { + CFStringGetCString(pmStr, buf, BUFLEN, kCFStringEncodingUTF8); + CFRelease(pmStr); + (*env)->SetObjectArrayElement(env, ampms, 1, (*env)->NewStringUTF(env, buf)); + } } CFRelease(df); } @@ -647,10 +658,16 @@ static CFNumberFormatterStyle convertNumberFormatterStyle(jint javaStyle) { static void copyArrayElements(JNIEnv *env, CFArrayRef cfarray, jobjectArray jarray, CFIndex sindex, int dindex, int count) { char buf[BUFLEN]; + jstring tmp_string; for (; count > 0; sindex++, dindex++, count--) { CFStringGetCString(CFArrayGetValueAtIndex(cfarray, sindex), buf, BUFLEN, kCFStringEncodingUTF8); - (*env)->SetObjectArrayElement(env, jarray, dindex, (*env)->NewStringUTF(env, buf)); + tmp_string = (*env)->NewStringUTF(env, buf); + if (tmp_string != NULL) { + (*env)->SetObjectArrayElement(env, jarray, dindex, tmp_string); + } else { + break; + } } } diff --git a/jdk/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java b/jdk/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java index 89981bf0513..5914704aed1 100644 --- a/jdk/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java +++ b/jdk/src/solaris/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,100 +25,10 @@ package sun.util.locale.provider; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.text.spi.DateFormatProvider; -import java.util.Locale; - /** * LocaleProviderAdapter implementation for the Unix locale data * * @author Naoto Sato */ public class HostLocaleProviderAdapterImpl { - static Locale[] supported = {Locale.getDefault(Locale.Category.FORMAT)}; - - public static DateFormatProvider getDateFormatProvider() { - return new DateFormatProvider() { - String posixPattern; - - @Override - public Locale[] getAvailableLocales() { - // not implemented yet - return new Locale[0]; - } - @Override - public DateFormat getDateInstance(int style, Locale locale) { - posixPattern = getPattern(style, -1, locale.toLanguageTag()); - return new SimpleDateFormat(convertPosixToJava(posixPattern), locale); - } - @Override - public DateFormat getTimeInstance(int style, Locale locale) { - posixPattern = getPattern(-1, style, locale.toLanguageTag()); - return new SimpleDateFormat(convertPosixToJava(posixPattern), locale); - } - @Override - public DateFormat getDateTimeInstance(int dateStyle, - int timeStyle, Locale locale) { - posixPattern = getPattern(dateStyle, timeStyle, locale.toLanguageTag()); - return new SimpleDateFormat(convertPosixToJava(posixPattern), locale); - } - }; - } - - private static String convertPosixToJava(String posixPattern) { - StringBuilder sb = new StringBuilder(); - boolean conversion = false; - - for (int index = 0; index < posixPattern.length(); index++) { - char c = posixPattern.charAt(index); - if (conversion) { - switch (c) { - case 'a': - sb.append("EEE"); - break; - case 'b': - sb.append("MMM"); - break; - case 'e': - sb.append("dd"); - break; - case 'H': - sb.append("kk"); - break; - case 'M': - sb.append("mm"); - break; - case 'S': - sb.append("ss"); - break; - case 'Y': - sb.append("yyyy"); - break; - case 'm': - sb.append("MM"); - break; - case 'd': - sb.append("dd"); - break; - case 'r': - sb.append("hh:mm:ss aa"); - break; - case 'Z': - sb.append("zzz"); - break; - } - conversion = false; - } else { - if (c == '%') { - conversion = true; - } else { - sb.append(c); - } - } - } - return sb.toString(); - } - - private static native String getPattern(int dateStyle, int timeStyle, String langtag); } diff --git a/jdk/src/solaris/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c b/jdk/src/solaris/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c deleted file mode 100644 index 10f151f9323..00000000000 --- a/jdk/src/solaris/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h" -#include -#include -#include -#include - -#define BUFLEN 64 - -/* - * Class: sun_util_locale_provider_HostLocaleProviderAdapterImpl - * Method: getPattern - * Signature: (IILjava/lang/String;)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPattern - (JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) { - - // TEMPORARY! - char locale[BUFLEN]; - char * pch; - char * old; - char * ret; - const char *langtag = (*env)->GetStringUTFChars(env, jlangtag, JNI_FALSE); - - strcpy(locale, langtag); - pch = strchr(locale, '-'); - if (pch != NULL) { - *pch = '_'; - } - pch = strchr(locale, '-'); - if (pch != NULL) { - *pch = '\0'; - } - strcat(locale, ".UTF-8"); - old = setlocale(LC_TIME, ""); - setlocale(LC_TIME, locale); - - if (dateStyle != (-1) && timeStyle != (-1)) { - ret = nl_langinfo(D_T_FMT); - } else if (dateStyle != (-1)) { - ret = nl_langinfo(D_FMT); - } else if (timeStyle != (-1)) { - ret = nl_langinfo(T_FMT); - } else { - ret = "yyyy/MM/dd"; - } - - setlocale(LC_TIME, old); - - (*env)->ReleaseStringUTFChars(env, jlangtag, langtag); - - return (*env)->NewStringUTF(env, ret); -} diff --git a/jdk/src/windows/native/java/lang/java_props_md.c b/jdk/src/windows/native/java/lang/java_props_md.c index 4dee31a8116..e456c9a7d44 100644 --- a/jdk/src/windows/native/java/lang/java_props_md.c +++ b/jdk/src/windows/native/java/lang/java_props_md.c @@ -28,6 +28,9 @@ #define _WIN32_WINNT 0x0601 #endif +#include "jni.h" +#include "jni_util.h" + #include #include #include @@ -51,7 +54,7 @@ #endif typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); -static void SetupI18nProps(LCID lcid, char** language, char** script, char** country, +static boolean SetupI18nProps(LCID lcid, char** language, char** script, char** country, char** variant, char** encoding); #define PROPSIZE 9 // eight-letter + null terminator @@ -60,8 +63,11 @@ static void SetupI18nProps(LCID lcid, char** language, char** script, char** cou static char * getEncodingInternal(LCID lcid) { - char * ret = malloc(16); int codepage; + char * ret = malloc(16); + if (ret == NULL) { + return NULL; + } if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, @@ -132,7 +138,11 @@ getEncodingInternal(LCID lcid) static char* getConsoleEncoding() { char* buf = malloc(16); - int cp = GetConsoleCP(); + int cp; + if (buf == NULL) { + return NULL; + } + cp = GetConsoleCP(); if (cp >= 874 && cp <= 950) sprintf(buf, "ms%d", cp); else @@ -152,25 +162,33 @@ DllExport const char * getJavaIDFromLangID(LANGID langID) { char * elems[5]; // lang, script, ctry, variant, encoding - char * ret = malloc(SNAMESIZE); + char * ret; int index; - SetupI18nProps(MAKELCID(langID, SORT_DEFAULT), - &(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4])); - - // there always is the "language" tag - strcpy(ret, elems[0]); - - // append other elements, if any - for (index = 1; index < 4; index++) { - if ((elems[index])[0] != '\0') { - strcat(ret, "-"); - strcat(ret, elems[index]); - } + ret = malloc(SNAMESIZE); + if (ret == NULL) { + return NULL; } - for (index = 0; index < 5; index++) { - free(elems[index]); + if (SetupI18nProps(MAKELCID(langID, SORT_DEFAULT), + &(elems[0]), &(elems[1]), &(elems[2]), &(elems[3]), &(elems[4]))) { + + // there always is the "language" tag + strcpy(ret, elems[0]); + + // append other elements, if any + for (index = 1; index < 4; index++) { + if ((elems[index])[0] != '\0') { + strcat(ret, "-"); + strcat(ret, elems[index]); + } + } + + for (index = 0; index < 5; index++) { + free(elems[index]); + } + } else { + ret = NULL; } return ret; @@ -259,12 +277,15 @@ cpu_isalist(void) return NULL; } -static void +static boolean SetupI18nProps(LCID lcid, char** language, char** script, char** country, char** variant, char** encoding) { /* script */ char tmp[SNAMESIZE]; *script = malloc(PROPSIZE); + if (*script == NULL) { + return FALSE; + } if (GetLocaleInfo(lcid, LOCALE_SNAME, tmp, SNAMESIZE) == 0 || sscanf(tmp, "%*[a-z\\-]%1[A-Z]%[a-z]", *script, &((*script)[1])) == 0 || @@ -274,6 +295,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, /* country */ *country = malloc(PROPSIZE); + if (*country == NULL) { + return FALSE; + } if (GetLocaleInfo(lcid, LOCALE_SISO3166CTRYNAME, *country, PROPSIZE) == 0 && GetLocaleInfo(lcid, @@ -283,6 +307,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, /* language */ *language = malloc(PROPSIZE); + if (*language == NULL) { + return FALSE; + } if (GetLocaleInfo(lcid, LOCALE_SISO639LANGNAME, *language, PROPSIZE) == 0 && GetLocaleInfo(lcid, @@ -294,6 +321,9 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, /* variant */ *variant = malloc(PROPSIZE); + if (*variant == NULL) { + return FALSE; + } (*variant)[0] = '\0'; /* handling for Norwegian */ @@ -308,6 +338,10 @@ SetupI18nProps(LCID lcid, char** language, char** script, char** country, /* encoding */ *encoding = getEncodingInternal(lcid); + if (*encoding == NULL) { + return FALSE; + } + return TRUE; } java_props_t * diff --git a/jdk/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c b/jdk/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c index 148282cfadc..93487774ecd 100644 --- a/jdk/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c +++ b/jdk/src/windows/native/sun/util/locale/provider/HostLocaleProviderAdapter_md.c @@ -24,6 +24,7 @@ */ #include "sun_util_locale_provider_HostLocaleProviderAdapterImpl.h" +#include "jni_util.h" #include #include #include @@ -197,8 +198,13 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte } localeString = (char *)getJavaIDFromLangID(langid); - ret = (*env)->NewStringUTF(env, localeString); - free(localeString); + if (localeString != NULL) { + ret = (*env)->NewStringUTF(env, localeString); + free(localeString); + } else { + JNU_ThrowOutOfMemoryError(env, "memory allocation error"); + ret = NULL; + } return ret; } @@ -211,6 +217,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte (JNIEnv *env, jclass cls, jint dateStyle, jint timeStyle, jstring jlangtag) { WCHAR pattern[BUFLEN]; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, NULL); pattern[0] = L'\0'; @@ -238,8 +245,11 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte */ JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarID (JNIEnv *env, jclass cls, jstring jlangtag) { - const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - jint ret = getCalendarID(langtag); + const jchar *langtag; + jint ret; + langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, 0); + ret = getCalendarID(langtag); (*env)->ReleaseStringChars(env, jlangtag, langtag); return ret; } @@ -252,10 +262,13 @@ JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterIm JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getAmPmStrings (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray ampms) { WCHAR buf[BUFLEN]; - const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + const jchar *langtag; // AM - int got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN); + int got; + langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, NULL); + got = getLocaleInfoWrapper(langtag, LOCALE_S1159, buf, BUFLEN); if (got) { (*env)->SetObjectArrayElement(env, ampms, 0, (*env)->NewString(env, buf, wcslen(buf))); } @@ -280,6 +293,7 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA (JNIEnv *env, jclass cls, jstring jlangtag, jobjectArray eras) { WCHAR ad[BUFLEN]; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, eras); getCalendarInfoWrapper(langtag, getCalendarID(langtag), NULL, CAL_SERASTRING, ad, BUFLEN, NULL); @@ -347,10 +361,14 @@ JNIEXPORT jobjectArray JNICALL Java_sun_util_locale_provider_HostLocaleProviderA */ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNumberPattern (JNIEnv *env, jclass cls, jint numberStyle, jstring jlangtag) { - const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + const jchar *langtag; jstring ret; + WCHAR * pattern; - WCHAR * pattern = getNumberPattern(langtag, numberStyle); + langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, NULL); + pattern = getNumberPattern(langtag, numberStyle); + CHECK_NULL_RETURN(pattern, NULL); (*env)->ReleaseStringChars(env, jlangtag, langtag); ret = (*env)->NewString(env, pattern, wcslen(pattern)); @@ -367,8 +385,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_isNativeDigit (JNIEnv *env, jclass cls, jstring jlangtag) { DWORD num; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, + CHECK_NULL_RETURN(langtag, JNI_FALSE); + got = getLocaleInfoWrapper(langtag, LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER, (LPWSTR)&num, sizeof(num)); (*env)->ReleaseStringChars(env, jlangtag, langtag); @@ -384,8 +404,10 @@ JNIEXPORT jboolean JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapt JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCurrencySymbol (JNIEnv *env, jclass cls, jstring jlangtag, jstring currencySymbol) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SCURRENCY, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, currencySymbol); + got = getLocaleInfoWrapper(langtag, LOCALE_SCURRENCY, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -403,8 +425,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getDecimalSeparator (JNIEnv *env, jclass cls, jstring jlangtag, jchar decimalSeparator) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SDECIMAL, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, decimalSeparator); + got = getLocaleInfoWrapper(langtag, LOCALE_SDECIMAL, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -422,8 +446,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getGroupingSeparator (JNIEnv *env, jclass cls, jstring jlangtag, jchar groupingSeparator) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_STHOUSAND, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, groupingSeparator); + got = getLocaleInfoWrapper(langtag, LOCALE_STHOUSAND, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -441,8 +467,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInfinity (JNIEnv *env, jclass cls, jstring jlangtag, jstring infinity) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SPOSINFINITY, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, infinity); + got = getLocaleInfoWrapper(langtag, LOCALE_SPOSINFINITY, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -460,8 +488,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getInternationalCurrencySymbol (JNIEnv *env, jclass cls, jstring jlangtag, jstring internationalCurrencySymbol) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SINTLSYMBOL, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, internationalCurrencySymbol); + got = getLocaleInfoWrapper(langtag, LOCALE_SINTLSYMBOL, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -479,8 +509,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMinusSign (JNIEnv *env, jclass cls, jstring jlangtag, jchar minusSign) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SNEGATIVESIGN, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, minusSign); + got = getLocaleInfoWrapper(langtag, LOCALE_SNEGATIVESIGN, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -498,8 +530,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getMonetaryDecimalSeparator (JNIEnv *env, jclass cls, jstring jlangtag, jchar monetaryDecimalSeparator) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SMONDECIMALSEP, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, monetaryDecimalSeparator); + got = getLocaleInfoWrapper(langtag, LOCALE_SMONDECIMALSEP, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -517,8 +551,10 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getNaN (JNIEnv *env, jclass cls, jstring jlangtag, jstring nan) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SNAN, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, nan); + got = getLocaleInfoWrapper(langtag, LOCALE_SNAN, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -536,8 +572,10 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPercent (JNIEnv *env, jclass cls, jstring jlangtag, jchar percent) { WCHAR buf[BUFLEN]; + int got; const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SPERCENT, buf, BUFLEN); + CHECK_NULL_RETURN(langtag, percent); + got = getLocaleInfoWrapper(langtag, LOCALE_SPERCENT, buf, BUFLEN); (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -555,8 +593,12 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getPerMill (JNIEnv *env, jclass cls, jstring jlangtag, jchar perMill) { WCHAR buf[BUFLEN]; - const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SPERMILLE, buf, BUFLEN); + const jchar *langtag; + int got; + langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, perMill); + got = getLocaleInfoWrapper(langtag, LOCALE_SPERMILLE, buf, BUFLEN); + (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -574,8 +616,12 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getZeroDigit (JNIEnv *env, jclass cls, jstring jlangtag, jchar zeroDigit) { WCHAR buf[BUFLEN]; - const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int got = getLocaleInfoWrapper(langtag, LOCALE_SNATIVEDIGITS, buf, BUFLEN); + const jchar *langtag; + int got; + langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, zeroDigit); + got = getLocaleInfoWrapper(langtag, LOCALE_SNATIVEDIGITS, buf, BUFLEN); + (*env)->ReleaseStringChars(env, jlangtag, langtag); if (got) { @@ -593,9 +639,11 @@ JNIEXPORT jchar JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterI JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterImpl_getCalendarDataValue (JNIEnv *env, jclass cls, jstring jlangtag, jint type) { DWORD num; - const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + const jchar *langtag; int got = 0; + langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL_RETURN(langtag, -1); switch (type) { case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTDAYOFWEEK: got = getLocaleInfoWrapper(langtag, @@ -648,6 +696,7 @@ JNIEXPORT jstring JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapte } pjChar = (*env)->GetStringChars(env, jStr, JNI_FALSE); + CHECK_NULL_RETURN(pjChar, NULL); got = getLocaleInfoWrapper(pjChar, lcType, buf, BUFLEN); (*env)->ReleaseStringChars(env, jStr, pjChar); @@ -705,8 +754,11 @@ jint getCalendarID(const jchar *langtag) { void replaceCalendarArrayElems(JNIEnv *env, jstring jlangtag, jobjectArray jarray, CALTYPE* pCalTypes, int offset, int length) { WCHAR name[BUFLEN]; - const jchar *langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); - int calid = getCalendarID(langtag); + const jchar *langtag; + int calid; + langtag = (*env)->GetStringChars(env, jlangtag, JNI_FALSE); + CHECK_NULL(langtag); + calid = getCalendarID(langtag); if (calid != -1) { int i; From 3981cc3f4154cc628712b4bf1360f2fe94f1f971 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Thu, 6 Feb 2014 22:12:09 +0000 Subject: [PATCH 08/30] 8031588: warnings from b03 for jdk/src/share/native/sun/security/jgss/wrapper: JNI exception pending Reviewed-by: chegar, mullan --- .../sun/security/jgss/wrapper/GSSLibStub.c | 66 +++++++++++++++---- .../sun/security/jgss/wrapper/NativeUtil.c | 33 ++++++++-- .../sun/security/jgss/wrapper/NativeUtil.h | 2 +- 3 files changed, 83 insertions(+), 18 deletions(-) diff --git a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c index e0da98aab74..439cc8da951 100644 --- a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c +++ b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c @@ -28,6 +28,7 @@ #include "NativeFunc.h" #include "jlong.h" #include +#include "jni_util.h" /* Throws a Java Exception by name */ @@ -36,6 +37,7 @@ void throwByName(JNIEnv *env, const char *name, const char *msg) { if (cls != 0) /* Otherwise an exception has already been thrown */ (*env)->ThrowNew(env, cls, msg); + JNU_Equals(env, NULL, NULL); } void throwOutOfMemoryError(JNIEnv *env, const char *message) { @@ -65,6 +67,12 @@ Java_sun_security_jgss_wrapper_GSSLibStub_init(JNIEnv *env, } libName = (*env)->GetStringUTFChars(env, jlibName, NULL); + if (libName == NULL) { + if (!(*env)->ExceptionCheck(env)) { + throwOutOfMemoryError(env, NULL); + } + return JNI_FALSE; + } sprintf(debugBuf, "[GSSLibStub_init] libName=%s", libName); debug(env, debugBuf); @@ -110,6 +118,8 @@ Java_sun_security_jgss_wrapper_GSSLibStub_getMechPtr(JNIEnv *env, } } (*env)->ReleaseByteArrayElements(env, jbytes, bytes, 0); + } else { + JNU_CHECK_EXCEPTION_RETURN(env, jlong_zero); } if (found != JNI_TRUE) { checkStatus(env, NULL, GSS_S_BAD_MECH, 0, "[GSSLibStub_getMechPtr]"); @@ -147,7 +157,9 @@ gss_channel_bindings_t getGSSCB(JNIEnv *env, jobject jcb) { cb->initiator_addrtype = GSS_C_AF_INET; value = (*env)->CallObjectMethod(env, jinetAddr, MID_InetAddress_getAddr); - initGSSBuffer(env, value, &(cb->initiator_address)); + if (!initGSSBuffer(env, value, &(cb->initiator_address))) { + return NULL; + } } else { cb->initiator_addrtype = GSS_C_AF_NULLADDR; cb->initiator_address.length = 0; @@ -161,7 +173,9 @@ gss_channel_bindings_t getGSSCB(JNIEnv *env, jobject jcb) { cb->acceptor_addrtype = GSS_C_AF_INET; value = (*env)->CallObjectMethod(env, jinetAddr, MID_InetAddress_getAddr); - initGSSBuffer(env, value, &(cb->acceptor_address)); + if (!initGSSBuffer(env, value, &(cb->acceptor_address))) { + return NULL; + } } else { cb->acceptor_addrtype = GSS_C_AF_NULLADDR; cb->acceptor_address.length = 0; @@ -171,7 +185,9 @@ gss_channel_bindings_t getGSSCB(JNIEnv *env, jobject jcb) { value = (*env)->CallObjectMethod(env, jcb, MID_ChannelBinding_getAppData); if (value != NULL) { - initGSSBuffer(env, value, &(cb->application_data)); + if (!initGSSBuffer(env, value, &(cb->application_data))) { + return NULL; + } } else { cb->application_data.length = 0; cb->application_data.value = NULL; @@ -230,6 +246,7 @@ void setSupplementaryInfo(JNIEnv *env, jobject jstub, jobject jprop, isUnseq = ((suppInfo & GSS_S_UNSEQ_TOKEN) != 0); hasGap = ((suppInfo & GSS_S_GAP_TOKEN) != 0); minorMsg = getMinorMessage(env, jstub, minor); + CHECK_NULL(minorMsg); (*env)->CallVoidMethod(env, jprop, MID_MessageProp_setSupplementaryStates, isDuplicate, isOld, isUnseq, hasGap, minor, minorMsg); @@ -277,6 +294,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_inquireNamesForMech(JNIEnv *env, /* release intermediate buffers */ deleteGSSOIDSet(nameTypes); + CHECK_NULL_RETURN(result, NULL); checkStatus(env, jobj, major, minor, "[GSSLibStub_inquireNamesForMech]"); return result; } else return NULL; @@ -326,7 +344,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_importName(JNIEnv *env, debug(env, "[GSSLibStub_importName]"); - initGSSBuffer(env, jnameVal, &nameVal); + if (!initGSSBuffer(env, jnameVal, &nameVal)) { + return jlong_zero; + } nameType = newGSSOID(env, jnameType); if ((*env)->ExceptionCheck(env)) { deleteGSSOID(nameType); @@ -501,9 +521,14 @@ Java_sun_security_jgss_wrapper_GSSLibStub_displayName(JNIEnv *env, /* release intermediate buffers */ jname = getJavaString(env, &outNameBuf); + if (jname == NULL && !(*env)->ExceptionCheck(env)) { + throwOutOfMemoryError(env, NULL); + return NULL; + } jtype = getJavaOID(env, outNameType); jresult = (*env)->NewObjectArray(env, 2, CLS_Object, NULL); + CHECK_NULL_RETURN(jresult, NULL); /* return immediately if an exception has occurred */ if ((*env)->ExceptionCheck(env)) { @@ -738,7 +763,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_importContext(JNIEnv *env, debug(env, "[GSSLibStub_importContext]"); contextHdl = GSS_C_NO_CONTEXT; - initGSSBuffer(env, jctxtToken, &ctxtToken); + if (!initGSSBuffer(env, jctxtToken, &ctxtToken)) { + return NULL; + } /* gss_import_sec_context(...) => GSS_S_NO_CONTEXT, GSS_S_DEFECTIVE_TOKEN, GSS_S_UNAVAILABLE, GSS_S_UNAUTHORIZED */ @@ -829,7 +856,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_initContext(JNIEnv *env, return NULL; } - initGSSBuffer(env, jinToken, &inToken); + if (!initGSSBuffer(env, jinToken, &inToken)) { + return NULL; + } sprintf(debugBuf, "[GSSLibStub_initContext] before: pCred=%ld, pContext=%ld", @@ -927,7 +956,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_acceptContext(JNIEnv *env, contextHdl = (gss_ctx_id_t)jlong_to_ptr( (*env)->GetLongField(env, jcontextSpi, FID_NativeGSSContext_pContext)); credHdl = (gss_cred_id_t) jlong_to_ptr(pCred); - initGSSBuffer(env, jinToken, &inToken); + if (!initGSSBuffer(env, jinToken, &inToken)) { + return NULL; + } cb = getGSSCB(env, jcb); if ((*env)->ExceptionCheck(env)) { free(cb); @@ -1102,6 +1133,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_inquireContext(JNIEnv *env, result[5] = (jlong) getJavaTime(time); jresult = (*env)->NewLongArray(env, 6); + CHECK_NULL_RETURN(jresult, NULL); (*env)->SetLongArrayRegion(env, jresult, 0, 6, result); /* release intermediate buffers */ @@ -1335,7 +1367,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_getMic(JNIEnv *env, jobject jobj, } contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext); qop = (gss_qop_t) jqop; - initGSSBuffer(env, jmsg, &msg); + if (!initGSSBuffer(env, jmsg, &msg)) { + return NULL; + } /* gss_get_mic(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!), GSS_S_BAD_QOP */ @@ -1379,8 +1413,12 @@ Java_sun_security_jgss_wrapper_GSSLibStub_verifyMic(JNIEnv *env, "[GSSLibStub_verifyMic]"); return; } - initGSSBuffer(env, jmsg, &msg); - initGSSBuffer(env, jmsgToken, &msgToken); + + if (!initGSSBuffer(env, jmsg, &msg) || + !initGSSBuffer(env, jmsgToken, &msgToken)) { + return; + } + qop = (gss_qop_t) (*env)->CallIntMethod(env, jprop, MID_MessageProp_getQOP); /* gss_verify_mic(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC, GSS_S_CONTEXT_EXPIRED, GSS_S_DUPLICATE_TOKEN(!), GSS_S_OLD_TOKEN(!), @@ -1433,7 +1471,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_wrap(JNIEnv *env, (*env)->CallBooleanMethod(env, jprop, MID_MessageProp_getPrivacy); qop = (gss_qop_t) (*env)->CallIntMethod(env, jprop, MID_MessageProp_getQOP); - initGSSBuffer(env, jmsg, &msg); + if (!initGSSBuffer(env, jmsg, &msg)) { + return NULL; + } /* gss_wrap(...) => GSS_S_CONTEXT_EXPIRED, GSS_S_NO_CONTEXT(!), GSS_S_BAD_QOP */ major = (*ftab->wrap)(&minor, contextHdl, confFlag, qop, &msg, &confState, @@ -1479,7 +1519,9 @@ Java_sun_security_jgss_wrapper_GSSLibStub_unwrap(JNIEnv *env, checkStatus(env, jobj, GSS_S_CONTEXT_EXPIRED, 0, "[GSSLibStub_unwrap]"); return NULL; } - initGSSBuffer(env, jmsgToken, &msgToken); + if (!initGSSBuffer(env, jmsgToken, &msgToken)) { + return NULL; + } confState = 0; qop = GSS_C_QOP_DEFAULT; /* gss_unwrap(...) => GSS_S_DEFECTIVE_TOKEN, GSS_S_BAD_MIC, diff --git a/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.c b/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.c index e5edfbcc957..0facc3fb32b 100644 --- a/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.c +++ b/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.c @@ -27,6 +27,7 @@ #include "NativeFunc.h" #include "jlong.h" #include +#include "jni_util.h" extern void throwOutOfMemoryError(JNIEnv *env, const char *message); @@ -495,6 +496,9 @@ jstring getMinorMessage(JNIEnv *env, jobject jstub, OM_uint32 statusValue) { &messageContext, &statusString); /* release intermediate buffers */ msg = getJavaString(env, &statusString); + if (msg == NULL && !(*env)->ExceptionCheck(env)) { + throwOutOfMemoryError(env, NULL); + } (*ftab->releaseBuffer)(&minor, &statusString); return msg; } @@ -529,6 +533,7 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major, jmsg = NULL; if (minor != 0) { jmsg = getMinorMessage(env, jstub, minor); + CHECK_NULL(jmsg); } gssEx = (*env)->NewObject(env, CLS_GSSException, MID_GSSException_ctor3, @@ -545,28 +550,41 @@ void checkStatus(JNIEnv *env, jobject jstub, OM_uint32 major, } jmajor = 13; /* use GSSException.FAILURE for now */ jmsg = (*env)->NewStringUTF(env, msg); + CHECK_NULL(jmsg); gssEx = (*env)->NewObject(env, CLS_GSSException, MID_GSSException_ctor3, jmajor, jminor, jmsg); + CHECK_NULL(gssEx); (*env)->Throw(env, gssEx); } } + /* * Utility routine for initializing gss_buffer_t structure * with the byte[] in the specified jbyteArray object. * NOTE: need to call resetGSSBuffer(...) to free up * the resources. + * Return JNI_TRUE if GetByteArrayElements() returns ok, JNI_FALSE otherwise + * If JNI_FALSE returned, then an exception has been thrown. */ -void initGSSBuffer(JNIEnv *env, jbyteArray jbytes, +int initGSSBuffer(JNIEnv *env, jbyteArray jbytes, gss_buffer_t cbytes) { if (jbytes != NULL) { cbytes->length = (*env)->GetArrayLength(env, jbytes); cbytes->value = (*env)->GetByteArrayElements(env, jbytes, NULL); + if (cbytes->value == NULL) { + if (!(*env)->ExceptionCheck(env)) { + throwOutOfMemoryError(env, NULL); + } + return JNI_FALSE; + } } else { cbytes->length = 0; cbytes->value = NULL; } + return JNI_TRUE; } + /* * Utility routine for unpinning/releasing the byte[] * associated with the specified jbyteArray object. @@ -593,7 +611,8 @@ jbyteArray getJavaBuffer(JNIEnv *env, gss_buffer_t cbytes) { if ((cbytes != NULL) && (cbytes != GSS_C_NO_BUFFER) && (cbytes->length != 0)) { result = (*env)->NewByteArray(env, cbytes->length); - (*env)->SetByteArrayRegion(env, result, 0, cbytes->length, + if (result != NULL) + (*env)->SetByteArrayRegion(env, result, 0, cbytes->length, cbytes->value); (*ftab->releaseBuffer)(&minor, cbytes); return result; @@ -616,6 +635,7 @@ gss_OID newGSSOID(JNIEnv *env, jobject jOid) { if ((*env)->ExceptionCheck(env)) { gssEx = (*env)->ExceptionOccurred(env); (*env)->Throw(env, gssEx); + return GSS_C_NO_OID; } cOid = malloc(sizeof(struct gss_OID_desc_struct)); if (cOid == NULL) { @@ -665,13 +685,12 @@ jobject getJavaOID(JNIEnv *env, gss_OID cOid) { oidHdr[0] = 6; oidHdr[1] = cLen; jbytes = (*env)->NewByteArray(env, cLen+2); + CHECK_NULL_RETURN(jbytes, NULL); (*env)->SetByteArrayRegion(env, jbytes, 0, 2, (jbyte *) oidHdr); (*env)->SetByteArrayRegion(env, jbytes, 2, cLen, (jbyte *) cOid->elements); result = (*env)->NewObject(env, CLS_Oid, MID_Oid_ctor1, jbytes); - if ((*env)->ExceptionCheck(env)) { - (*env)->Throw(env, (*env)->ExceptionOccurred(env)); - } + JNU_CHECK_EXCEPTION_RETURN(env, NULL); (*env)->DeleteLocalRef(env, jbytes); return result; } @@ -722,6 +741,9 @@ jobjectArray getJavaOIDArray(JNIEnv *env, gss_OID_set cOidSet) { if (cOidSet != NULL && cOidSet != GSS_C_NO_OID_SET) { numOfOids = cOidSet->count; jOidSet = (*env)->NewObjectArray(env, numOfOids, CLS_Oid, NULL); + if (jOidSet == NULL) { + return NULL; + } if (jOidSet != NULL) { for (i = 0; i < numOfOids; i++) { jOid = getJavaOID(env, &(cOidSet->elements[i])); @@ -736,6 +758,7 @@ jobjectArray getJavaOIDArray(JNIEnv *env, gss_OID_set cOidSet) { void debug(JNIEnv *env, char *msg) { jstring jmsg = (*env)->NewStringUTF(env, msg); + CHECK_NULL(jmsg); (*env)->CallStaticVoidMethod(env, CLS_SunNativeProvider, MID_SunNativeProvider_debug, jmsg); (*env)->DeleteLocalRef(env, jmsg); diff --git a/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h b/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h index c6194b694d8..58334a38989 100644 --- a/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h +++ b/jdk/src/share/native/sun/security/jgss/wrapper/NativeUtil.h @@ -37,7 +37,7 @@ extern "C" { extern OM_uint32 getGSSTime(jint); extern void checkStatus(JNIEnv *, jobject, OM_uint32, OM_uint32, char*); extern jint checkTime(OM_uint32); - extern void initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t); + extern jint initGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t); extern void resetGSSBuffer(JNIEnv *, jbyteArray, gss_buffer_t); extern gss_OID newGSSOID(JNIEnv *, jobject); From 795c56d54bfa4ac161830796585e0dabea8a6d4c Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Thu, 6 Feb 2014 14:56:12 -0800 Subject: [PATCH 09/30] 8033893: jdk build is broken due to the changeset of JDK-8033370 Reviewed-by: naoto --- jdk/make/lib/CoreLibraries.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index 3be43c8689e..7387a57f4a6 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -129,9 +129,9 @@ LIBJAVA_SRC_DIRS := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/l $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \ $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util -ifneq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(OPENJDK_TARGET_OS), windows) LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/util/locale/provider -else +else ifeq ($(OPENJDK_TARGET_OS), macosx) LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/util/locale/provider endif From 7be40556f67e1aa0b545c37bc78deaec56fc24a1 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Thu, 6 Feb 2014 16:42:25 -0800 Subject: [PATCH 10/30] 8033900: Remove reference to JNU_Equals in GSSLibStub.c Reviewed-by: valeriep --- jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c index 439cc8da951..3957ddeaa9f 100644 --- a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c +++ b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c @@ -37,7 +37,6 @@ void throwByName(JNIEnv *env, const char *name, const char *msg) { if (cls != 0) /* Otherwise an exception has already been thrown */ (*env)->ThrowNew(env, cls, msg); - JNU_Equals(env, NULL, NULL); } void throwOutOfMemoryError(JNIEnv *env, const char *message) { From 8cdace257545ff3595cd4811716df589285cce4e Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 7 Feb 2014 09:04:17 -0800 Subject: [PATCH 11/30] 8032012: String.toLowerCase/toUpperCase performance improvement Updated the implementation to improve the performance Reviewed-by: psandoz, forax --- jdk/src/share/classes/java/lang/String.java | 206 ++++++++++---------- jdk/test/java/lang/String/ToLowerCase.java | 18 +- 2 files changed, 120 insertions(+), 104 deletions(-) diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java index 6565f6434e8..e2f2d9f2984 100644 --- a/jdk/src/share/classes/java/lang/String.java +++ b/jdk/src/share/classes/java/lang/String.java @@ -2549,87 +2549,88 @@ public final class String if (locale == null) { throw new NullPointerException(); } - - int firstUpper; + int first; + boolean hasSurr = false; final int len = value.length; - /* Now check if there are any characters that need to be changed. */ - scan: { - for (firstUpper = 0 ; firstUpper < len; ) { - char c = value[firstUpper]; - if ((c >= Character.MIN_HIGH_SURROGATE) - && (c <= Character.MAX_HIGH_SURROGATE)) { - int supplChar = codePointAt(firstUpper); - if (supplChar != Character.toLowerCase(supplChar)) { - break scan; - } - firstUpper += Character.charCount(supplChar); - } else { - if (c != Character.toLowerCase(c)) { - break scan; - } - firstUpper++; - } + // Now check if there are any characters that need to be changed, or are surrogate + for (first = 0 ; first < len; first++) { + int cp = (int)value[first]; + if (Character.isSurrogate((char)cp)) { + hasSurr = true; + break; + } + if (cp != Character.toLowerCase(cp)) { // no need to check Character.ERROR + break; } - return this; } - + if (first == len) + return this; char[] result = new char[len]; - int resultOffset = 0; /* result may grow, so i+resultOffset - * is the write location in result */ - - /* Just copy the first few lowerCase characters. */ - System.arraycopy(value, 0, result, 0, firstUpper); - + System.arraycopy(value, 0, result, 0, first); // Just copy the first few + // lowerCase characters. String lang = locale.getLanguage(); - boolean localeDependent = - (lang == "tr" || lang == "az" || lang == "lt"); - char[] lowerCharArray; - int lowerChar; - int srcChar; + if (lang == "tr" || lang == "az" || lang == "lt") { + return toLowerCaseEx(result, first, locale, true); + } + if (hasSurr) { + return toLowerCaseEx(result, first, locale, false); + } + for (int i = first; i < len; i++) { + int cp = (int)value[i]; + if (cp == '\u03A3') { // GREEK CAPITAL LETTER SIGMA + return toLowerCaseEx(result, i, locale, false); + } + cp = Character.toLowerCase(cp); + if (!Character.isBmpCodePoint(cp)) { + return toLowerCaseEx(result, i, locale, false); + } + result[i] = (char)cp; + } + return new String(result, true); + } + + private String toLowerCaseEx(char[] result, int first, Locale locale, boolean localeDependent) { + int resultOffset = first; int srcCount; - for (int i = firstUpper; i < len; i += srcCount) { - srcChar = (int)value[i]; - if ((char)srcChar >= Character.MIN_HIGH_SURROGATE - && (char)srcChar <= Character.MAX_HIGH_SURROGATE) { + for (int i = first; i < value.length; i += srcCount) { + int srcChar = (int)value[i]; + int lowerChar; + char[] lowerCharArray; + srcCount = 1; + if (Character.isSurrogate((char)srcChar)) { srcChar = codePointAt(i); srcCount = Character.charCount(srcChar); - } else { - srcCount = 1; } if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale); } else { lowerChar = Character.toLowerCase(srcChar); } - if ((lowerChar == Character.ERROR) - || (lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) { + if (Character.isBmpCodePoint(lowerChar)) { // Character.ERROR is not a bmp + result[resultOffset++] = (char)lowerChar; + } else { if (lowerChar == Character.ERROR) { - lowerCharArray = - ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale); + lowerCharArray = ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale); } else if (srcCount == 2) { - resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount; + resultOffset += Character.toChars(lowerChar, result, resultOffset); continue; } else { lowerCharArray = Character.toChars(lowerChar); } - /* Grow result if needed */ int mapLen = lowerCharArray.length; if (mapLen > srcCount) { char[] result2 = new char[result.length + mapLen - srcCount]; - System.arraycopy(result, 0, result2, 0, i + resultOffset); + System.arraycopy(result, 0, result2, 0, resultOffset); result = result2; } for (int x = 0; x < mapLen; ++x) { - result[i + resultOffset + x] = lowerCharArray[x]; + result[resultOffset++] = lowerCharArray[x]; } - resultOffset += (mapLen - srcCount); - } else { - result[i + resultOffset] = (char)lowerChar; } } - return new String(result, 0, len + resultOffset); + return new String(result, 0, resultOffset); } /** @@ -2707,92 +2708,91 @@ public final class String if (locale == null) { throw new NullPointerException(); } - - int firstLower; + int first; + boolean hasSurr = false; final int len = value.length; - /* Now check if there are any characters that need to be changed. */ - scan: { - for (firstLower = 0 ; firstLower < len; ) { - int c = (int)value[firstLower]; - int srcCount; - if ((c >= Character.MIN_HIGH_SURROGATE) - && (c <= Character.MAX_HIGH_SURROGATE)) { - c = codePointAt(firstLower); - srcCount = Character.charCount(c); - } else { - srcCount = 1; - } - int upperCaseChar = Character.toUpperCaseEx(c); - if ((upperCaseChar == Character.ERROR) - || (c != upperCaseChar)) { - break scan; - } - firstLower += srcCount; + // Now check if there are any characters that need to be changed, or are surrogate + for (first = 0 ; first < len; first++ ) { + int cp = (int)value[first]; + if (Character.isSurrogate((char)cp)) { + hasSurr = true; + break; } + if (cp != Character.toUpperCaseEx(cp)) { // no need to check Character.ERROR + break; + } + } + if (first == len) { return this; } - - /* result may grow, so i+resultOffset is the write location in result */ - int resultOffset = 0; - char[] result = new char[len]; /* may grow */ - - /* Just copy the first few upperCase characters. */ - System.arraycopy(value, 0, result, 0, firstLower); - + char[] result = new char[len]; + System.arraycopy(value, 0, result, 0, first); // Just copy the first few + // upperCase characters. String lang = locale.getLanguage(); - boolean localeDependent = - (lang == "tr" || lang == "az" || lang == "lt"); - char[] upperCharArray; - int upperChar; - int srcChar; + if (lang == "tr" || lang == "az" || lang == "lt") { + return toUpperCaseEx(result, first, locale, true); + } + if (hasSurr) { + return toUpperCaseEx(result, first, locale, false); + } + for (int i = first; i < len; i++) { + int cp = Character.toUpperCaseEx((int)value[i]); + if (!Character.isBmpCodePoint(cp)) { // Character.ERROR is not bmp + return toUpperCaseEx(result, i, locale, false); + } + result[i] = (char)cp; + } + return new String(result, true); + } + + private String toUpperCaseEx(char[] result, int first, Locale locale, + boolean localeDependent) { + int resultOffset = first; int srcCount; - for (int i = firstLower; i < len; i += srcCount) { - srcChar = (int)value[i]; - if ((char)srcChar >= Character.MIN_HIGH_SURROGATE && - (char)srcChar <= Character.MAX_HIGH_SURROGATE) { + for (int i = first; i < value.length; i += srcCount) { + int srcChar = (int)value[i]; + int upperChar; + char[] upperCharArray; + srcCount = 1; + if (Character.isSurrogate((char)srcChar)) { srcChar = codePointAt(i); srcCount = Character.charCount(srcChar); - } else { - srcCount = 1; } if (localeDependent) { upperChar = ConditionalSpecialCasing.toUpperCaseEx(this, i, locale); } else { upperChar = Character.toUpperCaseEx(srcChar); } - if ((upperChar == Character.ERROR) - || (upperChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) { + if (Character.isBmpCodePoint(upperChar)) { + result[resultOffset++] = (char)upperChar; + } else { if (upperChar == Character.ERROR) { if (localeDependent) { upperCharArray = - ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale); + ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale); } else { upperCharArray = Character.toUpperCaseCharArray(srcChar); } } else if (srcCount == 2) { - resultOffset += Character.toChars(upperChar, result, i + resultOffset) - srcCount; + resultOffset += Character.toChars(upperChar, result, resultOffset); continue; } else { upperCharArray = Character.toChars(upperChar); } - /* Grow result if needed */ int mapLen = upperCharArray.length; if (mapLen > srcCount) { char[] result2 = new char[result.length + mapLen - srcCount]; - System.arraycopy(result, 0, result2, 0, i + resultOffset); + System.arraycopy(result, 0, result2, 0, resultOffset); result = result2; - } - for (int x = 0; x < mapLen; ++x) { - result[i + resultOffset + x] = upperCharArray[x]; - } - resultOffset += (mapLen - srcCount); - } else { - result[i + resultOffset] = (char)upperChar; + } + for (int x = 0; x < mapLen; ++x) { + result[resultOffset++] = upperCharArray[x]; + } } } - return new String(result, 0, len + resultOffset); + return new String(result, 0, resultOffset); } /** diff --git a/jdk/test/java/lang/String/ToLowerCase.java b/jdk/test/java/lang/String/ToLowerCase.java index b1edb92dcc1..3b194dbc5d3 100644 --- a/jdk/test/java/lang/String/ToLowerCase.java +++ b/jdk/test/java/lang/String/ToLowerCase.java @@ -23,7 +23,7 @@ /* @test - @bug 4217441 4533872 4900935 8020037 + @bug 4217441 4533872 4900935 8020037 8032012 @summary toLowerCase should lower-case Greek Sigma correctly depending on the context (final/non-final). Also it should handle Locale specific (lt, tr, and az) lowercasings and supplementary @@ -104,6 +104,22 @@ public class ToLowerCase { // invalid code point tests: test("\uD800\uD800\uD801A\uDC00\uDC00\uDC00B", Locale.US, "\uD800\uD800\uD801a\uDC00\uDC00\uDC00b"); + // test bmp + supp1 + StringBuilder src = new StringBuilder(0x20000); + StringBuilder exp = new StringBuilder(0x20000); + for (int cp = 0; cp < 0x20000; cp++) { + if (cp >= Character.MIN_HIGH_SURROGATE && cp <= Character.MAX_HIGH_SURROGATE) { + continue; + } + int lowerCase = Character.toLowerCase(cp); + if (lowerCase == -1) { //Character.ERROR + continue; + } + src.appendCodePoint(cp); + exp.appendCodePoint(lowerCase); + } + test(src.toString(), Locale.US, exp.toString()); + } static void test(String in, Locale locale, String expected) { From e956dc0c43e0663bf483b367eee278b0633a52c5 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Thu, 6 Feb 2014 10:30:18 -0800 Subject: [PATCH 12/30] 8033590: java.util.Comparator::thenComparing has unnecessary type restriction Reviewed-by: psandoz --- .../share/classes/java/util/Comparator.java | 4 +- jdk/test/java/util/Comparator/TypeTest.java | 44 ++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/java/util/Comparator.java b/jdk/src/share/classes/java/util/Comparator.java index 6f9d1663e69..ecf8d64ea95 100644 --- a/jdk/src/share/classes/java/util/Comparator.java +++ b/jdk/src/share/classes/java/util/Comparator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -235,7 +235,7 @@ public interface Comparator { * @see #thenComparing(Comparator) * @since 1.8 */ - default > Comparator thenComparing( + default Comparator thenComparing( Function keyExtractor, Comparator keyComparator) { diff --git a/jdk/test/java/util/Comparator/TypeTest.java b/jdk/test/java/util/Comparator/TypeTest.java index 69ae983197f..b060004d48e 100644 --- a/jdk/test/java/util/Comparator/TypeTest.java +++ b/jdk/test/java/util/Comparator/TypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /** * @test * @summary Comparator API narrowing type test + * @bug 8009736 8033590 * @run testng TypeTest */ @@ -33,6 +34,8 @@ import java.util.TreeMap; import java.util.Comparator; import org.testng.annotations.Test; +import static org.testng.Assert.assertTrue; + @Test(groups = "unit") public class TypeTest { static class Person { @@ -66,6 +69,24 @@ public class TypeTest { } } + static class Department { + Manager mgr; + String hr_code; + + Department(Manager mgr, String hr) { + this.mgr = mgr; + this.hr_code = hr; + } + + Manager getManager() { + return mgr; + } + + String getHR() { + return hr_code; + } + } + static void assertOrder(T o1, T o2, Comparator cmp) { if (cmp.compare(o1, o2) > 0) { System.out.println("Fail!!"); @@ -75,6 +96,8 @@ public class TypeTest { } } + // Type tests just to make sure the code can compile and build + // Not necessarily need a meaningful result public void testOrder() { Manager m1 = new Manager("Manager", 2, 2000); Manager m2 = new Manager("Manager", 4, 1300); @@ -93,4 +116,23 @@ public class TypeTest { Map map = new TreeMap<>(); map.entrySet().stream().sorted(Map.Entry.comparingByKey(String.CASE_INSENSITIVE_ORDER)); } + + public void testJDK8033590() { + Manager a = new Manager("John Doe", 1234, 16); + Manager b = new Manager("Jane Roe", 2468, 16); + Department da = new Department(a, "X"); + Department db = new Department(b, "X"); + + Comparator cmp = Comparator.comparing(Department::getHR) + .thenComparing(Department::getManager, Employee.C); + assertTrue(cmp.compare(da, db) < 0); + + cmp = Comparator.comparing(Department::getHR) + .thenComparing(Department::getManager, Manager.C); + assertTrue(cmp.compare(da, db) == 0); + + cmp = Comparator.comparing(Department::getHR) + .thenComparing(Department::getManager, Person.C); + assertTrue(cmp.compare(da, db) > 0); + } } From 79bbec5d8a53a00b2b42d194db820c49c5851522 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Mon, 10 Feb 2014 12:59:31 +0100 Subject: [PATCH 13/30] 8033917: Keep track of file paths in file streams and channels for instrumentation purposes Reviewed-by: alanb, dsamersoff --- .../classes/java/io/FileInputStream.java | 10 ++++++- .../classes/java/io/FileOutputStream.java | 10 ++++++- .../classes/java/io/RandomAccessFile.java | 9 +++++- .../classes/sun/nio/ch/FileChannelImpl.java | 29 ++++++++++++++----- .../SolarisUserDefinedFileAttributeView.java | 4 +-- .../sun/nio/fs/UnixChannelFactory.java | 6 ++-- .../sun/nio/fs/WindowsChannelFactory.java | 15 ++++++---- 7 files changed, 62 insertions(+), 21 deletions(-) diff --git a/jdk/src/share/classes/java/io/FileInputStream.java b/jdk/src/share/classes/java/io/FileInputStream.java index 3e67fb85515..836b3d6973f 100644 --- a/jdk/src/share/classes/java/io/FileInputStream.java +++ b/jdk/src/share/classes/java/io/FileInputStream.java @@ -51,6 +51,12 @@ class FileInputStream extends InputStream /* File Descriptor - handle to the open file */ private final FileDescriptor fd; + /** + * The path of the referenced file + * (null if the stream is created with a file descriptor) + */ + private final String path; + private FileChannel channel = null; private final Object closeLock = new Object(); @@ -128,6 +134,7 @@ class FileInputStream extends InputStream } fd = new FileDescriptor(); fd.attach(this); + path = name; open(name); } @@ -164,6 +171,7 @@ class FileInputStream extends InputStream security.checkRead(fdObj); } fd = fdObj; + path = null; /* * FileDescriptor is being shared by streams. @@ -345,7 +353,7 @@ class FileInputStream extends InputStream public FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, true, false, this); + channel = FileChannelImpl.open(fd, path, true, false, this); } return channel; } diff --git a/jdk/src/share/classes/java/io/FileOutputStream.java b/jdk/src/share/classes/java/io/FileOutputStream.java index 44f472870ec..8377261b448 100644 --- a/jdk/src/share/classes/java/io/FileOutputStream.java +++ b/jdk/src/share/classes/java/io/FileOutputStream.java @@ -67,6 +67,12 @@ class FileOutputStream extends OutputStream */ private FileChannel channel; + /** + * The path of the referenced file + * (null if the stream is created with a file descriptor) + */ + private final String path; + private final Object closeLock = new Object(); private volatile boolean closed = false; @@ -202,6 +208,7 @@ class FileOutputStream extends OutputStream this.fd = new FileDescriptor(); fd.attach(this); this.append = append; + this.path = name; open(name, append); } @@ -239,6 +246,7 @@ class FileOutputStream extends OutputStream } this.fd = fdObj; this.append = false; + this.path = null; fd.attach(this); } @@ -376,7 +384,7 @@ class FileOutputStream extends OutputStream public FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, false, true, append, this); + channel = FileChannelImpl.open(fd, path, false, true, append, this); } return channel; } diff --git a/jdk/src/share/classes/java/io/RandomAccessFile.java b/jdk/src/share/classes/java/io/RandomAccessFile.java index c48aa99b32f..ddd9f192eb1 100644 --- a/jdk/src/share/classes/java/io/RandomAccessFile.java +++ b/jdk/src/share/classes/java/io/RandomAccessFile.java @@ -62,6 +62,12 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { private FileChannel channel = null; private boolean rw; + /** + * The path of the referenced file + * (null if the stream is created with a file descriptor) + */ + private final String path; + private Object closeLock = new Object(); private volatile boolean closed = false; @@ -233,6 +239,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { } fd = new FileDescriptor(); fd.attach(this); + path = name; open(name, imode); } @@ -272,7 +279,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { public final FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, true, rw, this); + channel = FileChannelImpl.open(fd, path, true, rw, this); } return channel; } diff --git a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java index 2fcd0c89fe0..00842eda7c6 100644 --- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java +++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java @@ -29,10 +29,20 @@ import java.io.FileDescriptor; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; -import java.nio.channels.*; +import java.nio.channels.ClosedByInterruptException; +import java.nio.channels.ClosedChannelException; +import java.nio.channels.FileChannel; +import java.nio.channels.FileLock; +import java.nio.channels.FileLockInterruptionException; +import java.nio.channels.NonReadableChannelException; +import java.nio.channels.NonWritableChannelException; +import java.nio.channels.OverlappingFileLockException; +import java.nio.channels.ReadableByteChannel; +import java.nio.channels.WritableByteChannel; +import java.security.AccessController; import java.util.ArrayList; import java.util.List; -import java.security.AccessController; + import sun.misc.Cleaner; import sun.security.action.GetPropertyAction; @@ -56,13 +66,17 @@ public class FileChannelImpl // Required to prevent finalization of creating stream (immutable) private final Object parent; + // The path of the referenced file + // (null if the parent stream is created with a file descriptor) + private final String path; + // Thread-safe set of IDs of native threads, for signalling private final NativeThreadSet threads = new NativeThreadSet(2); // Lock for operations involving position and size private final Object positionLock = new Object(); - private FileChannelImpl(FileDescriptor fd, boolean readable, + private FileChannelImpl(FileDescriptor fd, String path, boolean readable, boolean writable, boolean append, Object parent) { this.fd = fd; @@ -70,23 +84,24 @@ public class FileChannelImpl this.writable = writable; this.append = append; this.parent = parent; + this.path = path; this.nd = new FileDispatcherImpl(append); } // Used by FileInputStream.getChannel() and RandomAccessFile.getChannel() - public static FileChannel open(FileDescriptor fd, + public static FileChannel open(FileDescriptor fd, String path, boolean readable, boolean writable, Object parent) { - return new FileChannelImpl(fd, readable, writable, false, parent); + return new FileChannelImpl(fd, path, readable, writable, false, parent); } // Used by FileOutputStream.getChannel - public static FileChannel open(FileDescriptor fd, + public static FileChannel open(FileDescriptor fd, String path, boolean readable, boolean writable, boolean append, Object parent) { - return new FileChannelImpl(fd, readable, writable, append, parent); + return new FileChannelImpl(fd, path, readable, writable, append, parent); } private void ensureOpen() throws IOException { diff --git a/jdk/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java b/jdk/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java index d3a34cac129..a59f30da7fb 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java +++ b/jdk/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java @@ -149,7 +149,7 @@ class SolarisUserDefinedFileAttributeView int afd = openat(fd, nameAsBytes(file,name), (O_RDONLY|O_XATTR), 0); // wrap with channel - FileChannel fc = UnixChannelFactory.newFileChannel(afd, true, false); + FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), true, false); // read to EOF (nothing we can do if I/O error occurs) try { @@ -190,7 +190,7 @@ class SolarisUserDefinedFileAttributeView UnixFileModeAttribute.ALL_PERMISSIONS); // wrap with channel - FileChannel fc = UnixChannelFactory.newFileChannel(afd, false, true); + FileChannel fc = UnixChannelFactory.newFileChannel(afd, file.toString(), false, true); // write value (nothing we can do if I/O error occurs) try { diff --git a/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java b/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java index ec44ee1514a..83f99c5485d 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java +++ b/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java @@ -100,10 +100,10 @@ class UnixChannelFactory { /** * Constructs a file channel from an existing (open) file descriptor */ - static FileChannel newFileChannel(int fd, boolean reading, boolean writing) { + static FileChannel newFileChannel(int fd, String path, boolean reading, boolean writing) { FileDescriptor fdObj = new FileDescriptor(); fdAccess.set(fdObj, fd); - return FileChannelImpl.open(fdObj, reading, writing, null); + return FileChannelImpl.open(fdObj, path, reading, writing, null); } /** @@ -134,7 +134,7 @@ class UnixChannelFactory { throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); - return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null); + return FileChannelImpl.open(fdObj, path.toString(), flags.read, flags.write, flags.append, null); } /** diff --git a/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java b/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java index d9b1489c378..46d063ca172 100644 --- a/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java +++ b/jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java @@ -25,19 +25,22 @@ package sun.nio.fs; -import java.nio.file.*; -import java.nio.channels.*; import java.io.FileDescriptor; import java.io.IOException; -import java.util.*; +import java.nio.channels.AsynchronousFileChannel; +import java.nio.channels.FileChannel; +import java.nio.file.LinkOption; +import java.nio.file.OpenOption; +import java.nio.file.StandardOpenOption; +import java.util.Set; import com.sun.nio.file.ExtendedOpenOption; +import sun.misc.JavaIOFileDescriptorAccess; +import sun.misc.SharedSecrets; import sun.nio.ch.FileChannelImpl; import sun.nio.ch.ThreadPool; import sun.nio.ch.WindowsAsynchronousFileChannelImpl; -import sun.misc.SharedSecrets; -import sun.misc.JavaIOFileDescriptorAccess; import static sun.nio.fs.WindowsNativeDispatcher.*; import static sun.nio.fs.WindowsConstants.*; @@ -157,7 +160,7 @@ class WindowsChannelFactory { throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(pathForWindows, pathToCheck, flags, pSecurityDescriptor); - return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null); + return FileChannelImpl.open(fdObj, pathForWindows, flags.read, flags.write, flags.append, null); } /** From 672016101260ebfb532a1401b3bf5a79dcc46454 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Mon, 10 Feb 2014 13:00:50 +0100 Subject: [PATCH 14/30] 8033911: Simplify instrumentation of FileInputStream and RandomAccessFile Reviewed-by: alanb, dsamersoff, jbachorik --- jdk/make/mapfiles/libjava/mapfile-vers | 6 +++--- jdk/src/share/classes/java/io/FileInputStream.java | 6 +++++- jdk/src/share/classes/java/io/RandomAccessFile.java | 12 ++++++++++-- jdk/src/share/native/java/io/FileInputStream.c | 2 +- jdk/src/share/native/java/io/RandomAccessFile.c | 4 ++-- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index 84278c1e3ed..760babc2ee1 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -79,7 +79,7 @@ SUNWprivate_1.1 { Java_java_io_FileInputStream_close0; Java_java_io_FileInputStream_initIDs; Java_java_io_FileInputStream_open; - Java_java_io_FileInputStream_read; + Java_java_io_FileInputStream_read0; Java_java_io_FileInputStream_readBytes; Java_java_io_FileInputStream_skip; Java_java_io_FileOutputStream_close0; @@ -98,11 +98,11 @@ SUNWprivate_1.1 { Java_java_io_RandomAccessFile_initIDs; Java_java_io_RandomAccessFile_length; Java_java_io_RandomAccessFile_open; - Java_java_io_RandomAccessFile_read; + Java_java_io_RandomAccessFile_read0; Java_java_io_RandomAccessFile_readBytes; Java_java_io_RandomAccessFile_seek0; Java_java_io_RandomAccessFile_setLength; - Java_java_io_RandomAccessFile_write; + Java_java_io_RandomAccessFile_write0; Java_java_io_RandomAccessFile_writeBytes; Java_java_io_UnixFileSystem_canonicalize0; Java_java_io_UnixFileSystem_checkAccess; diff --git a/jdk/src/share/classes/java/io/FileInputStream.java b/jdk/src/share/classes/java/io/FileInputStream.java index 836b3d6973f..cc6710e8fda 100644 --- a/jdk/src/share/classes/java/io/FileInputStream.java +++ b/jdk/src/share/classes/java/io/FileInputStream.java @@ -194,7 +194,11 @@ class FileInputStream extends InputStream * file is reached. * @exception IOException if an I/O error occurs. */ - public native int read() throws IOException; + public int read() throws IOException { + return read0(); + } + + private native int read0() throws IOException; /** * Reads a subarray as a sequence of bytes. diff --git a/jdk/src/share/classes/java/io/RandomAccessFile.java b/jdk/src/share/classes/java/io/RandomAccessFile.java index ddd9f192eb1..58d8c89cdcc 100644 --- a/jdk/src/share/classes/java/io/RandomAccessFile.java +++ b/jdk/src/share/classes/java/io/RandomAccessFile.java @@ -316,7 +316,11 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * @exception IOException if an I/O error occurs. Not thrown if * end-of-file has been reached. */ - public native int read() throws IOException; + public int read() throws IOException { + return read0(); + } + + private native int read0() throws IOException; /** * Reads a sub array as a sequence of bytes. @@ -464,7 +468,11 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * @param b the {@code byte} to be written. * @exception IOException if an I/O error occurs. */ - public native void write(int b) throws IOException; + public void write(int b) throws IOException { + write0(b); + } + + private native void write0(int b) throws IOException; /** * Writes a sub array as a sequence of bytes. diff --git a/jdk/src/share/native/java/io/FileInputStream.c b/jdk/src/share/native/java/io/FileInputStream.c index 52e2cdd8e6b..092ddbf6f1f 100644 --- a/jdk/src/share/native/java/io/FileInputStream.c +++ b/jdk/src/share/native/java/io/FileInputStream.c @@ -62,7 +62,7 @@ Java_java_io_FileInputStream_open(JNIEnv *env, jobject this, jstring path) { } JNIEXPORT jint JNICALL -Java_java_io_FileInputStream_read(JNIEnv *env, jobject this) { +Java_java_io_FileInputStream_read0(JNIEnv *env, jobject this) { return readSingle(env, this, fis_fd); } diff --git a/jdk/src/share/native/java/io/RandomAccessFile.c b/jdk/src/share/native/java/io/RandomAccessFile.c index 3251db87fb9..53b5f1aac1f 100644 --- a/jdk/src/share/native/java/io/RandomAccessFile.c +++ b/jdk/src/share/native/java/io/RandomAccessFile.c @@ -64,7 +64,7 @@ Java_java_io_RandomAccessFile_open(JNIEnv *env, } JNIEXPORT jint JNICALL -Java_java_io_RandomAccessFile_read(JNIEnv *env, jobject this) { +Java_java_io_RandomAccessFile_read0(JNIEnv *env, jobject this) { return readSingle(env, this, raf_fd); } @@ -75,7 +75,7 @@ Java_java_io_RandomAccessFile_readBytes(JNIEnv *env, } JNIEXPORT void JNICALL -Java_java_io_RandomAccessFile_write(JNIEnv *env, jobject this, jint byte) { +Java_java_io_RandomAccessFile_write0(JNIEnv *env, jobject this, jint byte) { writeSingle(env, this, byte, JNI_FALSE, raf_fd); } From 1cf765b9e84483d92cd825490ad346a1a1d4682d Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Mon, 10 Feb 2014 14:01:16 +0100 Subject: [PATCH 15/30] 6791551: ExclusiveBind.java has a race condition Reviewed-by: sla, sjiang --- jdk/test/com/sun/jdi/ExclusiveBind.java | 94 +++++++++---------------- 1 file changed, 34 insertions(+), 60 deletions(-) diff --git a/jdk/test/com/sun/jdi/ExclusiveBind.java b/jdk/test/com/sun/jdi/ExclusiveBind.java index 3389ee220f8..d53efd8d585 100644 --- a/jdk/test/com/sun/jdi/ExclusiveBind.java +++ b/jdk/test/com/sun/jdi/ExclusiveBind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,57 +25,28 @@ * @bug 4531526 * @summary Test that more than one debuggee cannot bind to same port * at the same time. + * @library /lib/testlibrary * + * @build jdk.testlibrary.ProcessTools jdk.testlibrary.JDKToolLauncher jdk.testlibrary.Utils * @build VMConnection ExclusiveBind HelloWorld * @run main ExclusiveBind */ -import java.io.InputStream; -import java.io.IOException; -import java.io.File; import java.net.ServerSocket; import com.sun.jdi.Bootstrap; import com.sun.jdi.VirtualMachine; import com.sun.jdi.connect.Connector; import com.sun.jdi.connect.AttachingConnector; + +import java.util.ArrayList; import java.util.Map; import java.util.List; import java.util.Iterator; +import java.util.concurrent.TimeUnit; + +import jdk.testlibrary.ProcessTools; +import jdk.testlibrary.Utils; public class ExclusiveBind { - - /* - * Helper class to direct process output to the parent - * System.out - */ - static class IOHandler implements Runnable { - InputStream in; - - IOHandler(InputStream in) { - this.in = in; - } - - static void handle(InputStream in) { - IOHandler handler = new IOHandler(in); - Thread thr = new Thread(handler); - thr.setDaemon(true); - thr.start(); - } - - public void run() { - try { - byte b[] = new byte[100]; - for (;;) { - int n = in.read(b); - if (n < 0) return; - for (int i=0; i args = new ArrayList<>(); + for(String dbgOption : VMConnection.getDebuggeeVMOptions().split(" ")) { + args.add(dbgOption); } - cmd += ",address=" + address + " " + class_name; + String lib = "-agentlib:jdwp=transport=dt_socket,server=y,suspend="; + if (suspend) { + lib += "y"; + } else { + lib += "n"; + } + lib += ",address=" + address; - System.out.println("Starting: " + cmd); + args.add(lib); + args.add(class_name); - Process p = Runtime.getRuntime().exec(cmd); - IOHandler.handle(p.getInputStream()); - IOHandler.handle(p.getErrorStream()); - - return p; + return ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()])); } /* @@ -132,16 +101,21 @@ public class ExclusiveBind { String address = String.valueOf(port); // launch the first debuggee - Process process1 = launch(address, true, "HelloWorld"); - - // give first debuggee time to suspend - Thread.currentThread().sleep(5000); + ProcessBuilder process1 = prepareLauncher(address, true, "HelloWorld"); + // start the debuggee and wait for the "ready" message + Process p = ProcessTools.startProcess( + "process1", + process1, + line -> line.equals("Listening for transport dt_socket at address: " + address), + Math.round(5000 * Utils.TIMEOUT_FACTOR), + TimeUnit.MILLISECONDS + ); // launch a second debuggee with the same address - Process process2 = launch(address, false, "HelloWorld"); + ProcessBuilder process2 = prepareLauncher(address, false, "HelloWorld"); // get exit status from second debuggee - int exitCode = process2.waitFor(); + int exitCode = ProcessTools.startProcess("process2", process2).waitFor(); // clean-up - attach to first debuggee and resume it AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach"); From 77bcb60eeefa220cbe5597db83ceeccfc7454163 Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Mon, 10 Feb 2014 14:35:42 +0000 Subject: [PATCH 16/30] 7152892: some jtreg tests fail with permission denied Reviewed-by: coffeys --- jdk/test/java/lang/ClassLoader/Assert.sh | 16 ++++++++++++++++ jdk/test/java/rmi/registry/readTest/readTest.sh | 4 ++++ jdk/test/java/util/zip/ZipFile/ReadZip.java | 2 ++ jdk/test/sun/net/www/protocol/jar/jarbug/run.sh | 4 ++++ 4 files changed, 26 insertions(+) diff --git a/jdk/test/java/lang/ClassLoader/Assert.sh b/jdk/test/java/lang/ClassLoader/Assert.sh index 812e6f43340..e65e6b8176f 100644 --- a/jdk/test/java/lang/ClassLoader/Assert.sh +++ b/jdk/test/java/lang/ClassLoader/Assert.sh @@ -23,6 +23,21 @@ # +OS=`uname -s` +case "$OS" in + SunOS | Linux | Darwin ) + FS="/" + CHMOD="${FS}bin${FS}chmod" + ;; + Windows* | CYGWIN* ) + CHMOD="chmod" + ;; + * ) + echo "Unrecognized system!" + exit 1; + ;; +esac + if [ "${TESTSRC}" = "" ] then echo "TESTSRC not set. Test cannot execute. Failed." @@ -50,6 +65,7 @@ echo "CLASSPATH=${CLASSPATH}" cp ${TESTSRC}/Assert.java . cp -R ${TESTSRC}/package1 . cp -R ${TESTSRC}/package2 . +${CHMOD} -R u+w * ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} Assert.java diff --git a/jdk/test/java/rmi/registry/readTest/readTest.sh b/jdk/test/java/rmi/registry/readTest/readTest.sh index 812d0a42b54..b43b2b59ba1 100644 --- a/jdk/test/java/rmi/registry/readTest/readTest.sh +++ b/jdk/test/java/rmi/registry/readTest/readTest.sh @@ -37,11 +37,13 @@ case "$OS" in SunOS | Linux | Darwin | AIX ) PS=":" FS="/" + CHMOD="${FS}bin${FS}chmod" FILEURL="file:" ;; Windows* ) PS=";" FS="\\" + CHMOD="chmod" FILEURL="file:/" if [ "$VER" -eq "5" ]; then ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000" @@ -51,6 +53,7 @@ case "$OS" in CYGWIN* ) PS=";" FS="/" + CHMOD="chmod" FILEURL="file:/" if [ "$VER" -eq "5" ]; then ARGS="-Djdk.net.ephemeralPortRange.low=1024 -Djdk.net.ephemeralPortRange.high=65000" @@ -65,6 +68,7 @@ esac TEST_CLASSPATH=.$PS${TESTCLASSPATH:-$TESTCLASSES} cp -r ${TESTSRC}${FS}* . +${CHMOD} -R u+w * ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} testPkg${FS}*java ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -cp $TEST_CLASSPATH readTest.java diff --git a/jdk/test/java/util/zip/ZipFile/ReadZip.java b/jdk/test/java/util/zip/ZipFile/ReadZip.java index b0e757158f7..44f1d9ed97f 100644 --- a/jdk/test/java/util/zip/ZipFile/ReadZip.java +++ b/jdk/test/java/util/zip/ZipFile/ReadZip.java @@ -63,6 +63,8 @@ public class ReadZip { Files.copy(Paths.get(System.getProperty("test.src", ""), "input.zip"), newZip.toPath(), StandardCopyOption.REPLACE_EXISTING); + newZip.setWritable(true); + // pad some bytes try (OutputStream os = Files.newOutputStream(newZip.toPath(), StandardOpenOption.APPEND)) { diff --git a/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh b/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh index 69632014bac..32de6ee0f78 100644 --- a/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh +++ b/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh @@ -34,14 +34,17 @@ case "$OS" in SunOS | Linux | Darwin | AIX ) PS=":" FS="/" + CHMOD="${FS}bin${FS}chmod" ;; Windows* ) PS=";" FS="\\" + CHMOD="chmod" ;; CYGWIN* ) PS=";" FS="/" + CHMOD="chmod" # # javac does not like /cygdrive produced by `pwd`. # @@ -59,6 +62,7 @@ esac mkdir -p ${DEST}${FS}jar1 cd ${TESTSRC}${FS}etc${FS}jar1 cp -r . ${DEST}${FS}jar1 +${CHMOD} -R u+w ${DEST}${FS}jar1 ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \ ${TESTSRC}${FS}src${FS}jar1${FS}LoadResourceBundle.java ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \ From 401de1c53e4e8fb4b4896b7ee9f0b00d4910adb5 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 10 Feb 2014 08:53:13 -0800 Subject: [PATCH 17/30] 8034046: Fix serial lint warnings in javax.sound Reviewed-by: alanb, serb --- .../sound/midi/InvalidMidiDataException.java | 4 +- .../sound/midi/MidiUnavailableException.java | 4 +- .../javax/sound/sampled/AudioPermission.java | 131 +----------------- .../javax/sound/sampled/LineEvent.java | 3 +- .../sampled/LineUnavailableException.java | 4 +- .../UnsupportedAudioFileException.java | 12 +- 6 files changed, 12 insertions(+), 146 deletions(-) diff --git a/jdk/src/share/classes/javax/sound/midi/InvalidMidiDataException.java b/jdk/src/share/classes/javax/sound/midi/InvalidMidiDataException.java index 4199a2b79af..ed20121fab8 100644 --- a/jdk/src/share/classes/javax/sound/midi/InvalidMidiDataException.java +++ b/jdk/src/share/classes/javax/sound/midi/InvalidMidiDataException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ package javax.sound.midi; * @author Kara Kytle */ public class InvalidMidiDataException extends Exception { + private static final long serialVersionUID = 2780771756789932067L; /** * Constructs an InvalidMidiDataException with @@ -49,7 +50,6 @@ public class InvalidMidiDataException extends Exception { super(); } - /** * Constructs an InvalidMidiDataException with the * specified detail message. diff --git a/jdk/src/share/classes/javax/sound/midi/MidiUnavailableException.java b/jdk/src/share/classes/javax/sound/midi/MidiUnavailableException.java index 0a7191e165c..85ace347d8b 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiUnavailableException.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiUnavailableException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,7 @@ package javax.sound.midi; * @author Kara Kytle */ public class MidiUnavailableException extends Exception { + private static final long serialVersionUID = 6093809578628944323L; /** * Constructs a MidiUnavailableException that has @@ -49,7 +50,6 @@ public class MidiUnavailableException extends Exception { super(); } - /** * Constructs a MidiUnavailableException with the * specified detail message. diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java b/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java index a265544d590..4e7dcef9602 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ package javax.sound.sampled; import java.security.BasicPermission; - /** * The AudioPermission class represents access rights to the audio * system resources. An AudioPermission contains a target name @@ -76,134 +75,8 @@ import java.security.BasicPermission; * @author Kara Kytle * @since 1.3 */ -/* - * (OLD PERMISSIONS TAKEN OUT FOR 1.2 BETA) - * - * - * playback device access - * Direct access to the audio playback device(s), including configuration of the - * playback format, volume, and balance, explicit opening and closing of the device, - * etc. - * Changes the properties of a shared system device and therefore - * can affect other applications. - * - * - * - * playback device override - * Manipulation of the audio playback device(s) in a way that directly conflicts - * with use by other applications. This includes closing the device while it is in - * use by another application, changing the device format while another application - * is using it, etc. - * Changes the properties of a shared system device and therefore - * can affect other applications. - * - * - * - * record device access - * Direct access to the audio recording device(s), including configuration of the - * the record format, volume, and balance, explicit opening and closing of the device, - * etc. - * Changes the properties of a shared system device and therefore - * can affect other applications. - * - * - * - * record device override - * Manipulation of the audio recording device(s) in a way that directly conflicts - * with use by other applications. This includes closing the device while it is in - * use by another application, changing the device format while another application - * is using it, etc. - * Changes the properties of a shared system device and therefore - * can affect other applications. - * - * - * - *

- * - * @author Kara Kytle - * @since 1.3 - */ - -/* - * The AudioPermission class represents access rights to the audio - * system resources. An AudioPermission contains a target name - * but no actions list; you either have the named permission or you don't. - *

- * The target name is the name of the audio permission (see the table below). - * The names follow the hierarchical property-naming convention. Also, an asterisk - * can be used to represent all the audio permissions. - *

- * The following table lists all the possible AudioPermission target names. - * For each name, the table provides a description of exactly what that permission - * allows, as well as a discussion of the risks of granting code the permission. - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
playAudio playback through the audio device or devices on the system.Allows the application to use a system device. Can affect other applications, - * because the result will be mixed with other audio being played on the system.
recordRecording audio from the audio device or devices on the system, - * commonly through a microphone.Can enable an applet or application to eavesdrop on a user.
playback device accessDirect access to the audio playback device(s), including configuration of the - * playback format, volume, and balance, explicit opening and closing of the device, - * etc.Changes the properties of a shared system device and therefore - * can affect other applications.
playback device overrideManipulation of the audio playback device(s) in a way that directly conflicts - * with use by other applications. This includes closing the device while it is in - * use by another application, changing the device format while another application - * is using it, etc. Changes the properties of a shared system device and therefore - * can affect other applications.
record device accessDirect access to the audio recording device(s), including configuration of the - * the record format, volume, and balance, explicit opening and closing of the device, - * etc.Changes the properties of a shared system device and therefore - * can affect other applications.
record device overrideManipulation of the audio recording device(s) in a way that directly conflicts - * with use by other applications. This includes closing the device while it is in - * use by another application, changing the device format while another application - * is using it, etc. Changes the properties of a shared system device and therefore - * can affect other applications.
- *

- * - * @author Kara Kytle - */ - public class AudioPermission extends BasicPermission { + private static final long serialVersionUID = -5518053473477801126L; /** * Creates a new AudioPermission object that has the specified diff --git a/jdk/src/share/classes/javax/sound/sampled/LineEvent.java b/jdk/src/share/classes/javax/sound/sampled/LineEvent.java index d94c757de91..ff5b90f1ba1 100644 --- a/jdk/src/share/classes/javax/sound/sampled/LineEvent.java +++ b/jdk/src/share/classes/javax/sound/sampled/LineEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,7 @@ package javax.sound.sampled; * @serial exclude */ public class LineEvent extends java.util.EventObject { + private static final long serialVersionUID = -1274246333383880410L; // INSTANCE VARIABLES diff --git a/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java b/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java index c63f9adcd01..1e72f75061e 100644 --- a/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java +++ b/jdk/src/share/classes/javax/sound/sampled/LineUnavailableException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ package javax.sound.sampled; */ public class LineUnavailableException extends Exception { + private static final long serialVersionUID = -2046718279487432130L; /** * Constructs a LineUnavailableException that has @@ -54,7 +55,6 @@ public class LineUnavailableException extends Exception { super(); } - /** * Constructs a LineUnavailableException that has * the specified detail message. diff --git a/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java b/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java index 56690b5a495..45acd480f35 100644 --- a/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java +++ b/jdk/src/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,15 +33,8 @@ package javax.sound.sampled; * @author Kara Kytle * @since 1.3 */ -/* - * An UnsupportedAudioFileException is an exception indicating that an - * operation failed because a file did not contain valid data of a recognized file - * type and format. - * - * @author Kara Kytle - */ - public class UnsupportedAudioFileException extends Exception { + private static final long serialVersionUID = -139127412623160368L; /** * Constructs a UnsupportedAudioFileException that has @@ -52,7 +45,6 @@ public class UnsupportedAudioFileException extends Exception { super(); } - /** * Constructs a UnsupportedAudioFileException that has * the specified detail message. From d03152e11b3ecfc0027eb0c052a0d273b49a16b0 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 10 Feb 2014 18:09:40 -0800 Subject: [PATCH 18/30] 8034050: Fix serial lint warnings in javax.print Reviewed-by: alanb, prr --- jdk/src/share/classes/javax/print/DocFlavor.java | 1 + .../share/classes/javax/print/PrintException.java | 4 ++-- .../print/attribute/AttributeSetUtilities.java | 13 ++++++++++++- .../print/attribute/UnmodifiableSetException.java | 4 +++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/javax/print/DocFlavor.java b/jdk/src/share/classes/javax/print/DocFlavor.java index 3c94623c222..d016cb7edb8 100644 --- a/jdk/src/share/classes/javax/print/DocFlavor.java +++ b/jdk/src/share/classes/javax/print/DocFlavor.java @@ -1045,6 +1045,7 @@ public class DocFlavor implements Serializable, Cloneable { * @author Alan Kaminsky */ public static class URL extends DocFlavor { + private static final long serialVersionUID = 2936725788144902062L; /** * Constructs a new doc flavor with the given MIME type and a print diff --git a/jdk/src/share/classes/javax/print/PrintException.java b/jdk/src/share/classes/javax/print/PrintException.java index a66df87265a..f3019980831 100644 --- a/jdk/src/share/classes/javax/print/PrintException.java +++ b/jdk/src/share/classes/javax/print/PrintException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ package javax.print; * */ public class PrintException extends Exception { - + private static final long serialVersionUID = -5932531546705242471L; /** * Construct a print exception with no detail message. diff --git a/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java b/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java index aa1468f74f5..42ebc1f512d 100644 --- a/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java +++ b/jdk/src/share/classes/javax/print/attribute/AttributeSetUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,6 +77,7 @@ public final class AttributeSetUtilities { */ private static class UnmodifiableAttributeSet implements AttributeSet, Serializable { + private static final long serialVersionUID = -6131802583863447813L; private AttributeSet attrset; @@ -147,6 +148,7 @@ public final class AttributeSetUtilities { private static class UnmodifiableDocAttributeSet extends UnmodifiableAttributeSet implements DocAttributeSet, Serializable { + private static final long serialVersionUID = -6349408326066898956L; public UnmodifiableDocAttributeSet(DocAttributeSet attributeSet) { @@ -161,6 +163,7 @@ public final class AttributeSetUtilities { extends UnmodifiableAttributeSet implements PrintRequestAttributeSet, Serializable { + private static final long serialVersionUID = 7799373532614825073L; public UnmodifiablePrintRequestAttributeSet (PrintRequestAttributeSet attributeSet) { @@ -175,6 +178,7 @@ public final class AttributeSetUtilities { extends UnmodifiableAttributeSet implements PrintJobAttributeSet, Serializable { + private static final long serialVersionUID = -8002245296274522112L; public UnmodifiablePrintJobAttributeSet (PrintJobAttributeSet attributeSet) { @@ -189,6 +193,7 @@ public final class AttributeSetUtilities { extends UnmodifiableAttributeSet implements PrintServiceAttributeSet, Serializable { + private static final long serialVersionUID = -7112165137107826819L; public UnmodifiablePrintServiceAttributeSet (PrintServiceAttributeSet attributeSet) { @@ -291,6 +296,7 @@ public final class AttributeSetUtilities { */ private static class SynchronizedAttributeSet implements AttributeSet, Serializable { + private static final long serialVersionUID = 8365731020128564925L; private AttributeSet attrset; @@ -357,6 +363,7 @@ public final class AttributeSetUtilities { private static class SynchronizedDocAttributeSet extends SynchronizedAttributeSet implements DocAttributeSet, Serializable { + private static final long serialVersionUID = 6455869095246629354L; public SynchronizedDocAttributeSet(DocAttributeSet attributeSet) { super(attributeSet); @@ -369,6 +376,7 @@ public final class AttributeSetUtilities { private static class SynchronizedPrintRequestAttributeSet extends SynchronizedAttributeSet implements PrintRequestAttributeSet, Serializable { + private static final long serialVersionUID = 5671237023971169027L; public SynchronizedPrintRequestAttributeSet (PrintRequestAttributeSet attributeSet) { @@ -382,6 +390,7 @@ public final class AttributeSetUtilities { private static class SynchronizedPrintJobAttributeSet extends SynchronizedAttributeSet implements PrintJobAttributeSet, Serializable { + private static final long serialVersionUID = 2117188707856965749L; public SynchronizedPrintJobAttributeSet (PrintJobAttributeSet attributeSet) { @@ -395,6 +404,8 @@ public final class AttributeSetUtilities { private static class SynchronizedPrintServiceAttributeSet extends SynchronizedAttributeSet implements PrintServiceAttributeSet, Serializable { + private static final long serialVersionUID = -2830705374001675073L; + public SynchronizedPrintServiceAttributeSet (PrintServiceAttributeSet attributeSet) { super(attributeSet); diff --git a/jdk/src/share/classes/javax/print/attribute/UnmodifiableSetException.java b/jdk/src/share/classes/javax/print/attribute/UnmodifiableSetException.java index 943f15ddba6..a5b4d1d9ddb 100644 --- a/jdk/src/share/classes/javax/print/attribute/UnmodifiableSetException.java +++ b/jdk/src/share/classes/javax/print/attribute/UnmodifiableSetException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ package javax.print.attribute; * @since 1.4 */ public class UnmodifiableSetException extends RuntimeException { + private static final long serialVersionUID = 2255250308571511731L; + /** * Constructs an UnsupportedOperationException with no detail message. */ From f776be9c0f5754a6972b67d05aa18b9e50cbf492 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 11 Feb 2014 09:59:34 +0000 Subject: [PATCH 19/30] 8034043: Native methods for preferences API should not be in libjava 8034026: SCDynamicStoreConfig.m should not be in src/macosx/native/java/util Reviewed-by: erikj, weijun, mchung --- jdk/make/lib/CoreLibraries.gmk | 38 ++++++++++++++++++- jdk/make/lib/PlatformLibraries.gmk | 1 - jdk/make/lib/SecurityLibraries.gmk | 14 +++++-- jdk/make/mapfiles/libjava/mapfile-vers | 10 +---- jdk/make/mapfiles/libprefs/mapfile-vers | 36 ++++++++++++++++++ jdk/make/profile-includes.txt | 1 + .../util/prefs/MacOSXPreferencesFile.java | 2 +- .../util/{ => prefs}/MacOSXPreferencesFile.m | 0 .../security/krb5}/SCDynamicStoreConfig.m | 0 .../java/util/logging/FileHandler.java | 7 +--- jdk/src/share/classes/sun/misc/VM.java | 5 +++ .../security/krb5/SCDynamicStoreConfig.java | 2 +- .../util/prefs/FileSystemPreferences.java | 11 +++++- .../util/{ => prefs}/FileSystemPreferences.c | 0 .../{java/util/logging.c => sun/misc/VM_md.c} | 6 +-- .../java/util/prefs/WindowsPreferences.java | 11 ++++++ .../util/{ => prefs}/WindowsPreferences.c | 0 .../{java/util/logging.c => sun/misc/VM_md.c} | 6 +-- 18 files changed, 116 insertions(+), 34 deletions(-) create mode 100644 jdk/make/mapfiles/libprefs/mapfile-vers rename jdk/src/macosx/native/java/util/{ => prefs}/MacOSXPreferencesFile.m (100%) rename jdk/src/macosx/native/{java/util => sun/security/krb5}/SCDynamicStoreConfig.m (100%) rename jdk/src/solaris/native/java/util/{ => prefs}/FileSystemPreferences.c (100%) rename jdk/src/solaris/native/{java/util/logging.c => sun/misc/VM_md.c} (91%) rename jdk/src/windows/native/java/util/{ => prefs}/WindowsPreferences.c (100%) rename jdk/src/windows/native/{java/util/logging.c => sun/misc/VM_md.c} (91%) diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index 7387a57f4a6..627dfceced2 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -123,6 +123,7 @@ LIBJAVA_SRC_DIRS := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/l $(JDK_TOPDIR)/src/share/native/java/security \ $(JDK_TOPDIR)/src/share/native/common \ $(JDK_TOPDIR)/src/share/native/sun/misc \ + $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/misc \ $(JDK_TOPDIR)/src/share/native/sun/reflect \ $(JDK_TOPDIR)/src/share/native/java/util \ $(JDK_TOPDIR)/src/share/native/java/util/concurrent/atomic \ @@ -187,7 +188,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA, \ LIBRARY := java, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ SRC := $(LIBJAVA_SRC_DIRS), \ - EXCLUDES := fdlibm/src zip, \ + EXCLUDES := fdlibm/src zip prefs, \ EXCLUDE_FILES := $(LIBJAVA_EXCLUDE_FILES), \ LANG := C, \ OPTIMIZATION := HIGH, \ @@ -285,6 +286,41 @@ BUILD_LIBRARIES += $(BUILD_LIBZIP) ########################################################################################## +ifeq ($(OPENJDK_TARGET_OS), macosx) + LIBPREF_SRC_DIRS := $(JDK_TOPDIR)/src/macosx/native/java/util/prefs +else + LIBPREF_SRC_DIRS := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util/prefs +endif + +$(eval $(call SetupNativeCompilation,BUILD_LIBPREFS, \ + LIBRARY := prefs, \ + OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ + SRC := $(LIBPREF_SRC_DIRS), \ + LANG := C, \ + OPTIMIZATION := HIGH, \ + CFLAGS := $(CFLAGS_JDKLIB), \ + MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libprefs/mapfile-vers, \ + LDFLAGS := $(LDFLAGS_JDKLIB) \ + $(call SET_SHARED_LIBRARY_ORIGIN), \ + LDFLAGS_SUFFIX_linux := -ljvm -ljava, \ + LDFLAGS_SUFFIX_solaris := -ljvm -ljava -lc, \ + LDFLAGS_SUFFIX_aix := -ljvm -ljava, \ + LDFLAGS_SUFFIX_windows := advapi32.lib, \ + LDFLAGS_SUFFIX_macosx := -ljvm -framework CoreFoundation, \ + VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ + RC_FLAGS := $(RC_FLAGS) \ + -D "JDK_FNAME=prefs.dll" \ + -D "JDK_INTERNAL_NAME=prefs" \ + -D "JDK_FTYPE=0x2L", \ + OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libprefs, \ + DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) + +$(BUILD_LIBPREFS): $(BUILD_LIBJAVA) + +BUILD_LIBRARIES += $(BUILD_LIBPREFS) + +########################################################################################## + $(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \ LIBRARY := unpack, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ diff --git a/jdk/make/lib/PlatformLibraries.gmk b/jdk/make/lib/PlatformLibraries.gmk index f12aa186c40..f17e8304279 100644 --- a/jdk/make/lib/PlatformLibraries.gmk +++ b/jdk/make/lib/PlatformLibraries.gmk @@ -95,7 +95,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) LIBOSX_DIRS := \ $(JDK_TOPDIR)/src/macosx/native/com/apple/concurrent \ - $(JDK_TOPDIR)/src/macosx/native/java/util \ $(JDK_TOPDIR)/src/macosx/native/com/apple/eio \ $(JDK_TOPDIR)/src/macosx/native/apple/security \ $(JDK_TOPDIR)/src/macosx/native/apple/launcher diff --git a/jdk/make/lib/SecurityLibraries.gmk b/jdk/make/lib/SecurityLibraries.gmk index 2a1721bc1c4..66c55b8264d 100644 --- a/jdk/make/lib/SecurityLibraries.gmk +++ b/jdk/make/lib/SecurityLibraries.gmk @@ -128,8 +128,13 @@ ifneq ($(BUILD_CRYPTO), no) ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib else ifeq ($(OPENJDK_TARGET_OS), macosx) BUILD_LIBKRB5_NAME := osxkrb5 - BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/share/native/sun/security/krb5 - BUILD_LIBKRB5_LIBS := -framework Kerberos + BUILD_LIBKRB5_SRC := $(JDK_TOPDIR)/src/share/native/sun/security/krb5 \ + $(JDK_TOPDIR)/src/macosx/native/sun/security/krb5 + BUILD_LIBKRB5_LIBS := -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ + -framework JavaNativeFoundation \ + -framework Cocoa \ + -framework SystemConfiguration \ + -framework Kerberos endif ifneq ($(BUILD_LIBKRB5_NAME), ) @@ -140,8 +145,9 @@ ifneq ($(BUILD_CRYPTO), no) LANG := C, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ - -I$(JDK_TOPDIR)/src/share/native/sun/security/krb5 \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/krb5, \ + -I$(JDK_TOPDIR)/src/share/native/sun/security/krb5, \ + CFLAGS_windows := -I$(JDK_TOPDIR)/src/windows/native/sun/security/krb5, \ + CFLAGS_macosx := -F/System/Library/Frameworks/JavaVM.framework/Frameworks, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_SUFFIX := $(BUILD_LIBKRB5_LIBS), \ diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index 760babc2ee1..9034580f1b9 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -236,10 +236,6 @@ SUNWprivate_1.1 { Java_java_util_TimeZone_getSystemTimeZoneID; Java_java_util_TimeZone_getSystemGMTOffsetID; Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8; - Java_java_util_prefs_FileSystemPreferences_chmod; - Java_java_util_prefs_FileSystemPreferences_lockFile0; - Java_java_util_prefs_FileSystemPreferences_unlockFile0; - Java_java_util_logging_FileHandler_isSetUID; Java_sun_misc_MessageUtils_toStderr; Java_sun_misc_MessageUtils_toStdout; Java_sun_misc_NativeSignalHandler_handle0; @@ -274,17 +270,13 @@ SUNWprivate_1.1 { Java_sun_misc_Version_getJvmVersionInfo; Java_sun_misc_Version_getJvmSpecialVersion; Java_sun_misc_VM_latestUserDefinedLoader; + Java_sun_misc_VM_isSetUID; Java_sun_misc_VM_initialize; Java_sun_misc_VMSupport_initAgentProperties; # ZipFile.c needs this one throwFileNotFoundException; -# Java_sun_misc_VM_getState; threads.c -# Java_sun_misc_VM_threadsSuspended; threads.c -# Java_sun_misc_VM_unsuspendSomeThreads; threads.c -# Java_sun_misc_VM_unsuspendThreads; threads.c - # Outcalls from libjvm done using dlsym(). VerifyClassCodes; diff --git a/jdk/make/mapfiles/libprefs/mapfile-vers b/jdk/make/mapfiles/libprefs/mapfile-vers new file mode 100644 index 00000000000..395d175080b --- /dev/null +++ b/jdk/make/mapfiles/libprefs/mapfile-vers @@ -0,0 +1,36 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# Define public interface. + +SUNWprivate_1.1 { + global: + Java_java_util_prefs_FileSystemPreferences_chmod; + Java_java_util_prefs_FileSystemPreferences_lockFile0; + Java_java_util_prefs_FileSystemPreferences_unlockFile0; + + local: + *; +}; diff --git a/jdk/make/profile-includes.txt b/jdk/make/profile-includes.txt index 105f9d36689..f8fbef0c69a 100644 --- a/jdk/make/profile-includes.txt +++ b/jdk/make/profile-includes.txt @@ -130,6 +130,7 @@ PROFILE_3_JRE_LIB_FILES := \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)management.diz \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt$(SHARED_LIBRARY_SUFFIX) \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)npt.diz \ + $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)prefs$(SHARED_LIBRARY_SUFFIX) \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/$(LIBRARY_PREFIX)sctp$(SHARED_LIBRARY_SUFFIX) \ jvm.hprof.txt \ management-agent.jar \ diff --git a/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java b/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java index ce63833da81..400368c1c62 100644 --- a/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java +++ b/jdk/src/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java @@ -82,7 +82,7 @@ class MacOSXPreferencesFile { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Void run() { - System.loadLibrary("osx"); + System.loadLibrary("prefs"); return null; } }); diff --git a/jdk/src/macosx/native/java/util/MacOSXPreferencesFile.m b/jdk/src/macosx/native/java/util/prefs/MacOSXPreferencesFile.m similarity index 100% rename from jdk/src/macosx/native/java/util/MacOSXPreferencesFile.m rename to jdk/src/macosx/native/java/util/prefs/MacOSXPreferencesFile.m diff --git a/jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m b/jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m similarity index 100% rename from jdk/src/macosx/native/java/util/SCDynamicStoreConfig.m rename to jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java index b2ac0d9d3e0..0318489bbf8 100644 --- a/jdk/src/share/classes/java/util/logging/FileHandler.java +++ b/jdk/src/share/classes/java/util/logging/FileHandler.java @@ -535,7 +535,7 @@ public class FileHandler extends StreamHandler { continue; } else if (ch2 == 'h') { file = new File(System.getProperty("user.home")); - if (isSetUID()) { + if (sun.misc.VM.isSetUID()) { // Ok, we are in a set UID program. For safety's sake // we disallow attempts to open files relative to %h. throw new IOException("can't use %h in set UID program"); @@ -669,9 +669,4 @@ public class FileHandler extends StreamHandler { lastException = ex; } } - - /** - * check if we are in a set UID program. - */ - private static native boolean isSetUID(); } diff --git a/jdk/src/share/classes/sun/misc/VM.java b/jdk/src/share/classes/sun/misc/VM.java index 8b77e2297fa..d6fdad114d6 100644 --- a/jdk/src/share/classes/sun/misc/VM.java +++ b/jdk/src/share/classes/sun/misc/VM.java @@ -367,6 +367,11 @@ public class VM { */ public static native ClassLoader latestUserDefinedLoader(); + /** + * Returns {@code true} if we are in a set UID program. + */ + public static native boolean isSetUID(); + static { initialize(); } diff --git a/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java b/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java index 8d632379d16..f94a1372054 100644 --- a/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java +++ b/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java @@ -42,7 +42,7 @@ public class SCDynamicStoreConfig { public Boolean run() { String osname = System.getProperty("os.name"); if (osname.contains("OS X")) { - System.loadLibrary("osx"); + System.loadLibrary("osxkrb5"); return true; } return false; diff --git a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java index 166fcd97d69..6ca10d10c93 100644 --- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java +++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java @@ -48,6 +48,15 @@ import sun.util.logging.PlatformLogger; * @since 1.4 */ class FileSystemPreferences extends AbstractPreferences { + + static { + PrivilegedAction load = () -> { + System.loadLibrary("prefs"); + return null; + }; + AccessController.doPrivileged(load); + } + /** * Sync interval in seconds. */ @@ -868,7 +877,7 @@ class FileSystemPreferences extends AbstractPreferences { /** * Returns the node name corresponding to the specified directory name. - * (Inverts the transformation of dirName(String). + * (Inverts the transformation of dirName(String). */ private static String nodeName(String dirName) { if (dirName.charAt(0) != '_') diff --git a/jdk/src/solaris/native/java/util/FileSystemPreferences.c b/jdk/src/solaris/native/java/util/prefs/FileSystemPreferences.c similarity index 100% rename from jdk/src/solaris/native/java/util/FileSystemPreferences.c rename to jdk/src/solaris/native/java/util/prefs/FileSystemPreferences.c diff --git a/jdk/src/solaris/native/java/util/logging.c b/jdk/src/solaris/native/sun/misc/VM_md.c similarity index 91% rename from jdk/src/solaris/native/java/util/logging.c rename to jdk/src/solaris/native/sun/misc/VM_md.c index af50903c642..7fe336274a4 100644 --- a/jdk/src/solaris/native/java/util/logging.c +++ b/jdk/src/solaris/native/sun/misc/VM_md.c @@ -23,16 +23,12 @@ * questions. */ -/* - * Solaris/Linux specific code to support logging. - */ - #include #include "jni_util.h" JNIEXPORT jboolean JNICALL -Java_java_util_logging_FileHandler_isSetUID(JNIEnv *env, jclass thisclass) { +Java_sun_misc_VM_isSetUID(JNIEnv *env, jclass thisclass) { /* Return true if we are in a set UID or set GID process. */ if (getuid() != geteuid() || getgid() != getegid()) { diff --git a/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java b/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java index 53678e5424a..6844234d39d 100644 --- a/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java +++ b/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java @@ -29,6 +29,9 @@ import java.util.Map; import java.util.TreeMap; import java.util.StringTokenizer; import java.io.ByteArrayOutputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; + import sun.util.logging.PlatformLogger; /** @@ -45,6 +48,14 @@ import sun.util.logging.PlatformLogger; class WindowsPreferences extends AbstractPreferences{ + static { + PrivilegedAction load = () -> { + System.loadLibrary("prefs"); + return null; + }; + AccessController.doPrivileged(load); + } + /** * Logger for error messages */ diff --git a/jdk/src/windows/native/java/util/WindowsPreferences.c b/jdk/src/windows/native/java/util/prefs/WindowsPreferences.c similarity index 100% rename from jdk/src/windows/native/java/util/WindowsPreferences.c rename to jdk/src/windows/native/java/util/prefs/WindowsPreferences.c diff --git a/jdk/src/windows/native/java/util/logging.c b/jdk/src/windows/native/sun/misc/VM_md.c similarity index 91% rename from jdk/src/windows/native/java/util/logging.c rename to jdk/src/windows/native/sun/misc/VM_md.c index 41b7cf657d2..165ad2713ea 100644 --- a/jdk/src/windows/native/java/util/logging.c +++ b/jdk/src/windows/native/sun/misc/VM_md.c @@ -23,15 +23,11 @@ * questions. */ -/* - * Win32 specific code to support logging. - */ - #include "jni_util.h" JNIEXPORT jboolean JNICALL -Java_java_util_logging_FileHandler_isSetUID(JNIEnv *env, jclass thisclass) { +Java_sun_misc_VM_isSetUID(JNIEnv *env, jclass thisclass) { /* There is no set UID on Windows. */ return JNI_FALSE; From 804f3e85f3d7fe031db2f2320b93dd1e7f9f46b4 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 11 Feb 2014 10:49:07 +0000 Subject: [PATCH 20/30] 8034175: Remove use of UseVMInterruptibleIO from tests Reviewed-by: chegar --- jdk/test/java/nio/file/Files/InterruptCopy.java | 1 - jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java | 1 - .../java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java | 1 - 3 files changed, 3 deletions(-) diff --git a/jdk/test/java/nio/file/Files/InterruptCopy.java b/jdk/test/java/nio/file/Files/InterruptCopy.java index 467a5eadfdf..c83479c9e46 100644 --- a/jdk/test/java/nio/file/Files/InterruptCopy.java +++ b/jdk/test/java/nio/file/Files/InterruptCopy.java @@ -25,7 +25,6 @@ * @bug 4313887 6993267 * @summary Unit test for Sun-specific ExtendedCopyOption.INTERRUPTIBLE option * @library .. - * @run main/othervm -XX:-UseVMInterruptibleIO InterruptCopy */ import java.nio.file.*; diff --git a/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java b/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java index d8d55d9902b..cdfd9e88bdb 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/Interrupt.java @@ -25,7 +25,6 @@ * @test * @bug 6384064 * @summary Check proper handling of interrupts - * @run main/othervm -XX:-UseVMInterruptibleIO Interrupt * @author Martin Buchholz */ diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java index 47c28540f24..8c2cf5a2b16 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java @@ -25,7 +25,6 @@ * @test * @bug 6450200 6450205 6450207 6450211 * @summary Test proper handling of tasks that terminate abruptly - * @run main/othervm -XX:-UseVMInterruptibleIO ThrowingTasks * @author Martin Buchholz */ From 2f7d6e1157ae5dfd119bc6a3b7511bbe12ef935a Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Tue, 11 Feb 2014 12:23:28 +0100 Subject: [PATCH 21/30] 8029876: Add a test to verify that Logger.getLogger & LogManager.getLogManager don't throw NPE when System.out == null Adds a new test that verifies that the suspected root cause of JDK-8025512 does not cause NPE to be thrown. Reviewed-by: mchung --- .../java/util/logging/TestGetLoggerNPE.java | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 jdk/test/java/util/logging/TestGetLoggerNPE.java diff --git a/jdk/test/java/util/logging/TestGetLoggerNPE.java b/jdk/test/java/util/logging/TestGetLoggerNPE.java new file mode 100644 index 00000000000..55ed6e0a70f --- /dev/null +++ b/jdk/test/java/util/logging/TestGetLoggerNPE.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.io.PrintStream; +import java.security.Permission; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.logging.LogManager; +import java.util.logging.Logger; +import sun.misc.JavaAWTAccess; +import sun.misc.SharedSecrets; + +/* + * @test + * @bug 8025512 + * + * @summary NPE with logging while launching webstart + * + * @build TestGetLoggerNPE + * @run main/othervm TestGetLoggerNPE getLogger + * @run main/othervm TestGetLoggerNPE getLogManager + */ +public class TestGetLoggerNPE { + static volatile Throwable thrown = null; + public static void main(String[] args) throws Exception { + final String testCase = args.length == 0 ? "getLogger" : args[0]; + final JavaAWTAccessStub access = new JavaAWTAccessStub(); + SharedSecrets.setJavaAWTAccess(access); + final ThreadGroup tg = new ThreadGroup("TestGroup"); + Thread t = new Thread(tg, "test") { + public void run() { + try { + access.setContext(Context.ONE); + final PrintStream out = System.out; + System.setOut(null); + try { + if ("getLogger".equals(testCase)) { + Logger.getLogger("sun.plugin"); + } else { + LogManager.getLogManager(); + } + } finally { + System.setOut(out); + } + + System.out.println(Logger.global); + } catch (Throwable x) { + x.printStackTrace(); + thrown = x; + } + } + }; + Policy.setPolicy(new Policy() { + public boolean implies(ProtectionDomain domain, + Permission permission) { + return true; // all permissions + } + }); + System.setSecurityManager(new SecurityManager()); + t.start(); + t.join(); + if (thrown == null) { + System.out.println("PASSED: " + testCase); + } else { + System.err.println("FAILED: " + testCase); + throw new Error("Test failed: " + testCase + " - " + thrown, thrown); + } + + } + + static enum Context { ONE, TWO }; + + static final class JavaAWTAccessStub implements JavaAWTAccess { + private static final InheritableThreadLocal context = new InheritableThreadLocal<>(); + + + public void setContext(Context context) { + JavaAWTAccessStub.context.set(context); + } + + @Override + public Object getAppletContext() { + return context.get(); + } + + } + +} From 6b108289adee80b454415609521ef7198a2d3bbc Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Sat, 8 Feb 2014 00:22:33 +0400 Subject: [PATCH 22/30] 8033943: Typo in the documentation for the class Arrays Reviewed-by: martin --- jdk/src/share/classes/java/util/Arrays.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/java/util/Arrays.java b/jdk/src/share/classes/java/util/Arrays.java index 09135c99969..2edadd87553 100644 --- a/jdk/src/share/classes/java/util/Arrays.java +++ b/jdk/src/share/classes/java/util/Arrays.java @@ -50,7 +50,7 @@ import java.util.stream.StreamSupport; * if the specified array reference is null, except where noted. * *

The documentation for the methods contained in this class includes - * briefs description of the implementations. Such descriptions should + * brief descriptions of the implementations. Such descriptions should * be regarded as implementation notes, rather than parts of the * specification. Implementors should feel free to substitute other * algorithms, so long as the specification itself is adhered to. (For From 8acc4717a27b7d5f930af834c71ad15fc3d82987 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Tue, 11 Feb 2014 14:48:51 +0100 Subject: [PATCH 23/30] 8034176: Update mapfile for libjfr Reviewed-by: erikj --- jdk/make/mapfiles/libjfr/mapfile-vers | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/make/mapfiles/libjfr/mapfile-vers b/jdk/make/mapfiles/libjfr/mapfile-vers index 8031edc9dda..dea13dd9864 100644 --- a/jdk/make/mapfiles/libjfr/mapfile-vers +++ b/jdk/make/mapfiles/libjfr/mapfile-vers @@ -34,6 +34,7 @@ SUNWprivate_1.1 { Java_oracle_jrockit_jfr_VMJFR_getPeriod; Java_oracle_jrockit_jfr_VMJFR_descriptors; Java_oracle_jrockit_jfr_VMJFR_redefineClass0; + Java_oracle_jrockit_jfr_VMJFR_retransformClasses0; JNI_OnLoad; local: *; From bad49f6fba24e40bf8db1df9344fe0fe0262f0a1 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 11 Feb 2014 16:43:57 +0000 Subject: [PATCH 24/30] 8034182: Misc. warnings in java.net code Reviewed-by: chegar --- jdk/src/share/native/java/net/net_util.c | 19 +++++++--------- jdk/src/share/native/java/net/net_util.h | 8 +++---- .../native/java/net/Inet6AddressImpl.c | 22 +++++++++---------- .../native/java/net/NetworkInterface.c | 2 +- .../native/java/net/PlainDatagramSocketImpl.c | 2 +- .../native/java/net/Inet6AddressImpl.c | 4 ++-- .../native/java/net/NetworkInterface.c | 2 +- .../native/java/net/NetworkInterface_winXP.c | 2 +- .../net/TwoStacksPlainDatagramSocketImpl.c | 1 + .../java/net/TwoStacksPlainSocketImpl.c | 3 +-- 10 files changed, 31 insertions(+), 34 deletions(-) diff --git a/jdk/src/share/native/java/net/net_util.c b/jdk/src/share/native/java/net/net_util.c index dd93b1375bc..33acf1ce573 100644 --- a/jdk/src/share/native/java/net/net_util.c +++ b/jdk/src/share/native/java/net/net_util.c @@ -108,7 +108,7 @@ jobject getInet6Address_scopeifname(JNIEnv *env, jobject iaObj) { return (*env)->GetObjectField(env, holder, ia6_scopeifnameID); } -int setInet6Address_scopeifname(JNIEnv *env, jobject iaObj, jobject scopeifname) { +jboolean setInet6Address_scopeifname(JNIEnv *env, jobject iaObj, jobject scopeifname) { jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, JNI_FALSE); (*env)->SetObjectField(env, holder, ia6_scopeifnameID, scopeifname); @@ -127,20 +127,18 @@ int getInet6Address_scopeid(JNIEnv *env, jobject iaObj) { return (*env)->GetIntField(env, holder, ia6_scopeidID); } -int setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) { +jboolean setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) { jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, JNI_FALSE); (*env)->SetIntField(env, holder, ia6_scopeidID, scopeid); if (scopeid > 0) { - (*env)->SetBooleanField(env, holder, ia6_scopeidsetID, JNI_TRUE); + (*env)->SetBooleanField(env, holder, ia6_scopeidsetID, JNI_TRUE); } return JNI_TRUE; } - -int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) { +jboolean getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) { jobject holder, addr; - jbyteArray barr; holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, JNI_FALSE); @@ -150,7 +148,7 @@ int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) { return JNI_TRUE; } -int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) { +jboolean setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) { jobject holder; jbyteArray addr; @@ -201,7 +199,6 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { jobject iaObj; #ifdef AF_INET6 if (him->sa_family == AF_INET6) { - jbyteArray ipaddress; #ifdef WIN32 struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; #else @@ -217,11 +214,12 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { setInetAddress_family(env, iaObj, IPv4); } else { jint scope; - int ret; + jboolean ret; iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); CHECK_NULL_RETURN(iaObj, NULL); ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr)); - CHECK_NULL_RETURN(ret, NULL); + if (ret == JNI_FALSE) + return NULL; setInetAddress_family(env, iaObj, IPv6); scope = getScopeID(him); setInet6Address_scopeid(env, iaObj, scope); @@ -268,7 +266,6 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj) return JNI_FALSE; } } else { - jbyteArray ipaddress; jbyte caddrCur[16]; int scope; diff --git a/jdk/src/share/native/java/net/net_util.h b/jdk/src/share/native/java/net/net_util.h index b77d02b2fad..9874d81db45 100644 --- a/jdk/src/share/native/java/net/net_util.h +++ b/jdk/src/share/native/java/net/net_util.h @@ -63,12 +63,12 @@ JNIEXPORT void JNICALL initInetAddressIDs(JNIEnv *env); * get_ methods that return objects return NULL on error. */ extern jobject getInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj); -extern int setInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj, jobject scopeifname); +extern jboolean setInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj, jobject scopeifname); extern int getInet6Address_scopeid_set(JNIEnv *env, jobject ia6Obj); extern int getInet6Address_scopeid(JNIEnv *env, jobject ia6Obj); -extern int setInet6Address_scopeid(JNIEnv *env, jobject ia6Obj, int scopeid); -extern int getInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *dest); -extern int setInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *address); +extern jboolean setInet6Address_scopeid(JNIEnv *env, jobject ia6Obj, int scopeid); +extern jboolean getInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *dest); +extern jboolean setInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *address); extern void setInetAddress_addr(JNIEnv *env, jobject iaObj, int address); extern void setInetAddress_family(JNIEnv *env, jobject iaObj, int family); diff --git a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c index 8de5a9bea1b..c5cb9e49b48 100644 --- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c @@ -66,27 +66,27 @@ */ JNIEXPORT jstring JNICALL Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { + int ret; char hostname[NI_MAXHOST+1]; hostname[0] = '\0'; - if (JVM_GetHostName(hostname, sizeof(hostname))) { + ret = JVM_GetHostName(hostname, sizeof(hostname)); + if (ret) { /* Something went wrong, maybe networking is not setup? */ strcpy(hostname, "localhost"); } else { // ensure null-terminated hostname[NI_MAXHOST] = '\0'; -#if defined(__linux__) || defined(_ALLBSD_SOURCE) - /* On Linux/FreeBSD gethostname() says "host.domain.sun.com". On - * Solaris gethostname() says "host", so extra work is needed. - */ -#else + } + +#if defined(__solaris__) && defined(AF_INET6) + if (ret == 0) { /* Solaris doesn't want to give us a fully qualified domain name. * We do a reverse lookup to try and get one. This works * if DNS occurs before NIS in /etc/resolv.conf, but fails * if NIS comes first (it still gets only a partial name). * We use thread-safe system calls. */ -#ifdef AF_INET6 struct addrinfo hints, *res; int error; @@ -111,9 +111,9 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { freeaddrinfo(res); } -#endif /* AF_INET6 */ -#endif /* __linux__ || _ALLBSD_SOURCE */ } +#endif + return (*env)->NewStringUTF(env, hostname); } @@ -402,7 +402,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, } while (iterator != NULL) { - int ret1; + jboolean ret1; if (iterator->ai_family == AF_INET) { jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (IS_NULL(iaObj)) { @@ -422,7 +422,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, goto cleanupAndReturn; } ret1 = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr)); - if (!ret1) { + if (ret1 == JNI_FALSE) { ret = NULL; goto cleanupAndReturn; } diff --git a/jdk/src/solaris/native/java/net/NetworkInterface.c b/jdk/src/solaris/native/java/net/NetworkInterface.c index 380dff19cc8..47e956908e8 100644 --- a/jdk/src/solaris/native/java/net/NetworkInterface.c +++ b/jdk/src/solaris/native/java/net/NetworkInterface.c @@ -677,7 +677,7 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) { int scope=0; iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (iaObj) { - int ret = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr)); + jboolean ret = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr)); if (ret == JNI_FALSE) { return NULL; } diff --git a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c index ac4a8385e9a..6fe1683ae7d 100644 --- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c +++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c @@ -2159,7 +2159,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this, caddr[14] = ((address >> 8) & 0xff); caddr[15] = (address & 0xff); } else { - getInet6Address_ipaddress(env, iaObj, caddr); + getInet6Address_ipaddress(env, iaObj, (char*)caddr); } memcpy((void *)&(mname6.ipv6mr_multiaddr), caddr, sizeof(struct in6_addr)); diff --git a/jdk/src/windows/native/java/net/Inet6AddressImpl.c b/jdk/src/windows/native/java/net/Inet6AddressImpl.c index cac70b34dfa..356c1eac1a1 100644 --- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c +++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c @@ -221,14 +221,14 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, (*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj); inetIndex ++; } else if (iterator->ai_family == AF_INET6) { - jint scope = 0, ret1; + jint scope = 0; + jboolean ret1; jobject iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; } ret1 = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr)); - if (ret1 == JNI_FALSE) { ret = NULL; goto cleanupAndReturn; diff --git a/jdk/src/windows/native/java/net/NetworkInterface.c b/jdk/src/windows/native/java/net/NetworkInterface.c index 44e9a61636b..3c0ec180ee4 100644 --- a/jdk/src/windows/native/java/net/NetworkInterface.c +++ b/jdk/src/windows/native/java/net/NetworkInterface.c @@ -614,7 +614,7 @@ jobject createNetworkInterface int scope; iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (iaObj) { - int ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr)); + jboolean ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr)); if (ret == JNI_FALSE) { return NULL; } diff --git a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c index 4d29e7f799d..e5580c6f3dc 100644 --- a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c +++ b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c @@ -549,7 +549,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs) int scope; iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (iaObj) { - int ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr)); + jboolean ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr)); if (ret == JNI_FALSE) { return NULL; } diff --git a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c index 3f0a211fd01..2c890ecae01 100644 --- a/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c +++ b/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c @@ -1646,6 +1646,7 @@ static int getIndexFromIf (JNIEnv *env, jobject nif) { } static int isAdapterIpv6Enabled(JNIEnv *env, int index) { + extern int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP); netif *ifList, *curr; int ipv6Enabled = 0; if (getAllInterfacesAndAddresses (env, &ifList) < 0) { diff --git a/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c b/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c index f535073df38..0a56c85bf64 100644 --- a/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c +++ b/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c @@ -575,7 +575,6 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this, { /* fields on this */ jint port; - jint scope; jint timeout = (*env)->GetIntField(env, this, psi_timeoutID); jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID); jobject fd1Obj = (*env)->GetObjectField(env, this, psi_fd1ID); @@ -750,7 +749,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this, NET_SocketClose(fd); return; } - setInet6Address_ipaddress(env, socketAddressObj, (const char *)&him.him6.sin6_addr); + setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.him6.sin6_addr); setInetAddress_family(env, socketAddressObj, IPv6); setInet6Address_scopeid(env, socketAddressObj, him.him6.sin6_scope_id); From b7c3e7214767fc567ebf2c3741a5fad1a7918560 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 12 Feb 2014 11:02:47 +0100 Subject: [PATCH 25/30] 8034173: Move JavaApp.icns to proper place in make/data Reviewed-by: ihse, tbell --- .../icons => make/data/macosxicons}/JavaApp.icns | Bin jdk/make/gensrc/GensrcIcons.gmk | 9 ++++----- jdk/make/lib/PlatformLibraries.gmk | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) rename jdk/{src/macosx/native/sun/osxapp/resource/icons => make/data/macosxicons}/JavaApp.icns (100%) diff --git a/jdk/src/macosx/native/sun/osxapp/resource/icons/JavaApp.icns b/jdk/make/data/macosxicons/JavaApp.icns similarity index 100% rename from jdk/src/macosx/native/sun/osxapp/resource/icons/JavaApp.icns rename to jdk/make/data/macosxicons/JavaApp.icns diff --git a/jdk/make/gensrc/GensrcIcons.gmk b/jdk/make/gensrc/GensrcIcons.gmk index f0acc3ed1ce..0728a2d8dad 100644 --- a/jdk/make/gensrc/GensrcIcons.gmk +++ b/jdk/make/gensrc/GensrcIcons.gmk @@ -109,17 +109,16 @@ $(foreach I, $(GENSRC_AWT_ICONS_SRC), $(eval $(call SetupGensrcAWTIcon,$(notdir ifeq ($(OPENJDK_TARGET_OS), macosx) - GENSRC_OSX_ICONS_TMP := $(JDK_OUTPUTDIR)/gensrc - GENSRC_OSX_ICONS_DST := $(GENSRC_OSX_ICONS_TMP)/sun/osxapp + GENSRC_OSX_ICONS_DST := $(JDK_OUTPUTDIR)/gensrc_headers_icons GENSRC_OSX_ICONS := $(GENSRC_OSX_ICONS_DST)/AWTIconData.h ifdef OPENJDK - GENSRC_OSX_ICONS_SRC := $(JDK_TOPDIR)/src/macosx/native/sun/osxapp/resource/icons/JavaApp.icns + GENSRC_OSX_ICONS_SRC := $(JDK_TOPDIR)/make/data/macosxicons/JavaApp.icns else - GENSRC_OSX_ICONS_SRC := $(JDK_TOPDIR)/src/closed/macosx/native/sun/osxapp/resource/icons/JavaApp.icns + GENSRC_OSX_ICONS_SRC := $(JDK_TOPDIR)/make/closed/data/macosxicons/JavaApp.icns endif - $(GENSRC_OSX_ICONS_DST)/AWTIconData.h: $(GENSRC_OSX_ICONS_SRC) + $(GENSRC_OSX_ICONS): $(GENSRC_OSX_ICONS_SRC) $(RM) $@ $@.tmp $(MKDIR) -p $(dir $@) $(ECHO) "static unsigned char sAWTIconData[] = { " >> $@.tmp diff --git a/jdk/make/lib/PlatformLibraries.gmk b/jdk/make/lib/PlatformLibraries.gmk index f17e8304279..a70adf87027 100644 --- a/jdk/make/lib/PlatformLibraries.gmk +++ b/jdk/make/lib/PlatformLibraries.gmk @@ -63,7 +63,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) \ -I$(JDK_TOPDIR)/src/macosx/native/sun/osxapp \ - -I$(JDK_OUTPUTDIR)/gensrc/sun/osxapp \ + -I$(JDK_OUTPUTDIR)/gensrc_headers_icons \ -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ -F/System/Library/Frameworks/ApplicationServices.framework/Frameworks, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ From 2b7c6c0d41d4a35881534d5e02c94cd0aa0fbf26 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 12 Feb 2014 19:20:43 +0800 Subject: [PATCH 26/30] 8034762: Move krb5.conf related tests into a single place Reviewed-by: xuelei --- jdk/test/sun/security/krb5/{ => config}/ConfPlusProp.java | 0 jdk/test/sun/security/krb5/{ => config}/ConfigWithQuotations.java | 0 jdk/test/sun/security/krb5/{ => config}/DnsFallback.java | 0 jdk/test/sun/security/krb5/{ => config}/ParseCAPaths.java | 0 jdk/test/sun/security/krb5/{ => config}/ParseConfig.java | 0 jdk/test/sun/security/krb5/{ => config}/confplusprop.conf | 0 jdk/test/sun/security/krb5/{ => config}/confplusprop2.conf | 0 jdk/test/sun/security/krb5/{ => config}/edu.mit.Kerberos | 0 jdk/test/sun/security/krb5/{ => config}/krb5-capaths.conf | 0 jdk/test/sun/security/krb5/{ => config}/krb5.conf | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename jdk/test/sun/security/krb5/{ => config}/ConfPlusProp.java (100%) rename jdk/test/sun/security/krb5/{ => config}/ConfigWithQuotations.java (100%) rename jdk/test/sun/security/krb5/{ => config}/DnsFallback.java (100%) rename jdk/test/sun/security/krb5/{ => config}/ParseCAPaths.java (100%) rename jdk/test/sun/security/krb5/{ => config}/ParseConfig.java (100%) rename jdk/test/sun/security/krb5/{ => config}/confplusprop.conf (100%) rename jdk/test/sun/security/krb5/{ => config}/confplusprop2.conf (100%) rename jdk/test/sun/security/krb5/{ => config}/edu.mit.Kerberos (100%) rename jdk/test/sun/security/krb5/{ => config}/krb5-capaths.conf (100%) rename jdk/test/sun/security/krb5/{ => config}/krb5.conf (100%) diff --git a/jdk/test/sun/security/krb5/ConfPlusProp.java b/jdk/test/sun/security/krb5/config/ConfPlusProp.java similarity index 100% rename from jdk/test/sun/security/krb5/ConfPlusProp.java rename to jdk/test/sun/security/krb5/config/ConfPlusProp.java diff --git a/jdk/test/sun/security/krb5/ConfigWithQuotations.java b/jdk/test/sun/security/krb5/config/ConfigWithQuotations.java similarity index 100% rename from jdk/test/sun/security/krb5/ConfigWithQuotations.java rename to jdk/test/sun/security/krb5/config/ConfigWithQuotations.java diff --git a/jdk/test/sun/security/krb5/DnsFallback.java b/jdk/test/sun/security/krb5/config/DnsFallback.java similarity index 100% rename from jdk/test/sun/security/krb5/DnsFallback.java rename to jdk/test/sun/security/krb5/config/DnsFallback.java diff --git a/jdk/test/sun/security/krb5/ParseCAPaths.java b/jdk/test/sun/security/krb5/config/ParseCAPaths.java similarity index 100% rename from jdk/test/sun/security/krb5/ParseCAPaths.java rename to jdk/test/sun/security/krb5/config/ParseCAPaths.java diff --git a/jdk/test/sun/security/krb5/ParseConfig.java b/jdk/test/sun/security/krb5/config/ParseConfig.java similarity index 100% rename from jdk/test/sun/security/krb5/ParseConfig.java rename to jdk/test/sun/security/krb5/config/ParseConfig.java diff --git a/jdk/test/sun/security/krb5/confplusprop.conf b/jdk/test/sun/security/krb5/config/confplusprop.conf similarity index 100% rename from jdk/test/sun/security/krb5/confplusprop.conf rename to jdk/test/sun/security/krb5/config/confplusprop.conf diff --git a/jdk/test/sun/security/krb5/confplusprop2.conf b/jdk/test/sun/security/krb5/config/confplusprop2.conf similarity index 100% rename from jdk/test/sun/security/krb5/confplusprop2.conf rename to jdk/test/sun/security/krb5/config/confplusprop2.conf diff --git a/jdk/test/sun/security/krb5/edu.mit.Kerberos b/jdk/test/sun/security/krb5/config/edu.mit.Kerberos similarity index 100% rename from jdk/test/sun/security/krb5/edu.mit.Kerberos rename to jdk/test/sun/security/krb5/config/edu.mit.Kerberos diff --git a/jdk/test/sun/security/krb5/krb5-capaths.conf b/jdk/test/sun/security/krb5/config/krb5-capaths.conf similarity index 100% rename from jdk/test/sun/security/krb5/krb5-capaths.conf rename to jdk/test/sun/security/krb5/config/krb5-capaths.conf diff --git a/jdk/test/sun/security/krb5/krb5.conf b/jdk/test/sun/security/krb5/config/krb5.conf similarity index 100% rename from jdk/test/sun/security/krb5/krb5.conf rename to jdk/test/sun/security/krb5/config/krb5.conf From 961783d9540609ca22df320493996d747e95af9e Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Feb 2014 14:07:55 +0000 Subject: [PATCH 27/30] 8034776: Remove sun.misc.Service Reviewed-by: sundar, lancea, chegar --- .../javax/imageio/spi/ServiceRegistry.java | 9 - .../classes/javax/sound/midi/MidiSystem.java | 2 +- .../javax/sound/sampled/AudioSystem.java | 2 +- jdk/src/share/classes/sun/misc/Service.java | 434 ------------------ .../sun/misc/ServiceConfigurationError.java | 62 --- .../misc/JarIndex/metaInfFilenames/Basic.java | 63 +-- 6 files changed, 7 insertions(+), 565 deletions(-) delete mode 100644 jdk/src/share/classes/sun/misc/Service.java delete mode 100644 jdk/src/share/classes/sun/misc/ServiceConfigurationError.java diff --git a/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java b/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java index 3f4338d7db9..a3fc54816a2 100644 --- a/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java +++ b/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java @@ -123,15 +123,6 @@ public class ServiceRegistry { } } - // The following two methods expose functionality from - // sun.misc.Service. If that class is made public, they may be - // removed. - // - // The sun.misc.ServiceConfigurationError class may also be - // exposed, in which case the references to 'an - // Error' below should be changed to 'a - // ServiceConfigurationError'. - /** * Searches for implementations of a particular service class * using the given class loader. diff --git a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java index d0eab92865e..c661e23304d 100644 --- a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java +++ b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java @@ -1475,7 +1475,7 @@ public class MidiSystem { /** * Obtains the set of services currently installed on the system - * using sun.misc.Service, the SPI mechanism in 1.3. + * using the SPI mechanism in 1.3. * @return a List of instances of providers for the requested service. * If no providers are available, a List of length 0 will be returned. */ diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java index 17c0f26d6fb..235ed234276 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java @@ -1622,7 +1622,7 @@ public class AudioSystem { /** * Obtains the set of services currently installed on the system - * using sun.misc.Service, the SPI mechanism in 1.3. + * using the SPI mechanism in 1.3. * @return a List of instances of providers for the requested service. * If no providers are available, a vector of length 0 will be returned. */ diff --git a/jdk/src/share/classes/sun/misc/Service.java b/jdk/src/share/classes/sun/misc/Service.java deleted file mode 100644 index e00077fec44..00000000000 --- a/jdk/src/share/classes/sun/misc/Service.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.misc; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.TreeSet; - - -/** - * A simple service-provider lookup mechanism. A service is a - * well-known set of interfaces and (usually abstract) classes. A service - * provider is a specific implementation of a service. The classes in a - * provider typically implement the interfaces and subclass the classes defined - * in the service itself. Service providers may be installed in an - * implementation of the Java platform in the form of extensions, that is, jar - * files placed into any of the usual extension directories. Providers may - * also be made available by adding them to the applet or application class - * path or by some other platform-specific means. - * - *

In this lookup mechanism a service is represented by an interface or an - * abstract class. (A concrete class may be used, but this is not - * recommended.) A provider of a given service contains one or more concrete - * classes that extend this service class with data and code specific to - * the provider. This provider class will typically not be the entire - * provider itself but rather a proxy that contains enough information to - * decide whether the provider is able to satisfy a particular request together - * with code that can create the actual provider on demand. The details of - * provider classes tend to be highly service-specific; no single class or - * interface could possibly unify them, so no such class has been defined. The - * only requirement enforced here is that provider classes must have a - * zero-argument constructor so that they may be instantiated during lookup. - * - *

A service provider identifies itself by placing a provider-configuration - * file in the resource directory META-INF/services. The file's name - * should consist of the fully-qualified name of the abstract service class. - * The file should contain a list of fully-qualified concrete provider-class - * names, one per line. Space and tab characters surrounding each name, as - * well as blank lines, are ignored. The comment character is '#' - * (0x23); on each line all characters following the first comment - * character are ignored. The file must be encoded in UTF-8. - * - *

If a particular concrete provider class is named in more than one - * configuration file, or is named in the same configuration file more than - * once, then the duplicates will be ignored. The configuration file naming a - * particular provider need not be in the same jar file or other distribution - * unit as the provider itself. The provider must be accessible from the same - * class loader that was initially queried to locate the configuration file; - * note that this is not necessarily the class loader that found the file. - * - *

Example: Suppose we have a service class named - * java.io.spi.CharCodec. It has two abstract methods: - * - *

- *   public abstract CharEncoder getEncoder(String encodingName);
- *   public abstract CharDecoder getDecoder(String encodingName);
- * 
- * - * Each method returns an appropriate object or null if it cannot - * translate the given encoding. Typical CharCodec providers will - * support more than one encoding. - * - *

If sun.io.StandardCodec is a provider of the CharCodec - * service then its jar file would contain the file - * META-INF/services/java.io.spi.CharCodec. This file would contain - * the single line: - * - *

- *   sun.io.StandardCodec    # Standard codecs for the platform
- * 
- * - * To locate an encoder for a given encoding name, the internal I/O code would - * do something like this: - * - *
- *   CharEncoder getEncoder(String encodingName) {
- *       Iterator ps = Service.providers(CharCodec.class);
- *       while (ps.hasNext()) {
- *           CharCodec cc = (CharCodec)ps.next();
- *           CharEncoder ce = cc.getEncoder(encodingName);
- *           if (ce != null)
- *               return ce;
- *       }
- *       return null;
- *   }
- * 
- * - * The provider-lookup mechanism always executes in the security context of the - * caller. Trusted system code should typically invoke the methods in this - * class from within a privileged security context. - * - * @author Mark Reinhold - * @since 1.3 - */ - -public final class Service { - - private static final String prefix = "META-INF/services/"; - - private Service() { } - - private static void fail(Class service, String msg, Throwable cause) - throws ServiceConfigurationError - { - ServiceConfigurationError sce - = new ServiceConfigurationError(service.getName() + ": " + msg); - sce.initCause(cause); - throw sce; - } - - private static void fail(Class service, String msg) - throws ServiceConfigurationError - { - throw new ServiceConfigurationError(service.getName() + ": " + msg); - } - - private static void fail(Class service, URL u, int line, String msg) - throws ServiceConfigurationError - { - fail(service, u + ":" + line + ": " + msg); - } - - /** - * Parse a single line from the given configuration file, adding the name - * on the line to both the names list and the returned set iff the name is - * not already a member of the returned set. - */ - private static int parseLine(Class service, URL u, BufferedReader r, int lc, - List names, Set returned) - throws IOException, ServiceConfigurationError - { - String ln = r.readLine(); - if (ln == null) { - return -1; - } - int ci = ln.indexOf('#'); - if (ci >= 0) ln = ln.substring(0, ci); - ln = ln.trim(); - int n = ln.length(); - if (n != 0) { - if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0)) - fail(service, u, lc, "Illegal configuration-file syntax"); - int cp = ln.codePointAt(0); - if (!Character.isJavaIdentifierStart(cp)) - fail(service, u, lc, "Illegal provider-class name: " + ln); - for (int i = Character.charCount(cp); i < n; i += Character.charCount(cp)) { - cp = ln.codePointAt(i); - if (!Character.isJavaIdentifierPart(cp) && (cp != '.')) - fail(service, u, lc, "Illegal provider-class name: " + ln); - } - if (!returned.contains(ln)) { - names.add(ln); - returned.add(ln); - } - } - return lc + 1; - } - - /** - * Parse the content of the given URL as a provider-configuration file. - * - * @param service - * The service class for which providers are being sought; - * used to construct error detail strings - * - * @param url - * The URL naming the configuration file to be parsed - * - * @param returned - * A Set containing the names of provider classes that have already - * been returned. This set will be updated to contain the names - * that will be yielded from the returned Iterator. - * - * @return A (possibly empty) Iterator that will yield the - * provider-class names in the given configuration file that are - * not yet members of the returned set - * - * @throws ServiceConfigurationError - * If an I/O error occurs while reading from the given URL, or - * if a configuration-file format error is detected - */ - private static Iterator parse(Class service, URL u, Set returned) - throws ServiceConfigurationError - { - InputStream in = null; - BufferedReader r = null; - ArrayList names = new ArrayList<>(); - try { - in = u.openStream(); - r = new BufferedReader(new InputStreamReader(in, "utf-8")); - int lc = 1; - while ((lc = parseLine(service, u, r, lc, names, returned)) >= 0); - } catch (IOException x) { - fail(service, ": " + x); - } finally { - try { - if (r != null) r.close(); - if (in != null) in.close(); - } catch (IOException y) { - fail(service, ": " + y); - } - } - return names.iterator(); - } - - - /** - * Private inner class implementing fully-lazy provider lookup - */ - private static class LazyIterator implements Iterator { - - Class service; - ClassLoader loader; - Enumeration configs = null; - Iterator pending = null; - Set returned = new TreeSet<>(); - String nextName = null; - - private LazyIterator(Class service, ClassLoader loader) { - this.service = service; - this.loader = loader; - } - - public boolean hasNext() throws ServiceConfigurationError { - if (nextName != null) { - return true; - } - if (configs == null) { - try { - String fullName = prefix + service.getName(); - if (loader == null) - configs = ClassLoader.getSystemResources(fullName); - else - configs = loader.getResources(fullName); - } catch (IOException x) { - fail(service, ": " + x); - } - } - while ((pending == null) || !pending.hasNext()) { - if (!configs.hasMoreElements()) { - return false; - } - pending = parse(service, configs.nextElement(), returned); - } - nextName = pending.next(); - return true; - } - - public S next() throws ServiceConfigurationError { - if (!hasNext()) { - throw new NoSuchElementException(); - } - String cn = nextName; - nextName = null; - Class c = null; - try { - c = Class.forName(cn, false, loader); - } catch (ClassNotFoundException x) { - fail(service, - "Provider " + cn + " not found"); - } - if (!service.isAssignableFrom(c)) { - fail(service, - "Provider " + cn + " not a subtype"); - } - try { - return service.cast(c.newInstance()); - } catch (Throwable x) { - fail(service, - "Provider " + cn + " could not be instantiated: " + x, - x); - } - return null; /* This cannot happen */ - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - } - - - /** - * Locates and incrementally instantiates the available providers of a - * given service using the given class loader. - * - *

This method transforms the name of the given service class into a - * provider-configuration filename as described above and then uses the - * getResources method of the given class loader to find all - * available files with that name. These files are then read and parsed to - * produce a list of provider-class names. The iterator that is returned - * uses the given class loader to lookup and then instantiate each element - * of the list. - * - *

Because it is possible for extensions to be installed into a running - * Java virtual machine, this method may return different results each time - * it is invoked.

- * - * @param service - * The service's abstract service class - * - * @param loader - * The class loader to be used to load provider-configuration files - * and instantiate provider classes, or null if the system - * class loader (or, failing that the bootstrap class loader) is to - * be used - * - * @return An Iterator that yields provider objects for the given - * service, in some arbitrary order. The iterator will throw a - * ServiceConfigurationError if a provider-configuration - * file violates the specified format or if a provider class cannot - * be found and instantiated. - * - * @throws ServiceConfigurationError - * If a provider-configuration file violates the specified format - * or names a provider class that cannot be found and instantiated - * - * @see #providers(java.lang.Class) - * @see #installedProviders(java.lang.Class) - */ - public static Iterator providers(Class service, ClassLoader loader) - throws ServiceConfigurationError - { - return new LazyIterator(service, loader); - } - - - /** - * Locates and incrementally instantiates the available providers of a - * given service using the context class loader. This convenience method - * is equivalent to - * - *

-     *   ClassLoader cl = Thread.currentThread().getContextClassLoader();
-     *   return Service.providers(service, cl);
-     * 
- * - * @param service - * The service's abstract service class - * - * @return An Iterator that yields provider objects for the given - * service, in some arbitrary order. The iterator will throw a - * ServiceConfigurationError if a provider-configuration - * file violates the specified format or if a provider class cannot - * be found and instantiated. - * - * @throws ServiceConfigurationError - * If a provider-configuration file violates the specified format - * or names a provider class that cannot be found and instantiated - * - * @see #providers(java.lang.Class, java.lang.ClassLoader) - */ - public static Iterator providers(Class service) - throws ServiceConfigurationError - { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - return Service.providers(service, cl); - } - - - /** - * Locates and incrementally instantiates the available providers of a - * given service using the extension class loader. This convenience method - * simply locates the extension class loader, call it - * extClassLoader, and then does - * - *
-     *   return Service.providers(service, extClassLoader);
-     * 
- * - * If the extension class loader cannot be found then the system class - * loader is used; if there is no system class loader then the bootstrap - * class loader is used. - * - * @param service - * The service's abstract service class - * - * @return An Iterator that yields provider objects for the given - * service, in some arbitrary order. The iterator will throw a - * ServiceConfigurationError if a provider-configuration - * file violates the specified format or if a provider class cannot - * be found and instantiated. - * - * @throws ServiceConfigurationError - * If a provider-configuration file violates the specified format - * or names a provider class that cannot be found and instantiated - * - * @see #providers(java.lang.Class, java.lang.ClassLoader) - */ - public static Iterator installedProviders(Class service) - throws ServiceConfigurationError - { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - ClassLoader prev = null; - while (cl != null) { - prev = cl; - cl = cl.getParent(); - } - return Service.providers(service, prev); - } - -} diff --git a/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java b/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java deleted file mode 100644 index 1060f2079b9..00000000000 --- a/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.misc; - - -/** - * Error thrown when something goes wrong while looking up service providers. - * In particular, this error will be thrown in the following situations: - * - *
    - *
  • A concrete provider class cannot be found, - *
  • A concrete provider class cannot be instantiated, - *
  • The format of a provider-configuration file is illegal, or - *
  • An IOException occurs while reading a provider-configuration file. - *
- * - * @author Mark Reinhold - * @since 1.3 - */ - -public class ServiceConfigurationError extends Error { - - static final long serialVersionUID = 8769866263384244465L; - - /** - * Constructs a new instance with the specified detail string. - */ - public ServiceConfigurationError(String msg) { - super(msg); - } - - /** - * Constructs a new instance that wraps the specified throwable. - */ - public ServiceConfigurationError(Throwable x) { - super(x); - } - -} diff --git a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java index 83485d5f134..dffc5a0639d 100644 --- a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java +++ b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java @@ -24,7 +24,7 @@ /* * @test * @bug 6887710 - * @summary Verify the impact of sun.misc.JarIndex.metaInfFilenames on Service loaders + * @summary Verify the impact of sun.misc.JarIndex.metaInfFilenames on ServiceLoader * @run main/othervm Basic */ @@ -48,9 +48,8 @@ import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; /** - * Verifies the impact of sun.misc.JarIndex.metaInfFilenames on service loaders - * (sun.misc.Service & java.util.ServiceLoader), as well as finding resources - * through Class.getResouce. + * Verifies the impact of sun.misc.JarIndex.metaInfFilenames on ServiceLoader + * and on finding resources via Class.getResource. * * 1) Compile the test sources: * jarA: @@ -214,23 +213,13 @@ public class Basic { int failed = 0; - // Tests using sun.misc.Service - if (!sunMiscServiceTest(baseURL, messageService, true, false, true)) { - System.out.println("Test: sun.misc.Service looking for " + messageService + ", failed"); - failed++; - } - if (!sunMiscServiceTest(baseURL, unknownService, false, false, false)) { - System.out.println("Test: sun.misc.Service looking for " + unknownService + " failed"); - failed++; - } - // Tests using java.util.SerivceLoader if (!javaUtilServiceLoaderTest(baseURL, messageService, true, false, true)) { - System.out.println("Test: sun.misc.Service looking for " + messageService + ", failed"); + System.out.println("Test: ServiceLoader looking for " + messageService + ", failed"); failed++; } if (!javaUtilServiceLoaderTest(baseURL, unknownService, false, false, false)) { - System.out.println("Test: sun.misc.Service looking for " + unknownService + " failed"); + System.out.println("Test: ServiceLoader looking for " + unknownService + " failed"); failed++; } @@ -248,48 +237,6 @@ public class Basic { throw new RuntimeException("Failed: " + failed + " tests"); } - static boolean sunMiscServiceTest(URL baseURL, - String serviceClass, - boolean expectToFind, - boolean expectbDotJar, - boolean expectcDotJar) throws IOException { - debug("----------------------------------"); - debug("Running test with sun.misc.Service looking for " + serviceClass); - URLClassLoader loader = getLoader(baseURL); - httpServer.reset(); - - Class messageServiceClass = null; - try { - messageServiceClass = loader.loadClass(serviceClass); - } catch (ClassNotFoundException cnfe) { - System.err.println(cnfe); - throw new RuntimeException("Error in test: " + cnfe); - } - - Iterator iterator = sun.misc.Service.providers(messageServiceClass, loader); - if (expectToFind && !iterator.hasNext()) { - debug(messageServiceClass + " NOT found."); - return false; - } - - while (iterator.hasNext()) { - debug("found " + iterator.next() + " " + messageService); - } - - debug("HttpServer: " + httpServer); - - if (!expectbDotJar && httpServer.bDotJar > 0) { - debug("Unexpeced request sent to the httpserver for b.jar"); - return false; - } - if (!expectcDotJar && httpServer.cDotJar > 0) { - debug("Unexpeced request sent to the httpserver for c.jar"); - return false; - } - - return true; - } - static boolean javaUtilServiceLoaderTest(URL baseURL, String serviceClass, boolean expectToFind, From 87ed9d213a7bd3704e888bc788dedfb705e294d2 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Feb 2014 14:23:52 +0000 Subject: [PATCH 28/30] 8034780: Remove used imports Reviewed-by: sundar, chegar, lancea, dfuchs --- jdk/src/share/classes/java/lang/invoke/MethodHandle.java | 2 -- jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java | 2 -- jdk/src/share/classes/sun/applet/AppletViewerPanel.java | 1 - 3 files changed, 5 deletions(-) diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java index ce115df85ed..f142076f528 100644 --- a/jdk/src/share/classes/java/lang/invoke/MethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java @@ -31,8 +31,6 @@ import sun.invoke.util.*; import sun.misc.Unsafe; import static java.lang.invoke.MethodHandleStatics.*; -import java.util.logging.Level; -import java.util.logging.Logger; /** * A method handle is a typed, directly executable reference to an underlying method, diff --git a/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java index c2d8e583a88..07f08dd6962 100644 --- a/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java +++ b/jdk/src/share/classes/java/lang/invoke/SimpleMethodHandle.java @@ -27,8 +27,6 @@ package java.lang.invoke; import static java.lang.invoke.LambdaForm.*; import static java.lang.invoke.MethodHandleNatives.Constants.*; -import java.util.logging.Level; -import java.util.logging.Logger; /** * A method handle whose behavior is determined only by its LambdaForm. diff --git a/jdk/src/share/classes/sun/applet/AppletViewerPanel.java b/jdk/src/share/classes/sun/applet/AppletViewerPanel.java index 2b79c3fc8cc..93f064bb36d 100644 --- a/jdk/src/share/classes/sun/applet/AppletViewerPanel.java +++ b/jdk/src/share/classes/sun/applet/AppletViewerPanel.java @@ -31,7 +31,6 @@ import java.net.URL; import java.net.MalformedURLException; import java.awt.*; import java.applet.*; -import sun.tools.jar.*; /** From fa26d0e934154ce0545c05fad56f508c988d3572 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 12 Feb 2014 17:51:31 +0000 Subject: [PATCH 29/30] 8034102: Check solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c for JNI pending exceptions Reviewed-by: chegar, henryjen --- .../sun/nio/fs/MacOSXNativeDispatcher.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c index f3602b8fdb7..5c752930c14 100644 --- a/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c +++ b/jdk/src/solaris/native/sun/nio/fs/MacOSXNativeDispatcher.c @@ -39,12 +39,15 @@ Java_sun_nio_fs_MacOSXNativeDispatcher_normalizepath(JNIEnv* env, jclass this, jint form) { jcharArray result = NULL; - char chars_buf[(PATH_MAX + 1) * 2]; // utf16 + zero padding + char *chars; CFMutableStringRef csref = CFStringCreateMutable(NULL, 0); if (csref == NULL) { JNU_ThrowOutOfMemoryError(env, "native heap"); - } else { - char *chars = (char*)(*env)->GetPrimitiveArrayCritical(env, path, 0); + return NULL; + } + chars = (char*)(*env)->GetPrimitiveArrayCritical(env, path, 0); + if (chars != NULL) { + char chars_buf[(PATH_MAX + 1) * 2]; // utf16 + zero padding jsize len = (*env)->GetArrayLength(env, path); CFStringAppendCharacters(csref, (const UniChar*)chars, len); (*env)->ReleasePrimitiveArrayCritical(env, path, chars, 0); @@ -53,24 +56,26 @@ Java_sun_nio_fs_MacOSXNativeDispatcher_normalizepath(JNIEnv* env, jclass this, if (len < PATH_MAX) { if (CFStringGetCString(csref, chars_buf, sizeof(chars_buf), kCFStringEncodingUTF16)) { result = (*env)->NewCharArray(env, len); - (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)&chars_buf); + if (result != NULL) { + (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)&chars_buf); + } } } else { int ulen = (len + 1) * 2; chars = malloc(ulen); if (chars == NULL) { - CFRelease(csref); JNU_ThrowOutOfMemoryError(env, "native heap"); - return result; } else { if (CFStringGetCString(csref, chars, ulen, kCFStringEncodingUTF16)) { result = (*env)->NewCharArray(env, len); - (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)chars); + if (result != NULL) { + (*env)->SetCharArrayRegion(env, result, 0, len, (jchar*)chars); + } } free(chars); } } - CFRelease(csref); } + CFRelease(csref); return result; } From 328fa609d0fc8ea607ca1f848710a3d9304b8e65 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 12 Feb 2014 10:51:50 -0800 Subject: [PATCH 30/30] 8030010: cleanup native code warnings Co-authored-by: Francis Andre Reviewed-by: alanb, lancea --- jdk/src/share/bin/java.c | 5 ++--- jdk/src/share/bin/parse_manifest.c | 4 ++-- jdk/src/share/instrument/InvocationAdapter.c | 1 - jdk/src/share/native/java/lang/ClassLoader.c | 8 ++++---- jdk/src/share/native/java/lang/Throwable.c | 2 +- jdk/src/windows/native/common/jdk_util_md.c | 1 - jdk/src/windows/native/java/io/WinNTFileSystem_md.c | 1 - jdk/src/windows/native/java/lang/ProcessImpl_md.c | 2 +- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c index b72fa0e6d26..79912d52d0a 100644 --- a/jdk/src/share/bin/java.c +++ b/jdk/src/share/bin/java.c @@ -345,10 +345,10 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ } \ } while (JNI_FALSE) -#define CHECK_EXCEPTION_RETURN(CER_return_value) \ +#define CHECK_EXCEPTION_RETURN() \ do { \ if ((*env)->ExceptionOccurred(env)) { \ - return CER_return_value; \ + return; \ } \ } while (JNI_FALSE) @@ -1258,7 +1258,6 @@ static jclass GetApplicationClass(JNIEnv *env) { jmethodID mid; - jobject result; jclass cls = GetLauncherHelperClass(env); NULL_CHECK0(cls); NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, diff --git a/jdk/src/share/bin/parse_manifest.c b/jdk/src/share/bin/parse_manifest.c index 4926824e36b..c17249c0b30 100644 --- a/jdk/src/share/bin/parse_manifest.c +++ b/jdk/src/share/bin/parse_manifest.c @@ -233,7 +233,7 @@ compute_cen(int fd, Byte *bp) jlong base_offset; jlong offset; char buffer[MINREAD]; - p = buffer; + p = (Byte*) buffer; /* * Read the END Header, which is the starting point for ZIP files. * (Clearly designed to make writing a zip file easier than reading @@ -276,7 +276,7 @@ compute_cen(int fd, Byte *bp) if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong)0) { return (-1); } - p = buffer; + p = (Byte*) buffer; base_offset = base_offset - ZIP64_ENDSIZ(p) - ZIP64_ENDOFF(p) - ZIP64_ENDHDR; } else { base_offset = base_offset - ENDSIZ(p) - ENDOFF(p); diff --git a/jdk/src/share/instrument/InvocationAdapter.c b/jdk/src/share/instrument/InvocationAdapter.c index f1923d7cc3f..878adeced8c 100644 --- a/jdk/src/share/instrument/InvocationAdapter.c +++ b/jdk/src/share/instrument/InvocationAdapter.c @@ -153,7 +153,6 @@ Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) { char * options; jarAttribute* attributes; char * premainClass; - char * agentClass; char * bootClassPath; /* diff --git a/jdk/src/share/native/java/lang/ClassLoader.c b/jdk/src/share/native/java/lang/ClassLoader.c index 8e0b950406a..7701cce4bea 100644 --- a/jdk/src/share/native/java/lang/ClassLoader.c +++ b/jdk/src/share/native/java/lang/ClassLoader.c @@ -325,7 +325,7 @@ static void *findJniFunction(JNIEnv *env, void *handle, void *entryName = NULL; char *jniFunctionName; int i; - int len; + size_t len; // Check for JNI_On(Un)Load<_libname> function if (isLoad) { @@ -501,9 +501,9 @@ Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib { const char *cname; char *libName; - int prefixLen = (int) strlen(JNI_LIB_PREFIX); - int suffixLen = (int) strlen(JNI_LIB_SUFFIX); - int len; + size_t prefixLen = strlen(JNI_LIB_PREFIX); + size_t suffixLen = strlen(JNI_LIB_SUFFIX); + size_t len; jstring lib; void *ret; const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS; diff --git a/jdk/src/share/native/java/lang/Throwable.c b/jdk/src/share/native/java/lang/Throwable.c index aaf3c265865..768c7e114a4 100644 --- a/jdk/src/share/native/java/lang/Throwable.c +++ b/jdk/src/share/native/java/lang/Throwable.c @@ -44,7 +44,7 @@ * `this' so you can write 'throw e.fillInStackTrace();' */ JNIEXPORT jobject JNICALL -Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject throwable, int dummy) +Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject throwable, jint dummy) { JVM_FillInStackTrace(env, throwable); return throwable; diff --git a/jdk/src/windows/native/common/jdk_util_md.c b/jdk/src/windows/native/common/jdk_util_md.c index 65d20f55b3b..0eae2158f97 100644 --- a/jdk/src/windows/native/common/jdk_util_md.c +++ b/jdk/src/windows/native/common/jdk_util_md.c @@ -42,7 +42,6 @@ void* JDK_FindJvmEntry(const char* name) { JNIEXPORT HMODULE JDK_LoadSystemLibrary(const char* name) { HMODULE handle = NULL; char path[MAX_PATH]; - int ret; if (GetSystemDirectory(path, sizeof(path)) != 0) { strcat(path, "\\"); diff --git a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c index ec7d9d7294b..cfaeccdd030 100644 --- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c +++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c @@ -360,7 +360,6 @@ Java_java_io_WinNTFileSystem_getBooleanAttributes(JNIEnv *env, jobject this, jobject file) { jint rv = 0; - jint pathlen; WCHAR *pathbuf = fileToNTPath(env, file, ids.path); if (pathbuf == NULL) diff --git a/jdk/src/windows/native/java/lang/ProcessImpl_md.c b/jdk/src/windows/native/java/lang/ProcessImpl_md.c index da7d00b081a..04db1e341b4 100644 --- a/jdk/src/windows/native/java/lang/ProcessImpl_md.c +++ b/jdk/src/windows/native/java/lang/ProcessImpl_md.c @@ -79,7 +79,7 @@ win32Error(JNIEnv *env, const WCHAR *functionName) /*Good suggestion about 2-bytes-per-symbol in localized error reports*/ char utf8_javaMessage[MESSAGE_LENGTH*2]; const int errnum = (int)GetLastError(); - int n = os_error_message(errnum, utf16_OSErrorMsg, ARRAY_SIZE(utf16_OSErrorMsg)); + size_t n = os_error_message(errnum, utf16_OSErrorMsg, ARRAY_SIZE(utf16_OSErrorMsg)); n = (n > 0) ? swprintf(utf16_javaMessage, MESSAGE_LENGTH, L"%s error=%d, %s", functionName, errnum, utf16_OSErrorMsg) : swprintf(utf16_javaMessage, MESSAGE_LENGTH, L"%s failed, error=%d", functionName, errnum);