8025580: Temporary flags: UseNewReflection and ReflectionWrapResolutionErrors

The fix removes all UseNewReflection/ReflectionWrapResolutionErrors occurrences/logic and adds them into the list of obsolete_jvm_flags in arguments.cpp.

Reviewed-by: coleenp, hseigel
This commit is contained in:
Yuri Gaevsky 2014-05-15 17:38:50 -04:00 committed by Coleen Phillimore
parent 54da05d840
commit cc3c656cf1
13 changed files with 53 additions and 99 deletions

View file

@ -604,7 +604,6 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
Ticks class_load_start_time = Ticks::now(); Ticks class_load_start_time = Ticks::now();
// UseNewReflection
// Fix for 4474172; see evaluation for more details // Fix for 4474172; see evaluation for more details
class_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader())); class_loader = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader()));
ClassLoaderData *loader_data = register_loader(class_loader, CHECK_NULL); ClassLoaderData *loader_data = register_loader(class_loader, CHECK_NULL);
@ -898,7 +897,6 @@ Klass* SystemDictionary::find(Symbol* class_name,
Handle protection_domain, Handle protection_domain,
TRAPS) { TRAPS) {
// UseNewReflection
// The result of this call should be consistent with the result // The result of this call should be consistent with the result
// of the call to resolve_instance_class_or_null(). // of the call to resolve_instance_class_or_null().
// See evaluation 6790209 and 4474172 for more details. // See evaluation 6790209 and 4474172 for more details.

View file

@ -390,7 +390,7 @@ public:
return k; return k;
} }
static Klass* check_klass_Opt_Only_JDK14NewRef(Klass* k) { static Klass* check_klass_Opt_Only_JDK14NewRef(Klass* k) {
assert(JDK_Version::is_gte_jdk14x_version() && UseNewReflection, "JDK 1.4 only"); assert(JDK_Version::is_gte_jdk14x_version(), "JDK 1.4 only");
// despite the optional loading, if you use this it must be present: // despite the optional loading, if you use this it must be present:
return check_klass(k); return check_klass(k);
} }

View file

