From 95e2d58dc175a3a6da4faa719a40be96b90a8756 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Fri, 8 Jul 2016 17:36:34 +0300 Subject: [PATCH 01/13] 8159925: sun/tools/jps/TestJpsJar.java still fails after fix for JDK-8153278 Check user.dir property Reviewed-by: dcubed, sspitsyn --- jdk/test/sun/tools/jps/JpsBase.java | 20 +++++++++++++++++--- jdk/test/sun/tools/jps/TestJpsJar.java | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/jdk/test/sun/tools/jps/JpsBase.java b/jdk/test/sun/tools/jps/JpsBase.java index d13a4053bd8..1b810f357bb 100644 --- a/jdk/test/sun/tools/jps/JpsBase.java +++ b/jdk/test/sun/tools/jps/JpsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -59,7 +59,17 @@ public final class JpsBase { return JpsBase.class.getName(); } + private static boolean userDirSanityCheck(String fullProcessName) { + String userDir = System.getProperty("user.dir"); + if (!fullProcessName.startsWith(userDir)) { + System.err.printf("Test skipped. user.dir '%s' is not a prefix of '%s'\n", userDir, fullProcessName); + return false; + } + return true; + } + public static void main(String[] args) throws Exception { + System.out.printf("INFO: user.dir: '%s''\n", System.getProperty("user.dir")); long pid = ProcessTools.getProcessId(); List> combinations = JpsHelper.JpsArg.generateCombinations(); @@ -85,8 +95,12 @@ public final class JpsBase { // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ... isFull = true; String fullProcessName = getFullProcessName(); - pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*"; - output.shouldMatch(pattern); + // Skip the test if user.dir is not a prefix of the current path + // It's possible if the test is run from symlinked dir or windows alias drive + if (userDirSanityCheck(fullProcessName)) { + pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*"; + output.shouldMatch(pattern); + } break; case m: // If '-m' is specified output should contain the arguments passed to the main method: diff --git a/jdk/test/sun/tools/jps/TestJpsJar.java b/jdk/test/sun/tools/jps/TestJpsJar.java index c0b862756db..00cc5423018 100644 --- a/jdk/test/sun/tools/jps/TestJpsJar.java +++ b/jdk/test/sun/tools/jps/TestJpsJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,6 +52,7 @@ public class TestJpsJar { cmd.addAll(JpsHelper.getVmArgs()); cmd.add("-Dtest.jdk=" + testJdk); cmd.add("-Dtest.src=" + testSrc); + cmd.add("-Duser.dir=" + System.getProperty("user.dir")); cmd.add("-jar"); cmd.add(jar.getAbsolutePath()); cmd.add("monkey"); From 327708637be70b2312be4570744b1b8de29ddf5b Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Sat, 9 Jul 2016 17:45:16 -0700 Subject: [PATCH 02/13] 8159145: Add JVMTI function GetNamedModule Introduce function GetNamedModule with a jtreg test coverage Reviewed-by: alanb, ctornqvi, hseigel, jiangli, dholmes, dcubed --- jdk/src/java.base/share/native/include/jvmti.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/native/include/jvmti.h b/jdk/src/java.base/share/native/include/jvmti.h index 5f8835c0baa..0009a88ae29 100644 --- a/jdk/src/java.base/share/native/include/jvmti.h +++ b/jdk/src/java.base/share/native/include/jvmti.h @@ -1217,8 +1217,11 @@ typedef struct jvmtiInterface_1_ { jmethodID method, jlocation location); - /* 40 : RESERVED */ - void *reserved40; + /* 40 : Get Named Module */ + jvmtiError (JNICALL *GetNamedModule) (jvmtiEnv* env, + jobject class_loader, + const char* package_name, + jobject* module_ptr); /* 41 : Set Field Access Watch */ jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env, @@ -2146,6 +2149,12 @@ struct _jvmtiEnv { return functions->GetAllModules(this, module_count_ptr, modules_ptr); } + jvmtiError GetNamedModule(jobject class_loader, + const char* package_name, + jobject* module_ptr) { + return functions->GetNamedModule(this, class_loader, package_name, module_ptr); + } + jvmtiError GetLoadedClasses(jint* class_count_ptr, jclass** classes_ptr) { return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr); From 3a2d3df9ed3f9fa490ecaea9ab33ea6f1321c821 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Sat, 9 Jul 2016 21:41:14 -0700 Subject: [PATCH 03/13] 8159147: Add ClassLoader parameter to new ClassFileTransformer transform method Add ClassLoader parameter to new ClassFileTransformer transform method Reviewed-by: alanb, dholmes, dcubed, mchung --- .../lang/instrument/ClassFileTransformer.java | 14 +++++++------- .../java/lang/instrument/Instrumentation.java | 4 ++-- .../sun/instrument/InstrumentationImpl.java | 5 +++-- .../sun/instrument/TransformerManager.java | 2 ++ .../share/native/libinstrument/JPLISAgent.c | 18 ++++++------------ .../share/native/libinstrument/JPLISAgent.h | 2 +- .../ATransformerManagementTestCase.java | 2 ++ .../java/lang/instrument/RetransformAgent.java | 1 + .../instrument/SimpleIdentityTransformer.java | 1 + 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java b/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java index c0bb90b59b6..17c5bede590 100644 --- a/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java +++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java @@ -38,7 +38,7 @@ import java.security.ProtectionDomain; * A transformer of class files. An agent registers an implementation of this * interface using the {@link Instrumentation#addTransformer addTransformer} * method so that the transformer's {@link - * ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[]) + * ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[]) * transform} method is invoked when classes are loaded, * {@link Instrumentation#redefineClasses redefined}, or * {@link Instrumentation#retransformClasses retransformed}. The implementation @@ -170,13 +170,13 @@ public interface ClassFileTransformer { /** * Transforms the given class file and returns a new replacement class file. * This method is invoked when the {@link Module Module} bearing {@link - * ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[]) + * ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[]) * transform} is not overridden. * * @implSpec The default implementation returns null. * * @param loader the defining loader of the class to be transformed, - * may be null if the bootstrap loader + * may be {@code null} if the bootstrap loader * @param className the name of the class in the internal form of fully * qualified class and interface names as defined in * The Java Virtual Machine Specification. @@ -208,9 +208,11 @@ public interface ClassFileTransformer { * * @implSpec The default implementation of this method invokes the * {@link #transform(ClassLoader,String,Class,ProtectionDomain,byte[]) transform} - * method with the {@link Module#getClassLoader() ClassLoader} for the module. + * method. * * @param module the module of the class to be transformed + * @param loader the defining loader of the class to be transformed, + * may be {@code null} if the bootstrap loader * @param className the name of the class in the internal form of fully * qualified class and interface names as defined in * The Java Virtual Machine Specification. @@ -230,15 +232,13 @@ public interface ClassFileTransformer { */ default byte[] transform( Module module, + ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { - PrivilegedAction pa = module::getClassLoader; - ClassLoader loader = AccessController.doPrivileged(pa); - // invoke the legacy transform method return transform(loader, className, diff --git a/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java b/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java index 44b0aa3c853..eef1b6e83db 100644 --- a/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java +++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java @@ -162,7 +162,7 @@ public interface Instrumentation { * *
  • for each transformer that was added with canRetransform * false, the bytes returned by - * {@link ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[]) + * {@link ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[]) * transform} during the last class load or redefine are * reused as the output of the transformation; note that this is * equivalent to reapplying the previous transformation, unaltered; @@ -170,7 +170,7 @@ public interface Instrumentation { *
  • *
  • for each transformer that was added with canRetransform * true, the - * {@link ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[]) + * {@link ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[]) * transform} method is called in these transformers *
  • *
  • the transformed class file bytes are installed as the new diff --git a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java index 1f992b4065f..80c2e7433b8 100644 --- a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java +++ b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java @@ -420,8 +420,8 @@ public class InstrumentationImpl implements Instrumentation { // WARNING: the native code knows the name & signature of this method private byte[] - transform( ClassLoader loader, - Module module, + transform( Module module, + ClassLoader loader, String classname, Class classBeingRedefined, ProtectionDomain protectionDomain, @@ -444,6 +444,7 @@ public class InstrumentationImpl implements Instrumentation { return null; // no manager, no transform } else { return mgr.transform( module, + loader, classname, classBeingRedefined, protectionDomain, diff --git a/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java b/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java index 310f0365260..dcac4b7ad8f 100644 --- a/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java +++ b/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java @@ -169,6 +169,7 @@ public class TransformerManager public byte[] transform( Module module, + ClassLoader loader, String classname, Class classBeingRedefined, ProtectionDomain protectionDomain, @@ -187,6 +188,7 @@ public class TransformerManager try { transformedBytes = transformer.transform( module, + loader, classname, classBeingRedefined, protectionDomain, diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c index b3936cb8b72..3017cca1f7a 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c +++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c @@ -771,12 +771,11 @@ addRedefineClassesCapability(JPLISAgent * agent) { } static jobject -getModuleObject(JNIEnv * jnienv, +getModuleObject(jvmtiEnv* jvmti, jobject loaderObject, const char* cname) { - jboolean errorOutstanding = JNI_FALSE; + jvmtiError err = JVMTI_ERROR_NONE; jobject moduleObject = NULL; - jstring package = NULL; /* find last slash in the class name */ char* last_slash = (cname == NULL) ? NULL : strrchr(cname, '/'); @@ -789,14 +788,9 @@ getModuleObject(JNIEnv * jnienv, } pkg_name_buf[len] = '\0'; - package = (*jnienv)->NewStringUTF(jnienv, pkg_name_buf); - jplis_assert_msg(package != NULL, "OOM error in NewStringUTF"); + err = (*jvmti)->GetNamedModule(jvmti, loaderObject, pkg_name_buf, &moduleObject); + jplis_assert_msg(err == JVMTI_ERROR_NONE, "error in the JVMTI GetNamedModule"); - moduleObject = JVM_GetModuleByPackageName(jnienv, loaderObject, package); - - errorOutstanding = checkForAndClearThrowable(jnienv); - jplis_assert_msg(!errorOutstanding, - "error in lookup of a module of the class being instrumented"); free((void*)pkg_name_buf); return moduleObject; } @@ -862,7 +856,7 @@ transformClassFile( JPLISAgent * agent, jobject moduleObject = NULL; if (classBeingRedefined == NULL) { - moduleObject = getModuleObject(jnienv, loaderObject, name); + moduleObject = getModuleObject(jvmti(agent), loaderObject, name); } else { // Redefine or retransform, InstrumentationImpl.transform() will use // classBeingRedefined.getModule() to get the module. @@ -873,8 +867,8 @@ transformClassFile( JPLISAgent * agent, jnienv, agent->mInstrumentationImpl, agent->mTransform, - loaderObject, moduleObject, + loaderObject, classNameStringObject, classBeingRedefined, protectionDomain, diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h index 3c70554ee44..6ecfde2d5c5 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h +++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h @@ -66,7 +66,7 @@ typedef struct _JPLISEnvironment JPLISEnvironment; #define JPLIS_INSTRUMENTIMPL_AGENTMAININVOKER_METHODSIGNATURE "(Ljava/lang/String;Ljava/lang/String;)V" #define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODNAME "transform" #define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODSIGNATURE \ - "(Ljava/lang/ClassLoader;Ljava/lang/reflect/Module;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B" + "(Ljava/lang/reflect/Module;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B" /* diff --git a/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java b/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java index b48610a91f2..5f88d3c9ba5 100644 --- a/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java +++ b/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java @@ -302,6 +302,7 @@ ATransformerManagementTestCase public byte[] transform( Module module, + ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, @@ -311,6 +312,7 @@ ATransformerManagementTestCase if (classBeingRedefined != null) checkInTransformer(MyClassFileTransformer.this); return super.transform( module, + loader, className, classBeingRedefined, protectionDomain, diff --git a/jdk/test/java/lang/instrument/RetransformAgent.java b/jdk/test/java/lang/instrument/RetransformAgent.java index 19cd34e60a7..cdba17efc6d 100644 --- a/jdk/test/java/lang/instrument/RetransformAgent.java +++ b/jdk/test/java/lang/instrument/RetransformAgent.java @@ -69,6 +69,7 @@ class RetransformAgent { } public byte[] transform(Module module, + ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, diff --git a/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java b/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java index d8fc0c07874..78e05fcb41b 100644 --- a/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java +++ b/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java @@ -63,6 +63,7 @@ SimpleIdentityTransformer implements ClassFileTransformer { public byte[] transform( Module module, + ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, From f7c908cebda8d7e937636a13c2dc01e1fb423344 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Thu, 14 Jul 2016 10:07:13 -0700 Subject: [PATCH 04/13] 8161388: quarantine java/lang/instrument/DaemonThread/TestDaemonThread.java Reviewed-by: gtriantafill, hseigel --- jdk/test/ProblemList.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 167e2493cf3..85f3014082b 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -138,6 +138,8 @@ java/lang/instrument/RetransformBigClass.sh 8061177 generic- java/lang/instrument/BootClassPath/BootClassPathTest.sh 8072130 macosx-all +java/lang/instrument/DaemonThread/TestDaemonThread.java 8161225 generic-all + java/lang/management/MemoryMXBean/LowMemoryTest.java 8130339 generic-all java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all From 2446e48a5ff990f7eaa6be225f7e8960dc9bb03c Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Fri, 15 Jul 2016 12:36:15 +0200 Subject: [PATCH 05/13] 8151163: All Buffer implementations should leverage Unsafe unaligned accessors Reviewed-by: shade, aph --- .../share/classes/java/nio/Bits.java | 500 +----------------- .../nio/ByteBufferAs-X-Buffer.java.template | 31 +- .../nio/Direct-X-Buffer-bin.java.template | 17 +- 3 files changed, 33 insertions(+), 515 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/nio/Bits.java b/jdk/src/java.base/share/classes/java/nio/Bits.java index d8b3024f781..8a7dcf77253 100644 --- a/jdk/src/java.base/share/classes/java/nio/Bits.java +++ b/jdk/src/java.base/share/classes/java/nio/Bits.java @@ -25,14 +25,14 @@ package java.nio; -import java.util.concurrent.atomic.AtomicLong; - -import jdk.internal.misc.JavaNioAccess; import jdk.internal.misc.JavaLangRefAccess; +import jdk.internal.misc.JavaNioAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.Unsafe; import jdk.internal.misc.VM; +import java.util.concurrent.atomic.AtomicLong; + /** * Access to bits, native and otherwise. */ @@ -61,504 +61,10 @@ class Bits { // package-private } - // -- get/put char -- - - private static char makeChar(byte b1, byte b0) { - return (char)((b1 << 8) | (b0 & 0xff)); - } - - static char getCharL(ByteBuffer bb, int bi) { - return makeChar(bb._get(bi + 1), - bb._get(bi )); - } - - static char getCharL(long a) { - return makeChar(_get(a + 1), - _get(a )); - } - - static char getCharB(ByteBuffer bb, int bi) { - return makeChar(bb._get(bi ), - bb._get(bi + 1)); - } - - static char getCharB(long a) { - return makeChar(_get(a ), - _get(a + 1)); - } - - static char getChar(ByteBuffer bb, int bi, boolean bigEndian) { - return bigEndian ? getCharB(bb, bi) : getCharL(bb, bi); - } - - static char getChar(long a, boolean bigEndian) { - return bigEndian ? getCharB(a) : getCharL(a); - } - - private static byte char1(char x) { return (byte)(x >> 8); } - private static byte char0(char x) { return (byte)(x ); } - - static void putCharL(ByteBuffer bb, int bi, char x) { - bb._put(bi , char0(x)); - bb._put(bi + 1, char1(x)); - } - - static void putCharL(long a, char x) { - _put(a , char0(x)); - _put(a + 1, char1(x)); - } - - static void putCharB(ByteBuffer bb, int bi, char x) { - bb._put(bi , char1(x)); - bb._put(bi + 1, char0(x)); - } - - static void putCharB(long a, char x) { - _put(a , char1(x)); - _put(a + 1, char0(x)); - } - - static void putChar(ByteBuffer bb, int bi, char x, boolean bigEndian) { - if (bigEndian) - putCharB(bb, bi, x); - else - putCharL(bb, bi, x); - } - - static void putChar(long a, char x, boolean bigEndian) { - if (bigEndian) - putCharB(a, x); - else - putCharL(a, x); - } - - - // -- get/put short -- - - private static short makeShort(byte b1, byte b0) { - return (short)((b1 << 8) | (b0 & 0xff)); - } - - static short getShortL(ByteBuffer bb, int bi) { - return makeShort(bb._get(bi + 1), - bb._get(bi )); - } - - static short getShortL(long a) { - return makeShort(_get(a + 1), - _get(a )); - } - - static short getShortB(ByteBuffer bb, int bi) { - return makeShort(bb._get(bi ), - bb._get(bi + 1)); - } - - static short getShortB(long a) { - return makeShort(_get(a ), - _get(a + 1)); - } - - static short getShort(ByteBuffer bb, int bi, boolean bigEndian) { - return bigEndian ? getShortB(bb, bi) : getShortL(bb, bi); - } - - static short getShort(long a, boolean bigEndian) { - return bigEndian ? getShortB(a) : getShortL(a); - } - - private static byte short1(short x) { return (byte)(x >> 8); } - private static byte short0(short x) { return (byte)(x ); } - - static void putShortL(ByteBuffer bb, int bi, short x) { - bb._put(bi , short0(x)); - bb._put(bi + 1, short1(x)); - } - - static void putShortL(long a, short x) { - _put(a , short0(x)); - _put(a + 1, short1(x)); - } - - static void putShortB(ByteBuffer bb, int bi, short x) { - bb._put(bi , short1(x)); - bb._put(bi + 1, short0(x)); - } - - static void putShortB(long a, short x) { - _put(a , short1(x)); - _put(a + 1, short0(x)); - } - - static void putShort(ByteBuffer bb, int bi, short x, boolean bigEndian) { - if (bigEndian) - putShortB(bb, bi, x); - else - putShortL(bb, bi, x); - } - - static void putShort(long a, short x, boolean bigEndian) { - if (bigEndian) - putShortB(a, x); - else - putShortL(a, x); - } - - - // -- get/put int -- - - private static int makeInt(byte b3, byte b2, byte b1, byte b0) { - return (((b3 ) << 24) | - ((b2 & 0xff) << 16) | - ((b1 & 0xff) << 8) | - ((b0 & 0xff) )); - } - - static int getIntL(ByteBuffer bb, int bi) { - return makeInt(bb._get(bi + 3), - bb._get(bi + 2), - bb._get(bi + 1), - bb._get(bi )); - } - - static int getIntL(long a) { - return makeInt(_get(a + 3), - _get(a + 2), - _get(a + 1), - _get(a )); - } - - static int getIntB(ByteBuffer bb, int bi) { - return makeInt(bb._get(bi ), - bb._get(bi + 1), - bb._get(bi + 2), - bb._get(bi + 3)); - } - - static int getIntB(long a) { - return makeInt(_get(a ), - _get(a + 1), - _get(a + 2), - _get(a + 3)); - } - - static int getInt(ByteBuffer bb, int bi, boolean bigEndian) { - return bigEndian ? getIntB(bb, bi) : getIntL(bb, bi) ; - } - - static int getInt(long a, boolean bigEndian) { - return bigEndian ? getIntB(a) : getIntL(a) ; - } - - private static byte int3(int x) { return (byte)(x >> 24); } - private static byte int2(int x) { return (byte)(x >> 16); } - private static byte int1(int x) { return (byte)(x >> 8); } - private static byte int0(int x) { return (byte)(x ); } - - static void putIntL(ByteBuffer bb, int bi, int x) { - bb._put(bi + 3, int3(x)); - bb._put(bi + 2, int2(x)); - bb._put(bi + 1, int1(x)); - bb._put(bi , int0(x)); - } - - static void putIntL(long a, int x) { - _put(a + 3, int3(x)); - _put(a + 2, int2(x)); - _put(a + 1, int1(x)); - _put(a , int0(x)); - } - - static void putIntB(ByteBuffer bb, int bi, int x) { - bb._put(bi , int3(x)); - bb._put(bi + 1, int2(x)); - bb._put(bi + 2, int1(x)); - bb._put(bi + 3, int0(x)); - } - - static void putIntB(long a, int x) { - _put(a , int3(x)); - _put(a + 1, int2(x)); - _put(a + 2, int1(x)); - _put(a + 3, int0(x)); - } - - static void putInt(ByteBuffer bb, int bi, int x, boolean bigEndian) { - if (bigEndian) - putIntB(bb, bi, x); - else - putIntL(bb, bi, x); - } - - static void putInt(long a, int x, boolean bigEndian) { - if (bigEndian) - putIntB(a, x); - else - putIntL(a, x); - } - - - // -- get/put long -- - - private static long makeLong(byte b7, byte b6, byte b5, byte b4, - byte b3, byte b2, byte b1, byte b0) - { - return ((((long)b7 ) << 56) | - (((long)b6 & 0xff) << 48) | - (((long)b5 & 0xff) << 40) | - (((long)b4 & 0xff) << 32) | - (((long)b3 & 0xff) << 24) | - (((long)b2 & 0xff) << 16) | - (((long)b1 & 0xff) << 8) | - (((long)b0 & 0xff) )); - } - - static long getLongL(ByteBuffer bb, int bi) { - return makeLong(bb._get(bi + 7), - bb._get(bi + 6), - bb._get(bi + 5), - bb._get(bi + 4), - bb._get(bi + 3), - bb._get(bi + 2), - bb._get(bi + 1), - bb._get(bi )); - } - - static long getLongL(long a) { - return makeLong(_get(a + 7), - _get(a + 6), - _get(a + 5), - _get(a + 4), - _get(a + 3), - _get(a + 2), - _get(a + 1), - _get(a )); - } - - static long getLongB(ByteBuffer bb, int bi) { - return makeLong(bb._get(bi ), - bb._get(bi + 1), - bb._get(bi + 2), - bb._get(bi + 3), - bb._get(bi + 4), - bb._get(bi + 5), - bb._get(bi + 6), - bb._get(bi + 7)); - } - - static long getLongB(long a) { - return makeLong(_get(a ), - _get(a + 1), - _get(a + 2), - _get(a + 3), - _get(a + 4), - _get(a + 5), - _get(a + 6), - _get(a + 7)); - } - - static long getLong(ByteBuffer bb, int bi, boolean bigEndian) { - return bigEndian ? getLongB(bb, bi) : getLongL(bb, bi); - } - - static long getLong(long a, boolean bigEndian) { - return bigEndian ? getLongB(a) : getLongL(a); - } - - private static byte long7(long x) { return (byte)(x >> 56); } - private static byte long6(long x) { return (byte)(x >> 48); } - private static byte long5(long x) { return (byte)(x >> 40); } - private static byte long4(long x) { return (byte)(x >> 32); } - private static byte long3(long x) { return (byte)(x >> 24); } - private static byte long2(long x) { return (byte)(x >> 16); } - private static byte long1(long x) { return (byte)(x >> 8); } - private static byte long0(long x) { return (byte)(x ); } - - static void putLongL(ByteBuffer bb, int bi, long x) { - bb._put(bi + 7, long7(x)); - bb._put(bi + 6, long6(x)); - bb._put(bi + 5, long5(x)); - bb._put(bi + 4, long4(x)); - bb._put(bi + 3, long3(x)); - bb._put(bi + 2, long2(x)); - bb._put(bi + 1, long1(x)); - bb._put(bi , long0(x)); - } - - static void putLongL(long a, long x) { - _put(a + 7, long7(x)); - _put(a + 6, long6(x)); - _put(a + 5, long5(x)); - _put(a + 4, long4(x)); - _put(a + 3, long3(x)); - _put(a + 2, long2(x)); - _put(a + 1, long1(x)); - _put(a , long0(x)); - } - - static void putLongB(ByteBuffer bb, int bi, long x) { - bb._put(bi , long7(x)); - bb._put(bi + 1, long6(x)); - bb._put(bi + 2, long5(x)); - bb._put(bi + 3, long4(x)); - bb._put(bi + 4, long3(x)); - bb._put(bi + 5, long2(x)); - bb._put(bi + 6, long1(x)); - bb._put(bi + 7, long0(x)); - } - - static void putLongB(long a, long x) { - _put(a , long7(x)); - _put(a + 1, long6(x)); - _put(a + 2, long5(x)); - _put(a + 3, long4(x)); - _put(a + 4, long3(x)); - _put(a + 5, long2(x)); - _put(a + 6, long1(x)); - _put(a + 7, long0(x)); - } - - static void putLong(ByteBuffer bb, int bi, long x, boolean bigEndian) { - if (bigEndian) - putLongB(bb, bi, x); - else - putLongL(bb, bi, x); - } - - static void putLong(long a, long x, boolean bigEndian) { - if (bigEndian) - putLongB(a, x); - else - putLongL(a, x); - } - - - // -- get/put float -- - - static float getFloatL(ByteBuffer bb, int bi) { - return Float.intBitsToFloat(getIntL(bb, bi)); - } - - static float getFloatL(long a) { - return Float.intBitsToFloat(getIntL(a)); - } - - static float getFloatB(ByteBuffer bb, int bi) { - return Float.intBitsToFloat(getIntB(bb, bi)); - } - - static float getFloatB(long a) { - return Float.intBitsToFloat(getIntB(a)); - } - - static float getFloat(ByteBuffer bb, int bi, boolean bigEndian) { - return bigEndian ? getFloatB(bb, bi) : getFloatL(bb, bi); - } - - static float getFloat(long a, boolean bigEndian) { - return bigEndian ? getFloatB(a) : getFloatL(a); - } - - static void putFloatL(ByteBuffer bb, int bi, float x) { - putIntL(bb, bi, Float.floatToRawIntBits(x)); - } - - static void putFloatL(long a, float x) { - putIntL(a, Float.floatToRawIntBits(x)); - } - - static void putFloatB(ByteBuffer bb, int bi, float x) { - putIntB(bb, bi, Float.floatToRawIntBits(x)); - } - - static void putFloatB(long a, float x) { - putIntB(a, Float.floatToRawIntBits(x)); - } - - static void putFloat(ByteBuffer bb, int bi, float x, boolean bigEndian) { - if (bigEndian) - putFloatB(bb, bi, x); - else - putFloatL(bb, bi, x); - } - - static void putFloat(long a, float x, boolean bigEndian) { - if (bigEndian) - putFloatB(a, x); - else - putFloatL(a, x); - } - - - // -- get/put double -- - - static double getDoubleL(ByteBuffer bb, int bi) { - return Double.longBitsToDouble(getLongL(bb, bi)); - } - - static double getDoubleL(long a) { - return Double.longBitsToDouble(getLongL(a)); - } - - static double getDoubleB(ByteBuffer bb, int bi) { - return Double.longBitsToDouble(getLongB(bb, bi)); - } - - static double getDoubleB(long a) { - return Double.longBitsToDouble(getLongB(a)); - } - - static double getDouble(ByteBuffer bb, int bi, boolean bigEndian) { - return bigEndian ? getDoubleB(bb, bi) : getDoubleL(bb, bi); - } - - static double getDouble(long a, boolean bigEndian) { - return bigEndian ? getDoubleB(a) : getDoubleL(a); - } - - static void putDoubleL(ByteBuffer bb, int bi, double x) { - putLongL(bb, bi, Double.doubleToRawLongBits(x)); - } - - static void putDoubleL(long a, double x) { - putLongL(a, Double.doubleToRawLongBits(x)); - } - - static void putDoubleB(ByteBuffer bb, int bi, double x) { - putLongB(bb, bi, Double.doubleToRawLongBits(x)); - } - - static void putDoubleB(long a, double x) { - putLongB(a, Double.doubleToRawLongBits(x)); - } - - static void putDouble(ByteBuffer bb, int bi, double x, boolean bigEndian) { - if (bigEndian) - putDoubleB(bb, bi, x); - else - putDoubleL(bb, bi, x); - } - - static void putDouble(long a, double x, boolean bigEndian) { - if (bigEndian) - putDoubleB(a, x); - else - putDoubleL(a, x); - } - - // -- Unsafe access -- private static final Unsafe unsafe = Unsafe.getUnsafe(); - private static byte _get(long a) { - return unsafe.getByte(a); - } - - private static void _put(long a, byte b) { - unsafe.putByte(a, b); - } - static Unsafe unsafe() { return unsafe; } diff --git a/jdk/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template b/jdk/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template index bae622550ac..c97f50e7177 100644 --- a/jdk/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template +++ b/jdk/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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,6 +27,8 @@ package java.nio; +import jdk.internal.misc.Unsafe; + class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private extends {#if[ro]?ByteBufferAs}$Type$Buffer{#if[ro]?$BO$} @@ -34,6 +36,9 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private #if[rw] + // Cached unsafe-access object + private static final Unsafe unsafe = Bits.unsafe(); + protected final ByteBuffer bb; protected final int offset; @@ -107,17 +112,27 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private return (i << $LG_BYTES_PER_VALUE$) + offset; } + private long byteOffset(long i) { + return (i << $LG_BYTES_PER_VALUE$) + bb.address + offset; + } + public $type$ get() { - return Bits.get$Type$$BO$(bb, ix(nextGetIndex())); + $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()), + {#if[boB]?true:false}); + return $fromBits$(x); } public $type$ get(int i) { - return Bits.get$Type$$BO$(bb, ix(checkIndex(i))); + $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), + {#if[boB]?true:false}); + return $fromBits$(x); } #if[streamableType] $type$ getUnchecked(int i) { - return Bits.get$Type$$BO$(bb, ix(i)); + $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(i), + {#if[boB]?true:false}); + return $fromBits$(x); } #end[streamableType] @@ -125,7 +140,9 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private public $Type$Buffer put($type$ x) { #if[rw] - Bits.put$Type$$BO$(bb, ix(nextPutIndex()), x); + $memtype$ y = $toBits$(x); + unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y, + {#if[boB]?true:false}); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -134,7 +151,9 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private public $Type$Buffer put(int i, $type$ x) { #if[rw] - Bits.put$Type$$BO$(bb, ix(checkIndex(i)), x); + $memtype$ y = $toBits$(x); + unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y, + {#if[boB]?true:false}); return this; #else[rw] throw new ReadOnlyBufferException(); diff --git a/jdk/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template b/jdk/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template index 538bd5f02c6..05e2c617d96 100644 --- a/jdk/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template +++ b/jdk/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,11 +32,8 @@ class XXX { #if[rw] private $type$ get$Type$(long a) { - if (unaligned) { - $memtype$ x = unsafe.get$Memtype$(a); - return $fromBits$(nativeByteOrder ? x : Bits.swap(x)); - } - return Bits.get$Type$(a, bigEndian); + $memtype$ x = unsafe.get$Memtype$Unaligned(null, a, bigEndian); + return $fromBits$(x); } public $type$ get$Type$() { @@ -51,12 +48,8 @@ class XXX { private ByteBuffer put$Type$(long a, $type$ x) { #if[rw] - if (unaligned) { - $memtype$ y = $toBits$(x); - unsafe.put$Memtype$(a, (nativeByteOrder ? y : Bits.swap(y))); - } else { - Bits.put$Type$(a, x, bigEndian); - } + $memtype$ y = $toBits$(x); + unsafe.put$Memtype$Unaligned(null, a, y, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); From 963af328b084d40a39fefc29d9b6f6358c7a39c4 Mon Sep 17 00:00:00 2001 From: Alan Burlison Date: Fri, 15 Jul 2016 09:37:38 -0700 Subject: [PATCH 06/13] 8160997: Solaris: deprecated and interfaces should be replaced Use final POSIX 1003.1c versions of getgrgid_r(), getgrnam_r(), getpwnam_r(), and getpwuid_r(). Reviewed-by: alanb, dcubed, simonis, dholmes --- .../native/libjava/ProcessHandleImpl_unix.c | 14 +++---- .../native/libnio/fs/UnixNativeDispatcher.c | 35 ++++++------------ .../solaris/native/libjaas/Solaris.c | 37 ++++++++++++++----- .../unix/native/libjaas/Unix.c | 13 ++++--- 4 files changed, 53 insertions(+), 46 deletions(-) diff --git a/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c b/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c index afbe1e275ee..4dc20ad084d 100644 --- a/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c +++ b/jdk/src/java.base/unix/native/libjava/ProcessHandleImpl_unix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -46,6 +45,12 @@ #include #include +/* For POSIX-compliant getpwuid_r on Solaris */ +#if defined(__solaris__) +#define _POSIX_PTHREAD_SEMANTICS +#endif +#include + #ifdef _AIX #include #endif @@ -468,12 +473,7 @@ void unix_getUserInfo(JNIEnv* env, jobject jinfo, uid_t uid) { } else { struct passwd pwent; struct passwd* p = NULL; - -#ifdef __solaris__ - RESTARTABLE_RETURN_PTR(getpwuid_r(uid, &pwent, pwbuf, (size_t)getpw_buf_size), p); -#else RESTARTABLE(getpwuid_r(uid, &pwent, pwbuf, (size_t)getpw_buf_size, &p), result); -#endif // Create the Java String if a name was found if (result == 0 && p != NULL && diff --git a/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c index fe203cdf2dc..81b37db572f 100644 --- a/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c +++ b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include #include #include @@ -43,6 +41,13 @@ #endif #include +/* For POSIX-compliant getpwuid_r, getgrgid_r on Solaris */ +#if defined(__solaris__) +#define _POSIX_PTHREAD_SEMANTICS +#endif +#include +#include + #ifdef __solaris__ #include #endif @@ -1022,11 +1027,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_getpwuid(JNIEnv* env, jclass this, jint uid int res = 0; errno = 0; - #ifdef __solaris__ - RESTARTABLE_RETURN_PTR(getpwuid_r((uid_t)uid, &pwent, pwbuf, (size_t)buflen), p); - #else - RESTARTABLE(getpwuid_r((uid_t)uid, &pwent, pwbuf, (size_t)buflen, &p), res); - #endif + RESTARTABLE(getpwuid_r((uid_t)uid, &pwent, pwbuf, (size_t)buflen, &p), res); if (res != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') { /* not found or error */ @@ -1071,11 +1072,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_getgrgid(JNIEnv* env, jclass this, jint gid } errno = 0; - #ifdef __solaris__ - RESTARTABLE_RETURN_PTR(getgrgid_r((gid_t)gid, &grent, grbuf, (size_t)buflen), g); - #else - RESTARTABLE(getgrgid_r((gid_t)gid, &grent, grbuf, (size_t)buflen, &g), res); - #endif + RESTARTABLE(getgrgid_r((gid_t)gid, &grent, grbuf, (size_t)buflen, &g), res); retry = 0; if (res != 0 || g == NULL || g->gr_name == NULL || *(g->gr_name) == '\0') { @@ -1126,11 +1123,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0(JNIEnv* env, jclass this, const char* name = (const char*)jlong_to_ptr(nameAddress); errno = 0; - #ifdef __solaris__ - RESTARTABLE_RETURN_PTR(getpwnam_r(name, &pwent, pwbuf, (size_t)buflen), p); - #else - RESTARTABLE(getpwnam_r(name, &pwent, pwbuf, (size_t)buflen, &p), res); - #endif + RESTARTABLE(getpwnam_r(name, &pwent, pwbuf, (size_t)buflen, &p), res); if (res != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') { /* not found or error */ @@ -1171,11 +1164,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0(JNIEnv* env, jclass this, } errno = 0; - #ifdef __solaris__ - RESTARTABLE_RETURN_PTR(getgrnam_r(name, &grent, grbuf, (size_t)buflen), g); - #else - RESTARTABLE(getgrnam_r(name, &grent, grbuf, (size_t)buflen, &g), res); - #endif + RESTARTABLE(getgrnam_r(name, &grent, grbuf, (size_t)buflen, &g), res); retry = 0; if (res != 0 || g == NULL || g->gr_name == NULL || *(g->gr_name) == '\0') { diff --git a/jdk/src/jdk.security.auth/solaris/native/libjaas/Solaris.c b/jdk/src/jdk.security.auth/solaris/native/libjaas/Solaris.c index 1d251a65656..438b3b7318d 100644 --- a/jdk/src/jdk.security.auth/solaris/native/libjaas/Solaris.c +++ b/jdk/src/jdk.security.auth/solaris/native/libjaas/Solaris.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,14 @@ #include #include "com_sun_security_auth_module_SolarisSystem.h" #include -#include #include #include #include + +/* For POSIX-compliant getpwuid_r on Solaris */ +#if defined(__solaris__) +#define _POSIX_PTHREAD_SEMANTICS +#endif #include static void throwIllegalArgumentException(JNIEnv *env, const char *msg) { @@ -43,8 +47,10 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo (JNIEnv *env, jobject obj) { int i; - char pwd_buf[1024]; + long pwd_bufsize; + char *pwd_buf = NULL; struct passwd pwd; + struct passwd* p = NULL; jsize numSuppGroups = getgroups(0, NULL); jfieldID fid; jstring jstr; @@ -53,20 +59,31 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo gid_t *groups; jclass cls; + pwd_bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); + if (pwd_bufsize == -1) { + pwd_bufsize = 1024; + } + pwd_buf = (char *)malloc(pwd_bufsize); groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t)); - if (groups == NULL) { - jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError"); - if (cls != NULL) + if (pwd_buf == NULL || groups == NULL) { + if (pwd_buf != NULL) { + free(pwd_buf); + } + if (groups != NULL) { + free(groups); + } + cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError"); + if (cls != NULL) { (*env)->ThrowNew(env, cls, NULL); + } return; } cls = (*env)->GetObjectClass(env, obj); - memset(pwd_buf, 0, sizeof(pwd_buf)); - if (getpwuid_r(getuid(), &pwd, pwd_buf, sizeof(pwd_buf)) != NULL && - getgroups(numSuppGroups, groups) != -1) { + if (getpwuid_r(getuid(), &pwd, pwd_buf, sizeof(pwd_buf), &p) != 0 && + p != NULL && getgroups(numSuppGroups, groups) != -1) { /* * set username @@ -129,7 +146,7 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo (*env)->SetObjectField(env, obj, fid, jgroups); } cleanupAndReturn: + free(pwd_buf); free(groups); - return; } diff --git a/jdk/src/jdk.security.auth/unix/native/libjaas/Unix.c b/jdk/src/jdk.security.auth/unix/native/libjaas/Unix.c index 76737ab76a3..fdee7d3b935 100644 --- a/jdk/src/jdk.security.auth/unix/native/libjaas/Unix.c +++ b/jdk/src/jdk.security.auth/unix/native/libjaas/Unix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,20 +23,21 @@ * questions. */ -#ifdef __solaris__ -#define _POSIX_C_SOURCE 199506L -#endif - #include #include "jni_util.h" #include "com_sun_security_auth_module_UnixSystem.h" #include -#include #include #include #include #include +/* For POSIX-compliant getpwuid_r on Solaris */ +#if defined(__solaris__) +#define _POSIX_PTHREAD_SEMANTICS +#endif +#include + /* * Declare library specific JNI_Onload entry if static build */ From 65e8b4d804cf92f1da0575a3d0fef9a451643d89 Mon Sep 17 00:00:00 2001 From: Amit Sapre Date: Fri, 15 Jul 2016 23:54:37 -0700 Subject: [PATCH 07/13] 8158350: Table in ThreadInfo.from(CompositeData) may need updates for new stack trace attributes Update table in ThreadInfo.from(CompositeData) for new stack trace attributes Reviewed-by: alanb, dholmes, dsamersoff --- .../share/classes/java/lang/management/ThreadInfo.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java b/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java index 46f92a248e4..c859d337c69 100644 --- a/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java +++ b/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java @@ -771,6 +771,14 @@ public class ThreadInfo { * Type * * + * moduleName + * {@code java.lang.String} + * + * + * moduleVersion + * {@code java.lang.String} + * + * * className * {@code java.lang.String} * From ed5f40504bd4f1616d8311255b704ceb6f5d5b27 Mon Sep 17 00:00:00 2001 From: Frederic Parain Date: Mon, 18 Jul 2016 08:28:32 -0700 Subject: [PATCH 08/13] 8161034: GPL header missing comma after year Reviewed-by: alanb --- jdk/src/java.base/windows/native/libjava/jni_util_md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/windows/native/libjava/jni_util_md.c b/jdk/src/java.base/windows/native/libjava/jni_util_md.c index 5dd0179432c..40d0210ea1d 100644 --- a/jdk/src/java.base/windows/native/libjava/jni_util_md.c +++ b/jdk/src/java.base/windows/native/libjava/jni_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 From 308ab83004d85d6ff0052d64e7ff7498a5ed10bb Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Mon, 18 Jul 2016 14:21:17 -0700 Subject: [PATCH 09/13] 8161164: quarantine more tests that can't attach symbolicator to the process on MacOS X 8161177: quarantine com/sun/jdi/sde/SourceDebugExtensionTest.java on Win* Reviewed-by: sspitsyn, gtriantafill --- jdk/test/ProblemList.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index c791208923b..722267c7221 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -342,6 +342,8 @@ com/sun/jdi/CatchPatternTest.sh 8068645 generic- com/sun/jdi/GetLocalVariables4Test.sh 8067354 windows-all +com/sun/jdi/sde/SourceDebugExtensionTest.java 8158066 windows-all + ############################################################################ # jdk_time @@ -366,6 +368,10 @@ java/util/BitSet/BitSetStreamTest.java 8079538 generic- sun/tools/jcmd/TestJcmdSanity.java 8031482 windows-all +sun/tools/jhsdb/BasicLauncherTest.java 8160376 macosx-all + +sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8160376 macosx-all + sun/tools/jmap/heapconfig/JMapHeapConfigTest.java 8072131,8132452 generic-all sun/tools/jstatd/TestJstatdExternalRegistry.java 8046285 generic-all From 7864c70b9bdb5968ee315c5cc71d9615e10fc068 Mon Sep 17 00:00:00 2001 From: Alan Burlison Date: Wed, 20 Jul 2016 12:53:25 -0700 Subject: [PATCH 10/13] 8161057: Solaris: deprecated/obsolete compiler flags should be removed Reviewed-by: tbell, dcubed, dholmes --- .../demo/share/jvmti/compiledMethodLoad/sample.makefile.txt | 6 +++--- jdk/src/demo/share/jvmti/gctest/sample.makefile.txt | 6 +++--- jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt | 6 +++--- jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt | 6 +++--- jdk/src/demo/share/jvmti/java_crw_demo/sample.makefile.txt | 6 +++--- jdk/src/demo/share/jvmti/minst/sample.makefile.txt | 6 +++--- jdk/src/demo/share/jvmti/mtrace/sample.makefile.txt | 6 +++--- jdk/src/demo/share/jvmti/versionCheck/sample.makefile.txt | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/jdk/src/demo/share/jvmti/compiledMethodLoad/sample.makefile.txt b/jdk/src/demo/share/jvmti/compiledMethodLoad/sample.makefile.txt index 3c4c5dee595..3da8383d912 100644 --- a/jdk/src/demo/share/jvmti/compiledMethodLoad/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/compiledMethodLoad/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -45,12 +45,12 @@ LIBNAME=compiledMethodLoad SOURCES=compiledMethodLoad.c ../agent_util/agent_util.c -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) diff --git a/jdk/src/demo/share/jvmti/gctest/sample.makefile.txt b/jdk/src/demo/share/jvmti/gctest/sample.makefile.txt index 5e5d0720bf9..46afeb498ce 100644 --- a/jdk/src/demo/share/jvmti/gctest/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/gctest/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -45,12 +45,12 @@ LIBNAME=gctest SOURCES=gctest.c ../agent_util/agent_util.c -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) diff --git a/jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt b/jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt index d6e964ff39b..e094bc8206f 100644 --- a/jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/heapTracker/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -49,12 +49,12 @@ JAVA_SOURCES=HeapTracker.java # Name of jar file that needs to be created JARFILE=heapTracker.jar -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) diff --git a/jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt b/jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt index a18c9d1494c..59693c298eb 100644 --- a/jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/heapViewer/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -45,12 +45,12 @@ LIBNAME=heapViewer SOURCES=heapViewer.c ../agent_util/agent_util.c -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) diff --git a/jdk/src/demo/share/jvmti/java_crw_demo/sample.makefile.txt b/jdk/src/demo/share/jvmti/java_crw_demo/sample.makefile.txt index 35dbbe4b5e0..81ce07938d4 100644 --- a/jdk/src/demo/share/jvmti/java_crw_demo/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/java_crw_demo/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -45,12 +45,12 @@ LIBNAME=java_crw_demo SOURCES=java_crw_demo.c -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) diff --git a/jdk/src/demo/share/jvmti/minst/sample.makefile.txt b/jdk/src/demo/share/jvmti/minst/sample.makefile.txt index 94bb4c56ccc..5c8f422fb40 100644 --- a/jdk/src/demo/share/jvmti/minst/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/minst/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -49,12 +49,12 @@ JAVA_SOURCES=Minst.java # Name of jar file that needs to be created JARFILE=minst.jar -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) diff --git a/jdk/src/demo/share/jvmti/mtrace/sample.makefile.txt b/jdk/src/demo/share/jvmti/mtrace/sample.makefile.txt index 46ceb7e59ef..b342e785020 100644 --- a/jdk/src/demo/share/jvmti/mtrace/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/mtrace/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -49,12 +49,12 @@ JAVA_SOURCES=Mtrace.java # Name of jar file that needs to be created JARFILE=mtrace.jar -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) diff --git a/jdk/src/demo/share/jvmti/versionCheck/sample.makefile.txt b/jdk/src/demo/share/jvmti/versionCheck/sample.makefile.txt index 7a586ed734c..01240330398 100644 --- a/jdk/src/demo/share/jvmti/versionCheck/sample.makefile.txt +++ b/jdk/src/demo/share/jvmti/versionCheck/sample.makefile.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -45,12 +45,12 @@ LIBNAME=versionCheck SOURCES=versionCheck.c ../agent_util/agent_util.c -# Solaris Sun C Compiler Version 5.5 +# Solaris Studio C Compiler Version 12.4 ifeq ($(OSNAME), solaris) # Sun Solaris Compiler options needed COMMON_FLAGS=-mt -KPIC # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none + COMMON_FLAGS+= -Xa -v -xc99=%none # Check LIBARCH for any special compiler options LIBARCH=$(shell uname -p) ifeq ($(LIBARCH), sparc) From 043af61997b5d633632282b284bf749c21432912 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 21 Jul 2016 16:29:17 +0200 Subject: [PATCH 11/13] 8161947: runtime/Unsafe/GetUnsafe.java is failing on jdk9/dev Reviewed-by: alanb, dholmes --- jdk/test/sun/misc/{Safe.java => GetSunMiscUnsafe.java} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename jdk/test/sun/misc/{Safe.java => GetSunMiscUnsafe.java} (90%) diff --git a/jdk/test/sun/misc/Safe.java b/jdk/test/sun/misc/GetSunMiscUnsafe.java similarity index 90% rename from jdk/test/sun/misc/Safe.java rename to jdk/test/sun/misc/GetSunMiscUnsafe.java index c499a0a2c90..44ac2f70ffb 100644 --- a/jdk/test/sun/misc/Safe.java +++ b/jdk/test/sun/misc/GetSunMiscUnsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,12 +29,12 @@ */ -public class Safe { +public class GetSunMiscUnsafe { public static void main(String[] args) throws Exception { try { sun.misc.Unsafe.getUnsafe(); - } catch (Exception x) { + } catch (SecurityException x) { System.err.println("Thrown as expected: " + x); return; } From a7960979d96c5ee5c8530652e9fa93a5e79eba31 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Tue, 26 Jul 2016 23:52:29 -0400 Subject: [PATCH 12/13] 8140723: Remove source code conditionalized on JAVASE_EMBEDDED Reviewed-by: psandoz, alanb, alexsch --- jdk/make/lib/Awt2dLibraries.gmk | 2 - .../java/lang/VersionProps.java.template | 4 -- .../unix/native/libjava/java_props_md.c | 41 +------------------ .../unix/native/libawt_xawt/xawt/XToolkit.c | 19 ++------- .../java.desktop/unix/native/libjawt/jawt.c | 7 +--- .../testlibrary/jdk/testlibrary/Platform.java | 6 +-- 6 files changed, 6 insertions(+), 73 deletions(-) diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index b692a733830..e6213d1328d 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -350,8 +350,6 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) BUILD_LIBAWT_XAWT_awt_Font.c_CFLAGS := -w # initializing a declared 'extern' BUILD_LIBAWT_XAWT_debug_mem.c_CFLAGS := -w - # decimal constant is unsigned only in ISO C90 (JAVASE_EMBEDDED) - BUILD_LIBAWT_XAWT_XToolkit.c_CFLAGS := -w endif $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_XAWT, \ diff --git a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template index a51702fa093..d3c86a2befe 100644 --- a/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template +++ b/jdk/src/java.base/share/classes/java/lang/VersionProps.java.template @@ -166,10 +166,6 @@ class VersionProps { ps.print(java_runtime_name + " (" + jdk_debug_level + "build " + java_runtime_version); - if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) { - // embedded builds report headless state - ps.print(", headless"); - } ps.println(')'); /* Third line: JVM information. */ diff --git a/jdk/src/java.base/unix/native/libjava/java_props_md.c b/jdk/src/java.base/unix/native/libjava/java_props_md.c index b03bd6ac8f1..78e1b7b99c6 100644 --- a/jdk/src/java.base/unix/native/libjava/java_props_md.c +++ b/jdk/src/java.base/unix/native/libjava/java_props_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -68,11 +68,6 @@ #endif #endif /* !_ALLBSD_SOURCE */ -#ifdef JAVASE_EMBEDDED -#include -#include -#endif - /* Take an array of string pairs (map of key->value) and a string (key). * Examine each pair in the map to see if the first string (key) matches the * string. If so, store the second string of the pair (value) in the value and @@ -350,36 +345,6 @@ static int ParseLocale(JNIEnv* env, int cat, char ** std_language, char ** std_s return 1; } -#ifdef JAVASE_EMBEDDED -/* Determine the default embedded toolkit based on whether libawt_xawt - * exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX - */ -static char* getEmbeddedToolkit() { - Dl_info dlinfo; - char buf[MAXPATHLEN]; - int32_t len; - char *p; - struct stat statbuf; - - /* Get address of this library and the directory containing it. */ - dladdr((void *)getEmbeddedToolkit, &dlinfo); - realpath((char *)dlinfo.dli_fname, buf); - len = strlen(buf); - p = strrchr(buf, '/'); - /* Default AWT Toolkit on Linux and Solaris is XAWT (libawt_xawt.so). */ - strncpy(p, "/libawt_xawt.so", MAXPATHLEN-len-1); - /* Check if it exists */ - if (stat(buf, &statbuf) == -1 && errno == ENOENT) { - /* No - this is a reduced-headless-jre so use special HToolkit */ - return "sun.awt.HToolkit"; - } - else { - /* Yes - this is a headful JRE so fallback to SE defaults */ - return NULL; - } -} -#endif - /* This function gets called very early, before VM_CALLS are setup. * Do not use any of the VM_CALLS entries!!! */ @@ -424,10 +389,6 @@ GetJavaProperties(JNIEnv *env) sprops.awt_headless = isInAquaSession() ? NULL : "true"; #else sprops.graphics_env = "sun.awt.X11GraphicsEnvironment"; -#ifdef JAVASE_EMBEDDED - sprops.awt_toolkit = getEmbeddedToolkit(); - if (sprops.awt_toolkit == NULL) // default as below -#endif sprops.awt_toolkit = "sun.awt.X11.XToolkit"; #endif diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c index db32a22ec6c..bb240b1e8cd 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -122,11 +122,7 @@ Java_sun_awt_X11_XToolkit_initIDs JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout (JNIEnv *env, jclass clazz) { -#ifndef JAVASE_EMBEDDED return (jlong) 2000; -#else - return (jlong) 10000; -#endif } /* @@ -369,12 +365,7 @@ static uint32_t get_poll_timeout(jlong nextTaskTime); #define AWT_READPIPE (awt_pipe_fds[0]) #define AWT_WRITEPIPE (awt_pipe_fds[1]) -#ifdef JAVASE_EMBEDDED - #define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)4000000000) /* milliseconds */ -#else - #define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */ -#endif - +#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */ #define DEF_AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */ #define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */ @@ -391,11 +382,7 @@ static uint32_t get_poll_timeout(jlong nextTaskTime); // Static fields -#ifdef JAVASE_EMBEDDED - static int awt_poll_alg = AWT_POLL_AGING_FAST; -#else - static int awt_poll_alg = AWT_POLL_AGING_SLOW; -#endif +static int awt_poll_alg = AWT_POLL_AGING_SLOW; static uint32_t AWT_FLUSH_TIMEOUT = DEF_AWT_FLUSH_TIMEOUT; /* milliseconds */ static uint32_t AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT; /* milliseconds */ diff --git a/jdk/src/java.desktop/unix/native/libjawt/jawt.c b/jdk/src/java.desktop/unix/native/libjawt/jawt.c index 1b7c0499258..b6a5240a7c1 100644 --- a/jdk/src/java.desktop/unix/native/libjawt/jawt.c +++ b/jdk/src/java.desktop/unix/native/libjawt/jawt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, 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,10 +39,6 @@ DEF_STATIC_JNI_OnLoad */ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) { -#if defined(JAVASE_EMBEDDED) && defined(HEADLESS) - /* there are no AWT libs available at all */ - return JNI_FALSE; -#else if (awt == NULL) { return JNI_FALSE; } @@ -62,5 +58,4 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) } return JNI_TRUE; -#endif } diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java b/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java index 523e6e6a074..635f37f0b82 100644 --- a/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java +++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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 @@ -58,10 +58,6 @@ public class Platform { return vmName.endsWith(" Minimal VM"); } - public static boolean isEmbedded() { - return vmName.contains("Embedded"); - } - public static boolean isTieredSupported() { return compiler.contains("Tiered Compilers"); } From 201f2252c2ae1ee90c921d0cd9783332d52765fe Mon Sep 17 00:00:00 2001 From: Karen Kinnear Date: Wed, 27 Jul 2016 08:33:15 -0400 Subject: [PATCH 13/13] 8162340: Better class stream parsing Check package validity Reviewed-by: lfoltan, coleenp, dholmes --- .../java/lang/invoke/VMAnonymousClass.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/lang/invoke/VMAnonymousClass.java b/jdk/test/java/lang/invoke/VMAnonymousClass.java index 8cd24d21c41..f686b24c113 100644 --- a/jdk/test/java/lang/invoke/VMAnonymousClass.java +++ b/jdk/test/java/lang/invoke/VMAnonymousClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,7 @@ public class VMAnonymousClass { test.testJavaUtil(); test.testJdkInternalMisc(); test.testJavaLangInvoke(); + test.testProhibitedJavaPkg(); System.out.println("TEST PASSED"); } @@ -54,13 +55,29 @@ public class VMAnonymousClass { @Test public void testJavaUtil() throws Throwable { test("java/util"); } @Test public void testJdkInternalMisc() throws Throwable { test("jdk/internal/misc"); } @Test public void testJavaLangInvoke() throws Throwable { test("java/lang/invoke"); } + @Test public void testProhibitedJavaPkg() throws Throwable { + try { + test("java/prohibited"); + } catch (SecurityException e) { + return; + } + throw new RuntimeException("Expected SecurityException"); + } private static Unsafe unsafe = getUnsafe(); private static void test(String pkg) throws Throwable { byte[] bytes = dumpClass(pkg); - // Define VM anonymous class in privileged context (on BCP). - Class anonClass = unsafe.defineAnonymousClass(Object.class, bytes, null); + Class host_class; + if (pkg.equals("java/prohibited")) { + VMAnonymousClass sampleclass = new VMAnonymousClass(); + host_class = (Class)sampleclass.getClass(); + } else { + host_class = Object.class; + } + + // Define VM anonymous class + Class anonClass = unsafe.defineAnonymousClass(host_class, bytes, null); MethodType t = MethodType.methodType(Object.class, int.class); MethodHandle target = MethodHandles.lookup().findStatic(anonClass, "get", t);