author | jcbeyler |
Wed, 17 Oct 2018 21:28:11 -0700 | |
changeset 52184 | 672bc2213cef |
parent 51774 | 79dc492c00ab |
permissions | -rw-r--r-- |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
1 |
/* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
4 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
8 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
14 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
18 |
* |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
22 |
*/ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
23 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
24 |
#include <stdlib.h> |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
25 |
#include <string.h> |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
26 |
#include "jni_tools.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
27 |
#include "agent_common.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
28 |
#include "jvmti_tools.h" |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
29 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
30 |
#define PASSED 0 |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
31 |
#define STATUS_FAILED 2 |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
32 |
#define SAMPLE_TAG ((jlong) 111111) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
33 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
34 |
extern "C" { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
35 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
36 |
/* ========================================================================== */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
37 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
38 |
/* scaffold objects */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
39 |
static jlong timeout = 0; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
40 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
41 |
/* test objects */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
42 |
static jobject testedObject = NULL; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
43 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
44 |
/* ========================================================================== */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
45 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
46 |
static int prepare(JNIEnv* jni) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
47 |
const char* CLASS_NAME = "nsk/jvmti/scenarios/multienv/MA04/ma04t001"; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
48 |
const char* FIELD_NAME = "testedObject"; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
49 |
const char* FIELD_SIGNATURE = "Ljava/lang/Object;"; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
50 |
jclass cls = NULL; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
51 |
jfieldID fid = NULL; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
52 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
53 |
NSK_DISPLAY0("Obtain tested object from a static field of debugee class\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
54 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
55 |
NSK_DISPLAY1("Find class: %s\n", CLASS_NAME); |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
56 |
if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(CLASS_NAME)) != NULL)) |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
57 |
return NSK_FALSE; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
58 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
59 |
NSK_DISPLAY2("Find field: %s:%s\n", FIELD_NAME, FIELD_SIGNATURE); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
60 |
if (!NSK_JNI_VERIFY(jni, (fid = |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
61 |
jni->GetStaticFieldID(cls, FIELD_NAME, FIELD_SIGNATURE)) != NULL)) |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
62 |
return NSK_FALSE; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
63 |
|
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
64 |
if (!NSK_JNI_VERIFY(jni, (testedObject = jni->GetStaticObjectField(cls, fid)) != NULL)) |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
65 |
return NSK_FALSE; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
66 |
|
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
67 |
if (!NSK_JNI_VERIFY(jni, (testedObject = jni->NewGlobalRef(testedObject)) != NULL)) |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
68 |
return NSK_FALSE; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
69 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
70 |
return NSK_TRUE; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
71 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
72 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
73 |
/* ========================================================================== */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
74 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
75 |
/** Agent algorithm. */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
76 |
static void JNICALL |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
77 |
agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
78 |
jlong tag = -1; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
79 |
char buffer[32]; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
80 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
81 |
if (!nsk_jvmti_waitForSync(timeout)) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
82 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
83 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
84 |
if (!prepare(jni)) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
85 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
86 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
87 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
88 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
89 |
NSK_DISPLAY0("Testcase #1: check that testedObject is not tagged \n"); |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
90 |
if (!NSK_JVMTI_VERIFY(jvmti->GetTag(testedObject, &tag))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
91 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
92 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
93 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
94 |
NSK_DISPLAY1("tag = %s\n", jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
95 |
if (tag != 0) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
96 |
NSK_COMPLAIN1("testedObject is unexpectedly tagged: %s\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
97 |
jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
98 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
99 |
} |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
100 |
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(testedObject, SAMPLE_TAG))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
101 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
102 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
103 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
104 |
if (!NSK_VERIFY(nsk_jvmti_resumeSync())) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
105 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
106 |
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
107 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
108 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
109 |
NSK_DISPLAY0("Testcase #2: check that testedObject is tagged correctly\n"); |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
110 |
if (!NSK_JVMTI_VERIFY(jvmti->GetTag(testedObject, &tag))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
111 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
112 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
113 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
114 |
NSK_DISPLAY1("tag = %s\n", jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
115 |
if (tag != SAMPLE_TAG) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
116 |
if (tag == 0) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
117 |
NSK_COMPLAIN0("testedObject not tagged\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
118 |
} else { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
119 |
NSK_COMPLAIN1("testedObject tagged incorrectly, expected=%s,", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
120 |
jlong_to_string(SAMPLE_TAG, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
121 |
NSK_COMPLAIN1(" got=%s\n", jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
122 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
123 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
124 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
125 |
if (!NSK_VERIFY(nsk_jvmti_resumeSync())) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
126 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
127 |
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
128 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
129 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
130 |
NSK_DISPLAY0("Testcase #3: check that testedObject is tagged correctly\n"); |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
131 |
if (!NSK_JVMTI_VERIFY(jvmti->GetTag(testedObject, &tag))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
132 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
133 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
134 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
135 |
NSK_DISPLAY1("tag = %s\n", jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
136 |
if (tag != SAMPLE_TAG) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
137 |
if (tag == 0) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
138 |
NSK_COMPLAIN0("testedObject not tagged\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
139 |
} else { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
140 |
NSK_COMPLAIN1("testedObject tagged incorrectly, expected=%s,", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
141 |
jlong_to_string(SAMPLE_TAG, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
142 |
NSK_COMPLAIN1(" got=%s\n", jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
143 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
144 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
145 |
} |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
146 |
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(testedObject, (jlong)0))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
147 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
148 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
149 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
150 |
if (!NSK_VERIFY(nsk_jvmti_resumeSync())) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
151 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
152 |
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
153 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
154 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
155 |
NSK_DISPLAY0("Testcase #4: check that testedObject is not tagged \n"); |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
156 |
if (!NSK_JVMTI_VERIFY(jvmti->GetTag(testedObject, &tag))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
157 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
158 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
159 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
160 |
NSK_DISPLAY1("tag = %s\n", jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
161 |
if (tag != 0) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
162 |
NSK_COMPLAIN1("testedObject is unexpectedly tagged: %s\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
163 |
jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
164 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
165 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
166 |
if (!NSK_VERIFY(nsk_jvmti_resumeSync())) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
167 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
168 |
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
169 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
170 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
171 |
NSK_DISPLAY0("Testcase #5: check that testedObject is not tagged\n"); |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
172 |
if (!NSK_JVMTI_VERIFY(jvmti->GetTag(testedObject, &tag))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
173 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
174 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
175 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
176 |
NSK_DISPLAY1("tag = %s\n", jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
177 |
if (tag != 0) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
178 |
NSK_COMPLAIN1("testedObject is unexpectedly tagged: %s\n", |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
179 |
jlong_to_string(tag, buffer)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
180 |
nsk_jvmti_setFailStatus(); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
181 |
} |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
182 |
NSK_TRACE(jni->DeleteGlobalRef(testedObject)); |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
183 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
184 |
if (!nsk_jvmti_resumeSync()) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
185 |
return; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
186 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
187 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
188 |
/* ========================================================================== */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
189 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
190 |
/** Agent library initialization. */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
191 |
#ifdef STATIC_BUILD |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
192 |
JNIEXPORT jint JNICALL Agent_OnLoad_ma04t001(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
193 |
return Agent_Initialize(jvm, options, reserved); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
194 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
195 |
JNIEXPORT jint JNICALL Agent_OnAttach_ma04t001(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
196 |
return Agent_Initialize(jvm, options, reserved); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
197 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
198 |
JNIEXPORT jint JNI_OnLoad_ma04t001(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
199 |
return JNI_VERSION_1_8; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
200 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
201 |
#endif |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
202 |
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
203 |
jvmtiEnv* jvmti = NULL; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
204 |
jvmtiEventCallbacks callbacks; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
205 |
jvmtiCapabilities caps; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
206 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
207 |
NSK_DISPLAY0("Agent_OnLoad\n"); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
208 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
209 |
if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
210 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
211 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
212 |
timeout = nsk_jvmti_getWaitTime() * 60 * 1000; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
213 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
214 |
if (!NSK_VERIFY((jvmti = |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
215 |
nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
216 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
217 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
218 |
memset(&caps, 0, sizeof(caps)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
219 |
caps.can_tag_objects = 1; |
52184
672bc2213cef
8211899: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[E-M]
jcbeyler
parents:
51774
diff
changeset
|
220 |
if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) { |
50260
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
221 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
222 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
223 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
224 |
if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
225 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
226 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
227 |
memset(&callbacks, 0, sizeof(callbacks)); |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
228 |
if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks))) |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
229 |
return JNI_ERR; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
230 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
231 |
return JNI_OK; |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
232 |
} |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
233 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
234 |
/* ========================================================================== */ |
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
235 |
|
46c67f5e27c2
8199383: [TESTBUG] Open source VM testbase JVMTI tests
iignatyev
parents:
diff
changeset
|
236 |
} |