diff options
Diffstat (limited to 'test')
18 files changed, 0 insertions, 783 deletions
diff --git a/test/1963-add-to-dex-classloader-in-memory/add_to_loader.cc b/test/1963-add-to-dex-classloader-in-memory/add_to_loader.cc deleted file mode 100644 index 1c3f36d8ca..0000000000 --- a/test/1963-add-to-dex-classloader-in-memory/add_to_loader.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <atomic> - -#include "jvmti.h" - -// Test infrastructure -#include "jvmti_helper.h" -#include "scoped_local_ref.h" -#include "test_env.h" - -namespace art { -namespace Test1963AddToDexClassLoaderInMemory { - -using AddToDexClassLoaderInMemory = jvmtiError (*)(jvmtiEnv* env, - jobject loader, - const unsigned char* dex_file, - jint dex_file_length); - -template <typename T> static void Dealloc(T* t) { - jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(t)); -} - -template <typename T, typename... Rest> static void Dealloc(T* t, Rest... rs) { - Dealloc(t); - Dealloc(rs...); -} -static void DeallocParams(jvmtiParamInfo* params, jint n_params) { - for (jint i = 0; i < n_params; i++) { - Dealloc(params[i].name); - } -} - -AddToDexClassLoaderInMemory GetAddFunction(JNIEnv* env) { - // Get the extensions. - jint n_ext = 0; - jvmtiExtensionFunctionInfo* infos = nullptr; - if (JvmtiErrorToException(env, jvmti_env, jvmti_env->GetExtensionFunctions(&n_ext, &infos))) { - return nullptr; - } - AddToDexClassLoaderInMemory result = nullptr; - for (jint i = 0; i < n_ext; i++) { - jvmtiExtensionFunctionInfo* cur_info = &infos[i]; - if (strcmp("com.android.art.classloader.add_to_dex_class_loader_in_memory", cur_info->id) == - 0) { - result = reinterpret_cast<AddToDexClassLoaderInMemory>(cur_info->func); - } - // Cleanup the cur_info - DeallocParams(cur_info->params, cur_info->param_count); - Dealloc(cur_info->id, cur_info->short_description, cur_info->params, cur_info->errors); - } - // Cleanup the array. - Dealloc(infos); - return result; -} - -extern "C" JNIEXPORT void JNICALL Java_art_Test1963_addToClassLoaderNative(JNIEnv* env, - jclass, - jobject loader, - jobject bytebuffer) { - AddToDexClassLoaderInMemory add_func = GetAddFunction(env); - if (add_func == nullptr) { - env->ThrowNew(env->FindClass("java/lang/RuntimeError"), "Failed to find extension function"); - return; - } - JvmtiErrorToException( - env, - jvmti_env, - add_func(jvmti_env, - loader, - reinterpret_cast<unsigned char*>(env->GetDirectBufferAddress(bytebuffer)), - env->GetDirectBufferCapacity(bytebuffer))); -} - -} // namespace Test1963AddToDexClassLoaderInMemory -} // namespace art diff --git a/test/1963-add-to-dex-classloader-in-memory/expected.txt b/test/1963-add-to-dex-classloader-in-memory/expected.txt deleted file mode 100644 index c3cc448178..0000000000 --- a/test/1963-add-to-dex-classloader-in-memory/expected.txt +++ /dev/null @@ -1,19 +0,0 @@ - - Run while adding new referenced class. - -- Running sayHi before redefinition -Hello from TestClass sayHi function -Goodbye from TestClass! - -- Adding NewClass to classloader! - -- Redefine the TestClass - -- call TestClass again, now with NewClass refs -Hello again from TestClass sayHi function -Hello from NewClass sayHi function -Goodbye again from TestClass! - - Run without adding new referenced class. - -- Running sayHi before redefinition -Hello from TestClass sayHi function -Goodbye from TestClass! - -- Redefine the TestClass - -- call TestClass again, now with NewClass refs -Hello again from TestClass sayHi function - -- Exception caught when running test without new class added! java.lang.NoClassDefFoundError - --- java.lang.NoClassDefFoundError At foobar.TestClass.sayHi(TestClass.java:5) diff --git a/test/1963-add-to-dex-classloader-in-memory/info.txt b/test/1963-add-to-dex-classloader-in-memory/info.txt deleted file mode 100644 index 48df9821d6..0000000000 --- a/test/1963-add-to-dex-classloader-in-memory/info.txt +++ /dev/null @@ -1 +0,0 @@ -Tests we can add dex-file buffers to an existing classloader and the old classes can see them.
\ No newline at end of file diff --git a/test/1963-add-to-dex-classloader-in-memory/run b/test/1963-add-to-dex-classloader-in-memory/run deleted file mode 100755 index c6e62ae6cd..0000000000 --- a/test/1963-add-to-dex-classloader-in-memory/run +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -./default-run "$@" --jvmti diff --git a/test/1963-add-to-dex-classloader-in-memory/src/Main.java b/test/1963-add-to-dex-classloader-in-memory/src/Main.java deleted file mode 100644 index 3728b45be6..0000000000 --- a/test/1963-add-to-dex-classloader-in-memory/src/Main.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -public class Main { - public static void main(String[] args) throws Exception { - art.Test1963.run(); - } -} diff --git a/test/1963-add-to-dex-classloader-in-memory/src/art/Redefinition.java b/test/1963-add-to-dex-classloader-in-memory/src/art/Redefinition.java deleted file mode 120000 index 81eaf31bbb..0000000000 --- a/test/1963-add-to-dex-classloader-in-memory/src/art/Redefinition.java +++ /dev/null @@ -1 +0,0 @@ -../../../jvmti-common/Redefinition.java
\ No newline at end of file diff --git a/test/1963-add-to-dex-classloader-in-memory/src/art/Test1963.java b/test/1963-add-to-dex-classloader-in-memory/src/art/Test1963.java deleted file mode 100644 index a42b3ff691..0000000000 --- a/test/1963-add-to-dex-classloader-in-memory/src/art/Test1963.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package art; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; - -public final class Test1963 { - private static boolean IS_ART = System.getProperty("java.vm.name").equals("Dalvik"); - - private static String TEST_CLASS_NAME = "foobar.TestClass"; - private static String NEW_CLASS_NAME = "foobar.NewClass"; - - /** - * base64 encoded class/dex file for - * package foobar; - * public class NewClass { - * static void sayHi() { - * System.out.println("Hello from NewClass sayHi function"); - * TestClass.sayBye(); - * } - * } - */ - private static byte[] NEW_CLASS_BYTES = Base64.getDecoder().decode( - "yv66vgAAADUAIQoABwAPCQAQABEIABIKABMAFAoAFQAWBwAXBwAYAQAGPGluaXQ+AQADKClWAQAE" - + "Q29kZQEAD0xpbmVOdW1iZXJUYWJsZQEABXNheUhpAQAKU291cmNlRmlsZQEADU5ld0NsYXNzLmph" - + "dmEMAAgACQcAGQwAGgAbAQAiSGVsbG8gZnJvbSBOZXdDbGFzcyBzYXlIaSBmdW5jdGlvbgcAHAwA" - + "HQAeBwAfDAAgAAkBAA9mb29iYXIvTmV3Q2xhc3MBABBqYXZhL2xhbmcvT2JqZWN0AQAQamF2YS9s" - + "YW5nL1N5c3RlbQEAA291dAEAFUxqYXZhL2lvL1ByaW50U3RyZWFtOwEAE2phdmEvaW8vUHJpbnRT" - + "dHJlYW0BAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWAQAQZm9vYmFyL1Rlc3RDbGFz" - + "cwEABnNheUJ5ZQAhAAYABwAAAAAAAgABAAgACQABAAoAAAAdAAEAAQAAAAUqtwABsQAAAAEACwAA" - + "AAYAAQAAAAIACAAMAAkAAQAKAAAALAACAAAAAAAMsgACEgO2AAS4AAWxAAAAAQALAAAADgADAAAA" - + "BAAIAAUACwAGAAEADQAAAAIADg=="); - private static byte[] NEW_DEX_BYTES = Base64.getDecoder().decode( - "ZGV4CjAzNQA8kzH5IALCWT88v716WlU7OfqukCT2o6WQAwAAcAAAAHhWNBIAAAAAAAAAAOQCAAAQ" - + "AAAAcAAAAAcAAACwAAAAAgAAAMwAAAABAAAA5AAAAAUAAADsAAAAAQAAABQBAABcAgAANAEAAIIB" - + "AACKAQAArgEAAMEBAADVAQAA7AEAAAACAAAUAgAAKAIAADcCAAA6AgAAPgIAAEMCAABMAgAAVAIA" - + "AFsCAAACAAAAAwAAAAQAAAAFAAAABgAAAAcAAAAJAAAACQAAAAYAAAAAAAAACgAAAAYAAAB8AQAA" - + "BQACAAsAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAA0AAAACAAEADAAAAAMAAAAAAAAAAAAAAAEAAAAD" - + "AAAAAAAAAAgAAAAAAAAA0gIAAAAAAAABAAEAAQAAAHIBAAAEAAAAcBAEAAAADgACAAAAAgAAAHYB" - + "AAALAAAAYgAAABoBAQBuIAMAEABxAAIAAAAOAAIADgAEAA54PAABAAAABAAGPGluaXQ+ACJIZWxs" - + "byBmcm9tIE5ld0NsYXNzIHNheUhpIGZ1bmN0aW9uABFMZm9vYmFyL05ld0NsYXNzOwASTGZvb2Jh" - + "ci9UZXN0Q2xhc3M7ABVMamF2YS9pby9QcmludFN0cmVhbTsAEkxqYXZhL2xhbmcvT2JqZWN0OwAS" - + "TGphdmEvbGFuZy9TdHJpbmc7ABJMamF2YS9sYW5nL1N5c3RlbTsADU5ld0NsYXNzLmphdmEAAVYA" - + "AlZMAANvdXQAB3ByaW50bG4ABnNheUJ5ZQAFc2F5SGkAdX5+RDh7ImNvbXBpbGF0aW9uLW1vZGUi" - + "OiJkZWJ1ZyIsIm1pbi1hcGkiOjEsInNoYS0xIjoiZDMyODJiOGY1NDdjMjM0YzRlNGM5MzA5YzM2" - + "Yzc5NWEyOTg1NmVhYiIsInZlcnNpb24iOiIxLjYuMS1kZXYifQAAAAIAAIGABLQCAQjMAgAAAAAO" - + "AAAAAAAAAAEAAAAAAAAAAQAAABAAAABwAAAAAgAAAAcAAACwAAAAAwAAAAIAAADMAAAABAAAAAEA" - + "AADkAAAABQAAAAUAAADsAAAABgAAAAEAAAAUAQAAASAAAAIAAAA0AQAAAyAAAAIAAAByAQAAARAA" - + "AAEAAAB8AQAAAiAAABAAAACCAQAAACAAAAEAAADSAgAAAxAAAAEAAADgAgAAABAAAAEAAADkAgAA"); - /** - * base64 encoded class/dex file for - * package foobar; - * public class TestClass { - * public static void sayHi() { - * System.out.println("Hello again from TestClass sayHi function"); - * TestClass.sayBye(); - * } - * static void sayBye() { - * System.out.println("Goodbye from TestClass!"); - * } - * } - */ - private static byte[] CLASS_BYTES = Base64.getDecoder().decode( - "yv66vgAAADUAIQoACAARCQASABMIABQKABUAFgoABwAXCAAYBwAZBwAaAQAGPGluaXQ+AQADKClW" - + "AQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEABXNheUhpAQAGc2F5QnllAQAKU291cmNlRmlsZQEA" - + "DlRlc3RDbGFzcy5qYXZhDAAJAAoHABsMABwAHQEAI0hlbGxvIGZyb20gVGVzdENsYXNzIHNheUhp" - + "IGZ1bmN0aW9uBwAeDAAfACAMAA4ACgEAF0dvb2RieWUgZnJvbSBUZXN0Q2xhc3MhAQAQZm9vYmFy" - + "L1Rlc3RDbGFzcwEAEGphdmEvbGFuZy9PYmplY3QBABBqYXZhL2xhbmcvU3lzdGVtAQADb3V0AQAV" - + "TGphdmEvaW8vUHJpbnRTdHJlYW07AQATamF2YS9pby9QcmludFN0cmVhbQEAB3ByaW50bG4BABUo" - + "TGphdmEvbGFuZy9TdHJpbmc7KVYAIQAHAAgAAAAAAAMAAQAJAAoAAQALAAAAHQABAAEAAAAFKrcA" - + "AbEAAAABAAwAAAAGAAEAAAACAAkADQAKAAEACwAAACwAAgAAAAAADLIAAhIDtgAEuAAFsQAAAAEA" - + "DAAAAA4AAwAAAAQACAAFAAsABgAIAA4ACgABAAsAAAAlAAIAAAAAAAmyAAISBrYABLEAAAABAAwA" - + "AAAKAAIAAAAIAAgACQABAA8AAAACABA="); - - private static byte[] DEX_BYTES = Base64.getDecoder().decode( - "ZGV4CjAzNQARmtFTPdWXebnrTNy5b71tEiJKC96qIPXAAwAAcAAAAHhWNBIAAAAAAAAAABQDAAAQ" - + "AAAAcAAAAAYAAACwAAAAAgAAAMgAAAABAAAA4AAAAAUAAADoAAAAAQAAABABAACQAgAAMAEAAKYB" - + "AACuAQAAxwEAAOwBAAAAAgAAFwIAACsCAAA/AgAAUwIAAGMCAABmAgAAagIAAG8CAAB4AgAAgAIA" - + "AIcCAAADAAAABAAAAAUAAAAGAAAABwAAAAkAAAAJAAAABQAAAAAAAAAKAAAABQAAAKABAAAEAAEA" - + "CwAAAAAAAAAAAAAAAAAAAA0AAAAAAAAADgAAAAEAAQAMAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAA" - + "AAAACAAAAAAAAAD+AgAAAAAAAAEAAQABAAAAjgEAAAQAAABwEAQAAAAOAAIAAAACAAAAkgEAAAgA" - + "AABiAAAAGgEBAG4gAwAQAA4AAgAAAAIAAACXAQAACwAAAGIAAAAaAQIAbiADABAAcQABAAAADgAC" - + "AA4ACAAOeAAEAA54PAAAAAABAAAAAwAGPGluaXQ+ABdHb29kYnllIGZyb20gVGVzdENsYXNzIQAj" - + "SGVsbG8gZnJvbSBUZXN0Q2xhc3Mgc2F5SGkgZnVuY3Rpb24AEkxmb29iYXIvVGVzdENsYXNzOwAV" - + "TGphdmEvaW8vUHJpbnRTdHJlYW07ABJMamF2YS9sYW5nL09iamVjdDsAEkxqYXZhL2xhbmcvU3Ry" - + "aW5nOwASTGphdmEvbGFuZy9TeXN0ZW07AA5UZXN0Q2xhc3MuamF2YQABVgACVkwAA291dAAHcHJp" - + "bnRsbgAGc2F5QnllAAVzYXlIaQB1fn5EOHsiY29tcGlsYXRpb24tbW9kZSI6ImRlYnVnIiwibWlu" - + "LWFwaSI6MSwic2hhLTEiOiJkMzI4MmI4ZjU0N2MyMzRjNGU0YzkzMDljMzZjNzk1YTI5ODU2ZWFi" - + "IiwidmVyc2lvbiI6IjEuNi4xLWRldiJ9AAAAAwAAgYAEsAIBCMgCAQnoAgAAAAAOAAAAAAAAAAEA" - + "AAAAAAAAAQAAABAAAABwAAAAAgAAAAYAAACwAAAAAwAAAAIAAADIAAAABAAAAAEAAADgAAAABQAA" - + "AAUAAADoAAAABgAAAAEAAAAQAQAAASAAAAMAAAAwAQAAAyAAAAMAAACOAQAAARAAAAEAAACgAQAA" - + "AiAAABAAAACmAQAAACAAAAEAAAD+AgAAAxAAAAEAAAAQAwAAABAAAAEAAAAUAwAA"); - /** - * base64 encoded class/dex file for - * package foobar; - * public class TestClass { - * public static void sayHi() { - * System.out.println("Hello again from TestClass sayHi function"); - * NewClass.sayHi(); - * } - * static void sayBye() { - * System.out.println("Goodbye again from TestClass!"); - * } - * } - */ - private static byte[] REDEF_CLASS_BYTES = Base64.getDecoder().decode( - "yv66vgAAADUAIwoACAARCQASABMIABQKABUAFgoAFwAYCAAZBwAaBwAbAQAGPGluaXQ+AQADKClW" - + "AQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEABXNheUhpAQAGc2F5QnllAQAKU291cmNlRmlsZQEA" - + "DlRlc3RDbGFzcy5qYXZhDAAJAAoHABwMAB0AHgEAKUhlbGxvIGFnYWluIGZyb20gVGVzdENsYXNz" - + "IHNheUhpIGZ1bmN0aW9uBwAfDAAgACEHACIMAA0ACgEAHUdvb2RieWUgYWdhaW4gZnJvbSBUZXN0" - + "Q2xhc3MhAQAQZm9vYmFyL1Rlc3RDbGFzcwEAEGphdmEvbGFuZy9PYmplY3QBABBqYXZhL2xhbmcv" - + "U3lzdGVtAQADb3V0AQAVTGphdmEvaW8vUHJpbnRTdHJlYW07AQATamF2YS9pby9QcmludFN0cmVh" - + "bQEAB3ByaW50bG4BABUoTGphdmEvbGFuZy9TdHJpbmc7KVYBAA9mb29iYXIvTmV3Q2xhc3MAIQAH" - + "AAgAAAAAAAMAAQAJAAoAAQALAAAAHQABAAEAAAAFKrcAAbEAAAABAAwAAAAGAAEAAAACAAkADQAK" - + "AAEACwAAACwAAgAAAAAADLIAAhIDtgAEuAAFsQAAAAEADAAAAA4AAwAAAAQACAAFAAsABgAIAA4A" - + "CgABAAsAAAAlAAIAAAAAAAmyAAISBrYABLEAAAABAAwAAAAKAAIAAAAIAAgACQABAA8AAAACABA="); - - private static byte[] REDEF_DEX_BYTES = Base64.getDecoder().decode( - "ZGV4CjAzNQA2plEeYRH4vl6wJgnAZOVcZ537QN9NXB3wAwAAcAAAAHhWNBIAAAAAAAAAAEQDAAAR" - + "AAAAcAAAAAcAAAC0AAAAAgAAANAAAAABAAAA6AAAAAYAAADwAAAAAQAAACABAACwAgAAQAEAALYB" - + "AAC+AQAA3QEAAAgCAAAbAgAALwIAAEYCAABaAgAAbgIAAIICAACSAgAAlQIAAJkCAACeAgAApwIA" - + "AK8CAAC2AgAAAwAAAAQAAAAFAAAABgAAAAcAAAAIAAAACgAAAAoAAAAGAAAAAAAAAAsAAAAGAAAA" - + "sAEAAAUAAgAMAAAAAAAAAA8AAAABAAAAAAAAAAEAAAAOAAAAAQAAAA8AAAACAAEADQAAAAMAAAAA" - + "AAAAAQAAAAEAAAADAAAAAAAAAAkAAAAAAAAALQMAAAAAAAABAAEAAQAAAJ4BAAAEAAAAcBAFAAAA" - + "DgACAAAAAgAAAKIBAAAIAAAAYgAAABoBAQBuIAQAEAAOAAIAAAACAAAApwEAAAsAAABiAAAAGgEC" - + "AG4gBAAQAHEAAAAAAA4AAgAOAAgADngABAAOeDwAAAAAAQAAAAQABjxpbml0PgAdR29vZGJ5ZSBh" - + "Z2FpbiBmcm9tIFRlc3RDbGFzcyEAKUhlbGxvIGFnYWluIGZyb20gVGVzdENsYXNzIHNheUhpIGZ1" - + "bmN0aW9uABFMZm9vYmFyL05ld0NsYXNzOwASTGZvb2Jhci9UZXN0Q2xhc3M7ABVMamF2YS9pby9Q" - + "cmludFN0cmVhbTsAEkxqYXZhL2xhbmcvT2JqZWN0OwASTGphdmEvbGFuZy9TdHJpbmc7ABJMamF2" - + "YS9sYW5nL1N5c3RlbTsADlRlc3RDbGFzcy5qYXZhAAFWAAJWTAADb3V0AAdwcmludGxuAAZzYXlC" - + "eWUABXNheUhpAHV+fkQ4eyJjb21waWxhdGlvbi1tb2RlIjoiZGVidWciLCJtaW4tYXBpIjoxLCJz" - + "aGEtMSI6ImQzMjgyYjhmNTQ3YzIzNGM0ZTRjOTMwOWMzNmM3OTVhMjk4NTZlYWIiLCJ2ZXJzaW9u" - + "IjoiMS42LjEtZGV2In0AAAADAAGBgATAAgEI2AIBCfgCAAAAAAAOAAAAAAAAAAEAAAAAAAAAAQAA" - + "ABEAAABwAAAAAgAAAAcAAAC0AAAAAwAAAAIAAADQAAAABAAAAAEAAADoAAAABQAAAAYAAADwAAAA" - + "BgAAAAEAAAAgAQAAASAAAAMAAABAAQAAAyAAAAMAAACeAQAAARAAAAEAAACwAQAAAiAAABEAAAC2" - + "AQAAACAAAAEAAAAtAwAAAxAAAAEAAABAAwAAABAAAAEAAABEAwAA"); - - public static void SafePrintCause(Throwable t) { - StackTraceElement cause = t.getStackTrace()[0]; - System.out.println(" --- " + t.getClass().getName() + " At " + cause.getClassName() + "." + - cause.getMethodName() + "(" + cause.getFileName() + ":" + - cause.getLineNumber() + ")"); - } - - public static void run() throws Exception { - System.out.println(" - Run while adding new referenced class."); - try { - run(true); - } catch (Exception e) { - // Unfortunately art and RI have different messages here so just return the type. - System.out.println(" -- Exception caught when running test with new class added! " + - e.getCause().getClass().getName()); - SafePrintCause(e.getCause()); - } - System.out.println(" - Run without adding new referenced class."); - try { - run(false); - } catch (Exception e) { - // Unfortunately art and RI have different messages here so just return the type. - System.out.println(" -- Exception caught when running test without new class added! " + - e.getCause().getClass().getName()); - SafePrintCause(e.getCause()); - } - } - - public static void run(boolean add_new) throws Exception { - ClassLoader cl = getClassLoader(); - Class<?> target = cl.loadClass(TEST_CLASS_NAME); - Method sayHi = target.getDeclaredMethod("sayHi"); - System.out.println(" -- Running sayHi before redefinition"); - sayHi.invoke(null); - if (add_new) { - System.out.println(" -- Adding NewClass to classloader!"); - addToClassLoader(cl, NEW_CLASS_BYTES, NEW_DEX_BYTES); - } - System.out.println(" -- Redefine the TestClass"); - Redefinition.doCommonClassRedefinition(target, REDEF_CLASS_BYTES, REDEF_DEX_BYTES); - System.out.println(" -- call TestClass again, now with NewClass refs"); - sayHi.invoke(null); - } - - public static class ExtensibleClassLoader extends ClassLoader { - private byte[] new_class = null; - public ExtensibleClassLoader() { - super(ExtensibleClassLoader.class.getClassLoader()); - } - - public void addSingleClass(byte[] bb) { - new_class = bb; - } - - protected Class<?> findClass(String name) throws ClassNotFoundException { - if (name.equals(TEST_CLASS_NAME)) { - return this.defineClass(TEST_CLASS_NAME, CLASS_BYTES, 0, CLASS_BYTES.length); - } - if (name.equals(NEW_CLASS_NAME) && new_class != null) { - return this.defineClass(name, new_class, 0, new_class.length); - } else { - return super.findClass(name); - } - } - } - - public static ClassLoader getClassLoader() throws Exception { - if (!IS_ART) { - return new ExtensibleClassLoader(); - } else { - Class<?> class_loader_class = Class.forName("dalvik.system.InMemoryDexClassLoader"); - Constructor<?> ctor = class_loader_class.getConstructor(ByteBuffer.class, ClassLoader.class); - return (ClassLoader)ctor.newInstance(ByteBuffer.wrap(DEX_BYTES), - Test1963.class.getClassLoader()); - } - } - - public static void addToClassLoader(ClassLoader cl, byte[] class_bytes, byte[] dex_bytes) { - if (IS_ART) { - addToClassLoaderNative(cl, ByteBuffer.allocateDirect(dex_bytes.length).put(dex_bytes)); - } else { - ((ExtensibleClassLoader)cl).addSingleClass(class_bytes); - } - } - - public static native void addToClassLoaderNative(ClassLoader loader, ByteBuffer buff); -} diff --git a/test/1964-add-to-dex-classloader-file/add_to_loader.cc b/test/1964-add-to-dex-classloader-file/add_to_loader.cc deleted file mode 100644 index 9fbea97124..0000000000 --- a/test/1964-add-to-dex-classloader-file/add_to_loader.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <atomic> - -#include "jvmti.h" - -// Test infrastructure -#include "jvmti_helper.h" -#include "scoped_local_ref.h" -#include "test_env.h" - -namespace art { -namespace Test1964AddToDexClassLoader { - -using AddToDexClassLoader = jvmtiError (*)(jvmtiEnv* env, - jobject loader, - const char* segment); - -template <typename T> static void Dealloc(T* t) { - jvmti_env->Deallocate(reinterpret_cast<unsigned char*>(t)); -} - -template <typename T, typename... Rest> static void Dealloc(T* t, Rest... rs) { - Dealloc(t); - Dealloc(rs...); -} -static void DeallocParams(jvmtiParamInfo* params, jint n_params) { - for (jint i = 0; i < n_params; i++) { - Dealloc(params[i].name); - } -} - -AddToDexClassLoader GetAddFunction(JNIEnv* env) { - // Get the extensions. - jint n_ext = 0; - jvmtiExtensionFunctionInfo* infos = nullptr; - if (JvmtiErrorToException(env, jvmti_env, jvmti_env->GetExtensionFunctions(&n_ext, &infos))) { - return nullptr; - } - AddToDexClassLoader result = nullptr; - for (jint i = 0; i < n_ext; i++) { - jvmtiExtensionFunctionInfo* cur_info = &infos[i]; - if (strcmp("com.android.art.classloader.add_to_dex_class_loader", cur_info->id) == - 0) { - result = reinterpret_cast<AddToDexClassLoader>(cur_info->func); - } - // Cleanup the cur_info - DeallocParams(cur_info->params, cur_info->param_count); - Dealloc(cur_info->id, cur_info->short_description, cur_info->params, cur_info->errors); - } - // Cleanup the array. - Dealloc(infos); - return result; -} - -extern "C" JNIEXPORT void JNICALL Java_Main_addToClassLoaderNative(JNIEnv* env, - jclass, - jobject loader, - jstring segment) { - AddToDexClassLoader add_func = GetAddFunction(env); - if (add_func == nullptr) { - env->ThrowNew(env->FindClass("java/lang/RuntimeError"), "Failed to find extension function"); - return; - } - const char* chars = env->GetStringUTFChars(segment, nullptr); - JvmtiErrorToException( - env, - jvmti_env, - add_func(jvmti_env, - loader, - chars)); - env->ReleaseStringUTFChars(segment, chars); -} - -} // namespace Test1964AddToDexClassLoader -} // namespace art diff --git a/test/1964-add-to-dex-classloader-file/expected.txt b/test/1964-add-to-dex-classloader-file/expected.txt deleted file mode 100644 index 58b86ef896..0000000000 --- a/test/1964-add-to-dex-classloader-file/expected.txt +++ /dev/null @@ -1,23 +0,0 @@ - - Run while adding new referenced class. - -- Running sayHi before redefinition -Hello from TestClass sayHi function -Goodbye from TestClass! - -- Adding NewClass to classloader! - -- Redefine the TestClass - -- call TestClass again, now with NewClass refs -Hello again from TestClass sayHi function -Hello from NewClass sayHi function -Nearby stack: - private static native art.StackTrace$StackFrameData[] art.StackTrace.nativeGetStackTrace(java.lang.Thread)(line: -1) - public static art.StackTrace$StackFrameData[] art.StackTrace.GetStackTrace(java.lang.Thread)(line: 61) - static void foobar.NewClass.sayHi() throws java.lang.Exception(line: 27) - public static void foobar.TestClass.sayHi()(line: 5) - - Run without adding new referenced class. - -- Running sayHi before redefinition -Hello from TestClass sayHi function -Goodbye from TestClass! - -- Redefine the TestClass - -- call TestClass again, now with NewClass refs -Hello again from TestClass sayHi function - -- Exception caught when running test without new class added! java.lang.NoClassDefFoundError - --- java.lang.NoClassDefFoundError At foobar.TestClass.sayHi(TestClass.java:5) diff --git a/test/1964-add-to-dex-classloader-file/info.txt b/test/1964-add-to-dex-classloader-file/info.txt deleted file mode 100644 index 48df9821d6..0000000000 --- a/test/1964-add-to-dex-classloader-file/info.txt +++ /dev/null @@ -1 +0,0 @@ -Tests we can add dex-file buffers to an existing classloader and the old classes can see them.
\ No newline at end of file diff --git a/test/1964-add-to-dex-classloader-file/run b/test/1964-add-to-dex-classloader-file/run deleted file mode 100755 index c6e62ae6cd..0000000000 --- a/test/1964-add-to-dex-classloader-file/run +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Copyright 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -./default-run "$@" --jvmti diff --git a/test/1964-add-to-dex-classloader-file/src-ex/foobar/NewClass.java b/test/1964-add-to-dex-classloader-file/src-ex/foobar/NewClass.java deleted file mode 100644 index a27d5d3c58..0000000000 --- a/test/1964-add-to-dex-classloader-file/src-ex/foobar/NewClass.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package foobar; -import art.Breakpoint; -import art.StackTrace; - -public class NewClass { - static void sayHi() throws Exception { - System.out.println("Hello from NewClass sayHi function"); - // Doing this would be nice but it would make compiling the test more tricky. Just use - // reflection and check the classloader is the same. - // TestClass.sayBye(); - StackTrace.StackFrameData[] stack = StackTrace.GetStackTrace(Thread.currentThread()); - StackTrace.StackFrameData caller = null; - System.out.println("Nearby stack:"); - for (StackTrace.StackFrameData sfd : stack) { - String caller_name = sfd.method.getDeclaringClass().getName(); - if (caller_name.startsWith("art.") || caller_name.startsWith("foobar.")) { - System.out.println("\t" + sfd.method + "(line: " + - Breakpoint.locationToLine(sfd.method, sfd.current_location) + ")"); - caller = sfd; - } else { - break; - } - } - if (NewClass.class.getClassLoader() != caller.method.getDeclaringClass().getClassLoader()) { - System.out.println("Different classloader for TestClass and my class."); - } - } -}
\ No newline at end of file diff --git a/test/1964-add-to-dex-classloader-file/src/Main.java b/test/1964-add-to-dex-classloader-file/src/Main.java deleted file mode 100644 index 2293d42193..0000000000 --- a/test/1964-add-to-dex-classloader-file/src/Main.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2019 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import art.Redefinition; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; - -public class Main { - private static String TEST_NAME = "1964-add-to-dex-classloader-file"; - private static boolean IS_ART = System.getProperty("java.vm.name").equals("Dalvik"); - - private static String TEST_CLASS_NAME = "foobar.TestClass"; - private static String NEW_CLASS_NAME = "foobar.NewClass"; - - /** - * base64 encoded class/dex file for - * package foobar; - * public class TestClass { - * public static void sayHi() { - * System.out.println("Hello again from TestClass sayHi function"); - * TestClass.sayBye(); - * } - * static void sayBye() { - * System.out.println("Goodbye from TestClass!"); - * } - * } - */ - private static byte[] CLASS_BYTES = Base64.getDecoder().decode( - "yv66vgAAADUAIQoACAARCQASABMIABQKABUAFgoABwAXCAAYBwAZBwAaAQAGPGluaXQ+AQADKClW" - + "AQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEABXNheUhpAQAGc2F5QnllAQAKU291cmNlRmlsZQEA" - + "DlRlc3RDbGFzcy5qYXZhDAAJAAoHABsMABwAHQEAI0hlbGxvIGZyb20gVGVzdENsYXNzIHNheUhp" - + "IGZ1bmN0aW9uBwAeDAAfACAMAA4ACgEAF0dvb2RieWUgZnJvbSBUZXN0Q2xhc3MhAQAQZm9vYmFy" - + "L1Rlc3RDbGFzcwEAEGphdmEvbGFuZy9PYmplY3QBABBqYXZhL2xhbmcvU3lzdGVtAQADb3V0AQAV" - + "TGphdmEvaW8vUHJpbnRTdHJlYW07AQATamF2YS9pby9QcmludFN0cmVhbQEAB3ByaW50bG4BABUo" - + "TGphdmEvbGFuZy9TdHJpbmc7KVYAIQAHAAgAAAAAAAMAAQAJAAoAAQALAAAAHQABAAEAAAAFKrcA" - + "AbEAAAABAAwAAAAGAAEAAAACAAkADQAKAAEACwAAACwAAgAAAAAADLIAAhIDtgAEuAAFsQAAAAEA" - + "DAAAAA4AAwAAAAQACAAFAAsABgAIAA4ACgABAAsAAAAlAAIAAAAAAAmyAAISBrYABLEAAAABAAwA" - + "AAAKAAIAAAAIAAgACQABAA8AAAACABA="); - - private static byte[] DEX_BYTES = Base64.getDecoder().decode( - "ZGV4CjAzNQARmtFTPdWXebnrTNy5b71tEiJKC96qIPXAAwAAcAAAAHhWNBIAAAAAAAAAABQDAAAQ" - + "AAAAcAAAAAYAAACwAAAAAgAAAMgAAAABAAAA4AAAAAUAAADoAAAAAQAAABABAACQAgAAMAEAAKYB" - + "AACuAQAAxwEAAOwBAAAAAgAAFwIAACsCAAA/AgAAUwIAAGMCAABmAgAAagIAAG8CAAB4AgAAgAIA" - + "AIcCAAADAAAABAAAAAUAAAAGAAAABwAAAAkAAAAJAAAABQAAAAAAAAAKAAAABQAAAKABAAAEAAEA" - + "CwAAAAAAAAAAAAAAAAAAAA0AAAAAAAAADgAAAAEAAQAMAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAA" - + "AAAACAAAAAAAAAD+AgAAAAAAAAEAAQABAAAAjgEAAAQAAABwEAQAAAAOAAIAAAACAAAAkgEAAAgA" - + "AABiAAAAGgEBAG4gAwAQAA4AAgAAAAIAAACXAQAACwAAAGIAAAAaAQIAbiADABAAcQABAAAADgAC" - + "AA4ACAAOeAAEAA54PAAAAAABAAAAAwAGPGluaXQ+ABdHb29kYnllIGZyb20gVGVzdENsYXNzIQAj" - + "SGVsbG8gZnJvbSBUZXN0Q2xhc3Mgc2F5SGkgZnVuY3Rpb24AEkxmb29iYXIvVGVzdENsYXNzOwAV" - + "TGphdmEvaW8vUHJpbnRTdHJlYW07ABJMamF2YS9sYW5nL09iamVjdDsAEkxqYXZhL2xhbmcvU3Ry" - + "aW5nOwASTGphdmEvbGFuZy9TeXN0ZW07AA5UZXN0Q2xhc3MuamF2YQABVgACVkwAA291dAAHcHJp" - + "bnRsbgAGc2F5QnllAAVzYXlIaQB1fn5EOHsiY29tcGlsYXRpb24tbW9kZSI6ImRlYnVnIiwibWlu" - + "LWFwaSI6MSwic2hhLTEiOiJkMzI4MmI4ZjU0N2MyMzRjNGU0YzkzMDljMzZjNzk1YTI5ODU2ZWFi" - + "IiwidmVyc2lvbiI6IjEuNi4xLWRldiJ9AAAAAwAAgYAEsAIBCMgCAQnoAgAAAAAOAAAAAAAAAAEA" - + "AAAAAAAAAQAAABAAAABwAAAAAgAAAAYAAACwAAAAAwAAAAIAAADIAAAABAAAAAEAAADgAAAABQAA" - + "AAUAAADoAAAABgAAAAEAAAAQAQAAASAAAAMAAAAwAQAAAyAAAAMAAACOAQAAARAAAAEAAACgAQAA" - + "AiAAABAAAACmAQAAACAAAAEAAAD+AgAAAxAAAAEAAAAQAwAAABAAAAEAAAAUAwAA"); - /** - * base64 encoded class/dex file for - * package foobar; - * public class TestClass { - * public static void sayHi() { - * System.out.println("Hello again from TestClass sayHi function"); - * NewClass.sayHi(); - * } - * static void sayBye() { - * System.out.println("Goodbye again from TestClass!"); - * } - * } - */ - private static byte[] REDEF_CLASS_BYTES = Base64.getDecoder().decode( - "yv66vgAAADUAIwoACAARCQASABMIABQKABUAFgoAFwAYCAAZBwAaBwAbAQAGPGluaXQ+AQADKClW" - + "AQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEABXNheUhpAQAGc2F5QnllAQAKU291cmNlRmlsZQEA" - + "DlRlc3RDbGFzcy5qYXZhDAAJAAoHABwMAB0AHgEAKUhlbGxvIGFnYWluIGZyb20gVGVzdENsYXNz" - + "IHNheUhpIGZ1bmN0aW9uBwAfDAAgACEHACIMAA0ACgEAHUdvb2RieWUgYWdhaW4gZnJvbSBUZXN0" - + "Q2xhc3MhAQAQZm9vYmFyL1Rlc3RDbGFzcwEAEGphdmEvbGFuZy9PYmplY3QBABBqYXZhL2xhbmcv" - + "U3lzdGVtAQADb3V0AQAVTGphdmEvaW8vUHJpbnRTdHJlYW07AQATamF2YS9pby9QcmludFN0cmVh" - + "bQEAB3ByaW50bG4BABUoTGphdmEvbGFuZy9TdHJpbmc7KVYBAA9mb29iYXIvTmV3Q2xhc3MAIQAH" - + "AAgAAAAAAAMAAQAJAAoAAQALAAAAHQABAAEAAAAFKrcAAbEAAAABAAwAAAAGAAEAAAACAAkADQAK" - + "AAEACwAAACwAAgAAAAAADLIAAhIDtgAEuAAFsQAAAAEADAAAAA4AAwAAAAQACAAFAAsABgAIAA4A" - + "CgABAAsAAAAlAAIAAAAAAAmyAAISBrYABLEAAAABAAwAAAAKAAIAAAAIAAgACQABAA8AAAACABA="); - - private static byte[] REDEF_DEX_BYTES = Base64.getDecoder().decode( - "ZGV4CjAzNQA2plEeYRH4vl6wJgnAZOVcZ537QN9NXB3wAwAAcAAAAHhWNBIAAAAAAAAAAEQDAAAR" - + "AAAAcAAAAAcAAAC0AAAAAgAAANAAAAABAAAA6AAAAAYAAADwAAAAAQAAACABAACwAgAAQAEAALYB" - + "AAC+AQAA3QEAAAgCAAAbAgAALwIAAEYCAABaAgAAbgIAAIICAACSAgAAlQIAAJkCAACeAgAApwIA" - + "AK8CAAC2AgAAAwAAAAQAAAAFAAAABgAAAAcAAAAIAAAACgAAAAoAAAAGAAAAAAAAAAsAAAAGAAAA" - + "sAEAAAUAAgAMAAAAAAAAAA8AAAABAAAAAAAAAAEAAAAOAAAAAQAAAA8AAAACAAEADQAAAAMAAAAA" - + "AAAAAQAAAAEAAAADAAAAAAAAAAkAAAAAAAAALQMAAAAAAAABAAEAAQAAAJ4BAAAEAAAAcBAFAAAA" - + "DgACAAAAAgAAAKIBAAAIAAAAYgAAABoBAQBuIAQAEAAOAAIAAAACAAAApwEAAAsAAABiAAAAGgEC" - + "AG4gBAAQAHEAAAAAAA4AAgAOAAgADngABAAOeDwAAAAAAQAAAAQABjxpbml0PgAdR29vZGJ5ZSBh" - + "Z2FpbiBmcm9tIFRlc3RDbGFzcyEAKUhlbGxvIGFnYWluIGZyb20gVGVzdENsYXNzIHNheUhpIGZ1" - + "bmN0aW9uABFMZm9vYmFyL05ld0NsYXNzOwASTGZvb2Jhci9UZXN0Q2xhc3M7ABVMamF2YS9pby9Q" - + "cmludFN0cmVhbTsAEkxqYXZhL2xhbmcvT2JqZWN0OwASTGphdmEvbGFuZy9TdHJpbmc7ABJMamF2" - + "YS9sYW5nL1N5c3RlbTsADlRlc3RDbGFzcy5qYXZhAAFWAAJWTAADb3V0AAdwcmludGxuAAZzYXlC" - + "eWUABXNheUhpAHV+fkQ4eyJjb21waWxhdGlvbi1tb2RlIjoiZGVidWciLCJtaW4tYXBpIjoxLCJz" - + "aGEtMSI6ImQzMjgyYjhmNTQ3YzIzNGM0ZTRjOTMwOWMzNmM3OTVhMjk4NTZlYWIiLCJ2ZXJzaW9u" - + "IjoiMS42LjEtZGV2In0AAAADAAGBgATAAgEI2AIBCfgCAAAAAAAOAAAAAAAAAAEAAAAAAAAAAQAA" - + "ABEAAABwAAAAAgAAAAcAAAC0AAAAAwAAAAIAAADQAAAABAAAAAEAAADoAAAABQAAAAYAAADwAAAA" - + "BgAAAAEAAAAgAQAAASAAAAMAAABAAQAAAyAAAAMAAACeAQAAARAAAAEAAACwAQAAAiAAABEAAAC2" - + "AQAAACAAAAEAAAAtAwAAAxAAAAEAAABAAwAAABAAAAEAAABEAwAA"); - - public static void SafePrintCause(Throwable t) { - StackTraceElement cause = t.getStackTrace()[0]; - System.out.println(" --- " + t.getClass().getName() + " At " + cause.getClassName() + "." + - cause.getMethodName() + "(" + cause.getFileName() + ":" + - cause.getLineNumber() + ")"); - } - - public static void run() throws Exception { - System.out.println(" - Run while adding new referenced class."); - try { - run(true); - } catch (Exception e) { - // Unfortunately art and RI have different messages here so just return the type. - System.out.println(" -- Exception caught when running test with new class added! " + - e.getCause().getClass().getName()); - SafePrintCause(e.getCause()); - System.out.println(e); - e.printStackTrace(); - } - System.out.println(" - Run without adding new referenced class."); - try { - run(false); - } catch (Exception e) { - // Unfortunately art and RI have different messages here so just return the type. - System.out.println(" -- Exception caught when running test without new class added! " + - e.getCause().getClass().getName()); - SafePrintCause(e.getCause()); - } - } - - public static void run(boolean add_new) throws Exception { - ClassLoader cl = getClassLoader(); - Class<?> target = cl.loadClass(TEST_CLASS_NAME); - Method sayHi = target.getDeclaredMethod("sayHi"); - System.out.println(" -- Running sayHi before redefinition"); - sayHi.invoke(null); - if (add_new) { - System.out.println(" -- Adding NewClass to classloader!"); - addToClassLoader(cl); - } - System.out.println(" -- Redefine the TestClass"); - Redefinition.doCommonClassRedefinition(target, REDEF_CLASS_BYTES, REDEF_DEX_BYTES); - System.out.println(" -- call TestClass again, now with NewClass refs"); - sayHi.invoke(null); - } - - public static class ExtensibleClassLoader extends URLClassLoader { - public ExtensibleClassLoader() { - // Initially we don't have any URLs - super(new URL[] {}, ExtensibleClassLoader.class.getClassLoader()); - } - - public void addSingleUrl(String file) throws Exception { - this.addURL(new URL("file://" + file)); - } - - protected Class<?> findClass(String name) throws ClassNotFoundException { - // Just define the TestClass without other jars. - if (name.equals(TEST_CLASS_NAME)) { - return this.defineClass(TEST_CLASS_NAME, CLASS_BYTES, 0, CLASS_BYTES.length); - } else { - return super.findClass(name); - } - } - } - - public static ClassLoader getClassLoader() throws Exception { - if (!IS_ART) { - return new ExtensibleClassLoader(); - } else { - Class<?> class_loader_class = Class.forName("dalvik.system.InMemoryDexClassLoader"); - Constructor<?> ctor = class_loader_class.getConstructor(ByteBuffer.class, ClassLoader.class); - return (ClassLoader)ctor.newInstance(ByteBuffer.wrap(DEX_BYTES), Main.class.getClassLoader()); - } - } - - public static void addToClassLoader(ClassLoader cl) throws Exception { - if (IS_ART) { - addToClassLoaderNative(cl, System.getenv("DEX_LOCATION") + "/" + TEST_NAME + "-ex.jar"); - } else { - ((ExtensibleClassLoader)cl).addSingleUrl(System.getenv("DEX_LOCATION") + "/classes-ex/"); - } - } - - public static native void addToClassLoaderNative(ClassLoader loader, String segment); - public static void main(String[] args) throws Exception { - run(); - } -} diff --git a/test/1964-add-to-dex-classloader-file/src/art/Breakpoint.java b/test/1964-add-to-dex-classloader-file/src/art/Breakpoint.java deleted file mode 120000 index 3673916cc6..0000000000 --- a/test/1964-add-to-dex-classloader-file/src/art/Breakpoint.java +++ /dev/null @@ -1 +0,0 @@ -../../../jvmti-common/Breakpoint.java
\ No newline at end of file diff --git a/test/1964-add-to-dex-classloader-file/src/art/Redefinition.java b/test/1964-add-to-dex-classloader-file/src/art/Redefinition.java deleted file mode 120000 index 81eaf31bbb..0000000000 --- a/test/1964-add-to-dex-classloader-file/src/art/Redefinition.java +++ /dev/null @@ -1 +0,0 @@ -../../../jvmti-common/Redefinition.java
\ No newline at end of file diff --git a/test/1964-add-to-dex-classloader-file/src/art/StackTrace.java b/test/1964-add-to-dex-classloader-file/src/art/StackTrace.java deleted file mode 120000 index e1a08aadbd..0000000000 --- a/test/1964-add-to-dex-classloader-file/src/art/StackTrace.java +++ /dev/null @@ -1 +0,0 @@ -../../../jvmti-common/StackTrace.java
\ No newline at end of file diff --git a/test/1964-add-to-dex-classloader-file/src/art/Suspension.java b/test/1964-add-to-dex-classloader-file/src/art/Suspension.java deleted file mode 120000 index bcef96f69d..0000000000 --- a/test/1964-add-to-dex-classloader-file/src/art/Suspension.java +++ /dev/null @@ -1 +0,0 @@ -../../../jvmti-common/Suspension.java
\ No newline at end of file diff --git a/test/Android.bp b/test/Android.bp index 263c615c0d..07c572f25f 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -294,7 +294,6 @@ art_cc_defaults { "1953-pop-frame/pop_frame.cc", "1957-error-ext/lasterror.cc", "1962-multi-thread-events/multi_thread_events.cc", - "1963-add-to-dex-classloader-in-memory/add_to_loader.cc", ], // Use NDK-compatible headers for ctstiagent. header_libs: [ @@ -327,7 +326,6 @@ art_cc_defaults { // "1952-pop-frame-jit/pop_frame.cc", "1959-redefine-object-instrument/fake_redef_object.cc", "1960-obsolete-jit-multithread-native/native_say_hi.cc", - "1964-add-to-dex-classloader-file/add_to_loader.cc", ], static_libs: [ "libz", |