diff src/share/vm/c1/c1_GraphBuilder.cpp @ 18003:dda2ae6f9557

8046542: [I.finalize() calls from methods compiled by C1 do not cause IllegalAccessError on Sparc Summary: call to Object.finalize() sometimes allowed by compilers on array type Reviewed-by: iveresov, vlivanov
author roland
date Wed, 02 Jul 2014 22:54:18 +0200
parents 45e59fae8f2b
children ee1c924763d2
line wrap: on
line diff
--- a/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Jul 03 12:59:11 2014 -0700
+++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Jul 02 22:54:18 2014 +0200
@@ -1993,7 +1993,13 @@
   if (!UseInlineCaches && is_loaded && code == Bytecodes::_invokevirtual
       && !target->can_be_statically_bound()) {
     // Find a vtable index if one is available
-    vtable_index = target->resolve_vtable_index(calling_klass, callee_holder);
+    // For arrays, callee_holder is Object. Resolving the call with
+    // Object would allow an illegal call to finalize() on an
+    // array. We use holder instead: illegal calls to finalize() won't
+    // be compiled as vtable calls (IC call resolution will catch the
+    // illegal call) and the few legal calls on array types won't be
+    // either.
+    vtable_index = target->resolve_vtable_index(calling_klass, holder);
   }
 #endif