@ -211,9 +211,9 @@ bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool shou
// reflection implementation, not just those associated with // reflection implementation, not just those associated with
// sun/reflect/SerializationConstructorAccessor. // sun/reflect/SerializationConstructorAccessor.
// NOTE: this is called too early in the bootstrapping process to be // NOTE: this is called too early in the bootstrapping process to be
// guarded by Universe::is_gte_jdk14x_version()/UseNewReflection. // guarded by Universe::is_gte_jdk14x_version().
// Also for lambda generated code, gte jdk8 // Also for lambda generated code, gte jdk8
(!is_reflect || VerifyReflectionBytecodes)); (!is_reflect));
} }
Symbol* Verifier::inference_verify( Symbol* Verifier::inference_verify(

View file

@ -950,7 +950,6 @@ void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method
// reflection implementation, not just those associated with // reflection implementation, not just those associated with
// sun/reflect/SerializationConstructorAccessor. // sun/reflect/SerializationConstructorAccessor.
bool is_reflect = JDK_Version::is_gte_jdk14x_version() && bool is_reflect = JDK_Version::is_gte_jdk14x_version() &&
UseNewReflection &&
klass_to_check->is_subclass_of( klass_to_check->is_subclass_of(
SystemDictionary::reflect_MagicAccessorImpl_klass()); SystemDictionary::reflect_MagicAccessorImpl_klass());

View file

@ -1019,13 +1019,11 @@ bool Method::should_not_be_cached() const {
* security related stack walks (like Reflection.getCallerClass). * security related stack walks (like Reflection.getCallerClass).
*/ */
bool Method::is_ignored_by_security_stack_walk() const { bool Method::is_ignored_by_security_stack_walk() const {
const bool use_new_reflection = JDK_Version::is_gte_jdk14x_version() && UseNewReflection;
if (intrinsic_id() == vmIntrinsics::_invoke) { if (intrinsic_id() == vmIntrinsics::_invoke) {
// This is Method.invoke() -- ignore it // This is Method.invoke() -- ignore it
return true; return true;
} }
if (use_new_reflection && if (JDK_Version::is_gte_jdk14x_version() &&
method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) {
// This is an auxilary frame -- ignore it // This is an auxilary frame -- ignore it
return true; return true;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * 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
@ -420,7 +420,6 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
return NULL; return NULL;
case vmIntrinsics::_getCallerClass: case vmIntrinsics::_getCallerClass:
if (!UseNewReflection) return NULL;
if (!InlineReflectionGetCallerClass) return NULL; if (!InlineReflectionGetCallerClass) return NULL;
if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return NULL; if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return NULL;
break; break;

View file

@ -544,7 +544,7 @@ JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID meth
if (m->is_initializer()) { if (m->is_initializer()) {
reflection_method = Reflection::new_constructor(m, CHECK_NULL); reflection_method = Reflection::new_constructor(m, CHECK_NULL);
} else { } else {
reflection_method = Reflection::new_method(m, UseNewReflection, false, CHECK_NULL); reflection_method = Reflection::new_method(m, false, CHECK_NULL);
} }
ret = JNIHandles::make_local(env, reflection_method); ret = JNIHandles::make_local(env, reflection_method);
return ret; return ret;
@ -2272,7 +2272,7 @@ JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldI
found = InstanceKlass::cast(k)->find_field_from_offset(offset, false, &fd); found = InstanceKlass::cast(k)->find_field_from_offset(offset, false, &fd);
} }
assert(found, "bad fieldID passed into jni_ToReflectedField"); assert(found, "bad fieldID passed into jni_ToReflectedField");
oop reflected = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); oop reflected = Reflection::new_field(&fd, CHECK_NULL);
ret = JNIHandles::make_local(env, reflected); ret = JNIHandles::make_local(env, reflected);
return ret; return ret;
JNI_END JNI_END

View file

@ -1854,7 +1854,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass,
if (!publicOnly || fs.access_flags().is_public()) { if (!publicOnly || fs.access_flags().is_public()) {
fd.reinitialize(k(), fs.index()); fd.reinitialize(k(), fs.index());
oop field = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL); oop field = Reflection::new_field(&fd, CHECK_NULL);
result->obj_at_put(out_idx, field); result->obj_at_put(out_idx, field);
++out_idx; ++out_idx;
} }
@ -1932,7 +1932,7 @@ static jobjectArray get_class_declared_methods_helper(
if (want_constructor) { if (want_constructor) {
m = Reflection::new_constructor(method, CHECK_NULL); m = Reflection::new_constructor(method, CHECK_NULL);
} else { } else {
m = Reflection::new_method(method, UseNewReflection, false, CHECK_NULL); m = Reflection::new_method(method, false, CHECK_NULL);
} }
result->obj_at_put(i, m); result->obj_at_put(i, m);
} }
@ -2055,7 +2055,7 @@ static jobject get_method_at_helper(constantPoolHandle cp, jint index, bool forc
} }
oop method; oop method;
if (!m->is_initializer() || m->is_static()) { if (!m->is_initializer() || m->is_static()) {
method = Reflection::new_method(m, true, true, CHECK_NULL); method = Reflection::new_method(m, true, CHECK_NULL);
} else { } else {
method = Reflection::new_constructor(m, CHECK_NULL); method = Reflection::new_constructor(m, CHECK_NULL);
} }
@ -2105,7 +2105,7 @@ static jobject get_field_at_helper(constantPoolHandle cp, jint index, bool force
if (target_klass == NULL) { if (target_klass == NULL) {
THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"); THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class");
} }
oop field = Reflection::new_field(&fd, true, CHECK_NULL); oop field = Reflection::new_field(&fd, CHECK_NULL);
return JNIHandles::make_local(field); return JNIHandles::make_local(field);
} }
@ -3521,7 +3521,6 @@ JVM_END
JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env)) JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env))
for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) {
// UseNewReflection
vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection
oop loader = vfst.method()->method_holder()->class_loader(); oop loader = vfst.method()->method_holder()->class_loader();
if (loader != NULL) { if (loader != NULL) {

View file

@ -311,6 +311,9 @@ static ObsoleteFlag obsolete_jvm_flags[] = {
{ "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) }, { "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ NULL, JDK_Version(0), JDK_Version(0) } { NULL, JDK_Version(0), JDK_Version(0) }
}; };

View file

@ -3647,22 +3647,6 @@ class CommandLineFlags {
\ \
/* New JDK 1.4 reflection implementation */ \ /* New JDK 1.4 reflection implementation */ \
\ \
develop(bool, UseNewReflection, true, \
"Temporary flag for transition to reflection based on dynamic " \
"bytecode generation in 1.4; can no longer be turned off in 1.4 " \
"JDK, and is unneeded in 1.3 JDK, but marks most places VM " \
"changes were needed") \
\
develop(bool, VerifyReflectionBytecodes, false, \
"Force verification of 1.4 reflection bytecodes. Does not work " \
"in situations like that described in 4486457 or for " \
"constructors generated for serialization, so can not be enabled "\
"in product.") \
\
product(bool, ReflectionWrapResolutionErrors, true, \
"Temporary flag for transition to AbstractMethodError wrapped " \
"in InvocationTargetException. See 6531596") \
\
develop(intx, FastSuperclassLimit, 8, \ develop(intx, FastSuperclassLimit, 8, \
"Depth of hardwired instanceof accelerator array") \ "Depth of hardwired instanceof accelerator array") \
\ \

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * 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
@ -466,7 +466,6 @@ bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, boo
// New (1.4) reflection implementation. Allow all accesses from // New (1.4) reflection implementation. Allow all accesses from
// sun/reflect/MagicAccessorImpl subclasses to succeed trivially. // sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
if ( JDK_Version::is_gte_jdk14x_version() if ( JDK_Version::is_gte_jdk14x_version()
&& UseNewReflection
&& current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
return true; return true;
} }
@ -571,7 +570,6 @@ bool Reflection::verify_field_access(Klass* current_class,
// New (1.4) reflection implementation. Allow all accesses from // New (1.4) reflection implementation. Allow all accesses from
// sun/reflect/MagicAccessorImpl subclasses to succeed trivially. // sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
if ( JDK_Version::is_gte_jdk14x_version() if ( JDK_Version::is_gte_jdk14x_version()
&& UseNewReflection
&& current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
return true; return true;
} }
@ -708,7 +706,7 @@ Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) {
} }
oop Reflection::new_method(methodHandle method, bool intern_name, bool for_constant_pool_access, TRAPS) { oop Reflection::new_method(methodHandle method, bool for_constant_pool_access, TRAPS) {
// In jdk1.2.x, getMethods on an interface erroneously includes <clinit>, thus the complicated assert. // In jdk1.2.x, getMethods on an interface erroneously includes <clinit>, thus the complicated assert.
// Also allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods. // Also allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
assert(!method()->is_initializer() || assert(!method()->is_initializer() ||
@ -731,14 +729,8 @@ oop Reflection::new_method(methodHandle method, bool intern_name, bool for_const
if (exception_types.is_null()) return NULL; if (exception_types.is_null()) return NULL;
Symbol* method_name = method->name(); Symbol* method_name = method->name();
Handle name; oop name_oop = StringTable::intern(method_name, CHECK_NULL);
if (intern_name) { Handle name = Handle(THREAD, name_oop);
// intern_name is only true with UseNewReflection
oop name_oop = StringTable::intern(method_name, CHECK_NULL);
name = Handle(THREAD, name_oop);
} else {
name = java_lang_String::create_from_symbol(method_name, CHECK_NULL);
}
if (name == NULL) return NULL; if (name == NULL) return NULL;
int modifiers = method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; int modifiers = method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS;
@ -825,16 +817,10 @@ oop Reflection::new_constructor(methodHandle method, TRAPS) {
} }
oop Reflection::new_field(fieldDescriptor* fd, bool intern_name, TRAPS) { oop Reflection::new_field(fieldDescriptor* fd, TRAPS) {
Symbol* field_name = fd->name(); Symbol* field_name = fd->name();
Handle name; oop name_oop = StringTable::intern(field_name, CHECK_NULL);
if (intern_name) { Handle name = Handle(THREAD, name_oop);
// intern_name is only true with UseNewReflection
oop name_oop = StringTable::intern(field_name, CHECK_NULL);
name = Handle(THREAD, name_oop);
} else {
name = java_lang_String::create_from_symbol(field_name, CHECK_NULL);
}
Symbol* signature = fd->signature(); Symbol* signature = fd->signature();
instanceKlassHandle holder (THREAD, fd->field_holder()); instanceKlassHandle holder (THREAD, fd->field_holder());
Handle type = new_type(signature, holder, CHECK_NULL); Handle type = new_type(signature, holder, CHECK_NULL);
@ -933,27 +919,23 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
// resolve based on the receiver // resolve based on the receiver
if (reflected_method->method_holder()->is_interface()) { if (reflected_method->method_holder()->is_interface()) {
// resolve interface call // resolve interface call
if (ReflectionWrapResolutionErrors) { //
// new default: 6531596 // Match resolution errors with those thrown due to reflection inlining
// Match resolution errors with those thrown due to reflection inlining // Linktime resolution & IllegalAccessCheck already done by Class.getMethod()
// Linktime resolution & IllegalAccessCheck already done by Class.getMethod() method = resolve_interface_call(klass, reflected_method, target_klass, receiver, THREAD);
method = resolve_interface_call(klass, reflected_method, target_klass, receiver, THREAD); if (HAS_PENDING_EXCEPTION) {
if (HAS_PENDING_EXCEPTION) { // Method resolution threw an exception; wrap it in an InvocationTargetException
// Method resolution threw an exception; wrap it in an InvocationTargetException oop resolution_exception = PENDING_EXCEPTION;
oop resolution_exception = PENDING_EXCEPTION; CLEAR_PENDING_EXCEPTION;
CLEAR_PENDING_EXCEPTION; // JVMTI has already reported the pending exception
// JVMTI has already reported the pending exception // JVMTI internal flag reset is needed in order to report InvocationTargetException
// JVMTI internal flag reset is needed in order to report InvocationTargetException if (THREAD->is_Java_thread()) {
if (THREAD->is_Java_thread()) { JvmtiExport::clear_detected_exception((JavaThread*) THREAD);
JvmtiExport::clear_detected_exception((JavaThread*) THREAD);
}
JavaCallArguments args(Handle(THREAD, resolution_exception));
THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
vmSymbols::throwable_void_signature(),
&args);
} }
} else { JavaCallArguments args(Handle(THREAD, resolution_exception));
method = resolve_interface_call(klass, reflected_method, target_klass, receiver, CHECK_(NULL)); THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
vmSymbols::throwable_void_signature(),
&args);
} }
} else { } else {
// if the method can be overridden, we resolve using the vtable index. // if the method can be overridden, we resolve using the vtable index.
@ -970,24 +952,16 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
// Check for abstract methods as well // Check for abstract methods as well
if (method->is_abstract()) { if (method->is_abstract()) {
// new default: 6531596 // new default: 6531596
if (ReflectionWrapResolutionErrors) { ResourceMark rm(THREAD);
ResourceMark rm(THREAD); Handle h_origexception = Exceptions::new_exception(THREAD,
Handle h_origexception = Exceptions::new_exception(THREAD, vmSymbols::java_lang_AbstractMethodError(),
vmSymbols::java_lang_AbstractMethodError(), Method::name_and_sig_as_C_string(target_klass(),
Method::name_and_sig_as_C_string(target_klass(), method->name(),
method->name(), method->signature()));
method->signature())); JavaCallArguments args(h_origexception);
JavaCallArguments args(h_origexception); THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(), vmSymbols::throwable_void_signature(),
vmSymbols::throwable_void_signature(), &args);
&args);
} else {
ResourceMark rm(THREAD);
THROW_MSG_0(vmSymbols::java_lang_AbstractMethodError(),
Method::name_and_sig_as_C_string(target_klass(),
method->name(),
method->signature()));
}
} }
} }
} }
@ -1006,7 +980,7 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
// In the JDK 1.4 reflection implementation, the security check is // In the JDK 1.4 reflection implementation, the security check is
// done at the Java level // done at the Java level
if (!(JDK_Version::is_gte_jdk14x_version() && UseNewReflection)) { if (!JDK_Version::is_gte_jdk14x_version()) {
// Access checking (unless overridden by Method) // Access checking (unless overridden by Method)
if (!override) { if (!override) {
@ -1018,7 +992,7 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method,
} }
} }
} // !(Universe::is_gte_jdk14x_version() && UseNewReflection) } // !Universe::is_gte_jdk14x_version()
assert(ptypes->is_objArray(), "just checking"); assert(ptypes->is_objArray(), "just checking");
int args_len = args.is_null() ? 0 : args->length(); int args_len = args.is_null() ? 0 : args->length();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * 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
@ -113,11 +113,11 @@ class Reflection: public AllStatic {
// //
// Create a java.lang.reflect.Method object based on a method // Create a java.lang.reflect.Method object based on a method
static oop new_method(methodHandle method, bool intern_name, bool for_constant_pool_access, TRAPS); static oop new_method(methodHandle method, bool for_constant_pool_access, TRAPS);
// Create a java.lang.reflect.Constructor object based on a method // Create a java.lang.reflect.Constructor object based on a method
static oop new_constructor(methodHandle method, TRAPS); static oop new_constructor(methodHandle method, TRAPS);
// Create a java.lang.reflect.Field object based on a field descriptor // Create a java.lang.reflect.Field object based on a field descriptor
static oop new_field(fieldDescriptor* fd, bool intern_name, TRAPS); static oop new_field(fieldDescriptor* fd, TRAPS);
// Create a java.lang.reflect.Parameter object based on a // Create a java.lang.reflect.Parameter object based on a
// MethodParameterElement // MethodParameterElement
static oop new_parameter(Handle method, int index, Symbol* sym, static oop new_parameter(Handle method, int index, Symbol* sym,

View file

@ -473,7 +473,7 @@ void vframeStreamCommon::skip_prefixed_method_and_wrappers() {
void vframeStreamCommon::skip_reflection_related_frames() { void vframeStreamCommon::skip_reflection_related_frames() {
while (!at_end() && while (!at_end() &&
(JDK_Version::is_gte_jdk14x_version() && UseNewReflection && (JDK_Version::is_gte_jdk14x_version() &&
(method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) || (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) ||
method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass())))) { method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass())))) {
next(); next();