From eb9fccdfd79eeb51693fe1dc5ed85a06dacb6a23 Mon Sep 17 00:00:00 2001 From: Patric Hedlin Date: Wed, 13 Jul 2016 12:10:22 +0200 Subject: [PATCH 01/81] 8160942: Unused code in GraphKit::record_profiled_receiver_for_speculation Fixed logic error; locally scoped 'maybe_null' w/initialiser is unused/dead Reviewed-by: kvn --- hotspot/src/share/vm/opto/graphKit.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index acb4174bcf1..c879137d882 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -2172,10 +2172,9 @@ Node* GraphKit::record_profiled_receiver_for_speculation(Node* n) { java_bc() == Bytecodes::_instanceof || java_bc() == Bytecodes::_aastore) { ciProfileData* data = method()->method_data()->bci_to_data(bci()); - bool maybe_null = data == NULL ? true : data->as_BitData()->null_seen(); + maybe_null = data == NULL ? true : data->as_BitData()->null_seen(); } return record_profile_for_speculation(n, exact_kls, maybe_null); - return n; } /** From 97ed41a8e931856f6356215ed8d20072382d268f Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Mon, 29 Aug 2016 07:32:37 +0200 Subject: [PATCH 02/81] 8163880: Constant pool caching of fields inhibited/delayed unnecessarily Delay/inhibit constant pool caching of fields only if necessary Reviewed-by: kvn --- .../vm/interpreter/interpreterRuntime.cpp | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp index 18ac2392abe..b4154a65ce8 100644 --- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp +++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp @@ -576,27 +576,39 @@ void InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code byt // compute auxiliary field attributes TosState state = as_TosState(info.field_type()); - // Put instructions on final fields are not resolved. This is required so we throw - // exceptions at the correct place (when the instruction is actually invoked). + // Resolution of put instructions on final fields is delayed. That is required so that + // exceptions are thrown at the correct place (when the instruction is actually invoked). // If we do not resolve an instruction in the current pass, leaving the put_code // set to zero will cause the next put instruction to the same field to reresolve. + + // Resolution of put instructions to final instance fields with invalid updates (i.e., + // to final instance fields with updates originating from a method different than ) + // is inhibited. A putfield instruction targeting an instance final field must throw + // an IllegalAccessError if the instruction is not in an instance + // initializer method . If resolution were not inhibited, a putfield + // in an initializer method could be resolved in the initializer. Subsequent + // putfield instructions to the same field would then use cached information. + // As a result, those instructions would not pass through the VM. That is, + // checks in resolve_field_access() would not be executed for those instructions + // and the required IllegalAccessError would not be thrown. // // Also, we need to delay resolving getstatic and putstatic instructions until the // class is initialized. This is required so that access to the static // field will call the initialization function every time until the class // is completely initialized ala. in 2.17.5 in JVM Specification. InstanceKlass* klass = InstanceKlass::cast(info.field_holder()); - bool uninitialized_static = ((bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic) && - !klass->is_initialized()); - - Bytecodes::Code put_code = (Bytecodes::Code)0; - if (is_put && !info.access_flags().is_final() && !uninitialized_static) { - put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield); - } + bool uninitialized_static = is_static && !klass->is_initialized(); + bool has_initialized_final_update = info.field_holder()->major_version() >= 53 && + info.has_initialized_final_update(); + assert(!(has_initialized_final_update && !info.access_flags().is_final()), "Fields with initialized final updates must be final"); Bytecodes::Code get_code = (Bytecodes::Code)0; + Bytecodes::Code put_code = (Bytecodes::Code)0; if (!uninitialized_static) { get_code = ((is_static) ? Bytecodes::_getstatic : Bytecodes::_getfield); + if ((is_put && !has_initialized_final_update) || !info.access_flags().is_final()) { + put_code = ((is_static) ? Bytecodes::_putstatic : Bytecodes::_putfield); + } } cp_cache_entry->set_field( From 7a6ffc8b52961e464333b3d7ae2745654a8430a7 Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Mon, 29 Aug 2016 17:15:20 +0000 Subject: [PATCH 03/81] 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT) Reviewed-by: zmajo --- .../src/jdk/vm/ci/hotspot/CompilerToVM.java | 4 +- .../vm/ci/hotspot/HotSpotConstantPool.java | 2 +- .../HotSpotResolvedObjectTypeImpl.java | 3 +- .../src/jdk/vm/ci/meta/ResolvedJavaType.java | 4 +- .../src/share/vm/jvmci/jvmciCompilerToVM.cpp | 7 ++- .../ci/runtime/test/TestResolvedJavaType.java | 43 ++++++++++++++++--- 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java index 34b80e013b3..00d998d69d6 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java @@ -366,8 +366,8 @@ final class CompilerToVM { * {@code exactReceiver}. * * @param caller the caller or context type used to perform access checks - * @return the link-time resolved method (might be abstract) or {@code 0} if it can not be - * linked + * @return the link-time resolved method (might be abstract) or {@code null} if it is either a + * signature polymorphic method or can not be linked. */ native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller); diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java index bd2c1699973..957f66516b9 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java @@ -722,7 +722,7 @@ final class HotSpotConstantPool implements ConstantPool, MetaspaceWrapperObject /** * Determines if {@code type} contains signature polymorphic methods. */ - private static boolean isSignaturePolymorphicHolder(final HotSpotResolvedObjectTypeImpl type) { + static boolean isSignaturePolymorphicHolder(final ResolvedJavaType type) { String name = type.getName(); if (signaturePolymorphicHolders == null) { signaturePolymorphicHolders = compilerToVM().getSignaturePolymorphicHolders(); diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java index b2ff5b32491..875b08b1bf8 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java @@ -24,6 +24,7 @@ package jdk.vm.ci.hotspot; import static java.util.Objects.requireNonNull; import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import static jdk.vm.ci.hotspot.HotSpotConstantPool.isSignaturePolymorphicHolder; import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; @@ -426,7 +427,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem // Methods can only be resolved against concrete types return null; } - if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic()) { + if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic() && !isSignaturePolymorphicHolder(method.getDeclaringClass())) { return method; } if (!method.getDeclaringClass().isAssignableFrom(this)) { diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java index 4928ef4b572..43cc6a62d9f 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java @@ -209,8 +209,8 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider, Annotated * * @param method the method to select the implementation of * @param callerType the caller or context type used to perform access checks - * @return the method that would be selected at runtime (might be abstract) or {@code null} if - * it can not be resolved + * @return the link-time resolved method (might be abstract) or {@code null} if it is either a + * signature polymorphic method or can not be linked. */ ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType); diff --git a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp index 69429aaf885..dc19a497f5e 100644 --- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp @@ -768,6 +768,11 @@ C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_t Symbol* h_name = method->name(); Symbol* h_signature = method->signature(); + if (MethodHandles::is_signature_polymorphic_method(method())) { + // Signature polymorphic methods are already resolved, JVMCI just returns NULL in this case. + return NULL; + } + LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass); methodHandle m; // Only do exact lookup if receiver klass has been linked. Otherwise, @@ -782,7 +787,7 @@ C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_t } if (m.is_null()) { - // Return NULL only if there was a problem with lookup (uninitialized class, etc.) + // Return NULL if there was a problem with lookup (uninitialized class, etc.) return NULL; } diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java index 84a6b0f0414..86e54c9b7bc 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java @@ -25,7 +25,6 @@ * @test * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library ../../../../../ - * @ignore 8161550 * @modules java.base/jdk.internal.reflect * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime @@ -74,11 +73,29 @@ import static org.junit.Assert.assertTrue; /** * Tests for {@link ResolvedJavaType}. */ +@SuppressWarnings("unchecked") public class TestResolvedJavaType extends TypeUniverse { + private static final Class SIGNATURE_POLYMORPHIC_CLASS = findPolymorphicSignatureClass(); public TestResolvedJavaType() { } + private static Class findPolymorphicSignatureClass() { + Class signaturePolyAnnotation = null; + try { + for (Class clazz : TestResolvedJavaType.class.getClassLoader().loadClass("java.lang.invoke.MethodHandle").getDeclaredClasses()) { + if (clazz.getName().endsWith("PolymorphicSignature") && Annotation.class.isAssignableFrom(clazz)) { + signaturePolyAnnotation = (Class) clazz; + break; + } + } + } catch (Throwable e) { + throw new AssertionError("Could not find annotation PolymorphicSignature in java.lang.invoke.MethodHandle", e); + } + assertNotNull(signaturePolyAnnotation); + return signaturePolyAnnotation; + } + @Test public void findInstanceFieldWithOffsetTest() { for (Class c : classes) { @@ -577,8 +594,14 @@ public class TestResolvedJavaType extends TypeUniverse { for (Method decl : decls) { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { - ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); - assertEquals(m.toString(), i, type.resolveMethod(m, context)); + ResolvedJavaMethod resolvedmethod = type.resolveMethod(m, context); + if (isSignaturePolymorphic(m)) { + // Signature polymorphic methods must not be resolved + assertNull(resolvedmethod); + } else { + ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); + assertEquals(m.toString(), i, resolvedmethod); + } } } } @@ -606,8 +629,14 @@ public class TestResolvedJavaType extends TypeUniverse { for (Method decl : decls) { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { - ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); - assertEquals(i, type.resolveConcreteMethod(m, context)); + ResolvedJavaMethod resolvedMethod = type.resolveConcreteMethod(m, context); + if (isSignaturePolymorphic(m)) { + // Signature polymorphic methods must not be resolved + assertNull(String.format("Got: %s", resolvedMethod), resolvedMethod); + } else { + ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); + assertEquals(i, resolvedMethod); + } } } } @@ -929,4 +958,8 @@ public class TestResolvedJavaType extends TypeUniverse { } } } + + private static boolean isSignaturePolymorphic(ResolvedJavaMethod method) { + return method.getAnnotation(SIGNATURE_POLYMORPHIC_CLASS) != null; + } } From adf14d8c2d78816cbd773e23c5c0ace0a8329408 Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Tue, 30 Aug 2016 09:30:07 +0200 Subject: [PATCH 04/81] 8161720: Better byte behavior for off-heap data Normalize boolean values read with Unsafe. Reviewed-by: aph, simonis, jrose, psandoz --- .../classes/jdk/internal/misc/Unsafe.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index d37b3e7de5b..bdba8a3edbf 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -1600,11 +1600,50 @@ public final class Unsafe { return weakCompareAndSwapShort(o, offset, c2s(expected), c2s(x)); } + /** + * The JVM converts integral values to boolean values using two + * different conventions, byte testing against zero and truncation + * to least-significant bit. + * + *

The JNI documents specify that, at least for returning + * values from native methods, a Java boolean value is converted + * to the value-set 0..1 by first truncating to a byte (0..255 or + * maybe -128..127) and then testing against zero. Thus, Java + * booleans in non-Java data structures are by convention + * represented as 8-bit containers containing either zero (for + * false) or any non-zero value (for true). + * + *

Java booleans in the heap are also stored in bytes, but are + * strongly normalized to the value-set 0..1 (i.e., they are + * truncated to the least-significant bit). + * + *

The main reason for having different conventions for + * conversion is performance: Truncation to the least-significant + * bit can be usually implemented with fewer (machine) + * instructions than byte testing against zero. + * + *

A number of Unsafe methods load boolean values from the heap + * as bytes. Unsafe converts those values according to the JNI + * rules (i.e, using the "testing against zero" convention). The + * method {@code byte2bool} implements that conversion. + * + * @param b the byte to be converted to boolean + * @return the result of the conversion + */ @ForceInline private boolean byte2bool(byte b) { - return b > 0; + return b != 0; } + /** + * Convert a boolean value to a byte. The return value is strongly + * normalized to the value-set 0..1 (i.e., the value is truncated + * to the least-significant bit). See {@link #byte2bool(byte)} for + * more details on conversion conventions. + * + * @param b the boolean to be converted to byte (and then normalized) + * @return the result of the conversion + */ @ForceInline private byte bool2byte(boolean b) { return b ? (byte)1 : (byte)0; From 00c9b389f60f49dfe43ffc1f4c809507f49d37da Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Tue, 30 Aug 2016 09:30:16 +0200 Subject: [PATCH 05/81] 8161720: Better byte behavior for off-heap data Normalize boolean values read with Unsafe. Reviewed-by: aph, simonis, jrose, psandoz --- hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 9 ++ hotspot/src/share/vm/opto/library_call.cpp | 22 +++++ hotspot/src/share/vm/prims/unsafe.cpp | 23 +++-- .../unsafe/UnsafeOffHeapBooleanTest.java | 92 ++++++++++++++++++ .../unsafe/UnsafeOnHeapBooleanTest.java | 95 +++++++++++++++++++ .../UnsafeSmallOffsetBooleanAccessTest.java | 85 +++++++++++++++++ 6 files changed, 319 insertions(+), 7 deletions(-) create mode 100644 hotspot/test/compiler/unsafe/UnsafeOffHeapBooleanTest.java create mode 100644 hotspot/test/compiler/unsafe/UnsafeOnHeapBooleanTest.java create mode 100644 hotspot/test/compiler/unsafe/UnsafeSmallOffsetBooleanAccessTest.java diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index a0f94545a7e..c1079e0f571 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -2410,6 +2410,15 @@ void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) { #endif // INCLUDE_ALL_GCS if (x->is_volatile() && os::is_MP()) __ membar_acquire(); + + /* Normalize boolean value returned by unsafe operation, i.e., value != 0 ? value = true : value false. */ + if (type == T_BOOLEAN) { + LabelObj* equalZeroLabel = new LabelObj(); + __ cmp(lir_cond_equal, value, 0); + __ branch(lir_cond_equal, T_BOOLEAN, equalZeroLabel->label()); + __ move(LIR_OprFact::intConst(1), value); + __ branch_destination(equalZeroLabel->label()); + } } diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 2fae1704c8f..e57f00ef26e 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -2471,6 +2471,28 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c // load value switch (type) { case T_BOOLEAN: + { + // Normalize the value returned by getBoolean in the following cases + if (mismatched || + heap_base_oop == top() || // - heap_base_oop is NULL or + (can_access_non_heap && alias_type->field() == NULL) // - heap_base_oop is potentially NULL + // and the unsafe access is made to large offset + // (i.e., larger than the maximum offset necessary for any + // field access) + ) { + IdealKit ideal = IdealKit(this); +#define __ ideal. + IdealVariable normalized_result(ideal); + __ declarations_done(); + __ set(normalized_result, p); + __ if_then(p, BoolTest::ne, ideal.ConI(0)); + __ set(normalized_result, ideal.ConI(1)); + ideal.end_if(); + final_sync(ideal); + p = __ value(normalized_result); +#undef __ + } + } case T_CHAR: case T_BYTE: case T_SHORT: diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 55a968170a5..8b3acd836c3 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -150,14 +150,23 @@ class MemoryAccess : StackObj { } template - T normalize(T x) { + T normalize_for_write(T x) { return x; } - jboolean normalize(jboolean x) { + jboolean normalize_for_write(jboolean x) { return x & 1; } + template + T normalize_for_read(T x) { + return x; + } + + jboolean normalize_for_read(jboolean x) { + return x != 0; + } + /** * Helper class to wrap memory accesses in JavaThread::doing_unsafe_access() */ @@ -196,7 +205,7 @@ public: T* p = (T*)addr(); - T x = *p; + T x = normalize_for_read(*p); return x; } @@ -207,7 +216,7 @@ public: T* p = (T*)addr(); - *p = normalize(x); + *p = normalize_for_write(x); } @@ -223,7 +232,7 @@ public: T x = OrderAccess::load_acquire((volatile T*)p); - return x; + return normalize_for_read(x); } template @@ -232,7 +241,7 @@ public: T* p = (T*)addr(); - OrderAccess::release_store_fence((volatile T*)p, normalize(x)); + OrderAccess::release_store_fence((volatile T*)p, normalize_for_write(x)); } @@ -256,7 +265,7 @@ public: jlong* p = (jlong*)addr(); - Atomic::store(normalize(x), p); + Atomic::store(normalize_for_write(x), p); } #endif }; diff --git a/hotspot/test/compiler/unsafe/UnsafeOffHeapBooleanTest.java b/hotspot/test/compiler/unsafe/UnsafeOffHeapBooleanTest.java new file mode 100644 index 00000000000..202259b7bd7 --- /dev/null +++ b/hotspot/test/compiler/unsafe/UnsafeOffHeapBooleanTest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8161720 + * @modules java.base/jdk.internal.misc + * @run main/othervm -Xint UnsafeOffHeapBooleanTest 1 + * @run main/othervm -XX:+TieredCompilation -XX:TieredStopAtLevel=3 -Xbatch UnsafeOffHeapBooleanTest 20000 + * @run main/othervm -XX:-TieredCompilation -Xbatch UnsafeOffHeapBooleanTest 20000 + */ + + +import java.lang.reflect.Field; +import jdk.internal.misc.Unsafe; + +public class UnsafeOffHeapBooleanTest { + static boolean bool0 = false, bool1 = false, result = false; + static Unsafe UNSAFE = Unsafe.getUnsafe(); + static long offHeapMemory; + + public static void test() { + // Write two bytes to the off-heap memory location, both + // bytes correspond to the boolean value 'true'. + UNSAFE.putShort(null, offHeapMemory, (short)0x0204); + + // Read two bytes from the storage allocated above (as booleans). + bool0 = UNSAFE.getBoolean(null, offHeapMemory + 0); + bool1 = UNSAFE.getBoolean(null, offHeapMemory + 1); + result = bool0 & bool1; + } + + public static void main(String args[]) { + System.out.println("### Test started"); + + if (args.length != 1) { + throw new RuntimeException("### Test failure: test called with incorrect number of arguments"); + } + + // Allocate two bytes of storage. + offHeapMemory = UNSAFE.allocateMemory(2); + + try { + for (int i = 0; i < Integer.parseInt(args[0]); i++) { + test(); + } + + // Check if the two 'true' boolean values were normalized + // (i.e., reduced from the range 1...255 to 1). + if (!bool0 || !bool1 || !result) { + System.out.println("Some of the results below are wrong"); + System.out.println("bool0 is: " + bool0); + System.out.println("bool1 is: " + bool1); + System.out.println("bool0 & bool1 is: " + result); + System.out.println("==================================="); + throw new RuntimeException("### Test failed"); + } else { + System.out.println("Test generated correct results"); + System.out.println("bool0 is: " + bool0); + System.out.println("bool1 is: " + bool1); + System.out.println("bool0 & bool1 is: " + result); + System.out.println("==================================="); + } + } catch (NumberFormatException e) { + throw new RuntimeException("### Test failure: test called with incorrectly formatted parameter"); + } + + UNSAFE.freeMemory(offHeapMemory); + + System.out.println("### Test passed"); + } +} diff --git a/hotspot/test/compiler/unsafe/UnsafeOnHeapBooleanTest.java b/hotspot/test/compiler/unsafe/UnsafeOnHeapBooleanTest.java new file mode 100644 index 00000000000..de6ae0c996c --- /dev/null +++ b/hotspot/test/compiler/unsafe/UnsafeOnHeapBooleanTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8161720 + * @modules java.base/jdk.internal.misc + * @run main/othervm -Xint UnsafeOnHeapBooleanTest 1 + * @run main/othervm -XX:-UseOnStackReplacement -XX:+TieredCompilation -XX:TieredStopAtLevel=3 -Xbatch UnsafeOnHeapBooleanTest 20000 + * @run main/othervm -XX:-UseOnStackReplacement -XX:-TieredCompilation -Xbatch UnsafeOnHeapBooleanTest 20000 + */ + +import java.lang.reflect.Field; +import jdk.internal.misc.Unsafe; + +public class UnsafeOnHeapBooleanTest { + static short static_v; + static boolean bool0 = false, bool1 = false, result = false; + static Unsafe UNSAFE = Unsafe.getUnsafe(); + + public static void test() { + try { + // Write two bytes into the static field + // UnsafeOnHeapBooleanTest.static_v write two values. Both + // bytes correspond to the boolean value 'true'. + Field staticVField = UnsafeOnHeapBooleanTest.class.getDeclaredField("static_v"); + Object base = UNSAFE.staticFieldBase(staticVField); + long offset = UNSAFE.staticFieldOffset(staticVField); + UNSAFE.putShort(base, offset, (short)0x0204); + + // Read two bytes from the static field + // UnsafeOnHeapBooleanTest.static_v (as booleans). + bool0 = UNSAFE.getBoolean(base, offset + 0); + bool1 = UNSAFE.getBoolean(base, offset + 1); + result = bool0 & bool1; + } catch (NoSuchFieldException e) { + throw new RuntimeException("### Test failure: static field UnsafeOnHeapBooleanTest.static_v was not found"); + } + } + + public static void main(String args[]) { + System.out.println("### Test started"); + + if (args.length != 1) { + throw new RuntimeException("### Test failure: test called with incorrect number of arguments"); + } + + try { + for (int i = 0; i < Integer.parseInt(args[0]); i++) { + test(); + } + + // Check if the two 'true' boolean values were normalized + // (i.e., reduced from the range 1...255 to 1). + if (!bool0 || !bool1 || !result) { + System.out.println("Some of the results below are wrong"); + System.out.println("bool0 is: " + bool0); + System.out.println("bool1 is: " + bool1); + System.out.println("bool0 & bool1 is: " + result); + System.out.println("==================================="); + throw new RuntimeException("### Test failed"); + } else { + System.out.println("Test generated correct results"); + System.out.println("bool0 is: " + bool0); + System.out.println("bool1 is: " + bool1); + System.out.println("bool0 & bool1 is: " + result); + System.out.println("==================================="); + } + } catch (NumberFormatException e) { + throw new RuntimeException("### Test failure: test called with incorrectly formatted parameter"); + } + + System.out.println("### Test passed"); + } +} diff --git a/hotspot/test/compiler/unsafe/UnsafeSmallOffsetBooleanAccessTest.java b/hotspot/test/compiler/unsafe/UnsafeSmallOffsetBooleanAccessTest.java new file mode 100644 index 00000000000..65efff72209 --- /dev/null +++ b/hotspot/test/compiler/unsafe/UnsafeSmallOffsetBooleanAccessTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8161720 + * @modules java.base/jdk.internal.misc + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:-TieredCompilation UnsafeSmallOffsetBooleanAccessTest + * @run main/othervm -Xbatch UnsafeSmallOffsetBooleanAccessTest + */ + +import java.util.Random; +import jdk.internal.misc.Unsafe; + +public class UnsafeSmallOffsetBooleanAccessTest { + static final Unsafe UNSAFE = Unsafe.getUnsafe(); + static final long F_OFFSET; + static final Random random = new Random(); + + static { + try { + F_OFFSET = UNSAFE.objectFieldOffset(T.class.getDeclaredField("f")); + System.out.println("The offset is: " + F_OFFSET); + } catch (Exception e) { + throw new Error(e); + } + } + + static class T { + boolean f; + } + + // Always return false in a way that is not obvious to the compiler. + public static boolean myRandom() { + if (random.nextInt(101) > 134) { + return true; + } else { + return false; + } + } + + public static boolean test(T t) { + boolean result = false; + for (int i = 0; i < 20000; i++) { + boolean random = myRandom(); + // If myRandom() returns false, access t.f. + // + // If myRandom() returns true, access virtual address + // F_OFFSET. That address is most likely not mapped, + // therefore the access will most likely cause a + // crash. We're not concerned about that, though, because + // myRandom() always returns false. However, the C2 + // compiler avoids normalization of the value returned by + // getBoolean in this case. + result = UNSAFE.getBoolean(myRandom() ? null : t, F_OFFSET); + } + return result; + } + + public static void main(String[] args) { + T t = new T(); + UNSAFE.putBoolean(t, F_OFFSET, true); + System.out.println("The result for t is: " + test(t)); + } +} From 0ad50cd56b48cd4021cf94b749646d14e171a1f5 Mon Sep 17 00:00:00 2001 From: Trevor Watson Date: Tue, 30 Aug 2016 10:50:29 +0200 Subject: [PATCH 06/81] 8141634: Implement VarHandles/Unsafe intrinsics on SPARC Implement the appropriate intrinsics on SPARC. Reviewed-by: kvn, dholmes, zmajo --- hotspot/src/cpu/sparc/vm/sparc.ad | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index f0a897f157e..6e024bb7bf3 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -2921,6 +2921,26 @@ enc_class Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{ __ cmp( Rold, O7 ); %} + // raw int cas without using tmp register for compareAndExchange + enc_class enc_casi_exch( iRegP mem, iRegL old, iRegL new) %{ + Register Rmem = reg_to_register_object($mem$$reg); + Register Rold = reg_to_register_object($old$$reg); + Register Rnew = reg_to_register_object($new$$reg); + + MacroAssembler _masm(&cbuf); + __ cas(Rmem, Rold, Rnew); + %} + + // 64-bit cas without using tmp register for compareAndExchange + enc_class enc_casx_exch( iRegP mem, iRegL old, iRegL new) %{ + Register Rmem = reg_to_register_object($mem$$reg); + Register Rold = reg_to_register_object($old$$reg); + Register Rnew = reg_to_register_object($new$$reg); + + MacroAssembler _masm(&cbuf); + __ casx(Rmem, Rold, Rnew); + %} + enc_class enc_lflags_ne_to_boolean( iRegI res ) %{ Register Rres = reg_to_register_object($res$$reg); @@ -7105,6 +7125,7 @@ instruct storeLConditional( iRegP mem_ptr, iRegL oldval, g3RegL newval, flagsReg instruct compareAndSwapL_bool(iRegP mem_ptr, iRegL oldval, iRegL newval, iRegI res, o7RegI tmp1, flagsReg ccr ) %{ predicate(VM_Version::supports_cx8()); match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval))); + match(Set res (WeakCompareAndSwapL mem_ptr (Binary oldval newval))); effect( USE mem_ptr, KILL ccr, KILL tmp1); format %{ "MOV $newval,O7\n\t" @@ -7121,6 +7142,7 @@ instruct compareAndSwapL_bool(iRegP mem_ptr, iRegL oldval, iRegL newval, iRegI r instruct compareAndSwapI_bool(iRegP mem_ptr, iRegI oldval, iRegI newval, iRegI res, o7RegI tmp1, flagsReg ccr ) %{ match(Set res (CompareAndSwapI mem_ptr (Binary oldval newval))); + match(Set res (WeakCompareAndSwapI mem_ptr (Binary oldval newval))); effect( USE mem_ptr, KILL ccr, KILL tmp1); format %{ "MOV $newval,O7\n\t" @@ -7139,6 +7161,7 @@ instruct compareAndSwapP_bool(iRegP mem_ptr, iRegP oldval, iRegP newval, iRegI r predicate(VM_Version::supports_cx8()); #endif match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval))); + match(Set res (WeakCompareAndSwapP mem_ptr (Binary oldval newval))); effect( USE mem_ptr, KILL ccr, KILL tmp1); format %{ "MOV $newval,O7\n\t" @@ -7159,6 +7182,7 @@ instruct compareAndSwapP_bool(iRegP mem_ptr, iRegP oldval, iRegP newval, iRegI r instruct compareAndSwapN_bool(iRegP mem_ptr, iRegN oldval, iRegN newval, iRegI res, o7RegI tmp1, flagsReg ccr ) %{ match(Set res (CompareAndSwapN mem_ptr (Binary oldval newval))); + match(Set res (WeakCompareAndSwapN mem_ptr (Binary oldval newval))); effect( USE mem_ptr, KILL ccr, KILL tmp1); format %{ "MOV $newval,O7\n\t" @@ -7172,6 +7196,54 @@ instruct compareAndSwapN_bool(iRegP mem_ptr, iRegN oldval, iRegN newval, iRegI r ins_pipe( long_memory_op ); %} +instruct compareAndExchangeI(iRegP mem_ptr, iRegI oldval, iRegI newval) +%{ + match(Set newval (CompareAndExchangeI mem_ptr (Binary oldval newval))); + effect( USE mem_ptr ); + + format %{ + "CASA [$mem_ptr],$oldval,$newval\t! If $oldval==[$mem_ptr] Then store $newval into [$mem_ptr] and set $newval=[$mem_ptr]\n\t" + %} + ins_encode( enc_casi_exch(mem_ptr, oldval, newval) ); + ins_pipe( long_memory_op ); +%} + +instruct compareAndExchangeL(iRegP mem_ptr, iRegL oldval, iRegL newval) +%{ + match(Set newval (CompareAndExchangeL mem_ptr (Binary oldval newval))); + effect( USE mem_ptr ); + + format %{ + "CASXA [$mem_ptr],$oldval,$newval\t! If $oldval==[$mem_ptr] Then store $newval into [$mem_ptr] and set $newval=[$mem_ptr]\n\t" + %} + ins_encode( enc_casx_exch(mem_ptr, oldval, newval) ); + ins_pipe( long_memory_op ); +%} + +instruct compareAndExchangeP(iRegP mem_ptr, iRegP oldval, iRegP newval) +%{ + match(Set newval (CompareAndExchangeP mem_ptr (Binary oldval newval))); + effect( USE mem_ptr ); + + format %{ + "CASXA [$mem_ptr],$oldval,$newval\t! If $oldval==[$mem_ptr] Then store $newval into [$mem_ptr] and set $newval=[$mem_ptr]\n\t" + %} + ins_encode( enc_casx_exch(mem_ptr, oldval, newval) ); + ins_pipe( long_memory_op ); +%} + +instruct compareAndExchangeN(iRegP mem_ptr, iRegN oldval, iRegN newval) +%{ + match(Set newval (CompareAndExchangeN mem_ptr (Binary oldval newval))); + effect( USE mem_ptr ); + + format %{ + "CASA [$mem_ptr],$oldval,$newval\t! If $oldval==[$mem_ptr] Then store $newval into [$mem_ptr] and set $newval=[$mem_ptr]\n\t" + %} + ins_encode( enc_casi_exch(mem_ptr, oldval, newval) ); + ins_pipe( long_memory_op ); +%} + instruct xchgI( memory mem, iRegI newval) %{ match(Set newval (GetAndSetI mem newval)); format %{ "SWAP [$mem],$newval" %} From 97391177a8c8e5235a8d9d0bfdac41aa73d147ed Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Tue, 30 Aug 2016 13:24:26 +0200 Subject: [PATCH 07/81] 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same Exception checking code needs to handle pre-allocated exceptions. Reviewed-by: dnsimon, kvn --- hotspot/src/share/vm/c1/c1_Runtime1.cpp | 10 +++++----- hotspot/src/share/vm/jvmci/jvmciRuntime.cpp | 9 +++++++-- hotspot/src/share/vm/opto/runtime.cpp | 16 +++++++++++----- hotspot/src/share/vm/runtime/sharedRuntime.cpp | 3 ++- hotspot/src/share/vm/runtime/sharedRuntime.hpp | 2 +- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index bbb5ef87c67..cbc11c13f1c 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -576,9 +576,8 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t // normal bytecode execution. thread->clear_exception_oop_and_pc(); - Handle original_exception(thread, exception()); - - continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); + bool recursive_exception = false; + continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false, recursive_exception); // If an exception was thrown during exception dispatch, the exception oop may have changed thread->set_exception_oop(exception()); thread->set_exception_pc(pc); @@ -586,8 +585,9 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t // the exception cache is used only by non-implicit exceptions // Update the exception cache only when there didn't happen // another exception during the computation of the compiled - // exception handler. - if (continuation != NULL && original_exception() == exception()) { + // exception handler. Checking for exception oop equality is not + // sufficient because some exceptions are pre-allocated and reused. + if (continuation != NULL && !recursive_exception) { nm->add_handler_for_exception_and_pc(exception, pc, continuation); } } diff --git a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp index ce6e8b5b80e..e9305c25aab 100644 --- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp @@ -313,13 +313,18 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t // normal bytecode execution. thread->clear_exception_oop_and_pc(); - continuation = SharedRuntime::compute_compiled_exc_handler(cm, pc, exception, false, false); + bool recursive_exception = false; + continuation = SharedRuntime::compute_compiled_exc_handler(cm, pc, exception, false, false, recursive_exception); // If an exception was thrown during exception dispatch, the exception oop may have changed thread->set_exception_oop(exception()); thread->set_exception_pc(pc); // the exception cache is used only by non-implicit exceptions - if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { + // Update the exception cache only when there didn't happen + // another exception during the computation of the compiled + // exception handler. Checking for exception oop equality is not + // sufficient because some exceptions are pre-allocated and reused. + if (continuation != NULL && !recursive_exception && !SharedRuntime::deopt_blob()->contains(continuation)) { cm->add_handler_for_exception_and_pc(exception, pc, continuation); } } diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index d0a3c4b8fd3..51f07849740 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -1349,17 +1349,23 @@ JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* t force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc); if (handler_address == NULL) { - Handle original_exception(thread, exception()); - handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true); + bool recursive_exception = false; + handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception); assert (handler_address != NULL, "must have compiled handler"); // Update the exception cache only when the unwind was not forced // and there didn't happen another exception during the computation of the - // compiled exception handler. - if (!force_unwind && original_exception() == exception()) { + // compiled exception handler. Checking for exception oop equality is not + // sufficient because some exceptions are pre-allocated and reused. + if (!force_unwind && !recursive_exception) { nm->add_handler_for_exception_and_pc(exception,pc,handler_address); } } else { - assert(handler_address == SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true), "Must be the same"); +#ifdef ASSERT + bool recursive_exception = false; + address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception); + vmassert(recursive_exception || (handler_address == computed_address), "Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT, + p2i(handler_address), p2i(computed_address)); +#endif } } diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index c2bf3c00778..cd517806273 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -621,7 +621,7 @@ JRT_END // ret_pc points into caller; we are returning caller's exception handler // for given exception address SharedRuntime::compute_compiled_exc_handler(CompiledMethod* cm, address ret_pc, Handle& exception, - bool force_unwind, bool top_frame_only) { + bool force_unwind, bool top_frame_only, bool& recursive_exception_occurred) { assert(cm != NULL, "must exist"); ResourceMark rm; @@ -677,6 +677,7 @@ address SharedRuntime::compute_compiled_exc_handler(CompiledMethod* cm, address // BCI of the exception handler which caused the exception to be // thrown (bugs 4307310 and 4546590). Set "exception" reference // argument to ensure that the correct exception is thrown (4870175). + recursive_exception_occurred = true; exception = Handle(THREAD, PENDING_EXCEPTION); CLEAR_PENDING_EXCEPTION; if (handler_bci >= 0) { diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index 02824bb485d..d938217bb9c 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -189,7 +189,7 @@ class SharedRuntime: AllStatic { // exception handling and implicit exceptions static address compute_compiled_exc_handler(CompiledMethod* nm, address ret_pc, Handle& exception, - bool force_unwind, bool top_frame_only); + bool force_unwind, bool top_frame_only, bool& recursive_exception_occurred); enum ImplicitExceptionKind { IMPLICIT_NULL, IMPLICIT_DIVIDE_BY_ZERO, From 4010176ca57657ea9f666ccaf89b1cc5b5fefb2f Mon Sep 17 00:00:00 2001 From: Patric Hedlin Date: Tue, 30 Aug 2016 13:53:36 +0200 Subject: [PATCH 08/81] 8157024: CodeCache JFR events reporting wrong data Fix scaling Reviewed-by: kvn --- hotspot/src/share/vm/code/codeCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/code/codeCache.cpp b/hotspot/src/share/vm/code/codeCache.cpp index e1a5d2fd0c9..0e858c03996 100644 --- a/hotspot/src/share/vm/code/codeCache.cpp +++ b/hotspot/src/share/vm/code/codeCache.cpp @@ -1305,7 +1305,7 @@ void CodeCache::report_codemem_full(int code_blob_type, bool print) { event.set_entryCount(heap->blob_count()); event.set_methodCount(heap->nmethod_count()); event.set_adaptorCount(heap->adapter_count()); - event.set_unallocatedCapacity(heap->unallocated_capacity()/K); + event.set_unallocatedCapacity(heap->unallocated_capacity()); event.set_fullCount(heap->full_count()); event.commit(); } From 010d9bf7dfb16272f83ad91093e6c529fd1ddbd9 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 30 Aug 2016 16:08:52 +0200 Subject: [PATCH 09/81] 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup" Also add methods to check for slow/fastdebug to Platform.java. Reviewed-by: simonis, cjplummer, dholmes --- hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp | 6 ++++-- hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 6 ++++-- .../share/vm/utilities/globalDefinitions_xlc.hpp | 2 +- .../NMT/CheckForProperDetailStackTrace.java | 14 +++++--------- .../TestMutuallyExclusivePlatformPredicates.java | 5 +++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index 7a40c0df126..1e440ca8579 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -192,8 +192,10 @@ frame os::current_frame() { intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); // hack. frame topframe(csp, (address)0x8); - // return sender of current topframe which hopefully has pc != NULL. - return os::get_sender_for_C_frame(&topframe); + // Return sender of sender of current topframe which hopefully + // both have pc != NULL. + frame tmp = os::get_sender_for_C_frame(&topframe); + return os::get_sender_for_C_frame(&tmp); } // Utility functions diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 3dce4275405..c0aeb994f41 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -205,8 +205,10 @@ frame os::current_frame() { intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); // hack. frame topframe(csp, (address)0x8); - // return sender of current topframe which hopefully has pc != NULL. - return os::get_sender_for_C_frame(&topframe); + // Return sender of sender of current topframe which hopefully + // both have pc != NULL. + frame tmp = os::get_sender_for_C_frame(&topframe); + return os::get_sender_for_C_frame(&tmp); } // Utility functions diff --git a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp index 68e204d45f0..ff97f116a77 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions_xlc.hpp @@ -186,6 +186,6 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } // Inlining support #define NOINLINE -#define ALWAYSINLINE __attribute__((always_inline)) +#define ALWAYSINLINE inline __attribute__((always_inline)) #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP diff --git a/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java b/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java index c053f660e9e..8caa81686f8 100644 --- a/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java +++ b/hotspot/test/runtime/NMT/CheckForProperDetailStackTrace.java @@ -57,11 +57,6 @@ public class CheckForProperDetailStackTrace { private static String expectedSymbol = "locked_create_entry_or_null"; - private static final String jdkDebug = System.getProperty("jdk.debug"); - private static boolean isSlowDebugBuild() { - return (jdkDebug.toLowerCase().equals("slowdebug")); - } - public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", @@ -76,11 +71,12 @@ public class CheckForProperDetailStackTrace { output.shouldNotContain("NativeCallStack::NativeCallStack"); output.shouldNotContain("os::get_native_stack"); - // AllocateHeap shouldn't be in the output because it is suppose to always be inlined. - // We check for that here, but allow it for Windows and Solaris slowdebug builds because - // the compiler ends up not inlining AllocateHeap. + // AllocateHeap shouldn't be in the output because it is supposed to always be inlined. + // We check for that here, but allow it for Aix, Solaris and Windows slowdebug builds + // because the compiler ends up not inlining AllocateHeap. Boolean okToHaveAllocateHeap = - isSlowDebugBuild() && (Platform.isSolaris() || Platform.isWindows()); + Platform.isSlowDebugBuild() && + (Platform.isAix() || Platform.isSolaris() || Platform.isWindows()); if (!okToHaveAllocateHeap) { output.shouldNotContain("AllocateHeap"); } diff --git a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java index 399535944f6..0d38e160684 100644 --- a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java +++ b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java @@ -50,8 +50,9 @@ public class TestMutuallyExclusivePlatformPredicates { OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"), VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"), MODE("isInt", "isMixed", "isComp"), - IGNORED("isDebugBuild", "shouldSAAttach", - "canPtraceAttachLinux", "canAttachOSX", "isTieredSupported"); + IGNORED("isDebugBuild", "isFastDebugBuild", "isSlowDebugBuild", + "shouldSAAttach", "canPtraceAttachLinux", "canAttachOSX", + "isTieredSupported"); public final List methodNames; From b2c1c48604bf36ff98c706d7222f7f7da584f435 Mon Sep 17 00:00:00 2001 From: Tatiana Pivovarova Date: Wed, 31 Aug 2016 14:47:20 +0300 Subject: [PATCH 10/81] 8165030: [TESTBUG] ctw failed to build after 8157957 Reviewed-by: kvn --- hotspot/test/testlibrary/ctw/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/testlibrary/ctw/Makefile b/hotspot/test/testlibrary/ctw/Makefile index 0c642c63256..db7204b1f12 100644 --- a/hotspot/test/testlibrary/ctw/Makefile +++ b/hotspot/test/testlibrary/ctw/Makefile @@ -40,7 +40,7 @@ TESTLIBRARY_DIR = ../../../../test/lib JAVAC = $(JDK_HOME)/bin/javac JAR = $(JDK_HOME)/bin/jar -SRC_FILES = $(shell find $(SRC_DIR) $(TESTLIBRARY_DIR)/share/classes -name '*.java') +SRC_FILES = $(shell find $(SRC_DIR) $(TESTLIBRARY_DIR)/jdk/test/lib -name '*.java') WB_SRC_FILES = $(shell find $(TESTLIBRARY_DIR)/sun/hotspot -name '*.java') MAIN_CLASS = sun.hotspot.tools.ctw.CompileTheWorld From 2baffbf490d9c390a63a09d08cae47eb3fa6460e Mon Sep 17 00:00:00 2001 From: Dean Long Date: Wed, 31 Aug 2016 12:10:40 -0700 Subject: [PATCH 11/81] 8156137: SIGSEGV in ReceiverTypeData::clean_weak_klass_links Process previous versions in Klass::clean_weak_klass_links() Reviewed-by: coleenp, sspitsyn, stefank, dcubed --- hotspot/src/share/vm/oops/klass.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 38a613d93b7..804d02d0b08 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -431,6 +431,12 @@ void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive if (clean_alive_klasses && current->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(current); ik->clean_weak_instanceklass_links(is_alive); + + // JVMTI RedefineClasses creates previous versions that are not in + // the class hierarchy, so process them here. + while ((ik = ik->previous_versions()) != NULL) { + ik->clean_weak_instanceklass_links(is_alive); + } } } } From 20bd3cebb8b390292594c3f9ec682c0365d7b05c Mon Sep 17 00:00:00 2001 From: Dmitrij Pochepko Date: Thu, 1 Sep 2016 21:12:07 +0300 Subject: [PATCH 12/81] 8157956: OverflowCodeCacheTest.java fails with Out of space in CodeCache for method handle intrinsic Reviewed-by: kvn --- .../test/compiler/codecache/OverflowCodeCacheTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java index 64bbd2c1dae..bc6a2023360 100644 --- a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java +++ b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java @@ -75,6 +75,7 @@ public class OverflowCodeCacheTest { System.out.printf("type %s%n", type); System.out.println("allocating till possible..."); ArrayList blobs = new ArrayList<>(); + int compilationActivityMode = -1; try { long addr; int size = (int) (getHeapSize() >> 7); @@ -88,13 +89,16 @@ public class OverflowCodeCacheTest { type + " doesn't allow using " + actualType + " when overflow"); } } - Asserts.assertNotEquals(WHITE_BOX.getCompilationActivityMode(), 1 /* run_compilation*/, - "Compilation must be disabled when CodeCache(CodeHeap) overflows"); + /* now, remember compilationActivityMode to check it later, after freeing, since we + possibly have no free cache for futher work */ + compilationActivityMode = WHITE_BOX.getCompilationActivityMode(); } finally { for (Long blob : blobs) { WHITE_BOX.freeCodeBlob(blob); } } + Asserts.assertNotEquals(compilationActivityMode, 1 /* run_compilation*/, + "Compilation must be disabled when CodeCache(CodeHeap) overflows"); } private long getHeapSize() { From 5b11c37fb720df4c467837eecf792db12d9acfa4 Mon Sep 17 00:00:00 2001 From: Dmitrij Pochepko Date: Thu, 1 Sep 2016 21:13:20 +0300 Subject: [PATCH 13/81] 8146096: [TEST BUG] compiler/loopopts/UseCountedLoopSafepoints.java Timeouts Reviewed-by: kvn --- .../loopopts/UseCountedLoopSafepoints.java | 59 +++------ .../UseCountedLoopSafepointsTest.java | 123 ++++++++++++++++++ 2 files changed, 143 insertions(+), 39 deletions(-) create mode 100644 hotspot/test/compiler/loopopts/UseCountedLoopSafepointsTest.java diff --git a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java index 0bf9185f7f5..d60e6c219c7 100644 --- a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java +++ b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java @@ -22,51 +22,32 @@ * */ -/** - * @test - * @bug 6869327 - * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop - * @library /test/lib - * @modules java.base/jdk.internal.misc - * @ignore 8146096 - * @run driver compiler.loopopts.UseCountedLoopSafepoints - */ - package compiler.loopopts; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; - -import java.util.concurrent.atomic.AtomicLong; +import java.lang.reflect.Method; +import sun.hotspot.WhiteBox; +import jdk.test.lib.Asserts; +import compiler.whitebox.CompilerWhiteBoxTest; public class UseCountedLoopSafepoints { - private static final AtomicLong _num = new AtomicLong(0); + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + private static final String METHOD_NAME = "testMethod"; + + private long accum = 0; - // Uses the fact that an EnableBiasedLocking vmop will be started - // after 500ms, while we are still in the loop. If there is a - // safepoint in the counted loop, then we will reach safepoint - // very quickly. Otherwise SafepointTimeout will be hit. public static void main (String args[]) throws Exception { - if (args.length == 1) { - final int loops = Integer.parseInt(args[0]); - for (int i = 0; i < loops; i++) { - _num.addAndGet(1); - } - } else { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:+IgnoreUnrecognizedVMOptions", - "-XX:-TieredCompilation", - "-XX:+UseBiasedLocking", - "-XX:BiasedLockingStartupDelay=500", - "-XX:+SafepointTimeout", - "-XX:SafepointTimeoutDelay=2000", - "-XX:+UseCountedLoopSafepoints", - UseCountedLoopSafepoints.class.getName(), - "2000000000" - ); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldNotContain("Timeout detected"); - output.shouldHaveExitValue(0); + new UseCountedLoopSafepoints().testMethod(); + Method m = UseCountedLoopSafepoints.class.getDeclaredMethod(METHOD_NAME); + String directive = "[{ match: \"" + UseCountedLoopSafepoints.class.getName().replace('.', '/') + + "." + METHOD_NAME + "\", " + "BackgroundCompilation: false }]"; + Asserts.assertTrue(WB.addCompilerDirective(directive) == 1, "Can't add compiler directive"); + Asserts.assertTrue(WB.enqueueMethodForCompilation(m, + CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION), "Can't enqueue method"); + } + + private void testMethod() { + for (int i = 0; i < 100; i++) { + accum += accum << 5 + accum >> 4 - accum >>> 5; } } } diff --git a/hotspot/test/compiler/loopopts/UseCountedLoopSafepointsTest.java b/hotspot/test/compiler/loopopts/UseCountedLoopSafepointsTest.java new file mode 100644 index 00000000000..741f0d93d67 --- /dev/null +++ b/hotspot/test/compiler/loopopts/UseCountedLoopSafepointsTest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 6869327 + * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop + * @library /test/lib / + * @requires vm.compMode != "Xint" & vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) + * @modules java.base/jdk.internal.misc + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver compiler.loopopts.UseCountedLoopSafepointsTest + */ + +package compiler.loopopts; + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import jdk.test.lib.Asserts; + +/* Idea of this test is to check if ideal graph has CountedLoopEnd->SafePoint edge in case + of UseCountedLoopSafepoint enabled and has no such edge in case it's disabled. Restricting + compilation to testMethod only will leave only one counted loop (the one in testedMethod) */ +public class UseCountedLoopSafepointsTest { + + public static void main (String args[]) { + check(true); // check ideal graph with UseCountedLoopSafepoint enabled + check(false); // ... and disabled + } + + private static void check(boolean enabled) { + OutputAnalyzer oa; + try { + oa = ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.", + "-XX:" + (enabled ? "+" : "-") + "UseCountedLoopSafepoints", "-XX:+WhiteBoxAPI", + "-XX:-Inline", "-Xbatch", "-XX:+PrintIdeal", "-XX:LoopUnrollLimit=0", + "-XX:CompileOnly=" + UseCountedLoopSafepoints.class.getName() + "::testMethod", + UseCountedLoopSafepoints.class.getName()); + } catch (Exception e) { + throw new Error("Exception launching child for case enabled=" + enabled + " : " + e, e); + } + oa.shouldHaveExitValue(0); + // parse output in seach of SafePoint and CountedLoopEnd nodes + List safePoints = new ArrayList<>(); + List loopEnds = new ArrayList<>(); + for (String line : oa.getOutput().split("\\n")) { + int separatorIndex = line.indexOf("\t==="); + if (separatorIndex > -1) { + String header = line.substring(0, separatorIndex); + if (header.endsWith("\tSafePoint")) { + safePoints.add(new Node("SafePoint", line)); + } else if (header.endsWith("\tCountedLoopEnd")) { + loopEnds.add(new Node("CountedLoopEnd", line)); + } + } + } + // now, find CountedLoopEnd -> SafePoint edge + boolean found = false; + for (Node loopEnd : loopEnds) { + found |= loopEnd.to.stream() + .filter(id -> nodeListHasElementWithId(safePoints, id)) + .findAny() + .isPresent(); + } + Asserts.assertEQ(enabled, found, "Safepoint " + (found ? "" : "not ") + "found"); + } + + private static boolean nodeListHasElementWithId(List list, int id) { + return list.stream() + .filter(node -> node.id == id) + .findAny() + .isPresent(); + } + + private static class Node { + public final int id; + public final List from; + public final List to; + + public Node(String name, String str) { + List tmpFrom = new ArrayList<>(); + List tmpTo = new ArrayList<>(); + // parse string like: " $id $name === $to1 $to2 ... [[ $from1 $from2 ... ]] $anything" + // example: 318 SafePoint === 317 1 304 1 1 10 308 [[ 97 74 ]] ... + id = Integer.parseInt(str.substring(1, str.indexOf(name)).trim()); + Arrays.stream(str.substring(str.indexOf("===") + 4, str.indexOf("[[")).trim().split("\\s+")) + .map(Integer::parseInt) + .forEach(tmpTo::add); + Arrays.stream(str.substring(str.indexOf("[[") + 3, str.indexOf("]]")).trim().split("\\s+")) + .map(Integer::parseInt) + .forEach(tmpFrom::add); + this.from = Collections.unmodifiableList(tmpFrom); + this.to = Collections.unmodifiableList(tmpTo); + } + } +} From 11bd07c98b22e4948ffe7f7da9ea00aa8ee28e26 Mon Sep 17 00:00:00 2001 From: Dmitrij Pochepko Date: Thu, 1 Sep 2016 21:15:12 +0300 Subject: [PATCH 14/81] 8165244: Unquarantine compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java Reviewed-by: kvn --- .../compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java index 90113dc5577..4c509335114 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java @@ -19,7 +19,6 @@ import java.util.List; * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") * @library /test/lib / * @library ../common/patches - * @ignore 8139383 * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree From a78140b8222f9e215d601f9f96f648ff818d6d3d Mon Sep 17 00:00:00 2001 From: Tatiana Pivovarova Date: Thu, 1 Sep 2016 20:16:04 +0300 Subject: [PATCH 15/81] 8165050: [TESTBUG] tests generated by jittester cannot be run with jtreg Reviewed-by: vlivanov --- hotspot/test/testlibrary/jittester/Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hotspot/test/testlibrary/jittester/Makefile b/hotspot/test/testlibrary/jittester/Makefile index 808765729dc..720b69c6dc3 100644 --- a/hotspot/test/testlibrary/jittester/Makefile +++ b/hotspot/test/testlibrary/jittester/Makefile @@ -56,7 +56,6 @@ BUILD_DIR = build CLASSES_DIR = $(BUILD_DIR)/classes SRC_DIR = src TEST_DIR = test -DRIVER_DIR = $(TESTBASE_DIR)/jdk/test/lib/jittester/jtreg MANIFEST = manifest.mf APPLICATION_ARGS += \ --property-file $(PROPERTY_FILE) \ @@ -118,19 +117,18 @@ cleantmp: @rm filelist @rm -rf $(CLASSES_DIR) -copytestlibrary: $(DRIVER_DIR) - @cp -r src/jdk/test/lib/jittester/jtreg/*.java $(DRIVER_DIR) +copytestlibrary: $(TESTBASE_DIR)/jdk/test/lib/jittester/jtreg + @cp -r src/jdk/test/lib/jittester/jtreg/*.java $(TESTBASE_DIR)/jdk/test/lib/jittester/jtreg + @cp -r $(TESTLIBRARY_SRC_DIR) $(TESTBASE_DIR)/jdk/test/ testgroup: $(TESTBASE_DIR) @echo 'jittester_all = \\' > $(TESTGROUP_FILE) @echo ' /' >> $(TESTGROUP_FILE) @echo '' >> $(TESTGROUP_FILE) - @echo 'main = \\' >> $(TESTGROUP_FILE) - @echo ' Test_0.java' >> $(TESTGROUP_FILE) testroot: $(TESTBASE_DIR) @echo 'groups=TEST.groups' > $(TESTROOT_FILE) -$(TESTBASE_DIR) $(DIST_DIR) $(DRIVER_DIR): +$(TESTBASE_DIR) $(DIST_DIR) $(TESTBASE_DIR)/jdk/test/lib/jittester/jtreg: $(shell if [ ! -d $@ ]; then mkdir -p $@; fi) From 66dfee55f83af3ac978117e3f002e9cd52608425 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 2 Sep 2016 15:04:47 +0200 Subject: [PATCH 16/81] 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup" Also add methods to check for slow/fastdebug to Platform.java. Reviewed-by: simonis, cjplummer, dholmes --- test/lib/jdk/test/lib/Platform.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index ec4fa8b63ba..1c5e60021c2 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -116,6 +116,14 @@ public class Platform { return (jdkDebug.toLowerCase().contains("debug")); } + public static boolean isSlowDebugBuild() { + return (jdkDebug.toLowerCase().equals("slowdebug")); + } + + public static boolean isFastDebugBuild() { + return (jdkDebug.toLowerCase().equals("fastdebug")); + } + public static String getVMVersion() { return vmVersion; } From 89f7f6f4b321c49350fcf3ac7205131788822db7 Mon Sep 17 00:00:00 2001 From: Michael Berg Date: Tue, 6 Sep 2016 09:59:25 -0700 Subject: [PATCH 17/81] 8164989: Inflate and compress intrinsics produce incorrect results with avx512 Disabled avx512 for compress and reastrict using of inflate. Reviewed-by: kvn --- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index 9957425c95c..8ec00bd9fce 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -8131,8 +8131,7 @@ void MacroAssembler::has_negatives(Register ary1, Register len, jmp(FALSE_LABEL); clear_vector_masking(); // closing of the stub context for programming mask registers - } - else { + } else { movl(result, len); // copy if (UseAVX == 2 && UseSSE >= 2) { @@ -8169,8 +8168,7 @@ void MacroAssembler::has_negatives(Register ary1, Register len, bind(COMPARE_TAIL); // len is zero movl(len, result); // Fallthru to tail compare - } - else if (UseSSE42Intrinsics) { + } else if (UseSSE42Intrinsics) { // With SSE4.2, use double quad vector compare Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; @@ -10748,7 +10746,10 @@ void MacroAssembler::char_array_compress(Register src, Register dst, Register le // save length for return push(len); + // 8165287: EVEX version disabled for now, needs to be refactored as + // it is returning incorrect results. if ((UseAVX > 2) && // AVX512 + 0 && VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2()) { @@ -11067,10 +11068,11 @@ void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len bind(below_threshold); bind(copy_new_tail); - if (UseAVX > 2) { + if ((UseAVX > 2) && + VM_Version::supports_avx512vlbw() && + VM_Version::supports_bmi2()) { movl(tmp2, len); - } - else { + } else { movl(len, tmp2); } andl(tmp2, 0x00000007); From 7a341735fe2e125f2aa4fdc191d37f4225150f71 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Thu, 8 Sep 2016 23:38:56 -0700 Subject: [PATCH 18/81] 8164913: JVMTI.agent_load dcmd should show useful error message Show useful error message Reviewed-by: dholmes, dsamersoff, sspitsyn --- hotspot/src/share/vm/prims/jvmtiExport.cpp | 2 -- .../src/share/vm/services/diagnosticCommand.cpp | 15 ++++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index a388f29dc9e..53f80345c74 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -2407,9 +2407,7 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam, delete agent_lib; } - // Agent_OnAttach executed so completion status is JNI_OK st->print_cr("%d", result); - result = JNI_OK; } } return result; diff --git a/hotspot/src/share/vm/services/diagnosticCommand.cpp b/hotspot/src/share/vm/services/diagnosticCommand.cpp index c90bf08e39e..d5338b2609c 100644 --- a/hotspot/src/share/vm/services/diagnosticCommand.cpp +++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp @@ -277,11 +277,12 @@ void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) { char *suffix = strrchr(_libpath.value(), '.'); bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0); + jint result = JNI_ERR; if (is_java_agent) { if (_option.value() == NULL) { - JvmtiExport::load_agent_library("instrument", "false", - _libpath.value(), output()); + result = JvmtiExport::load_agent_library("instrument", "false", + _libpath.value(), output()); } else { size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2; if (opt_len > 4096) { @@ -298,14 +299,18 @@ void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) { } jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value()); - JvmtiExport::load_agent_library("instrument", "false", opt, output()); + result = JvmtiExport::load_agent_library("instrument", "false", + opt, output()); os::free(opt); } } else { - JvmtiExport::load_agent_library(_libpath.value(), "true", - _option.value(), output()); + result = JvmtiExport::load_agent_library(_libpath.value(), "true", + _option.value(), output()); } + + output()->print_cr("JVMTI agent attach %s.", + (result == JNI_OK) ? "succeeded" : "failed"); } int JVMTIAgentLoadDCmd::num_arguments() { From d22c8d1b01fd8597026be826b2f534bc3b9a9be3 Mon Sep 17 00:00:00 2001 From: Alexander Vorobyev Date: Fri, 9 Sep 2016 19:30:08 +0300 Subject: [PATCH 19/81] 8146128: compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig timeouts Test settings were changes in order to avoid timeouts Reviewed-by: kvn --- hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java | 4 ++-- .../compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java index 0aa9dc3bb35..476b52d09d0 100644 --- a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java +++ b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java @@ -48,8 +48,8 @@ public abstract class AESIntrinsicsBase extends CommandLineOptionTest { = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintIntrinsics"}; public static final String[] TEST_AES_CMD = {"-XX:+IgnoreUnrecognizedVMOptions", "-XX:+PrintFlagsFinal", - "-Xbatch", "-DcheckOutput=true", "-Dmode=CBC", - TestAESMain.class.getName()}; + "-Xbatch", "-XX:CompileThresholdScaling=0.01", "-DcheckOutput=true", "-Dmode=CBC", + TestAESMain.class.getName(), "100", "1000"}; protected AESIntrinsicsBase(BooleanSupplier predicate) { super(predicate); diff --git a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java index 5f3b533c39d..a649e045bed 100644 --- a/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java +++ b/hotspot/test/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java @@ -27,11 +27,11 @@ * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management - * @ignore 8146128 * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions + * @run main/othervm/timeout=600 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions * -XX:+WhiteBoxAPI -Xbatch * compiler.cpuflags.TestAESIntrinsicsOnSupportedConfig */ From 2bb3bc6449b0bf06324d52d2da89c5ce98eebab2 Mon Sep 17 00:00:00 2001 From: Ron Durbin Date: Fri, 9 Sep 2016 11:14:57 -0700 Subject: [PATCH 20/81] 8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option Split the single thread_min_stack_allowed into three distinct values (java_thread_min_stack_allowed, compiler_thread_min_stack_allowed and vm_internal_thread_min_stack_allowed) on non-Windows platforms. Reviewed-by: dcubed, gthornbr, dholmes, coleenp, fparain, aph --- hotspot/src/cpu/sparc/vm/globals_sparc.hpp | 2 + hotspot/src/os/aix/vm/os_aix.cpp | 55 +---- hotspot/src/os/aix/vm/os_aix.hpp | 10 +- hotspot/src/os/bsd/vm/os_bsd.cpp | 55 +---- hotspot/src/os/bsd/vm/os_bsd.hpp | 10 +- hotspot/src/os/linux/vm/os_linux.cpp | 59 +----- hotspot/src/os/linux/vm/os_linux.hpp | 8 +- hotspot/src/os/posix/vm/os_posix.cpp | 117 +++++++++++ hotspot/src/os/posix/vm/os_posix.hpp | 13 +- hotspot/src/os/solaris/vm/os_solaris.cpp | 83 ++------ hotspot/src/os/solaris/vm/os_solaris.hpp | 4 - hotspot/src/os/windows/vm/os_windows.cpp | 2 +- .../src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp | 6 +- hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp | 14 +- .../src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp | 5 +- hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp | 15 +- .../src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp | 12 +- .../vm/globals_linux_aarch64.hpp | 4 +- .../linux_aarch64/vm/os_linux_aarch64.cpp | 6 +- .../os_cpu/linux_ppc/vm/globals_linux_ppc.hpp | 6 +- .../src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 10 +- .../linux_sparc/vm/globals_linux_sparc.hpp | 3 +- .../os_cpu/linux_sparc/vm/os_linux_sparc.cpp | 6 +- .../os_cpu/linux_x86/vm/globals_linux_x86.hpp | 6 +- .../src/os_cpu/linux_x86/vm/os_linux_x86.cpp | 10 +- .../os_cpu/linux_zero/vm/os_linux_zero.cpp | 6 +- .../vm/globals_solaris_sparc.hpp | 3 +- .../solaris_sparc/vm/os_solaris_sparc.cpp | 8 +- .../solaris_x86/vm/globals_solaris_x86.hpp | 5 +- .../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 10 +- hotspot/src/share/vm/runtime/os.hpp | 2 +- hotspot/src/share/vm/utilities/exceptions.cpp | 4 +- .../TestOptionsWithRanges.java | 16 +- .../runtime/Thread/TooSmallStackSize.java | 198 ++++++++++++++++++ 34 files changed, 438 insertions(+), 335 deletions(-) create mode 100644 hotspot/test/runtime/Thread/TooSmallStackSize.java diff --git a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp index d1ae77b5df0..fe26b39d736 100644 --- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp @@ -57,10 +57,12 @@ define_pd_global(intx, InlineSmallCode, 1500); #ifdef _LP64 // Stack slots are 2X larger in LP64 than in the 32 bit VM. +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); define_pd_global(intx, VMThreadStackSize, 1024); #define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+2)) #else +define_pd_global(intx, CompilerThreadStackSize, 512); define_pd_global(intx, ThreadStackSize, 512); define_pd_global(intx, VMThreadStackSize, 512); #define DEFAULT_STACK_SHADOW_PAGES (6 DEBUG_ONLY(+2)) diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index 6c668c16870..47788262bdc 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -847,7 +847,8 @@ static void *thread_native_entry(Thread *thread) { return 0; } -bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { +bool os::create_thread(Thread* thread, ThreadType thr_type, + size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); @@ -880,37 +881,12 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???"); // calculate stack size if it's not specified by caller - if (stack_size == 0) { - stack_size = os::Aix::default_stack_size(thr_type); - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize whose default value can be changed with the flag -Xss. - assert(JavaThread::stack_size_at_create() > 0, "this should be set"); - stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - - stack_size = MAX2(stack_size, os::Aix::min_stack_allowed); + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); pthread_t tid; int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); - char buf[64]; if (ret == 0) { log_info(os, thread)("Thread started (pthread id: " UINTX_FORMAT ", attributes: %s). ", @@ -3593,32 +3569,11 @@ jint os::init_2(void) { Aix::signal_sets_init(); Aix::install_signal_handlers(); - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Aix::min_stack_allowed = MAX2(os::Aix::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Aix::min_stack_allowed = align_size_up(os::Aix::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Aix::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " - "Specify at least %dk", - os::Aix::min_stack_allowed / K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - // Note that this can be 0, if no default stacksize was set. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, vm_page_size())); - if (UseNUMA) { UseNUMA = false; warning("NUMA optimizations are not available on this OS."); diff --git a/hotspot/src/os/aix/vm/os_aix.hpp b/hotspot/src/os/aix/vm/os_aix.hpp index c17cd686c1c..83858048cbb 100644 --- a/hotspot/src/os/aix/vm/os_aix.hpp +++ b/hotspot/src/os/aix/vm/os_aix.hpp @@ -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. * Copyright (c) 2013, 2016 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -140,14 +140,6 @@ class Aix { // libpthread version string static void libpthread_init(); - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - static size_t min_stack_allowed; - - // Return default stack size or guard size for the specified thread type - static size_t default_stack_size(os::ThreadType thr_type); - static size_t default_guard_size(os::ThreadType thr_type); - // Function returns true if we run on OS/400 (pase), false if we run // on AIX. static bool on_pase() { diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 39cfd207cc6..926144074f9 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -734,7 +734,8 @@ static void *thread_native_entry(Thread *thread) { return 0; } -bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { +bool os::create_thread(Thread* thread, ThreadType thr_type, + size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); // Allocate the OSThread object @@ -757,32 +758,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // calculate stack size if it's not specified by caller - if (stack_size == 0) { - stack_size = os::Bsd::default_stack_size(thr_type); - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize which default value can be - // changed with the flag -Xss - assert(JavaThread::stack_size_at_create() > 0, "this should be set"); - stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - - stack_size = MAX2(stack_size, os::Bsd::min_stack_allowed); + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); ThreadState state; @@ -3502,32 +3478,11 @@ jint os::init_2(void) { Bsd::signal_sets_init(); Bsd::install_signal_handlers(); - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Bsd::min_stack_allowed = MAX2(os::Bsd::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Bsd::min_stack_allowed = align_size_up(os::Bsd::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Bsd::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " - "Specify at least %dk", - os::Bsd::min_stack_allowed/ K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, - vm_page_size())); - if (MaxFDLimit) { // set the number of file descriptors to max. print out error // if getrlimit/setrlimit fails but continue regardless. diff --git a/hotspot/src/os/bsd/vm/os_bsd.hpp b/hotspot/src/os/bsd/vm/os_bsd.hpp index 52b88e6d865..5bc6092214c 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.hpp +++ b/hotspot/src/os/bsd/vm/os_bsd.hpp @@ -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 @@ -120,14 +120,6 @@ class Bsd { static struct sigaction *get_chained_signal_action(int sig); static bool chained_handler(int sig, siginfo_t* siginfo, void* context); - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - static size_t min_stack_allowed; - - // Return default stack size or guard size for the specified thread type - static size_t default_stack_size(os::ThreadType thr_type); - static size_t default_guard_size(os::ThreadType thr_type); - // Real-time clock functions static void clock_init(void); diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 5aafe4b8474..e03ac29102e 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -701,7 +701,7 @@ static void *thread_native_entry(Thread *thread) { } bool os::create_thread(Thread* thread, ThreadType thr_type, - size_t stack_size) { + size_t req_stack_size) { assert(thread->osthread() == NULL, "caller responsible"); // Allocate the OSThread object @@ -723,34 +723,8 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - // stack size // calculate stack size if it's not specified by caller - if (stack_size == 0) { - stack_size = os::Linux::default_stack_size(thr_type); - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize which default value can be - // changed with the flag -Xss - assert(JavaThread::stack_size_at_create() > 0, "this should be set"); - stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - - stack_size = MAX2(stack_size, os::Linux::min_stack_allowed); + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); pthread_attr_setstacksize(&attr, stack_size); // glibc guard page @@ -956,10 +930,9 @@ static bool find_vma(address addr, address* vma_low, address* vma_high) { // bogus value for initial thread. void os::Linux::capture_initial_stack(size_t max_size) { // stack size is the easy part, get it from RLIMIT_STACK - size_t stack_size; struct rlimit rlim; getrlimit(RLIMIT_STACK, &rlim); - stack_size = rlim.rlim_cur; + size_t stack_size = rlim.rlim_cur; // 6308388: a bug in ld.so will relocate its own .data section to the // lower end of primordial stack; reduce ulimit -s value a little bit @@ -4793,32 +4766,10 @@ jint os::init_2(void) { Linux::signal_sets_init(); Linux::install_signal_handlers(); - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Linux::min_stack_allowed = align_size_up(os::Linux::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Linux::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " - "Specify at least " SIZE_FORMAT "k", - os::Linux::min_stack_allowed/ K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, - vm_page_size())); - Linux::capture_initial_stack(JavaThread::stack_size_at_create()); #if defined(IA32) diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp index 2b6ae922e3f..3cada1b07be 100644 --- a/hotspot/src/os/linux/vm/os_linux.hpp +++ b/hotspot/src/os/linux/vm/os_linux.hpp @@ -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 @@ -170,12 +170,8 @@ class Linux { static void libpthread_init(); static bool libnuma_init(); static void* libnuma_dlsym(void* handle, const char* name); - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - static size_t min_stack_allowed; - // Return default stack size or guard size for the specified thread type - static size_t default_stack_size(os::ThreadType thr_type); + // Return default guard size for the specified thread type static size_t default_guard_size(os::ThreadType thr_type); static void capture_initial_stack(size_t max_size); diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index 2b7407dc985..8ff039e8644 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -1099,6 +1099,123 @@ char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_a return buf; } +// Check minimum allowable stack sizes for thread creation and to initialize +// the java system classes, including StackOverflowError - depends on page +// size. Add two 4K pages for compiler2 recursion in main thread. +// Add in 4*BytesPerWord 4K pages to account for VM stack during +// class initialization depending on 32 or 64 bit VM. +jint os::Posix::set_minimum_stack_sizes() { + _java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed, + JavaThread::stack_guard_zone_size() + + JavaThread::stack_shadow_zone_size() + + (4 * BytesPerWord COMPILER2_PRESENT(+ 2)) * 4 * K); + + _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size()); + + size_t stack_size_in_bytes = ThreadStackSize * K; + if (stack_size_in_bytes != 0 && + stack_size_in_bytes < _java_thread_min_stack_allowed) { + // The '-Xss' and '-XX:ThreadStackSize=N' options both set + // ThreadStackSize so we go with "Java thread stack size" instead + // of "ThreadStackSize" to be more friendly. + tty->print_cr("\nThe Java thread stack size specified is too small. " + "Specify at least " SIZE_FORMAT "k", + _java_thread_min_stack_allowed / K); + return JNI_ERR; + } + +#ifdef SOLARIS + // For 64kbps there will be a 64kb page size, which makes + // the usable default stack size quite a bit less. Increase the + // stack for 64kb (or any > than 8kb) pages, this increases + // virtual memory fragmentation (since we're not creating the + // stack on a power of 2 boundary. The real fix for this + // should be to fix the guard page mechanism. + + if (vm_page_size() > 8*K) { + stack_size_in_bytes = (stack_size_in_bytes != 0) + ? stack_size_in_bytes + + JavaThread::stack_red_zone_size() + + JavaThread::stack_yellow_zone_size() + : 0; + ThreadStackSize = stack_size_in_bytes/K; + } +#endif // SOLARIS + + // Make the stack size a multiple of the page size so that + // the yellow/red zones can be guarded. + JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes, + vm_page_size())); + + _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size()); + + stack_size_in_bytes = CompilerThreadStackSize * K; + if (stack_size_in_bytes != 0 && + stack_size_in_bytes < _compiler_thread_min_stack_allowed) { + tty->print_cr("\nThe CompilerThreadStackSize specified is too small. " + "Specify at least " SIZE_FORMAT "k", + _compiler_thread_min_stack_allowed / K); + return JNI_ERR; + } + + _vm_internal_thread_min_stack_allowed = align_size_up(_vm_internal_thread_min_stack_allowed, vm_page_size()); + + stack_size_in_bytes = VMThreadStackSize * K; + if (stack_size_in_bytes != 0 && + stack_size_in_bytes < _vm_internal_thread_min_stack_allowed) { + tty->print_cr("\nThe VMThreadStackSize specified is too small. " + "Specify at least " SIZE_FORMAT "k", + _vm_internal_thread_min_stack_allowed / K); + return JNI_ERR; + } + return JNI_OK; +} + +// Called when creating the thread. The minimum stack sizes have already been calculated +size_t os::Posix::get_initial_stack_size(ThreadType thr_type, size_t req_stack_size) { + size_t stack_size; + if (req_stack_size == 0) { + stack_size = default_stack_size(thr_type); + } else { + stack_size = req_stack_size; + } + + switch (thr_type) { + case os::java_thread: + // Java threads use ThreadStackSize which default value can be + // changed with the flag -Xss + if (req_stack_size == 0 && JavaThread::stack_size_at_create() > 0) { + // no requested size and we have a more specific default value + stack_size = JavaThread::stack_size_at_create(); + } + stack_size = MAX2(stack_size, + _java_thread_min_stack_allowed); + break; + case os::compiler_thread: + if (req_stack_size == 0 && CompilerThreadStackSize > 0) { + // no requested size and we have a more specific default value + stack_size = (size_t)(CompilerThreadStackSize * K); + } + stack_size = MAX2(stack_size, + _compiler_thread_min_stack_allowed); + break; + case os::vm_thread: + case os::pgc_thread: + case os::cgc_thread: + case os::watcher_thread: + default: // presume the unknown thr_type is a VM internal + if (req_stack_size == 0 && VMThreadStackSize > 0) { + // no requested size and we have a more specific default value + stack_size = (size_t)(VMThreadStackSize * K); + } + + stack_size = MAX2(stack_size, + _vm_internal_thread_min_stack_allowed); + break; + } + + return stack_size; +} os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() { assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread"); diff --git a/hotspot/src/os/posix/vm/os_posix.hpp b/hotspot/src/os/posix/vm/os_posix.hpp index 0196e989456..8120bde9e02 100644 --- a/hotspot/src/os/posix/vm/os_posix.hpp +++ b/hotspot/src/os/posix/vm/os_posix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, 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 @@ -42,7 +42,18 @@ protected: static void print_libversion_info(outputStream* st); static void print_load_average(outputStream* st); + // Minimum stack size a thread can be created with (allowing + // the VM to completely create the thread and enter user code) + static size_t _compiler_thread_min_stack_allowed; + static size_t _java_thread_min_stack_allowed; + static size_t _vm_internal_thread_min_stack_allowed; + public: + // Return default stack size for the specified thread type + static size_t default_stack_size(os::ThreadType thr_type); + // Check and sets minimum stack sizes + static jint set_minimum_stack_sizes(); + static size_t get_initial_stack_size(ThreadType thr_type, size_t req_stack_size); // Returns true if signal is valid. static bool is_valid_signal(int sig); diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 825a679dc19..4c4268486b1 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -917,8 +917,15 @@ static char* describe_thr_create_attributes(char* buf, size_t buflen, return buf; } +// return default stack size for thr_type +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { + // default stack size when not specified by caller is 1M (2M for LP64) + size_t s = (BytesPerWord >> 2) * K * K; + return s; +} + bool os::create_thread(Thread* thread, ThreadType thr_type, - size_t stack_size) { + size_t req_stack_size) { // Allocate the OSThread object OSThread* osthread = new OSThread(NULL, NULL); if (osthread == NULL) { @@ -953,31 +960,8 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, tty->print_cr("In create_thread, creating a %s thread\n", thrtyp); } - // Calculate stack size if it's not specified by caller. - if (stack_size == 0) { - // The default stack size 1M (2M for LP64). - stack_size = (BytesPerWord >> 2) * K * K; - - switch (thr_type) { - case os::java_thread: - // Java threads use ThreadStackSize which default value can be changed with the flag -Xss - if (JavaThread::stack_size_at_create() > 0) stack_size = JavaThread::stack_size_at_create(); - break; - case os::compiler_thread: - if (CompilerThreadStackSize > 0) { - stack_size = (size_t)(CompilerThreadStackSize * K); - break; - } // else fall through: - // use VMThreadStackSize if CompilerThreadStackSize is not defined - case os::vm_thread: - case os::pgc_thread: - case os::cgc_thread: - case os::watcher_thread: - if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K); - break; - } - } - stack_size = MAX2(stack_size, os::Solaris::min_stack_allowed); + // calculate stack size if it's not specified by caller + size_t stack_size = os::Posix::get_initial_stack_size(thr_type, req_stack_size); // Initial state is ALLOCATED but not INITIALIZED osthread->set_state(ALLOCATED); @@ -4400,7 +4384,12 @@ void os::init(void) { // Constant minimum stack size allowed. It must be at least // the minimum of what the OS supports (thr_min_stack()), and // enough to allow the thread to get to user bytecode execution. - Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed); + Posix::_compiler_thread_min_stack_allowed = MAX2(thr_min_stack(), + Posix::_compiler_thread_min_stack_allowed); + Posix::_java_thread_min_stack_allowed = MAX2(thr_min_stack(), + Posix::_java_thread_min_stack_allowed); + Posix::_vm_internal_thread_min_stack_allowed = MAX2(thr_min_stack(), + Posix::_vm_internal_thread_min_stack_allowed); // dynamic lookup of functions that may not be available in our lowest // supported Solaris release @@ -4445,47 +4434,11 @@ jint os::init_2(void) { log_info(os)("Memory Serialize Page address: " INTPTR_FORMAT, p2i(mem_serialize_page)); } - // Check minimum allowable stack size for thread creation and to initialize - // the java system classes, including StackOverflowError - depends on page - // size. Add two 4K pages for compiler2 recursion in main thread. - // Add in 4*BytesPerWord 4K pages to account for VM stack during - // class initialization depending on 32 or 64 bit VM. - os::Solaris::min_stack_allowed = MAX2(os::Solaris::min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4*BytesPerWord COMPILER2_PRESENT(+2)) * 4 * K); - - os::Solaris::min_stack_allowed = align_size_up(os::Solaris::min_stack_allowed, os::vm_page_size()); - - size_t threadStackSizeInBytes = ThreadStackSize * K; - if (threadStackSizeInBytes != 0 && - threadStackSizeInBytes < os::Solaris::min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, Specify at least %dk", - os::Solaris::min_stack_allowed/K); + // Check and sets minimum stack sizes against command line options + if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - // For 64kbps there will be a 64kb page size, which makes - // the usable default stack size quite a bit less. Increase the - // stack for 64kb (or any > than 8kb) pages, this increases - // virtual memory fragmentation (since we're not creating the - // stack on a power of 2 boundary. The real fix for this - // should be to fix the guard page mechanism. - - if (vm_page_size() > 8*K) { - threadStackSizeInBytes = (threadStackSizeInBytes != 0) - ? threadStackSizeInBytes + - JavaThread::stack_red_zone_size() + - JavaThread::stack_yellow_zone_size() - : 0; - ThreadStackSize = threadStackSizeInBytes/K; - } - - // Make the stack size a multiple of the page size so that - // the yellow/red zones can be guarded. - JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, - vm_page_size())); - Solaris::libthread_init(); if (UseNUMA) { diff --git a/hotspot/src/os/solaris/vm/os_solaris.hpp b/hotspot/src/os/solaris/vm/os_solaris.hpp index 12f72247168..150abcb6486 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.hpp +++ b/hotspot/src/os/solaris/vm/os_solaris.hpp @@ -292,10 +292,6 @@ class Solaris { static jint _os_thread_limit; static volatile jint _os_thread_count; - // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) - - static size_t min_stack_allowed; // Stack overflow handling diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index d8034537e2d..3b075455d92 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -4215,7 +4215,7 @@ jint os::init_2(void) { min_stack_allowed = align_size_up(min_stack_allowed, os::vm_page_size()); if (actual_reserve_size < min_stack_allowed) { - tty->print_cr("\nThe stack size specified is too small, " + tty->print_cr("\nThe Java thread stack size specified is too small. " "Specify at least %dk", min_stack_allowed / K); return JNI_ERR; diff --git a/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp b/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp index c730ed269f8..50096a18c53 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp @@ -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. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,10 +33,6 @@ define_pd_global(bool, DontYieldALot, false); define_pd_global(intx, ThreadStackSize, 2048); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 2048); -// if we set CompilerThreadStackSize to a value different than 0, it will -// be used in os::create_thread(). Otherwise, due the strange logic in os::create_thread(), -// the stack size for compiler threads will default to VMThreadStackSize, although it -// is defined to 4M in os::Aix::default_stack_size()! define_pd_global(intx, CompilerThreadStackSize, 4096); // Allow extra space in DEBUG builds for asserts. diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index e5c986743ff..7a40c0df126 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -533,23 +533,17 @@ void os::Aix::init_thread_fpu_state(void) { //////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Aix::min_stack_allowed = 128*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; // return default stack size for thr_type -size_t os::Aix::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) - // Notice that the setting for compiler threads here have no impact - // because of the strange 'fallback logic' in os::create_thread(). - // Better set CompilerThreadStackSize in globals_.hpp if you want to - // specify a different stack size for compiler threads! size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); return s; } -size_t os::Aix::default_guard_size(os::ThreadType thr_type) { - return 2 * page_size(); -} - ///////////////////////////////////////////////////////////////////////////// // helper functions for fatal error handler diff --git a/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp index 3711f37f6d0..b17ee1c2f86 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp @@ -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 @@ -31,9 +31,11 @@ // define_pd_global(bool, DontYieldALot, false); #ifdef AMD64 +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 1024); #else +define_pd_global(intx, CompilerThreadStackSize, 512); // ThreadStackSize 320 allows a couple of test cases to run while // keeping the number of threads that can be created high. System // default ThreadStackSize appears to be 512 which is too big. @@ -41,7 +43,6 @@ define_pd_global(intx, ThreadStackSize, 320); define_pd_global(intx, VMThreadStackSize, 512); #endif // AMD64 -define_pd_global(intx, CompilerThreadStackSize, 0); define_pd_global(size_t, JVMInvokeMethodSlack, 8192); diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index 0bdbc7c3aaa..6e3de2d6f9e 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -838,9 +838,13 @@ bool os::is_allocatable(size_t bytes) { // thread stack #ifdef AMD64 -size_t os::Bsd::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #else -size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; #ifdef __GNUC__ #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) @@ -849,7 +853,7 @@ size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; #endif // AMD64 // return default stack size for thr_type -size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) #ifdef AMD64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); @@ -859,11 +863,6 @@ size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { return s; } -size_t os::Bsd::default_guard_size(os::ThreadType thr_type) { - // Creating guard page is very expensive. Java thread has HotSpot - // guard page, only enable glibc guard page for non-Java threads. - return (thr_type == java_thread ? 0 : page_size()); -} // Java thread: // diff --git a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp index f7ff3e51b96..9a6b38bc0fc 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp @@ -282,9 +282,11 @@ bool os::is_allocatable(size_t bytes) { /////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Bsd::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; -size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { #ifdef _LP64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); #else @@ -293,12 +295,6 @@ size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { return s; } -size_t os::Bsd::default_guard_size(os::ThreadType thr_type) { - // Only enable glibc guard pages for non-Java threads - // (Java threads have HotSpot guard pages) - return (thr_type == java_thread ? 0 : page_size()); -} - static void current_stack_region(address *bottom, size_t *size) { address stack_bottom; address stack_top; diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp b/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp index 420453ba864..360be743ddc 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/globals_linux_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,7 +33,7 @@ define_pd_global(bool, DontYieldALot, false); define_pd_global(intx, ThreadStackSize, 2048); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 2048); -define_pd_global(intx, CompilerThreadStackSize, 0); +define_pd_global(intx, CompilerThreadStackSize, 2048); define_pd_global(uintx,JVMInvokeMethodSlack, 8192); diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp index b4bc43a81c6..21d185d5d70 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp @@ -473,10 +473,12 @@ bool os::is_allocatable(size_t bytes) { //////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); return s; diff --git a/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp b/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp index 1d995a9ee4c..3787aeb1168 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp @@ -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. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -33,10 +33,6 @@ define_pd_global(bool, DontYieldALot, false); define_pd_global(intx, ThreadStackSize, 2048); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 2048); -// if we set CompilerThreadStackSize to a value different than 0, it will -// be used in os::create_thread(). Otherwise, due the strange logic in os::create_thread(), -// the stack size for compiler threads will default to VMThreadStackSize, although it -// is defined to 4M in os::Linux::default_stack_size()! define_pd_global(intx, CompilerThreadStackSize, 4096); // Allow extra space in DEBUG builds for asserts. diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 554dfa42286..3dce4275405 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -533,15 +533,13 @@ void os::Linux::set_fpu_control_word(int fpu_control) { //////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 128*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) - // Notice that the setting for compiler threads here have no impact - // because of the strange 'fallback logic' in os::create_thread(). - // Better set CompilerThreadStackSize in globals_.hpp if you want to - // specify a different stack size for compiler threads! size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K); return s; } diff --git a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp index bc3c7f0ec7d..df6cad419fb 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp @@ -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 @@ -31,7 +31,6 @@ // define_pd_global(size_t, JVMInvokeMethodSlack, 12288); -define_pd_global(intx, CompilerThreadStackSize, 0); // Used on 64 bit platforms for UseCompressedOops base address define_pd_global(size_t, HeapBaseMinAddress, CONST64(4)*G); diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index 7cf5edb70b0..a5d435cae75 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -726,10 +726,12 @@ bool os::is_allocatable(size_t bytes) { /////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 128 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); return s; diff --git a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp index b123d90c994..4d5069e5a8c 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp +++ b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp @@ -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 @@ -30,9 +30,11 @@ define_pd_global(bool, DontYieldALot, false); #ifdef AMD64 +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 1024); #else +define_pd_global(intx, CompilerThreadStackSize, 512); // ThreadStackSize 320 allows a couple of test cases to run while // keeping the number of threads that can be created high. System // default ThreadStackSize appears to be 512 which is too big. @@ -40,8 +42,6 @@ define_pd_global(intx, ThreadStackSize, 320); define_pd_global(intx, VMThreadStackSize, 512); #endif // AMD64 -define_pd_global(intx, CompilerThreadStackSize, 0); - define_pd_global(size_t, JVMInvokeMethodSlack, 8192); // Used on 64 bit platforms for UseCompressedOops base address diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index 6eeb1280c82..e7566c7d4af 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -676,13 +676,17 @@ bool os::is_allocatable(size_t bytes) { // thread stack #ifdef AMD64 -size_t os::Linux::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #else -size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; #endif // AMD64 // return default stack size for thr_type -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { // default stack size (compiler thread needs larger stack) #ifdef AMD64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); diff --git a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp index b43499ec772..b5d7401282c 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp +++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp @@ -307,9 +307,11 @@ bool os::is_allocatable(size_t bytes) { /////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Linux::min_stack_allowed = 64 * K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; -size_t os::Linux::default_stack_size(os::ThreadType thr_type) { +size_t os::Posix::default_stack_size(os::ThreadType thr_type) { #ifdef _LP64 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); #else diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp index fa63ce0fc12..049d214a677 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp @@ -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 @@ -31,7 +31,6 @@ // define_pd_global(size_t, JVMInvokeMethodSlack, 12288); -define_pd_global(intx, CompilerThreadStackSize, 0); // Used on 64 bit platforms for UseCompressedOops base address #ifdef _LP64 diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp index cf782a2f75f..864080d2073 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @@ -84,9 +84,13 @@ // Minimum stack size for the VM. It's easier to document a constant // but it's different for x86 and sparc because the page sizes are different. #ifdef _LP64 -size_t os::Solaris::min_stack_allowed = 128*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; #else -size_t os::Solaris::min_stack_allowed = 96*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 96 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 96 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 96 * K; #endif int os::Solaris::max_register_window_saves_before_flushing() { diff --git a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp index 0c3016edffe..632dc1e0c85 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp @@ -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 @@ -30,10 +30,12 @@ define_pd_global(bool, DontYieldALot, true); // Determined in the design center #ifdef AMD64 +define_pd_global(intx, CompilerThreadStackSize, 1024); define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default define_pd_global(intx, VMThreadStackSize, 1024); define_pd_global(size_t, JVMInvokeMethodSlack, 8*K); #else +define_pd_global(intx, CompilerThreadStackSize, 512); // ThreadStackSize 320 allows a couple of test cases to run while // keeping the number of threads that can be created high. define_pd_global(intx, ThreadStackSize, 320); @@ -41,7 +43,6 @@ define_pd_global(intx, VMThreadStackSize, 512); define_pd_global(size_t, JVMInvokeMethodSlack, 10*K); #endif // AMD64 -define_pd_global(intx, CompilerThreadStackSize, 0); // Used on 64 bit platforms for UseCompressedOops base address define_pd_global(size_t, HeapBaseMinAddress, 2*G); diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp index ef64ff751d0..bc79053f81d 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp @@ -86,15 +86,19 @@ #define MAX_PATH (2 * K) -// Minimum stack size for the VM. It's easier to document a constant value +// Minimum stack sizes for the VM. It's easier to document a constant value // but it's different for x86 and sparc because the page sizes are different. #ifdef AMD64 -size_t os::Solaris::min_stack_allowed = 224*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 394 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 224 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 224 * K; #define REG_SP REG_RSP #define REG_PC REG_RIP #define REG_FP REG_RBP #else -size_t os::Solaris::min_stack_allowed = 64*K; +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #define REG_SP UESP #define REG_PC EIP #define REG_FP EBP diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 431e7b2a985..4f714e3cec2 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -443,7 +443,7 @@ class os: AllStatic { static bool create_thread(Thread* thread, ThreadType thr_type, - size_t stack_size = 0); + size_t req_stack_size = 0); static bool create_main_thread(JavaThread* thread); static bool create_attached_thread(JavaThread* thread); static void pd_start_thread(Thread* thread); diff --git a/hotspot/src/share/vm/utilities/exceptions.cpp b/hotspot/src/share/vm/utilities/exceptions.cpp index fa4981986ef..2bb3d77e6a5 100644 --- a/hotspot/src/share/vm/utilities/exceptions.cpp +++ b/hotspot/src/share/vm/utilities/exceptions.cpp @@ -80,7 +80,7 @@ bool Exceptions::special_exception(Thread* thread, const char* file, int line, H if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) { InstanceKlass* ik = InstanceKlass::cast(h_exception->klass()); assert(ik->is_initialized(), - "need to increase min_stack_allowed calculation"); + "need to increase java_thread_min_stack_allowed calculation"); } #endif // ASSERT @@ -227,7 +227,7 @@ void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file Klass* k = SystemDictionary::StackOverflowError_klass(); oop e = InstanceKlass::cast(k)->allocate_instance(CHECK); exception = Handle(THREAD, e); // fill_in_stack trace does gc - assert(InstanceKlass::cast(k)->is_initialized(), "need to increase min_stack_allowed calculation"); + assert(InstanceKlass::cast(k)->is_initialized(), "need to increase java_thread_min_stack_allowed calculation"); if (StackTraceInThrowable) { java_lang_Throwable::fill_in_stack_trace(exception, method()); } diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index 303912d4e20..bd188d6cec8 100644 --- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java +++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java @@ -88,20 +88,6 @@ public class TestOptionsWithRanges { */ excludeTestMaxRange("CICompilerCount"); - /* - * JDK-8136766 - * Temporarily remove ThreadStackSize from testing because Windows can set it to 0 - * (for default OS size) but other platforms insist it must be greater than 0 - */ - excludeTestRange("ThreadStackSize"); - - /* - * Remove the flag controlling the size of the stack because the - * flag has direct influence on the physical memory usage of - * the VM. - */ - allOptionsAsMap.remove("CompilerThreadStackSize"); - /* * Exclude MallocMaxTestWords as it is expected to exit VM at small values (>=0) */ @@ -124,6 +110,8 @@ public class TestOptionsWithRanges { excludeTestMaxRange("OldSize"); excludeTestMaxRange("ParallelGCThreads"); + excludeTestMaxRange("CompilerThreadStackSize"); + excludeTestMaxRange("ThreadStackSize"); excludeTestMaxRange("VMThreadStackSize"); /* diff --git a/hotspot/test/runtime/Thread/TooSmallStackSize.java b/hotspot/test/runtime/Thread/TooSmallStackSize.java new file mode 100644 index 00000000000..383390503eb --- /dev/null +++ b/hotspot/test/runtime/Thread/TooSmallStackSize.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8140520 + * @summary Setting small CompilerThreadStackSize, ThreadStackSize, and + * VMThreadStackSize values should result in an error message that shows + * the minimum stack size value for each thread type. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run main TooSmallStackSize + */ + +/* + * The primary purpose of this test is to make sure we can run with a + * stack smaller than the minimum without crashing. Also this test will + * determine the minimum allowed stack size for the platform (as + * provided by the JVM error message when a very small stack is used), + * and then verify that the JVM can be launched with that stack size + * without a crash or any error messages. + * + * Note: The '-Xss' and '-XX:ThreadStackSize=' options + * both control Java thread stack size. This repo's version of the test + * exercises the '-XX:ThreadStackSize' VM option. The jdk repo's version + * of the test exercises the '-Xss' option. + */ + +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class TooSmallStackSize { + /* for debugging. Normally false. */ + static final boolean verbose = false; + static final String CompilerThreadStackSizeString = "CompilerThreadStackSize"; + static final String ThreadStackSizeString = "Java thread stack size"; + static final String VMThreadStackSizeString = "VMThreadStackSize"; + + /* + * Returns the minimum stack size this platform will allowed based on the + * contents of the error message the JVM outputs when too small of a + * stack size was used. + * + * The testOutput argument must contain the result of having already run + * the JVM with too small of a stack size. + */ + static String getMinStackAllowed(String testOutput) { + /* + * The JVM output will contain in one of the lines: + * "The CompilerThreadStackSize specified is too small. Specify at least 100k" + * "The Java thread stack size specified is too small. Specify at least 100k" + * "The VMThreadStackSize specified is too small. Specify at least 100k" + * Although the actual size will vary. We need to extract this size + * string from the output and return it. + */ + String matchStr = "Specify at least "; + int match_idx = testOutput.indexOf(matchStr); + if (match_idx >= 0) { + int size_start_idx = match_idx + matchStr.length(); + int k_start_idx = testOutput.indexOf("k", size_start_idx); + // don't include the 'k'; the caller will have to + // add it back as needed. + return testOutput.substring(size_start_idx, k_start_idx); + } + + System.out.println("Expect='" + matchStr + "'"); + System.out.println("Actual: " + testOutput); + System.out.println("FAILED: Could not get the stack size from the output"); + throw new RuntimeException("test fails"); + } + + /* + * Run the JVM with the specified stack size. + * + * Returns the minimum allowed stack size gleaned from the error message, + * if there is an error message. Otherwise returns the stack size passed in. + */ + static String checkStack(String stackOption, String optionMesg, String stackSize) throws Exception { + String min_stack_allowed; + + System.out.println("*** Testing " + stackOption + stackSize); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + stackOption + stackSize, + // Uncomment the following to get log output + // that shows actual thread creation sizes. + // "-Xlog:os+thread", + "-version"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + if (verbose) { + System.out.println("stdout: " + output.getStdout()); + } + + if (output.getExitValue() == 0) { + // checkMinStackAllowed() is called with stackSize values + // that should be the minimum that works. This method, + // checkStack(), is called with stackSize values that + // should be too small and result in error messages. + // However, some platforms fix up a stackSize value that is + // too small into something that works so we have to allow + // for checkStack() calls that work. + System.out.println("PASSED: got exit_code == 0 with " + stackOption + stackSize); + min_stack_allowed = stackSize; + } else { + String expect = "The " + optionMesg + " specified is too small"; + if (verbose) { + System.out.println("Expect='" + expect + "'"); + } + output.shouldContain(expect); + min_stack_allowed = getMinStackAllowed(output.getStdout()); + + System.out.println("PASSED: got expected error message with " + stackOption + stackSize); + } + + return min_stack_allowed; + } + + /* + * Run the JVM with the minimum allowed stack size. This should always succeed. + */ + static void checkMinStackAllowed(String stackOption, String optionMesg, String stackSize) throws Exception { + System.out.println("*** Testing " + stackOption + stackSize); + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + stackOption + stackSize, + // Uncomment the following to get log output + // that shows actual thread creation sizes. + // "-Xlog:os+thread", + "-version"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldHaveExitValue(0); + + System.out.println("PASSED: VM launched with " + stackOption + stackSize); + } + + public static void main(String... args) throws Exception { + /* + * The result of a 16k stack size should be a quick exit with a complaint + * that the stack size is too small. However, for some win32 builds, the + * stack is always at least 64k, and this also sometimes is the minimum + * allowed size, so we won't see an error in this case. + * + * This test case will also produce a crash on some platforms if the fix + * for 6762191 is not yet in place. + */ + checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "16"); + + /* + * Try with a 32k stack size, which is the size that the launcher will + * set to if you try setting to anything smaller. This should produce the same + * result as setting to 16k if the fix for 6762191 is in place. + */ + String min_stack_allowed = checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "32"); + + /* + * Try again with a the minimum stack size that was given in the error message + */ + checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, min_stack_allowed); + + /* + * Now redo the same tests with the compiler thread stack size: + */ + checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "16"); + min_stack_allowed = checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "32"); + checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, min_stack_allowed); + + /* + * Now redo the same tests with the VM thread stack size: + */ + checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "16"); + min_stack_allowed = checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "32"); + checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, min_stack_allowed); + } +} From 37c77e03d35d240beeee49704dba3b7a1e4e56ec Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Sat, 10 Sep 2016 08:25:51 -0400 Subject: [PATCH 21/81] 8165634: Support multiple --add-modules options on the command line Use numbered properties for --add-module options so that multiple --add-module options can be supported. Reviewed-by: coleenp, gziemski, lfoltan, ccheung --- hotspot/src/share/vm/runtime/arguments.cpp | 46 ++++--------------- hotspot/src/share/vm/runtime/arguments.hpp | 3 -- .../runtime/modules/ModuleOptionsTest.java | 14 +++--- 3 files changed, 17 insertions(+), 46 deletions(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index e897e9cdf50..fdcf8d59012 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1308,35 +1308,13 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop return true; } -// sets or adds a module name to the jdk.module.addmods property -bool Arguments::append_to_addmods_property(const char* module_name) { - const char* key = "jdk.module.addmods"; - const char* old_value = Arguments::get_property(key); - size_t buf_len = strlen(key) + strlen(module_name) + 2; - if (old_value != NULL) { - buf_len += strlen(old_value) + 1; - } - char* new_value = AllocateHeap(buf_len, mtArguments); - if (new_value == NULL) { - return false; - } - if (old_value == NULL) { - jio_snprintf(new_value, buf_len, "%s=%s", key, module_name); - } else { - jio_snprintf(new_value, buf_len, "%s=%s,%s", key, old_value, module_name); - } - bool added = add_property(new_value, UnwriteableProperty, InternalProperty); - FreeHeap(new_value); - return added; -} - #if INCLUDE_CDS void Arguments::check_unsupported_dumping_properties() { assert(DumpSharedSpaces, "this function is only used with -Xshare:dump"); const char* unsupported_properties[5] = { "jdk.module.main", "jdk.module.path", "jdk.module.upgrade.path", - "jdk.module.addmods", + "jdk.module.addmods.0", "jdk.module.limitmods" }; const char* unsupported_options[5] = { "-m", "--module-path", @@ -2566,8 +2544,8 @@ bool Arguments::parse_uintx(const char* value, unsigned int addreads_count = 0; unsigned int addexports_count = 0; +unsigned int addmods_count = 0; unsigned int patch_mod_count = 0; -const char* add_modules_value = NULL; bool Arguments::create_property(const char* prop_name, const char* prop_value, PropertyInternal internal) { size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2; @@ -2821,7 +2799,9 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m return JNI_ENOMEM; } } else if (match_option(option, "--add-modules=", &tail)) { - add_modules_value = tail; + if (!create_numbered_property("jdk.module.addmods", tail, addmods_count++)) { + return JNI_ENOMEM; + } } else if (match_option(option, "--limit-modules=", &tail)) { if (!create_property("jdk.module.limitmods", tail, InternalProperty)) { return JNI_ENOMEM; @@ -2873,7 +2853,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m char *options = strcpy(NEW_C_HEAP_ARRAY(char, strlen(tail) + 1, mtArguments), tail); add_init_agent("instrument", options, false); // java agents need module java.instrument - if (!Arguments::append_to_addmods_property("java.instrument")) { + if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) { return JNI_ENOMEM; } } @@ -3149,7 +3129,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m return JNI_EINVAL; } // management agent in module java.management - if (!Arguments::append_to_addmods_property("java.management")) { + if (!create_numbered_property("jdk.module.addmods", "java.management", addmods_count++)) { return JNI_ENOMEM; } #else @@ -3560,15 +3540,6 @@ jint Arguments::finalize_vm_init_args() { return JNI_ERR; } - // Append the value of the last --add-modules option specified on the command line. - // This needs to be done here, to prevent overwriting possible values written - // to the jdk.module.addmods property by -javaagent and other options. - if (add_modules_value != NULL) { - if (!append_to_addmods_property(add_modules_value)) { - return JNI_ENOMEM; - } - } - // This must be done after all arguments have been processed. // java_compiler() true means set to "NONE" or empty. if (java_compiler() && !xdebug_mode()) { @@ -3617,7 +3588,8 @@ jint Arguments::finalize_vm_init_args() { #endif #if INCLUDE_JVMCI - if (EnableJVMCI && !append_to_addmods_property("jdk.vm.ci")) { + if (EnableJVMCI && + !create_numbered_property("jdk.module.addmods", "jdk.vm.ci", addmods_count++)) { return JNI_ENOMEM; } #endif diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index dbac4f710b0..c989e61fe07 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -489,9 +489,6 @@ class Arguments : AllStatic { static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase); - // Miscellaneous system property setter - static bool append_to_addmods_property(const char* module_name); - // Aggressive optimization flags. static jint set_aggressive_opts_flags(); diff --git a/hotspot/test/runtime/modules/ModuleOptionsTest.java b/hotspot/test/runtime/modules/ModuleOptionsTest.java index a1dec0141d4..28064bddc27 100644 --- a/hotspot/test/runtime/modules/ModuleOptionsTest.java +++ b/hotspot/test/runtime/modules/ModuleOptionsTest.java @@ -24,8 +24,8 @@ /* * @test * @bug 8136930 - * @summary Test that the VM only recognizes the last specified --add-modules - * and --list-modules options + * @summary Test that the VM only recognizes the last specified --list-modules + * options but accumulates --add-module values. * @modules java.base/jdk.internal.misc * @library /test/lib */ @@ -38,14 +38,16 @@ public class ModuleOptionsTest { public static void main(String[] args) throws Exception { - // Test that last --add-modules is the only one recognized. No exception - // should be thrown. + // Test that multiple --add-modules options are cumulative, not last one wins. + // An exception should be thrown because module i_dont_exist doesn't exist. ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "--add-modules=i_dont_exist", "--add-modules=java.base", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldHaveExitValue(0); + output.shouldContain("ResolutionException"); + output.shouldContain("i_dont_exist"); + output.shouldHaveExitValue(1); - // Test that last --limit-modules is the only one recognized. No exception + // Test that the last --limit-modules is the only one recognized. No exception // should be thrown. pb = ProcessTools.createJavaProcessBuilder( "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version"); From 1075dcd335bb3a994ea211b8ccb433a29bbd210c Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 12 Sep 2016 09:34:51 +0200 Subject: [PATCH 22/81] 8165313: Inserting freed regions during Free Collection Set serial phase takes very long on huge heaps Sort the collection set in ascending order so that the optimization when adding free regions can be exploited. Reviewed-by: sjohanss, mgerdin --- hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp index d6797b306d5..fb4286becd3 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp @@ -32,6 +32,7 @@ #include "gc/g1/heapRegionSet.hpp" #include "logging/logStream.hpp" #include "utilities/debug.hpp" +#include "utilities/quickSort.hpp" G1CollectorState* G1CollectionSet::collector_state() { return _g1->collector_state(); @@ -396,6 +397,16 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1Survi return time_remaining_ms; } +static int compare_region_idx(const uint a, const uint b) { + if (a > b) { + return 1; + } else if (a == b) { + return 0; + } else { + return -1; + } +} + void G1CollectionSet::finalize_old_part(double time_remaining_ms) { double non_young_start_time_sec = os::elapsedTime(); double predicted_old_time_ms = 0.0; @@ -493,6 +504,8 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { double non_young_end_time_sec = os::elapsedTime(); phase_times()->record_non_young_cset_choice_time_ms((non_young_end_time_sec - non_young_start_time_sec) * 1000.0); + + QuickSort::sort(_collection_set_regions, (int)_collection_set_cur_length, compare_region_idx, true); } #ifdef ASSERT From be6cc69504415e76d62dd2d6ea8e4adb03cc151a Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Thu, 8 Sep 2016 12:30:38 +0200 Subject: [PATCH 23/81] 8165455: Tracing events for G1 have incorrect metadata Reviewed-by: egahlin, tschatzl --- hotspot/src/share/vm/gc/shared/gcTrace.cpp | 6 ++- hotspot/src/share/vm/gc/shared/gcTrace.hpp | 4 +- .../src/share/vm/gc/shared/gcTraceSend.cpp | 20 +++++----- hotspot/src/share/vm/trace/traceevents.xml | 38 +++++++++---------- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/gcTrace.cpp b/hotspot/src/share/vm/gc/shared/gcTrace.cpp index b275feed4b9..f3a1a873da5 100644 --- a/hotspot/src/share/vm/gc/shared/gcTrace.cpp +++ b/hotspot/src/share/vm/gc/shared/gcTrace.cpp @@ -185,8 +185,10 @@ void OldGCTracer::report_concurrent_mode_failure() { } #if INCLUDE_ALL_GCS -void G1MMUTracer::report_mmu(double timeSlice, double gcTime, double maxTime) { - send_g1_mmu_event(timeSlice, gcTime, maxTime); +void G1MMUTracer::report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec) { + send_g1_mmu_event(time_slice_sec * MILLIUNITS, + gc_time_sec * MILLIUNITS, + max_time_sec * MILLIUNITS); } void G1NewTracer::report_yc_type(G1YCType type) { diff --git a/hotspot/src/share/vm/gc/shared/gcTrace.hpp b/hotspot/src/share/vm/gc/shared/gcTrace.hpp index d45526e87d3..20cc55ecd49 100644 --- a/hotspot/src/share/vm/gc/shared/gcTrace.hpp +++ b/hotspot/src/share/vm/gc/shared/gcTrace.hpp @@ -235,10 +235,10 @@ class ParNewTracer : public YoungGCTracer { #if INCLUDE_ALL_GCS class G1MMUTracer : public AllStatic { - static void send_g1_mmu_event(double timeSlice, double gcTime, double maxTime); + static void send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms); public: - static void report_mmu(double timeSlice, double gcTime, double maxTime); + static void report_mmu(double time_slice_sec, double gc_time_sec, double max_time_sec); }; class G1NewTracer : public YoungGCTracer { diff --git a/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp b/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp index 046db77d4d5..2a2711d3e34 100644 --- a/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp +++ b/hotspot/src/share/vm/gc/shared/gcTraceSend.cpp @@ -200,13 +200,13 @@ void G1NewTracer::send_g1_young_gc_event() { } } -void G1MMUTracer::send_g1_mmu_event(double timeSlice, double gcTime, double maxTime) { +void G1MMUTracer::send_g1_mmu_event(double time_slice_ms, double gc_time_ms, double max_time_ms) { EventG1MMU e; if (e.should_commit()) { e.set_gcId(GCId::current()); - e.set_timeSlice(timeSlice); - e.set_gcTime(gcTime); - e.set_maxGcTime(maxTime); + e.set_timeSlice(time_slice_ms); + e.set_gcTime(gc_time_ms); + e.set_pauseTarget(max_time_ms); e.commit(); } } @@ -281,10 +281,10 @@ void G1NewTracer::send_basic_ihop_statistics(size_t threshold, evt.set_targetOccupancy(target_occupancy); evt.set_thresholdPercentage(target_occupancy > 0 ? ((double)threshold / target_occupancy) : 0.0); evt.set_currentOccupancy(current_occupancy); - evt.set_lastAllocationSize(last_allocation_size); - evt.set_lastAllocationDuration(last_allocation_duration); - evt.set_lastAllocationRate(last_allocation_duration != 0.0 ? last_allocation_size / last_allocation_duration : 0.0); - evt.set_lastMarkingLength(last_marking_length); + evt.set_recentMutatorAllocationSize(last_allocation_size); + evt.set_recentMutatorDuration(last_allocation_duration * MILLIUNITS); + evt.set_recentAllocationRate(last_allocation_duration != 0.0 ? last_allocation_size / last_allocation_duration : 0.0); + evt.set_lastMarkingDuration(last_marking_length * MILLIUNITS); evt.commit(); } } @@ -301,11 +301,11 @@ void G1NewTracer::send_adaptive_ihop_statistics(size_t threshold, evt.set_gcId(GCId::current()); evt.set_threshold(threshold); evt.set_thresholdPercentage(internal_target_occupancy > 0 ? ((double)threshold / internal_target_occupancy) : 0.0); - evt.set_internalTargetOccupancy(internal_target_occupancy); + evt.set_ihopTargetOccupancy(internal_target_occupancy); evt.set_currentOccupancy(current_occupancy); evt.set_additionalBufferSize(additional_buffer_size); evt.set_predictedAllocationRate(predicted_allocation_rate); - evt.set_predictedMarkingLength(predicted_marking_length); + evt.set_predictedMarkingDuration(predicted_marking_length * MILLIUNITS); evt.set_predictionActive(prediction_active); evt.commit(); } diff --git a/hotspot/src/share/vm/trace/traceevents.xml b/hotspot/src/share/vm/trace/traceevents.xml index f3b6447127a..c2a5fe7a61d 100644 --- a/hotspot/src/share/vm/trace/traceevents.xml +++ b/hotspot/src/share/vm/trace/traceevents.xml @@ -315,9 +315,9 @@ Declares a structure type that can be used in other events. - - - + + + @@ -377,29 +377,29 @@ Declares a structure type that can be used in other events. - - - - - - - - - + + + + + + + + - - - - - - + + + + + - + From 795272dc756ca926271e10f1a4a62cdf2db1b157 Mon Sep 17 00:00:00 2001 From: Alexander Kulyakhtin Date: Fri, 9 Sep 2016 15:16:22 +0300 Subject: [PATCH 24/81] 8139368: -javaagent and -Dcom.sun.management need to add to the initial set of modules to resolve A new test for the -javaagent option Reviewed-by: mchung, alanb --- .../java/lang/instrument/SimpleAgent.java | 32 +++++++++++++++ .../instrument/TestAgentWithLimitMods.java | 40 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 jdk/test/java/lang/instrument/SimpleAgent.java create mode 100644 jdk/test/java/lang/instrument/TestAgentWithLimitMods.java diff --git a/jdk/test/java/lang/instrument/SimpleAgent.java b/jdk/test/java/lang/instrument/SimpleAgent.java new file mode 100644 index 00000000000..ea3a2a7689d --- /dev/null +++ b/jdk/test/java/lang/instrument/SimpleAgent.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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 + * 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.lang.instrument.Instrumentation; + +class SimpleAgent { + + public static void premain(String args, Instrumentation inst) { + System.out.println("in premain"); + } + +} diff --git a/jdk/test/java/lang/instrument/TestAgentWithLimitMods.java b/jdk/test/java/lang/instrument/TestAgentWithLimitMods.java new file mode 100644 index 00000000000..1571774b45c --- /dev/null +++ b/jdk/test/java/lang/instrument/TestAgentWithLimitMods.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * + * @test + * @summary Tests that the -javaagent option adds the java.instrument into + * the module graph + * @modules java.instrument + * @run shell MakeJAR3.sh SimpleAgent + * @run main/othervm -javaagent:SimpleAgent.jar -limitmods java.base TestAgentWithLimitMods + * + */ +public class TestAgentWithLimitMods { + + public static void main(String[] args) { + System.out.println("Test passed"); + } + +} From 14ca5d3c2b9a064e67acb7757193004c6abf9733 Mon Sep 17 00:00:00 2001 From: Ron Durbin Date: Fri, 9 Sep 2016 11:15:58 -0700 Subject: [PATCH 25/81] 8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option Split the single thread_min_stack_allowed into three distinct values (java_thread_min_stack_allowed, compiler_thread_min_stack_allowed and vm_internal_thread_min_stack_allowed) on non-Windows platforms. Reviewed-by: dcubed, gthornbr, dholmes, coleenp, fparain, aph --- .../tools/launcher/TooSmallStackSize.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/jdk/test/tools/launcher/TooSmallStackSize.java b/jdk/test/tools/launcher/TooSmallStackSize.java index 7cc02ab56df..6220dca2740 100644 --- a/jdk/test/tools/launcher/TooSmallStackSize.java +++ b/jdk/test/tools/launcher/TooSmallStackSize.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 @@ -35,6 +35,11 @@ * stack size for the platform (as provided by the JVM error message when a very * small stack is used), and then verify that the JVM can be launched with that stack * size without a crash or any error messages. + * + * Note: The '-Xss' and '-XX:ThreadStackSize=' options + * both control Java thread stack size. This repo's version of the test + * exercises the '-Xss' option. The hotspot repo's version of the test + * exercises the '-XX:ThreadStackSize' VM option. */ public class TooSmallStackSize extends TestHelper { @@ -59,7 +64,7 @@ public class TooSmallStackSize extends TestHelper { static String getMinStackAllowed(TestResult tr) { /* * The JVM output will contain in one of the lines: - * "The stack size specified is too small, Specify at least 100k" + * "The Java thread stack size specified is too small. Specify at least 100k" * Although the actual size will vary. We need to extract this size * string from the output and return it. */ @@ -73,6 +78,9 @@ public class TooSmallStackSize extends TestHelper { } } + System.out.println("Expect='" + matchStr + "'"); + System.out.println("Actual:"); + printTestOutput(tr); System.out.println("FAILED: Could not get the stack size from the output"); throw new RuntimeException("test fails"); } @@ -96,11 +104,15 @@ public class TooSmallStackSize extends TestHelper { System.out.println("PASSED: got no error message with stack size of " + stackSize); min_stack_allowed = stackSize; } else { - if (tr.contains("The stack size specified is too small")) { + String matchStr = "The Java thread stack size specified is too small"; + if (tr.contains(matchStr)) { System.out.println("PASSED: got expected error message with stack size of " + stackSize); min_stack_allowed = getMinStackAllowed(tr); } else { // Likely a crash + System.out.println("Expect='" + matchStr + "'"); + System.out.println("Actual:"); + printTestOutput(tr); System.out.println("FAILED: Did not get expected error message with stack size of " + stackSize); throw new RuntimeException("test fails"); } @@ -123,6 +135,8 @@ public class TooSmallStackSize extends TestHelper { System.out.println("PASSED: VM launched with minimum allowed stack size of " + stackSize); } else { // Likely a crash + System.out.println("Test output:"); + printTestOutput(tr); System.out.println("FAILED: VM failed to launch with minimum allowed stack size of " + stackSize); throw new RuntimeException("test fails"); } From 2b31773cba23ed00117c1005a9faca45f07d80ba Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Sat, 10 Sep 2016 08:27:40 -0400 Subject: [PATCH 26/81] 8165634: Support multiple --add-modules options on the command line Reviewed-by: alanb --- .../jdk/internal/module/ModuleBootstrap.java | 59 +++++++++++++------ .../launcher/modules/addmods/AddModsTest.java | 22 +++++++ 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java index b9b93b275ef..ca40bf2706e 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java @@ -153,27 +153,24 @@ public final class ModuleBootstrap { boolean addAllDefaultModules = false; boolean addAllSystemModules = false; boolean addAllApplicationModules = false; - String propValue = getAndRemoveProperty("jdk.module.addmods"); - if (propValue != null) { - for (String mod: propValue.split(",")) { - switch (mod) { - case ALL_DEFAULT: - addAllDefaultModules = true; - break; - case ALL_SYSTEM: - addAllSystemModules = true; - break; - case ALL_MODULE_PATH: - addAllApplicationModules = true; - break; - default : - roots.add(mod); - } + for (String mod: getExtraAddModules()) { + switch (mod) { + case ALL_DEFAULT: + addAllDefaultModules = true; + break; + case ALL_SYSTEM: + addAllSystemModules = true; + break; + case ALL_MODULE_PATH: + addAllApplicationModules = true; + break; + default : + roots.add(mod); } } // --limit-modules - propValue = getAndRemoveProperty("jdk.module.limitmods"); + String propValue = getAndRemoveProperty("jdk.module.limitmods"); if (propValue != null) { Set mods = new HashSet<>(); for (String mod: propValue.split(",")) { @@ -392,6 +389,32 @@ public final class ModuleBootstrap { } } + /** + * Returns the set of module names specified via --add-modules options + * on the command line + */ + private static Set getExtraAddModules() { + String prefix = "jdk.module.addmods."; + int index = 0; + + // the system property is removed after decoding + String value = getAndRemoveProperty(prefix + index); + if (value == null) { + return Collections.emptySet(); + } + + Set modules = new HashSet<>(); + while (value != null) { + for (String s : value.split(",")) { + if (s.length() > 0) modules.add(s); + } + + index++; + value = getAndRemoveProperty(prefix + index); + } + + return modules; + } /** * Process the --add-reads options to add any additional read edges that @@ -514,7 +537,7 @@ public final class ModuleBootstrap { // value is (,)* if (map.containsKey(key)) - fail(key + " specified more than once"); + fail(key + " specified more than once"); Set values = new HashSet<>(); map.put(key, values); diff --git a/jdk/test/tools/launcher/modules/addmods/AddModsTest.java b/jdk/test/tools/launcher/modules/addmods/AddModsTest.java index 3ace33457bc..3a7a320bafa 100644 --- a/jdk/test/tools/launcher/modules/addmods/AddModsTest.java +++ b/jdk/test/tools/launcher/modules/addmods/AddModsTest.java @@ -31,6 +31,7 @@ * @summary Basic test for java --add-modules */ +import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; @@ -223,6 +224,27 @@ public class AddModsTest { } + /** + * Tests {@code --add-modules} be specified more than once. + */ + public void testWithMultipleAddModules() throws Exception { + + String modulepath = MODS1_DIR.toString() + File.pathSeparator + + MODS2_DIR.toString(); + int exitValue + = executeTestJava("--module-path", modulepath, + "--add-modules", LOGGER_MODULE, + "--add-modules", TEST_MODULE, + "-m", TEST_MID, + "logger.Logger") + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } + + /** * Attempt to run with a bad module name specified to --add-modules */ From f6a78989956ebb38b7ca179245995aa1d4958942 Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Mon, 12 Sep 2016 16:34:36 +0200 Subject: [PATCH 27/81] 8114823: G1 doesn't honor request to disable class unloading Reviewed-by: tschatzl, mgerdin --- hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp | 15 ++- .../src/share/vm/gc/g1/g1RootProcessor.cpp | 45 +++++-- .../src/share/vm/gc/g1/g1RootProcessor.hpp | 20 +++ hotspot/src/share/vm/runtime/arguments.cpp | 12 +- .../TestClassUnloadingDisabled.java | 118 ++++++++++++++++++ 5 files changed, 191 insertions(+), 19 deletions(-) create mode 100644 hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java diff --git a/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp index 4eed0960dca..9834fbd8c7f 100644 --- a/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp @@ -132,9 +132,16 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations); { G1RootProcessor root_processor(g1h, 1); - root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, - &GenMarkSweep::follow_cld_closure, - &follow_code_closure); + if (ClassUnloading) { + root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure, + &GenMarkSweep::follow_cld_closure, + &follow_code_closure); + } else { + root_processor.process_all_roots_no_string_table( + &GenMarkSweep::follow_root_closure, + &GenMarkSweep::follow_cld_closure, + &follow_code_closure); + } } { @@ -157,7 +164,7 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, // This is the point where the entire marking should have completed. assert(GenMarkSweep::_marking_stack.is_empty(), "Marking should have completed"); - { + if (ClassUnloading) { GCTraceTime(Debug, gc, phases) trace("Class Unloading", gc_timer()); // Unload classes and purge the SystemDictionary. diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp index f8526e778e9..8c4642d0ccb 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp @@ -83,6 +83,7 @@ void G1RootProcessor::evacuate_roots(G1EvacuationRootClosures* closures, uint wo } process_vm_roots(closures, phase_times, worker_i); + process_string_table_roots(closures, phase_times, worker_i); { // Now the CM ref_processor roots. @@ -191,19 +192,34 @@ public: void G1RootProcessor::process_all_roots(OopClosure* oops, CLDClosure* clds, - CodeBlobClosure* blobs) { + CodeBlobClosure* blobs, + bool process_string_table) { AllRootsClosures closures(oops, clds); process_java_roots(&closures, NULL, 0); process_vm_roots(&closures, NULL, 0); - if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { - CodeCache::blobs_do(blobs); + if (process_string_table) { + process_string_table_roots(&closures, NULL, 0); } + process_code_cache_roots(blobs, NULL, 0); _process_strong_tasks.all_tasks_completed(n_workers()); } +void G1RootProcessor::process_all_roots(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs) { + process_all_roots(oops, clds, blobs, true); +} + +void G1RootProcessor::process_all_roots_no_string_table(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs) { + assert(!ClassUnloading, "Should only be used when class unloading is disabled"); + process_all_roots(oops, clds, blobs, false); +} + void G1RootProcessor::process_java_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, uint worker_i) { @@ -280,14 +296,23 @@ void G1RootProcessor::process_vm_roots(G1RootClosures* closures, SystemDictionary::roots_oops_do(strong_roots, weak_roots); } } +} - { - G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); - // All threads execute the following. A specific chunk of buckets - // from the StringTable are the individual tasks. - if (weak_roots != NULL) { - StringTable::possibly_parallel_oops_do(weak_roots); - } +void G1RootProcessor::process_string_table_roots(G1RootClosures* closures, + G1GCPhaseTimes* phase_times, + uint worker_i) { + assert(closures->weak_oops() != NULL, "Should only be called when all roots are processed"); + G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i); + // All threads execute the following. A specific chunk of buckets + // from the StringTable are the individual tasks. + StringTable::possibly_parallel_oops_do(closures->weak_oops()); +} + +void G1RootProcessor::process_code_cache_roots(CodeBlobClosure* code_closure, + G1GCPhaseTimes* phase_times, + uint worker_i) { + if (!_process_strong_tasks.is_task_claimed(G1RP_PS_CodeCache_oops_do)) { + CodeCache::blobs_do(code_closure); } } diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp index ad0f0479810..11cb6723559 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp @@ -73,6 +73,11 @@ class G1RootProcessor : public StackObj { void worker_has_discovered_all_strong_classes(); void wait_until_all_strong_classes_discovered(); + void process_all_roots(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs, + bool process_string_table); + void process_java_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, uint worker_i); @@ -81,6 +86,14 @@ class G1RootProcessor : public StackObj { G1GCPhaseTimes* phase_times, uint worker_i); + void process_string_table_roots(G1RootClosures* closures, + G1GCPhaseTimes* phase_times, + uint worker_i); + + void process_code_cache_roots(CodeBlobClosure* code_closure, + G1GCPhaseTimes* phase_times, + uint worker_i); + public: G1RootProcessor(G1CollectedHeap* g1h, uint n_workers); @@ -99,6 +112,13 @@ public: CLDClosure* clds, CodeBlobClosure* blobs); + // Apply oops, clds and blobs to strongly and weakly reachable roots in the system, + // the only thing different from process_all_roots is that we skip the string table + // to avoid keeping every string live when doing class unloading. + void process_all_roots_no_string_table(OopClosure* oops, + CLDClosure* clds, + CodeBlobClosure* blobs); + // Number of worker threads used by the root processor. uint n_workers() const; }; diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index fdcf8d59012..e7e45e9fcd1 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1665,11 +1665,6 @@ void Arguments::set_cms_and_parnew_gc_flags() { CompactibleFreeListSpaceLAB::modify_initialization(OldPLABSize, OldPLABWeight); } - if (!ClassUnloading) { - FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); - FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false); - } - log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); } #endif // INCLUDE_ALL_GCS @@ -1997,6 +1992,13 @@ void Arguments::set_gc_specific_flags() { // Keeping the heap 100% free is hard ;-) so limit it to 99%. FLAG_SET_ERGO(uintx, MinHeapFreeRatio, 99); } + + // If class unloading is disabled, also disable concurrent class unloading. + if (!ClassUnloading) { + FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false); + FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false); + FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false); + } #endif // INCLUDE_ALL_GCS } diff --git a/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java b/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java new file mode 100644 index 00000000000..96f10bbcd60 --- /dev/null +++ b/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reqserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key gc + * @bug 8114823 + * @requires vm.gc == null + * @requires vm.opt.ExplicitGCInvokesConcurrent != true + * @requires vm.opt.ClassUnloading != true + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseG1GC TestClassUnloadingDisabled + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseSerialGC TestClassUnloadingDisabled + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseParallelGC TestClassUnloadingDisabled + * + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-ClassUnloading -XX:+UseConcMarkSweepGC TestClassUnloadingDisabled + */ + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import sun.hotspot.WhiteBox; + +import static jdk.test.lib.Asserts.*; + +public class TestClassUnloadingDisabled { + public static void main(String args[]) throws Exception { + final WhiteBox wb = WhiteBox.getWhiteBox(); + // Fetch the dir where the test class and the class + // to be loaded resides. + String classDir = TestClassUnloadingDisabled.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + String className = "ClassToLoadUnload"; + + assertFalse(wb.isClassAlive(className), "Should not be loaded yet"); + + // The NoPDClassLoader handles loading classes in the test directory + // and loads them without a protection domain, which in some cases + // keeps the class live regardless of marking state. + NoPDClassLoader nopd = new NoPDClassLoader(classDir); + nopd.loadClass(className); + + assertTrue(wb.isClassAlive(className), "Class should be loaded"); + + // Clear the class-loader, class and object references to make + // class unloading possible. + nopd = null; + + System.gc(); + assertTrue(wb.isClassAlive(className), "Class should not have ben unloaded"); + } +} + +class NoPDClassLoader extends ClassLoader { + String path; + + NoPDClassLoader(String path) { + this.path = path; + } + + public Class loadClass(String name) throws ClassNotFoundException { + byte[] cls = null; + File f = new File(path,name + ".class"); + + // Delegate class loading if class not present in the given + // directory. + if (!f.exists()) { + return super.loadClass(name); + } + + try { + Path path = Paths.get(f.getAbsolutePath()); + cls = Files.readAllBytes(path); + } catch (IOException e) { + throw new ClassNotFoundException(name); + } + + // Define class with no protection domain and resolve it. + return defineClass(name, cls, 0, cls.length, null); + } +} + +class ClassToLoadUnload { +} From 22d512c0eddacadfd1026d46526d7d71f85baa72 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Mon, 12 Sep 2016 13:16:39 -0400 Subject: [PATCH 28/81] 8165881: Backout JDK-8164913 Reviewed-by: hseigel --- hotspot/src/share/vm/prims/jvmtiExport.cpp | 2 ++ .../src/share/vm/services/diagnosticCommand.cpp | 15 +++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index 53f80345c74..a388f29dc9e 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -2407,7 +2407,9 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam, delete agent_lib; } + // Agent_OnAttach executed so completion status is JNI_OK st->print_cr("%d", result); + result = JNI_OK; } } return result; diff --git a/hotspot/src/share/vm/services/diagnosticCommand.cpp b/hotspot/src/share/vm/services/diagnosticCommand.cpp index d5338b2609c..c90bf08e39e 100644 --- a/hotspot/src/share/vm/services/diagnosticCommand.cpp +++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp @@ -277,12 +277,11 @@ void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) { char *suffix = strrchr(_libpath.value(), '.'); bool is_java_agent = (suffix != NULL) && (strncmp(".jar", suffix, 4) == 0); - jint result = JNI_ERR; if (is_java_agent) { if (_option.value() == NULL) { - result = JvmtiExport::load_agent_library("instrument", "false", - _libpath.value(), output()); + JvmtiExport::load_agent_library("instrument", "false", + _libpath.value(), output()); } else { size_t opt_len = strlen(_libpath.value()) + strlen(_option.value()) + 2; if (opt_len > 4096) { @@ -299,18 +298,14 @@ void JVMTIAgentLoadDCmd::execute(DCmdSource source, TRAPS) { } jio_snprintf(opt, opt_len, "%s=%s", _libpath.value(), _option.value()); - result = JvmtiExport::load_agent_library("instrument", "false", - opt, output()); + JvmtiExport::load_agent_library("instrument", "false", opt, output()); os::free(opt); } } else { - result = JvmtiExport::load_agent_library(_libpath.value(), "true", - _option.value(), output()); + JvmtiExport::load_agent_library(_libpath.value(), "true", + _option.value(), output()); } - - output()->print_cr("JVMTI agent attach %s.", - (result == JNI_OK) ? "succeeded" : "failed"); } int JVMTIAgentLoadDCmd::num_arguments() { From 2347610827502b107de831d8bca49ac86847e3c4 Mon Sep 17 00:00:00 2001 From: Poonam Bajaj Date: Mon, 12 Sep 2016 17:18:19 +0000 Subject: [PATCH 29/81] 8165493: SA: Add method in GrowableArray.java to be able to access the 'data' field Reviewed-by: dholmes, dsamersoff, egahlin --- .../share/classes/sun/jvm/hotspot/utilities/GrowableArray.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java index e66586e4b4f..ca757cac7be 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/GrowableArray.java @@ -65,4 +65,7 @@ public class GrowableArray extends GenericGrowableArray { super(addr); virtualConstructor = v; } + public Address getData() { + return dataField.getValue(getAddress()); + } } From 1c2da5f5edc092d7c8170b3f9bada9bb4a98b0c0 Mon Sep 17 00:00:00 2001 From: David Simms Date: Tue, 13 Sep 2016 09:04:44 +0200 Subject: [PATCH 30/81] 8164086: Checked JNI pending exception check should be cleared when returning to Java frame Transitions to Java clear the pending pointer Reviewed-by: dholmes, neliasso, coleenp --- hotspot/make/test/JtregNative.gmk | 1 + .../cpu/aarch64/vm/sharedRuntime_aarch64.cpp | 5 + .../templateInterpreterGenerator_aarch64.cpp | 5 + .../src/cpu/sparc/vm/sharedRuntime_sparc.cpp | 5 + .../vm/templateInterpreterGenerator_sparc.cpp | 5 + .../src/cpu/x86/vm/sharedRuntime_x86_32.cpp | 5 + .../src/cpu/x86/vm/sharedRuntime_x86_64.cpp | 5 + .../vm/templateInterpreterGenerator_x86.cpp | 5 + hotspot/src/share/vm/prims/whitebox.cpp | 16 +- hotspot/src/share/vm/prims/whitebox.hpp | 15 +- .../src/share/vm/runtime/interfaceSupport.hpp | 1 + hotspot/src/share/vm/runtime/thread.hpp | 9 +- .../checked/TestCheckedJniExceptionCheck.java | 209 ++++++++++++++++++ .../checked/libTestCheckedJniExceptionCheck.c | 98 ++++++++ 14 files changed, 381 insertions(+), 3 deletions(-) create mode 100644 hotspot/test/runtime/jni/checked/TestCheckedJniExceptionCheck.java create mode 100644 hotspot/test/runtime/jni/checked/libTestCheckedJniExceptionCheck.c diff --git a/hotspot/make/test/JtregNative.gmk b/hotspot/make/test/JtregNative.gmk index 9ed952f36c0..8c818122765 100644 --- a/hotspot/make/test/JtregNative.gmk +++ b/hotspot/make/test/JtregNative.gmk @@ -44,6 +44,7 @@ BUILD_HOTSPOT_JTREG_NATIVE_SRC := \ $(HOTSPOT_TOPDIR)/test/native_sanity \ $(HOTSPOT_TOPDIR)/test/runtime/jni/8025979 \ $(HOTSPOT_TOPDIR)/test/runtime/jni/8033445 \ + $(HOTSPOT_TOPDIR)/test/runtime/jni/checked \ $(HOTSPOT_TOPDIR)/test/runtime/jni/ToStringInInterfaceTest \ $(HOTSPOT_TOPDIR)/test/runtime/modules/getModuleJNI \ $(HOTSPOT_TOPDIR)/test/runtime/SameObject \ diff --git a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp index 771dc099b9f..d1c4dbb68a2 100644 --- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp @@ -2041,6 +2041,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(r0); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ str(zr, Address(rthread, JavaThread::pending_jni_exception_check_fn_offset())); + } + if (!is_critical_native) { // reset handle block __ ldr(r2, Address(rthread, JavaThread::active_handles_offset())); diff --git a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp index 5ac01c904fc..122cac33cef 100644 --- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp @@ -1355,6 +1355,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // reset_last_Java_frame __ reset_last_Java_frame(true); + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ str(zr, Address(rthread, JavaThread::pending_jni_exception_check_fn_offset())); + } + // reset handle block __ ldr(t, Address(rthread, JavaThread::active_handles_offset())); __ str(zr, Address(t, JNIHandleBlock::top_offset_in_bytes())); diff --git a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp index aa54e3b91f9..06ca12698c4 100644 --- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp @@ -2765,6 +2765,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(I0); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset()); + } + if (!is_critical_native) { // reset handle block __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), L5); diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp index d8973ed0281..1f9fba2370b 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp @@ -1487,6 +1487,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { __ set(_thread_in_Java, G3_scratch); __ st(G3_scratch, thread_state); + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset()); + } + // reset handle block __ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch); __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes()); diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index 96961a8b9b0..c69ef9a26e6 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -2236,6 +2236,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(rax); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ movptr(Address(thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD); + } + if (!is_critical_native) { // reset handle block __ movptr(rcx, Address(thread, JavaThread::active_handles_offset())); diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index 76b7bb46e34..180a3abed4a 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -2589,6 +2589,11 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ verify_oop(rax); } + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ movptr(Address(r15_thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD); + } + if (!is_critical_native) { // reset handle block __ movptr(rcx, Address(r15_thread, JavaThread::active_handles_offset())); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp index 845959fe4e4..6441d19cf5f 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp @@ -1169,6 +1169,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // reset_last_Java_frame __ reset_last_Java_frame(thread, true); + if (CheckJNICalls) { + // clear_pending_jni_exception_check + __ movptr(Address(thread, JavaThread::pending_jni_exception_check_fn_offset()), NULL_WORD); + } + // reset handle block __ movptr(t, Address(thread, JavaThread::active_handles_offset())); __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD); diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 6228453f6cc..6ef4f96ed08 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -894,6 +894,7 @@ static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, F } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, false); Flag::Error result = (*TAt)(flag_name, value, true, true); env->ReleaseStringUTFChars(name, flag_name); return (result == Flag::SUCCESS); @@ -906,6 +907,7 @@ static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, F } ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, false); Flag::Error result = (*TAtPut)(flag_name, value, Flag::INTERNAL); env->ReleaseStringUTFChars(name, flag_name); return (result == Flag::SUCCESS); @@ -944,6 +946,7 @@ static jobject doubleBox(JavaThread* thread, JNIEnv* env, jdouble value) { static Flag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) { ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, NULL); Flag* result = Flag::find_flag(flag_name, strlen(flag_name), true, true); env->ReleaseStringUTFChars(name, flag_name); return result; @@ -1084,7 +1087,14 @@ WB_END WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value)) ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI - const char* ccstrValue = (value == NULL) ? NULL : env->GetStringUTFChars(value, NULL); + const char* ccstrValue; + if (value == NULL) { + ccstrValue = NULL; + } + else { + ccstrValue = env->GetStringUTFChars(value, NULL); + CHECK_JNI_EXCEPTION(env); + } ccstr ccstrResult = ccstrValue; bool needFree; { @@ -1308,6 +1318,7 @@ WB_ENTRY(jobjectArray, WB_GetCodeHeapEntries(JNIEnv* env, jobject o, jint blob_t jclass clazz = env->FindClass(vmSymbols::java_lang_Object()->as_C_string()); CHECK_JNI_EXCEPTION_(env, NULL); result = env->NewObjectArray(blobs.length(), clazz, NULL); + CHECK_JNI_EXCEPTION_(env, NULL); if (result == NULL) { return result; } @@ -1317,6 +1328,7 @@ WB_ENTRY(jobjectArray, WB_GetCodeHeapEntries(JNIEnv* env, jobject o, jint blob_t jobjectArray obj = codeBlob2objectArray(thread, env, *it); CHECK_JNI_EXCEPTION_(env, NULL); env->SetObjectArrayElement(result, i, obj); + CHECK_JNI_EXCEPTION_(env, NULL); ++i; } return result; @@ -1523,6 +1535,7 @@ static bool GetMethodOption(JavaThread* thread, JNIEnv* env, jobject method, jst // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); const char* flag_name = env->GetStringUTFChars(name, NULL); + CHECK_JNI_EXCEPTION_(env, false); bool result = CompilerOracle::has_option_value(mh, flag_name, *value); env->ReleaseStringUTFChars(name, flag_name); return result; @@ -1678,6 +1691,7 @@ WB_ENTRY(jint, WB_AddCompilerDirective(JNIEnv* env, jobject o, jstring compDirec // can't be in VM when we call JNI ThreadToNativeFromVM ttnfv(thread); const char* dir = env->GetStringUTFChars(compDirect, NULL); + CHECK_JNI_EXCEPTION_(env, 0); int ret; { ThreadInVMfromNative ttvfn(thread); // back to VM diff --git a/hotspot/src/share/vm/prims/whitebox.hpp b/hotspot/src/share/vm/prims/whitebox.hpp index 6398b4ca0d9..8402195fcaf 100644 --- a/hotspot/src/share/vm/prims/whitebox.hpp +++ b/hotspot/src/share/vm/prims/whitebox.hpp @@ -33,9 +33,22 @@ #include "oops/symbol.hpp" #include "runtime/interfaceSupport.hpp" +// Unconditionally clear pedantic pending JNI checks +class ClearPendingJniExcCheck : public StackObj { +private: + JavaThread* _thread; +public: + ClearPendingJniExcCheck(JNIEnv* env) : _thread(JavaThread::thread_from_jni_environment(env)) {} + ~ClearPendingJniExcCheck() { + _thread->clear_pending_jni_exception_check(); + } +}; + // Entry macro to transition from JNI to VM state. -#define WB_ENTRY(result_type, header) JNI_ENTRY(result_type, header) +#define WB_ENTRY(result_type, header) JNI_ENTRY(result_type, header) \ + ClearPendingJniExcCheck _clearCheck(env); + #define WB_END JNI_END #define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL diff --git a/hotspot/src/share/vm/runtime/interfaceSupport.hpp b/hotspot/src/share/vm/runtime/interfaceSupport.hpp index 840d68e2444..7b7d01fa9d3 100644 --- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp +++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp @@ -280,6 +280,7 @@ class ThreadToNativeFromVM : public ThreadStateTransition { ~ThreadToNativeFromVM() { trans_from_native(_thread_in_vm); + assert(!_thread->is_pending_jni_exception_check(), "Pending JNI Exception Check"); // We don't need to clear_walkable because it will happen automagically when we return to java } }; diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 37e6ed310c0..2925dee0b50 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -1542,6 +1542,9 @@ class JavaThread: public Thread { static ByteSize jmp_ring_offset() { return byte_offset_of(JavaThread, _jmp_ring); } #endif // PRODUCT static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment); } + static ByteSize pending_jni_exception_check_fn_offset() { + return byte_offset_of(JavaThread, _pending_jni_exception_check_fn); + } static ByteSize last_Java_sp_offset() { return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset(); } @@ -1615,7 +1618,11 @@ class JavaThread: public Thread { assert(_jni_active_critical >= 0, "JNI critical nesting problem?"); } - // Checked JNI, is the programmer required to check for exceptions, specify which function name + // Checked JNI: is the programmer required to check for exceptions, if so specify + // which function name. Returning to a Java frame should implicitly clear the + // pending check, this is done for Native->Java transitions (i.e. user JNI code). + // VM->Java transistions are not cleared, it is expected that JNI code enclosed + // within ThreadToNativeFromVM makes proper exception checks (i.e. VM internal). bool is_pending_jni_exception_check() const { return _pending_jni_exception_check_fn != NULL; } void clear_pending_jni_exception_check() { _pending_jni_exception_check_fn = NULL; } const char* get_pending_jni_exception_check() const { return _pending_jni_exception_check_fn; } diff --git a/hotspot/test/runtime/jni/checked/TestCheckedJniExceptionCheck.java b/hotspot/test/runtime/jni/checked/TestCheckedJniExceptionCheck.java new file mode 100644 index 00000000000..e5e8f9e7ad6 --- /dev/null +++ b/hotspot/test/runtime/jni/checked/TestCheckedJniExceptionCheck.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8164086 + * @summary regression tests for 8164086, verify correct warning from checked JNI + * @library /test/lib + * @modules java.management + * @run main/native TestCheckedJniExceptionCheck launch + */ + +import java.util.List; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class TestCheckedJniExceptionCheck { + + static { + System.loadLibrary("TestCheckedJniExceptionCheck"); + } + + int callableMethodInvokeCount = 0; + + static final String TEST_START = "TEST STARTED"; + static final String EXPECT_WARNING_START = "EXPECT_WARNING_START"; + static final String EXPECT_WARNING_END = "EXPECT_WARNING_END"; + + static final String JNI_CHECK_EXCEPTION = "WARNING in native method: JNI call made without checking exceptions when required to from"; + + static void printExpectWarningStart(int count) { + System.out.println(EXPECT_WARNING_START + " " + count); + } + + static void printExpectWarningEnd() { + System.out.println(EXPECT_WARNING_END); + } + + public TestCheckedJniExceptionCheck() { + initMethodIds("callableMethod", "()V", + "callableNestedMethod", "(IZ)V"); + System.out.println(TEST_START); + } + + public void test() { + testSingleCallNoCheck(); + testSingleCallCheck(); + testSingleCallNoCheckMultipleTimes(); + + testMultipleCallsNoCheck(); + testMultipleCallsCheck(); + + testNestedSingleCallsNoCheck(); + testNestedSingleCallsCheck(); + testNestedMultipleCallsNoCheck(); + testNestedMultipleCallsCheck(); + } + + public void testSingleCallNoCheck() { + System.out.println("testSingleCallNoCheck start"); + callJavaFromNative(1, false); + System.out.println("testSingleCallNoCheck end"); + } + + public void testSingleCallCheck() { + System.out.println("testSingleCallCheck start"); + callJavaFromNative(1, true); + System.out.println("testSingleCallCheck end"); + } + + public void testSingleCallNoCheckMultipleTimes() { + System.out.println("testSingleCallNoCheckMultipleTimes start"); + callJavaFromNative(1, false); + callJavaFromNative(1, false); + System.out.println("testSingleCallNoCheckMultipleTimes end"); + } + + public void testMultipleCallsNoCheck() { + System.out.println("testMultipleCallsNoCheck start"); + printExpectWarningStart(1); + callJavaFromNative(2, false); + printExpectWarningEnd(); + System.out.println("testMultipleCallsNoCheck end"); + } + + public void testMultipleCallsCheck() { + System.out.println("testMultipleCallsCheck start"); + callJavaFromNative(2, true); + System.out.println("testMultipleCallsCheck end"); + } + + public void testNestedSingleCallsNoCheck() { + System.out.println("testNestedSingleCallsNoCheck start"); + callNestedJavaFromNative(1, false); + System.out.println("testNestedSingleCallsNoCheck end"); + } + + public void testNestedSingleCallsCheck() { + System.out.println("testNestedSingleCallsCheck start"); + callNestedJavaFromNative(1, true); + System.out.println("testNestedSingleCallsCheck end"); + } + + public void testNestedMultipleCallsNoCheck() { + System.out.println("testNestedMultipleCallsNoCheck start"); + printExpectWarningStart(3); + callNestedJavaFromNative(2, false); + printExpectWarningEnd(); + System.out.println("testNestedMultipleCallsNoCheck end"); + } + + public void testNestedMultipleCallsCheck() { + System.out.println("testNestedMultipleCallsCheck start"); + callNestedJavaFromNative(2, true); + System.out.println("testNestedMultipleCallsCheck end"); + } + + public void callableMethod() { + callableMethodInvokeCount++; + } + + public void callableNestedMethod(int nofCalls, boolean withExceptionChecks) { + callJavaFromNative(nofCalls, withExceptionChecks); + } + + public native void callJavaFromNative(int nofCalls, boolean withExceptionChecks); + + public native void callNestedJavaFromNative(int nofCalls, boolean withExceptionChecks); + + private native void initMethodIds(String callableMethodName, + String callableMethodSig, + String callableNestedMethodName, + String callableNestedMethodSig); + + + // Check warnings appear where they should, with start/end statements in output... + static void checkOuputForCorrectWarnings(OutputAnalyzer oa) throws RuntimeException { + List lines = oa.asLines(); + int expectedWarnings = 0; + int warningCount = 0; + int lineNo = 0; + boolean testStartLine = false; + for (String line : lines) { + lineNo++; + if (!testStartLine) { // Skip any warning before the actual test itself + testStartLine = line.startsWith(TEST_START); + continue; + } + if (line.startsWith(JNI_CHECK_EXCEPTION)) { + if (expectedWarnings == 0) { + oa.reportDiagnosticSummary(); + throw new RuntimeException("Unexpected warning at line " + lineNo); + } + warningCount++; + if (warningCount > expectedWarnings) { + oa.reportDiagnosticSummary(); + throw new RuntimeException("Unexpected warning at line " + lineNo); + } + } + else if (line.startsWith(EXPECT_WARNING_START)) { + String countStr = line.substring(EXPECT_WARNING_START.length() + 1); + expectedWarnings = Integer.parseInt(countStr); + } + else if (line.startsWith(EXPECT_WARNING_END)) { + if (warningCount != expectedWarnings) { + oa.reportDiagnosticSummary(); + throw new RuntimeException("Missing warning at line " + lineNo); + } + warningCount = 0; + expectedWarnings = 0; + } + } + /* + System.out.println("Output looks good..."); + oa.reportDiagnosticSummary(); + */ + } + + public static void main(String[] args) throws Throwable { + if (args == null || args.length == 0) { + new TestCheckedJniExceptionCheck().test(); + return; + } + + // launch and check output + checkOuputForCorrectWarnings(ProcessTools.executeTestJvm("-Xcheck:jni", + "TestCheckedJniExceptionCheck")); + } + +} diff --git a/hotspot/test/runtime/jni/checked/libTestCheckedJniExceptionCheck.c b/hotspot/test/runtime/jni/checked/libTestCheckedJniExceptionCheck.c new file mode 100644 index 00000000000..fc4a9344838 --- /dev/null +++ b/hotspot/test/runtime/jni/checked/libTestCheckedJniExceptionCheck.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 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 + * 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. + */ + +#include + +static jmethodID _callable_method_id; +static jmethodID _callable_nested_method_id; + +static void check_exceptions(JNIEnv *env) { + if ((*env)->ExceptionCheck(env)) { + (*env)->ExceptionDescribe(env); + (*env)->FatalError(env, "Unexpected Exception"); + } +} + +static jmethodID get_method_id(JNIEnv *env, jclass clz, jstring jname, jstring jsig) { + jmethodID mid; + const char *name, *sig; + + name = (*env)->GetStringUTFChars(env, jname, NULL); + check_exceptions(env); + + sig = (*env)->GetStringUTFChars(env, jsig, NULL); + check_exceptions(env); + + mid = (*env)->GetMethodID(env, clz, name, sig); + check_exceptions(env); + + (*env)->ReleaseStringUTFChars(env, jname, name); + (*env)->ReleaseStringUTFChars(env, jsig, sig); + return mid; +} + +JNIEXPORT void JNICALL +Java_TestCheckedJniExceptionCheck_initMethodIds(JNIEnv *env, + jobject obj, + jstring callable_method_name, + jstring callable_method_sig, + jstring callable_nested_method_name, + jstring callable_nested_method_sig) { + jclass clz = (*env)->GetObjectClass(env, obj); + + _callable_method_id = get_method_id(env, clz, + callable_method_name, + callable_method_sig); + + _callable_nested_method_id = get_method_id(env, clz, + callable_nested_method_name, + callable_nested_method_sig); +} + +JNIEXPORT void JNICALL +Java_TestCheckedJniExceptionCheck_callJavaFromNative(JNIEnv *env, + jobject obj, + jint nofCalls, + jboolean checkExceptions) { + int i; + for (i = 0; i < nofCalls; i++) { + (*env)->CallVoidMethod(env, obj, _callable_method_id); + if (checkExceptions == JNI_TRUE) { + check_exceptions(env); + } + } +} + +JNIEXPORT void JNICALL +Java_TestCheckedJniExceptionCheck_callNestedJavaFromNative(JNIEnv *env, + jobject obj, + jint nofCalls, + jboolean checkExceptions) { + int i; + for (i = 0; i < nofCalls; i++) { + (*env)->CallVoidMethod(env, obj, _callable_nested_method_id, nofCalls, checkExceptions); + if (checkExceptions == JNI_TRUE) { + check_exceptions(env); + } + } +} From c719b0171c747dc8e6929240171f0ed55a18b927 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 13 Sep 2016 11:32:45 +0200 Subject: [PATCH 31/81] 8164948: Initializing stores of HeapRegions are not ordered with regards to their use in G1ConcurrentMark Add a storestore barrier before publishing newly initialized HeapRegion instances, and place a loadload barrier before use of members. Reviewed-by: sjohanss, sangheki --- hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp | 3 ++- hotspot/src/share/vm/gc/g1/heapRegionManager.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 2f14e088f3f..9084f46c3be 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -1904,7 +1904,8 @@ G1ConcurrentMark::claim_region(uint worker_id) { assert(_g1h->is_in_g1_reserved(finger), "invariant"); HeapRegion* curr_region = _g1h->heap_region_containing(finger); - + // Make sure that the reads below do not float before loading curr_region. + OrderAccess::loadload(); // Above heap_region_containing may return NULL as we always scan claim // until the end of the heap. In this case, just jump to the next region. HeapWord* end = curr_region != NULL ? curr_region->end() : finger + HeapRegion::GrainWords; diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp index 06b04eeefea..1f6bc95b1ad 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp @@ -123,6 +123,7 @@ void HeapRegionManager::make_regions_available(uint start, uint num_regions) { for (uint i = start; i < start + num_regions; i++) { if (_regions.get_by_index(i) == NULL) { HeapRegion* new_hr = new_heap_region(i); + OrderAccess::storestore(); _regions.set_by_index(i, new_hr); _allocated_heapregions_length = MAX2(_allocated_heapregions_length, i + 1); } From 6b056f929d0b40736737d3da8315ed09433f28bb Mon Sep 17 00:00:00 2001 From: Max Ockner Date: Tue, 13 Sep 2016 11:04:29 -0400 Subject: [PATCH 32/81] 8163014: Mysterious/wrong value for "long" frame local variable on 64-bit The high byte of a long variable on a 64-bit platform is now zeroed when it is pushed to stack. Reviewed-by: coleenp, dlong --- .../cpu/aarch64/vm/interp_masm_aarch64.cpp | 3 +- .../src/cpu/sparc/vm/interp_masm_sparc.cpp | 2 +- hotspot/src/cpu/x86/vm/interp_masm_x86.cpp | 3 +- .../runtime/LocalLong/LocalLongHelper.java | 99 +++++++++++++++++++ .../test/runtime/LocalLong/LocalLongTest.java | 47 +++++++++ 5 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 hotspot/test/runtime/LocalLong/LocalLongHelper.java create mode 100644 hotspot/test/runtime/LocalLong/LocalLongTest.java diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp index bc8699e4a6b..91e32e94afa 100644 --- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp @@ -326,7 +326,8 @@ void InterpreterMacroAssembler::push_i(Register r) { } void InterpreterMacroAssembler::push_l(Register r) { - str(r, pre(esp, 2 * -wordSize)); + str(zr, pre(esp, -wordSize)); + str(r, pre(esp, -wordsize)); } void InterpreterMacroAssembler::pop_f(FloatRegister r) { diff --git a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp index ba25825ca5a..ef2362897f7 100644 --- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp @@ -359,7 +359,7 @@ void InterpreterMacroAssembler::store_unaligned_long(Register l, Register r1, in #ifdef _LP64 stx(l, r1, offset); // store something more useful here - debug_only(stx(G0, r1, offset+Interpreter::stackElementSize);) + stx(G0, r1, offset+Interpreter::stackElementSize); #else st(l, r1, offset); st(l->successor(), r1, offset + Interpreter::stackElementSize); diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp index f3ae96f05a1..331ac5d3405 100644 --- a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp @@ -611,7 +611,8 @@ void InterpreterMacroAssembler::pop_l(Register r) { void InterpreterMacroAssembler::push_l(Register r) { subptr(rsp, 2 * wordSize); - movq(Address(rsp, 0), r); + movptr(Address(rsp, Interpreter::expr_offset_in_bytes(0)), r ); + movptr(Address(rsp, Interpreter::expr_offset_in_bytes(1)), NULL_WORD ); } void InterpreterMacroAssembler::pop(TosState state) { diff --git a/hotspot/test/runtime/LocalLong/LocalLongHelper.java b/hotspot/test/runtime/LocalLong/LocalLongHelper.java new file mode 100644 index 00000000000..2134aee069e --- /dev/null +++ b/hotspot/test/runtime/LocalLong/LocalLongHelper.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 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 + * 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.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.lang.StackWalker.StackFrame; + +public class LocalLongHelper { + static StackWalker sw; + static Method intValue; + static Method getLocals; + static Class primitiveValueClass; + static Method primitiveType; + static Method getMethodType; + static Field memberName; + static Field offset; + + public static void main(String[] args) throws Throwable { + setupReflectionStatics(); + new LocalLongHelper().longArg(0xC0FFEE, 0x1234567890ABCDEFL); + } + + // locals[2] contains the high byte of the long argument. + public long longArg(int i, long l) throws Throwable { + List frames = sw.walk(s -> s.collect(Collectors.toList())); + Object[] locals = (Object[]) getLocals.invoke(frames.get(0)); + + int locals_2 = (int) intValue.invoke(locals[2]); + if (locals_2 != 0){ + throw new RuntimeException("Expected locals_2 == 0"); + } + return l; // Don't want l to become a dead var + } + + private static void setupReflectionStatics() throws Throwable { + Class liveStackFrameClass = Class.forName("java.lang.LiveStackFrame"); + primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue"); + + getLocals = liveStackFrameClass.getDeclaredMethod("getLocals"); + getLocals.setAccessible(true); + + intValue = primitiveValueClass.getDeclaredMethod("intValue"); + intValue.setAccessible(true); + + Class stackFrameInfoClass = Class.forName("java.lang.StackFrameInfo"); + memberName = stackFrameInfoClass.getDeclaredField("memberName"); + memberName.setAccessible(true); + offset = stackFrameInfoClass.getDeclaredField("bci"); + offset.setAccessible(true); + getMethodType = Class.forName("java.lang.invoke.MemberName").getDeclaredMethod("getMethodType"); + getMethodType.setAccessible(true); + + Class extendedOptionClass = Class.forName("java.lang.StackWalker$ExtendedOption"); + Method ewsNI = StackWalker.class.getDeclaredMethod("newInstance", Set.class, extendedOptionClass); + ewsNI.setAccessible(true); + Field f = extendedOptionClass.getDeclaredField("LOCALS_AND_OPERANDS"); + f.setAccessible(true); + Object localsAndOperandsOption = f.get(null); + + primitiveType = primitiveValueClass.getDeclaredMethod("type"); + primitiveType.setAccessible(true); + + sw = (StackWalker) ewsNI.invoke(null, java.util.Collections.emptySet(), localsAndOperandsOption); + } + + private static String type(Object o) throws Throwable { + if (primitiveValueClass.isInstance(o)) { + final char c = (char) primitiveType.invoke(o); + return String.valueOf(c); + } else if (o != null) { + return o.getClass().getName(); + } else { + return "null"; + } + } +} diff --git a/hotspot/test/runtime/LocalLong/LocalLongTest.java b/hotspot/test/runtime/LocalLong/LocalLongTest.java new file mode 100644 index 00000000000..2c6d8bf2035 --- /dev/null +++ b/hotspot/test/runtime/LocalLong/LocalLongTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/* + * @test LocalLongTest + * @bug 8163014 + * @modules java.base/jdk.internal.misc + * @library /test/lib + * @compile LocalLongHelper.java + * @run driver LocalLongTest + */ + +import jdk.test.lib.Platform; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; + +public class LocalLongTest { + public static void main(String... args) throws Exception { + if (Platform.is64bit()) { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xint", + "LocalLongHelper"); + OutputAnalyzer o = new OutputAnalyzer(pb.start()); + o.shouldHaveExitValue(0); + } + }; +} From c702b1312c08c9bec6f50fabd65930ef51cf0e67 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Tue, 13 Sep 2016 13:10:42 -0700 Subject: [PATCH 33/81] 8165681: ClassLoad and ClassPrepare JVMTI events are missed in the start phase Add the events bits to the early events bits Reviewed-by: dholmes, dsamersoff --- hotspot/src/share/vm/prims/jvmtiEventController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/prims/jvmtiEventController.cpp b/hotspot/src/share/vm/prims/jvmtiEventController.cpp index 006feeab4c0..0f4d4913dbb 100644 --- a/hotspot/src/share/vm/prims/jvmtiEventController.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEventController.cpp @@ -96,7 +96,7 @@ static const jlong INTERP_EVENT_BITS = SINGLE_STEP_BIT | METHOD_ENTRY_BIT | ME static const jlong THREAD_FILTERED_EVENT_BITS = INTERP_EVENT_BITS | EXCEPTION_BITS | MONITOR_BITS | BREAKPOINT_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | THREAD_END_BIT; static const jlong NEED_THREAD_LIFE_EVENTS = THREAD_FILTERED_EVENT_BITS | THREAD_START_BIT; -static const jlong EARLY_EVENT_BITS = CLASS_FILE_LOAD_HOOK_BIT | +static const jlong EARLY_EVENT_BITS = CLASS_FILE_LOAD_HOOK_BIT | CLASS_LOAD_BIT | CLASS_PREPARE_BIT | VM_START_BIT | VM_INIT_BIT | VM_DEATH_BIT | NATIVE_METHOD_BIND_BIT | THREAD_START_BIT | THREAD_END_BIT | COMPILED_METHOD_LOAD_BIT | COMPILED_METHOD_UNLOAD_BIT | From d624da89423dcf07f8ec74fb1ea706b0633332f6 Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Wed, 14 Sep 2016 08:17:50 -0400 Subject: [PATCH 34/81] 8165889: Remove jdk.test.lib.unsafe.UnsafeHelper Remove use of setAccessible() to get Unsafe. Reviewed-by: shade, lfoltan --- hotspot/test/compiler/c2/Test6968348.java | 8 ++------ .../test/compiler/c2/cr8004867/TestIntUnsafeCAS.java | 8 ++------ .../compiler/c2/cr8004867/TestIntUnsafeOrdered.java | 8 ++------ .../compiler/c2/cr8004867/TestIntUnsafeVolatile.java | 8 ++------ .../unsafe/TestUnsafeMismatchedArrayFieldAccess.java | 4 +--- .../jvmci/compilerToVM/GetResolvedJavaMethodTest.java | 3 +-- .../jvmci/compilerToVM/GetResolvedJavaTypeTest.java | 3 +-- .../jvmci/compilerToVM/ResolveFieldInPoolTest.java | 3 +-- .../jvmci/compilerToVM/ResolveMethodTest.java | 3 +-- .../superword/TestVectorizationWithInvariant.java | 3 +-- .../test/compiler/rtm/locking/TestRTMAbortRatio.java | 3 +-- .../compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java | 3 +-- .../rtm/locking/TestRTMDeoptOnLowAbortRatio.java | 3 +-- .../compiler/rtm/locking/TestRTMLockingThreshold.java | 3 +-- .../rtm/locking/TestRTMTotalCountIncrRate.java | 3 +-- .../test/compiler/testlibrary/rtm/XAbortProvoker.java | 5 ++--- hotspot/test/compiler/unsafe/UnsafeRaw.java | 3 +-- .../gc/arguments/TestMaxMinHeapFreeRatioFlags.java | 3 +-- .../gc/arguments/TestTargetSurvivorRatioFlag.java | 3 +-- .../runtime/ErrorHandling/CreateCoredumpOnCrash.java | 3 +-- .../runtime/ErrorHandling/ProblematicFrameTest.java | 3 +-- hotspot/test/runtime/Unsafe/AllocateInstance.java | 3 +-- hotspot/test/runtime/Unsafe/AllocateMemory.java | 3 +-- hotspot/test/runtime/Unsafe/CopyMemory.java | 3 +-- hotspot/test/runtime/Unsafe/DefineClass.java | 3 +-- hotspot/test/runtime/Unsafe/FieldOffset.java | 3 +-- hotspot/test/runtime/Unsafe/GetField.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutAddress.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutBoolean.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutByte.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutChar.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutDouble.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutFloat.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutInt.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutLong.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutObject.java | 3 +-- hotspot/test/runtime/Unsafe/GetPutShort.java | 3 +-- .../test/runtime/Unsafe/GetUncompressedObject.java | 3 +-- hotspot/test/runtime/Unsafe/NestedUnsafe.java | 3 +-- hotspot/test/runtime/Unsafe/PageSize.java | 3 +-- hotspot/test/runtime/Unsafe/PrimitiveHostClass.java | 11 +---------- hotspot/test/runtime/Unsafe/RangeCheck.java | 3 +-- hotspot/test/runtime/Unsafe/Reallocate.java | 3 +-- hotspot/test/runtime/Unsafe/SetMemory.java | 3 +-- hotspot/test/runtime/Unsafe/ThrowException.java | 3 +-- hotspot/test/runtime/contended/Basic.java | 11 +---------- hotspot/test/runtime/contended/DefaultValue.java | 11 +---------- hotspot/test/runtime/contended/Inheritance1.java | 11 +---------- .../test/runtime/defineAnonClass/NestedUnsafe.java | 3 +-- .../test/runtime/defineAnonClass/NestedUnsafe2.java | 3 +-- .../ctw/src/sun/hotspot/tools/ctw/PathHandler.java | 2 +- 51 files changed, 56 insertions(+), 151 deletions(-) diff --git a/hotspot/test/compiler/c2/Test6968348.java b/hotspot/test/compiler/c2/Test6968348.java index be609bfbb8f..29da68e4af2 100644 --- a/hotspot/test/compiler/c2/Test6968348.java +++ b/hotspot/test/compiler/c2/Test6968348.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -38,15 +38,11 @@ import jdk.internal.misc.Unsafe; import java.lang.reflect.Field; public class Test6968348 { - static Unsafe unsafe; + static Unsafe unsafe = Unsafe.getUnsafe(); static final long[] buffer = new long[4096]; static int array_long_base_offset; public static void main(String[] args) throws Exception { - Class c = Test6968348.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe)f.get(c); array_long_base_offset = unsafe.arrayBaseOffset(long[].class); for (int n = 0; n < 100000; n++) { diff --git a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java index 4499ed5b981..ec953664cc2 100644 --- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.java +++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeCAS.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 @@ -50,14 +50,10 @@ public class TestIntUnsafeCAS { private static final int ALIGN_OFF = 8; private static final int UNALIGN_OFF = 5; - private static final Unsafe unsafe; + private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final int BASE; static { try { - Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe)f.get(c); BASE = unsafe.arrayBaseOffset(int[].class); } catch (Exception e) { InternalError err = new InternalError(); diff --git a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java index 3298e1ba94d..4625fcce04d 100644 --- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.java +++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeOrdered.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 @@ -50,14 +50,10 @@ public class TestIntUnsafeOrdered { private static final int ALIGN_OFF = 8; private static final int UNALIGN_OFF = 5; - private static final Unsafe unsafe; + private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final int BASE; static { try { - Class c = Unsafe.class; - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(c); BASE = unsafe.arrayBaseOffset(int[].class); } catch (Exception e) { InternalError err = new InternalError(); diff --git a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java index 6bcd3983a7f..f0272b4faaf 100644 --- a/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.java +++ b/hotspot/test/compiler/c2/cr8004867/TestIntUnsafeVolatile.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 @@ -50,14 +50,10 @@ public class TestIntUnsafeVolatile { private static final int ALIGN_OFF = 8; private static final int UNALIGN_OFF = 5; - private static final Unsafe unsafe; + private static final Unsafe unsafe = Unsafe.getUnsafe(); private static final int BASE; static { try { - Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); - Field f = c.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe)f.get(c); BASE = unsafe.arrayBaseOffset(int[].class); } catch (Exception e) { InternalError err = new InternalError(); diff --git a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java index b56d1b4e5bf..30e7ab0526d 100644 --- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java +++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java @@ -27,7 +27,6 @@ * @bug 8142386 * @summary Unsafe access to an array is wrongly marked as mismatched * @modules java.base/jdk.internal.misc - * @library /test/lib * * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:-TieredCompilation * compiler.intrinsics.unsafe.TestUnsafeMismatchedArrayFieldAccess @@ -36,11 +35,10 @@ package compiler.intrinsics.unsafe; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; public class TestUnsafeMismatchedArrayFieldAccess { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); static { try { diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java index c1c382d768d..48fa29157b8 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java @@ -45,7 +45,6 @@ package compiler.jvmci.compilerToVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; @@ -114,7 +113,7 @@ public class GetResolvedJavaMethodTest { abstract HotSpotResolvedJavaMethod getResolvedJavaMethod(); } - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static final Field METASPACE_METHOD_FIELD; private static final Class TEST_CLASS = GetResolvedJavaMethodTest.class; diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java index 80021f8e79b..38adf2fc720 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java @@ -53,7 +53,6 @@ package compiler.jvmci.compilerToVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; @@ -154,7 +153,7 @@ public class GetResolvedJavaTypeTest { abstract HotSpotResolvedObjectType getResolvedJavaType(); } - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class; /* a compressed parameter for tested method is set to false because diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java index 4985773a831..202eaa003c0 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java @@ -53,7 +53,6 @@ import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; import jdk.internal.misc.Unsafe; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.test.lib.Asserts; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.vm.ci.meta.ConstantPool; @@ -69,7 +68,7 @@ import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CON */ public class ResolveFieldInPoolTest { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); public static void main(String[] args) throws Exception { Map typeTests = new HashMap<>(); diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java index e6416fdbab6..f3fd052a5ae 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java @@ -52,7 +52,6 @@ import compiler.jvmci.common.testcases.SingleSubclassedClass; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; @@ -61,7 +60,7 @@ import java.util.HashSet; import java.util.Set; public class ResolveMethodTest { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); public static void main(String args[]) { ResolveMethodTest test = new ResolveMethodTest(); diff --git a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java index 686e2f465e2..cdc7254df22 100644 --- a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java +++ b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java @@ -34,7 +34,6 @@ package compiler.loopopts.superword; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; public class TestVectorizationWithInvariant { @@ -43,7 +42,7 @@ public class TestVectorizationWithInvariant { private static final long CHAR_ARRAY_OFFSET; static { - unsafe = UnsafeHelper.getUnsafe(); + unsafe = Unsafe.getUnsafe(); BYTE_ARRAY_OFFSET = unsafe.arrayBaseOffset(byte[].class); CHAR_ARRAY_OFFSET = unsafe.arrayBaseOffset(char[].class); } diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java index e45212e268d..b7ce4c62f07 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java @@ -49,7 +49,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -125,7 +124,7 @@ public class TestRTMAbortRatio extends CommandLineOptionTest { public static class Test implements CompilableTest { private static final int TOTAL_ITERATIONS = 10000; private static final int WARMUP_ITERATIONS = 1000; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java index 21c1a612b6f..48aea40ee8a 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java @@ -51,7 +51,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -158,7 +157,7 @@ public class TestRTMAfterNonRTMDeopt extends CommandLineOptionTest { private static int field = 0; private static final int ITERATIONS = 10000; private static final int RANGE_CHECK_AT = ITERATIONS / 2; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); @Override diff --git a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java index 6807d82463a..d936790c07d 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java @@ -48,7 +48,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -133,7 +132,7 @@ public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest { } public static class Test implements CompilableTest { - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); @Override diff --git a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java index 0dfea49a526..d42cde137f4 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java @@ -49,7 +49,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -142,7 +141,7 @@ public class TestRTMLockingThreshold extends CommandLineOptionTest { @SuppressWarnings("UnsuedDeclaration") private static int field = 0; private static final int TOTAL_ITERATIONS = 10000; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); diff --git a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java index e7158d4f670..4e1e0d82fac 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java @@ -49,7 +49,6 @@ import compiler.testlibrary.rtm.predicate.SupportedVM; import jdk.internal.misc.Unsafe; import jdk.test.lib.Asserts; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.test.lib.cli.CommandLineOptionTest; import jdk.test.lib.cli.predicate.AndPredicate; @@ -113,7 +112,7 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest { public static class Test implements CompilableTest { private static final long TOTAL_ITERATIONS = 10000L; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private final Object monitor = new Object(); // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") diff --git a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java index ab476b311c2..c62f7043f83 100644 --- a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java +++ b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.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 @@ -25,7 +25,6 @@ package compiler.testlibrary.rtm; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; /** * Current RTM locking implementation force transaction abort @@ -35,7 +34,7 @@ class XAbortProvoker extends AbortProvoker { // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") private static int field = 0; - private static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); public XAbortProvoker() { this(new Object()); diff --git a/hotspot/test/compiler/unsafe/UnsafeRaw.java b/hotspot/test/compiler/unsafe/UnsafeRaw.java index 3bf38ca941d..82795e98b0a 100644 --- a/hotspot/test/compiler/unsafe/UnsafeRaw.java +++ b/hotspot/test/compiler/unsafe/UnsafeRaw.java @@ -35,7 +35,6 @@ package compiler.unsafe; import jdk.internal.misc.Unsafe; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import java.util.Random; @@ -82,7 +81,7 @@ public class UnsafeRaw { } public static void main(String[] args) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); final int array_size = 128; final int element_size = 4; final int magic = 0x12345678; diff --git a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java index 51cc5550559..714674b853d 100644 --- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java +++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java @@ -37,7 +37,6 @@ import java.util.Collections; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class TestMaxMinHeapFreeRatioFlags { @@ -134,7 +133,7 @@ public class TestMaxMinHeapFreeRatioFlags { */ public static class RatioVerifier { - private static final Unsafe unsafe = UnsafeHelper.getUnsafe(); + private static final Unsafe unsafe = Unsafe.getUnsafe(); // Size of byte array that will be allocated public static final int CHUNK_SIZE = 1024; diff --git a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java index 2f980e5f325..60eef56287c 100644 --- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -46,7 +46,6 @@ import jdk.internal.misc.Unsafe; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.Utils; -import jdk.test.lib.unsafe.UnsafeHelper; import sun.hotspot.WhiteBox; /* In order to test that TargetSurvivorRatio affects survivor space occupancy @@ -249,7 +248,7 @@ public class TestTargetSurvivorRatioFlag { public static class TargetSurvivorRatioVerifier { static final WhiteBox wb = WhiteBox.getWhiteBox(); - static final Unsafe unsafe = UnsafeHelper.getUnsafe(); + static final Unsafe unsafe = Unsafe.getUnsafe(); // Desired size of memory allocated at once public static final int CHUNK_SIZE = 1024; diff --git a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java index a5a19fed1df..60226a33e42 100644 --- a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java +++ b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java @@ -34,13 +34,12 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class CreateCoredumpOnCrash { private static class Crasher { public static void main(String[] args) { - UnsafeHelper.getUnsafe().putInt(0L, 0); + Unsafe.getUnsafe().putInt(0L, 0); } } diff --git a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java index e3b88c29673..2aa02bf7c49 100644 --- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java +++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java @@ -35,14 +35,13 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class ProblematicFrameTest { private static class Crasher { public static void main(String[] args) { - UnsafeHelper.getUnsafe().getInt(0); + Unsafe.getUnsafe().getInt(0); } } diff --git a/hotspot/test/runtime/Unsafe/AllocateInstance.java b/hotspot/test/runtime/Unsafe/AllocateInstance.java index ca2d56dd749..ac684f84144 100644 --- a/hotspot/test/runtime/Unsafe/AllocateInstance.java +++ b/hotspot/test/runtime/Unsafe/AllocateInstance.java @@ -30,12 +30,11 @@ * @run main AllocateInstance */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class AllocateInstance { - static final Unsafe UNSAFE = UnsafeHelper.getUnsafe(); + static final Unsafe UNSAFE = Unsafe.getUnsafe(); class TestClass { public boolean calledConstructor = false; diff --git a/hotspot/test/runtime/Unsafe/AllocateMemory.java b/hotspot/test/runtime/Unsafe/AllocateMemory.java index afb48c24488..6c67427fe58 100644 --- a/hotspot/test/runtime/Unsafe/AllocateMemory.java +++ b/hotspot/test/runtime/Unsafe/AllocateMemory.java @@ -31,13 +31,12 @@ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m AllocateMemory */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class AllocateMemory { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // Allocate a byte, write to the location and read back the value long address = unsafe.allocateMemory(1); diff --git a/hotspot/test/runtime/Unsafe/CopyMemory.java b/hotspot/test/runtime/Unsafe/CopyMemory.java index 0b832c3ee67..447d1c89702 100644 --- a/hotspot/test/runtime/Unsafe/CopyMemory.java +++ b/hotspot/test/runtime/Unsafe/CopyMemory.java @@ -30,14 +30,13 @@ * @run main CopyMemory */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class CopyMemory { final static int LENGTH = 8; public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); long src = unsafe.allocateMemory(LENGTH); long dst = unsafe.allocateMemory(LENGTH); assertNotEquals(src, 0L); diff --git a/hotspot/test/runtime/Unsafe/DefineClass.java b/hotspot/test/runtime/Unsafe/DefineClass.java index 613e9afef6f..5973f666122 100644 --- a/hotspot/test/runtime/Unsafe/DefineClass.java +++ b/hotspot/test/runtime/Unsafe/DefineClass.java @@ -34,13 +34,12 @@ import java.security.ProtectionDomain; import java.io.InputStream; import jdk.test.lib.InMemoryJavaCompiler; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class DefineClass { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); TestClassLoader classloader = new TestClassLoader(); ProtectionDomain pd = new ProtectionDomain(null, null); diff --git a/hotspot/test/runtime/Unsafe/FieldOffset.java b/hotspot/test/runtime/Unsafe/FieldOffset.java index b4d425b8421..546e71cec5b 100644 --- a/hotspot/test/runtime/Unsafe/FieldOffset.java +++ b/hotspot/test/runtime/Unsafe/FieldOffset.java @@ -31,14 +31,13 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import java.lang.reflect.*; import static jdk.test.lib.Asserts.*; public class FieldOffset { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Field[] fields = Test.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { diff --git a/hotspot/test/runtime/Unsafe/GetField.java b/hotspot/test/runtime/Unsafe/GetField.java index 48533068f31..3772fa6e8db 100644 --- a/hotspot/test/runtime/Unsafe/GetField.java +++ b/hotspot/test/runtime/Unsafe/GetField.java @@ -30,14 +30,13 @@ * @run main GetField */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import java.lang.reflect.*; import static jdk.test.lib.Asserts.*; public class GetField { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // Unsafe.INVALID_FIELD_OFFSET is a static final int field, // make sure getField returns the correct field Field field = Unsafe.class.getField("INVALID_FIELD_OFFSET"); diff --git a/hotspot/test/runtime/Unsafe/GetPutAddress.java b/hotspot/test/runtime/Unsafe/GetPutAddress.java index 07fa4afa429..5fdb964037f 100644 --- a/hotspot/test/runtime/Unsafe/GetPutAddress.java +++ b/hotspot/test/runtime/Unsafe/GetPutAddress.java @@ -31,13 +31,12 @@ */ import jdk.test.lib.Platform; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutAddress { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); int addressSize = unsafe.addressSize(); // Ensure the size returned from Unsafe.addressSize is correct assertEquals(unsafe.addressSize(), Platform.is32bit() ? 4 : 8); diff --git a/hotspot/test/runtime/Unsafe/GetPutBoolean.java b/hotspot/test/runtime/Unsafe/GetPutBoolean.java index fe53ad4f911..b5d8b7217ae 100644 --- a/hotspot/test/runtime/Unsafe/GetPutBoolean.java +++ b/hotspot/test/runtime/Unsafe/GetPutBoolean.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutBoolean { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("b1"); diff --git a/hotspot/test/runtime/Unsafe/GetPutByte.java b/hotspot/test/runtime/Unsafe/GetPutByte.java index 9e2909e4e7d..89bf84a546c 100644 --- a/hotspot/test/runtime/Unsafe/GetPutByte.java +++ b/hotspot/test/runtime/Unsafe/GetPutByte.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutByte { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("b"); diff --git a/hotspot/test/runtime/Unsafe/GetPutChar.java b/hotspot/test/runtime/Unsafe/GetPutChar.java index 7fcfeea8c26..5e3c930d1d2 100644 --- a/hotspot/test/runtime/Unsafe/GetPutChar.java +++ b/hotspot/test/runtime/Unsafe/GetPutChar.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutChar { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("c"); diff --git a/hotspot/test/runtime/Unsafe/GetPutDouble.java b/hotspot/test/runtime/Unsafe/GetPutDouble.java index fb7210ae2ff..101b4d76c63 100644 --- a/hotspot/test/runtime/Unsafe/GetPutDouble.java +++ b/hotspot/test/runtime/Unsafe/GetPutDouble.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutDouble { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("d"); diff --git a/hotspot/test/runtime/Unsafe/GetPutFloat.java b/hotspot/test/runtime/Unsafe/GetPutFloat.java index 26821864435..40a35ee5200 100644 --- a/hotspot/test/runtime/Unsafe/GetPutFloat.java +++ b/hotspot/test/runtime/Unsafe/GetPutFloat.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutFloat { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("f"); diff --git a/hotspot/test/runtime/Unsafe/GetPutInt.java b/hotspot/test/runtime/Unsafe/GetPutInt.java index 56b4d762974..8dfa401fee2 100644 --- a/hotspot/test/runtime/Unsafe/GetPutInt.java +++ b/hotspot/test/runtime/Unsafe/GetPutInt.java @@ -30,13 +30,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutInt { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("i"); diff --git a/hotspot/test/runtime/Unsafe/GetPutLong.java b/hotspot/test/runtime/Unsafe/GetPutLong.java index d039e2275aa..e0720e6f317 100644 --- a/hotspot/test/runtime/Unsafe/GetPutLong.java +++ b/hotspot/test/runtime/Unsafe/GetPutLong.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutLong { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("l"); diff --git a/hotspot/test/runtime/Unsafe/GetPutObject.java b/hotspot/test/runtime/Unsafe/GetPutObject.java index 1ffc7b4d756..2ee272e22ec 100644 --- a/hotspot/test/runtime/Unsafe/GetPutObject.java +++ b/hotspot/test/runtime/Unsafe/GetPutObject.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutObject { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Object o = new Object(); Field field = Test.class.getField("o"); diff --git a/hotspot/test/runtime/Unsafe/GetPutShort.java b/hotspot/test/runtime/Unsafe/GetPutShort.java index ae1cb97d9ad..7618e931a48 100644 --- a/hotspot/test/runtime/Unsafe/GetPutShort.java +++ b/hotspot/test/runtime/Unsafe/GetPutShort.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutShort { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Test t = new Test(); Field field = Test.class.getField("s"); diff --git a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java index 380ab8438aa..001d11a4355 100644 --- a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java +++ b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java @@ -30,13 +30,12 @@ import static jdk.test.lib.Asserts.*; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; public class GetUncompressedObject { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // Allocate some memory and fill it with non-zero values. final int size = 32; diff --git a/hotspot/test/runtime/Unsafe/NestedUnsafe.java b/hotspot/test/runtime/Unsafe/NestedUnsafe.java index 98117d0d384..a1a995ab636 100644 --- a/hotspot/test/runtime/Unsafe/NestedUnsafe.java +++ b/hotspot/test/runtime/Unsafe/NestedUnsafe.java @@ -35,7 +35,6 @@ import java.security.ProtectionDomain; import java.io.InputStream; import java.lang.*; import jdk.test.lib.InMemoryJavaCompiler; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; @@ -50,7 +49,7 @@ public class NestedUnsafe { " } } "); public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); Class klass = unsafe.defineAnonymousClass(NestedUnsafe.class, klassbuf, new Object[0]); unsafe.ensureClassInitialized(klass); diff --git a/hotspot/test/runtime/Unsafe/PageSize.java b/hotspot/test/runtime/Unsafe/PageSize.java index a0b487a4dff..009412fd18a 100644 --- a/hotspot/test/runtime/Unsafe/PageSize.java +++ b/hotspot/test/runtime/Unsafe/PageSize.java @@ -31,13 +31,12 @@ */ import java.lang.reflect.Field; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class PageSize { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); int pageSize = unsafe.pageSize(); for (int n = 1; n != 0; n <<= 1) { diff --git a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java index ffe95401556..689c2c1d6fe 100644 --- a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java +++ b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java @@ -39,16 +39,7 @@ import jdk.internal.misc.Unsafe; public class PrimitiveHostClass { - static final Unsafe U; - static { - try { - Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); - theUnsafe.setAccessible(true); - U = (Unsafe) theUnsafe.get(null); - } catch (Exception e) { - throw new AssertionError(e); - } - } + static final Unsafe U = Unsafe.getUnsafe(); public static void testVMAnonymousClass(Class hostClass) { diff --git a/hotspot/test/runtime/Unsafe/RangeCheck.java b/hotspot/test/runtime/Unsafe/RangeCheck.java index e9e9f224a29..8b885bfb3ba 100644 --- a/hotspot/test/runtime/Unsafe/RangeCheck.java +++ b/hotspot/test/runtime/Unsafe/RangeCheck.java @@ -33,7 +33,6 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.Platform; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; @@ -60,7 +59,7 @@ public class RangeCheck { public static class DummyClassWithMainRangeCheck { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); unsafe.getObject(new DummyClassWithMainRangeCheck(), Short.MAX_VALUE); } } diff --git a/hotspot/test/runtime/Unsafe/Reallocate.java b/hotspot/test/runtime/Unsafe/Reallocate.java index 837e587fc28..4381fa124bc 100644 --- a/hotspot/test/runtime/Unsafe/Reallocate.java +++ b/hotspot/test/runtime/Unsafe/Reallocate.java @@ -31,13 +31,12 @@ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m Reallocate */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class Reallocate { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); long address = unsafe.allocateMemory(1); assertNotEquals(address, 0L); diff --git a/hotspot/test/runtime/Unsafe/SetMemory.java b/hotspot/test/runtime/Unsafe/SetMemory.java index 77eed63f60a..8dd3a84c74a 100644 --- a/hotspot/test/runtime/Unsafe/SetMemory.java +++ b/hotspot/test/runtime/Unsafe/SetMemory.java @@ -30,13 +30,12 @@ * @run main SetMemory */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class SetMemory { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); long address = unsafe.allocateMemory(1); assertNotEquals(address, 0L); unsafe.setMemory(address, 1, (byte)17); diff --git a/hotspot/test/runtime/Unsafe/ThrowException.java b/hotspot/test/runtime/Unsafe/ThrowException.java index 465618c3cff..03df26c935c 100644 --- a/hotspot/test/runtime/Unsafe/ThrowException.java +++ b/hotspot/test/runtime/Unsafe/ThrowException.java @@ -30,13 +30,12 @@ * @run main ThrowException */ -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class ThrowException { public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); try { unsafe.throwException(new TestException()); } catch (Throwable t) { diff --git a/hotspot/test/runtime/contended/Basic.java b/hotspot/test/runtime/contended/Basic.java index 5ffba1aa920..6b181aa5aa9 100644 --- a/hotspot/test/runtime/contended/Basic.java +++ b/hotspot/test/runtime/contended/Basic.java @@ -48,20 +48,11 @@ import jdk.internal.vm.annotation.Contended; */ public class Basic { - private static final Unsafe U; + private static final Unsafe U = Unsafe.getUnsafe(); private static int ADDRESS_SIZE; private static int HEADER_SIZE; static { - // steal Unsafe - try { - Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); - unsafe.setAccessible(true); - U = (Unsafe) unsafe.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - // When running with CompressedOops on 64-bit platform, the address size // reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // Try to guess the reference field size with this naive trick. diff --git a/hotspot/test/runtime/contended/DefaultValue.java b/hotspot/test/runtime/contended/DefaultValue.java index b61ab3d4502..28aacd5d88c 100644 --- a/hotspot/test/runtime/contended/DefaultValue.java +++ b/hotspot/test/runtime/contended/DefaultValue.java @@ -49,20 +49,11 @@ import jdk.internal.vm.annotation.Contended; */ public class DefaultValue { - private static final Unsafe U; + private static final Unsafe U = Unsafe.getUnsafe(); private static int ADDRESS_SIZE; private static int HEADER_SIZE; static { - // steal Unsafe - try { - Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); - unsafe.setAccessible(true); - U = (Unsafe) unsafe.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - // When running with CompressedOops on 64-bit platform, the address size // reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // Try to guess the reference field size with this naive trick. diff --git a/hotspot/test/runtime/contended/Inheritance1.java b/hotspot/test/runtime/contended/Inheritance1.java index 57dec49b3ae..fe253c0db2c 100644 --- a/hotspot/test/runtime/contended/Inheritance1.java +++ b/hotspot/test/runtime/contended/Inheritance1.java @@ -49,20 +49,11 @@ import jdk.internal.vm.annotation.Contended; */ public class Inheritance1 { - private static final Unsafe U; + private static final Unsafe U = Unsafe.getUnsafe(); private static int ADDRESS_SIZE; private static int HEADER_SIZE; static { - // steal Unsafe - try { - Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); - unsafe.setAccessible(true); - U = (Unsafe) unsafe.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - // When running with CompressedOops on 64-bit platform, the address size // reported by Unsafe is still 8, while the real reference fields are 4 bytes long. // Try to guess the reference field size with this naive trick. diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java index c25f29a0965..f4a80a61a59 100644 --- a/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe.java @@ -39,7 +39,6 @@ import java.io.InputStream; import java.lang.*; import jdk.test.lib.*; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; // Test that an anonymous class in package 'p' cannot define its own anonymous class @@ -54,7 +53,7 @@ public class NestedUnsafe { " } } "); public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // The anonymous class calls defineAnonymousClass creating a nested anonymous class. byte klassbuf2[] = InMemoryJavaCompiler.compile("p.TestClass2", diff --git a/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java index 33ec95a1005..0d773a56feb 100644 --- a/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java +++ b/hotspot/test/runtime/defineAnonClass/NestedUnsafe2.java @@ -39,7 +39,6 @@ import java.io.InputStream; import java.lang.*; import jdk.test.lib.*; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; // Test that an anonymous class that gets put in its host's package cannot define @@ -54,7 +53,7 @@ public class NestedUnsafe2 { " } } "); public static void main(String args[]) throws Exception { - Unsafe unsafe = UnsafeHelper.getUnsafe(); + Unsafe unsafe = Unsafe.getUnsafe(); // The anonymous class calls defineAnonymousClass creating a nested anonymous class. byte klassbuf2[] = InMemoryJavaCompiler.compile("TestClass2", diff --git a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java index a86010c84ae..36e6ddea8be 100644 --- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java +++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/PathHandler.java @@ -39,7 +39,7 @@ import java.util.regex.Pattern; * Concrete subclasses should implement method {@link #process()}. */ public abstract class PathHandler { - private static final Unsafe UNSAFE = jdk.test.lib.unsafe.UnsafeHelper.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); private static final AtomicLong CLASS_COUNT = new AtomicLong(0L); private static volatile boolean CLASSES_LIMIT_REACHED = false; private static final Pattern JAR_IN_DIR_PATTERN From 228097de7cfaa4c43830d784adf1fb78f885a901 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 14 Sep 2016 10:02:49 -0400 Subject: [PATCH 35/81] 8149607: [Verifier] Do not verify pop, pop2, swap, dup* against top Throw VerifyError exception if type top is illegally popped from the stack. Reviewed-by: coleenp, acorn, ddmitriev --- .../share/vm/classfile/verificationType.hpp | 5 +- .../verifier/popTopTests/PopDupTop.java | 64 +++++ .../verifier/popTopTests/popDupSwapTests.jasm | 244 ++++++++++++++++++ 3 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 hotspot/test/runtime/verifier/popTopTests/PopDupTop.java create mode 100644 hotspot/test/runtime/verifier/popTopTests/popDupSwapTests.jasm diff --git a/hotspot/src/share/vm/classfile/verificationType.hpp b/hotspot/src/share/vm/classfile/verificationType.hpp index a654f48acb5..92e2043334c 100644 --- a/hotspot/src/share/vm/classfile/verificationType.hpp +++ b/hotspot/src/share/vm/classfile/verificationType.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -95,7 +95,8 @@ class VerificationType VALUE_OBJ_CLASS_SPEC { Category2_2nd = (Category2_2ndFlag << 1 * BitsPerByte) | Primitive, // Primitive values (type descriminator stored in most-signifcant bytes) - Bogus = (ITEM_Bogus << 2 * BitsPerByte) | Category1, + // Bogus needs the " | Primitive". Else, is_reference(Bogus) returns TRUE. + Bogus = (ITEM_Bogus << 2 * BitsPerByte) | Primitive, Boolean = (ITEM_Boolean << 2 * BitsPerByte) | Category1, Byte = (ITEM_Byte << 2 * BitsPerByte) | Category1, Short = (ITEM_Short << 2 * BitsPerByte) | Category1, diff --git a/hotspot/test/runtime/verifier/popTopTests/PopDupTop.java b/hotspot/test/runtime/verifier/popTopTests/PopDupTop.java new file mode 100644 index 00000000000..fe72c923a41 --- /dev/null +++ b/hotspot/test/runtime/verifier/popTopTests/PopDupTop.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * @test + * @bug 8149607 + * @summary Throw VerifyError when popping a stack element of TOP + * @compile popDupSwapTests.jasm + * @run main/othervm -Xverify:all PopDupTop + */ + +public class PopDupTop { + + public static void testClass(String class_name, String msg) throws Throwable { + try { + Class newClass = Class.forName(class_name); + throw new RuntimeException("Expected VerifyError exception not thrown for " + msg); + } catch (java.lang.VerifyError e) { + if (!e.getMessage().contains("Bad type on operand stack")) { + throw new RuntimeException( + "Unexpected VerifyError message for " + msg + ": " + e.getMessage()); + } + } + } + + public static void main(String args[]) throws Throwable { + System.out.println("Regression test for bug 8149607"); + + testClass("dup_x1", "dup_x1 of long,ref"); + testClass("dup2toptop", "dup2 of top,top"); + testClass("dup2longtop", "dup2 of long,top"); + testClass("dup2_x1", "dup2_x1 long,ref,ref"); + testClass("dup2_x2", "dup2_x2 top"); + testClass("dup2_x2_long_refs", "dup2_x2 long,ref,ref,ref"); + testClass("poptop", "pop of top"); + testClass("poptoptop", "pop of top,top"); + testClass("pop2toptop", "pop2 of top,top"); + testClass("pop2longtop", "pop2 of long,top"); + testClass("swaptoptop", "swap of top,top"); + testClass("swapinttop", "swap of int,top"); + testClass("swaptopint", "swap of top,int"); + } +} diff --git a/hotspot/test/runtime/verifier/popTopTests/popDupSwapTests.jasm b/hotspot/test/runtime/verifier/popTopTests/popDupSwapTests.jasm new file mode 100644 index 00000000000..6d42b1cd76f --- /dev/null +++ b/hotspot/test/runtime/verifier/popTopTests/popDupSwapTests.jasm @@ -0,0 +1,244 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +// Test that VerifyError is thrown if dup2_x1 tries to replace the filler slot +// of a category 2 value. +// The stack map is long,top,null,null. The verifier should reject dup2_x1's +// (form1) attempt to turn the stack map into long,top,null,null,null,null +public class dup2_x1 version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + lconst_0; + aconst_null; + aconst_null; + dup2_x1; + return; + } +} + + +public class dup2_x2 version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + iconst_0; + lconst_0; + aconst_null; + + stack_frame_type full; + stack_map int, bogus, bogus, null; + locals_map; + + dup2_x2; + return; + } +} + + +// Test that VerifyError is thrown if dup2_x2 tries to replace the filler slot +// of a category 2 value. +// The stack map is long,top,null,null,null. The verifier should reject dup2_x2's +// (form 1) attempt to turn the stack map into long,top,null,null,null,top,null. +public class dup2_x2_long_refs version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + lconst_0; + aconst_null; + aconst_null; + aconst_null; + dup2_x2; + return; + } +} + + +// Test that VerifyError is thrown when dup2 is used to remove the upper +// half of a category 2 type. +public class dup2longtop version 51:0 { + public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 { + lconst_0; + iconst_0; + dup2; + return; + } +} + + +// Test that VerifyError is thrown when dup2 is used to remove top +// because top may be the upper half of a category 2 type. +public class dup2toptop version 51:0 { + public static Method main:"([Ljava/lang/String;)V" stack 5 locals 1 { + // here we have {long, top, null} + // EXECUTION: we have {long, null} + lconst_0; + aconst_null; + + stack_frame_type full; + stack_map bogus, bogus, null; + locals_map bogus; + + // VERIFIER: use form1 of dup2 - {top, top, null} -> {top, top, null, top, null} + // EXECUTION: have {long, null} - no applicable form of dup2 for such type state by JVMS ch. 6 + dup2; + + return; + } +} + + +// Test that VerifyError is thrown if dup_x1 tries to replace the filler slot +// of a category 2 value. +public class dup_x1 version 51:0 { + public static Method run:"()V" stack 6 locals 0 { + lconst_0; + aconst_null; + dup_x1; + return; + } +} + + +// Test that VerifyError is thrown when pop2 is used to remove top +// because top may be the upper half of a category 2 type. +public class pop2longtop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + lconst_0; + iconst_0; + stack_frame_type full; + stack_map long, bogus; + locals_map; + pop2; + return; + } +} // end Class pop2longtop + + + +// Test that VerifyError is thrown when pop2 is used to remove top, top +// because either top may be the upper half of a category 2 type. +public class pop2toptop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, bogus; + locals_map; + pop2; + return; + } +} // end Class pop2toptop + + + +// Test that VerifyError is thrown when pop is used to remove top +// because top may be the upper half of a category 2 type. +public class poptop version 51:0 +{ + + public Method regular:"()V" stack 2 locals 1 + { + iconst_0; + stack_frame_type full; + stack_map bogus; + pop; + return; + } +} // end Class poptop + + + +// Test that VerifyError is thrown when pop is used to remove top, top +// because either top may be the upper half of a category 2 type. +public class poptoptop version 51:0 +{ + + public Method regular:"()V" stack 2 locals 1 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, bogus; + pop; + return; + } +} // end Class poptoptop + + + +// Test that VerifyError is thrown when swap is used to swap int, top +// because top may be the lower half of a category 2 type. +public class swapinttop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map int, bogus; + locals_map; + swap; + return; + } +} // end Class swapinttop + + + +// Test that VerifyError is thrown when swap is used to swap top, int +// because top may be the upper half of a category 2 type. +public class swaptopint version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, int; + locals_map; + swap; + return; + } +} // end Class swaptopint + + + +// Test that VerifyError is thrown when swap is used to swap top, top +// because either top may be the upper half of a category 2 type. +public class swaptoptop version 51:0 +{ + + public Method regular:"()V" stack 6 locals 6 + { + iconst_0; + iconst_0; + stack_frame_type full; + stack_map bogus, bogus; + locals_map; + swap; + return; + } +} // end Class swaptoptop From cc223fcb91bdd6922b4b7a77600517572f5664f1 Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Tue, 13 Sep 2016 16:18:44 -0700 Subject: [PATCH 36/81] 8161029: GPL header missing comma after year Reviewed-by: kbarrett, ehelin --- hotspot/src/share/vm/gc/shared/workerManager.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/shared/workerManager.hpp b/hotspot/src/share/vm/gc/shared/workerManager.hpp index 6758c08c741..e12002739ac 100644 --- a/hotspot/src/share/vm/gc/shared/workerManager.hpp +++ b/hotspot/src/share/vm/gc/shared/workerManager.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 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 From 5bc6d1fab534e61e368b2e195f570af43cb8faef Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Wed, 14 Sep 2016 08:16:16 -0400 Subject: [PATCH 37/81] 8165889: Remove jdk.test.lib.unsafe.UnsafeHelper Remove use of setAccessible() to get Unsafe. Reviewed-by: shade, lfoltan --- jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java b/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java index 1dd55404a6c..31dc1e74038 100644 --- a/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java +++ b/jdk/test/jdk/internal/misc/Unsafe/TestBadHostClass.java @@ -25,7 +25,6 @@ * @test * @bug 8058575 * @summary Test that bad host classes cause exceptions to get thrown. - * @library /test/lib * @modules java.base/jdk.internal.misc * java.base/jdk.internal.org.objectweb.asm * @run main TestBadHostClass @@ -35,7 +34,6 @@ import java.lang.*; import java.lang.reflect.Field; import jdk.internal.misc.Unsafe; -import jdk.test.lib.unsafe.UnsafeHelper; import jdk.internal.org.objectweb.asm.ClassWriter; import static jdk.internal.org.objectweb.asm.Opcodes.*; From f1c915d9f0159898e0881b5f8d35ab69a1433f3a Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Wed, 14 Sep 2016 08:24:55 -0400 Subject: [PATCH 38/81] 8165889: Remove jdk.test.lib.unsafe.UnsafeHelper Remove use of setAccessible() to get Unsafe. Reviewed-by: shade, lfoltan --- .../lib/jdk/test/lib/unsafe/UnsafeHelper.java | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 test/lib/jdk/test/lib/unsafe/UnsafeHelper.java diff --git a/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java b/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java deleted file mode 100644 index 4a6c92644a6..00000000000 --- a/test/lib/jdk/test/lib/unsafe/UnsafeHelper.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 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 - * 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. - */ - -package jdk.test.lib.unsafe; - -import jdk.internal.misc.Unsafe; -import java.lang.reflect.Field; - - -/** - * Helper class for accessing the jdk.internal.misc.Unsafe functionality - */ -public final class UnsafeHelper { - private static Unsafe unsafe = null; - - /** - * @return Unsafe instance. - */ - public static synchronized Unsafe getUnsafe() { - if (unsafe == null) { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(null); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException("Unable to get Unsafe instance.", e); - } - } - return unsafe; - } -} - From 5460376f6190c9200c77f359f3e72be304b54554 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 14 Sep 2016 11:53:20 -0700 Subject: [PATCH 39/81] 8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method Reviewed-by: bchristi, coleenp, dfuchs, sspitsyn --- hotspot/src/share/vm/prims/jvm.h | 3 ++- hotspot/src/share/vm/prims/stackwalk.cpp | 14 ++++++++++++-- hotspot/src/share/vm/prims/stackwalk.hpp | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvm.h b/hotspot/src/share/vm/prims/jvm.h index 7a0da904bd1..5c7aefb7c0a 100644 --- a/hotspot/src/share/vm/prims/jvm.h +++ b/hotspot/src/share/vm/prims/jvm.h @@ -196,7 +196,8 @@ JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements) * java.lang.StackWalker */ enum { - JVM_STACKWALK_FILL_CLASS_REFS_ONLY = 0x2, + JVM_STACKWALK_FILL_CLASS_REFS_ONLY = 0x02, + JVM_STACKWALK_GET_CALLER_CLASS = 0x04, JVM_STACKWALK_SHOW_HIDDEN_FRAMES = 0x20, JVM_STACKWALK_FILL_LIVE_STACK_FRAMES = 0x100 }; diff --git a/hotspot/src/share/vm/prims/stackwalk.cpp b/hotspot/src/share/vm/prims/stackwalk.cpp index 3cce63b69bd..62a0a663cad 100644 --- a/hotspot/src/share/vm/prims/stackwalk.cpp +++ b/hotspot/src/share/vm/prims/stackwalk.cpp @@ -113,7 +113,10 @@ int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream, int bci = stream.bci(); if (method == NULL) continue; - if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) { + + // skip hidden frames for default StackWalker option (i.e. SHOW_HIDDEN_FRAMES + // not set) and when StackWalker::getCallerClass is called + if (!ShowHiddenFrames && (skip_hidden_frames(mode) || get_caller_class(mode))) { if (method->is_hidden()) { if (TraceStackWalk) { tty->print(" hidden method: "); method->print_short_name(); @@ -139,7 +142,14 @@ int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream, Handle stackFrame(frames_array->obj_at(index)); fill_stackframe(stackFrame, method, bci); } else { - assert (use_frames_array(mode) == false, "Bad mode for get caller class"); + assert (use_frames_array(mode) == false, "Bad mode for filling in Class object"); + if (get_caller_class(mode) && index == start_index && method->caller_sensitive()) { + ResourceMark rm(THREAD); + THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), + err_msg("StackWalker::getCallerClass called from @CallerSensitive %s method", + method->name_and_sig_as_C_string())); + } + frames_array->obj_at_put(index, method->method_holder()->java_mirror()); } if (++frames_decoded >= max_nframes) break; diff --git a/hotspot/src/share/vm/prims/stackwalk.hpp b/hotspot/src/share/vm/prims/stackwalk.hpp index cbc4405df81..580c953b197 100644 --- a/hotspot/src/share/vm/prims/stackwalk.hpp +++ b/hotspot/src/share/vm/prims/stackwalk.hpp @@ -82,6 +82,9 @@ private: static void fill_live_stackframe(Handle stackFrame, const methodHandle& method, int bci, javaVFrame* jvf, TRAPS); + static inline bool get_caller_class(int mode) { + return (mode & JVM_STACKWALK_GET_CALLER_CLASS) != 0; + } static inline bool skip_hidden_frames(int mode) { return (mode & JVM_STACKWALK_SHOW_HIDDEN_FRAMES) == 0; } From 6f740b0d0fce3dd40ed4252cf8b4104d00561a97 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 14 Sep 2016 11:53:36 -0700 Subject: [PATCH 40/81] 8157464: Disallow StackWalker.getCallerClass() be called by caller-sensitive method Reviewed-by: bchristi, coleenp, dfuchs, sspitsyn --- .../classes/java/lang/StackStreamFactory.java | 5 +- jdk/src/java.base/share/native/include/jvm.h | 1 + .../CallerSensitiveMethod/Main.java | 35 ++++ .../csm/jdk/test/CallerSensitiveTest.java | 159 ++++++++++++++++++ .../csm/module-info.java | 26 +++ .../src/java.base/java/util/CSM.java | 77 +++++++++ 6 files changed, 300 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/lang/StackWalker/CallerSensitiveMethod/Main.java create mode 100644 jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java create mode 100644 jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/module-info.java create mode 100644 jdk/test/java/lang/StackWalker/CallerSensitiveMethod/src/java.base/java/util/CSM.java diff --git a/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java b/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java index d9aeaf47f4a..55976485d4f 100644 --- a/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java +++ b/jdk/src/java.base/share/classes/java/lang/StackStreamFactory.java @@ -71,6 +71,7 @@ final class StackStreamFactory { // These flags must match the values maintained in the VM @Native private static final int DEFAULT_MODE = 0x0; @Native private static final int FILL_CLASS_REFS_ONLY = 0x2; + @Native private static final int GET_CALLER_CLASS = 0x4; @Native private static final int SHOW_HIDDEN_FRAMES = 0x20; // LambdaForms are hidden by the VM @Native private static final int FILL_LIVE_STACK_FRAMES = 0x100; /* @@ -614,9 +615,7 @@ final class StackStreamFactory { private Class caller; CallerClassFinder(StackWalker walker) { - super(walker, FILL_CLASS_REFS_ONLY); - assert (mode & FILL_CLASS_REFS_ONLY) == FILL_CLASS_REFS_ONLY - : "mode should contain FILL_CLASS_REFS_ONLY"; + super(walker, FILL_CLASS_REFS_ONLY|GET_CALLER_CLASS); } final class ClassBuffer extends FrameBuffer> { diff --git a/jdk/src/java.base/share/native/include/jvm.h b/jdk/src/java.base/share/native/include/jvm.h index bf60a857beb..1d6576a6381 100644 --- a/jdk/src/java.base/share/native/include/jvm.h +++ b/jdk/src/java.base/share/native/include/jvm.h @@ -179,6 +179,7 @@ JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements) */ enum { JVM_STACKWALK_FILL_CLASS_REFS_ONLY = 0x2, + JVM_STACKWALK_GET_CALLER_CLASS = 0x04, JVM_STACKWALK_SHOW_HIDDEN_FRAMES = 0x20, JVM_STACKWALK_FILL_LIVE_STACK_FRAMES = 0x100 }; diff --git a/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/Main.java b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/Main.java new file mode 100644 index 00000000000..8dc52c45d98 --- /dev/null +++ b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/Main.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8157464 + * @summary Basic test for StackWalker.getCallerClass() + * @library src + * @build java.base/java.util.CSM csm/* + * @run main/othervm csm/jdk.test.CallerSensitiveTest + * @run main/othervm csm/jdk.test.CallerSensitiveTest sm + */ +public class Main { +} + diff --git a/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java new file mode 100644 index 00000000000..c09c327ec3a --- /dev/null +++ b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) 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 + * 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. + */ + +package jdk.test; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; +import java.lang.invoke.MethodType; +import java.lang.reflect.Method; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.CSM.Result; +import java.util.function.Supplier; + +/** + * This test invokes StackWalker::getCallerClass via static reference, + * reflection, MethodHandle, lambda. Also verify that + * StackWalker::getCallerClass can't be called from @CallerSensitive method. + */ +public class CallerSensitiveTest { + private static final String NON_CSM_CALLER_METHOD = "getCallerClass"; + private static final String CSM_CALLER_METHOD = "caller"; + + public static void main(String... args) throws Throwable { + boolean sm = false; + if (args.length > 0 && args[0].equals("sm")) { + sm = true; + PermissionCollection perms = new Permissions(); + perms.add(new StackFramePermission("retainClassReference")); + Policy.setPolicy(new Policy() { + @Override + public boolean implies(ProtectionDomain domain, Permission p) { + return perms.implies(p); + } + }); + System.setSecurityManager(new SecurityManager()); + } + + System.err.format("Test %s security manager.%n", + sm ? "with" : "without"); + + CallerSensitiveTest cstest = new CallerSensitiveTest(); + // test static call to java.util.CSM::caller and CSM::getCallerClass + cstest.staticMethodCall(); + // test java.lang.reflect.Method call + cstest.reflectMethodCall(); + // test java.lang.invoke.MethodHandle + cstest.invokeMethodHandle(Lookup1.lookup); + cstest.invokeMethodHandle(Lookup2.lookup); + // test method ref + cstest.lambda(); + + LambdaTest.lambda(); + + if (failed > 0) { + throw new RuntimeException(failed + " test cases failed."); + } + } + + void staticMethodCall() { + java.util.CSM.caller(); + + Result result = java.util.CSM.getCallerClass(); + checkNonCSMCaller(CallerSensitiveTest.class, result); + } + + void reflectMethodCall() throws Throwable { + Method method1 = java.util.CSM.class.getMethod(CSM_CALLER_METHOD); + method1.invoke(null); + + Method method2 = java.util.CSM.class.getMethod(NON_CSM_CALLER_METHOD); + Result result = (Result) method2.invoke(null); + checkNonCSMCaller(CallerSensitiveTest.class, result); + } + + void invokeMethodHandle(Lookup lookup) throws Throwable { + MethodHandle mh1 = lookup.findStatic(java.util.CSM.class, CSM_CALLER_METHOD, + MethodType.methodType(Class.class)); + Class c = (Class)mh1.invokeExact(); + + MethodHandle mh2 = lookup.findStatic(java.util.CSM.class, NON_CSM_CALLER_METHOD, + MethodType.methodType(Result.class)); + Result result = (Result)mh2.invokeExact(); + checkNonCSMCaller(CallerSensitiveTest.class, result); + } + + void lambda() { + Result result = LambdaTest.getCallerClass.get(); + checkNonCSMCaller(CallerSensitiveTest.class, result); + + LambdaTest.caller.get(); + } + + static int failed = 0; + + static void checkNonCSMCaller(Class expected, Result result) { + if (result.callers.size() != 1) { + throw new RuntimeException("Expected result.callers contain one element"); + } + if (expected != result.callers.get(0)) { + System.err.format("ERROR: Expected %s but got %s%n", expected, + result.callers); + result.frames.stream() + .forEach(f -> System.err.println(" " + f)); + failed++; + } + } + + static class Lookup1 { + static Lookup lookup = MethodHandles.lookup(); + } + + static class Lookup2 { + static Lookup lookup = MethodHandles.lookup(); + } + + static class LambdaTest { + static Supplier> caller = java.util.CSM::caller; + static Supplier getCallerClass = java.util.CSM::getCallerClass; + + static void caller() { + caller.get(); + } + static Result getCallerClass() { + return getCallerClass.get(); + } + + static void lambda() { + Result result = LambdaTest.getCallerClass(); + checkNonCSMCaller(LambdaTest.class, result); + + LambdaTest.caller(); + } + } +} diff --git a/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/module-info.java b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/module-info.java new file mode 100644 index 00000000000..5defa50bc41 --- /dev/null +++ b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/csm/module-info.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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 + * 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. + */ + +module csm { + exports jdk.test; +} diff --git a/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/src/java.base/java/util/CSM.java b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/src/java.base/java/util/CSM.java new file mode 100644 index 00000000000..070da3547b4 --- /dev/null +++ b/jdk/test/java/lang/StackWalker/CallerSensitiveMethod/src/java.base/java/util/CSM.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 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 + * 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. + */ + +package java.util; + +import static java.lang.StackWalker.Option.*; +import java.lang.StackWalker.StackFrame; +import java.util.stream.Collectors; + +import jdk.internal.reflect.CallerSensitive; +import jdk.internal.reflect.Reflection; + +public class CSM { + private static StackWalker walker = + StackWalker.getInstance(EnumSet.of(RETAIN_CLASS_REFERENCE, + SHOW_HIDDEN_FRAMES, + SHOW_REFLECT_FRAMES)); + + public static class Result { + public final List> callers; + public final List frames; + Result(List> callers, + List frames) { + this.callers = callers; + this.frames = frames; + } + } + + /** + * Returns the caller of this caller-sensitive method returned by + * by Reflection::getCallerClass. + * + * StackWalker::getCallerClass is expected to throw UOE + */ + @CallerSensitive + public static Class caller() { + Class c1 = Reflection.getCallerClass(); + + try { + Class c2 = walker.getCallerClass(); + throw new RuntimeException("Exception not thrown by StackWalker::getCallerClass"); + } catch (UnsupportedOperationException e) {} + return c1; + } + + /** + * Returns the caller of this non-caller-sensitive method. + */ + public static Result getCallerClass() { + Class caller = walker.getCallerClass(); + return new Result(List.of(caller), dump()); + } + + static List dump() { + return walker.walk(s -> s.collect(Collectors.toList())); + } +} From 73fbb10440ce0c0456ccc280301ab31b4a179072 Mon Sep 17 00:00:00 2001 From: John Jiang Date: Tue, 20 Sep 2016 10:32:52 +0800 Subject: [PATCH 41/81] 8165566: sun/security/ssl/SocketCreation/SocketCreation.java fails intermittently: Address already in use It takes every server to be allocated a free port. Reviewed-by: chegar --- .../ssl/SocketCreation/SocketCreation.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/jdk/test/sun/security/ssl/SocketCreation/SocketCreation.java b/jdk/test/sun/security/ssl/SocketCreation/SocketCreation.java index 65e41b56ac2..94f0323b6dc 100644 --- a/jdk/test/sun/security/ssl/SocketCreation/SocketCreation.java +++ b/jdk/test/sun/security/ssl/SocketCreation/SocketCreation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, 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 @@ -139,7 +139,7 @@ public class SocketCreation { (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); System.out.println("Server: Will call createServerSocket(int)"); - ServerSocket sslServerSocket = sslssf.createServerSocket(serverPort); + ServerSocket sslServerSocket = sslssf.createServerSocket(0); serverPort = sslServerSocket.getLocalPort(); System.out.println("Server: Will accept on SSL server socket..."); @@ -157,7 +157,7 @@ public class SocketCreation { (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); System.out.println("Server: Will call createServerSocket(int, int)"); - ServerSocket sslServerSocket = sslssf.createServerSocket(serverPort, + ServerSocket sslServerSocket = sslssf.createServerSocket(0, 1); serverPort = sslServerSocket.getLocalPort(); @@ -177,7 +177,7 @@ public class SocketCreation { System.out.println("Server: Will call createServerSocket(int, " + " int, InetAddress)"); - ServerSocket sslServerSocket = sslssf.createServerSocket(serverPort, + ServerSocket sslServerSocket = sslssf.createServerSocket(0, 1, InetAddress.getByName("localhost")); serverPort = sslServerSocket.getLocalPort(); @@ -203,14 +203,15 @@ public class SocketCreation { if (sslServerSocket.isBound()) throw new Exception("Server socket is already bound!"); - System.out.println("Server: Will bind SSL server socket to port " + - serverPort + "..."); - - sslServerSocket.bind(new java.net.InetSocketAddress(serverPort)); + sslServerSocket.bind(new java.net.InetSocketAddress(0)); if (!sslServerSocket.isBound()) throw new Exception("Server socket is not bound!"); + serverPort = sslServerSocket.getLocalPort(); + System.out.println("Server: Bound SSL server socket to port " + + serverPort + "..."); + serverReady = true; System.out.println("Server: Will accept on SSL server socket..."); @@ -224,11 +225,10 @@ public class SocketCreation { SSLSocketFactory sslsf = (SSLSocketFactory) SSLSocketFactory.getDefault(); - System.out.println("Server: Will create normal server socket bound" - + " to port " + serverPort + "..."); - - ServerSocket ss = new ServerSocket(serverPort); + ServerSocket ss = new ServerSocket(0); serverPort = ss.getLocalPort(); + System.out.println("Server: Created normal server socket bound" + + " to port " + serverPort + "..."); System.out.println("Server: Will accept on server socket..."); serverReady = true; Socket s = ss.accept(); From dd770672f8649267d1820e1336e6ae365833c839 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Tue, 20 Sep 2016 08:46:33 +0200 Subject: [PATCH 42/81] 8166189: Fix for Bug 8165524 breaks AIX build Reviewed-by: simonis, goetz, mchung, cbensen, dsamersoff --- .../java.base/aix/native/libjli/java_md_aix.c | 85 +++++++++++++++++++ .../java.base/aix/native/libjli/java_md_aix.h | 47 ++++++++++ .../java.base/unix/native/libjli/java_md.h | 15 ++-- 3 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 jdk/src/java.base/aix/native/libjli/java_md_aix.c create mode 100644 jdk/src/java.base/aix/native/libjli/java_md_aix.h diff --git a/jdk/src/java.base/aix/native/libjli/java_md_aix.c b/jdk/src/java.base/aix/native/libjli/java_md_aix.c new file mode 100644 index 00000000000..62cac20ef5d --- /dev/null +++ b/jdk/src/java.base/aix/native/libjli/java_md_aix.c @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016 SAP SE. 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. + */ +#include +#include + +#include "java_md_aix.h" + +static unsigned char dladdr_buffer[0x4000]; + +static int fill_dll_info(void) { + return loadquery(L_GETINFO, dladdr_buffer, sizeof(dladdr_buffer)); +} + +static int dladdr_dont_reload(void *addr, Dl_info *info) { + const struct ld_info *p = (struct ld_info *)dladdr_buffer; + memset((void *)info, 0, sizeof(Dl_info)); + for (;;) { + if (addr >= p->ldinfo_textorg && + addr < (((char*)p->ldinfo_textorg) + p->ldinfo_textsize)) + { + info->dli_fname = p->ldinfo_filename; + return 1; + } + if (!p->ldinfo_next) { + break; + } + p = (struct ld_info *)(((char *)p) + p->ldinfo_next); + } + return 0; +} + +int dladdr(void *addr, Dl_info *info) { + static int loaded = 0; + int rc = 0; + void *addr0; + if (!addr) { + return rc; + } + if (!loaded) { + if (fill_dll_info() == -1) + return rc; + loaded = 1; + } + + // first try with addr on cached data + rc = dladdr_dont_reload(addr, info); + + // addr could be an AIX function descriptor, so try dereferenced version + if (rc == 0) { + addr0 = *((void **)addr); + rc = dladdr_dont_reload(addr0, info); + } + + // if we had no success until now, maybe loadquery info is outdated. + // refresh and retry + if (rc == 0) { + if (fill_dll_info() == -1) + return rc; + rc = dladdr_dont_reload(addr, info); + if (rc == 0) { + rc = dladdr_dont_reload(addr0, info); + } + } + return rc; +} diff --git a/jdk/src/java.base/aix/native/libjli/java_md_aix.h b/jdk/src/java.base/aix/native/libjli/java_md_aix.h new file mode 100644 index 00000000000..c8676ca6bde --- /dev/null +++ b/jdk/src/java.base/aix/native/libjli/java_md_aix.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016 SAP SE. 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. + */ + +#ifndef JAVA_MD_AIX_H +#define JAVA_MD_AIX_H + +/* + * Very limited AIX port of dladdr() for libjli.so. + * + * We try to mimick dladdr(3) on Linux (see http://linux.die.net/man/3/dladdr) + * dladdr(3) is not POSIX but a GNU extension, and is not available on AIX. + * + * We only support Dl_info.dli_fname here as this is the only thing that is + * used of it by libjli.so. A more comprehensive port of dladdr can be found + * in the hotspot implementation which is not available at this place, though. + */ + +typedef struct { + const char *dli_fname; /* file path of loaded library */ + void *dli_fbase; /* unsupported */ + const char *dli_sname; /* unsupported */ + void *dli_saddr; /* unsupported */ +} Dl_info; + +int dladdr(void *addr, Dl_info *info); + +#endif /* JAVA_MD_AIX_H */ diff --git a/jdk/src/java.base/unix/native/libjli/java_md.h b/jdk/src/java.base/unix/native/libjli/java_md.h index ab99dbbdf66..8e95aced972 100644 --- a/jdk/src/java.base/unix/native/libjli/java_md.h +++ b/jdk/src/java.base/unix/native/libjli/java_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, 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 @@ -35,12 +35,12 @@ #include "manifest_info.h" #include "jli_util.h" -#define PATH_SEPARATOR ':' -#define FILESEP "/" -#define FILE_SEPARATOR '/' +#define PATH_SEPARATOR ':' +#define FILESEP "/" +#define FILE_SEPARATOR '/' #define IS_FILE_SEPARATOR(c) ((c) == '/') #ifndef MAXNAMELEN -#define MAXNAMELEN PATH_MAX +#define MAXNAMELEN PATH_MAX #endif #ifdef _LP64 @@ -59,10 +59,13 @@ static jboolean GetJVMPath(const char *jrepath, const char *jvmtype, static jboolean GetJREPath(char *path, jint pathsize, const char * arch, jboolean speculative); +#if defined(_AIX) +#include "java_md_aix.h" +#endif + #ifdef MACOSX #include "java_md_macosx.h" #else /* !MACOSX */ #include "java_md_solinux.h" #endif /* MACOSX */ - #endif /* JAVA_MD_H */ From a68f80b64559acfc4db3be1bf0e6e72a336a152d Mon Sep 17 00:00:00 2001 From: Srinivas Dama Date: Tue, 20 Sep 2016 11:33:03 +0200 Subject: [PATCH 43/81] 8166296: add documentation for Date,RegExp,Error,JSON objects Reviewed-by: mhaupt, sundar --- .../runtime/resources/Functions.properties | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties index d259e7528b5..8f17d34cbc1 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties @@ -190,3 +190,105 @@ Number.prototype.toExponential=returns a string representing the number in decim Number.prototype.toPrecision=returns a string representing the number to a specified precision in fixed-point or exponential notation +Date.parse=returns a number, the UTC time value corresponding to the date and time interpreted from the given string argument, returns NAN if the argument is not recognized + +Date.UTC=returns the number of milliseconds in the given date object since January 1, 1970, 00:00:00 universal time + +Date.now=returns the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC + +Date.prototype.toString=returns the string value representing the given date object + +Date.prototype.toDateString=returns the string value representing the date portion of the given date object + +Date.prototype.toTimeString=returns the string value representing the time portion of the given date object + +Date.prototype.toLocaleString=returns the string value representing the date according to language specific conventions + +Date.prototype.toLocaleDateString=returns the string value representing the date portion of the given date object according to language specific conventions + +Date.prototype.toLocaleTimeString=returns the string value representing the time portion of the given date object according to language specific conventions + +Date.prototype.valueOf=returns the number of milliseconds between January 1, 1970, 00:00:00 UTC and the given date + +Date.prototype.getTime=returns the number representing milliseconds elapsed between January 1, 1970, 00:00:00 UTC and the given date + +Date.prototype.getFullYear=returns the year of the given date according to local time + +Date.prototype.getUTCFullYear=returns the year of the given date according to universal time + +Date.prototype.getMonth=returns the month between 0 to 11 of the given date according to local time + +Date.prototype.getUTCMonth=returns the month between 0 and 11 of the given date according to universal time + +Date.prototype.getDate=returns the day of the month for the given date according to local time + +Date.prototype.getUTCDate=returns the day of the month for the given date according to universal time + +Date.prototype.getDay=returns the day of the week for the given date according to local time, 0 represents Sunday + +Date.prototype.getUTCDay=returns the day of the week for the given date according to universal time, 0 represents Sunday + +Date.prototype.getHours=returns the hour in the given date, according to local time + +Date.prototype.getUTCHours=returns the hour in the given date, according to universal time + +Date.prototype.getMinutes=returns the minutes in the given date, according to local time + +Date.prototype.getUTCMinutes=returns the minutes in the given date, according to universal time + +Date.prototype.getSeconds=returns the seconds in the given date, according to local time + +Date.prototype.getUTCSeconds=returns the seconds in the given date, according to universal time + +Date.prototype.getMilliseconds=returns the milliseconds in the given date, according to local time + +Date.prototype.getUTCMilliseconds=returns the milliseconds in the given date, according to universal time + +Date.prototype.getTimezoneOffset=returns the difference between local time and UTC time in minutes + +Date.prototype.setTime=sets the date object to the time given, which is represented by the number of milliseconds since January 1, 1970, 00:00:00 UTC + +Date.prototype.setMilliseconds=sets the milliseconds for the given date according to local time + +Date.prototype.setUTCMilliseconds=sets the milliseconds for the given date according to universal time + +Date.prototype.setSeconds=sets the seconds for the given date according to local time + +Date.prototype.setUTCSeconds=sets the seconds for the given date according to universal time + +Date.prototype.setMinutes=sets the minutes for the given date according to local time + +Date.prototype.setUTCMinutes=sets the minutes for the given date according to universal time + +Date.prototype.setHours=sets the hours for the given date according to local time + +Date.prototype.setUTCHours=sets the hours for the given date according to universal time + +Date.prototype.setDate=sets the day of the month for the given date according to local time + +Date.prototype.setUTCDate=sets the day of the month for the given date according to universal time + +Date.prototype.setMonth=sets the month for the given date according to the currently set year + +Date.prototype.setUTCMonth=sets the month for the given date according to the universal time + +Date.prototype.setFullYear=sets the full year for the given date according to local time + +Date.prototype.toUTCString=converts the given date to a string using UTC time zone + +Date.prototype.toISOString=returns the string value in ISO 8601 format for the given date according to universal time + +Date.prototype.toJSON=returns the string representation of the given date + +RegExp.prototype.exec=returns an array object containing the results of match of given string against regular expression, null if no match found + +RegExp.prototype.test=returns true if match of given string against regular expression found, else returns false + +RegExp.prototype.toString=returns string representation of regular expression + +Error.prototype.toString=returns string representation of error object + +JSON.parse=returns an object by parsing given string as JSON + +JSON.stringify=returns a JSON string corresponding to the given ECMAScript value + From 3b0d7a4511982c6f7a89a1b33fde893b0d9bb938 Mon Sep 17 00:00:00 2001 From: Sergei Kovalev Date: Tue, 20 Sep 2016 12:56:54 +0300 Subject: [PATCH 44/81] 8166285: Missing dependencies java.httpclient for tests from java/net pachage Reviewed-by: chegar --- .../net/URLClassLoader/definePackage/SplitPackage.java | 1 + jdk/test/java/net/httpclient/HeadersTest1.java | 10 +++++++--- jdk/test/java/net/httpclient/ProxyAuthTest.java | 1 + jdk/test/java/net/httpclient/whitebox/Driver.java | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java index c31441d8b1a..f5af425be46 100644 --- a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java +++ b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java @@ -27,6 +27,7 @@ * @summary Test two URLClassLoader define Package object of the same name * @library /lib/testlibrary * @build CompilerUtils + * @modules jdk.compiler * @run testng SplitPackage */ diff --git a/jdk/test/java/net/httpclient/HeadersTest1.java b/jdk/test/java/net/httpclient/HeadersTest1.java index e3c892ef2c1..2c8540e9e83 100644 --- a/jdk/test/java/net/httpclient/HeadersTest1.java +++ b/jdk/test/java/net/httpclient/HeadersTest1.java @@ -23,9 +23,11 @@ * questions. */ -/** +/* * @test * @bug 8153142 + * @modules java.httpclient + * jdk.httpserver * @run main/othervm HeadersTest1 * @summary HeadersTest1 */ @@ -39,9 +41,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; -import java.net.PasswordAuthentication; import java.net.URI; -import java.net.http.*; +import java.net.http.HttpClient; +import java.net.http.HttpHeaders; +import java.net.http.HttpResponse; +import java.net.http.HttpRequest; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.List; diff --git a/jdk/test/java/net/httpclient/ProxyAuthTest.java b/jdk/test/java/net/httpclient/ProxyAuthTest.java index 42bc0c709db..4301e06d708 100644 --- a/jdk/test/java/net/httpclient/ProxyAuthTest.java +++ b/jdk/test/java/net/httpclient/ProxyAuthTest.java @@ -26,6 +26,7 @@ * @test * @bug 8163561 * @modules java.base/sun.net.www + * java.httpclient * @summary Verify that Proxy-Authenticate header is correctly handled * * @run main/othervm ProxyAuthTest diff --git a/jdk/test/java/net/httpclient/whitebox/Driver.java b/jdk/test/java/net/httpclient/whitebox/Driver.java index fbbdb05dbed..b1cc54be137 100644 --- a/jdk/test/java/net/httpclient/whitebox/Driver.java +++ b/jdk/test/java/net/httpclient/whitebox/Driver.java @@ -24,5 +24,6 @@ /* * @test * @bug 8151299 + * @modules java.httpclient * @run testng java.httpclient/java.net.http.SelectorTest */ From e3124c170aa254a0259ec16aa34ce8e1ab73bf49 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 20 Sep 2016 16:56:04 +0300 Subject: [PATCH 45/81] 8166262: failurehandler should not use jtreg internal API Reviewed-by: sla, dsamersoff --- .../jtreg/GatherDiagnosticInfoObserver.java | 7 +-- .../GatherProcessInfoTimeoutHandler.java | 3 +- .../jdk/test/failurehandler/jtreg/OS.java | 56 +++++++++++++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/OS.java diff --git a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java index bab0b598059..5eb67163f80 100644 --- a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java +++ b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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,8 +26,7 @@ package jdk.test.failurehandler.jtreg; import com.sun.javatest.Harness; import com.sun.javatest.Parameters; import com.sun.javatest.TestResult; -import com.sun.javatest.regtest.RegressionParameters; -import com.sun.javatest.regtest.OS; +import com.sun.javatest.InterviewParameters; import jdk.test.failurehandler.*; import java.io.File; @@ -119,7 +118,7 @@ public class GatherDiagnosticInfoObserver implements Harness.Observer { @Override public void startingTestRun(Parameters params) { // TODO find a better way to get JDKs - RegressionParameters rp = (RegressionParameters) params; + InterviewParameters rp = (InterviewParameters) params; Map map = new HashMap<>(); rp.save(map); compileJdk = (String) map.get("regtest.compilejdk"); diff --git a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.java b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.java index c08418073fe..10c0580dc50 100644 --- a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.java +++ b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherProcessInfoTimeoutHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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,7 +23,6 @@ package jdk.test.failurehandler.jtreg; -import com.sun.javatest.regtest.OS; import com.sun.javatest.regtest.TimeoutHandler; import jdk.test.failurehandler.*; diff --git a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/OS.java b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/OS.java new file mode 100644 index 00000000000..ccc1861f9e7 --- /dev/null +++ b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/OS.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 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 + * 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. + */ + +package jdk.test.failurehandler.jtreg; + +// Stripped down version of jtreg internal class com.sun.javatest.regtest.config.OS +class OS { + public final String family; + + private static OS current; + + public static OS current() { + if (current == null) { + String name = System.getProperty("os.name"); + current = new OS(name); + } + return current; + } + + private OS(String name) { + if (name.startsWith("Linux")) { + family = "linux"; + } else if (name.startsWith("Mac") || name.startsWith("Darwin")) { + family = "mac"; + } else if (name.startsWith("SunOS") || name.startsWith("Solaris")) { + family = "solaris"; + } else if (name.startsWith("Windows")) { + family = "windows"; + } else { + // use first word of name + family = name.replaceFirst("^([^ ]+).*", "$1"); + } + } +} + + From 60ecb416671ecb242bd8dd85bfe3a63f3d615a2d Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 20 Sep 2016 21:53:00 +0530 Subject: [PATCH 46/81] 8166298: 3 nashorn ant tests fail with latest jdk9-dev tip Reviewed-by: hannesw, mhaupt --- nashorn/test/script/trusted/JDK-8006529.js | 33 ++++--- nashorn/test/script/trusted/event_queue.js | 19 ++-- .../trusted/optimistic_recompilation.js | 11 ++- .../jdk/nashorn/test/models/Reflector.java | 92 +++++++++++++++++++ 4 files changed, 129 insertions(+), 26 deletions(-) create mode 100644 nashorn/test/src/jdk/nashorn/test/models/Reflector.java diff --git a/nashorn/test/script/trusted/JDK-8006529.js b/nashorn/test/script/trusted/JDK-8006529.js index 7a4c09404ca..c68d4d4bf35 100644 --- a/nashorn/test/script/trusted/JDK-8006529.js +++ b/nashorn/test/script/trusted/JDK-8006529.js @@ -38,7 +38,7 @@ * We cannot use direct Java class (via dynalink bean linker) to Compiler * and FunctionNode because of package-access check and so reflective calls. */ - +var Reflector = Java.type("jdk.nashorn.test.models.Reflector"); var forName = java.lang.Class["forName(String)"]; var Parser = forName("jdk.nashorn.internal.parser.Parser").static var Compiler = forName("jdk.nashorn.internal.codegen.Compiler").static @@ -69,7 +69,11 @@ var rhsMethod = UnaryNode.class.getMethod("getExpression") var lhsMethod = BinaryNode.class.getMethod("lhs") var binaryRhsMethod = BinaryNode.class.getMethod("rhs") var debugIdMethod = Debug.class.getMethod("id", java.lang.Object.class) -var compilePhases = CompilationPhases.class.getField("COMPILE_UPTO_BYTECODE").get(null); +var compilePhases = Reflector.get(CompilationPhases.class.getField("COMPILE_UPTO_BYTECODE"), null); + +function invoke(m, obj) { + return Reflector.invoke(m, obj); +} // These are method names of methods in FunctionNode class var allAssertionList = ['isVarArg', 'needsParentScope', 'needsCallee', 'hasScopeBlock', 'usesSelfSymbol', 'isSplit', 'hasEval', 'allVarsInScope', 'isStrict'] @@ -86,7 +90,7 @@ var functionNodeMethods = {}; // returns functionNode.getBody().getStatements().get(0) function getFirstFunction(functionNode) { - var f = findFunction(getBodyMethod.invoke(functionNode)) + var f = findFunction(invoke(getBodyMethod, functionNode)) if (f == null) { throw new Error(); } @@ -95,7 +99,7 @@ function getFirstFunction(functionNode) { function findFunction(node) { if(node instanceof Block) { - var stmts = getStatementsMethod.invoke(node) + var stmts = invoke(getStatementsMethod, node) for(var i = 0; i < stmts.size(); ++i) { var retval = findFunction(stmts.get(i)) if(retval != null) { @@ -103,13 +107,13 @@ function findFunction(node) { } } } else if(node instanceof VarNode) { - return findFunction(getInitMethod.invoke(node)) + return findFunction(invoke(getInitMethod, node)) } else if(node instanceof UnaryNode) { - return findFunction(rhsMethod.invoke(node)) + return findFunction(invoke(rhsMethod, node)) } else if(node instanceof BinaryNode) { - return findFunction(lhsMethod.invoke(node)) || findFunction(binaryRhsMethod.invoke(node)) + return findFunction(invoke(lhsMethod, node)) || findFunction(invoke(binaryRhsMethod, node)) } else if(node instanceof ExpressionStatement) { - return findFunction(getExpressionMethod.invoke(node)) + return findFunction(invoke(getExpressionMethod, node)) } else if(node instanceof FunctionNode) { return node } @@ -131,12 +135,12 @@ function compile(source, phases) { var ctxt = getContextMethod.invoke(null); var env = getEnvMethod.invoke(ctxt); - var parser = ParserConstructor.newInstance(env, source, ThrowErrorManager.class.newInstance()); - var func = parseMethod.invoke(parser); + var parser = Reflector.newInstance(ParserConstructor, env, source, ThrowErrorManager.class.newInstance()); + var func = invoke(parseMethod, parser); - var compiler = CompilerConstructor.invoke(null, ctxt, source, false); + var compiler = Reflector.invoke(CompilerConstructor, null, ctxt, source, false); - return compileMethod.invoke(compiler, func, phases); + return Reflector.invoke(compileMethod, compiler, func, phases); }; var allAssertions = (function() { @@ -161,9 +165,10 @@ function test(f) { } for(var assertion in allAssertions) { var expectedValue = !!assertions[assertion] - var actualValue = functionNodeMethods[assertion].invoke(f) + var actualValue = invoke(functionNodeMethods[assertion], f) if(actualValue !== expectedValue) { - throw "Expected " + assertion + " === " + expectedValue + ", got " + actualValue + " for " + f + ":" + debugIdMethod.invoke(null, f); + throw "Expected " + assertion + " === " + expectedValue + ", got " + actualValue + " for " + f + ":" + + invoke(debugIdMethod, null, f); } } } diff --git a/nashorn/test/script/trusted/event_queue.js b/nashorn/test/script/trusted/event_queue.js index 22a86a23787..15843416124 100644 --- a/nashorn/test/script/trusted/event_queue.js +++ b/nashorn/test/script/trusted/event_queue.js @@ -36,6 +36,7 @@ print(Debug); print(); +var Reflector = Java.type("jdk.nashorn.test.models.Reflector"); var forName = java.lang.Class["forName(String)"]; var RuntimeEvent = forName("jdk.nashorn.internal.runtime.events.RuntimeEvent").static; var getValue = RuntimeEvent.class.getMethod("getValue"); @@ -84,19 +85,19 @@ for (var i = 0; i < events.length; i++) { var e = events[i]; print("event #" + i); print("\tevent class=" + e.getClass()); - print("\tvalueClass in event=" + getValueClass.invoke(e)); - var v = getValue.invoke(e); + print("\tvalueClass in event=" + Reflector.invoke(getValueClass, e)); + var v = Reflector.invoke(getValue, e); print("\tclass of value=" + v.getClass()); - print("\treturn type=" + getReturnType.invoke(v)); + print("\treturn type=" + Reflector.invoke(getReturnType, v)); lastInLoop = events[i]; } print(); print("in loop last class = " + lastInLoop.getClass()); -print("in loop last value class = " + getValueClass.invoke(lastInLoop)); -var rexInLoop = getValue.invoke(lastInLoop); +print("in loop last value class = " + Reflector.invoke(getValueClass, lastInLoop)); +var rexInLoop = Reflector.invoke(getValue, lastInLoop); print("in loop rex class = " + rexInLoop.getClass()); -print("in loop rex return type = " + getReturnType.invoke(rexInLoop)); +print("in loop rex return type = " + Reflector.invoke(getReturnType, rexInLoop)); //try last runtime events var last = Debug.getLastRuntimeEvent(); @@ -106,10 +107,10 @@ print(last !== lastInLoop); print(); print("last class = " + last.getClass()); -print("last value class = " + getValueClass.invoke(last)); -var rex = getValue.invoke(last); +print("last value class = " + Reflector.invoke(getValueClass, last)); +var rex = Reflector.invoke(getValue, last); print("rex class = " + rex.getClass()); -print("rex return type = " + getReturnType.invoke(rex)); +print("rex return type = " + Reflector.invoke(getReturnType, rex)); //try the capacity setter print(); diff --git a/nashorn/test/script/trusted/optimistic_recompilation.js b/nashorn/test/script/trusted/optimistic_recompilation.js index 9d9724d0f93..1037133b180 100644 --- a/nashorn/test/script/trusted/optimistic_recompilation.js +++ b/nashorn/test/script/trusted/optimistic_recompilation.js @@ -32,6 +32,7 @@ * @run */ +var Reflector = Java.type("jdk.nashorn.test.models.Reflector"); var forName = java.lang.Class["forName(String)"]; var RuntimeEvent = forName("jdk.nashorn.internal.runtime.events.RuntimeEvent").static; var getValue = RuntimeEvent.class.getMethod("getValue"); @@ -42,6 +43,10 @@ var getReturnValue = RecompilationEvent.class.getMethod("getReturnValue"); var setReturnTypeAndValue = []; var expectedValues = []; +function invoke(m, obj) { + return Reflector.invoke(m, obj); +} + function checkExpectedRecompilation(f, expectedValues, testCase) { Debug.clearRuntimeEvents(); print(f()); @@ -51,12 +56,12 @@ function checkExpectedRecompilation(f, expectedValues, testCase) { if (events.length == expectedValues.length) { for (var i in events) { var e = events[i]; - var returnValue = getReturnValue.invoke(e); + var returnValue = invoke(getReturnValue, e); if (typeof returnValue != 'undefined') { - setReturnTypeAndValue[i] = [getReturnType.invoke(getValue.invoke(e)), returnValue]; + setReturnTypeAndValue[i] = [invoke(getReturnType, invoke(getValue, e)), returnValue]; } else { returnValue = "undefined"; - setReturnTypeAndValue[i] = [getReturnType.invoke(getValue.invoke(e)), returnValue]; + setReturnTypeAndValue[i] = [invoke(getReturnType, invoke(getValue, e)), returnValue]; } if (!setReturnTypeAndValue[i].toString().equals(expectedValues[i].toString())) { fail("The return values are not as expected. Expected value: " + expectedValues[i] + " and got: " + setReturnTypeAndValue[i] + " in test case: " + f); diff --git a/nashorn/test/src/jdk/nashorn/test/models/Reflector.java b/nashorn/test/src/jdk/nashorn/test/models/Reflector.java new file mode 100644 index 00000000000..c2483b53653 --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/test/models/Reflector.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 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 + * 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 jdk.nashorn.test.models; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Module; +import jdk.nashorn.internal.runtime.Context; + +/** + * Few tests reflectively invoke or read fields of Nashorn classes + * and objects - but of packages that are not exported to any module! + * But, those packages are qualified exported to test [java] code + * such as this class. So, test scripts can invoke the methods of this + * class instead. + */ +public final class Reflector { + private Reflector() {} + private static final Module NASHORN_MOD = Context.class.getModule(); + + public static Object invoke(Method m, Object self, Object...args) { + if (m.getDeclaringClass().getModule() != NASHORN_MOD) { + throw new RuntimeException(m + " is not from Nashorn module"); + } + + try { + return m.invoke(self, args); + } catch (final Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new RuntimeException(e); + } + } + } + + public static Object newInstance(Constructor c, Object...args) { + if (c.getDeclaringClass().getModule() != NASHORN_MOD) { + throw new RuntimeException(c + " is not from Nashorn module"); + } + + try { + return c.newInstance(args); + } catch (final Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new RuntimeException(e); + } + } + } + + public static Object get(Field f, Object self) { + if (f.getDeclaringClass().getModule() != NASHORN_MOD) { + throw new RuntimeException(f + " is not from Nashorn module"); + } + + try { + return f.get(self); + } catch (final Exception e) { + if (e instanceof RuntimeException) { + throw (RuntimeException)e; + } else { + throw new RuntimeException(e); + } + } + } +} From 3e5ef4867fe60ab4e16244a32150e2f0dfa1cf5a Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Wed, 21 Sep 2016 08:55:47 +0800 Subject: [PATCH 47/81] 8166248: tools/pack200/Pack200Test.java fails on Win32: Could not reserve enough space Reviewed-by: ksrini --- jdk/test/tools/pack200/Pack200Test.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/tools/pack200/Pack200Test.java b/jdk/test/tools/pack200/Pack200Test.java index 5c50da1e503..0c18de51899 100644 --- a/jdk/test/tools/pack200/Pack200Test.java +++ b/jdk/test/tools/pack200/Pack200Test.java @@ -24,6 +24,7 @@ /* * @test * @bug 6521334 6712743 8007902 8151901 + * @requires (sun.arch.data.model == "64" & os.maxMemory >= 4g) * @summary test general packer/unpacker functionality * using native and java unpackers * @compile -XDignore.symbol.file Utils.java Pack200Test.java From 0d0e86808b4d81a7a8cb39398ee5e46dbac2a301 Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Wed, 21 Sep 2016 02:19:59 -0700 Subject: [PATCH 48/81] 8166359: java/net/URLPermission/nstest/lookup.sh fails if proxy is set since fix for JDK-8161016 Reviewed-by: chegar --- jdk/test/java/net/URLPermission/nstest/LookupTest.java | 3 ++- jdk/test/java/net/URLPermission/nstest/LookupTestHosts | 2 -- jdk/test/java/net/URLPermission/nstest/lookup.sh | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 jdk/test/java/net/URLPermission/nstest/LookupTestHosts diff --git a/jdk/test/java/net/URLPermission/nstest/LookupTest.java b/jdk/test/java/net/URLPermission/nstest/LookupTest.java index d5b9141c1d4..eebcff5249f 100644 --- a/jdk/test/java/net/URLPermission/nstest/LookupTest.java +++ b/jdk/test/java/net/URLPermission/nstest/LookupTest.java @@ -37,6 +37,7 @@ public class LookupTest { String url, boolean throwsSecException, boolean throwsIOException) { try { + ProxySelector.setDefault(null); URL u = new URL(url); System.err.println ("Connecting to " + u); URLConnection urlc = u.openConnection(); @@ -71,7 +72,7 @@ public class LookupTest { System.out.print(port); } else if (cmd.equals("-runtest")) { port = Integer.parseInt(args[1]); - String hostsFileName = System.getProperty("test.src", ".") + "/LookupTestHosts"; + String hostsFileName = System.getProperty("user.dir", ".") + "/LookupTestHosts"; System.setProperty("jdk.net.hosts.file", hostsFileName); addMappingToHostsFile("allowedAndFound.com", "127.0.0.1", hostsFileName, false); addMappingToHostsFile("notAllowedButFound.com", "99.99.99.99", hostsFileName, true); diff --git a/jdk/test/java/net/URLPermission/nstest/LookupTestHosts b/jdk/test/java/net/URLPermission/nstest/LookupTestHosts deleted file mode 100644 index 0e64bb8c49f..00000000000 --- a/jdk/test/java/net/URLPermission/nstest/LookupTestHosts +++ /dev/null @@ -1,2 +0,0 @@ -127.0.0.1 allowedAndFound.com -99.99.99.99 notAllowedButFound.com diff --git a/jdk/test/java/net/URLPermission/nstest/lookup.sh b/jdk/test/java/net/URLPermission/nstest/lookup.sh index 798e1c168f6..a6b495c9f35 100644 --- a/jdk/test/java/net/URLPermission/nstest/lookup.sh +++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh @@ -48,6 +48,7 @@ cat << POLICY > policy grant { permission java.net.URLPermission "http://allowedAndFound.com:${port}/-", "*:*"; permission java.net.URLPermission "http://allowedButNotfound.com:${port}/-", "*:*"; + permission java.net.NetPermission "setProxySelector"; permission java.io.FilePermission "<>", "read,write,delete"; permission java.util.PropertyPermission "java.io.tmpdir", "read"; From 06d76af9058ae53ca279307a14c5077978fa68e4 Mon Sep 17 00:00:00 2001 From: Alan Burlison Date: Wed, 21 Sep 2016 14:16:05 +0200 Subject: [PATCH 49/81] 8165163: Solaris11 and onwards provide CUPS by default, references to csw and sfw versions should be removed Reviewed-by: erikj --- README-builds.html | 3 +-- README-builds.md | 3 +-- common/autoconf/generated-configure.sh | 19 +------------------ common/autoconf/lib-cups.m4 | 15 --------------- 4 files changed, 3 insertions(+), 37 deletions(-) diff --git a/README-builds.html b/README-builds.html index 42cc0f11b7c..d29aeb2855b 100644 --- a/README-builds.html +++ b/README-builds.html @@ -626,8 +626,7 @@ number of different configurations, e.g. debug, release, 32, 64, etc.

The Common UNIX Printing System (CUPS) Headers are required for building the OpenJDK on Solaris and Linux. The Solaris header files can be obtained by - installing the package SFWcups from the Solaris Software Companion - CD/DVD, these often will be installed into the directory /opt/sfw/cups.

+ installing the package print/cups.

The CUPS header files can always be downloaded from www.cups.org.

diff --git a/README-builds.md b/README-builds.md index bddb467612e..49b9fa4a9f3 100644 --- a/README-builds.md +++ b/README-builds.md @@ -560,8 +560,7 @@ Some of the more commonly used `configure` options are: > The Common UNIX Printing System (CUPS) Headers are required for building the OpenJDK on Solaris and Linux. The Solaris header files can be obtained by - installing the package **SFWcups** from the Solaris Software Companion - CD/DVD, these often will be installed into the directory `/opt/sfw/cups`. + installing the package **print/cups**. > The CUPS header files can always be downloaded from [www.cups.org](http://www.cups.org). diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index b233cdcd433..5ecc4e8687b 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5095,7 +5095,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1472718471 +DATE_WHEN_GENERATED=1474459654 ############################################################################### # @@ -56909,23 +56909,6 @@ fi done - fi - if test "x$CUPS_FOUND" = xno; then - # Getting nervous now? Lets poke around for standard Solaris third-party - # package installation locations. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cups headers" >&5 -$as_echo_n "checking for cups headers... " >&6; } - if test -s $SYSROOT/opt/sfw/cups/include/cups/cups.h; then - # An SFW package seems to be installed! - CUPS_FOUND=yes - CUPS_CFLAGS="-I$SYSROOT/opt/sfw/cups/include" - elif test -s $SYSROOT/opt/csw/include/cups/cups.h; then - # A CSW package seems to be installed! - CUPS_FOUND=yes - CUPS_CFLAGS="-I$SYSROOT/opt/csw/include" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_FOUND" >&5 -$as_echo "$CUPS_FOUND" >&6; } fi if test "x$CUPS_FOUND" = xno; then diff --git a/common/autoconf/lib-cups.m4 b/common/autoconf/lib-cups.m4 index 8a61bc04104..0a7df8b381b 100644 --- a/common/autoconf/lib-cups.m4 +++ b/common/autoconf/lib-cups.m4 @@ -75,21 +75,6 @@ AC_DEFUN_ONCE([LIB_SETUP_CUPS], DEFAULT_CUPS=yes ]) fi - if test "x$CUPS_FOUND" = xno; then - # Getting nervous now? Lets poke around for standard Solaris third-party - # package installation locations. - AC_MSG_CHECKING([for cups headers]) - if test -s $SYSROOT/opt/sfw/cups/include/cups/cups.h; then - # An SFW package seems to be installed! - CUPS_FOUND=yes - CUPS_CFLAGS="-I$SYSROOT/opt/sfw/cups/include" - elif test -s $SYSROOT/opt/csw/include/cups/cups.h; then - # A CSW package seems to be installed! - CUPS_FOUND=yes - CUPS_CFLAGS="-I$SYSROOT/opt/csw/include" - fi - AC_MSG_RESULT([$CUPS_FOUND]) - fi if test "x$CUPS_FOUND" = xno; then HELP_MSG_MISSING_DEPENDENCY([cups]) AC_MSG_ERROR([Could not find cups! $HELP_MSG ]) From 731eb07adc327ee14951d06935c04d9c32fa6a36 Mon Sep 17 00:00:00 2001 From: Alan Burlison Date: Wed, 21 Sep 2016 14:20:27 +0200 Subject: [PATCH 50/81] 8165161: Solaris: /usr/ccs /opt/sfw and /opt/csw are dead, references should be expunged Reviewed-by: erikj --- Makefile | 4 +- README-builds.html | 3 +- README-builds.md | 3 +- common/autoconf/basics.m4 | 5 - common/autoconf/flags.m4 | 3 +- common/autoconf/generated-configure.sh | 365 +------------------------ common/autoconf/lib-freetype.m4 | 5 - common/autoconf/lib-x11.m4 | 4 +- common/autoconf/toolchain.m4 | 8 - 9 files changed, 10 insertions(+), 390 deletions(-) diff --git a/Makefile b/Makefile index 2460cd414d8..ebe52d5d7f2 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,8 @@ ### It also performs some sanity checks on make. ### -# The shell code below will be executed on /usr/ccs/bin/make on Solaris, but not in GNU Make. -# /usr/ccs/bin/make lacks basically every other flow control mechanism. +# The shell code below will be executed on /usr/bin/make on Solaris, but not in GNU Make. +# /usr/bin/make lacks basically every other flow control mechanism. .TEST_FOR_NON_GNUMAKE:sh=echo You are not using GNU Make/gmake, this is a requirement. Check your path. 1>&2 && exit 1 # The .FEATURES variable is likely to be unique for GNU Make. diff --git a/README-builds.html b/README-builds.html index d29aeb2855b..6d7d5b52461 100644 --- a/README-builds.html +++ b/README-builds.html @@ -1110,8 +1110,7 @@ version, see "Building GNU make".
  • Place the location of the GNU make binary in the PATH.
  • Solaris: Do NOT use /usr/bin/make on Solaris. If your Solaris system has the software from the Solaris Developer Companion CD installed, you -should try and use gmake which will be located in either the /usr/bin, -/opt/sfw/bin or /usr/sfw/bin directory.
  • +should try and use /usr/bin/gmake or /usr/gnu/bin/make.
  • Windows: Make sure you start your build inside a bash shell.
  • Mac OS X: The XCode "command line tools" must be installed on your Mac.
  • diff --git a/README-builds.md b/README-builds.md index 49b9fa4a9f3..c6907cd7ab2 100644 --- a/README-builds.md +++ b/README-builds.md @@ -1016,8 +1016,7 @@ about using GNU make: * Place the location of the GNU make binary in the `PATH`. * **Solaris:** Do NOT use `/usr/bin/make` on Solaris. If your Solaris system has the software from the Solaris Developer Companion CD installed, you - should try and use `gmake` which will be located in either the `/usr/bin`, - `/opt/sfw/bin` or `/usr/sfw/bin` directory. + should try and use `/usr/bin/gmake` or `/usr/gnu/bin/make`. * **Windows:** Make sure you start your build inside a bash shell. * **Mac OS X:** The XCode "command line tools" must be installed on your Mac. diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 0c1477f5a58..8404ca42d02 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -750,11 +750,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], # Prepend the extra path to the global path BASIC_PREPEND_TO_PATH([PATH],$EXTRA_PATH) - if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then - # Add extra search paths on solaris for utilities like ar, as, dtrace etc... - PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin:/usr/sbin" - fi - AC_MSG_CHECKING([for sysroot]) AC_MSG_RESULT([$SYSROOT]) AC_MSG_CHECKING([for toolchain path]) diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index cc32499be7b..dbb65dfe1ec 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -88,8 +88,7 @@ AC_DEFUN([FLAGS_SETUP_SYSROOT_FLAGS], # inlining of system functions and intrinsics. $1SYSROOT_CFLAGS="-I-xbuiltin -I[$]$1SYSROOT/usr/include" $1SYSROOT_LDFLAGS="-L[$]$1SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L[$]$1SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" + -L[$]$1SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR" fi elif test "x$TOOLCHAIN_TYPE" = xgcc; then $1SYSROOT_CFLAGS="--sysroot=[$]$1SYSROOT" diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 5ecc4e8687b..5d6d6913fe2 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5095,7 +5095,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1474459654 +DATE_WHEN_GENERATED=1474460325 ############################################################################### # @@ -17213,11 +17213,6 @@ $as_echo "$as_me: WARNING: Both SYSROOT and --with-sdk-name are set, only SYSROO fi - if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then - # Add extra search paths on solaris for utilities like ar, as, dtrace etc... - PATH="$PATH:/usr/ccs/bin:/usr/sfw/bin:/opt/csw/bin:/usr/sbin" - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SYSROOT" >&5 @@ -31475,8 +31470,7 @@ fi # inlining of system functions and intrinsics. SYSROOT_CFLAGS="-I-xbuiltin -I$SYSROOT/usr/include" SYSROOT_LDFLAGS="-L$SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" + -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR" fi elif test "x$TOOLCHAIN_TYPE" = xgcc; then SYSROOT_CFLAGS="--sysroot=$SYSROOT" @@ -32992,14 +32986,6 @@ $as_echo "$as_me: or run \"bash.exe -l\" from a VS command prompt and then run c fi - # For solaris we really need solaris tools, and not the GNU equivalent. - # The build tools on Solaris reside in /usr/ccs (C Compilation System), - # so add that to path before starting to probe. - # FIXME: This was originally only done for AS,NM,GNM,STRIP,OBJCOPY,OBJDUMP. - if test "x$OPENJDK_BUILD_OS" = xsolaris; then - PATH="/usr/ccs/bin:$PATH" - fi - # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to # override all other locations. if test "x$TOOLCHAIN_PATH" != x; then @@ -44000,8 +43986,7 @@ $as_echo "$BUILD_DEVKIT_ROOT" >&6; } # inlining of system functions and intrinsics. BUILD_SYSROOT_CFLAGS="-I-xbuiltin -I$BUILD_SYSROOT/usr/include" BUILD_SYSROOT_LDFLAGS="-L$BUILD_SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L$BUILD_SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L$BUILD_SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" + -L$BUILD_SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR" fi elif test "x$TOOLCHAIN_TYPE" = xgcc; then BUILD_SYSROOT_CFLAGS="--sysroot=$BUILD_SYSROOT" @@ -56730,9 +56715,7 @@ fi if test "x$OPENJDK_TARGET_OS" = xsolaris; then OPENWIN_HOME="/usr/openwin" X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions" - X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \ - -R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \ + X_LIBS="-L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \ -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR" fi @@ -61149,346 +61132,6 @@ $as_echo "$FREETYPE_LIB_PATH" >&6; } fi fi - if test "x$FOUND_FREETYPE" != xyes; then - FREETYPE_BASE_DIR="$SYSROOT/usr/sfw" - - POTENTIAL_FREETYPE_INCLUDE_PATH="$FREETYPE_BASE_DIR/include" - POTENTIAL_FREETYPE_LIB_PATH="$FREETYPE_BASE_DIR/lib" - METHOD="well-known location" - - # Let's start with an optimistic view of the world :-) - FOUND_FREETYPE=yes - - # First look for the canonical freetype main include file ft2build.h. - if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then - # Oh no! Let's try in the freetype2 directory. This is needed at least at Mac OS X Yosemite. - POTENTIAL_FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH/freetype2" - if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then - # Fail. - FOUND_FREETYPE=no - fi - fi - - if test "x$FOUND_FREETYPE" = xyes; then - # Include file found, let's continue the sanity check. - { $as_echo "$as_me:${as_lineno-$LINENO}: Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD" >&5 -$as_echo "$as_me: Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD" >&6;} - - # Reset to default value - FREETYPE_BASE_NAME=freetype - FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}" - if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then - if test "x$OPENJDK_TARGET_OS" = xmacosx \ - && test -s "$POTENTIAL_FREETYPE_LIB_PATH/${LIBRARY_PREFIX}freetype.6${SHARED_LIBRARY_SUFFIX}"; then - # On Mac OS X Yosemite, the symlink from libfreetype.dylib to libfreetype.6.dylib disappeared. Check - # for the .6 version explicitly. - FREETYPE_BASE_NAME=freetype.6 - FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}" - { $as_echo "$as_me:${as_lineno-$LINENO}: Compensating for missing symlink by using version 6 explicitly" >&5 -$as_echo "$as_me: Compensating for missing symlink by using version 6 explicitly" >&6;} - else - { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location." >&5 -$as_echo "$as_me: Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location." >&6;} - FOUND_FREETYPE=no - fi - else - if test "x$OPENJDK_TARGET_OS" = xwindows; then - # On Windows, we will need both .lib and .dll file. - if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location." >&5 -$as_echo "$as_me: Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location." >&6;} - FOUND_FREETYPE=no - fi - elif test "x$OPENJDK_TARGET_OS" = xsolaris \ - && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then - # Found lib in isa dir, use that instead. - POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR" - { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead" >&5 -$as_echo "$as_me: Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead" >&6;} - fi - fi - fi - - if test "x$FOUND_FREETYPE" = xyes; then - - # Only process if variable expands to non-empty - - if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x; then - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - - # Input might be given as Windows format, start by converting to - # unix format. - path="$POTENTIAL_FREETYPE_INCLUDE_PATH" - new_path=`$CYGPATH -u "$path"` - - # Cygwin tries to hide some aspects of the Windows file system, such that binaries are - # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered - # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then - # "foo.exe" is OK but "foo" is an error. - # - # This test is therefore slightly more accurate than "test -f" to check for file precense. - # It is also a way to make sure we got the proper file name for the real test later on. - test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` - if test "x$test_shortpath" = x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&5 -$as_echo "$as_me: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&6;} - as_fn_error $? "Cannot locate the the path of POTENTIAL_FREETYPE_INCLUDE_PATH" "$LINENO" 5 - fi - - # Call helper function which possibly converts this using DOS-style short mode. - # If so, the updated path is stored in $new_path. - - input_path="$new_path" - # Check if we need to convert this using DOS-style short mode. If the path - # contains just simple characters, use it. Otherwise (spaces, weird characters), - # take no chances and rewrite it. - # Note: m4 eats our [], so we need to use [ and ] instead. - has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` - if test "x$has_forbidden_chars" != x; then - # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) - shortmode_path=`$CYGPATH -s -m -a "$input_path"` - path_after_shortmode=`$CYGPATH -u "$shortmode_path"` - if test "x$path_after_shortmode" != "x$input_to_shortpath"; then - # Going to short mode and back again did indeed matter. Since short mode is - # case insensitive, let's make it lowercase to improve readability. - shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Now convert it back to Unix-style (cygpath) - input_path=`$CYGPATH -u "$shortmode_path"` - new_path="$input_path" - fi - fi - - test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` - if test "x$test_cygdrive_prefix" = x; then - # As a simple fix, exclude /usr/bin since it's not a real path. - if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then - # The path is in a Cygwin special directory (e.g. /home). We need this converted to - # a path prefixed by /cygdrive for fixpath to work. - new_path="$CYGWIN_ROOT_PATH$input_path" - fi - fi - - - if test "x$path" != "x$new_path"; then - POTENTIAL_FREETYPE_INCLUDE_PATH="$new_path" - { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&5 -$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&6;} - fi - - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - - path="$POTENTIAL_FREETYPE_INCLUDE_PATH" - has_colon=`$ECHO $path | $GREP ^.:` - new_path="$path" - if test "x$has_colon" = x; then - # Not in mixed or Windows style, start by that. - new_path=`cmd //c echo $path` - fi - - - input_path="$new_path" - # Check if we need to convert this using DOS-style short mode. If the path - # contains just simple characters, use it. Otherwise (spaces, weird characters), - # take no chances and rewrite it. - # Note: m4 eats our [], so we need to use [ and ] instead. - has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` - if test "x$has_forbidden_chars" != x; then - # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) - new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - fi - - - windows_path="$new_path" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - unix_path=`$CYGPATH -u "$windows_path"` - new_path="$unix_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` - new_path="$unix_path" - fi - - if test "x$path" != "x$new_path"; then - POTENTIAL_FREETYPE_INCLUDE_PATH="$new_path" - { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&5 -$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_INCLUDE_PATH to \"$new_path\"" >&6;} - fi - - # Save the first 10 bytes of this path to the storage, so fixpath can work. - all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") - - else - # We're on a unix platform. Hooray! :) - path="$POTENTIAL_FREETYPE_INCLUDE_PATH" - has_space=`$ECHO "$path" | $GREP " "` - if test "x$has_space" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&5 -$as_echo "$as_me: The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is invalid." >&6;} - as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 - fi - - # Use eval to expand a potential ~ - eval path="$path" - if test ! -f "$path" && test ! -d "$path"; then - as_fn_error $? "The path of POTENTIAL_FREETYPE_INCLUDE_PATH, which resolves as \"$path\", is not found." "$LINENO" 5 - fi - - if test -d "$path"; then - POTENTIAL_FREETYPE_INCLUDE_PATH="`cd "$path"; $THEPWDCMD -L`" - else - dir="`$DIRNAME "$path"`" - base="`$BASENAME "$path"`" - POTENTIAL_FREETYPE_INCLUDE_PATH="`cd "$dir"; $THEPWDCMD -L`/$base" - fi - fi - fi - - - # Only process if variable expands to non-empty - - if test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - - # Input might be given as Windows format, start by converting to - # unix format. - path="$POTENTIAL_FREETYPE_LIB_PATH" - new_path=`$CYGPATH -u "$path"` - - # Cygwin tries to hide some aspects of the Windows file system, such that binaries are - # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered - # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then - # "foo.exe" is OK but "foo" is an error. - # - # This test is therefore slightly more accurate than "test -f" to check for file precense. - # It is also a way to make sure we got the proper file name for the real test later on. - test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` - if test "x$test_shortpath" = x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&5 -$as_echo "$as_me: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&6;} - as_fn_error $? "Cannot locate the the path of POTENTIAL_FREETYPE_LIB_PATH" "$LINENO" 5 - fi - - # Call helper function which possibly converts this using DOS-style short mode. - # If so, the updated path is stored in $new_path. - - input_path="$new_path" - # Check if we need to convert this using DOS-style short mode. If the path - # contains just simple characters, use it. Otherwise (spaces, weird characters), - # take no chances and rewrite it. - # Note: m4 eats our [], so we need to use [ and ] instead. - has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` - if test "x$has_forbidden_chars" != x; then - # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) - shortmode_path=`$CYGPATH -s -m -a "$input_path"` - path_after_shortmode=`$CYGPATH -u "$shortmode_path"` - if test "x$path_after_shortmode" != "x$input_to_shortpath"; then - # Going to short mode and back again did indeed matter. Since short mode is - # case insensitive, let's make it lowercase to improve readability. - shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Now convert it back to Unix-style (cygpath) - input_path=`$CYGPATH -u "$shortmode_path"` - new_path="$input_path" - fi - fi - - test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` - if test "x$test_cygdrive_prefix" = x; then - # As a simple fix, exclude /usr/bin since it's not a real path. - if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then - # The path is in a Cygwin special directory (e.g. /home). We need this converted to - # a path prefixed by /cygdrive for fixpath to work. - new_path="$CYGWIN_ROOT_PATH$input_path" - fi - fi - - - if test "x$path" != "x$new_path"; then - POTENTIAL_FREETYPE_LIB_PATH="$new_path" - { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&5 -$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&6;} - fi - - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - - path="$POTENTIAL_FREETYPE_LIB_PATH" - has_colon=`$ECHO $path | $GREP ^.:` - new_path="$path" - if test "x$has_colon" = x; then - # Not in mixed or Windows style, start by that. - new_path=`cmd //c echo $path` - fi - - - input_path="$new_path" - # Check if we need to convert this using DOS-style short mode. If the path - # contains just simple characters, use it. Otherwise (spaces, weird characters), - # take no chances and rewrite it. - # Note: m4 eats our [], so we need to use [ and ] instead. - has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` - if test "x$has_forbidden_chars" != x; then - # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) - new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - fi - - - windows_path="$new_path" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - unix_path=`$CYGPATH -u "$windows_path"` - new_path="$unix_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` - new_path="$unix_path" - fi - - if test "x$path" != "x$new_path"; then - POTENTIAL_FREETYPE_LIB_PATH="$new_path" - { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&5 -$as_echo "$as_me: Rewriting POTENTIAL_FREETYPE_LIB_PATH to \"$new_path\"" >&6;} - fi - - # Save the first 10 bytes of this path to the storage, so fixpath can work. - all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") - - else - # We're on a unix platform. Hooray! :) - path="$POTENTIAL_FREETYPE_LIB_PATH" - has_space=`$ECHO "$path" | $GREP " "` - if test "x$has_space" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&5 -$as_echo "$as_me: The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is invalid." >&6;} - as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 - fi - - # Use eval to expand a potential ~ - eval path="$path" - if test ! -f "$path" && test ! -d "$path"; then - as_fn_error $? "The path of POTENTIAL_FREETYPE_LIB_PATH, which resolves as \"$path\", is not found." "$LINENO" 5 - fi - - if test -d "$path"; then - POTENTIAL_FREETYPE_LIB_PATH="`cd "$path"; $THEPWDCMD -L`" - else - dir="`$DIRNAME "$path"`" - base="`$BASENAME "$path"`" - POTENTIAL_FREETYPE_LIB_PATH="`cd "$dir"; $THEPWDCMD -L`/$base" - fi - fi - fi - - - FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype includes" >&5 -$as_echo_n "checking for freetype includes... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_INCLUDE_PATH" >&5 -$as_echo "$FREETYPE_INCLUDE_PATH" >&6; } - FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype libraries" >&5 -$as_echo_n "checking for freetype libraries... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_LIB_PATH" >&5 -$as_echo "$FREETYPE_LIB_PATH" >&6; } - fi - - fi - if test "x$FOUND_FREETYPE" != xyes; then FREETYPE_BASE_DIR="$SYSROOT/usr" if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then diff --git a/common/autoconf/lib-freetype.m4 b/common/autoconf/lib-freetype.m4 index 5fc47824779..99d84a28a7d 100644 --- a/common/autoconf/lib-freetype.m4 +++ b/common/autoconf/lib-freetype.m4 @@ -357,11 +357,6 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], fi fi - if test "x$FOUND_FREETYPE" != xyes; then - FREETYPE_BASE_DIR="$SYSROOT/usr/sfw" - LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location]) - fi - if test "x$FOUND_FREETYPE" != xyes; then FREETYPE_BASE_DIR="$SYSROOT/usr" if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then diff --git a/common/autoconf/lib-x11.m4 b/common/autoconf/lib-x11.m4 index b332a50fc15..0614299e849 100644 --- a/common/autoconf/lib-x11.m4 +++ b/common/autoconf/lib-x11.m4 @@ -91,9 +91,7 @@ AC_DEFUN_ONCE([LIB_SETUP_X11], if test "x$OPENJDK_TARGET_OS" = xsolaris; then OPENWIN_HOME="/usr/openwin" X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions" - X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \ - -L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \ - -R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \ + X_LIBS="-L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \ -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR" fi diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 6a563f01942..db3d39e2655 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -294,14 +294,6 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], fi AC_SUBST(TOOLCHAIN_VERSION) - # For solaris we really need solaris tools, and not the GNU equivalent. - # The build tools on Solaris reside in /usr/ccs (C Compilation System), - # so add that to path before starting to probe. - # FIXME: This was originally only done for AS,NM,GNM,STRIP,OBJCOPY,OBJDUMP. - if test "x$OPENJDK_BUILD_OS" = xsolaris; then - PATH="/usr/ccs/bin:$PATH" - fi - # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to # override all other locations. if test "x$TOOLCHAIN_PATH" != x; then From 4e8fe41e356d11207237dd9b37298d10b86abf22 Mon Sep 17 00:00:00 2001 From: Alan Burlison Date: Wed, 21 Sep 2016 14:22:11 +0200 Subject: [PATCH 51/81] 8165161: Solaris: /usr/ccs /opt/sfw and /opt/csw are dead, references should be expunged Reviewed-by: rriggs, erikj --- jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c | 4 ++-- .../unix/native/libawt_xawt/awt/awt_GraphicsEnv.c | 2 +- .../share/classes/sun/security/pkcs11/Secmod.java | 2 +- jdk/test/jprt.config | 9 +++------ jdk/test/start-Xvfb.sh | 3 --- jdk/test/sun/security/smartcardio/README.txt | 8 ++++---- jdk/test/sun/security/tools/keytool/KeyToolTest.java | 4 ++-- jdk/test/tools/launcher/RunpathTest.java | 2 +- 8 files changed, 14 insertions(+), 20 deletions(-) diff --git a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c index 27230858253..533584fdb7a 100644 --- a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c +++ b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c @@ -152,8 +152,8 @@ defaultPath(void) #ifdef __solaris__ /* These really are the Solaris defaults! */ return (geteuid() == 0 || getuid() == 0) ? - "/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin:/usr/sbin" : - "/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin:"; + "/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:/usr/sbin" : + "/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:"; #else return ":/bin:/usr/bin"; /* glibc */ #endif diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c index c1895cd29d7..7124f6127af 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c @@ -442,7 +442,7 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) { #ifndef __linux__ /* SOLARIS */ if (xrenderLibHandle == NULL) { - xrenderLibHandle = dlopen("/usr/sfw/lib/libXrender.so.1", + xrenderLibHandle = dlopen("/usr/lib/libXrender.so.1", RTLD_LAZY | RTLD_GLOBAL); } #endif diff --git a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Secmod.java b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Secmod.java index cd11ad57fe9..262bbb9afd1 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Secmod.java +++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/Secmod.java @@ -45,7 +45,7 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*; *
      *   Secmod secmod = Secmod.getInstance();
      *   if (secmod.isInitialized() == false) {
    - *       secmod.initialize("/home/myself/.mozilla", "/usr/sfw/lib/mozilla");
    + *       secmod.initialize("/home/myself/.mozilla");
      *   }
      *
      *   Provider p = secmod.getModule(ModuleType.KEYSTORE).getProvider();
    diff --git a/jdk/test/jprt.config b/jdk/test/jprt.config
    index 3d6c975a398..9f438197ec3 100644
    --- a/jdk/test/jprt.config
    +++ b/jdk/test/jprt.config
    @@ -82,15 +82,12 @@ if [ "${osname}" = SunOS ] ; then
         fi
     
         # Add basic solaris system paths
    -    path4sdk=/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
    +    path4sdk=/usr/bin:/usr/gnu/bin
     
         # Find GNU make
    -    make=/usr/sfw/bin/gmake
    +    make=/usr/bin/gmake
         if [ ! -f ${make} ] ; then
    -	make=/opt/sfw/bin/gmake
    -	if [ ! -f ${make} ] ; then
    -	    make=${slashjava}/devtools/${solaris_arch}/bin/gnumake
    -        fi 
    +	make=${slashjava}/devtools/${solaris_arch}/bin/gnumake
         fi
         fileMustExist "${make}" make
     
    diff --git a/jdk/test/start-Xvfb.sh b/jdk/test/start-Xvfb.sh
    index ea3d16c9997..ec6a4a2b1c7 100644
    --- a/jdk/test/start-Xvfb.sh
    +++ b/jdk/test/start-Xvfb.sh
    @@ -59,9 +59,6 @@ else
       /usr/bin/nohup /usr/bin/X11/Xvfb -fbdir ${currentDir} -pixdepths 8 16 24 32 ${DISPLAY} > ${currentDir}/nohup.$$ 2>&1 &
     fi
     WM="/usr/bin/X11/fvwm2"
    -if [ ! -x ${WM} ] ; then
    -  WM="/opt/sfw/bin/fvwm2"
    -fi
     #
     # Wait for Xvfb to initialize:
     sleep 5
    diff --git a/jdk/test/sun/security/smartcardio/README.txt b/jdk/test/sun/security/smartcardio/README.txt
    index 5efbb5fa33b..6a0953a61e3 100644
    --- a/jdk/test/sun/security/smartcardio/README.txt
    +++ b/jdk/test/sun/security/smartcardio/README.txt
    @@ -1,17 +1,17 @@
     
     Rough hints for setting up MUSCLE on Solaris:
     
    -Make sure you have libusb, usually in /usr/sfw:
    +Make sure you have libusb, usually in /usr/lib:
     
    -ls -l /usr/sfw/lib/libusb.so
    -lrwxrwxrwx   1 root     other         11 Jan 12 16:02 /usr/sfw/lib/libusb.so -> libusb.so.1
    +ls -l /usr/lib/libusb.so
    +lrwxrwxrwx   1 root     other         11 Jan 12 16:02 /usr/lib/libusb.so -> libusb.so.1
     
     Get PCSC and CCID.
     -rwx------   1 user staff     529540 Jun 16 18:24 ccid-1.0.1.tar.gz
     -rwx------   1 user staff     842654 Jun 16 18:24 pcsc-lite-1.3.1.tar.gz
     
     Unpack pcsc
    -Run ./configure --enable-libusb=/usr/sfw (??)
    +Run ./configure --enable-libusb (??)
     gnumake
     Make /usr/local writeable for user
     gnumake install
    diff --git a/jdk/test/sun/security/tools/keytool/KeyToolTest.java b/jdk/test/sun/security/tools/keytool/KeyToolTest.java
    index a783c4e9dbd..7e19d510767 100644
    --- a/jdk/test/sun/security/tools/keytool/KeyToolTest.java
    +++ b/jdk/test/sun/security/tools/keytool/KeyToolTest.java
    @@ -1761,7 +1761,7 @@ public class KeyToolTest {
             //PKCS#11 tests
     
             //   1. sccs edit cert8.db key3.db
    -        //Runtime.getRuntime().exec("/usr/ccs/bin/sccs edit cert8.db key3.db");
    +        //Runtime.getRuntime().exec("/usr/bin/sccs edit cert8.db key3.db");
             testOK("", p11Arg + ("-storepass test12 -genkey -alias genkey" +
                     " -dname cn=genkey -keysize 512 -keyalg rsa"));
             testOK("", p11Arg + "-storepass test12 -list");
    @@ -1781,7 +1781,7 @@ public class KeyToolTest {
             testOK("", p11Arg + "-storepass test12 -list");
             assertTrue(out.indexOf("Your keystore contains 0 entries") != -1);
             //(check for empty database listing)
    -        //Runtime.getRuntime().exec("/usr/ccs/bin/sccs unedit cert8.db key3.db");
    +        //Runtime.getRuntime().exec("/usr/bin/sccs unedit cert8.db key3.db");
             remove("genkey.cert");
             remove("genkey.certreq");
             //  12. sccs unedit cert8.db key3.db
    diff --git a/jdk/test/tools/launcher/RunpathTest.java b/jdk/test/tools/launcher/RunpathTest.java
    index 26233b28561..00e757343c3 100644
    --- a/jdk/test/tools/launcher/RunpathTest.java
    +++ b/jdk/test/tools/launcher/RunpathTest.java
    @@ -40,7 +40,7 @@ public class RunpathTest extends TestHelper {
         }
     
         final String findElfReader() {
    -        String[] paths = {"/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/ccs/bin"};
    +        String[] paths = {"/usr/sbin", "/usr/bin"};
             final String cmd = isSolaris ? "elfdump" : "readelf";
             for (String x : paths) {
                 File p = new File(x);
    
    From ce5c490b25f3dc274788b8e6917b0004d64117e8 Mon Sep 17 00:00:00 2001
    From: Alan Burlison 
    Date: Wed, 21 Sep 2016 14:23:33 +0200
    Subject: [PATCH 52/81] 8165161: Solaris: /usr/ccs /opt/sfw and /opt/csw are
     dead, references should be expunged
    
    Reviewed-by: erikj
    ---
     hotspot/test/jprt.config | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/hotspot/test/jprt.config b/hotspot/test/jprt.config
    index 53ffdaecd83..d6ffc5f070e 100644
    --- a/hotspot/test/jprt.config
    +++ b/hotspot/test/jprt.config
    @@ -86,12 +86,12 @@ case "${osname}" in
         fi
     
         # Add basic solaris system paths
    -    path4sdk=/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
    +    path4sdk=/usr/bin
     
         # Find GNU make
    -    make=/usr/sfw/bin/gmake
    +    make=/usr/bin/gmake
         if [ ! -f ${make} ] ; then
    -	make=/opt/sfw/bin/gmake
    +	make=/usr/gnu/bin/make
     	if [ ! -f ${make} ] ; then
     	    make=${slashjava}/devtools/${solaris_arch}/bin/gnumake
             fi 
    
    From 1c751c11fb5e54e0a402c5aa098b16290e9182c0 Mon Sep 17 00:00:00 2001
    From: Sergei Kovalev 
    Date: Wed, 21 Sep 2016 17:09:41 +0300
    Subject: [PATCH 53/81] 8166450: smartcardio related tests failed on
     compilation during execution with jtreg tool
    
    Reviewed-by: weijun
    ---
     jdk/test/sun/security/smartcardio/TestChannel.java         | 3 ++-
     jdk/test/sun/security/smartcardio/TestConnect.java         | 3 ++-
     jdk/test/sun/security/smartcardio/TestConnectAgain.java    | 3 ++-
     jdk/test/sun/security/smartcardio/TestControl.java         | 3 ++-
     jdk/test/sun/security/smartcardio/TestDefault.java         | 3 ++-
     jdk/test/sun/security/smartcardio/TestDirect.java          | 3 ++-
     jdk/test/sun/security/smartcardio/TestExclusive.java       | 3 ++-
     jdk/test/sun/security/smartcardio/TestMultiplePresent.java | 3 ++-
     jdk/test/sun/security/smartcardio/TestPresent.java         | 3 ++-
     jdk/test/sun/security/smartcardio/TestTransmit.java        | 3 ++-
     10 files changed, 20 insertions(+), 10 deletions(-)
    
    diff --git a/jdk/test/sun/security/smartcardio/TestChannel.java b/jdk/test/sun/security/smartcardio/TestChannel.java
    index c7e022f7c21..90052158ca7 100644
    --- a/jdk/test/sun/security/smartcardio/TestChannel.java
    +++ b/jdk/test/sun/security/smartcardio/TestChannel.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6239117
      * @summary test logical channels work
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestChannel
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestConnect.java b/jdk/test/sun/security/smartcardio/TestConnect.java
    index 467939e1059..fa0631c98ad 100644
    --- a/jdk/test/sun/security/smartcardio/TestConnect.java
    +++ b/jdk/test/sun/security/smartcardio/TestConnect.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6293769 6294527 6309280
      * @summary test connect() works
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestConnect
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestConnectAgain.java b/jdk/test/sun/security/smartcardio/TestConnectAgain.java
    index f4e6af21cba..7f2343b2edd 100644
    --- a/jdk/test/sun/security/smartcardio/TestConnectAgain.java
    +++ b/jdk/test/sun/security/smartcardio/TestConnectAgain.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6239117
      * @summary test connect works correctly if called multiple times/card removed
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestConnectAgain
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestControl.java b/jdk/test/sun/security/smartcardio/TestControl.java
    index 682f715d1c4..fd1c936582e 100644
    --- a/jdk/test/sun/security/smartcardio/TestControl.java
    +++ b/jdk/test/sun/security/smartcardio/TestControl.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6239117 6470320
      * @summary test if transmitControlCommand() works
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestControl
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestDefault.java b/jdk/test/sun/security/smartcardio/TestDefault.java
    index 9f3a6660426..190b988e91b 100644
    --- a/jdk/test/sun/security/smartcardio/TestDefault.java
    +++ b/jdk/test/sun/security/smartcardio/TestDefault.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6327047
      * @summary verify that TerminalFactory.getDefault() works
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestDefault
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestDirect.java b/jdk/test/sun/security/smartcardio/TestDirect.java
    index 5c09ea907ab..bddc3093934 100644
    --- a/jdk/test/sun/security/smartcardio/TestDirect.java
    +++ b/jdk/test/sun/security/smartcardio/TestDirect.java
    @@ -21,10 +21,11 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 8046343
      * @summary Make sure that direct protocol is available
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestDirect
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestExclusive.java b/jdk/test/sun/security/smartcardio/TestExclusive.java
    index 9e4416ac6d9..cd451321f53 100644
    --- a/jdk/test/sun/security/smartcardio/TestExclusive.java
    +++ b/jdk/test/sun/security/smartcardio/TestExclusive.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6239117
      * @summary verify that beginExclusive()/endExclusive() works
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestExclusive
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestMultiplePresent.java b/jdk/test/sun/security/smartcardio/TestMultiplePresent.java
    index 15e320d2475..9fd2256bf09 100644
    --- a/jdk/test/sun/security/smartcardio/TestMultiplePresent.java
    +++ b/jdk/test/sun/security/smartcardio/TestMultiplePresent.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6239117 6445367
      * @summary test that CardTerminals.waitForCard() works
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestMultiplePresent
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestPresent.java b/jdk/test/sun/security/smartcardio/TestPresent.java
    index 1f499e97c12..fea98795d75 100644
    --- a/jdk/test/sun/security/smartcardio/TestPresent.java
    +++ b/jdk/test/sun/security/smartcardio/TestPresent.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6293769 6294527
      * @summary test that the isCardPresent()/waitForX() APIs work correctly
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestPresent
      */
     
    diff --git a/jdk/test/sun/security/smartcardio/TestTransmit.java b/jdk/test/sun/security/smartcardio/TestTransmit.java
    index 85b32f6dd48..e233a4bb163 100644
    --- a/jdk/test/sun/security/smartcardio/TestTransmit.java
    +++ b/jdk/test/sun/security/smartcardio/TestTransmit.java
    @@ -21,11 +21,12 @@
      * questions.
      */
     
    -/**
    +/*
      * @test
      * @bug 6293769 6294527
      * @summary test transmit() works
      * @author Andreas Sterbenz
    + * @modules java.smartcardio/javax.smartcardio
      * @run main/manual TestTransmit
      */
     
    
    From 139e60e8e3545180aae685c608c1645a881616de Mon Sep 17 00:00:00 2001
    From: Jamil Nimeh 
    Date: Thu, 22 Sep 2016 07:28:40 -0700
    Subject: [PATCH 54/81] 8049516: sun.security.provider.SeedGenerator throws
     ArrayIndexOutOfBoundsException
    
    Prevent the latch inside ThreadedSeedGenerator.run() from overflowing into a negative value causing a negative index array lookup.
    
    Reviewed-by: xuelei, weijun
    ---
     .../classes/sun/security/provider/SeedGenerator.java   | 10 ++++++----
     1 file changed, 6 insertions(+), 4 deletions(-)
    
    diff --git a/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
    index e72ae9f406c..ac3a9f86a1a 100644
    --- a/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
    +++ b/jdk/src/java.base/share/classes/sun/security/provider/SeedGenerator.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1996, 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
    @@ -344,7 +344,8 @@ abstract class SeedGenerator {
                             try {
                                 BogusThread bt = new BogusThread();
                                 Thread t = new Thread
    -                                (seedGroup, bt, "SeedGenerator Thread", 0, false);
    +                                (seedGroup, bt, "SeedGenerator Thread", 0,
    +                                        false);
                                 t.start();
                             } catch (Exception e) {
                                 throw new InternalError("internal error: " +
    @@ -357,7 +358,8 @@ abstract class SeedGenerator {
                             long startTime = System.nanoTime();
                             while (System.nanoTime() - startTime < 250000000) {
                                 synchronized(this){};
    -                            latch++;
    +                            // Mask the sign bit and keep latch non-negative
    +                            latch = (latch + 1) & 0x1FFFFFFF;
                             }
     
                             // Translate the value using the permutation, and xor
    @@ -431,7 +433,7 @@ abstract class SeedGenerator {
             // data and using it to mix the trivial permutation.
             // It should be evenly distributed. The specific values
             // are not crucial to the security of this class.
    -        private static byte[] rndTab = {
    +        private static final byte[] rndTab = {
                 56, 30, -107, -6, -86, 25, -83, 75, -12, -64,
                 5, -128, 78, 21, 16, 32, 70, -81, 37, -51,
                 -43, -46, -108, 87, 29, 17, -55, 22, -11, -111,
    
    From 48490309d8d37afd439ef7f860cfb16149db4c9c Mon Sep 17 00:00:00 2001
    From: Sean Coffey 
    Date: Thu, 22 Sep 2016 17:21:10 +0100
    Subject: [PATCH 55/81] 8151832: Improve exception messages in exception thrown
     by new JDK 9 code
    
    Reviewed-by: alanb
    ---
     .../classes/java/lang/module/ModuleInfo.java  | 22 +++++++++----------
     .../classes/java/lang/reflect/Proxy.java      |  4 ++--
     .../jdk/internal/jimage/BasicImageReader.java | 14 +++++++-----
     .../jdk/internal/jimage/ImageHeader.java      |  3 ++-
     .../jdk/internal/jimage/ImageLocation.java    | 11 ++++++----
     .../jdk/internal/jimage/ImageStream.java      |  4 ++--
     .../internal/jimage/ImageStringsReader.java   |  8 ++++---
     .../jdk/internal/jrtfs/JrtFileSystem.java     |  5 +++--
     .../classes/jdk/internal/jrtfs/JrtPath.java   | 15 ++++++++-----
     .../share/classes/jdk/internal/misc/VM.java   |  2 +-
     .../sun/beans/finder/ConstructorFinder.java   | 13 ++++++-----
     .../classes/javax/imageio/ImageReader.java    |  6 ++---
     .../classes/javax/imageio/ImageWriter.java    |  6 ++---
     13 files changed, 66 insertions(+), 47 deletions(-)
    
    diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java
    index db9a3e000b9..1d0e22fec11 100644
    --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java
    +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java
    @@ -664,7 +664,7 @@ final class ModuleInfo {
                 try {
                     bb.get(b, off, len);
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -681,7 +681,7 @@ final class ModuleInfo {
                     int ch = bb.get();
                     return (ch != 0);
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -690,7 +690,7 @@ final class ModuleInfo {
                 try {
                     return bb.get();
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -699,7 +699,7 @@ final class ModuleInfo {
                 try {
                     return ((int) bb.get()) & 0xff;
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -708,7 +708,7 @@ final class ModuleInfo {
                 try {
                     return bb.getShort();
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -717,7 +717,7 @@ final class ModuleInfo {
                 try {
                     return ((int) bb.getShort()) & 0xffff;
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -726,7 +726,7 @@ final class ModuleInfo {
                 try {
                     return bb.getChar();
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -735,7 +735,7 @@ final class ModuleInfo {
                 try {
                     return bb.getInt();
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -744,7 +744,7 @@ final class ModuleInfo {
                 try {
                     return bb.getLong();
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -753,7 +753,7 @@ final class ModuleInfo {
                 try {
                     return bb.getFloat();
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    @@ -762,7 +762,7 @@ final class ModuleInfo {
                 try {
                     return bb.getDouble();
                 } catch (BufferUnderflowException e) {
    -                throw new EOFException();
    +                throw new EOFException(e.getMessage());
                 }
             }
     
    diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java
    index ba2632b5445..15d41a4101d 100644
    --- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java
    +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java
    @@ -597,10 +597,10 @@ public class Proxy implements java.io.Serializable {
             private final Module module;
             ProxyBuilder(ClassLoader loader, List> interfaces) {
                 if (!VM.isModuleSystemInited()) {
    -                throw new InternalError("Proxy is not supported until module system is fully initialzed");
    +                throw new InternalError("Proxy is not supported until module system is fully initialized");
                 }
                 if (interfaces.size() > 65535) {
    -                throw new IllegalArgumentException("interface limit exceeded");
    +                throw new IllegalArgumentException("interface limit exceeded: " + interfaces.size());
                 }
     
                 Set> refTypes = referencedTypes(loader, interfaces);
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
    index 07038b9ef5e..10506b7029c 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java
    @@ -186,7 +186,9 @@ public class BasicImageReader implements AutoCloseable {
     
             if (result.getMajorVersion() != ImageHeader.MAJOR_VERSION ||
                 result.getMinorVersion() != ImageHeader.MINOR_VERSION) {
    -            throw new IOException("The image file \"" + name + "\" is not the correct version");
    +            throw new IOException("The image file \"" + name + "\" is not " +
    +                "the correct version. Major: " + result.getMajorVersion() +
    +                ". Minor: " + result.getMinorVersion());
             }
     
             return result;
    @@ -318,11 +320,11 @@ public class BasicImageReader implements AutoCloseable {
     
         private ByteBuffer readBuffer(long offset, long size) {
             if (offset < 0 || Integer.MAX_VALUE <= offset) {
    -            throw new IndexOutOfBoundsException("offset");
    +            throw new IndexOutOfBoundsException("Bad offset: " + offset);
             }
     
             if (size < 0 || Integer.MAX_VALUE <= size) {
    -            throw new IndexOutOfBoundsException("size");
    +            throw new IndexOutOfBoundsException("Bad size: " + size);
             }
     
             if (MAP_ALL) {
    @@ -382,11 +384,13 @@ public class BasicImageReader implements AutoCloseable {
             long uncompressedSize = loc.getUncompressedSize();
     
             if (compressedSize < 0 || Integer.MAX_VALUE < compressedSize) {
    -            throw new IndexOutOfBoundsException("Compressed size");
    +            throw new IndexOutOfBoundsException(
    +                "Bad compressed size: " + compressedSize);
             }
     
             if (uncompressedSize < 0 || Integer.MAX_VALUE < uncompressedSize) {
    -            throw new IndexOutOfBoundsException("Uncompressed size");
    +            throw new IndexOutOfBoundsException(
    +                "Bad uncompressed size: " + uncompressedSize);
             }
     
             if (compressedSize == 0) {
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java
    index c4ff85bbfb8..f63665119e2 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageHeader.java
    @@ -79,7 +79,8 @@ public final class ImageHeader {
             Objects.requireNonNull(buffer);
     
             if (buffer.capacity() != HEADER_SLOTS) {
    -            throw new InternalError("jimage header not the correct size");
    +            throw new InternalError(
    +                "jimage header not the correct size: " + buffer.capacity());
             }
     
             int magic = buffer.get(0);
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java
    index 16787dad3af..ad0ae42fc3d 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageLocation.java
    @@ -81,7 +81,8 @@ public class ImageLocation {
                     }
     
                     if (kind < ATTRIBUTE_END || ATTRIBUTE_COUNT <= kind) {
    -                    throw new InternalError("Invalid jimage attribute kind");
    +                    throw new InternalError(
    +                        "Invalid jimage attribute kind: " + kind);
                     }
     
                     int length = attributeLength(data);
    @@ -91,7 +92,7 @@ public class ImageLocation {
                         value <<= 8;
     
                         if (!bytes.hasRemaining()) {
    -                        throw new InternalError("\"Missing jimage attribute datad");
    +                        throw new InternalError("Missing jimage attribute data");
                         }
     
                         value |= bytes.get() & 0xFF;
    @@ -134,7 +135,8 @@ public class ImageLocation {
     
         long getAttribute(int kind) {
             if (kind < ATTRIBUTE_END || ATTRIBUTE_COUNT <= kind) {
    -            throw new InternalError("Invalid jimage attribute kind");
    +            throw new InternalError(
    +                "Invalid jimage attribute kind: " + kind);
             }
     
             return attributes[kind];
    @@ -142,7 +144,8 @@ public class ImageLocation {
     
         String getAttributeString(int kind) {
             if (kind < ATTRIBUTE_END || ATTRIBUTE_COUNT <= kind) {
    -            throw new InternalError("Invalid jimage attribute kind");
    +            throw new InternalError(
    +                "Invalid jimage attribute kind: " + kind);
             }
     
             return getStrings().get((int)attributes[kind]);
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStream.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStream.java
    index 9802afcc93a..774e0e6e62a 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStream.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStream.java
    @@ -82,7 +82,7 @@ public class ImageStream {
     
         public void ensure(int needs) {
             if (needs < 0) {
    -            throw new IndexOutOfBoundsException("needs");
    +            throw new IndexOutOfBoundsException("Bad value: " + needs);
             }
     
             if (needs > buffer.remaining()) {
    @@ -106,7 +106,7 @@ public class ImageStream {
     
         public void skip(int n) {
             if (n < 0) {
    -            throw new IndexOutOfBoundsException("n");
    +            throw new IndexOutOfBoundsException("skip value = " + n);
             }
     
             buffer.position(buffer.position() + n);
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java
    index 382e6b1696b..e4a11cbdc14 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageStringsReader.java
    @@ -151,7 +151,7 @@ public class ImageStringsReader implements ImageStrings {
             try {
                 charsFromMUTF8(chars, bytes, offset, count);
             } catch (UTFDataFormatException ex) {
    -            throw new InternalError("Attempt to convert non modified UTF-8 byte sequence");
    +            throw new InternalError("Attempt to convert non modified UTF-8 byte sequence", ex);
             }
     
             return new String(chars);
    @@ -199,7 +199,8 @@ public class ImageStringsReader implements ImageStrings {
                         ch = buffer.get();
     
                         if ((ch & 0xC0) != 0x80) {
    -                        throw new InternalError("Bad continuation in modified UTF-8 byte sequence");
    +                        throw new InternalError("Bad continuation in " +
    +                            "modified UTF-8 byte sequence: " + ch);
                         }
     
                         uch = ((uch & ~mask) << 6) | (ch & 0x3F);
    @@ -208,7 +209,8 @@ public class ImageStringsReader implements ImageStrings {
                 }
     
                 if ((uch & 0xFFFF) != uch) {
    -                throw new InternalError("UTF-32 char in modified UTF-8 byte sequence");
    +                throw new InternalError("UTF-32 char in modified UTF-8 " +
    +                    "byte sequence: " + uch);
                 }
     
                 chars[j++] = (char)uch;
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java
    index cb6c85d11e3..49285b31dfb 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java
    @@ -183,7 +183,7 @@ class JrtFileSystem extends FileSystem {
         public PathMatcher getPathMatcher(String syntaxAndInput) {
             int pos = syntaxAndInput.indexOf(':');
             if (pos <= 0 || pos == syntaxAndInput.length()) {
    -            throw new IllegalArgumentException();
    +            throw new IllegalArgumentException("pos is " + pos);
             }
             String syntax = syntaxAndInput.substring(0, pos);
             String input = syntaxAndInput.substring(pos + 1);
    @@ -285,7 +285,8 @@ class JrtFileSystem extends FileSystem {
             for (OpenOption option : options) {
                 Objects.requireNonNull(option);
                 if (!(option instanceof StandardOpenOption)) {
    -                throw new IllegalArgumentException();
    +                throw new IllegalArgumentException(
    +                    "option class: " + option.getClass());
                 }
             }
             if (options.contains(StandardOpenOption.WRITE) ||
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java
    index cf3bbd8d2d9..f23887cabad 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java
    @@ -122,7 +122,8 @@ final class JrtPath implements Path {
         public final JrtPath getName(int index) {
             initOffsets();
             if (index < 0 || index >= offsets.length) {
    -            throw new IllegalArgumentException();
    +            throw new IllegalArgumentException("index: " +
    +                index + ", offsets length: " + offsets.length);
             }
             int begin = offsets[index];
             int end;
    @@ -139,7 +140,9 @@ final class JrtPath implements Path {
             initOffsets();
             if (beginIndex < 0 || endIndex > offsets.length ||
                 beginIndex >= endIndex) {
    -            throw new IllegalArgumentException();
    +            throw new IllegalArgumentException(
    +                "beginIndex: " + beginIndex + ", endIndex: " + endIndex +
    +                ", offsets length: " + offsets.length);
             }
             // starting/ending offsets
             int begin = offsets[beginIndex];
    @@ -211,7 +214,8 @@ final class JrtPath implements Path {
                 return o;
             }
             if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) {
    -            throw new IllegalArgumentException();
    +            throw new IllegalArgumentException(
    +                "Incorrect filesystem or path: " + other);
             }
             final String tp = this.path;
             final String op = o.path;
    @@ -366,7 +370,8 @@ final class JrtPath implements Path {
         private JrtPath checkPath(Path path) {
             Objects.requireNonNull(path);
             if (!(path instanceof JrtPath))
    -            throw new ProviderMismatchException();
    +            throw new ProviderMismatchException("path class: " +
    +                path.getClass());
             return (JrtPath) path;
         }
     
    @@ -459,7 +464,7 @@ final class JrtPath implements Path {
                 }
                 if (c == '\u0000') {
                     throw new InvalidPathException(path,
    -                        "Path: nul character not allowed");
    +                        "Path: NUL character not allowed");
                 }
                 to.append(c);
                 prevC = c;
    diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java
    index 9fe63d56e5e..695795e4338 100644
    --- a/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java
    +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/VM.java
    @@ -50,7 +50,7 @@ public class VM {
         public static void initLevel(int value) {
             synchronized (lock) {
                 if (value <= initLevel || value > SYSTEM_BOOTED)
    -                throw new InternalError();
    +                throw new InternalError("Bad level: " + value);
                 initLevel = value;
                 lock.notifyAll();
             }
    diff --git a/jdk/src/java.desktop/share/classes/com/sun/beans/finder/ConstructorFinder.java b/jdk/src/java.desktop/share/classes/com/sun/beans/finder/ConstructorFinder.java
    index 984bf8ad239..d0315ada6bf 100644
    --- a/jdk/src/java.desktop/share/classes/com/sun/beans/finder/ConstructorFinder.java
    +++ b/jdk/src/java.desktop/share/classes/com/sun/beans/finder/ConstructorFinder.java
    @@ -67,19 +67,22 @@ public final class ConstructorFinder extends AbstractFinder> {
          */
         public static Constructor findConstructor(Class type, Class...args) throws NoSuchMethodException {
             if (type.isPrimitive()) {
    -            throw new NoSuchMethodException("Primitive wrapper does not contain constructors");
    +            throw new NoSuchMethodException("Primitive wrapper does not contain constructors: "
    +                + type.getName());
             }
             if (type.isInterface()) {
    -            throw new NoSuchMethodException("Interface does not contain constructors");
    +            throw new NoSuchMethodException("Interface does not contain constructors: "
    +                + type.getName());
             }
             if (!FinderUtils.isExported(type)) {
    -            throw new NoSuchMethodException("Class is not accessible");
    +            throw new NoSuchMethodException("Class is not accessible: " + type.getName());
             }
             if (Modifier.isAbstract(type.getModifiers())) {
    -            throw new NoSuchMethodException("Abstract class cannot be instantiated");
    +            throw new NoSuchMethodException("Abstract class cannot be instantiated: "
    +                + type.getName());
             }
             if (!Modifier.isPublic(type.getModifiers()) || !isPackageAccessible(type)) {
    -            throw new NoSuchMethodException("Class is not accessible");
    +            throw new NoSuchMethodException("Class is not accessible: " + type.getName());
             }
             PrimitiveWrapperMap.replacePrimitivesWithWrappers(args);
             Signature signature = new Signature(type, args);
    diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/ImageReader.java b/jdk/src/java.desktop/share/classes/javax/imageio/ImageReader.java
    index 5f39ea935fa..e17a5f2e796 100644
    --- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageReader.java
    +++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageReader.java
    @@ -2461,16 +2461,16 @@ public abstract class ImageReader {
                 try {
                     bundle = ResourceBundle.getBundle(baseName, locale, this.getClass().getModule());
                 } catch (MissingResourceException mre) {
    -                throw new IllegalArgumentException("Bundle not found!");
    +                throw new IllegalArgumentException("Bundle not found!", mre);
                 }
     
                 String warning = null;
                 try {
                     warning = bundle.getString(keyword);
                 } catch (ClassCastException cce) {
    -                throw new IllegalArgumentException("Resource is not a String!");
    +                throw new IllegalArgumentException("Resource is not a String!", cce);
                 } catch (MissingResourceException mre) {
    -                throw new IllegalArgumentException("Resource is missing!");
    +                throw new IllegalArgumentException("Resource is missing!", mre);
                 }
     
                 listener.warningOccurred(this, warning);
    diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/ImageWriter.java b/jdk/src/java.desktop/share/classes/javax/imageio/ImageWriter.java
    index a9a681ce05f..8723c50773e 100644
    --- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageWriter.java
    +++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageWriter.java
    @@ -1963,16 +1963,16 @@ public abstract class ImageWriter implements ImageTranscoder {
                 try {
                     bundle = ResourceBundle.getBundle(baseName, locale, this.getClass().getModule());
                 } catch (MissingResourceException mre) {
    -                throw new IllegalArgumentException("Bundle not found!");
    +                throw new IllegalArgumentException("Bundle not found!", mre);
                 }
     
                 String warning = null;
                 try {
                     warning = bundle.getString(keyword);
                 } catch (ClassCastException cce) {
    -                throw new IllegalArgumentException("Resource is not a String!");
    +                throw new IllegalArgumentException("Resource is not a String!", cce);
                 } catch (MissingResourceException mre) {
    -                throw new IllegalArgumentException("Resource is missing!");
    +                throw new IllegalArgumentException("Resource is missing!", mre);
                 }
     
                 listener.warningOccurred(this, imageIndex, warning);
    
    From f16543a919b2bfabf09b7f880463fe2b579ad765 Mon Sep 17 00:00:00 2001
    From: Lana Steuck 
    Date: Thu, 22 Sep 2016 16:41:12 +0000
    Subject: [PATCH 56/81] Added tag jdk-9+137 for changeset 2526d9083e41
    
    ---
     .hgtags-top-repo | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/.hgtags-top-repo b/.hgtags-top-repo
    index e540680549f..a0cde0979fb 100644
    --- a/.hgtags-top-repo
    +++ b/.hgtags-top-repo
    @@ -379,3 +379,4 @@ be1218f792a450dfb5d4b1f82616b9d95a6a732e jdk-9+133
     065724348690eda41fc69112278d8da6dcde548c jdk-9+134
     82b94cb5f342319d2cda77f9fa59703ad7fde576 jdk-9+135
     3ec350f5f32af249b59620d7e37b54bdcd77b233 jdk-9+136
    +d7f519b004254b19e384131d9f0d0e40e31a0fd3 jdk-9+137
    
    From 7b52c73b39f527ad41d52c015dd856c650a79060 Mon Sep 17 00:00:00 2001
    From: Lana Steuck 
    Date: Thu, 22 Sep 2016 16:41:12 +0000
    Subject: [PATCH 57/81] Added tag jdk-9+137 for changeset 94d6d0f4ced0
    
    ---
     hotspot/.hgtags | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/hotspot/.hgtags b/hotspot/.hgtags
    index d842722fa52..c6f688c2bbd 100644
    --- a/hotspot/.hgtags
    +++ b/hotspot/.hgtags
    @@ -539,3 +539,4 @@ a25e0fb6033245ab075136e744d362ce765464cd jdk-9+133
     b8b694c6b4d2ab0939aed7adaf0eec1ac321a085 jdk-9+134
     3b1c4562953db47e36b237a500f368d5c9746d47 jdk-9+135
     a20da289f646ee44440695b81abc0548330e4ca7 jdk-9+136
    +dfcbf839e299e7e2bba1da69bdb347617ea4c7e8 jdk-9+137
    
    From 0ddec1875f41c298c30383758e3230dcaec08dc9 Mon Sep 17 00:00:00 2001
    From: Lana Steuck 
    Date: Thu, 22 Sep 2016 16:41:12 +0000
    Subject: [PATCH 58/81] Added tag jdk-9+137 for changeset 7d79b32d8005
    
    ---
     corba/.hgtags | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/corba/.hgtags b/corba/.hgtags
    index e8dba874e9c..e47bd43b69b 100644
    --- a/corba/.hgtags
    +++ b/corba/.hgtags
    @@ -379,3 +379,4 @@ f7e1d5337c2e550fe553df7a3886bbed80292ecd jdk-9+131
     1a497f5ca0cfd88115cc7daa8af8a62b8741caf2 jdk-9+134
     094d0db606db976045f594dba47d4593b715cc81 jdk-9+135
     aa053a3faf266c12b4fd5272da431a3e08e4a3e3 jdk-9+136
    +258cf18fa7fc59359b874f8743b7168dc48baf73 jdk-9+137
    
    From a2aedd4cfcbb217681df765d6b4217f62d43d37c Mon Sep 17 00:00:00 2001
    From: Lana Steuck 
    Date: Thu, 22 Sep 2016 16:41:13 +0000
    Subject: [PATCH 59/81] Added tag jdk-9+137 for changeset 6de6d5c0e9d5
    
    ---
     jaxp/.hgtags | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/jaxp/.hgtags b/jaxp/.hgtags
    index fa7e108ef76..eb923642658 100644
    --- a/jaxp/.hgtags
    +++ b/jaxp/.hgtags
    @@ -379,3 +379,4 @@ e66cdc2de6b02443911d386fc9217b0d824d0686 jdk-9+130
     1c6c21d87aa459d82425e1fddc9ce8647aebde34 jdk-9+134
     f695240370c77a25fed88225a392e7d530cb4d78 jdk-9+135
     f1eafcb0eb7182b937bc93f214d8cabd01ec4d59 jdk-9+136
    +a8d5fe567ae72b4931040e59dd4478363f9004f5 jdk-9+137
    
    From a93882a532efa4de04b408d6f86a8ce0ba59c601 Mon Sep 17 00:00:00 2001
    From: Lana Steuck 
    Date: Thu, 22 Sep 2016 16:41:14 +0000
    Subject: [PATCH 60/81] Added tag jdk-9+137 for changeset c3cde7c41eef
    
    ---
     jdk/.hgtags | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/jdk/.hgtags b/jdk/.hgtags
    index d92b0709299..d64c53cafe8 100644
    --- a/jdk/.hgtags
    +++ b/jdk/.hgtags
    @@ -379,3 +379,4 @@ d5c70818cd8a82e76632c8c815bdb4f75f53aeaf jdk-9+132
     803adcd526d74ae0b64948d1f8260c2dbe514779 jdk-9+134
     021369229cfd0b5feb76834b2ea498f47f43c0f3 jdk-9+135
     54c5931849a33a363e03fdffa141503f5cc4779d jdk-9+136
    +e72df94364e3686e7d62059ce0d6b187b82da713 jdk-9+137
    
    From 1f29517431730f2da29a5228a6b4cf2790549180 Mon Sep 17 00:00:00 2001
    From: Lana Steuck 
    Date: Thu, 22 Sep 2016 16:41:14 +0000
    Subject: [PATCH 61/81] Added tag jdk-9+137 for changeset 3627d835ccf4
    
    ---
     jaxws/.hgtags | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/jaxws/.hgtags b/jaxws/.hgtags
    index 8fceda6eb06..73800b65dcd 100644
    --- a/jaxws/.hgtags
    +++ b/jaxws/.hgtags
    @@ -382,3 +382,4 @@ fe4e11bd2423635dc0f5f5cb9a64eb2f2cce7f4c jdk-9+128
     ab1d78d395d4cb8be426ff181211da1a4085cf01 jdk-9+134
     22631824f55128a7ab6605493b3001a37af6a168 jdk-9+135
     09ec13a99f50a4a346180d1e3b0fd8bc1ee399ce jdk-9+136
    +297c16d401c534cb879809d2a746d21ca99d2954 jdk-9+137
    
    From d436c124fb89c0fdb28642a91952dd820d58d8f1 Mon Sep 17 00:00:00 2001
    From: Lana Steuck 
    Date: Thu, 22 Sep 2016 16:41:15 +0000
    Subject: [PATCH 62/81] Added tag jdk-9+137 for changeset b772c7126f36
    
    ---
     nashorn/.hgtags | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/nashorn/.hgtags b/nashorn/.hgtags
    index 26b80a32770..41633a26b9a 100644
    --- a/nashorn/.hgtags
    +++ b/nashorn/.hgtags
    @@ -370,3 +370,4 @@ ee77c6b3713ab293e027ac3ea1cc16f86dac535f jdk-9+131
     e05400ba935753c77697af936db24657eb811022 jdk-9+134
     cb00d5ef023a18a66fcb4311ed4474d4145c66e9 jdk-9+135
     f11b8f5c4ccbf9c87d283815abac6c0117fba3c0 jdk-9+136
    +17ed43add2f9e3528686cd786ae2ed49c8ed36e9 jdk-9+137
    
    From 93c5fec349c1aa153bf2e6eba72df777acee55c8 Mon Sep 17 00:00:00 2001
    From: Joe Wang 
    Date: Thu, 22 Sep 2016 10:17:19 -0700
    Subject: [PATCH 63/81] 8166398: CatalogSupport tests need to be fixed
    
    Reviewed-by: dfuchs
    ---
     .../internal/impl/XMLEntityManager.java       |  8 ++--
     .../internal/xinclude/XIncludeHandler.java    | 21 +++++-----
     .../jaxp/unittest/catalog/CatalogSupport.java | 21 +++++-----
     .../jaxp/unittest/catalog/CatalogSupport.xml  |  1 +
     .../unittest/catalog/CatalogSupportBase.java  | 38 ++++++-------------
     .../unittest/catalog/XI_simple4Catalog.xml    |  2 +-
     .../jaxp/unittest/catalog/XI_test2Catalog.xml | 10 +++++
     7 files changed, 46 insertions(+), 55 deletions(-)
     create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/XI_test2Catalog.xml
    
    diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
    index d3b848c9847..5ed41e82fc8 100644
    --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
    +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
    @@ -1033,12 +1033,12 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
                 staxInputSource = new StaxXMLInputSource(xmlInputSource, fISCreatedByResolver);
             }
     
    -        if (staxInputSource == null) {
    +        if (staxInputSource == null && fUseCatalog) {
                 if (fCatalogFeatures == null) {
                     fCatalogFeatures = JdkXmlUtils.getCatalogFeatures(fDefer, fCatalogFile, fPrefer, fResolve);
                 }
                 fCatalogFile = fCatalogFeatures.get(Feature.FILES);
    -            if (fUseCatalog && fCatalogFile != null) {
    +            if (fCatalogFile != null) {
                     try {
                         if (fCatalogResolver == null) {
                             fCatalogResolver = CatalogManager.catalogResolver(fCatalogFeatures);
    @@ -1133,12 +1133,12 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
                 xmlInputSource = fEntityResolver.resolveEntity(resourceIdentifier);
             }
     
    -        if (xmlInputSource == null) {
    +        if (xmlInputSource == null && fUseCatalog) {
                 if (fCatalogFeatures == null) {
                     fCatalogFeatures = JdkXmlUtils.getCatalogFeatures(fDefer, fCatalogFile, fPrefer, fResolve);
                 }
                 fCatalogFile = fCatalogFeatures.get(Feature.FILES);
    -            if (fUseCatalog && fCatalogFile != null) {
    +            if (fCatalogFile != null) {
                     /*
                      since the method can be called from various processors, both
                      EntityResolver and URIResolver are used to attempt to find
    diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
    index 3f5410c1741..5efe85f9410 100644
    --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
    +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
    @@ -34,6 +34,8 @@ import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
     import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
     import com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException;
     import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
    +import com.sun.org.apache.xerces.internal.parsers.XIncludeParserConfiguration;
    +import com.sun.org.apache.xerces.internal.parsers.XPointerParserConfiguration;
     import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;
     import com.sun.org.apache.xerces.internal.util.HTTPInputSource;
     import com.sun.org.apache.xerces.internal.util.IntStack;
    @@ -129,8 +131,6 @@ import org.xml.sax.InputSource;
     public class XIncludeHandler
         implements XMLComponent, XMLDocumentFilter, XMLDTDFilter {
     
    -    public final static String XINCLUDE_DEFAULT_CONFIGURATION =
    -        "com.sun.org.apache.xerces.internal.parsers.XIncludeParserConfiguration";
         public final static String HTTP_ACCEPT = "Accept";
         public final static String HTTP_ACCEPT_LANGUAGE = "Accept-Language";
         public final static String XPOINTER = "xpointer";
    @@ -1624,12 +1624,12 @@ public class XIncludeHandler
                     includedSource =
                         fEntityResolver.resolveEntity(resourceIdentifier);
     
    -                if (includedSource == null) {
    +                if (includedSource == null && fUseCatalog) {
                         if (fCatalogFeatures == null) {
                             fCatalogFeatures = JdkXmlUtils.getCatalogFeatures(fDefer, fCatalogFile, fPrefer, fResolve);
                         }
                         fCatalogFile = fCatalogFeatures.get(CatalogFeatures.Feature.FILES);
    -                    if (fUseCatalog && fCatalogFile != null) {
    +                    if (fCatalogFile != null) {
                             /*
                                Although URI entry is preferred for resolving XInclude, system entry
                                is allowed as well.
    @@ -1690,14 +1690,11 @@ public class XIncludeHandler
                 if ((xpointer != null && fXPointerChildConfig == null)
                             || (xpointer == null && fXIncludeChildConfig == null) ) {
     
    -                String parserName = XINCLUDE_DEFAULT_CONFIGURATION;
    -                if (xpointer != null)
    -                        parserName = "com.sun.org.apache.xerces.internal.parsers.XPointerParserConfiguration";
    -
    -                fChildConfig =
    -                    (XMLParserConfiguration)ObjectFactory.newInstance(
    -                        parserName,
    -                        true);
    +                if (xpointer == null) {
    +                    fChildConfig = new XIncludeParserConfiguration();
    +                } else {
    +                    fChildConfig = new XPointerParserConfiguration();
    +                }
     
                     // use the same symbol table, error reporter, entity resolver, security manager and buffer size.
                     if (fSymbolTable != null) fChildConfig.setProperty(SYMBOL_TABLE, fSymbolTable);
    diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java
    index 792cb13ee89..dc96ce2832e 100644
    --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java
    +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java
    @@ -32,7 +32,6 @@ import javax.xml.transform.dom.DOMSource;
     import javax.xml.transform.sax.SAXSource;
     import javax.xml.transform.stax.StAXSource;
     import javax.xml.transform.stream.StreamSource;
    -
     import org.testng.annotations.BeforeClass;
     import org.testng.annotations.DataProvider;
     import org.testng.annotations.Listeners;
    @@ -42,7 +41,7 @@ import org.xml.sax.InputSource;
     
     /**
      * @test
    - * @bug 8158084 8162438 8162442 8166220
    + * @bug 8158084 8162438 8162442 8166220 8166398
      * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
      * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport
      * @run testng/othervm catalog.CatalogSupport
    @@ -51,7 +50,7 @@ import org.xml.sax.InputSource;
      * A custom resolver is used whether or not there's a Catalog;
      * A Catalog is used when there's no custom resolver, and the USE_CATALOG
      * is true (which is the case by default).
    - */
    +*/
     
     /**
      * Support Catalog:
    @@ -177,13 +176,13 @@ public class CatalogSupport extends CatalogSupportBase {
          */
         @DataProvider(name = "data_SAXA")
         public Object[][] getDataSAX() {
    -        String[] systemIds = {"system.xsd"};
    -        InputSource[] returnValues = {new InputSource(new StringReader(dtd_systemResolved))};
    -        MyEntityHandler entityHandler = new MyEntityHandler(systemIds, returnValues, elementInSystem);
    +        String[] systemIds = {"system.dtd"};
             return new Object[][]{
                 {false, true, xml_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog},
    -            {false, true, xml_catalog, xml_system, entityHandler, expectedWResolver},
    -            {true, true, xml_catalog, xml_system, entityHandler, expectedWResolver}
    +            {false, true, xml_catalog, xml_system, getMyEntityHandler(elementInSystem, systemIds,
    +                    new InputSource(new StringReader(dtd_systemResolved))), expectedWResolver},
    +            {true, true, xml_catalog, xml_system, getMyEntityHandler(elementInSystem, systemIds,
    +                    new InputSource(new StringReader(dtd_systemResolved))), expectedWResolver}
             };
         }
     
    @@ -209,7 +208,7 @@ public class CatalogSupport extends CatalogSupportBase {
          */
         @DataProvider(name = "data_DOMA")
         public Object[][] getDataDOM() {
    -        String[] systemIds = {"system.xsd"};
    +        String[] systemIds = {"system.dtd"};
             InputSource[] returnValues = {new InputSource(new StringReader(dtd_systemResolved))};
             MyEntityHandler entityHandler = new MyEntityHandler(systemIds, returnValues, elementInSystem);
             return new Object[][]{
    @@ -230,8 +229,8 @@ public class CatalogSupport extends CatalogSupportBase {
     
             return new Object[][]{
                 {false, true, xml_catalog, xml_system, null, expectedWCatalog},
    -            {false, true, xml_catalog, xml_system, null, expectedWResolver},
    -            {true, true, xml_catalog, xml_system, null, expectedWResolver}
    +            {false, true, xml_catalog, xml_system, new MyStaxEntityResolver(), expectedWResolver},
    +            {true, true, xml_catalog, xml_system, new MyStaxEntityResolver(), expectedWResolver}
             };
         }
     
    diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml
    index f889ac50a78..63432cb50e8 100644
    --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml
    +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml
    @@ -15,6 +15,7 @@
         
         
         
    +    
         
     
         
    diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java
    index 27bf6b4b661..236e5cda0dc 100644
    --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java
    +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java
    @@ -276,7 +276,7 @@ public class CatalogSupportBase {
             SAXParser parser = getSAXParser(setUseCatalog, useCatalog, catalog);
     
             parser.parse(xml, handler);
    -        assertEquals(expected, handler.getResult().trim(), "");
    +        Assert.assertEquals(handler.getResult().trim(), expected);
         }
     
         /*
    @@ -287,8 +287,9 @@ public class CatalogSupportBase {
             XMLReader reader = getXMLReader(setUseCatalog, useCatalog, catalog);
     
             reader.setContentHandler(handler);
    +        reader.setEntityResolver(handler);
             reader.parse(xml);
    -        assertEquals(expected, handler.getResult().trim(), "");
    +        Assert.assertEquals(handler.getResult().trim(), expected);
         }
     
         /*
    @@ -300,7 +301,7 @@ public class CatalogSupportBase {
     
             parser.parse(new InputSource(new StringReader(xml)), handler);
             debugPrint("handler.result:" + handler.getResult());
    -        assertEquals(expected, handler.getResult(), "Catalog support for XInclude");
    +        Assert.assertEquals(handler.getResult().trim(), expected);
         }
     
         /*
    @@ -314,8 +315,7 @@ public class CatalogSupportBase {
     
             Node node = doc.getElementsByTagName(elementInSystem).item(0);
             String result = node.getFirstChild().getTextContent();
    -
    -        assertEquals(expected, result.trim(), "Catalog support for DOM");
    +        Assert.assertEquals(result.trim(), expected);
         }
     
         /*
    @@ -327,7 +327,7 @@ public class CatalogSupportBase {
                 XMLStreamReader streamReader = getStreamReader(
                         setUseCatalog, useCatalog, catalog, xml, resolver);
                 String text = getText(streamReader, XMLStreamConstants.CHARACTERS);
    -            assertEquals(expected, text.trim(), "Catalog support for StAX");
    +            Assert.assertEquals(text.trim(), expected);
         }
     
         /*
    @@ -340,7 +340,7 @@ public class CatalogSupportBase {
                 XMLStreamReader streamReader = getStreamReader(
                         setUseCatalog, useCatalog, catalog, xml, resolver);
                 String text = getText(streamReader, XMLStreamConstants.ENTITY_REFERENCE);
    -            assertEquals(expected, text.trim(), "Catalog support for StAX");
    +            Assert.assertEquals(text.trim(), expected);
         }
     
         /*
    @@ -601,9 +601,11 @@ public class CatalogSupportBase {
         }
     
         /**
    -     * Returns the text of the first element found by the reader.
    +     * Returns the accumulated text of an event type.
    +     *
          * @param streamReader the XMLStreamReader
    -     * @return the text of the first element
    +     * @param type the type of event requested
    +     * @return the text of the accumulated text for the request type
          * @throws XMLStreamException
          */
         String getText(XMLStreamReader streamReader, int type) throws XMLStreamException {
    @@ -662,24 +664,6 @@ public class CatalogSupportBase {
             return factory;
         }
     
    -    void assertNotNull(Object obj, String msg) {
    -        if (obj == null) {
    -            debugPrint("Test failed: " + msg);
    -        } else {
    -            debugPrint("Test passed: " + obj + " is not null");
    -        }
    -    }
    -
    -    void assertEquals(String expected, String actual, String msg) {
    -        if (!expected.equals(actual)) {
    -            debugPrint("Test failed: " + msg);
    -        } else {
    -            debugPrint("Test passed: ");
    -        }
    -        debugPrint("Expected: " + expected);
    -        debugPrint("Actual: " + actual);
    -    }
    -
         void fail(String msg) {
             System.out.println("Test failed:");
             System.out.println(msg);
    diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/XI_simple4Catalog.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/XI_simple4Catalog.xml
    index af26081369d..dc199c5fad2 100644
    --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/XI_simple4Catalog.xml
    +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/XI_simple4Catalog.xml
    @@ -9,7 +9,7 @@
         
       
       
    -    
    +    
       
       
        
    diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/XI_test2Catalog.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/XI_test2Catalog.xml
    new file mode 100644
    index 00000000000..62c4ed3d105
    --- /dev/null
    +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/XI_test2Catalog.xml
    @@ -0,0 +1,10 @@
    +
    +
    +
    +
    +  
    +    
    +  
    +
    +
    +
    
    From 8d4f1ae8dffb2556ceb900c81cc78415f88efb60 Mon Sep 17 00:00:00 2001
    From: Valerie Peng 
    Date: Fri, 23 Sep 2016 01:08:24 +0000
    Subject: [PATCH 64/81] 8136355: CKM_SSL3_KEY_AND_MAC_DERIVE no longer
     available by default on Solaris 12
    
    Enhanced to detect and throw InvalidAlgorithmParameterException if SSLv3 is requested but unsupported
    
    Reviewed-by: xuelei
    ---
     .../pkcs11/P11TlsKeyMaterialGenerator.java    | 35 +++++++----
     .../pkcs11/P11TlsMasterSecretGenerator.java   | 63 +++++++++++--------
     .../P11TlsRsaPremasterSecretGenerator.java    | 25 +++++++-
     .../security/pkcs11/tls/TestKeyMaterial.java  | 38 ++++++-----
     .../security/pkcs11/tls/TestMasterSecret.java | 30 ++++++---
     .../security/pkcs11/tls/TestPremaster.java    | 17 ++++-
     6 files changed, 138 insertions(+), 70 deletions(-)
    
    diff --git a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java
    index c054f312c55..83ecaa1701f 100644
    --- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java
    +++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsKeyMaterialGenerator.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 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,8 +68,8 @@ public final class P11TlsKeyMaterialGenerator extends KeyGeneratorSpi {
         // master secret as a P11Key
         private P11Key p11Key;
     
    -    // version, e.g. 0x0301
    -    private int version;
    +    // whether SSLv3 is supported
    +    private final boolean supportSSLv3;
     
         P11TlsKeyMaterialGenerator(Token token, String algorithm, long mechanism)
                 throws PKCS11Exception {
    @@ -77,6 +77,11 @@ public final class P11TlsKeyMaterialGenerator extends KeyGeneratorSpi {
             this.token = token;
             this.algorithm = algorithm;
             this.mechanism = mechanism;
    +
    +        // Given the current lookup order specified in SunPKCS11.java,
    +        // if CKM_SSL3_KEY_AND_MAC_DERIVE is not used to construct this object,
    +        // it means that this mech is disabled or unsupported.
    +        this.supportSSLv3 = (mechanism == CKM_SSL3_KEY_AND_MAC_DERIVE);
         }
     
         protected void engineInit(SecureRandom random) {
    @@ -89,20 +94,26 @@ public final class P11TlsKeyMaterialGenerator extends KeyGeneratorSpi {
             if (params instanceof TlsKeyMaterialParameterSpec == false) {
                 throw new InvalidAlgorithmParameterException(MSG);
             }
    -        this.spec = (TlsKeyMaterialParameterSpec)params;
    +
    +        TlsKeyMaterialParameterSpec spec = (TlsKeyMaterialParameterSpec)params;
    +        int version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
    +
    +        if ((version == 0x0300 && !supportSSLv3) || (version < 0x0300) ||
    +            (version > 0x0302)) {
    +             throw new InvalidAlgorithmParameterException
    +                    ("Only" + (supportSSLv3? " SSL 3.0,": "") +
    +                     " TLS 1.0, and TLS 1.1 are supported (0x" +
    +                     Integer.toHexString(version) + ")");
    +        }
             try {
                 p11Key = P11SecretKeyFactory.convertKey
                                 (token, spec.getMasterSecret(), "TlsMasterSecret");
             } catch (InvalidKeyException e) {
                 throw new InvalidAlgorithmParameterException("init() failed", e);
             }
    -        version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
    -        if ((version < 0x0300) && (version > 0x0302)) {
    -            throw new InvalidAlgorithmParameterException
    -                    ("Only SSL 3.0, TLS 1.0, and TLS 1.1 are supported");
    -        }
    -        // we assume the token supports both the CKM_SSL3_* and the CKM_TLS_*
    -        // mechanisms
    +        this.spec = spec;
    +        this.mechanism = (version == 0x0300)?
    +            CKM_SSL3_KEY_AND_MAC_DERIVE : CKM_TLS_KEY_AND_MAC_DERIVE;
         }
     
         protected void engineInit(int keysize, SecureRandom random) {
    @@ -115,8 +126,6 @@ public final class P11TlsKeyMaterialGenerator extends KeyGeneratorSpi {
                 throw new IllegalStateException
                     ("TlsKeyMaterialGenerator must be initialized");
             }
    -        mechanism = (version == 0x0300) ? CKM_SSL3_KEY_AND_MAC_DERIVE
    -                                         : CKM_TLS_KEY_AND_MAC_DERIVE;
             int macBits = spec.getMacKeyLength() << 3;
             int ivBits = spec.getIvLength() << 3;
     
    diff --git a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsMasterSecretGenerator.java b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsMasterSecretGenerator.java
    index 73a2ac2e890..128952e8a49 100644
    --- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsMasterSecretGenerator.java
    +++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsMasterSecretGenerator.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 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
    @@ -61,7 +61,10 @@ public final class P11TlsMasterSecretGenerator extends KeyGeneratorSpi {
         private TlsMasterSecretParameterSpec spec;
         private P11Key p11Key;
     
    -    int version;
    +    CK_VERSION ckVersion;
    +
    +    // whether SSLv3 is supported
    +    private final boolean supportSSLv3;
     
         P11TlsMasterSecretGenerator(Token token, String algorithm, long mechanism)
                 throws PKCS11Exception {
    @@ -69,6 +72,11 @@ public final class P11TlsMasterSecretGenerator extends KeyGeneratorSpi {
             this.token = token;
             this.algorithm = algorithm;
             this.mechanism = mechanism;
    +
    +        // Given the current lookup order specified in SunPKCS11.java, if
    +        // CKM_SSL3_MASTER_KEY_DERIVE is not used to construct this object,
    +        // it means that this mech is disabled or unsupported.
    +        supportSSLv3 = (mechanism == CKM_SSL3_MASTER_KEY_DERIVE);
         }
     
         protected void engineInit(SecureRandom random) {
    @@ -81,7 +89,17 @@ public final class P11TlsMasterSecretGenerator extends KeyGeneratorSpi {
             if (params instanceof TlsMasterSecretParameterSpec == false) {
                 throw new InvalidAlgorithmParameterException(MSG);
             }
    -        this.spec = (TlsMasterSecretParameterSpec)params;
    +
    +        TlsMasterSecretParameterSpec spec = (TlsMasterSecretParameterSpec)params;
    +        int version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
    +        if ((version == 0x0300 && !supportSSLv3) || (version < 0x0300) ||
    +            (version > 0x0302)) {
    +             throw new InvalidAlgorithmParameterException
    +                    ("Only" + (supportSSLv3? " SSL 3.0,": "") +
    +                     " TLS 1.0, and TLS 1.1 are supported (0x" +
    +                     Integer.toHexString(version) + ")");
    +        }
    +
             SecretKey key = spec.getPremasterSecret();
             // algorithm should be either TlsRsaPremasterSecret or TlsPremasterSecret,
             // but we omit the check
    @@ -90,25 +108,7 @@ public final class P11TlsMasterSecretGenerator extends KeyGeneratorSpi {
             } catch (InvalidKeyException e) {
                 throw new InvalidAlgorithmParameterException("init() failed", e);
             }
    -        version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
    -        if ((version < 0x0300) || (version > 0x0302)) {
    -            throw new InvalidAlgorithmParameterException
    -                ("Only SSL 3.0, TLS 1.0, and TLS 1.1 supported");
    -        }
    -        // We assume the token supports the required mechanism. If it does not,
    -        // generateKey() will fail and the failover should take care of us.
    -    }
    -
    -    protected void engineInit(int keysize, SecureRandom random) {
    -        throw new InvalidParameterException(MSG);
    -    }
    -
    -    protected SecretKey engineGenerateKey() {
    -        if (spec == null) {
    -            throw new IllegalStateException
    -                ("TlsMasterSecretGenerator must be initialized");
    -        }
    -        CK_VERSION ckVersion;
    +        this.spec = spec;
             if (p11Key.getAlgorithm().equals("TlsRsaPremasterSecret")) {
                 mechanism = (version == 0x0300) ? CKM_SSL3_MASTER_KEY_DERIVE
                                                  : CKM_TLS_MASTER_KEY_DERIVE;
    @@ -124,6 +124,17 @@ public final class P11TlsMasterSecretGenerator extends KeyGeneratorSpi {
                                                  : CKM_TLS_MASTER_KEY_DERIVE_DH;
                 ckVersion = null;
             }
    +    }
    +
    +    protected void engineInit(int keysize, SecureRandom random) {
    +        throw new InvalidParameterException(MSG);
    +    }
    +
    +    protected SecretKey engineGenerateKey() {
    +        if (spec == null) {
    +            throw new IllegalStateException
    +                ("TlsMasterSecretGenerator must be initialized");
    +        }
             byte[] clientRandom = spec.getClientRandom();
             byte[] serverRandom = spec.getServerRandom();
             CK_SSL3_RANDOM_DATA random =
    @@ -139,13 +150,12 @@ public final class P11TlsMasterSecretGenerator extends KeyGeneratorSpi {
                 long keyID = token.p11.C_DeriveKey(session.id(),
                     new CK_MECHANISM(mechanism, params), p11Key.keyID, attributes);
                 int major, minor;
    -            ckVersion = params.pVersion;
    -            if (ckVersion == null) {
    +            if (params.pVersion == null) {
                     major = -1;
                     minor = -1;
                 } else {
    -                major = ckVersion.major;
    -                minor = ckVersion.minor;
    +                major = params.pVersion.major;
    +                minor = params.pVersion.minor;
                 }
                 SecretKey key = P11Key.masterSecretKey(session, keyID,
                     "TlsMasterSecret", 48 << 3, attributes, major, minor);
    @@ -156,5 +166,4 @@ public final class P11TlsMasterSecretGenerator extends KeyGeneratorSpi {
                 token.releaseSession(session);
             }
         }
    -
     }
    diff --git a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsRsaPremasterSecretGenerator.java b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsRsaPremasterSecretGenerator.java
    index 40d3a634ce5..245c067b3d4 100644
    --- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsRsaPremasterSecretGenerator.java
    +++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/P11TlsRsaPremasterSecretGenerator.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 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
    @@ -60,12 +60,20 @@ final class P11TlsRsaPremasterSecretGenerator extends KeyGeneratorSpi {
         @SuppressWarnings("deprecation")
         private TlsRsaPremasterSecretParameterSpec spec;
     
    +    // whether SSLv3 is supported
    +    private final boolean supportSSLv3;
    +
         P11TlsRsaPremasterSecretGenerator(Token token, String algorithm, long mechanism)
                 throws PKCS11Exception {
             super();
             this.token = token;
             this.algorithm = algorithm;
             this.mechanism = mechanism;
    +
    +        // Given the current lookup order specified in SunPKCS11.java,
    +        // if CKM_SSL3_PRE_MASTER_KEY_GEN is not used to construct this object,
    +        // it means that this mech is disabled or unsupported.
    +        this.supportSSLv3 = (mechanism == CKM_SSL3_PRE_MASTER_KEY_GEN);
         }
     
         protected void engineInit(SecureRandom random) {
    @@ -78,7 +86,20 @@ final class P11TlsRsaPremasterSecretGenerator extends KeyGeneratorSpi {
             if (!(params instanceof TlsRsaPremasterSecretParameterSpec)) {
                 throw new InvalidAlgorithmParameterException(MSG);
             }
    -        this.spec = (TlsRsaPremasterSecretParameterSpec)params;
    +
    +        TlsRsaPremasterSecretParameterSpec spec =
    +            (TlsRsaPremasterSecretParameterSpec) params;
    +
    +        int version = (spec.getMajorVersion() << 8) | spec.getMinorVersion();
    +
    +        if ((version == 0x0300 && !supportSSLv3) || (version < 0x0300) ||
    +            (version > 0x0302)) {
    +             throw new InvalidAlgorithmParameterException
    +                    ("Only" + (supportSSLv3? " SSL 3.0,": "") +
    +                     " TLS 1.0, and TLS 1.1 are supported (0x" +
    +                     Integer.toHexString(version) + ")");
    +        }
    +        this.spec = spec;
         }
     
         protected void engineInit(int keysize, SecureRandom random) {
    diff --git a/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java b/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java
    index 27944e92f89..81a8b4571ba 100644
    --- a/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java
    +++ b/jdk/test/sun/security/pkcs11/tls/TestKeyMaterial.java
    @@ -23,7 +23,7 @@
     
     /*
      * @test
    - * @bug 6316539
    + * @bug 6316539 8136355
      * @summary Known-answer-test for TlsKeyMaterial generator
      * @author Andreas Sterbenz
      * @library ..
    @@ -37,6 +37,7 @@ import java.io.BufferedReader;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     import java.security.Provider;
    +import java.security.InvalidAlgorithmParameterException;
     import java.util.Arrays;
     import javax.crypto.KeyGenerator;
     import javax.crypto.SecretKey;
    @@ -139,21 +140,28 @@ public class TestKeyMaterial extends PKCS11Test {
                             keyLength, expandedKeyLength, ivLength, macLength,
                             null, -1, -1);
     
    -                    kg.init(spec);
    -                    TlsKeyMaterialSpec result =
    -                        (TlsKeyMaterialSpec)kg.generateKey();
    -                    match(lineNumber, clientCipherBytes,
    -                        result.getClientCipherKey(), cipherAlgorithm);
    -                    match(lineNumber, serverCipherBytes,
    -                        result.getServerCipherKey(), cipherAlgorithm);
    -                    match(lineNumber, clientIv, result.getClientIv(), "");
    -                    match(lineNumber, serverIv, result.getServerIv(), "");
    -                    match(lineNumber, clientMacBytes, result.getClientMacKey(), "");
    -                    match(lineNumber, serverMacBytes, result.getServerMacKey(), "");
    -
    -                } else {
    +                    try {
    +                        kg.init(spec);
    +                        TlsKeyMaterialSpec result =
    +                            (TlsKeyMaterialSpec)kg.generateKey();
    +                        match(lineNumber, clientCipherBytes,
    +                            result.getClientCipherKey(), cipherAlgorithm);
    +                        match(lineNumber, serverCipherBytes,
    +                            result.getServerCipherKey(), cipherAlgorithm);
    +                        match(lineNumber, clientIv, result.getClientIv(), "");
    +                        match(lineNumber, serverIv, result.getServerIv(), "");
    +                        match(lineNumber, clientMacBytes, result.getClientMacKey(), "");
    +                        match(lineNumber, serverMacBytes, result.getServerMacKey(), "");
    +                    } catch (InvalidAlgorithmParameterException iape) {
    +                        // SSLv3 support is removed in S12
    +                        if (major == 3 && minor == 0) {
    +                            System.out.println("Skip testing SSLv3");
    +                            continue;
    +                        }
    +                    }
    +               } else {
                         throw new Exception("Unknown line: " + line);
    -                }
    +               }
                 }
                 if (n == 0) {
                     throw new Exception("no tests");
    diff --git a/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java b/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java
    index 67ee6e708bd..de6863608d5 100644
    --- a/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java
    +++ b/jdk/test/sun/security/pkcs11/tls/TestMasterSecret.java
    @@ -23,7 +23,7 @@
     
     /*
      * @test
    - * @bug 6316539
    + * @bug 6316539 8136355
      * @summary Known-answer-test for TlsMasterSecret generator
      * @author Andreas Sterbenz
      * @library ..
    @@ -38,6 +38,7 @@ import java.io.BufferedReader;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     import java.security.Provider;
    +import java.security.InvalidAlgorithmParameterException;
     import java.util.Arrays;
     import javax.crypto.KeyGenerator;
     import javax.crypto.SecretKey;
    @@ -116,15 +117,24 @@ public class TestMasterSecret extends PKCS11Test {
                             new TlsMasterSecretParameterSpec(premasterKey,
                                 protoMajor, protoMinor, clientRandom, serverRandom,
                                 null, -1, -1);
    -                    kg.init(spec);
    -                    TlsMasterSecret key = (TlsMasterSecret)kg.generateKey();
    -                    byte[] enc = key.getEncoded();
    -                    if (Arrays.equals(master, enc) == false) {
    -                        throw new Exception("mismatch line: " + lineNumber);
    -                    }
    -                    if ((preMajor != key.getMajorVersion()) ||
    -                            (preMinor != key.getMinorVersion())) {
    -                        throw new Exception("version mismatch line: " + lineNumber);
    +
    +                    try {
    +                        kg.init(spec);
    +                        TlsMasterSecret key = (TlsMasterSecret)kg.generateKey();
    +                        byte[] enc = key.getEncoded();
    +                        if (Arrays.equals(master, enc) == false) {
    +                            throw new Exception("mismatch line: " + lineNumber);
    +                        }
    +                        if ((preMajor != key.getMajorVersion()) ||
    +                                (preMinor != key.getMinorVersion())) {
    +                           throw new Exception("version mismatch line: " + lineNumber);
    +                        }
    +                    } catch (InvalidAlgorithmParameterException iape) {
    +                        // SSLv3 support is removed in S12
    +                        if (preMajor == 3 && preMinor == 0) {
    +                            System.out.println("Skip testing SSLv3");
    +                            continue;
    +                        }
                         }
                     } else {
                         throw new Exception("Unknown line: " + line);
    diff --git a/jdk/test/sun/security/pkcs11/tls/TestPremaster.java b/jdk/test/sun/security/pkcs11/tls/TestPremaster.java
    index a179bb81c2a..67191a7df28 100644
    --- a/jdk/test/sun/security/pkcs11/tls/TestPremaster.java
    +++ b/jdk/test/sun/security/pkcs11/tls/TestPremaster.java
    @@ -23,7 +23,7 @@
     
     /*
      * @test
    - * @bug 6316539
    + * @bug 6316539 8136355
      * @summary Basic tests for TlsRsaPremasterSecret generator
      * @author Andreas Sterbenz
      * @library ..
    @@ -34,6 +34,7 @@
      */
     
     import java.security.Provider;
    +import java.security.InvalidAlgorithmParameterException;
     import javax.crypto.KeyGenerator;
     import javax.crypto.SecretKey;
     import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
    @@ -61,7 +62,7 @@ public class TestPremaster extends PKCS11Test {
                 System.out.println("OK: " + e);
             }
     
    -        int[] protocolVersions = {0x0300, 0x0301, 0x0302, 0x0400};
    +        int[] protocolVersions = {0x0300, 0x0301, 0x0302};
             for (int clientVersion : protocolVersions) {
                 for (int serverVersion : protocolVersions) {
                     test(kg, clientVersion, serverVersion);
    @@ -81,8 +82,18 @@ public class TestPremaster extends PKCS11Test {
                     "Testing RSA pre-master secret key generation between " +
                     "client (0x%04X) and server(0x%04X)%n",
                     clientVersion, serverVersion);
    -        kg.init(new TlsRsaPremasterSecretParameterSpec(
    +        try {
    +            kg.init(new TlsRsaPremasterSecretParameterSpec(
                                         clientVersion, serverVersion));
    +        } catch (InvalidAlgorithmParameterException iape) {
    +            // S12 removed support for SSL v3.0
    +            if (clientVersion == 0x300 || serverVersion == 0x300) {
    +                System.out.println("Skip testing SSLv3 due to no support");
    +                return;
    +            }
    +            // unexpected, pass it up
    +            throw iape;
    +        }
             SecretKey key = kg.generateKey();
             byte[] encoded = key.getEncoded();
             if (encoded != null) {  // raw key material may be not extractable
    
    From 8469097dde95e44e6d5c68d6380a836b778a362c Mon Sep 17 00:00:00 2001
    From: Felix Yang 
    Date: Fri, 23 Sep 2016 03:15:00 -0700
    Subject: [PATCH 65/81] 8085049: java/net/MulticastSocket/TimeToLive.java fails
     intermittently with "Address already in use"
    
    Reviewed-by: chegar
    ---
     jdk/test/java/net/MulticastSocket/TimeToLive.java | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/jdk/test/java/net/MulticastSocket/TimeToLive.java b/jdk/test/java/net/MulticastSocket/TimeToLive.java
    index 6d3158f7396..99f2641d5d8 100644
    --- a/jdk/test/java/net/MulticastSocket/TimeToLive.java
    +++ b/jdk/test/java/net/MulticastSocket/TimeToLive.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1998, 1999, 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
    @@ -37,7 +37,7 @@ public class TimeToLive {
         static int[] bad_ttls = { -1, 256 };
     
         public static void main(String[] args) throws Exception {
    -        MulticastSocket socket = new MulticastSocket(6789);
    +        MulticastSocket socket = new MulticastSocket();
             int ttl = socket.getTimeToLive();
             System.out.println("default ttl: " + ttl);
             for (int i = 0; i < new_ttls.length; i++) {
    
    From 281862a6aa0e34d98193960b3d30937e304d2eef Mon Sep 17 00:00:00 2001
    From: Michael Haupt 
    Date: Fri, 23 Sep 2016 15:20:49 +0200
    Subject: [PATCH 66/81] 8161211: better inlining support for loop bytecode
     intrinsics
    
    Reviewed-by: jrose, vlivanov, redestad
    ---
     .../java/lang/invoke/BoundMethodHandle.java   |   1 -
     .../lang/invoke/InvokerBytecodeGenerator.java |  99 ++++++++++------
     .../classes/java/lang/invoke/LambdaForm.java  |   5 +-
     .../java/lang/invoke/MethodHandleImpl.java    | 110 +++++++++++-------
     .../java/lang/invoke/MethodHandles.java       |  16 ++-
     .../java/lang/invoke/MethodHandlesTest.java   |   7 ++
     6 files changed, 150 insertions(+), 88 deletions(-)
    
    diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
    index 461dd3967cb..395e80ca6b0 100644
    --- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
    +++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
    @@ -869,5 +869,4 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
         static SpeciesData speciesData_LLL()    { return checkCache(3, "LLL"); }
         static SpeciesData speciesData_LLLL()   { return checkCache(4, "LLLL"); }
         static SpeciesData speciesData_LLLLL()  { return checkCache(5, "LLLLL"); }
    -    static SpeciesData speciesData_LLLLLL() { return checkCache(6, "LLLLLL"); }
     }
    diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
    index afb04b6efa4..ea6236aa2d9 100644
    --- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
    +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
    @@ -39,14 +39,14 @@ import java.io.File;
     import java.io.FileOutputStream;
     import java.io.IOException;
     import java.lang.reflect.Modifier;
    -import java.util.Arrays;
     import java.util.ArrayList;
    +import java.util.Arrays;
     import java.util.HashMap;
     import java.util.stream.Stream;
     
    -import static java.lang.invoke.LambdaForm.*;
    +import static java.lang.invoke.LambdaForm.BasicType;
     import static java.lang.invoke.LambdaForm.BasicType.*;
    -import static java.lang.invoke.LambdaForm.Kind.*;
    +import static java.lang.invoke.LambdaForm.*;
     import static java.lang.invoke.MethodHandleNatives.Constants.*;
     import static java.lang.invoke.MethodHandleStatics.*;
     
    @@ -65,6 +65,9 @@ class InvokerBytecodeGenerator {
         private static final String OBJ     = "java/lang/Object";
         private static final String OBJARY  = "[Ljava/lang/Object;";
     
    +    private static final String LOOP_CLAUSES = MHI + "$LoopClauses";
    +    private static final String MHARY2       = "[[L" + MH + ";";
    +
         private static final String LF_SIG  = "L" + LF + ";";
         private static final String LFN_SIG = "L" + LFN + ";";
         private static final String LL_SIG  = "(L" + OBJ + ";)L" + OBJ + ";";
    @@ -1319,38 +1322,43 @@ class InvokerBytecodeGenerator {
          * The pattern looks like (Cf. MethodHandleImpl.loop):
          * 
    {@code
          * // a0: BMH
    -     * // a1: inits, a2: steps, a3: preds, a4: finis
    -     * // a5: box, a6: unbox
    -     * // a7 (and following): arguments
    -     * loop=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L,a5:L,a6:L,a7:L)=>{
    -     *   t8:L=MethodHandle.invokeBasic(a5:L,a7:L);                  // box the arguments into an Object[]
    -     *   t9:L=MethodHandleImpl.loop(bt:L,a1:L,a2:L,a3:L,a4:L,t8:L); // call the loop executor (with supplied types in bt)
    -     *   t10:L=MethodHandle.invokeBasic(a6:L,t9:L);t10:L}           // unbox the result; return the result
    +     * // a1: LoopClauses (containing an array of arrays: inits, steps, preds, finis)
    +     * // a2: box, a3: unbox
    +     * // a4 (and following): arguments
    +     * loop=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L)=>{
    +     *   t5:L=MethodHandle.invokeBasic(a2:L,a4:L);          // box the arguments into an Object[]
    +     *   t6:L=MethodHandleImpl.loop(bt:L,a1:L,t5:L);        // call the loop executor (with supplied types in bt)
    +     *   t7:L=MethodHandle.invokeBasic(a3:L,t6:L);t7:L}     // unbox the result; return the result
          * }
    *

    * It is compiled into bytecode equivalent to the code seen in {@link MethodHandleImpl#loop(BasicType[], - * MethodHandle[], MethodHandle[], MethodHandle[], MethodHandle[], Object...)}, with the difference that no arrays + * MethodHandleImpl.LoopClauses, Object...)}, with the difference that no arrays * will be used for local state storage. Instead, the local state will be mapped to actual stack slots. *

    * Bytecode generation applies an unrolling scheme to enable better bytecode generation regarding local state type * handling. The generated bytecode will have the following form ({@code void} types are ignored for convenience). * Assume there are {@code C} clauses in the loop. *

    {@code
    -     * INIT: (INIT_SEQ for clause 1)
    -     *       ...
    -     *       (INIT_SEQ for clause C)
    -     * LOOP: (LOOP_SEQ for clause 1)
    -     *       ...
    -     *       (LOOP_SEQ for clause C)
    -     *       GOTO LOOP
    -     * DONE: ...
    +     * PREINIT: ALOAD_1
    +     *          CHECKCAST LoopClauses
    +     *          GETFIELD LoopClauses.clauses
    +     *          ASTORE clauseDataIndex          // place the clauses 2-dimensional array on the stack
    +     * INIT:    (INIT_SEQ for clause 1)
    +     *          ...
    +     *          (INIT_SEQ for clause C)
    +     * LOOP:    (LOOP_SEQ for clause 1)
    +     *          ...
    +     *          (LOOP_SEQ for clause C)
    +     *          GOTO LOOP
    +     * DONE:    ...
          * }
    *

    * The {@code INIT_SEQ_x} sequence for clause {@code x} (with {@code x} ranging from {@code 0} to {@code C-1}) has * the following shape. Assume slot {@code vx} is used to hold the state for clause {@code x}. *

    {@code
    -     * INIT_SEQ_x:  ALOAD inits
    -     *              CHECKCAST MethodHandle[]
    +     * INIT_SEQ_x:  ALOAD clauseDataIndex
    +     *              ICONST_0
    +     *              AALOAD      // load the inits array
          *              ICONST x
          *              AALOAD      // load the init handle for clause x
          *              load args
    @@ -1361,24 +1369,27 @@ class InvokerBytecodeGenerator {
          * The {@code LOOP_SEQ_x} sequence for clause {@code x} (with {@code x} ranging from {@code 0} to {@code C-1}) has
          * the following shape. Again, assume slot {@code vx} is used to hold the state for clause {@code x}.
          * 
    {@code
    -     * LOOP_SEQ_x:  ALOAD steps
    -     *              CHECKCAST MethodHandle[]
    +     * LOOP_SEQ_x:  ALOAD clauseDataIndex
    +     *              ICONST_1
    +     *              AALOAD              // load the steps array
          *              ICONST x
          *              AALOAD              // load the step handle for clause x
          *              load locals
          *              load args
          *              INVOKEVIRTUAL MethodHandle.invokeBasic
          *              store vx
    -     *              ALOAD preds
    -     *              CHECKCAST MethodHandle[]
    +     *              ALOAD clauseDataIndex
    +     *              ICONST_2
    +     *              AALOAD              // load the preds array
          *              ICONST x
          *              AALOAD              // load the pred handle for clause x
          *              load locals
          *              load args
          *              INVOKEVIRTUAL MethodHandle.invokeBasic
          *              IFNE LOOP_SEQ_x+1   // predicate returned false -> jump to next clause
    -     *              ALOAD finis
    -     *              CHECKCAST MethodHandle[]
    +     *              ALOAD clauseDataIndex
    +     *              ICONST_3
    +     *              AALOAD              // load the finis array
          *              ICONST x
          *              AALOAD              // load the fini handle for clause x
          *              load locals
    @@ -1397,8 +1408,12 @@ class InvokerBytecodeGenerator {
             BasicType[] loopClauseTypes = (BasicType[]) invoker.arguments[0];
             Class[] loopLocalStateTypes = Stream.of(loopClauseTypes).
                     filter(bt -> bt != BasicType.V_TYPE).map(BasicType::basicTypeClass).toArray(Class[]::new);
    +        Class[] localTypes = new Class[loopLocalStateTypes.length + 1];
    +        localTypes[0] = MethodHandleImpl.LoopClauses.class;
    +        System.arraycopy(loopLocalStateTypes, 0, localTypes, 1, loopLocalStateTypes.length);
     
    -        final int firstLoopStateIndex = extendLocalsMap(loopLocalStateTypes);
    +        final int clauseDataIndex = extendLocalsMap(localTypes);
    +        final int firstLoopStateIndex = clauseDataIndex + 1;
     
             Class returnType = result.function.resolvedHandle().type().returnType();
             MethodType loopType = args.function.resolvedHandle().type()
    @@ -1420,10 +1435,16 @@ class InvokerBytecodeGenerator {
             Label lDone = new Label();
             Label lNext;
     
    +        // PREINIT:
    +        emitPushArgument(MethodHandleImpl.LoopClauses.class, invoker.arguments[1]);
    +        mv.visitFieldInsn(Opcodes.GETFIELD, LOOP_CLAUSES, "clauses", MHARY2);
    +        emitAstoreInsn(clauseDataIndex);
    +
             // INIT:
             for (int c = 0, state = 0; c < nClauses; ++c) {
                 MethodType cInitType = loopType.changeReturnType(loopClauseTypes[c].basicTypeClass());
    -            emitLoopHandleInvoke(invoker, inits, c, args, false, cInitType, loopLocalStateTypes, firstLoopStateIndex);
    +            emitLoopHandleInvoke(invoker, inits, c, args, false, cInitType, loopLocalStateTypes, clauseDataIndex,
    +                    firstLoopStateIndex);
                 if (cInitType.returnType() != void.class) {
                     emitStoreInsn(BasicType.basicType(cInitType.returnType()), firstLoopStateIndex + state);
                     ++state;
    @@ -1440,18 +1461,21 @@ class InvokerBytecodeGenerator {
                 boolean isVoid = stepType.returnType() == void.class;
     
                 // invoke loop step
    -            emitLoopHandleInvoke(invoker, steps, c, args, true, stepType, loopLocalStateTypes, firstLoopStateIndex);
    +            emitLoopHandleInvoke(invoker, steps, c, args, true, stepType, loopLocalStateTypes, clauseDataIndex,
    +                    firstLoopStateIndex);
                 if (!isVoid) {
                     emitStoreInsn(BasicType.basicType(stepType.returnType()), firstLoopStateIndex + state);
                     ++state;
                 }
     
                 // invoke loop predicate
    -            emitLoopHandleInvoke(invoker, preds, c, args, true, predType, loopLocalStateTypes, firstLoopStateIndex);
    +            emitLoopHandleInvoke(invoker, preds, c, args, true, predType, loopLocalStateTypes, clauseDataIndex,
    +                    firstLoopStateIndex);
                 mv.visitJumpInsn(Opcodes.IFNE, lNext);
     
                 // invoke fini
    -            emitLoopHandleInvoke(invoker, finis, c, args, true, finiType, loopLocalStateTypes, firstLoopStateIndex);
    +            emitLoopHandleInvoke(invoker, finis, c, args, true, finiType, loopLocalStateTypes, clauseDataIndex,
    +                    firstLoopStateIndex);
                 mv.visitJumpInsn(Opcodes.GOTO, lDone);
     
                 // this is the beginning of the next loop clause
    @@ -1483,9 +1507,10 @@ class InvokerBytecodeGenerator {
         }
     
         private void emitLoopHandleInvoke(Name holder, int handles, int clause, Name args, boolean pushLocalState,
    -                                      MethodType type, Class[] loopLocalStateTypes, int firstLoopStateSlot) {
    +                                      MethodType type, Class[] loopLocalStateTypes, int clauseDataSlot,
    +                                      int firstLoopStateSlot) {
             // load handle for clause
    -        emitPushArgument(holder, handles);
    +        emitPushClauseArray(clauseDataSlot, handles);
             emitIconstInsn(clause);
             mv.visitInsn(Opcodes.AALOAD);
             // load loop state (preceding the other arguments)
    @@ -1499,6 +1524,12 @@ class InvokerBytecodeGenerator {
             mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.toMethodDescriptorString(), false);
         }
     
    +    private void emitPushClauseArray(int clauseDataSlot, int which) {
    +        emitAloadInsn(clauseDataSlot);
    +        emitIconstInsn(which - 1);
    +        mv.visitInsn(Opcodes.AALOAD);
    +    }
    +
         private void emitZero(BasicType type) {
             switch (type) {
                 case I_TYPE: mv.visitInsn(Opcodes.ICONST_0); break;
    diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
    index 6fdf21e2c91..bcc825bcf15 100644
    --- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
    +++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
    @@ -41,7 +41,6 @@ import java.util.HashMap;
     import static java.lang.invoke.LambdaForm.BasicType.*;
     import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic;
     import static java.lang.invoke.MethodHandleStatics.*;
    -import java.util.Objects;
     
     /**
      * The symbolic, non-executable form of a method handle's invocation semantics.
    @@ -732,9 +731,9 @@ class LambdaForm {
         boolean isLoop(int pos) {
             // loop idiom:
             //   t_{n}:L=MethodHandle.invokeBasic(...)
    -        //   t_{n+1}:L=MethodHandleImpl.loop(types, *, *, *, *, t_{n})
    +        //   t_{n+1}:L=MethodHandleImpl.loop(types, *, t_{n})
             //   t_{n+2}:?=MethodHandle.invokeBasic(*, t_{n+1})
    -        return isMatchingIdiom(pos, "loop", 5);
    +        return isMatchingIdiom(pos, "loop", 2);
         }
     
         /*
    diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
    index 4fe4bb524a7..ca4f050553f 100644
    --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
    +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
    @@ -1689,8 +1689,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
                 NF_tryFinally = new NamedFunction(MethodHandleImpl.class
                         .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
                 NF_loop = new NamedFunction(MethodHandleImpl.class
    -                    .getDeclaredMethod("loop", BasicType[].class, MethodHandle[].class, MethodHandle[].class,
    -                            MethodHandle[].class, MethodHandle[].class, Object[].class));
    +                    .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
                 NF_throwException = new NamedFunction(MethodHandleImpl.class
                         .getDeclaredMethod("throwException", Throwable.class));
                 NF_profileBoolean = new NamedFunction(MethodHandleImpl.class
    @@ -1794,12 +1793,13 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
             MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
             MethodHandle unboxResult = unboxResultHandle(tloop);
     
    -        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLLL();
    +        LoopClauses clauseData =
    +                new LoopClauses(new MethodHandle[][]{toArray(init), toArray(step), toArray(pred), toArray(fini)});
    +        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
             BoundMethodHandle mh;
             try {
    -            mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) toArray(init),
    -                    (Object) toArray(step), (Object) toArray(pred), (Object) toArray(fini), (Object) collectArgs,
    -                    (Object) unboxResult);
    +            mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) clauseData,
    +                    (Object) collectArgs, (Object) unboxResult);
             } catch (Throwable ex) {
                 throw uncaughtException(ex);
             }
    @@ -1818,23 +1818,20 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
          * {@code t12}):
          * 
    {@code
          *  loop=Lambda(a0:L,a1:L)=>{
    -     *    t2:L=BoundMethodHandle$Species_L6.argL0(a0:L);             // array of init method handles
    -     *    t3:L=BoundMethodHandle$Species_L6.argL1(a0:L);             // array of step method handles
    -     *    t4:L=BoundMethodHandle$Species_L6.argL2(a0:L);             // array of pred method handles
    -     *    t5:L=BoundMethodHandle$Species_L6.argL3(a0:L);             // array of fini method handles
    -     *    t6:L=BoundMethodHandle$Species_L6.argL4(a0:L);             // helper handle to box the arguments into an Object[]
    -     *    t7:L=BoundMethodHandle$Species_L6.argL5(a0:L);             // helper handle to unbox the result
    -     *    t8:L=MethodHandle.invokeBasic(t6:L,a1:L);                  // box the arguments into an Object[]
    -     *    t9:L=MethodHandleImpl.loop(null,t2:L,t3:L,t4:L,t5:L,t6:L); // call the loop executor
    -     *    t10:L=MethodHandle.invokeBasic(t7:L,t9:L);t10:L}           // unbox the result; return the result
    +     *    t2:L=BoundMethodHandle$Species_L3.argL0(a0:L);    // LoopClauses holding init, step, pred, fini handles
    +     *    t3:L=BoundMethodHandle$Species_L3.argL1(a0:L);    // helper handle to box the arguments into an Object[]
    +     *    t4:L=BoundMethodHandle$Species_L3.argL2(a0:L);    // helper handle to unbox the result
    +     *    t5:L=MethodHandle.invokeBasic(t3:L,a1:L);         // box the arguments into an Object[]
    +     *    t6:L=MethodHandleImpl.loop(null,t2:L,t3:L);       // call the loop executor
    +     *    t7:L=MethodHandle.invokeBasic(t4:L,t6:L);t7:L}    // unbox the result; return the result
          * }
    *

    - * {@code argL0} through {@code argL3} are the arrays of init, step, pred, and fini method handles. - * {@code argL4} and {@code argL5} are auxiliary method handles: {@code argL2} boxes arguments and wraps them into - * {@code Object[]} ({@code ValueConversions.array()}), and {@code argL3} unboxes the result if necessary + * {@code argL0} is a LoopClauses instance holding, in a 2-dimensional array, the init, step, pred, and fini method + * handles. {@code argL1} and {@code argL2} are auxiliary method handles: {@code argL1} boxes arguments and wraps + * them into {@code Object[]} ({@code ValueConversions.array()}), and {@code argL2} unboxes the result if necessary * ({@code ValueConversions.unbox()}). *

    - * Having {@code t6} and {@code t7} passed in via a BMH and not hardcoded in the lambda form allows to share lambda + * Having {@code t3} and {@code t4} passed in via a BMH and not hardcoded in the lambda form allows to share lambda * forms among loop combinators with the same basic type. *

    * The above template is instantiated by using the {@link LambdaFormEditor} to replace the {@code null} argument to @@ -1845,15 +1842,12 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; private static LambdaForm makeLoopForm(MethodType basicType, BasicType[] localVarTypes) { MethodType lambdaType = basicType.invokerType(); - final int THIS_MH = 0; // the BMH_LLLLLL + final int THIS_MH = 0; // the BMH_LLL final int ARG_BASE = 1; // start of incoming arguments final int ARG_LIMIT = ARG_BASE + basicType.parameterCount(); int nameCursor = ARG_LIMIT; - final int GET_INITS = nameCursor++; - final int GET_STEPS = nameCursor++; - final int GET_PREDS = nameCursor++; - final int GET_FINIS = nameCursor++; + final int GET_CLAUSE_DATA = nameCursor++; final int GET_COLLECT_ARGS = nameCursor++; final int GET_UNBOX_RESULT = nameCursor++; final int BOXED_ARGS = nameCursor++; @@ -1864,14 +1858,11 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; if (lform == null) { Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); - BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLLL(); + BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL(); names[THIS_MH] = names[THIS_MH].withConstraint(data); - names[GET_INITS] = new Name(data.getterFunction(0), names[THIS_MH]); - names[GET_STEPS] = new Name(data.getterFunction(1), names[THIS_MH]); - names[GET_PREDS] = new Name(data.getterFunction(2), names[THIS_MH]); - names[GET_FINIS] = new Name(data.getterFunction(3), names[THIS_MH]); - names[GET_COLLECT_ARGS] = new Name(data.getterFunction(4), names[THIS_MH]); - names[GET_UNBOX_RESULT] = new Name(data.getterFunction(5), names[THIS_MH]); + names[GET_CLAUSE_DATA] = new Name(data.getterFunction(0), names[THIS_MH]); + names[GET_COLLECT_ARGS] = new Name(data.getterFunction(1), names[THIS_MH]); + names[GET_UNBOX_RESULT] = new Name(data.getterFunction(2), names[THIS_MH]); // t_{i}:L=MethodHandle.invokeBasic(collectArgs:L,a1:L,...); MethodType collectArgsType = basicType.changeReturnType(Object.class); @@ -1881,10 +1872,10 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; System.arraycopy(names, ARG_BASE, args, 1, ARG_LIMIT - ARG_BASE); names[BOXED_ARGS] = new Name(makeIntrinsic(invokeBasic, Intrinsic.LOOP), args); - // t_{i+1}:L=MethodHandleImpl.loop(localTypes:L,inits:L,steps:L,preds:L,finis:L,t_{i}:L); + // t_{i+1}:L=MethodHandleImpl.loop(localTypes:L,clauses:L,t_{i}:L); Object[] lArgs = new Object[]{null, // placeholder for BasicType[] localTypes - will be added by LambdaFormEditor - names[GET_INITS], names[GET_STEPS], names[GET_PREDS], names[GET_FINIS], names[BOXED_ARGS]}; + names[GET_CLAUSE_DATA], names[BOXED_ARGS]}; names[LOOP] = new Name(NF_loop, lArgs); // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L); @@ -1900,22 +1891,52 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; return lform.editor().noteLoopLocalTypesForm(BOXED_ARGS, localVarTypes); } + static class LoopClauses { + @Stable final MethodHandle[][] clauses; + LoopClauses(MethodHandle[][] clauses) { + assert clauses.length == 4; + this.clauses = clauses; + } + @Override + public String toString() { + StringBuffer sb = new StringBuffer("LoopClauses -- "); + for (int i = 0; i < 4; ++i) { + if (i > 0) { + sb.append(" "); + } + sb.append('<').append(i).append(">: "); + MethodHandle[] hs = clauses[i]; + for (int j = 0; j < hs.length; ++j) { + if (j > 0) { + sb.append(" "); + } + sb.append('*').append(j).append(": ").append(hs[j]).append('\n'); + } + } + sb.append(" --\n"); + return sb.toString(); + } + } /** * Intrinsified during LambdaForm compilation * (see {@link InvokerBytecodeGenerator#emitLoop(int)}). */ @LambdaForm.Hidden - static Object loop(BasicType[] localTypes, MethodHandle[] init, MethodHandle[] step, MethodHandle[] pred, - MethodHandle[] fini, Object... av) throws Throwable { + static Object loop(BasicType[] localTypes, LoopClauses clauseData, Object... av) throws Throwable { + final MethodHandle[] init = clauseData.clauses[0]; + final MethodHandle[] step = clauseData.clauses[1]; + final MethodHandle[] pred = clauseData.clauses[2]; + final MethodHandle[] fini = clauseData.clauses[3]; int varSize = (int) Stream.of(init).filter(h -> h.type().returnType() != void.class).count(); int nArgs = init[0].type().parameterCount(); Object[] varsAndArgs = new Object[varSize + nArgs]; for (int i = 0, v = 0; i < init.length; ++i) { - if (init[i].type().returnType() == void.class) { - init[i].asFixedArity().invokeWithArguments(av); + MethodHandle ih = init[i]; + if (ih.type().returnType() == void.class) { + ih.invokeWithArguments(av); } else { - varsAndArgs[v++] = init[i].asFixedArity().invokeWithArguments(av); + varsAndArgs[v++] = ih.invokeWithArguments(av); } } System.arraycopy(av, 0, varsAndArgs, varSize, nArgs); @@ -1926,12 +1947,12 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; MethodHandle s = step[i]; MethodHandle f = fini[i]; if (s.type().returnType() == void.class) { - s.asFixedArity().invokeWithArguments(varsAndArgs); + s.invokeWithArguments(varsAndArgs); } else { - varsAndArgs[v++] = s.asFixedArity().invokeWithArguments(varsAndArgs); + varsAndArgs[v++] = s.invokeWithArguments(varsAndArgs); } - if (!(boolean) p.asFixedArity().invokeWithArguments(varsAndArgs)) { - return f.asFixedArity().invokeWithArguments(varsAndArgs); + if (!(boolean) p.invokeWithArguments(varsAndArgs)) { + return f.invokeWithArguments(varsAndArgs); } } } @@ -2122,14 +2143,13 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; Throwable t = null; Object r = null; try { - // Use asFixedArity() to avoid unnecessary boxing of last argument for VarargsCollector case. - r = target.asFixedArity().invokeWithArguments(av); + r = target.invokeWithArguments(av); } catch (Throwable thrown) { t = thrown; throw t; } finally { Object[] args = target.type().returnType() == void.class ? prepend(av, t) : prepend(av, t, r); - r = cleanup.asFixedArity().invokeWithArguments(args); + r = cleanup.invokeWithArguments(args); } return r; } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index 86685b605de..28364e53ae9 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -4368,10 +4368,11 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); } // Step 4: fill in missing parameter types. - List finit = fillParameterTypes(init, commonSuffix); - List fstep = fillParameterTypes(step, commonParameterSequence); - List fpred = fillParameterTypes(pred, commonParameterSequence); - List ffini = fillParameterTypes(fini, commonParameterSequence); + // Also convert all handles to fixed-arity handles. + List finit = fixArities(fillParameterTypes(init, commonSuffix)); + List fstep = fixArities(fillParameterTypes(step, commonParameterSequence)); + List fpred = fixArities(fillParameterTypes(pred, commonParameterSequence)); + List ffini = fixArities(fillParameterTypes(fini, commonParameterSequence)); assert finit.stream().map(MethodHandle::type).map(MethodType::parameterList). allMatch(pl -> pl.equals(commonSuffix)); @@ -4389,6 +4390,10 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); }).collect(Collectors.toList()); } + private static List fixArities(List hs) { + return hs.stream().map(MethodHandle::asFixedArity).collect(Collectors.toList()); + } + /** * Constructs a {@code while} loop from an initializer, a body, and a predicate. This is a convenience wrapper for * the {@linkplain #loop(MethodHandle[][]) generic loop combinator}. @@ -4887,7 +4892,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum")); // target parameter list. cleanup = dropArgumentsToMatch(cleanup, (rtype == void.class ? 1 : 2), targetParamTypes, 0); - return MethodHandleImpl.makeTryFinally(target, cleanup, rtype, targetParamTypes); + // Use asFixedArity() to avoid unnecessary boxing of last argument for VarargsCollector case. + return MethodHandleImpl.makeTryFinally(target.asFixedArity(), cleanup.asFixedArity(), rtype, targetParamTypes); } /** diff --git a/jdk/test/java/lang/invoke/MethodHandlesTest.java b/jdk/test/java/lang/invoke/MethodHandlesTest.java index 0f4e7236c62..2098b5bb2a8 100644 --- a/jdk/test/java/lang/invoke/MethodHandlesTest.java +++ b/jdk/test/java/lang/invoke/MethodHandlesTest.java @@ -632,6 +632,7 @@ public class MethodHandlesTest { } public void testFindVirtualClone0() throws Throwable { + if (CAN_SKIP_WORKING) return; // test some ad hoc system methods testFindVirtual(false, PUBLIC, Object.class, Object.class, "clone"); @@ -2798,11 +2799,17 @@ public class MethodHandlesTest { toClauseMajor(postClauses, inits, steps, usePreds, finis); MethodHandle pre = MethodHandles.loop(preClauses); MethodHandle post = MethodHandles.loop(postClauses); + if (verbosity >= 6) { + System.out.println("pre-handle: " + pre); + } Object[] preResults = (Object[]) pre.invokeWithArguments(args); if (verbosity >= 4) { System.out.println("pre-checked: expected " + Arrays.asList(preCheckedResults[i]) + ", actual " + Arrays.asList(preResults)); } + if (verbosity >= 6) { + System.out.println("post-handle: " + post); + } Object[] postResults = (Object[]) post.invokeWithArguments(args); if (verbosity >= 4) { System.out.println("post-checked: expected " + Arrays.asList(postCheckedResults[i]) + ", actual " + From 90dc5934608f07fc04e7caf8cfe899c757743849 Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Fri, 23 Sep 2016 15:31:46 +0100 Subject: [PATCH 67/81] 8159410: InetAddress.isReachable returns true for non existing IP adresses Reviewed-by: chegar, coffeys --- .../windows/native/libnet/Inet4AddressImpl.c | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c index 30b2a93ffcc..debc50a1543 100644 --- a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c +++ b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "java_net_InetAddress.h" #include "java_net_Inet4AddressImpl.h" @@ -442,7 +443,15 @@ ping4(JNIEnv *env, DWORD ReplySize = 0; jboolean ret = JNI_FALSE; - ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData); + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366051%28v=vs.85%29.aspx + ReplySize = sizeof(ICMP_ECHO_REPLY) // The buffer should be large enough + // to hold at least one ICMP_ECHO_REPLY + // structure + + sizeof(SendData) // plus RequestSize bytes of data. + + 8; // This buffer should also be large enough + // to also hold 8 more bytes of data + // (the size of an ICMP error message) + ReplyBuffer = (VOID*) malloc(ReplySize); if (ReplyBuffer == NULL) { IcmpCloseHandle(hIcmpFile); @@ -478,10 +487,45 @@ ping4(JNIEnv *env, (timeout < 1000) ? 1000 : timeout); // DWORD Timeout } - if (dwRetVal != 0) { + if (dwRetVal == 0) { // if the call failed + TCHAR *buf; + DWORD err = WSAGetLastError(); + switch (err) { + case ERROR_NO_NETWORK: + case ERROR_NETWORK_UNREACHABLE: + case ERROR_HOST_UNREACHABLE: + case ERROR_PROTOCOL_UNREACHABLE: + case ERROR_PORT_UNREACHABLE: + case ERROR_REQUEST_ABORTED: + case ERROR_INCORRECT_ADDRESS: + case ERROR_HOST_DOWN: + case WSAEHOSTUNREACH: /* Host Unreachable */ + case WSAENETUNREACH: /* Network Unreachable */ + case WSAENETDOWN: /* Network is down */ + case WSAEPFNOSUPPORT: /* Protocol Family unsupported */ + case IP_REQ_TIMED_OUT: + break; + default: + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&buf, 0, NULL); + NET_ThrowNew(env, err, buf); + LocalFree(buf); + break; + } + } else { PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer; - if ((int)pEchoReply->RoundTripTime <= timeout) + + // This is to take into account the undocumented minimum + // timeout mentioned in the IcmpSendEcho call above. + // We perform an extra check to make sure that our + // roundtrip time was less than our desired timeout + // for cases where that timeout is < 1000ms. + if (pEchoReply->Status == IP_SUCCESS + && (int)pEchoReply->RoundTripTime <= timeout) + { ret = JNI_TRUE; + } } free(ReplyBuffer); From 72a44a46fa380a5eb9ee3ee712608b0933618af6 Mon Sep 17 00:00:00 2001 From: Sergei Kovalev Date: Fri, 23 Sep 2016 12:08:38 +0300 Subject: [PATCH 68/81] 8166553: undeclared dependencies for two IO tests Reviewed-by: bpb --- jdk/test/java/io/PrintStream/FormatLocale.java | 3 ++- jdk/test/sun/nio/cs/TestUnmappable.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/io/PrintStream/FormatLocale.java b/jdk/test/java/io/PrintStream/FormatLocale.java index 08d6817d193..ce10a21b388 100644 --- a/jdk/test/java/io/PrintStream/FormatLocale.java +++ b/jdk/test/java/io/PrintStream/FormatLocale.java @@ -21,10 +21,11 @@ * questions. */ -/** +/* * @test * @bug 8146156 * @summary test whether conversion follows Locale.Category.FORMAT locale. + * @modules jdk.localedata * @run main/othervm FormatLocale */ diff --git a/jdk/test/sun/nio/cs/TestUnmappable.java b/jdk/test/sun/nio/cs/TestUnmappable.java index 6273807cce3..8204fdf4d10 100644 --- a/jdk/test/sun/nio/cs/TestUnmappable.java +++ b/jdk/test/sun/nio/cs/TestUnmappable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 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 @@ -28,11 +28,11 @@ * @bug 8008386 * @summary (cs) Unmappable leading should be decoded to replacement. * Tests for Shift_JIS and MS932 decoding + * @modules jdk.charsets * @run main TestUnmappable */ -import java.nio.*; -import java.nio.charset.*; +import java.nio.charset.Charset; public class TestUnmappable { public static void main(String args[]) throws Exception { From 9496149e05fc2d73bca12f2d659b842136f4dc80 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 23 Sep 2016 13:14:14 -0700 Subject: [PATCH 69/81] 8166465: CompletableFuture.minimalCompletionStage().toCompletableFuture() should be non-minimal Reviewed-by: martin, chegar, shade --- .../util/concurrent/CompletableFuture.java | 17 ++ .../concurrent/tck/CompletableFutureTest.java | 228 +++++++++++++++--- 2 files changed, 215 insertions(+), 30 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java index 5708af2653c..9946b128591 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java @@ -2559,6 +2559,13 @@ public class CompletableFuture implements Future, CompletionStage { * exceptionally with a CompletionException with this exception as * cause. * + *

    Unless overridden by a subclass, a new non-minimal + * CompletableFuture with all methods available can be obtained from + * a minimal CompletionStage via {@link #toCompletableFuture()}. + * For example, completion of a minimal stage can be awaited by + * + *

     {@code minimalStage.toCompletableFuture().join(); }
    + * * @return the new CompletionStage * @since 9 */ @@ -2853,6 +2860,16 @@ public class CompletableFuture implements Future, CompletionStage { @Override public CompletableFuture completeOnTimeout (T value, long timeout, TimeUnit unit) { throw new UnsupportedOperationException(); } + @Override public CompletableFuture toCompletableFuture() { + Object r; + if ((r = result) != null) + return new CompletableFuture(encodeRelay(r)); + else { + CompletableFuture d = new CompletableFuture<>(); + unipush(new UniRelay(d, this)); + return d; + } + } } // VarHandle mechanics diff --git a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java index a29f50e0a24..12f7ee99b53 100644 --- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java +++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java @@ -388,7 +388,7 @@ public class CompletableFutureTest extends JSR166TestCase { checkCompletedNormally(f, "test"); } - abstract class CheckedAction { + abstract static class CheckedAction { int invocationCount = 0; final ExecutionMode m; CheckedAction(ExecutionMode m) { this.m = m; } @@ -400,7 +400,7 @@ public class CompletableFutureTest extends JSR166TestCase { void assertInvoked() { assertEquals(1, invocationCount); } } - abstract class CheckedIntegerAction extends CheckedAction { + abstract static class CheckedIntegerAction extends CheckedAction { Integer value; CheckedIntegerAction(ExecutionMode m) { super(m); } void assertValue(Integer expected) { @@ -409,7 +409,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class IntegerSupplier extends CheckedAction + static class IntegerSupplier extends CheckedAction implements Supplier { final Integer value; @@ -428,7 +428,7 @@ public class CompletableFutureTest extends JSR166TestCase { return (x == null) ? null : x + 1; } - class NoopConsumer extends CheckedIntegerAction + static class NoopConsumer extends CheckedIntegerAction implements Consumer { NoopConsumer(ExecutionMode m) { super(m); } @@ -438,7 +438,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class IncFunction extends CheckedIntegerAction + static class IncFunction extends CheckedIntegerAction implements Function { IncFunction(ExecutionMode m) { super(m); } @@ -456,7 +456,7 @@ public class CompletableFutureTest extends JSR166TestCase { - ((y == null) ? 99 : y.intValue()); } - class SubtractAction extends CheckedIntegerAction + static class SubtractAction extends CheckedIntegerAction implements BiConsumer { SubtractAction(ExecutionMode m) { super(m); } @@ -466,7 +466,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class SubtractFunction extends CheckedIntegerAction + static class SubtractFunction extends CheckedIntegerAction implements BiFunction { SubtractFunction(ExecutionMode m) { super(m); } @@ -476,14 +476,14 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class Noop extends CheckedAction implements Runnable { + static class Noop extends CheckedAction implements Runnable { Noop(ExecutionMode m) { super(m); } public void run() { invoked(); } } - class FailingSupplier extends CheckedAction + static class FailingSupplier extends CheckedAction implements Supplier { final CFException ex; @@ -494,7 +494,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class FailingConsumer extends CheckedIntegerAction + static class FailingConsumer extends CheckedIntegerAction implements Consumer { final CFException ex; @@ -506,7 +506,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class FailingBiConsumer extends CheckedIntegerAction + static class FailingBiConsumer extends CheckedIntegerAction implements BiConsumer { final CFException ex; @@ -518,7 +518,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class FailingFunction extends CheckedIntegerAction + static class FailingFunction extends CheckedIntegerAction implements Function { final CFException ex; @@ -530,7 +530,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class FailingBiFunction extends CheckedIntegerAction + static class FailingBiFunction extends CheckedIntegerAction implements BiFunction { final CFException ex; @@ -542,7 +542,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class FailingRunnable extends CheckedAction implements Runnable { + static class FailingRunnable extends CheckedAction implements Runnable { final CFException ex; FailingRunnable(ExecutionMode m) { super(m); ex = new CFException(); } public void run() { @@ -551,7 +551,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class CompletableFutureInc extends CheckedIntegerAction + static class CompletableFutureInc extends CheckedIntegerAction implements Function> { CompletableFutureInc(ExecutionMode m) { super(m); } @@ -564,7 +564,7 @@ public class CompletableFutureTest extends JSR166TestCase { } } - class FailingCompletableFutureFunction extends CheckedIntegerAction + static class FailingCompletableFutureFunction extends CheckedIntegerAction implements Function> { final CFException ex; @@ -3604,29 +3604,53 @@ public class CompletableFutureTest extends JSR166TestCase { * copy returns a CompletableFuture that is completed normally, * with the same value, when source is. */ - public void testCopy() { + public void testCopy_normalCompletion() { + for (boolean createIncomplete : new boolean[] { true, false }) + for (Integer v1 : new Integer[] { 1, null }) + { CompletableFuture f = new CompletableFuture<>(); + if (!createIncomplete) assertTrue(f.complete(v1)); CompletableFuture g = f.copy(); - checkIncomplete(f); - checkIncomplete(g); - f.complete(1); - checkCompletedNormally(f, 1); - checkCompletedNormally(g, 1); - } + if (createIncomplete) { + checkIncomplete(f); + checkIncomplete(g); + assertTrue(f.complete(v1)); + } + checkCompletedNormally(f, v1); + checkCompletedNormally(g, v1); + }} /** * copy returns a CompletableFuture that is completed exceptionally * when source is. */ - public void testCopy2() { - CompletableFuture f = new CompletableFuture<>(); - CompletableFuture g = f.copy(); - checkIncomplete(f); - checkIncomplete(g); + public void testCopy_exceptionalCompletion() { + for (boolean createIncomplete : new boolean[] { true, false }) + { CFException ex = new CFException(); - f.completeExceptionally(ex); + CompletableFuture f = new CompletableFuture<>(); + if (!createIncomplete) f.completeExceptionally(ex); + CompletableFuture g = f.copy(); + if (createIncomplete) { + checkIncomplete(f); + checkIncomplete(g); + f.completeExceptionally(ex); + } checkCompletedExceptionally(f, ex); checkCompletedWithWrappedException(g, ex); + }} + + /** + * Completion of a copy does not complete its source. + */ + public void testCopy_oneWayPropagation() { + CompletableFuture f = new CompletableFuture<>(); + assertTrue(f.copy().complete(1)); + assertTrue(f.copy().complete(null)); + assertTrue(f.copy().cancel(true)); + assertTrue(f.copy().cancel(false)); + assertTrue(f.copy().completeExceptionally(new CFException())); + checkIncomplete(f); } /** @@ -3991,7 +4015,10 @@ public class CompletableFutureTest extends JSR166TestCase { .collect(Collectors.toList()); List> stages = new ArrayList<>(); - stages.add(new CompletableFuture().minimalCompletionStage()); + CompletionStage min = + new CompletableFuture().minimalCompletionStage(); + stages.add(min); + stages.add(min.thenApply(x -> x)); stages.add(CompletableFuture.completedStage(1)); stages.add(CompletableFuture.failedStage(new CFException())); @@ -4027,6 +4054,131 @@ public class CompletableFutureTest extends JSR166TestCase { throw new Error("Methods did not throw UOE: " + bugs); } + /** + * minimalStage.toCompletableFuture() returns a CompletableFuture that + * is completed normally, with the same value, when source is. + */ + public void testMinimalCompletionStage_toCompletableFuture_normalCompletion() { + for (boolean createIncomplete : new boolean[] { true, false }) + for (Integer v1 : new Integer[] { 1, null }) + { + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); + if (!createIncomplete) assertTrue(f.complete(v1)); + CompletableFuture g = minimal.toCompletableFuture(); + if (createIncomplete) { + checkIncomplete(f); + checkIncomplete(g); + assertTrue(f.complete(v1)); + } + checkCompletedNormally(f, v1); + checkCompletedNormally(g, v1); + }} + + /** + * minimalStage.toCompletableFuture() returns a CompletableFuture that + * is completed exceptionally when source is. + */ + public void testMinimalCompletionStage_toCompletableFuture_exceptionalCompletion() { + for (boolean createIncomplete : new boolean[] { true, false }) + { + CFException ex = new CFException(); + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); + if (!createIncomplete) f.completeExceptionally(ex); + CompletableFuture g = minimal.toCompletableFuture(); + if (createIncomplete) { + checkIncomplete(f); + checkIncomplete(g); + f.completeExceptionally(ex); + } + checkCompletedExceptionally(f, ex); + checkCompletedWithWrappedException(g, ex); + }} + + /** + * minimalStage.toCompletableFuture() gives mutable CompletableFuture + */ + public void testMinimalCompletionStage_toCompletableFuture_mutable() { + for (Integer v1 : new Integer[] { 1, null }) + { + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); + CompletableFuture g = minimal.toCompletableFuture(); + assertTrue(g.complete(v1)); + checkCompletedNormally(g, v1); + checkIncomplete(f); + checkIncomplete(minimal.toCompletableFuture()); + }} + + /** + * minimalStage.toCompletableFuture().join() awaits completion + */ + public void testMinimalCompletionStage_toCompletableFuture_join() throws Exception { + for (boolean createIncomplete : new boolean[] { true, false }) + for (Integer v1 : new Integer[] { 1, null }) + { + CompletableFuture f = new CompletableFuture<>(); + if (!createIncomplete) assertTrue(f.complete(v1)); + CompletionStage minimal = f.minimalCompletionStage(); + if (createIncomplete) assertTrue(f.complete(v1)); + assertEquals(v1, minimal.toCompletableFuture().join()); + assertEquals(v1, minimal.toCompletableFuture().get()); + checkCompletedNormally(minimal.toCompletableFuture(), v1); + }} + + /** + * Completion of a toCompletableFuture copy of a minimal stage + * does not complete its source. + */ + public void testMinimalCompletionStage_toCompletableFuture_oneWayPropagation() { + CompletableFuture f = new CompletableFuture<>(); + CompletionStage g = f.minimalCompletionStage(); + assertTrue(g.toCompletableFuture().complete(1)); + assertTrue(g.toCompletableFuture().complete(null)); + assertTrue(g.toCompletableFuture().cancel(true)); + assertTrue(g.toCompletableFuture().cancel(false)); + assertTrue(g.toCompletableFuture().completeExceptionally(new CFException())); + checkIncomplete(g.toCompletableFuture()); + f.complete(1); + checkCompletedNormally(g.toCompletableFuture(), 1); + } + + /** Demo utility method for external reliable toCompletableFuture */ + static CompletableFuture toCompletableFuture(CompletionStage stage) { + CompletableFuture f = new CompletableFuture<>(); + stage.handle((T t, Throwable ex) -> { + if (ex != null) f.completeExceptionally(ex); + else f.complete(t); + return null; + }); + return f; + } + + /** Demo utility method to join a CompletionStage */ + static T join(CompletionStage stage) { + return toCompletableFuture(stage).join(); + } + + /** + * Joining a minimal stage "by hand" works + */ + public void testMinimalCompletionStage_join_by_hand() { + for (boolean createIncomplete : new boolean[] { true, false }) + for (Integer v1 : new Integer[] { 1, null }) + { + CompletableFuture f = new CompletableFuture<>(); + CompletionStage minimal = f.minimalCompletionStage(); + CompletableFuture g = new CompletableFuture<>(); + if (!createIncomplete) assertTrue(f.complete(v1)); + minimal.thenAccept((x) -> g.complete(x)); + if (createIncomplete) assertTrue(f.complete(v1)); + g.join(); + checkCompletedNormally(g, v1); + checkCompletedNormally(f, v1); + assertEquals(v1, join(minimal)); + }} + static class Monad { static class ZeroException extends RuntimeException { public ZeroException() { super("monadic zero"); } @@ -4317,6 +4469,22 @@ public class CompletableFutureTest extends JSR166TestCase { assertTrue(neverCompleted.thenRun(() -> {}).cancel(true)); } + /** + * Checks for garbage retention when MinimalStage.toCompletableFuture() + * is invoked many times. + * 8161600: Garbage retention when source CompletableFutures are never completed + * + * As of 2016-07, fails with OOME: + * ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testToCompletableFutureGarbageRetention tck + */ + public void testToCompletableFutureGarbageRetention() throws Throwable { + final int n = expensiveTests ? 900_000 : 10; + CompletableFuture neverCompleted = new CompletableFuture<>(); + CompletionStage minimal = neverCompleted.minimalCompletionStage(); + for (int i = 0; i < n; i++) + assertTrue(minimal.toCompletableFuture().cancel(true)); + } + // static U join(CompletionStage stage) { // CompletableFuture f = new CompletableFuture<>(); // stage.whenComplete((v, ex) -> { From c9f268cc15689f01be36e4e8b2512166991da66b Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 23 Sep 2016 13:18:22 -0700 Subject: [PATCH 70/81] 8166057: [testbug] CoreThreadTimeOut still uses hardcoded timeout Reviewed-by: martin, chegar, shade --- .../ThreadPoolExecutor/CoreThreadTimeOut.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java index 088907cae77..a8bb4c29615 100644 --- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java +++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java @@ -83,15 +83,18 @@ public class CoreThreadTimeOut { tpe.allowCoreThreadTimeOut(true); check(tpe.allowsCoreThreadTimeOut()); equal(countExecutorThreads(), 0); - long t0 = System.nanoTime(); - for (int i = 0; i < threadCount; i++) - tpe.submit(new Runnable() { public void run() {}}); - int count = countExecutorThreads(); - if (millisElapsedSince(t0) < timeoutMillis) - equal(count, threadCount); + long startTime = System.nanoTime(); + for (int i = 0; i < threadCount; i++) { + tpe.submit(() -> {}); + int count = countExecutorThreads(); + if (millisElapsedSince(startTime) < timeoutMillis) + equal(count, i + 1); + } while (countExecutorThreads() > 0 && - millisElapsedSince(t0) < 10 * 1000); + millisElapsedSince(startTime) < LONG_DELAY_MS) + Thread.yield(); equal(countExecutorThreads(), 0); + check(millisElapsedSince(startTime) >= timeoutMillis); tpe.shutdown(); check(tpe.allowsCoreThreadTimeOut()); check(tpe.awaitTermination(LONG_DELAY_MS, MILLISECONDS)); From edc7565f51768eeede4116a97993873beb400675 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 23 Sep 2016 13:21:23 -0700 Subject: [PATCH 71/81] 8166059: JSR166TestCase.java fails with NPE in dumpTestThreads on timeout Reviewed-by: martin, chegar, shade --- jdk/test/java/util/concurrent/tck/JSR166TestCase.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java index aaa97d8abcb..8a0360f9b99 100644 --- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java +++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java @@ -1032,14 +1032,17 @@ public class JSR166TestCase extends TestCase { ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); System.err.println("------ stacktrace dump start ------"); for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) { - String name = info.getThreadName(); + final String name = info.getThreadName(); + String lockName; if ("Signal Dispatcher".equals(name)) continue; if ("Reference Handler".equals(name) - && info.getLockName().startsWith("java.lang.ref.Reference$Lock")) + && (lockName = info.getLockName()) != null + && lockName.startsWith("java.lang.ref.Reference$Lock")) continue; if ("Finalizer".equals(name) - && info.getLockName().startsWith("java.lang.ref.ReferenceQueue$Lock")) + && (lockName = info.getLockName()) != null + && lockName.startsWith("java.lang.ref.ReferenceQueue$Lock")) continue; if ("checkForWedgedTest".equals(name)) continue; @@ -1783,7 +1786,7 @@ public class JSR166TestCase extends TestCase { * A CyclicBarrier that uses timed await and fails with * AssertionFailedErrors instead of throwing checked exceptions. */ - public class CheckedBarrier extends CyclicBarrier { + public static class CheckedBarrier extends CyclicBarrier { public CheckedBarrier(int parties) { super(parties); } public int await() { From c7cf1788eda68ef66e97c71d6626c198f7d77db2 Mon Sep 17 00:00:00 2001 From: Doug Lea Date: Fri, 23 Sep 2016 13:24:33 -0700 Subject: [PATCH 72/81] 8165919: Miscellaneous changes imported from jsr166 CVS 2016-09-21 Reviewed-by: martin, chegar, shade --- .../java/util/concurrent/ForkJoinPool.java | 31 +++++++------- .../concurrent/atomic/DoubleAccumulator.java | 40 ++++++++++--------- .../concurrent/atomic/LongAccumulator.java | 16 ++++---- .../util/Collections/EmptyNavigableMap.java | 3 -- .../util/Collections/EmptyNavigableSet.java | 3 +- jdk/test/java/util/Deque/ChorusLine.java | 10 ++++- .../java/util/PriorityQueue/ForgetMeNot.java | 6 ++- .../util/PriorityQueue/PriorityQueueSort.java | 8 +++- .../util/PriorityQueue/RemoveContains.java | 13 +++++- .../concurrent/Executors/AutoShutdown.java | 2 - .../tck/AtomicIntegerArrayTest.java | 12 +++--- .../concurrent/tck/AtomicLongArrayTest.java | 12 +++--- .../tck/ConcurrentSkipListMapTest.java | 2 +- .../tck/ConcurrentSkipListSetTest.java | 3 +- .../concurrent/tck/CyclicBarrierTest.java | 14 +++---- .../util/concurrent/tck/DelayQueueTest.java | 6 +-- .../util/concurrent/tck/ForkJoinPoolTest.java | 12 ++---- .../concurrent/tck/ScheduledExecutorTest.java | 13 +++--- .../java/util/concurrent/tck/TreeMapTest.java | 2 +- .../java/util/concurrent/tck/TreeSetTest.java | 3 +- 20 files changed, 112 insertions(+), 99 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index e8f7ac614df..98524dedc23 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -1191,7 +1191,7 @@ public class ForkJoinPool extends AbstractExecutorService { * Default idle timeout value (in milliseconds) for the thread * triggering quiescence to park waiting for new work */ - private static final long DEFAULT_KEEPALIVE = 60000L; + private static final long DEFAULT_KEEPALIVE = 60_000L; /** * Undershoot tolerance for idle timeouts @@ -2303,7 +2303,6 @@ public class ForkJoinPool extends AbstractExecutorService { throw new NullPointerException(); long ms = Math.max(unit.toMillis(keepAliveTime), TIMEOUT_SLOP); - String prefix = "ForkJoinPool-" + nextPoolId() + "-worker-"; int corep = Math.min(Math.max(corePoolSize, parallelism), MAX_CAP); long c = ((((long)(-corep) << TC_SHIFT) & TC_MASK) | (((long)(-parallelism) << RC_SHIFT) & RC_MASK)); @@ -2315,8 +2314,8 @@ public class ForkJoinPool extends AbstractExecutorService { n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16; n = (n + 1) << 1; // power of two, including space for submission queues + this.workerNamePrefix = "ForkJoinPool-" + nextPoolId() + "-worker-"; this.workQueues = new WorkQueue[n]; - this.workerNamePrefix = prefix; this.factory = factory; this.ueh = handler; this.saturate = saturate; @@ -2327,11 +2326,19 @@ public class ForkJoinPool extends AbstractExecutorService { checkPermission(); } + private Object newInstanceFromSystemProperty(String property) + throws ReflectiveOperationException { + String className = System.getProperty(property); + return (className == null) + ? null + : ClassLoader.getSystemClassLoader().loadClass(className) + .getConstructor().newInstance(); + } + /** * Constructor for common pool using parameters possibly * overridden by system properties */ - @SuppressWarnings("deprecation") // Class.newInstance private ForkJoinPool(byte forCommonPoolOnly) { int parallelism = -1; ForkJoinWorkerThreadFactory fac = null; @@ -2339,18 +2346,12 @@ public class ForkJoinPool extends AbstractExecutorService { try { // ignore exceptions in accessing/parsing properties String pp = System.getProperty ("java.util.concurrent.ForkJoinPool.common.parallelism"); - String fp = System.getProperty - ("java.util.concurrent.ForkJoinPool.common.threadFactory"); - String hp = System.getProperty - ("java.util.concurrent.ForkJoinPool.common.exceptionHandler"); if (pp != null) parallelism = Integer.parseInt(pp); - if (fp != null) - fac = ((ForkJoinWorkerThreadFactory)ClassLoader. - getSystemClassLoader().loadClass(fp).newInstance()); - if (hp != null) - handler = ((UncaughtExceptionHandler)ClassLoader. - getSystemClassLoader().loadClass(hp).newInstance()); + fac = (ForkJoinWorkerThreadFactory) newInstanceFromSystemProperty( + "java.util.concurrent.ForkJoinPool.common.threadFactory"); + handler = (UncaughtExceptionHandler) newInstanceFromSystemProperty( + "java.util.concurrent.ForkJoinPool.common.exceptionHandler"); } catch (Exception ignore) { } @@ -2373,8 +2374,8 @@ public class ForkJoinPool extends AbstractExecutorService { n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16; n = (n + 1) << 1; - this.workQueues = new WorkQueue[n]; this.workerNamePrefix = "ForkJoinPool.commonPool-worker-"; + this.workQueues = new WorkQueue[n]; this.factory = fac; this.ueh = handler; this.saturate = null; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java index f3e3531dbd9..0d0346f02d6 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/DoubleAccumulator.java @@ -35,6 +35,9 @@ package java.util.concurrent.atomic; +import static java.lang.Double.doubleToRawLongBits; +import static java.lang.Double.longBitsToDouble; + import java.io.Serializable; import java.util.function.DoubleBinaryOperator; @@ -91,7 +94,7 @@ public class DoubleAccumulator extends Striped64 implements Serializable { public DoubleAccumulator(DoubleBinaryOperator accumulatorFunction, double identity) { this.function = accumulatorFunction; - base = this.identity = Double.doubleToRawLongBits(identity); + base = this.identity = doubleToRawLongBits(identity); } /** @@ -101,18 +104,19 @@ public class DoubleAccumulator extends Striped64 implements Serializable { */ public void accumulate(double x) { Cell[] as; long b, v, r; int m; Cell a; - if ((as = cells) != null || - (r = Double.doubleToRawLongBits - (function.applyAsDouble - (Double.longBitsToDouble(b = base), x))) != b && !casBase(b, r)) { + if ((as = cells) != null + || ((r = doubleToRawLongBits + (function.applyAsDouble(longBitsToDouble(b = base), x))) != b + && !casBase(b, r))) { boolean uncontended = true; - if (as == null || (m = as.length - 1) < 0 || - (a = as[getProbe() & m]) == null || - !(uncontended = - (r = Double.doubleToRawLongBits - (function.applyAsDouble - (Double.longBitsToDouble(v = a.value), x))) == v || - a.cas(v, r))) + if (as == null + || (m = as.length - 1) < 0 + || (a = as[getProbe() & m]) == null + || !(uncontended = + ((r = doubleToRawLongBits + (function.applyAsDouble + (longBitsToDouble(v = a.value), x))) == v) + || a.cas(v, r))) doubleAccumulate(x, function, uncontended); } } @@ -128,12 +132,12 @@ public class DoubleAccumulator extends Striped64 implements Serializable { */ public double get() { Cell[] as = cells; - double result = Double.longBitsToDouble(base); + double result = longBitsToDouble(base); if (as != null) { for (Cell a : as) if (a != null) result = function.applyAsDouble - (result, Double.longBitsToDouble(a.value)); + (result, longBitsToDouble(a.value)); } return result; } @@ -168,12 +172,12 @@ public class DoubleAccumulator extends Striped64 implements Serializable { */ public double getThenReset() { Cell[] as = cells; - double result = Double.longBitsToDouble(base); + double result = longBitsToDouble(base); base = identity; if (as != null) { for (Cell a : as) { if (a != null) { - double v = Double.longBitsToDouble(a.value); + double v = longBitsToDouble(a.value); a.reset(identity); result = function.applyAsDouble(result, v); } @@ -267,9 +271,9 @@ public class DoubleAccumulator extends Striped64 implements Serializable { * held by this proxy */ private Object readResolve() { - double d = Double.longBitsToDouble(identity); + double d = longBitsToDouble(identity); DoubleAccumulator a = new DoubleAccumulator(function, d); - a.base = Double.doubleToRawLongBits(value); + a.base = doubleToRawLongBits(value); return a; } } diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java index 939a4a2eed9..8c6e332ad79 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/LongAccumulator.java @@ -103,14 +103,16 @@ public class LongAccumulator extends Striped64 implements Serializable { */ public void accumulate(long x) { Cell[] as; long b, v, r; int m; Cell a; - if ((as = cells) != null || - (r = function.applyAsLong(b = base, x)) != b && !casBase(b, r)) { + if ((as = cells) != null + || ((r = function.applyAsLong(b = base, x)) != b + && !casBase(b, r))) { boolean uncontended = true; - if (as == null || (m = as.length - 1) < 0 || - (a = as[getProbe() & m]) == null || - !(uncontended = - (r = function.applyAsLong(v = a.value, x)) == v || - a.cas(v, r))) + if (as == null + || (m = as.length - 1) < 0 + || (a = as[getProbe() & m]) == null + || !(uncontended = + (r = function.applyAsLong(v = a.value, x)) == v + || a.cas(v, r))) longAccumulate(x, function, uncontended); } } diff --git a/jdk/test/java/util/Collections/EmptyNavigableMap.java b/jdk/test/java/util/Collections/EmptyNavigableMap.java index 5daf055786a..359d30f4ab6 100644 --- a/jdk/test/java/util/Collections/EmptyNavigableMap.java +++ b/jdk/test/java/util/Collections/EmptyNavigableMap.java @@ -33,7 +33,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; -import java.util.NoSuchElementException; import java.util.NavigableMap; import java.util.SortedMap; import java.util.TreeMap; @@ -41,10 +40,8 @@ import org.testng.annotations.Test; import org.testng.annotations.DataProvider; import static org.testng.Assert.fail; -import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertSame; public class EmptyNavigableMap { diff --git a/jdk/test/java/util/Collections/EmptyNavigableSet.java b/jdk/test/java/util/Collections/EmptyNavigableSet.java index 7541f3d363b..afe216da8d7 100644 --- a/jdk/test/java/util/Collections/EmptyNavigableSet.java +++ b/jdk/test/java/util/Collections/EmptyNavigableSet.java @@ -41,10 +41,9 @@ import org.testng.annotations.Test; import org.testng.annotations.DataProvider; import static org.testng.Assert.fail; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; public class EmptyNavigableSet { diff --git a/jdk/test/java/util/Deque/ChorusLine.java b/jdk/test/java/util/Deque/ChorusLine.java index 2a09c65ef50..9f0d6f89aa5 100644 --- a/jdk/test/java/util/Deque/ChorusLine.java +++ b/jdk/test/java/util/Deque/ChorusLine.java @@ -28,8 +28,14 @@ * @author Martin Buchholz */ -import java.util.*; -import java.util.concurrent.*; +import java.util.ArrayDeque; +import java.util.Collection; +import java.util.Deque; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.NoSuchElementException; +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.LinkedBlockingDeque; public class ChorusLine { private interface Tweaker { diff --git a/jdk/test/java/util/PriorityQueue/ForgetMeNot.java b/jdk/test/java/util/PriorityQueue/ForgetMeNot.java index 7778d1d793d..6f9f65d529e 100644 --- a/jdk/test/java/util/PriorityQueue/ForgetMeNot.java +++ b/jdk/test/java/util/PriorityQueue/ForgetMeNot.java @@ -28,7 +28,11 @@ * @author Martin Buchholz */ -import java.util.*; +import java.util.Arrays; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.PriorityQueue; +import java.util.Queue; public class ForgetMeNot { private static void checkQ(PriorityQueue q, Integer...elts) { diff --git a/jdk/test/java/util/PriorityQueue/PriorityQueueSort.java b/jdk/test/java/util/PriorityQueue/PriorityQueueSort.java index 206d6e815c5..24229639163 100644 --- a/jdk/test/java/util/PriorityQueue/PriorityQueueSort.java +++ b/jdk/test/java/util/PriorityQueue/PriorityQueueSort.java @@ -37,7 +37,13 @@ * @summary Checks that a priority queue returns elements in sorted order across various operations */ -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Queue; +import java.util.PriorityQueue; public class PriorityQueueSort { diff --git a/jdk/test/java/util/PriorityQueue/RemoveContains.java b/jdk/test/java/util/PriorityQueue/RemoveContains.java index 4b5d5a93bf2..809478221dd 100644 --- a/jdk/test/java/util/PriorityQueue/RemoveContains.java +++ b/jdk/test/java/util/PriorityQueue/RemoveContains.java @@ -28,8 +28,17 @@ * @author Martin Buchholz */ -import java.util.*; -import java.util.concurrent.*; +import java.util.ArrayDeque; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.PriorityQueue; +import java.util.Queue; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.PriorityBlockingQueue; +import java.util.concurrent.LinkedTransferQueue; public class RemoveContains { static volatile int passed = 0, failed = 0; diff --git a/jdk/test/java/util/concurrent/Executors/AutoShutdown.java b/jdk/test/java/util/concurrent/Executors/AutoShutdown.java index 7e34e28bded..95dd38c02cc 100644 --- a/jdk/test/java/util/concurrent/Executors/AutoShutdown.java +++ b/jdk/test/java/util/concurrent/Executors/AutoShutdown.java @@ -31,8 +31,6 @@ */ import static java.util.concurrent.Executors.defaultThreadFactory; -import static java.util.concurrent.Executors.newFixedThreadPool; -import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; import static java.util.concurrent.Executors.newSingleThreadExecutor; import static java.util.concurrent.TimeUnit.MILLISECONDS; diff --git a/jdk/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java b/jdk/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java index d3d8f14f5c0..e12284063f1 100644 --- a/jdk/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java +++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java @@ -303,7 +303,7 @@ public class AtomicIntegerArrayTest extends JSR166TestCase { class Counter extends CheckedRunnable { final AtomicIntegerArray aa; - volatile int counts; + int decs; Counter(AtomicIntegerArray a) { aa = a; } public void realRun() { for (;;) { @@ -314,7 +314,7 @@ public class AtomicIntegerArrayTest extends JSR166TestCase { if (v != 0) { done = false; if (aa.compareAndSet(i, v, v - 1)) - ++counts; + decs++; } } if (done) @@ -334,13 +334,11 @@ public class AtomicIntegerArrayTest extends JSR166TestCase { aa.set(i, countdown); Counter c1 = new Counter(aa); Counter c2 = new Counter(aa); - Thread t1 = new Thread(c1); - Thread t2 = new Thread(c2); - t1.start(); - t2.start(); + Thread t1 = newStartedThread(c1); + Thread t2 = newStartedThread(c2); t1.join(); t2.join(); - assertEquals(c1.counts+c2.counts, SIZE * countdown); + assertEquals(c1.decs + c2.decs, SIZE * countdown); } /** diff --git a/jdk/test/java/util/concurrent/tck/AtomicLongArrayTest.java b/jdk/test/java/util/concurrent/tck/AtomicLongArrayTest.java index bd74addbf7f..b312388dd6a 100644 --- a/jdk/test/java/util/concurrent/tck/AtomicLongArrayTest.java +++ b/jdk/test/java/util/concurrent/tck/AtomicLongArrayTest.java @@ -302,7 +302,7 @@ public class AtomicLongArrayTest extends JSR166TestCase { class Counter extends CheckedRunnable { final AtomicLongArray aa; - volatile long counts; + int decs; Counter(AtomicLongArray a) { aa = a; } public void realRun() { for (;;) { @@ -313,7 +313,7 @@ public class AtomicLongArrayTest extends JSR166TestCase { if (v != 0) { done = false; if (aa.compareAndSet(i, v, v - 1)) - ++counts; + decs++; } } if (done) @@ -333,13 +333,11 @@ public class AtomicLongArrayTest extends JSR166TestCase { aa.set(i, countdown); Counter c1 = new Counter(aa); Counter c2 = new Counter(aa); - Thread t1 = new Thread(c1); - Thread t2 = new Thread(c2); - t1.start(); - t2.start(); + Thread t1 = newStartedThread(c1); + Thread t2 = newStartedThread(c2); t1.join(); t2.join(); - assertEquals(c1.counts+c2.counts, SIZE * countdown); + assertEquals(c1.decs + c2.decs, SIZE * countdown); } /** diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java index 515303e3e64..0b1faad2824 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java @@ -1024,7 +1024,7 @@ public class ConcurrentSkipListMapTest extends JSR166TestCase { static NavigableMap newMap(Class cl) throws Exception { NavigableMap result = - (NavigableMap) cl.newInstance(); + (NavigableMap) cl.getConstructor().newInstance(); assertEquals(0, result.size()); assertFalse(result.keySet().iterator().hasNext()); return result; diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java index 4ec79c8edd3..28c9f6bd81b 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java @@ -725,7 +725,8 @@ public class ConcurrentSkipListSetTest extends JSR166TestCase { } static NavigableSet newSet(Class cl) throws Exception { - NavigableSet result = (NavigableSet) cl.newInstance(); + NavigableSet result = + (NavigableSet) cl.getConstructor().newInstance(); assertEquals(0, result.size()); assertFalse(result.iterator().hasNext()); return result; diff --git a/jdk/test/java/util/concurrent/tck/CyclicBarrierTest.java b/jdk/test/java/util/concurrent/tck/CyclicBarrierTest.java index bfae2ee323b..8db1063dce9 100644 --- a/jdk/test/java/util/concurrent/tck/CyclicBarrierTest.java +++ b/jdk/test/java/util/concurrent/tck/CyclicBarrierTest.java @@ -40,6 +40,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import junit.framework.Test; import junit.framework.TestSuite; @@ -52,11 +53,6 @@ public class CyclicBarrierTest extends JSR166TestCase { return new TestSuite(CyclicBarrierTest.class); } - private volatile int countAction; - private class MyAction implements Runnable { - public void run() { ++countAction; } - } - /** * Spin-waits till the number of waiters == numberOfWaiters. */ @@ -114,14 +110,16 @@ public class CyclicBarrierTest extends JSR166TestCase { * The supplied barrier action is run at barrier */ public void testBarrierAction() throws Exception { - countAction = 0; - CyclicBarrier b = new CyclicBarrier(1, new MyAction()); + final AtomicInteger count = new AtomicInteger(0); + final Runnable incCount = new Runnable() { public void run() { + count.getAndIncrement(); }}; + CyclicBarrier b = new CyclicBarrier(1, incCount); assertEquals(1, b.getParties()); assertEquals(0, b.getNumberWaiting()); b.await(); b.await(); assertEquals(0, b.getNumberWaiting()); - assertEquals(2, countAction); + assertEquals(2, count.get()); } /** diff --git a/jdk/test/java/util/concurrent/tck/DelayQueueTest.java b/jdk/test/java/util/concurrent/tck/DelayQueueTest.java index 4d05c864554..d4a6bdc969c 100644 --- a/jdk/test/java/util/concurrent/tck/DelayQueueTest.java +++ b/jdk/test/java/util/concurrent/tck/DelayQueueTest.java @@ -121,10 +121,8 @@ public class DelayQueueTest extends JSR166TestCase { } public boolean equals(Object other) { - return equals((NanoDelay)other); - } - public boolean equals(NanoDelay other) { - return other.trigger == trigger; + return (other instanceof NanoDelay) && + this.trigger == ((NanoDelay)other).trigger; } // suppress [overrides] javac warning diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java index 282557d97b7..70004764a78 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java @@ -51,6 +51,7 @@ import java.util.concurrent.Future; import java.util.concurrent.RecursiveTask; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.ReentrantLock; import junit.framework.AssertionFailedError; @@ -84,13 +85,6 @@ public class ForkJoinPoolTest extends JSR166TestCase { // Some classes to test extension and factory methods - static class MyHandler implements Thread.UncaughtExceptionHandler { - volatile int catches = 0; - public void uncaughtException(Thread t, Throwable e) { - ++catches; - } - } - static class MyError extends Error {} // to test handlers @@ -101,9 +95,9 @@ public class ForkJoinPoolTest extends JSR166TestCase { static class FailingThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory { - volatile int calls = 0; + final AtomicInteger calls = new AtomicInteger(0); public ForkJoinWorkerThread newThread(ForkJoinPool p) { - if (++calls > 1) return null; + if (calls.incrementAndGet() > 1) return null; return new FailingFJWSubclass(p); } } diff --git a/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java b/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java index 1cb2a472658..0946d006276 100644 --- a/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java +++ b/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java @@ -537,15 +537,14 @@ public class ScheduledExecutorTest extends JSR166TestCase { * isShutdown is false before shutdown, true after */ public void testIsShutdown() { - final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); - try { - assertFalse(p.isShutdown()); + assertFalse(p.isShutdown()); + try (PoolCleaner cleaner = cleaner(p)) { + try { + p.shutdown(); + assertTrue(p.isShutdown()); + } catch (SecurityException ok) {} } - finally { - try { p.shutdown(); } catch (SecurityException ok) { return; } - } - assertTrue(p.isShutdown()); } /** diff --git a/jdk/test/java/util/concurrent/tck/TreeMapTest.java b/jdk/test/java/util/concurrent/tck/TreeMapTest.java index ebf1dd01b9b..ada561ea119 100644 --- a/jdk/test/java/util/concurrent/tck/TreeMapTest.java +++ b/jdk/test/java/util/concurrent/tck/TreeMapTest.java @@ -829,7 +829,7 @@ public class TreeMapTest extends JSR166TestCase { static NavigableMap newMap(Class cl) throws Exception { NavigableMap result - = (NavigableMap) cl.newInstance(); + = (NavigableMap) cl.getConstructor().newInstance(); assertEquals(0, result.size()); assertFalse(result.keySet().iterator().hasNext()); return result; diff --git a/jdk/test/java/util/concurrent/tck/TreeSetTest.java b/jdk/test/java/util/concurrent/tck/TreeSetTest.java index eb7b6efd9d0..dc5b007b0d3 100644 --- a/jdk/test/java/util/concurrent/tck/TreeSetTest.java +++ b/jdk/test/java/util/concurrent/tck/TreeSetTest.java @@ -722,7 +722,8 @@ public class TreeSetTest extends JSR166TestCase { } static NavigableSet newSet(Class cl) throws Exception { - NavigableSet result = (NavigableSet) cl.newInstance(); + NavigableSet result = + (NavigableSet) cl.getConstructor().newInstance(); assertEquals(0, result.size()); assertFalse(result.iterator().hasNext()); return result; From 414dc12887c66682a0090ccb8ca5eaa878ec5db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Mon, 26 Sep 2016 13:27:45 +0200 Subject: [PATCH 73/81] 8164467: ES6 computed properties are implemented wrongly Reviewed-by: sundar, lagergren --- .../internal/codegen/CodeGenerator.java | 57 ++++++++++------ .../jdk/nashorn/internal/ir/PropertyNode.java | 6 +- .../jdk/nashorn/internal/parser/Parser.java | 30 +++++---- .../internal/runtime/ScriptObject.java | 12 ++-- .../basic/es6/computed-property-duplicate.js | 44 +++++++++++++ .../basic/es6/computed-property-getter.js | 66 +++++++++++++++++++ .../basic/es6/computed-property-method.js | 66 +++++++++++++++++++ .../basic/es6/computed-property-number.js | 54 +++++++++++++++ .../basic/es6/computed-property-setter.js | 43 ++++++++++++ .../script/basic/es6/computed-property.js | 66 +++++++++++++++++++ 10 files changed, 404 insertions(+), 40 deletions(-) create mode 100644 nashorn/test/script/basic/es6/computed-property-duplicate.js create mode 100644 nashorn/test/script/basic/es6/computed-property-getter.js create mode 100644 nashorn/test/script/basic/es6/computed-property-method.js create mode 100644 nashorn/test/script/basic/es6/computed-property-number.js create mode 100644 nashorn/test/script/basic/es6/computed-property-setter.js create mode 100644 nashorn/test/script/basic/es6/computed-property.js diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java index f784b74ca5f..c9fa06880f9 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -2512,7 +2512,8 @@ final class CodeGenerator extends NodeOperatorVisitor elements = objectNode.getElements(); final List> tuples = new ArrayList<>(); - final List gettersSetters = new ArrayList<>(); + // List below will contain getter/setter properties and properties with computed keys (ES6) + final List specialProperties = new ArrayList<>(); final int ccp = getCurrentContinuationEntryPoint(); final List ranges = objectNode.getSplitRanges(); @@ -2522,11 +2523,14 @@ final class CodeGenerator extends NodeOperatorVisitor valueType = (!useDualFields() || value == null || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass(); + final Class valueType = (!useDualFields() || isComputedOrAccessor || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass(); tuples.add(new MapTuple(key, symbol, Type.typeFor(valueType), value) { @Override public Class getValueType() { @@ -2590,26 +2594,41 @@ final class CodeGenerator extends NodeOperatorVisitor Date: Mon, 26 Sep 2016 14:56:35 +0200 Subject: [PATCH 74/81] 8163102: Fix headless only configuration option Reviewed-by: tbell --- jdk/make/launcher/Launcher-java.desktop.gmk | 4 +- jdk/make/launcher/Launcher-jdk.policytool.gmk | 4 +- jdk/make/lib/Awt2dLibraries.gmk | 138 +++++++++--------- .../java.desktop/unix/native/libjawt/jawt.c | 5 + 4 files changed, 77 insertions(+), 74 deletions(-) diff --git a/jdk/make/launcher/Launcher-java.desktop.gmk b/jdk/make/launcher/Launcher-java.desktop.gmk index f9fa7d16c22..8cf4d79363e 100644 --- a/jdk/make/launcher/Launcher-java.desktop.gmk +++ b/jdk/make/launcher/Launcher-java.desktop.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -28,7 +28,7 @@ include LauncherCommon.gmk # Hook to include the corresponding custom file, if present. $(eval $(call IncludeCustomExtension, jdk, launcher/Launcher-java.desktop.gmk)) -ifndef BUILD_HEADLESS_ONLY +ifeq ($(ENABLE_HEADLESS_ONLY), false) $(eval $(call SetupBuildLauncher, appletviewer, \ MAIN_CLASS := sun.applet.Main, \ JAVA_ARGS := --add-modules ALL-DEFAULT, \ diff --git a/jdk/make/launcher/Launcher-jdk.policytool.gmk b/jdk/make/launcher/Launcher-jdk.policytool.gmk index 26ec6a4b96a..a23b598b22b 100644 --- a/jdk/make/launcher/Launcher-jdk.policytool.gmk +++ b/jdk/make/launcher/Launcher-jdk.policytool.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -25,7 +25,7 @@ include LauncherCommon.gmk -ifndef BUILD_HEADLESS_ONLY +ifeq ($(ENABLE_HEADLESS_ONLY), false) $(eval $(call SetupBuildLauncher, policytool, \ MAIN_CLASS := sun.security.tools.policytool.PolicyTool, \ LIBS_unix := $(X_LIBS), \ diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index c7d296bf907..4212cd9f652 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -280,7 +280,7 @@ TARGETS += $(BUILD_LIBAWT) ################################################################################ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) - ifndef BUILD_HEADLESS_ONLY + ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBAWT_XAWT_DIRS := \ $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt_xawt \ @@ -511,77 +511,75 @@ TARGETS += $(BUILD_LIBJAVAJPEG) ################################################################################ -ifeq ($(BUILD_HEADLESS), true) - # Mac and Windows only use the native AWT lib, do not build libawt_headless - ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),) +# Mac and Windows only use the native AWT lib, do not build libawt_headless +ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),) - LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/java.desktop/unix/native/libawt_headless/awt \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \ - $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \ - $(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \ - $(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ - # + LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/java.desktop/unix/native/libawt_headless/awt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/opengl \ + $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/java2d/x11 \ + $(JDK_TOPDIR)/src/java.desktop/share/native/common/java2d/opengl \ + $(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ + # - LIBAWT_HEADLESS_EXCLUDES := medialib - LIBAWT_HEADLESS_CFLAGS := -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \ - $(addprefix -I, $(LIBAWT_HEADLESS_DIRS)) \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/loops \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga/ \ - $(LIBJAVA_HEADER_FLAGS) \ - # + LIBAWT_HEADLESS_EXCLUDES := medialib + LIBAWT_HEADLESS_CFLAGS := -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \ + $(addprefix -I, $(LIBAWT_HEADLESS_DIRS)) \ + -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d \ + -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/loops \ + -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image/cvutils \ + -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/java2d/pipe \ + -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/awt/image \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libawt/java2d \ + -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/font \ + -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/awt/debug \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/font \ + -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libsunwjdga/ \ + $(LIBJAVA_HEADER_FLAGS) \ + # - LIBAWT_HEADLESS_REORDER := - ifeq ($(OPENJDK_TARGET_OS), solaris) - ifneq ($(OPENJDK_TARGET_CPU), x86_64) - LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU) - endif + LIBAWT_HEADLESS_REORDER := + ifeq ($(OPENJDK_TARGET_OS), solaris) + ifneq ($(OPENJDK_TARGET_CPU), x86_64) + LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU) endif - - $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \ - LIBRARY := awt_headless, \ - OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(LIBAWT_HEADLESS_DIRS), \ - EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \ - OPTIMIZATION := LOW, \ - CFLAGS := $(CFLAGS_JDKLIB) \ - -DHEADLESS=true \ - -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \ - $(CUPS_CFLAGS) \ - $(X_CFLAGS) \ - $(LIBAWT_HEADLESS_CFLAGS), \ - DISABLED_WARNINGS_xlc := 1506-356, \ - DISABLED_WARNINGS_solstudio := E_EMPTY_TRANSLATION_UNIT, \ - MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \ - LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ - LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ - REORDER := $(LIBAWT_HEADLESS_REORDER), \ - LIBS_unix := -lawt -ljvm -ljava, \ - LIBS_linux := $(LIBM) $(LIBDL), \ - LIBS_solaris := $(LIBM) $(LIBDL) $(LIBCXX) -lc, \ - OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \ - )) - - # AIX warning explanation: - # 1506-356 : (W) Compilation unit is empty. - # This happens during the headless build - - $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT) - - TARGETS += $(BUILD_LIBAWT_HEADLESS) - endif + + $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \ + LIBRARY := awt_headless, \ + OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ + SRC := $(LIBAWT_HEADLESS_DIRS), \ + EXCLUDES := $(LIBAWT_HEADLESS_EXCLUDES), \ + OPTIMIZATION := LOW, \ + CFLAGS := $(CFLAGS_JDKLIB) \ + -DHEADLESS=true \ + -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \ + $(CUPS_CFLAGS) \ + $(X_CFLAGS) \ + $(LIBAWT_HEADLESS_CFLAGS), \ + DISABLED_WARNINGS_xlc := 1506-356, \ + DISABLED_WARNINGS_solstudio := E_EMPTY_TRANSLATION_UNIT, \ + MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \ + LDFLAGS := $(LDFLAGS_JDKLIB) \ + $(call SET_SHARED_LIBRARY_ORIGIN), \ + LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \ + LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ + LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ + REORDER := $(LIBAWT_HEADLESS_REORDER), \ + LIBS_unix := -lawt -ljvm -ljava, \ + LIBS_linux := $(LIBM) $(LIBDL), \ + LIBS_solaris := $(LIBM) $(LIBDL) $(LIBCXX) -lc, \ + OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libawt_headless, \ + )) + + # AIX warning explanation: + # 1506-356 : (W) Compilation unit is empty. + # This happens during the headless build + + $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT) + + TARGETS += $(BUILD_LIBAWT_HEADLESS) + endif ################################################################################ @@ -780,7 +778,7 @@ else # OPENJDK_TARGET_OS not windows ifneq ($(OPENJDK_TARGET_OS), solaris) JAWT_LIBS += -lawt endif - ifndef BUILD_HEADLESS_ONLY + ifeq ($(ENABLE_HEADLESS_ONLY), false) JAWT_LIBS += -lawt_xawt else JAWT_LIBS += -lawt_headless @@ -809,7 +807,7 @@ else # OPENJDK_TARGET_OS not windows OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt, \ )) - ifndef BUILD_HEADLESS_ONLY + ifeq ($(ENABLE_HEADLESS_ONLY), false) $(BUILD_LIBJAWT): $(BUILD_LIBAWT_XAWT) else $(BUILD_LIBJAWT): $(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)awt_headless$(SHARED_LIBRARY_SUFFIX) @@ -825,7 +823,7 @@ TARGETS += $(BUILD_LIBJAWT) ################################################################################ -ifndef BUILD_HEADLESS_ONLY +ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_DIRS := \ $(JDK_TOPDIR)/src/java.desktop/share/native/libjavajpeg \ diff --git a/jdk/src/java.desktop/unix/native/libjawt/jawt.c b/jdk/src/java.desktop/unix/native/libjawt/jawt.c index 59e9a55cff2..ee61138dd31 100644 --- a/jdk/src/java.desktop/unix/native/libjawt/jawt.c +++ b/jdk/src/java.desktop/unix/native/libjawt/jawt.c @@ -39,6 +39,10 @@ DEF_STATIC_JNI_OnLoad */ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) { +#if defined(HEADLESS) + /* there are no AWT libs available at all */ + return JNI_FALSE; +#else if (awt == NULL) { return JNI_FALSE; } @@ -64,4 +68,5 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) } return JNI_TRUE; +#endif } From 12fae4c79f6a97590a031131f808b5980bea44d0 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 26 Sep 2016 14:57:00 +0200 Subject: [PATCH 75/81] 8163102: Fix headless only configuration option Reviewed-by: tbell --- common/autoconf/generated-configure.sh | 67 +++++++++++--------------- common/autoconf/jdk-options.m4 | 39 ++++++--------- common/autoconf/libraries.m4 | 10 ++-- common/autoconf/spec.gmk.in | 8 +-- 4 files changed, 48 insertions(+), 76 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 5d6d6913fe2..796784ed18b 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -926,9 +926,7 @@ COMPRESS_JARS INCLUDE_SA UNLIMITED_CRYPTO CACERTS_FILE -BUILD_HEADLESS -SUPPORT_HEADFUL -SUPPORT_HEADLESS +ENABLE_HEADLESS_ONLY DEFAULT_MAKE_TARGET OS_VERSION_MICRO OS_VERSION_MINOR @@ -1153,7 +1151,7 @@ with_sdk_name with_conf_name with_output_sync with_default_make_target -enable_headful +enable_headless_only with_cacerts_file enable_unlimited_crypto with_copyright_year @@ -1976,8 +1974,7 @@ Optional Features: [disabled] --enable-debug set the debug level to fastdebug (shorthand for --with-debug-level=fastdebug) [disabled] - --disable-headful disable building headful support (graphical UI - support) [enabled] + --enable-headless-only only build headless (no GUI) support [disabled] --enable-unlimited-crypto Enable unlimited crypto policy [disabled] --disable-keep-packaged-modules @@ -5095,7 +5092,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1474460325 +DATE_WHEN_GENERATED=1474894604 ############################################################################### # @@ -24192,37 +24189,31 @@ fi # We need build & target for this. - # Should we build a JDK/JVM with headful support (ie a graphical ui)? - # We always build headless support. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking headful support" >&5 -$as_echo_n "checking headful support... " >&6; } - # Check whether --enable-headful was given. -if test "${enable_headful+set}" = set; then : - enableval=$enable_headful; SUPPORT_HEADFUL=${enable_headful} -else - SUPPORT_HEADFUL=yes + # Should we build a JDK without a graphical UI? + { $as_echo "$as_me:${as_lineno-$LINENO}: checking headless only" >&5 +$as_echo_n "checking headless only... " >&6; } + # Check whether --enable-headless-only was given. +if test "${enable_headless_only+set}" = set; then : + enableval=$enable_headless_only; fi - SUPPORT_HEADLESS=yes - BUILD_HEADLESS="BUILD_HEADLESS:=true" - - if test "x$SUPPORT_HEADFUL" = xyes; then - # We are building both headful and headless. - headful_msg="include support for both headful and headless" + if test "x$enable_headless_only" = "xyes"; then + ENABLE_HEADLESS_ONLY="true" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + elif test "x$enable_headless_only" = "xno"; then + ENABLE_HEADLESS_ONLY="false" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + elif test "x$enable_headless_only" = "x"; then + ENABLE_HEADLESS_ONLY="false" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + else + as_fn_error $? "--enable-headless-only can only take yes or no" "$LINENO" 5 fi - if test "x$SUPPORT_HEADFUL" = xno; then - # Thus we are building headless only. - BUILD_HEADLESS="BUILD_HEADLESS:=true" - headful_msg="headless only" - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $headful_msg" >&5 -$as_echo "$headful_msg" >&6; } - - - # Choose cacerts source file @@ -53045,13 +53036,9 @@ $as_echo "yes" >&6; } # No X11 support on windows or macosx NEEDS_LIB_X11=false else - if test "x$SUPPORT_HEADFUL" = xno; then - # No X11 support if building headless-only - NEEDS_LIB_X11=false - else - # All other instances need X11 - NEEDS_LIB_X11=true - fi + # All other instances need X11, even if building headless only, libawt still + # needs X11 headers. + NEEDS_LIB_X11=true fi # Check if cups is needed diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index d6aa389f3ae..8becdf3669c 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -134,32 +134,25 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_OPEN_OR_CUSTOM], AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], [ - # Should we build a JDK/JVM with headful support (ie a graphical ui)? - # We always build headless support. - AC_MSG_CHECKING([headful support]) - AC_ARG_ENABLE([headful], [AS_HELP_STRING([--disable-headful], - [disable building headful support (graphical UI support) @<:@enabled@:>@])], - [SUPPORT_HEADFUL=${enable_headful}], [SUPPORT_HEADFUL=yes]) + # Should we build a JDK without a graphical UI? + AC_MSG_CHECKING([headless only]) + AC_ARG_ENABLE([headless-only], [AS_HELP_STRING([--enable-headless-only], + [only build headless (no GUI) support @<:@disabled@:>@])]) - SUPPORT_HEADLESS=yes - BUILD_HEADLESS="BUILD_HEADLESS:=true" - - if test "x$SUPPORT_HEADFUL" = xyes; then - # We are building both headful and headless. - headful_msg="include support for both headful and headless" + if test "x$enable_headless_only" = "xyes"; then + ENABLE_HEADLESS_ONLY="true" + AC_MSG_RESULT([yes]) + elif test "x$enable_headless_only" = "xno"; then + ENABLE_HEADLESS_ONLY="false" + AC_MSG_RESULT([no]) + elif test "x$enable_headless_only" = "x"; then + ENABLE_HEADLESS_ONLY="false" + AC_MSG_RESULT([no]) + else + AC_MSG_ERROR([--enable-headless-only can only take yes or no]) fi - if test "x$SUPPORT_HEADFUL" = xno; then - # Thus we are building headless only. - BUILD_HEADLESS="BUILD_HEADLESS:=true" - headful_msg="headless only" - fi - - AC_MSG_RESULT([$headful_msg]) - - AC_SUBST(SUPPORT_HEADLESS) - AC_SUBST(SUPPORT_HEADFUL) - AC_SUBST(BUILD_HEADLESS) + AC_SUBST(ENABLE_HEADLESS_ONLY) # Choose cacerts source file AC_ARG_WITH(cacerts-file, [AS_HELP_STRING([--with-cacerts-file], diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index 1e408ef022b..3ca12d4da7d 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -42,13 +42,9 @@ AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES], # No X11 support on windows or macosx NEEDS_LIB_X11=false else - if test "x$SUPPORT_HEADFUL" = xno; then - # No X11 support if building headless-only - NEEDS_LIB_X11=false - else - # All other instances need X11 - NEEDS_LIB_X11=true - fi + # All other instances need X11, even if building headless only, libawt still + # needs X11 headers. + NEEDS_LIB_X11=true fi # Check if cups is needed diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index c591a79d327..710cf70ab7c 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -241,12 +241,8 @@ BUILD_GTEST := @BUILD_GTEST@ # Control use of precompiled header in hotspot libjvm build USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@ -# Should we compile support for running with a graphical UI? (ie headful) -# Should we compile support for running without? (ie headless) -SUPPORT_HEADFUL:=@SUPPORT_HEADFUL@ -SUPPORT_HEADLESS:=@SUPPORT_HEADLESS@ -# Legacy defines controlled by the SUPPORT_HEADLESS and SUPPORT_HEADFUL options. -@BUILD_HEADLESS@ +# Only build headless support or not +ENABLE_HEADLESS_ONLY := @ENABLE_HEADLESS_ONLY@ # Legacy support USE_NEW_HOTSPOT_BUILD:=@USE_NEW_HOTSPOT_BUILD@ From 2d35d5bfc31121e1531089c20f066bac201e4754 Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Mon, 26 Sep 2016 08:19:07 -0700 Subject: [PATCH 76/81] 8130657: com/sun/net/httpserver/Test5.java failed with java.lang.RuntimeException: wrong string result 8085575: java/net/Socket/InheritHandle.java fails intermittently with "Address already in use" Reviewed-by: dfuchs --- jdk/test/com/sun/net/httpserver/Test5.java | 3 +- .../java/net/MulticastSocket/TimeToLive.java | 39 ++++++++++--------- jdk/test/java/net/Socket/InheritHandle.java | 23 +++++++++-- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/jdk/test/com/sun/net/httpserver/Test5.java b/jdk/test/com/sun/net/httpserver/Test5.java index b6d39439b7a..f704cf8ef42 100644 --- a/jdk/test/com/sun/net/httpserver/Test5.java +++ b/jdk/test/com/sun/net/httpserver/Test5.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -145,6 +145,7 @@ public class Test5 extends Test { socket.close(); s = new String (b,0,count, "ISO8859_1"); if (!compare (s, result)) { + System.err.println(" Expected [" + result + "]\n actual [" + s + "]"); throw new RuntimeException ("wrong string result"); } } diff --git a/jdk/test/java/net/MulticastSocket/TimeToLive.java b/jdk/test/java/net/MulticastSocket/TimeToLive.java index 99f2641d5d8..009ff6d0eb3 100644 --- a/jdk/test/java/net/MulticastSocket/TimeToLive.java +++ b/jdk/test/java/net/MulticastSocket/TimeToLive.java @@ -37,26 +37,27 @@ public class TimeToLive { static int[] bad_ttls = { -1, 256 }; public static void main(String[] args) throws Exception { - MulticastSocket socket = new MulticastSocket(); - int ttl = socket.getTimeToLive(); - System.out.println("default ttl: " + ttl); - for (int i = 0; i < new_ttls.length; i++) { - socket.setTimeToLive(new_ttls[i]); - if (!(new_ttls[i] == socket.getTimeToLive())) { - throw new RuntimeException("test failure, set/get differ: " + - new_ttls[i] + " / " + - socket.getTimeToLive()); + try (MulticastSocket socket = new MulticastSocket()) { + int ttl = socket.getTimeToLive(); + System.out.println("default ttl: " + ttl); + for (int i = 0; i < new_ttls.length; i++) { + socket.setTimeToLive(new_ttls[i]); + if (!(new_ttls[i] == socket.getTimeToLive())) { + throw new RuntimeException("test failure, set/get differ: " + + new_ttls[i] + " / " + + socket.getTimeToLive()); + } } - } - for (int j = 0; j < bad_ttls.length; j++) { - boolean exception = false; - try { - socket.setTimeToLive(bad_ttls[j]); - } catch (IllegalArgumentException e) { - exception = true; - } - if (!exception) { - throw new RuntimeException("bad argument accepted: " + bad_ttls[j]); + for (int j = 0; j < bad_ttls.length; j++) { + boolean exception = false; + try { + socket.setTimeToLive(bad_ttls[j]); + } catch (IllegalArgumentException e) { + exception = true; + } + if (!exception) { + throw new RuntimeException("bad argument accepted: " + bad_ttls[j]); + } } } } diff --git a/jdk/test/java/net/Socket/InheritHandle.java b/jdk/test/java/net/Socket/InheritHandle.java index 3fa57caa68e..9a9cddae683 100644 --- a/jdk/test/java/net/Socket/InheritHandle.java +++ b/jdk/test/java/net/Socket/InheritHandle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,7 @@ @author Chris Hegarty */ +import java.net.BindException; import java.net.ServerSocket; import java.io.File; import java.io.IOException; @@ -74,6 +75,11 @@ public class InheritHandle } catch (IOException ioe) { System.out.println("Cannot create process"); ioe.printStackTrace(); + try { + ss.close(); + } catch (IOException e) { + e.printStackTrace(); + } return; } @@ -85,9 +91,18 @@ public class InheritHandle System.out.println("Now close the socket and try to create another" + " one listening on the same port"); ss.close(); - ss = new ServerSocket(port); - System.out.println("Second ServerSocket created successfully"); - ss.close(); + int retries = 0; + while (retries < 5) { + try (ServerSocket s = new ServerSocket(port);) { + System.out.println("Second ServerSocket created successfully"); + break; + } catch (BindException e) { + System.out.println("BindException \"" + e.getMessage() + "\", retrying..."); + Thread.sleep(100L); + retries ++; + continue; + } + } } catch (InterruptedException ie) { } catch (IOException ioe) { From b6e72d65aaa8c56206370ab4391de4efc6539795 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Mon, 26 Sep 2016 21:24:17 +0200 Subject: [PATCH 77/81] 8166604: nio: remove unneeded locals variables and correct NPE Reviewed-by: alanb --- .../share/classes/sun/nio/ch/DatagramChannelImpl.java | 4 ---- .../java.base/share/classes/sun/nio/ch/SocketChannelImpl.java | 2 -- 2 files changed, 6 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java index f063e13ac13..7f63ec88264 100644 --- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java +++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java @@ -328,8 +328,6 @@ class DatagramChannelImpl public SocketAddress receive(ByteBuffer dst) throws IOException { if (dst.isReadOnly()) throw new IllegalArgumentException("Read-only buffer"); - if (dst == null) - throw new NullPointerException(); synchronized (readLock) { ensureOpen(); // Socket was not bound before attempting receive @@ -716,8 +714,6 @@ class DatagramChannelImpl @Override public DatagramChannel connect(SocketAddress sa) throws IOException { - int localPort = 0; - synchronized(readLock) { synchronized(writeLock) { synchronized (stateLock) { diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java index 856e0cf2fb6..8e21e522079 100644 --- a/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java +++ b/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java @@ -616,8 +616,6 @@ class SocketChannelImpl } public boolean connect(SocketAddress sa) throws IOException { - int localPort = 0; - synchronized (readLock) { synchronized (writeLock) { ensureOpenAndUnconnected(); From cf46ec878a69f576c6b10dd616ded8f1a5102ef8 Mon Sep 17 00:00:00 2001 From: Steve Drach Date: Mon, 26 Sep 2016 13:37:10 -0700 Subject: [PATCH 78/81] 8153654: Update jdeps to be multi-release jar aware Reviewed-by: mchung --- jdk/src/java.base/share/classes/module-info.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index f49111be646..11d53463dc8 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -166,6 +166,7 @@ module java.base { jdk.charsets, jdk.compiler, jdk.jartool, + jdk.jdeps, jdk.jlink, jdk.net, jdk.scripting.nashorn, @@ -189,7 +190,8 @@ module java.base { jdk.unsupported, jdk.vm.ci; exports jdk.internal.util.jar to - jdk.jartool; + jdk.jartool, + jdk.jdeps; exports jdk.internal.vm to java.management, jdk.jvmstat; From e168404209458f6c4990964e491715b544ff9482 Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Tue, 27 Sep 2016 01:36:31 -0700 Subject: [PATCH 79/81] 8154525: java/net/ServerSocket/ThreadStop.java fails intermittently with error while cleaning up threads after test Reviewed-by: chegar --- jdk/test/java/net/ServerSocket/ThreadStop.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jdk/test/java/net/ServerSocket/ThreadStop.java b/jdk/test/java/net/ServerSocket/ThreadStop.java index 2ebecbb8db8..adf19379280 100644 --- a/jdk/test/java/net/ServerSocket/ThreadStop.java +++ b/jdk/test/java/net/ServerSocket/ThreadStop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 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 @@ -68,23 +68,23 @@ public class ThreadStop { thr.start(); // give server time to block in ServerSocket.accept() - Thread.currentThread().sleep(2000); + Thread.sleep(2000); // "stop" the thread thr.stop(); // give thread time to stop - Thread.currentThread().sleep(2000); + Thread.sleep(2000); // it's platform specific if Thread.stop interrupts the // thread - on Linux/Windows most likely that thread is // still in accept() so we connect to server which causes // it to unblock and do JNI-stuff with a pending exception - try { - Socket s = new Socket("localhost", svr.localPort()); - } catch (IOException ioe) { } - + try (Socket s = new Socket("localhost", svr.localPort())) { + } catch (IOException ioe) { + } + thr.join(); } } From 0c8a532f7a561387235aea93f11302d294f8e0da Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Tue, 27 Sep 2016 12:07:33 +0100 Subject: [PATCH 80/81] 8166747: Add invalid network / computer name cases to isReachable known failure switch Reviewed-by: chegar, msheppar --- jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c index debc50a1543..3a9e650a5f8 100644 --- a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c +++ b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c @@ -499,6 +499,8 @@ ping4(JNIEnv *env, case ERROR_REQUEST_ABORTED: case ERROR_INCORRECT_ADDRESS: case ERROR_HOST_DOWN: + case ERROR_INVALID_COMPUTERNAME: + case ERROR_INVALID_NETNAME: case WSAEHOSTUNREACH: /* Host Unreachable */ case WSAENETUNREACH: /* Network Unreachable */ case WSAENETDOWN: /* Network is down */ From 439cb413d5c187594e4c16a3e7559a6408bbd54f Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 27 Sep 2016 15:33:34 +0200 Subject: [PATCH 81/81] 8164301: jib should provide a JDK for running jtreg with Reviewed-by: tbell --- common/conf/jib-profiles.js | 49 ++++++++++++++++++++++--------------- make/MainSupport.gmk | 2 ++ 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index e57bbf7e4bd..d003e1815e4 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -224,6 +224,23 @@ var getJibProfilesCommon = function (input) { common.configure_args_slowdebug = ["--with-debug-level=slowdebug"], common.organization = "jpg.infra.builddeps" + var boot_jdk_revision = "8"; + var boot_jdk_subdirpart = "1.8.0"; + // JDK 8 does not work on sparc M7 cpus, need a newer update when building + // on such hardware. + if (input.build_cpu == "sparcv9") { + var cpu_brand = $EXEC("bash -c \"kstat -m cpu_info | grep brand | head -n1 | awk '{ print \$2 }'\""); + if (cpu_brand.trim() == 'SPARC-M7') { + boot_jdk_revision = "8u20"; + boot_jdk_subdirpart = "1.8.0_20"; + } + } + common.boot_jdk_revision = boot_jdk_revision; + common.boot_jdk_subdirpart = boot_jdk_subdirpart; + common.boot_jdk_home = input.get("boot_jdk", "home_path") + "/jdk" + + common.boot_jdk_subdirpart + + (input.build_os == "macosx" ? ".jdk/Contents/Home" : ""); + return common; }; @@ -333,8 +350,11 @@ var getJibProfilesProfiles = function (input, common) { "run-test": { target_os: input.build_os, target_cpu: input.build_cpu, - dependencies: [ "jtreg", "gnumake" ], - labels: "test" + dependencies: [ "jtreg", "gnumake", "boot_jdk" ], + labels: "test", + environment: { + "JT_JAVA": common.boot_jdk_home + } } }; profiles = concatObjects(profiles, testOnlyProfiles); @@ -357,18 +377,6 @@ var getJibProfilesDependencies = function (input, common) { var boot_jdk_platform = input.build_os + "-" + (input.build_cpu == "x86" ? "i586" : input.build_cpu); - var boot_jdk_revision = "8"; - var boot_jdk_subdirpart = "1.8.0"; - // JDK 8 does not work on sparc M7 cpus, need a newer update when building - // on such hardware. - if (input.build_cpu == "sparcv9") { - var cpu_brand = $EXEC("bash -c \"kstat -m cpu_info | grep brand | head -n1 | awk '{ print \$2 }'\""); - if (cpu_brand.trim() == 'SPARC-M7') { - boot_jdk_revision = "8u20"; - boot_jdk_subdirpart = "1.8.0_20"; - } - } - var devkit_platform_revisions = { linux_x64: "gcc4.9.2-OEL6.4+1.0", macosx_x64: "Xcode6.3-MacOSX10.9+1.0", @@ -386,12 +394,12 @@ var getJibProfilesDependencies = function (input, common) { boot_jdk: { server: "javare", module: "jdk", - revision: boot_jdk_revision, + revision: common.boot_jdk_revision, checksum_file: boot_jdk_platform + "/MD5_VALUES", - file: boot_jdk_platform + "/jdk-" + boot_jdk_revision + "-" + boot_jdk_platform + ".tar.gz", - configure_args: (input.build_os == "macosx" - ? "--with-boot-jdk=" + input.get("boot_jdk", "install_path") + "/jdk" + boot_jdk_subdirpart + ".jdk/Contents/Home" - : "--with-boot-jdk=" + input.get("boot_jdk", "install_path") + "/jdk" + boot_jdk_subdirpart) + file: boot_jdk_platform + "/jdk-" + common.boot_jdk_revision + + "-" + boot_jdk_platform + ".tar.gz", + configure_args: "--with-boot-jdk=" + common.boot_jdk_home, + environment_path: common.boot_jdk_home }, devkit: { @@ -420,7 +428,8 @@ var getJibProfilesDependencies = function (input, common) { build_number: "b03", checksum_file: "MD5_VALUES", file: "jtreg_bin-4.2.zip", - environment_name: "JT_HOME" + environment_name: "JT_HOME", + environment_path: input.get("jtreg", "install_path") + "/jtreg/bin" }, gnumake: { diff --git a/make/MainSupport.gmk b/make/MainSupport.gmk index 7683cfeb2af..57fd68deaa5 100644 --- a/make/MainSupport.gmk +++ b/make/MainSupport.gmk @@ -31,11 +31,13 @@ ifndef _MAINSUPPORT_GMK _MAINSUPPORT_GMK := 1 # Run the tests specified by $1, with PRODUCT_HOME specified by $2 +# JT_JAVA is picked up by the jtreg launcher and used to run Jtreg itself. define RunTests ($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \ JT_HOME=$(JT_HOME) PRODUCT_HOME=$(strip $2) \ TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ ALT_OUTPUTDIR=$(OUTPUT_ROOT) TEST_JOBS=$(TEST_JOBS) \ + JT_JAVA=$(BOOT_JDK) \ JOBS=$(JOBS) $1) || true endef