10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include <stdio.h>
25 #include <string.h>
26 #include "jvmti.h"
27 #include "agent_common.h"
28 #include "JVMTITools.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #ifndef JNI_ENV_ARG
35
36 #ifdef __cplusplus
37 #define JNI_ENV_ARG(x, y) y
38 #define JNI_ENV_PTR(x) x
39 #else
40 #define JNI_ENV_ARG(x,y) x, y
41 #define JNI_ENV_PTR(x) (*x)
42 #endif
43
44 #endif
45
46 #define PASSED 0
47 #define STATUS_FAILED 2
48 #define JVM_ACC_SYNTHETIC 0x1000
49
50 static jvmtiEnv *jvmti = NULL;
51 static jvmtiCapabilities caps;
52 static jint result = PASSED;
53 static jboolean printdump = JNI_FALSE;
54
55 #ifdef STATIC_BUILD
56 JNIEXPORT jint JNICALL Agent_OnLoad_issynth001(JavaVM *jvm, char *options, void *reserved) {
57 return Agent_Initialize(jvm, options, reserved);
58 }
59 JNIEXPORT jint JNICALL Agent_OnAttach_issynth001(JavaVM *jvm, char *options, void *reserved) {
60 return Agent_Initialize(jvm, options, reserved);
61 }
62 JNIEXPORT jint JNI_OnLoad_issynth001(JavaVM *jvm, char *options, void *reserved) {
63 return JNI_VERSION_1_8;
64 }
65 #endif
66 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
67 jint res;
68 jvmtiError err;
69
70 if (options != NULL && strcmp(options, "printdump") == 0) {
71 printdump = JNI_TRUE;
72 }
73
74 res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
75 JVMTI_VERSION_1_1);
76 if (res != JNI_OK || jvmti == NULL) {
77 printf("Wrong result of a valid call to GetEnv!\n");
78 return JNI_ERR;
79 }
80
81 err = jvmti->GetPotentialCapabilities(&caps);
82 if (err != JVMTI_ERROR_NONE) {
83 printf("(GetPotentialCapabilities) unexpected error: %s (%d)\n",
84 TranslateError(err), err);
85 return JNI_ERR;
86 }
87
88 err = jvmti->AddCapabilities(&caps);
89 if (err != JVMTI_ERROR_NONE) {
90 printf("(AddCapabilities) unexpected error: %s (%d)\n",
91 TranslateError(err), err);
92 return JNI_ERR;
93 }
94
95 err = jvmti->GetCapabilities(&caps);
277 * No synthetic methods are expected here.
278 */
279 result = checkClassMethods(klass);
280 if (result != PASSED) {
281 return result;
282 }
283
284 /* Check of fields of Inner class.
285 * Just one synthetic field is expected here:
286 * Name: this$0, Signature: Lnsk/jvmti/unit/IsSynthetic/issynth001;
287 */
288 result = checkClassFields(klass);
289
290 return result;
291 }
292
293 JNIEXPORT jint JNICALL Java_issynth001_getRes(JNIEnv *env, jclass cls) {
294 return result;
295 }
296
297 #ifdef __cplusplus
298 }
299 #endif
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include <stdio.h>
25 #include <string.h>
26 #include "jvmti.h"
27 #include "agent_common.h"
28 #include "JVMTITools.h"
29
30 extern "C" {
31
32
33 #define PASSED 0
34 #define STATUS_FAILED 2
35 #define JVM_ACC_SYNTHETIC 0x1000
36
37 static jvmtiEnv *jvmti = NULL;
38 static jvmtiCapabilities caps;
39 static jint result = PASSED;
40 static jboolean printdump = JNI_FALSE;
41
42 #ifdef STATIC_BUILD
43 JNIEXPORT jint JNICALL Agent_OnLoad_issynth001(JavaVM *jvm, char *options, void *reserved) {
44 return Agent_Initialize(jvm, options, reserved);
45 }
46 JNIEXPORT jint JNICALL Agent_OnAttach_issynth001(JavaVM *jvm, char *options, void *reserved) {
47 return Agent_Initialize(jvm, options, reserved);
48 }
49 JNIEXPORT jint JNI_OnLoad_issynth001(JavaVM *jvm, char *options, void *reserved) {
50 return JNI_VERSION_1_8;
51 }
52 #endif
53 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
54 jint res;
55 jvmtiError err;
56
57 if (options != NULL && strcmp(options, "printdump") == 0) {
58 printdump = JNI_TRUE;
59 }
60
61 res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
62 if (res != JNI_OK || jvmti == NULL) {
63 printf("Wrong result of a valid call to GetEnv!\n");
64 return JNI_ERR;
65 }
66
67 err = jvmti->GetPotentialCapabilities(&caps);
68 if (err != JVMTI_ERROR_NONE) {
69 printf("(GetPotentialCapabilities) unexpected error: %s (%d)\n",
70 TranslateError(err), err);
71 return JNI_ERR;
72 }
73
74 err = jvmti->AddCapabilities(&caps);
75 if (err != JVMTI_ERROR_NONE) {
76 printf("(AddCapabilities) unexpected error: %s (%d)\n",
77 TranslateError(err), err);
78 return JNI_ERR;
79 }
80
81 err = jvmti->GetCapabilities(&caps);
263 * No synthetic methods are expected here.
264 */
265 result = checkClassMethods(klass);
266 if (result != PASSED) {
267 return result;
268 }
269
270 /* Check of fields of Inner class.
271 * Just one synthetic field is expected here:
272 * Name: this$0, Signature: Lnsk/jvmti/unit/IsSynthetic/issynth001;
273 */
274 result = checkClassFields(klass);
275
276 return result;
277 }
278
279 JNIEXPORT jint JNICALL Java_issynth001_getRes(JNIEnv *env, jclass cls) {
280 return result;
281 }
282
283 }
|