提交 8cb8c440 编写于 作者: R robm

Merge

OPENJDK ASSEMBLY EXCEPTION OPENJDK ASSEMBLY EXCEPTION
The OpenJDK source code made available by Oracle at openjdk.java.net and The OpenJDK source code made available by Oracle America, Inc. (Oracle) at
openjdk.dev.java.net ("OpenJDK Code") is distributed under the terms of the openjdk.java.net ("OpenJDK Code") is distributed under the terms of the GNU
GNU General Public License <http://www.gnu.org/copyleft/gpl.html> version 2 General Public License <http://www.gnu.org/copyleft/gpl.html> version 2
only ("GPL2"), with the following clarification and special exception. only ("GPL2"), with the following clarification and special exception.
Linking this OpenJDK Code statically or dynamically with other code Linking this OpenJDK Code statically or dynamically with other code
...@@ -19,9 +19,9 @@ only ("GPL2"), with the following clarification and special exception. ...@@ -19,9 +19,9 @@ only ("GPL2"), with the following clarification and special exception.
provided that the Designated Exception Modules continue to be provided that the Designated Exception Modules continue to be
governed by the licenses under which they were offered by Oracle. governed by the licenses under which they were offered by Oracle.
As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code to As such, it allows licensees and sublicensees of Oracle's GPL2 OpenJDK Code
build an executable that includes those portions of necessary code that Oracle to build an executable that includes those portions of necessary code that
could not provide under GPL2 (or that Oracle has provided under GPL2 with the Oracle could not provide under GPL2 (or that Oracle has provided under GPL2
Classpath exception). If you modify or add to the OpenJDK code, that new with the Classpath exception). If you modify or add to the OpenJDK code,
GPL2 code may still be combined with Designated Exception Modules if the that new GPL2 code may still be combined with Designated Exception Modules
new code is made subject to this exception by its copyright holder. if the new code is made subject to this exception by its copyright holder.
...@@ -704,16 +704,16 @@ void VM_Version::get_processor_features() { ...@@ -704,16 +704,16 @@ void VM_Version::get_processor_features() {
UseMultiplyToLenIntrinsic = true; UseMultiplyToLenIntrinsic = true;
} }
if (FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) { if (FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) {
UseSquareToLenIntrinsic = false; UseSquareToLenIntrinsic = true;
} }
if (FLAG_IS_DEFAULT(UseMulAddIntrinsic)) { if (FLAG_IS_DEFAULT(UseMulAddIntrinsic)) {
UseMulAddIntrinsic = false; UseMulAddIntrinsic = true;
} }
if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) { if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
UseMontgomeryMultiplyIntrinsic = false; UseMontgomeryMultiplyIntrinsic = true;
} }
if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) { if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) {
UseMontgomerySquareIntrinsic = false; UseMontgomerySquareIntrinsic = true;
} }
#else #else
if (UseMultiplyToLenIntrinsic) { if (UseMultiplyToLenIntrinsic) {
......
...@@ -616,7 +616,11 @@ bool InstanceKlass::link_class_or_fail(TRAPS) { ...@@ -616,7 +616,11 @@ bool InstanceKlass::link_class_or_fail(TRAPS) {
bool InstanceKlass::link_class_impl( bool InstanceKlass::link_class_impl(
instanceKlassHandle this_oop, bool throw_verifyerror, TRAPS) { instanceKlassHandle this_oop, bool throw_verifyerror, TRAPS) {
// check for error state // check for error state.
// This is checking for the wrong state. If the state is initialization_error,
// then this class *was* linked. The CDS code does a try_link_class and uses
// initialization_error to mark classes to not include in the archive during
// DumpSharedSpaces. This should be removed when the CDS bug is fixed.
if (this_oop->is_in_error_state()) { if (this_oop->is_in_error_state()) {
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
THROW_MSG_(vmSymbols::java_lang_NoClassDefFoundError(), THROW_MSG_(vmSymbols::java_lang_NoClassDefFoundError(),
...@@ -801,37 +805,22 @@ void InstanceKlass::link_methods(TRAPS) { ...@@ -801,37 +805,22 @@ void InstanceKlass::link_methods(TRAPS) {
} }
// Eagerly initialize superinterfaces that declare default methods (concrete instance: any access) // Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_oop, TRAPS) { void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_k, TRAPS) {
if (this_oop->has_default_methods()) { assert (this_k->has_default_methods(), "caller should have checked this");
for (int i = 0; i < this_oop->local_interfaces()->length(); ++i) { for (int i = 0; i < this_k->local_interfaces()->length(); ++i) {
Klass* iface = this_oop->local_interfaces()->at(i); Klass* iface = this_k->local_interfaces()->at(i);
InstanceKlass* ik = InstanceKlass::cast(iface); InstanceKlass* ik = InstanceKlass::cast(iface);
if (ik->should_be_initialized()) {
if (ik->has_default_methods()) { // Initialization is depth first search ie. we start with top of the inheritance tree
ik->initialize_super_interfaces(ik, THREAD); // has_default_methods drives searching superinterfaces since it
} // means has_default_methods in its superinterface hierarchy
// Only initialize() interfaces that "declare" concrete methods. if (ik->has_default_methods()) {
// has_default_methods drives searching superinterfaces since it ik->initialize_super_interfaces(ik, CHECK);
// means has_default_methods in its superinterface hierarchy }
if (!HAS_PENDING_EXCEPTION && ik->declares_default_methods()) {
ik->initialize(THREAD); // Only initialize() interfaces that "declare" concrete methods.
} if (ik->should_be_initialized() && ik->declares_default_methods()) {
if (HAS_PENDING_EXCEPTION) { ik->initialize(CHECK);
Handle e(THREAD, PENDING_EXCEPTION);
CLEAR_PENDING_EXCEPTION;
{
EXCEPTION_MARK;
// Locks object, set state, and notify all waiting threads
this_oop->set_initialization_state_and_notify(
initialization_error, THREAD);
// ignore any exception thrown, superclass initialization error is
// thrown below
CLEAR_PENDING_EXCEPTION;
}
THROW_OOP(e());
}
}
} }
} }
} }
...@@ -897,30 +886,36 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { ...@@ -897,30 +886,36 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) {
} }
// Step 7 // Step 7
Klass* super_klass = this_oop->super(); // Next, if C is a class rather than an interface, initialize its super class and super
if (super_klass != NULL && !this_oop->is_interface() && super_klass->should_be_initialized()) { // interfaces.
super_klass->initialize(THREAD); if (!this_oop->is_interface()) {
Klass* super_klass = this_oop->super();
if (super_klass != NULL && super_klass->should_be_initialized()) {
super_klass->initialize(THREAD);
}
// If C implements any interfaces that declares a non-abstract, non-static method,
// the initialization of C triggers initialization of its super interfaces.
// Only need to recurse if has_default_methods which includes declaring and
// inheriting default methods
if (!HAS_PENDING_EXCEPTION && this_oop->has_default_methods()) {
this_oop->initialize_super_interfaces(this_oop, THREAD);
}
// If any exceptions, complete abruptly, throwing the same exception as above.
if (HAS_PENDING_EXCEPTION) { if (HAS_PENDING_EXCEPTION) {
Handle e(THREAD, PENDING_EXCEPTION); Handle e(THREAD, PENDING_EXCEPTION);
CLEAR_PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
{ {
EXCEPTION_MARK; EXCEPTION_MARK;
this_oop->set_initialization_state_and_notify(initialization_error, THREAD); // Locks object, set state, and notify all waiting threads // Locks object, set state, and notify all waiting threads
CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, superclass initialization error is thrown below this_oop->set_initialization_state_and_notify(initialization_error, THREAD);
CLEAR_PENDING_EXCEPTION;
} }
DTRACE_CLASSINIT_PROBE_WAIT(super__failed, InstanceKlass::cast(this_oop()), -1,wait); DTRACE_CLASSINIT_PROBE_WAIT(super__failed, InstanceKlass::cast(this_oop()), -1,wait);
THROW_OOP(e()); THROW_OOP(e());
} }
} }
// Recursively initialize any superinterfaces that declare default methods
// Only need to recurse if has_default_methods which includes declaring and
// inheriting default methods
if (this_oop->has_default_methods()) {
this_oop->initialize_super_interfaces(this_oop, CHECK);
}
// Step 8 // Step 8
{ {
assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl"); assert(THREAD->is_Java_thread(), "non-JavaThread in initialize_impl");
...@@ -981,10 +976,15 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) ...@@ -981,10 +976,15 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS)
void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_oop, ClassState state, TRAPS) { void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_oop, ClassState state, TRAPS) {
oop init_lock = this_oop->init_lock(); oop init_lock = this_oop->init_lock();
ObjectLocker ol(init_lock, THREAD, init_lock != NULL); if (init_lock != NULL) {
this_oop->set_init_state(state); ObjectLocker ol(init_lock, THREAD);
this_oop->fence_and_clear_init_lock(); this_oop->set_init_state(state);
ol.notify_all(CHECK); this_oop->fence_and_clear_init_lock();
ol.notify_all(CHECK);
} else {
assert(init_lock != NULL, "The initialization state should never be set twice");
this_oop->set_init_state(state);
}
} }
// The embedded _implementor field can only record one implementor. // The embedded _implementor field can only record one implementor.
......
...@@ -985,14 +985,6 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring nam ...@@ -985,14 +985,6 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring nam
} }
UNSAFE_END UNSAFE_END
static jobject get_class_loader(JNIEnv* env, jclass cls) {
if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) {
return NULL;
}
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
oop loader = k->class_loader();
return JNIHandles::make_local(env, loader);
}
UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length)) UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length))
UnsafeWrapper("Unsafe_DefineClass"); UnsafeWrapper("Unsafe_DefineClass");
...@@ -1001,7 +993,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na ...@@ -1001,7 +993,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na
int depthFromDefineClass0 = 1; int depthFromDefineClass0 = 1;
jclass caller = JVM_GetCallerClass(env, depthFromDefineClass0); jclass caller = JVM_GetCallerClass(env, depthFromDefineClass0);
jobject loader = (caller == NULL) ? NULL : get_class_loader(env, caller); jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller);
jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller); jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller);
return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd); return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd);
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
/* /*
* @test * @test
* @bug 8034275 * @bug 8034275
* @summary [JDK 8u40] Test interface initialization: only for interfaces declaring default methods * @bug 8163969
* @summary [JDK 8u40] Test interface init: only for interfaces declaring default methods, when subclass inits
* @run main TestInterfaceInit * @run main TestInterfaceInit
*/ */
import java.util.List; import java.util.List;
...@@ -39,43 +40,59 @@ public class TestInterfaceInit { ...@@ -39,43 +40,59 @@ public class TestInterfaceInit {
// Declares a default method and initializes // Declares a default method and initializes
interface I { interface I {
boolean v = TestInterfaceInit.out(I.class); boolean v = TestInterfaceInit.out(I.class);
default void x() {} default void ix() {}
} }
// Declares a default method and initializes // Declares a default method and initializes
interface J extends I { interface J extends I {
boolean v = TestInterfaceInit.out(J.class); boolean v = TestInterfaceInit.out(J.class);
default void x() {} default void jx() {}
} }
// No default method, does not initialize // No default method, has an abstract method, does not initialize
interface JN extends J { interface JN extends J {
boolean v = TestInterfaceInit.out(JN.class); boolean v = TestInterfaceInit.out(JN.class);
public abstract void jnx();
} }
// Declares a default method and initializes // Declares a default method and initializes
interface K extends I { interface K extends I {
boolean v = TestInterfaceInit.out(K.class); boolean v = TestInterfaceInit.out(K.class);
default void x() {} default void kx() {}
} }
// No default method, does not initialize // No default method, has a static method, does not initialize
interface KN extends K { interface KN extends K {
boolean v = TestInterfaceInit.out(KN.class); boolean v = TestInterfaceInit.out(KN.class);
static void knx() {}
} }
interface L extends JN, KN { interface L extends JN, KN {
boolean v = TestInterfaceInit.out(L.class); boolean v = TestInterfaceInit.out(L.class);
default void x() {} default void lx() {}
}
static class ChildClass implements JN, KN {
boolean v = TestInterfaceInit.out(ChildClass.class);
public void jnx() {}
} }
public static void main(String[] args) { public static void main(String[] args) {
// Trigger initialization // Trigger initialization
boolean v = L.v; boolean v = L.v;
List<Class<?>> expectedCInitOrder = Arrays.asList(I.class,J.class,K.class,L.class); List<Class<?>> expectedCInitOrder = Arrays.asList(L.class);
if (!cInitOrder.equals(expectedCInitOrder)) {
throw new RuntimeException(String.format("Class initialization array %s not equal to expected array %s", cInitOrder, expectedCInitOrder));
}
ChildClass myC = new ChildClass();
boolean w = myC.v;
expectedCInitOrder = Arrays.asList(L.class,I.class,J.class,K.class,ChildClass.class);
if (!cInitOrder.equals(expectedCInitOrder)) { if (!cInitOrder.equals(expectedCInitOrder)) {
throw new RuntimeException(String.format("Class initialization array %s not equal to expected array %s", cInitOrder, expectedCInitOrder)); throw new RuntimeException(String.format("Class initialization array %s not equal to expected array %s", cInitOrder, expectedCInitOrder));
} }
} }
static boolean out(Class c) { static boolean out(Class c) {
......
/* /*
* Copyright (c) 2013, 2014, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -260,8 +260,8 @@ public final class Utils { ...@@ -260,8 +260,8 @@ public final class Utils {
output = ProcessTools.executeProcess(jcmdLauncher.getCommand()); output = ProcessTools.executeProcess(jcmdLauncher.getCommand());
output.shouldHaveExitValue(0); output.shouldHaveExitValue(0);
// Search for a line starting with numbers (pid), follwed by the key. // Search for a line starting with numbers (pid), followed by the key.
Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n"); Pattern pattern = Pattern.compile("^([0-9]+)\\s.*(" + key + ")", Pattern.MULTILINE);
Matcher matcher = pattern.matcher(output.getStdout()); Matcher matcher = pattern.matcher(output.getStdout());
int pid = -1; int pid = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册