hotspot/src/share/vm/runtime/reflection.cpp
changeset 25057 f38210f84f8c
parent 24456 8c7933fa5a1f
child 26412 80741eb33ba2
--- a/hotspot/src/share/vm/runtime/reflection.cpp	Wed Jun 11 12:09:12 2014 +0200
+++ b/hotspot/src/share/vm/runtime/reflection.cpp	Wed Jun 11 09:58:23 2014 -0400
@@ -410,49 +410,6 @@
 }
 
 
-bool Reflection::reflect_check_access(Klass* field_class, AccessFlags acc, Klass* target_class, bool is_method_invoke, TRAPS) {
-  // field_class  : declaring class
-  // acc          : declared field access
-  // target_class : for protected
-
-  // Check if field or method is accessible to client.  Throw an
-  // IllegalAccessException and return false if not.
-
-  // The "client" is the class associated with the nearest real frame
-  // getCallerClass already skips Method.invoke frames, so pass 0 in
-  // that case (same as classic).
-  ResourceMark rm(THREAD);
-  assert(THREAD->is_Java_thread(), "sanity check");
-  Klass* client_class = ((JavaThread *)THREAD)->security_get_caller_class(is_method_invoke ? 0 : 1);
-
-  if (client_class != field_class) {
-    if (!verify_class_access(client_class, field_class, false)
-        || !verify_field_access(client_class,
-                                field_class,
-                                field_class,
-                                acc,
-                                false)) {
-      THROW_(vmSymbols::java_lang_IllegalAccessException(), false);
-    }
-  }
-
-  // Additional test for protected members: JLS 6.6.2
-
-  if (acc.is_protected()) {
-    if (target_class != client_class) {
-      if (!is_same_class_package(client_class, field_class)) {
-        if (!target_class->is_subclass_of(client_class)) {
-          THROW_(vmSymbols::java_lang_IllegalAccessException(), false);
-        }
-      }
-    }
-  }
-
-  // Passed all tests
-  return true;
-}
-
-
 bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, bool classloader_only) {
   // Verify that current_class can access new_class.  If the classloader_only
   // flag is set, we automatically allow any accesses in which current_class
@@ -463,10 +420,9 @@
       is_same_class_package(current_class, new_class)) {
     return true;
   }
-  // New (1.4) reflection implementation. Allow all accesses from
-  // sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
-  if (   JDK_Version::is_gte_jdk14x_version()
-      && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
+  // Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to
+  // succeed trivially.
+  if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
     return true;
   }
 
@@ -567,10 +523,9 @@
     return true;
   }
 
-  // New (1.4) reflection implementation. Allow all accesses from
-  // sun/reflect/MagicAccessorImpl subclasses to succeed trivially.
-  if (   JDK_Version::is_gte_jdk14x_version()
-      && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
+  // Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to
+  // succeed trivially.
+  if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) {
     return true;
   }
 
@@ -707,12 +662,10 @@
 
 
 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.
-  // Also allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
+  // Allow sun.reflect.ConstantPool to refer to <clinit> methods as java.lang.reflect.Methods.
   assert(!method()->is_initializer() ||
-         (for_constant_pool_access && method()->is_static()) ||
-         (method()->name() == vmSymbols::class_initializer_name()
-    && method()->method_holder()->is_interface() && JDK_Version::is_jdk12x_version()), "should call new_constructor instead");
+         (for_constant_pool_access && method()->is_static()),
+         "should call new_constructor instead");
   instanceKlassHandle holder (THREAD, method->method_holder());
   int slot = method->method_idnum();
 
@@ -978,22 +931,6 @@
                                                         reflected_method->signature()));
   }
 
-  // In the JDK 1.4 reflection implementation, the security check is
-  // done at the Java level
-  if (!JDK_Version::is_gte_jdk14x_version()) {
-
-  // Access checking (unless overridden by Method)
-  if (!override) {
-    if (!(klass->is_public() && reflected_method->is_public())) {
-      bool access = Reflection::reflect_check_access(klass(), reflected_method->access_flags(), target_klass(), is_method_invoke, CHECK_NULL);
-      if (!access) {
-        return NULL; // exception
-      }
-    }
-  }
-
-  } // !Universe::is_gte_jdk14x_version()
-
   assert(ptypes->is_objArray(), "just checking");
   int args_len = args.is_null() ? 0 : args->length();
   // Check number of arguments