diff src/share/vm/memory/universe.cpp @ 13403:9d15b81d5d1b

8016839: JSR292: AME instead of IAE when calling a method Summary: Catch missing-because-illegal case for itable entries and use an exception-throwing method instead of null. Reviewed-by: acorn, jrose, coleenp
author drchase
date Tue, 26 Nov 2013 18:16:04 -0500
parents 610be0309a79
children 02f27ecb4f3a 63a4eb8bcd23 1174c8abbdb6 cfd4aac53239
line wrap: on
line diff
--- a/src/share/vm/memory/universe.cpp	Fri Nov 22 13:42:46 2013 -0800
+++ b/src/share/vm/memory/universe.cpp	Tue Nov 26 18:16:04 2013 -0500
@@ -120,6 +120,7 @@
 oop Universe::_arithmetic_exception_instance          = NULL;
 oop Universe::_virtual_machine_error_instance         = NULL;
 oop Universe::_vm_exception                           = NULL;
+Method* Universe::_throw_illegal_access_error         = NULL;
 Array<int>* Universe::_the_empty_int_array            = NULL;
 Array<u2>* Universe::_the_empty_short_array           = NULL;
 Array<Klass*>* Universe::_the_empty_klass_array     = NULL;
@@ -1096,6 +1097,18 @@
   Universe::_finalizer_register_cache->init(
     SystemDictionary::Finalizer_klass(), m);
 
+  InstanceKlass::cast(SystemDictionary::misc_Unsafe_klass())->link_class(CHECK_false);
+  m = InstanceKlass::cast(SystemDictionary::misc_Unsafe_klass())->find_method(
+                                  vmSymbols::throwIllegalAccessError_name(),
+                                  vmSymbols::void_method_signature());
+  if (m != NULL && !m->is_static()) {
+    // Note null is okay; this method is used in itables, and if it is null,
+    // then AbstractMethodError is thrown instead.
+    tty->print_cr("Unable to link/verify Unsafe.throwIllegalAccessError method");
+    return false; // initialization failed (cannot throw exception yet)
+  }
+  Universe::_throw_illegal_access_error = m;
+
   // Setup method for registering loaded classes in class loader vector
   InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->link_class(CHECK_false);
   m = InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->find_method(vmSymbols::addClass_name(), vmSymbols::class_void_signature());