OSDN Git Service

Be able to run jvmti-stress on RI
authorAlex Light <allight@google.com>
Thu, 20 Apr 2017 22:54:25 +0000 (15:54 -0700)
committerAlex Light <allight@google.com>
Thu, 20 Apr 2017 23:09:42 +0000 (16:09 -0700)
This is useful for testing.

When running on RI no class redefinition is performed.

Test: ./test/run-test --dev --jvm --jvmti-stress 001-HelloWorld
Test: ./test/run-test --dev --jvm --jvmti-stress 902
Test: ./test/run-test --dev --jvm --jvmti-stress 986

Change-Id: If234ff553bf136312c5128d03b02b28f4ff94e3d

test/etc/run-test-jar
test/ti-stress/stress.cc

index 56cfd24..f8b008b 100755 (executable)
@@ -372,16 +372,18 @@ if [ "$IS_JVMTI_TEST" = "y" ]; then
 fi
 
 if [[ "$JVMTI_STRESS" = "y" ]]; then
-  if [[ "$USE_JVM" = "n" ]]; then
-    plugin=libopenjdkjvmtid.so
-    agent=libtistressd.so
-    if  [[ "$TEST_IS_NDEBUG" = "y" ]]; then
-      agent=libtistress.so
-      plugin=libopenjdkjvmti.so
-    fi
+  plugin=libopenjdkjvmtid.so
+  agent=libtistressd.so
+  if  [[ "$TEST_IS_NDEBUG" = "y" ]]; then
+    agent=libtistress.so
+    plugin=libopenjdkjvmti.so
+  fi
 
-    file_1=$(mktemp --tmpdir=${DEX_LOCATION})
-    file_2=$(mktemp --tmpdir=${DEX_LOCATION})
+  file_1=$(mktemp --tmpdir=${DEX_LOCATION})
+  file_2=$(mktemp --tmpdir=${DEX_LOCATION})
+  if [[ "$USE_JVM" = "y" ]]; then
+    FLAGS="${FLAGS} -agentpath:${ANDROID_HOST_OUT}/nativetest64/${agent}=/bin/false,${file_1},${file_2}"
+  else
     # TODO Remove need for DEXTER_BINARY!
     FLAGS="${FLAGS} -agentpath:${agent}=${DEXTER_BINARY},${file_1},${file_2}"
     if [ "$IS_JVMTI_TEST" = "n" ]; then
index e7d76dd..e8e3cc7 100644 (file)
@@ -95,8 +95,8 @@ static void doJvmtiMethodBind(jvmtiEnv* jvmtienv,
   if (thread == nullptr) {
     info.name = const_cast<char*>("<NULLPTR>");
   } else if (jvmtienv->GetThreadInfo(thread, &info) != JVMTI_ERROR_NONE) {
-    LOG(ERROR) << "Unable to get thread info!";
-    return;
+    LOG(WARNING) << "Unable to get thread info!";
+    info.name = const_cast<char*>("<UNKNOWN THREAD>");
   }
   char *fname, *fsig, *fgen;
   char *cname, *cgen;
@@ -185,7 +185,10 @@ static void JNICALL EnsureVMClassloaderInitializedCB(jvmtiEnv *jvmti_env,
   LOG(INFO) << "manual load & initialization of class java/lang/VMClassLoader!";
   jclass klass = jni_env->FindClass("java/lang/VMClassLoader");
   if (klass == nullptr) {
-    LOG(ERROR) << "Unable to find VMClassLoader class!";
+    // Probably on RI. Clear the exception so we can continue but don't mark vmclassloader as
+    // initialized.
+    LOG(WARNING) << "Unable to find VMClassLoader class!";
+    jni_env->ExceptionClear();
   } else {
     // GetMethodID is spec'd to cause the class to be initialized.
     jni_env->GetMethodID(klass, "hashCode", "()I");