test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/GetLocalVariable/getlocal003/getlocal003.cpp
changeset 55117 b6418e5aad70
parent 52445 a1eb4f1b94c1
child 59223 f16e4154dd7b
equal deleted inserted replaced
55116:5212c250f9a8 55117:b6418e5aad70
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    65             table[i].start_location + table[i].length < location) {
    65             table[i].start_location + table[i].length < location) {
    66             continue;  /* The local variable is not visible */
    66             continue;  /* The local variable is not visible */
    67         }
    67         }
    68         print_LocalVariableEntry(&table[i]);
    68         print_LocalVariableEntry(&table[i]);
    69         char sig = table[i].signature[0];
    69         char sig = table[i].signature[0];
       
    70         int slot = table[i].slot;
    70 
    71 
    71         if (sig == 'Z' || sig == 'B' || sig == 'C' || sig == 'S') {
    72         if (sig == 'Z' || sig == 'B' || sig == 'C' || sig == 'S') {
    72             sig = 'I'; // covered by GetLocalInt
    73             sig = 'I'; // covered by GetLocalInt
    73         }
    74         }
    74         err = jvmti->GetLocalInt(thr, 0, table[i].slot, &intVal);
    75         err = jvmti->GetLocalInt(thr, 0, slot, &intVal);
    75         printf(" GetLocalInt:     %s (%d)\n", TranslateError(err), err);
    76         printf(" GetLocalInt:     %s (%d)\n", TranslateError(err), err);
    76         if (err != JVMTI_ERROR_NONE && sig == 'I') {
    77         if (err != JVMTI_ERROR_NONE && sig == 'I') {
    77             printf("FAIL: GetLocalInt failed to get value of int\n");
    78             printf("FAIL: GetLocalInt failed to get value of int\n");
    78             result = STATUS_FAILED;
    79             result = STATUS_FAILED;
    79         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'I') {
    80         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'I') {
    80             printf("FAIL: GetLocalInt did not return JVMTI_ERROR_TYPE_MISMATCH for non-int\n");
    81             printf("FAIL: GetLocalInt did not return JVMTI_ERROR_TYPE_MISMATCH for non-int\n");
    81             result = STATUS_FAILED;
    82             result = STATUS_FAILED;
    82         }
    83         }
    83 
    84 
    84         err = jvmti->GetLocalLong(thr, 0, table[i].slot, &longVal);
    85         err = jvmti->GetLocalLong(thr, 0, slot, &longVal);
    85         printf(" GetLocalLong:    %s (%d)\n", TranslateError(err), err);
    86         printf(" GetLocalLong:    %s (%d)\n", TranslateError(err), err);
    86         if (err != JVMTI_ERROR_NONE && sig == 'J') {
    87         if (err != JVMTI_ERROR_NONE && sig == 'J') {
    87             printf("FAIL: GetLocalLong failed to get value of long\n");
    88             printf("FAIL: GetLocalLong failed to get value of long\n");
    88             result = STATUS_FAILED;
    89             result = STATUS_FAILED;
    89         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'J') {
    90         } else if (err != JVMTI_ERROR_INVALID_SLOT &&
    90             printf("FAIL: GetLocalLong did not return JVMTI_ERROR_TYPE_MISMATCH for non-long\n");
    91                    err != JVMTI_ERROR_TYPE_MISMATCH &&
    91             result = STATUS_FAILED;
    92                    sig != 'J') {
    92         }
    93             printf("FAIL: GetLocalLong did not return JVMTI_ERROR_INVALID_SLOT"
    93 
    94                    " nor JVMTI_ERROR_TYPE_MISMATCH for non-long\n");
    94         err = jvmti->GetLocalFloat(thr, 0, table[i].slot, &floatVal);
    95             result = STATUS_FAILED;
       
    96         }
       
    97 
       
    98         err = jvmti->GetLocalFloat(thr, 0, slot, &floatVal);
    95         printf(" GetLocalFloat:   %s (%d)\n", TranslateError(err), err);
    99         printf(" GetLocalFloat:   %s (%d)\n", TranslateError(err), err);
    96         if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'F') {
   100         if (err != JVMTI_ERROR_NONE && sig == 'F') {
    97             printf("FAIL: GetLocalFloat failed to get value of float\n");
   101             printf("FAIL: GetLocalFloat failed to get value of float\n");
    98             result = STATUS_FAILED;
   102             result = STATUS_FAILED;
    99         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'F') {
   103         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'F') {
   100             printf("FAIL: GetLocalFloat did not return JVMTI_ERROR_TYPE_MISMATCH for non-float\n");
   104             printf("FAIL: GetLocalFloat did not return JVMTI_ERROR_TYPE_MISMATCH for non-float\n");
   101             result = STATUS_FAILED;
   105             result = STATUS_FAILED;
   102         }
   106         }
   103 
   107 
   104         err = jvmti->GetLocalDouble(thr, 0, table[i].slot, &doubleVal);
   108         err = jvmti->GetLocalDouble(thr, 0, slot, &doubleVal);
   105         printf(" GetLocalDouble:  %s (%d)\n", TranslateError(err), err);
   109         printf(" GetLocalDouble:  %s (%d)\n", TranslateError(err), err);
   106         if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'D') {
   110         if (err != JVMTI_ERROR_NONE && sig == 'D') {
   107             printf("FAIL: GetLocalDouble failed to get value of double\n");
   111             printf("FAIL: GetLocalDouble failed to get value of double\n");
   108             result = STATUS_FAILED;
   112             result = STATUS_FAILED;
   109         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'D') {
   113         } else if (err != JVMTI_ERROR_INVALID_SLOT &&
   110             printf("FAIL: GetLocalDouble did not return JVMTI_ERROR_TYPE_MISMATCH for non-double\n");
   114                    err != JVMTI_ERROR_TYPE_MISMATCH &&
   111             result = STATUS_FAILED;
   115                    sig != 'D') {
   112         }
   116             printf("FAIL: GetLocalDouble did not return JVMTI_ERROR_INVALID_SLOT"
   113 
   117                    " nor JVMTI_ERROR_TYPE_MISMATCH for non-double\n");
   114         err = jvmti->GetLocalObject(thr, 0, table[i].slot, &obj);
   118             result = STATUS_FAILED;
       
   119         }
       
   120 
       
   121         err = jvmti->GetLocalObject(thr, 0, slot, &obj);
   115         printf(" GetLocalObject:  %s (%d)\n", TranslateError(err), err);
   122         printf(" GetLocalObject:  %s (%d)\n", TranslateError(err), err);
   116         if (err != JVMTI_ERROR_NONE && table[i].signature[0] == 'L') {
   123         if (err != JVMTI_ERROR_NONE && sig == 'L') {
   117             printf("FAIL: GetLocalObject failed to get value of object\n");
   124             printf("FAIL: GetLocalObject failed to get value of object\n");
   118             result = STATUS_FAILED;
   125             result = STATUS_FAILED;
   119         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && table[i].signature[0] != 'L') {
   126         } else if (err != JVMTI_ERROR_TYPE_MISMATCH && sig != 'L') {
   120             printf("FAIL: GetLocalObject did not return JVMTI_ERROR_TYPE_MISMATCH for non-object\n");
   127             printf("FAIL: GetLocalObject did not return JVMTI_ERROR_TYPE_MISMATCH for non-object\n");
   121             result = STATUS_FAILED;
   128             result = STATUS_FAILED;
   122         }
   129         }
   123     }
   130     }
   124 }
   131 }