8223718: Checks in check_slot_type_no_lvt() should be always executed
authorsspitsyn
Thu, 30 May 2019 15:55:16 -0700
changeset 55117 b6418e5aad70
parent 55116 5212c250f9a8
child 55118 9ea55cb79d77
8223718: Checks in check_slot_type_no_lvt() should be always executed Summary: Call check_slot_type_no_lvt() even if the LVT is present Reviewed-by: kvn, gadams, amenkov
src/hotspot/share/prims/jvmtiImpl.cpp
test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp
--- a/src/hotspot/share/prims/jvmtiImpl.cpp	Thu May 30 13:45:48 2019 -0700
+++ b/src/hotspot/share/prims/jvmtiImpl.cpp	Thu May 30 15:55:16 2019 -0700
@@ -749,10 +749,11 @@
     }
   }
 
+  if (!check_slot_type_no_lvt(_jvf)) {
+    return false;
+  }
   if (method_oop->has_localvariable_table()) {
     return check_slot_type_lvt(_jvf);
-  } else {
-    return check_slot_type_no_lvt(_jvf);
   }
   return true;
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp	Thu May 30 13:45:48 2019 -0700
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp	Thu May 30 15:55:16 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -67,11 +67,12 @@
         }
         print_LocalVariableEntry(&table[i]);
         char sig = table[i].signature[0];
+        int slot = table[i].slot;
 
         if (sig == 'Z' || sig == 'B' || sig == 'C' || sig == 'S') {
             sig = 'I'; // covered by GetLocalInt
         }
-        err = jvmti->GetLocalInt(thr, 0, table[i].slot, &intVal);
+        err = jvmti->GetLocalInt(thr, 0, slot, &intVal);
         printf(" GetLocalInt:     %s (%d)\n", TranslateError(err), err);
         if (err != JVMTI_ERROR_NONE && sig == 'I') {
             printf("FAIL: GetLocalInt failed to get value of int\n");
@@ -81,42 +82,48 @@
             result = STATUS_FAILED;
         }
 
-        err = jvmti->GetLocalLong(thr, 0, table[i].slot, &longVal);
+        err = jvmti->GetLocalLong(thr, 0, slot, &longVal);
         printf(" GetLocalLong:    %s (%d)\n", TranslateError(err), err);
         if (err != JVMTI_ERROR_NONE && sig == 'J') {
             printf("FAIL: GetLocalLong failed to get value of long\n");
             result = STATUS_FAILED;
-        } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'J') {
-            printf("FAIL: GetLocalLong did not return JVMTI_ERROR_TYPE_MISMATCH for non-long\n");
+        } else if (err != JVMTI_ERROR_INVALID_SLOT &&
+                   err != JVMTI_ERROR_TYPE_MISMATCH &&
+                   sig != 'J') {
+            printf("FAIL: GetLocalLong did not return JVMTI_ERROR_INVALID_SLOT"
+                   " nor JVMTI_ERROR_TYPE_MISMATCH for non-long\n");
             result = STATUS_FAILED;
         }
 
-        err = jvmti->GetLocalFloat(thr, 0, table[i].slot, &floatVal);
+        err = jvmti->GetLocalFloat(thr, 0, slot, &floatVal);
         printf(" GetLocalFloat:   %s (%d)\n", TranslateError(err), err);
-        if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'F') {
+        if (err != JVMTI_ERROR_NONE && sig == 'F') {
             printf("FAIL: GetLocalFloat failed to get value of float\n");
             result = STATUS_FAILED;
-        } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'F') {
+        } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'F') {
             printf("FAIL: GetLocalFloat did not return JVMTI_ERROR_TYPE_MISMATCH for non-float\n");
             result = STATUS_FAILED;
         }
 
-        err = jvmti->GetLocalDouble(thr, 0, table[i].slot, &doubleVal);
+        err = jvmti->GetLocalDouble(thr, 0, slot, &doubleVal);
         printf(" GetLocalDouble:  %s (%d)\n", TranslateError(err), err);
-        if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'D') {
+        if (err != JVMTI_ERROR_NONE && sig == 'D') {
             printf("FAIL: GetLocalDouble failed to get value of double\n");
             result = STATUS_FAILED;
-        } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'D') {
-            printf("FAIL: GetLocalDouble did not return JVMTI_ERROR_TYPE_MISMATCH for non-double\n");
+        } else if (err != JVMTI_ERROR_INVALID_SLOT &&
+                   err != JVMTI_ERROR_TYPE_MISMATCH &&
+                   sig != 'D') {
+            printf("FAIL: GetLocalDouble did not return JVMTI_ERROR_INVALID_SLOT"
+                   " nor JVMTI_ERROR_TYPE_MISMATCH for non-double\n");
             result = STATUS_FAILED;
         }
 
-        err = jvmti->GetLocalObject(thr, 0, table[i].slot, &obj);
+        err = jvmti->GetLocalObject(thr, 0, slot, &obj);
         printf(" GetLocalObject:  %s (%d)\n", TranslateError(err), err);
-        if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'L') {
+        if (err != JVMTI_ERROR_NONE && sig == 'L') {
             printf("FAIL: GetLocalObject failed to get value of object\n");
             result = STATUS_FAILED;
-        } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'L') {
+        } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'L') {
             printf("FAIL: GetLocalObject did not return JVMTI_ERROR_TYPE_MISMATCH for non-object\n");
             result = STATUS_FAILED;
         }