Skip to content

Commit

Permalink
8242891: vmTestbase/nsk/jvmti/ test should be fixed to fail early if …
Browse files Browse the repository at this point in the history
…JVMTI function return error

Reviewed-by: sspitsyn, cjplummer
  • Loading branch information
lmesnik committed Jul 14, 2020
1 parent f8f35d3 commit 590de67
Show file tree
Hide file tree
Showing 37 changed files with 164 additions and 38 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -118,6 +118,8 @@ ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) {
result = STATUS_FAILED;
NSK_COMPLAIN0("TEST FAILURE: unable to obtain a class signature\n");
unlock(jvmti_env, env);
return;
}

i = findSig(sig, 1);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -102,6 +102,7 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti_env, JNIEnv *env,
printf("(GetClassSignature#%" PRIuPTR ") unexpected error: %s (%d)\n",
eventsCount, TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassStatus(cls, &inf.status);
if (err != JVMTI_ERROR_NONE) {
Expand All @@ -114,19 +115,22 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti_env, JNIEnv *env,
printf("(GetClassMethods#%" PRIuPTR ") unexpected error: %s (%d)\n",
eventsCount, TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassFields(cls, &inf.fcount, &fields);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassMethods#%" PRIuPTR ") unexpected error: %s (%d)\n",
eventsCount, TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetImplementedInterfaces(cls,
&inf.icount, &interfaces);
if (err != JVMTI_ERROR_NONE) {
printf("(GetImplementedInterfaces#%" PRIuPTR ") unexpected error: %s (%d)\n",
eventsCount, TranslateError(err), err);
result = STATUS_FAILED;
return;
}

if (printdump == JNI_TRUE) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -57,9 +57,11 @@ void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) {
printf("(CreateRawMonitor#%d) unexpected error: %s (%d)\n",
i, TranslateError(err), err);
result = STATUS_FAILED;
return;
} else if (monitors[i] == NULL) {
printf("(CreateRawMonitor#%d) jrawMonitorID is null\n", i);
result = STATUS_FAILED;
return;
}
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -95,45 +95,52 @@ Exception(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr,
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodDeclaringClass(method, &cls);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodDeclaringClass#t) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(cls, &ex.t_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature#t) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodName(method,
&ex.t_name, &ex.t_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodName#t) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
ex.t_loc = location;
err = jvmti_env->GetMethodDeclaringClass(catch_method, &cls);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodDeclaringClass#c) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(cls, &ex.c_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature#c) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodName(catch_method,
&ex.c_name, &ex.c_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodName#c) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
ex.c_loc = catch_location;
if (printdump == JNI_TRUE) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -83,25 +83,29 @@ ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr,
printf("(GetClassSignature#e) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodDeclaringClass(method, &cls);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodDeclaringClass) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(cls, &ex.c_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature#c) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodName(method,
&ex.c_name, &ex.c_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
ex.c_loc = location;
if (printdump == JNI_TRUE) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -130,34 +130,39 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env,
printf("(GetMethodDeclaringClass) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(cls,
&watch.m_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodName(method,
&watch.m_name, &watch.m_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(field_klass,
&watch.f_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetFieldName(field_klass, field,
&watch.f_name, &watch.f_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetFieldName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
if (printdump == JNI_TRUE) {
printf(">>> class: \"%s\"\n", watch.m_cls);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -130,34 +130,39 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env,
printf("(GetMethodDeclaringClass) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(cls,
&watch.m_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodName(method,
&watch.m_name, &watch.m_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(field_klass,
&watch.f_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetFieldName(field_klass, field,
&watch.f_name, &watch.f_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetFieldName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
if (printdump == JNI_TRUE) {
printf(">>> class: \"%s\"\n", watch.m_cls);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -109,34 +109,39 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env,
printf("(GetMethodDeclaringClass) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(cls,
&watch.m_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodName(method,
&watch.m_name, &watch.m_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(field_klass,
&watch.f_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetFieldName(field_klass, field,
&watch.f_name, &watch.f_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetFieldName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
if (printdump == JNI_TRUE) {
printf(">>> class: \"%s\"\n", watch.m_cls);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
Expand Down Expand Up @@ -95,34 +95,39 @@ void JNICALL FieldAccess(jvmtiEnv *jvmti_env, JNIEnv *env,
printf("(GetMethodDeclaringClass) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(cls,
&watch.m_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetMethodName(method,
&watch.m_name, &watch.m_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetMethodName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetClassSignature(field_klass,
&watch.f_cls, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetClassSignature) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
err = jvmti_env->GetFieldName(field_klass, field,
&watch.f_name, &watch.f_sig, &generic);
if (err != JVMTI_ERROR_NONE) {
printf("(GetFieldName) unexpected error: %s (%d)\n",
TranslateError(err), err);
result = STATUS_FAILED;
return;
}
if (printdump == JNI_TRUE) {
printf(">>> class: \"%s\"\n", watch.m_cls);
Expand Down

0 comments on commit 590de67

Please sign in to comment.