8031045: Access checks should precede additional per-instruction checks
authorhseigel
Fri, 17 Jan 2014 09:39:51 -0500
changeset 22521 5387725ea99d
parent 22516 19615e4d71bd
child 22522 c776d3301b4a
8031045: Access checks should precede additional per-instruction checks Summary: Move access check above the check for non-static method Reviewed-by: lfoltan, coleenp
hotspot/src/share/vm/interpreter/linkResolver.cpp
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp	Wed Jan 15 11:46:19 2014 +0100
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp	Fri Jan 17 09:39:51 2014 -0500
@@ -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.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -649,16 +649,6 @@
     }
   }
 
-  if (nostatics && resolved_method->is_static()) {
-    ResourceMark rm(THREAD);
-    char buf[200];
-    jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", Method::name_and_sig_as_C_string(resolved_klass(),
-                                                      resolved_method->name(),
-                                                      resolved_method->signature()));
-    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
-  }
-
-
   if (check_access) {
     // JDK8 adds non-public interface methods, and accessability check requirement
     assert(current_klass.not_null() , "current_klass should not be null");
@@ -702,6 +692,15 @@
     }
   }
 
+  if (nostatics && resolved_method->is_static()) {
+    ResourceMark rm(THREAD);
+    char buf[200];
+    jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s",
+                 Method::name_and_sig_as_C_string(resolved_klass(),
+                 resolved_method->name(), resolved_method->signature()));
+    THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
+  }
+
   if (TraceItables && Verbose) {
     ResourceMark rm(THREAD);
     tty->print("invokeinterface resolved method: caller-class:%s, compile-time-class:%s, method:%s, method_holder:%s, access_flags: ",