< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp

Print this page

  1 /*
  2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  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
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 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  */

 50 static iface_info i2[] = {
 51     { "Lnsk/jvmti/GetImplementedInterfaces/getintrf007$InnerInterface1;" }
 52 };
 53 
 54 static iface_info i3[] = {
 55     { "Lnsk/jvmti/GetImplementedInterfaces/getintrf007$InnerInterface2;" }
 56 };
 57 
 58 static iface_info i7[] = {
 59     { "Lnsk/jvmti/GetImplementedInterfaces/OuterInterface1;" }
 60 };
 61 
 62 static iface_info i8[] = {
 63     { "Lnsk/jvmti/GetImplementedInterfaces/OuterInterface1;" }
 64 };
 65 
 66 static iface_info i9[] = {
 67     { "Lnsk/jvmti/GetImplementedInterfaces/OuterInterface2;" }
 68 };
 69 




 70 static class_info classes[] = {
 71     { "InnerClass1", 0, NULL },
 72     { "InnerInterface1", 0, NULL },
 73     { "InnerInterface2", 1, i2 },
 74     { "InnerClass2", 1, i3 },
 75     { "OuterClass1", 0, NULL },
 76     { "OuterClass2", 0, NULL },
 77     { "OuterInterface1", 0, NULL },
 78     { "OuterClass3", 1, i7 },
 79     { "OuterInterface2", 1, i8 },
 80     { "OuterClass4", 1, i9 },
 81     { "OuterClass5", 0, NULL }
 82 };
 83 
 84 #ifdef STATIC_BUILD
 85 JNIEXPORT jint JNICALL Agent_OnLoad_getintrf007(JavaVM *jvm, char *options, void *reserved) {
 86     return Agent_Initialize(jvm, options, reserved);
 87 }
 88 JNIEXPORT jint JNICALL Agent_OnAttach_getintrf007(JavaVM *jvm, char *options, void *reserved) {
 89     return Agent_Initialize(jvm, options, reserved);
 90 }
 91 JNIEXPORT jint JNI_OnLoad_getintrf007(JavaVM *jvm, char *options, void *reserved) {
 92     return JNI_VERSION_1_8;
 93 }
 94 #endif
 95 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 96     jint res;
 97 
 98     if (options != NULL && strcmp(options, "printdump") == 0) {

138         printf("(%d) wrong number of interfaces: %d, expected: %d\n",
139                i, icount, classes[i].icount);
140         result = STATUS_FAILED;
141     }
142 
143     for (j = 0; j < icount; j++) {
144         if (interfaces[j] == NULL) {
145             printf("(%d:%d) null reference\n", i, j);
146         } else {
147             err = jvmti->GetClassSignature(interfaces[j],
148                 &sig, &generic);
149             if (err != JVMTI_ERROR_NONE) {
150                 printf("(GetClassSignature#%d:%d) unexpected error: %s (%d)\n",
151                        i, j, TranslateError(err), err);
152             } else {
153                 if (printdump == JNI_TRUE) {
154                     printf(">>>   [%d]: %s\n", j, sig);
155                 }
156                 if ((j < classes[i].icount) && (sig == NULL ||
157                         strcmp(sig, classes[i].ifaces[j].sig) != 0)) {
158                     printf("(%d:%d) wrong interface: \"%s\"", i, j, sig);
159                     printf(", expected: \"%s\"\n", classes[i].ifaces[j].sig);
160                     result = STATUS_FAILED;


161                 }
162             }
163         }
164     }
165 }
166 
167 JNIEXPORT int JNICALL Java_nsk_jvmti_GetImplementedInterfaces_getintrf007_getRes(JNIEnv *env, jclass cls) {
168     return result;
169 }
170 
171 }

  1 /*
  2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  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
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 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  */

 50 static iface_info i2[] = {
 51     { "Lnsk/jvmti/GetImplementedInterfaces/getintrf007$InnerInterface1;" }
 52 };
 53 
 54 static iface_info i3[] = {
 55     { "Lnsk/jvmti/GetImplementedInterfaces/getintrf007$InnerInterface2;" }
 56 };
 57 
 58 static iface_info i7[] = {
 59     { "Lnsk/jvmti/GetImplementedInterfaces/OuterInterface1;" }
 60 };
 61 
 62 static iface_info i8[] = {
 63     { "Lnsk/jvmti/GetImplementedInterfaces/OuterInterface1;" }
 64 };
 65 
 66 static iface_info i9[] = {
 67     { "Lnsk/jvmti/GetImplementedInterfaces/OuterInterface2;" }
 68 };
 69 
 70 static iface_info jlio[] = {
 71     { "Ljava/lang/IdentityObject;" }
 72 };
 73 
 74 static class_info classes[] = {
 75     { "InnerClass1", 1, jlio },
 76     { "InnerInterface1", 0, NULL },
 77     { "InnerInterface2", 1, i2 },
 78     { "InnerClass2", 2, i3 },
 79     { "OuterClass1", 1, jlio },
 80     { "OuterClass2", 0, NULL },
 81     { "OuterInterface1", 0, NULL },
 82     { "OuterClass3", 2, i7 },
 83     { "OuterInterface2", 1, i8 },
 84     { "OuterClass4", 1, i9 },
 85     { "OuterClass5", 0, NULL }
 86 };
 87 
 88 #ifdef STATIC_BUILD
 89 JNIEXPORT jint JNICALL Agent_OnLoad_getintrf007(JavaVM *jvm, char *options, void *reserved) {
 90     return Agent_Initialize(jvm, options, reserved);
 91 }
 92 JNIEXPORT jint JNICALL Agent_OnAttach_getintrf007(JavaVM *jvm, char *options, void *reserved) {
 93     return Agent_Initialize(jvm, options, reserved);
 94 }
 95 JNIEXPORT jint JNI_OnLoad_getintrf007(JavaVM *jvm, char *options, void *reserved) {
 96     return JNI_VERSION_1_8;
 97 }
 98 #endif
 99 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
100     jint res;
101 
102     if (options != NULL && strcmp(options, "printdump") == 0) {

142         printf("(%d) wrong number of interfaces: %d, expected: %d\n",
143                i, icount, classes[i].icount);
144         result = STATUS_FAILED;
145     }
146 
147     for (j = 0; j < icount; j++) {
148         if (interfaces[j] == NULL) {
149             printf("(%d:%d) null reference\n", i, j);
150         } else {
151             err = jvmti->GetClassSignature(interfaces[j],
152                 &sig, &generic);
153             if (err != JVMTI_ERROR_NONE) {
154                 printf("(GetClassSignature#%d:%d) unexpected error: %s (%d)\n",
155                        i, j, TranslateError(err), err);
156             } else {
157                 if (printdump == JNI_TRUE) {
158                     printf(">>>   [%d]: %s\n", j, sig);
159                 }
160                 if ((j < classes[i].icount) && (sig == NULL ||
161                         strcmp(sig, classes[i].ifaces[j].sig) != 0)) {
162                     if (strcmp(sig, "Ljava/lang/IdentityObject;") != 0) {
163                         printf("(%d:%d) wrong interface: \"%s\"", i, j, sig);
164                         printf(", expected: \"%s\"\n", classes[i].ifaces[j].sig);
165                         result = STATUS_FAILED;
166                     }
167                 }
168             }
169         }
170     }
171 }
172 
173 JNIEXPORT int JNICALL Java_nsk_jvmti_GetImplementedInterfaces_getintrf007_getRes(JNIEnv *env, jclass cls) {
174     return result;
175 }
176 
177 }
< prev index next >