summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-04-17 10:06:44 -0700
committer Alex Light <allight@google.com> 2017-04-17 10:06:44 -0700
commit3ccf980505e8b62280cb08616efce28113037f28 (patch)
tree79414560cbdf151d24dd3d47c96a859e9b919e39
parentd5e1a7937fc3f80856309f76c921c2242d4f34ce (diff)
Use standard loading code in many tests
In order to prepare for use in CTS tests make tests 902, 914, 915, 917, 919, 926, 930, 932, 940, 942, 945, 981 & 982 use standard OnLoad functions. Final configuration is done during test initialization. Bug: 32072923 Test: ./test/testrunner/testrunner.py --host -j40 Change-Id: I84b2e17d0e024255d2dc49452f3d74dfd64abd22
-rw-r--r--test/902-hello-transformation/src/art/Redefinition.java19
-rw-r--r--test/902-hello-transformation/src/art/Test902.java1
-rw-r--r--test/914-hello-obsolescence/src/art/Redefinition.java19
-rw-r--r--test/914-hello-obsolescence/src/art/Test914.java1
-rw-r--r--test/915-obsolete-2/src/art/Redefinition.java19
-rw-r--r--test/915-obsolete-2/src/art/Test915.java1
-rw-r--r--test/916-obsolete-jit/src/art/Redefinition.java19
-rw-r--r--test/917-fields-transformation/src/art/Redefinition.java19
-rw-r--r--test/917-fields-transformation/src/art/Test917.java1
-rw-r--r--test/919-obsolete-fields/src/art/Redefinition.java19
-rw-r--r--test/919-obsolete-fields/src/art/Test919.java1
-rw-r--r--test/921-hello-failure/src/art/Redefinition.java19
-rw-r--r--test/926-multi-obsolescence/src/art/Redefinition.java19
-rw-r--r--test/926-multi-obsolescence/src/art/Test926.java1
-rw-r--r--test/930-hello-retransform/src/art/Redefinition.java19
-rw-r--r--test/930-hello-retransform/src/art/Test930.java1
-rw-r--r--test/932-transform-saves/src/art/Redefinition.java19
-rw-r--r--test/932-transform-saves/src/art/Test932.java1
-rw-r--r--test/934-load-transform/src/art/Redefinition.java19
-rw-r--r--test/935-non-retransformable/src/art/Redefinition.java19
-rw-r--r--test/937-hello-retransform-package/src/art/Redefinition.java19
-rw-r--r--test/938-load-transform-bcp/src/art/Redefinition.java19
-rw-r--r--test/939-hello-transformation-bcp/src/art/Redefinition.java19
-rw-r--r--test/940-recursive-obsolete/src/art/Redefinition.java19
-rw-r--r--test/940-recursive-obsolete/src/art/Test940.java1
-rw-r--r--test/941-recurive-obsolete-jit/src/art/Redefinition.java19
-rw-r--r--test/942-private-recursive/src/art/Redefinition.java19
-rw-r--r--test/942-private-recursive/src/art/Test942.java1
-rw-r--r--test/943-private-recursive-jit/src/art/Redefinition.java19
-rw-r--r--test/944-transform-classloaders/src/art/Redefinition.java19
-rw-r--r--test/944-transform-classloaders/src/art/Test944.java1
-rw-r--r--test/945-obsolete-native/src/art/Redefinition.java19
-rw-r--r--test/945-obsolete-native/src/art/Test945.java1
-rw-r--r--test/946-obsolete-throw/src/art/Redefinition.java19
-rw-r--r--test/947-reflect-method/src/art/Redefinition.java19
-rw-r--r--test/948-change-annotations/src/art/Redefinition.java19
-rw-r--r--test/949-in-memory-transform/src/art/Redefinition.java19
-rw-r--r--test/950-redefine-intrinsic/src/art/Redefinition.java19
-rw-r--r--test/951-threaded-obsolete/src/art/Redefinition.java19
-rw-r--r--test/980-redefine-object/src/art/Redefinition.java19
-rw-r--r--test/981-dedup-original-dex/src/art/Redefinition.java19
-rw-r--r--test/981-dedup-original-dex/src/art/Test981.java1
-rw-r--r--test/982-ok-no-retransform/src/art/Redefinition.java19
-rw-r--r--test/982-ok-no-retransform/src/art/Test982.java1
-rw-r--r--test/983-source-transform-verify/src/art/Redefinition.java19
-rw-r--r--test/984-obsolete-invoke/src/art/Redefinition.java19
-rw-r--r--test/ti-agent/common_helper.cc88
-rw-r--r--test/ti-agent/common_load.cc14
48 files changed, 682 insertions, 42 deletions
diff --git a/test/902-hello-transformation/src/art/Redefinition.java b/test/902-hello-transformation/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/902-hello-transformation/src/art/Redefinition.java
+++ b/test/902-hello-transformation/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/902-hello-transformation/src/art/Test902.java b/test/902-hello-transformation/src/art/Test902.java
index 323d1586ea..e95558f7c7 100644
--- a/test/902-hello-transformation/src/art/Test902.java
+++ b/test/902-hello-transformation/src/art/Test902.java
@@ -70,6 +70,7 @@ public class Test902 {
"yAIAAAMQAAABAAAA2AIAAAYgAAABAAAA5AIAAAAQAAABAAAA9AIAAA==");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform());
}
diff --git a/test/914-hello-obsolescence/src/art/Redefinition.java b/test/914-hello-obsolescence/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/914-hello-obsolescence/src/art/Redefinition.java
+++ b/test/914-hello-obsolescence/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/914-hello-obsolescence/src/art/Test914.java b/test/914-hello-obsolescence/src/art/Test914.java
index 0c7cdedf3b..ef2710da5b 100644
--- a/test/914-hello-obsolescence/src/art/Test914.java
+++ b/test/914-hello-obsolescence/src/art/Test914.java
@@ -71,6 +71,7 @@ public class Test914 {
"AA==");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform());
}
diff --git a/test/915-obsolete-2/src/art/Redefinition.java b/test/915-obsolete-2/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/915-obsolete-2/src/art/Redefinition.java
+++ b/test/915-obsolete-2/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/915-obsolete-2/src/art/Test915.java b/test/915-obsolete-2/src/art/Test915.java
index 1b20e5b08b..63c7f344dd 100644
--- a/test/915-obsolete-2/src/art/Test915.java
+++ b/test/915-obsolete-2/src/art/Test915.java
@@ -108,6 +108,7 @@ public class Test915 {
"AAABAAAAEAUAAA==");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform());
}
diff --git a/test/916-obsolete-jit/src/art/Redefinition.java b/test/916-obsolete-jit/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/916-obsolete-jit/src/art/Redefinition.java
+++ b/test/916-obsolete-jit/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/917-fields-transformation/src/art/Redefinition.java b/test/917-fields-transformation/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/917-fields-transformation/src/art/Redefinition.java
+++ b/test/917-fields-transformation/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/917-fields-transformation/src/art/Test917.java b/test/917-fields-transformation/src/art/Test917.java
index f47e8ee3ef..245e92e200 100644
--- a/test/917-fields-transformation/src/art/Test917.java
+++ b/test/917-fields-transformation/src/art/Test917.java
@@ -77,6 +77,7 @@ public class Test917 {
"AAEAAACMAgAABCAAAAIAAACgAgAAAxAAAAEAAACwAgAABiAAAAEAAAC8AgAAABAAAAEAAADMAgAA");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform("Hello", "Goodbye"),
new Transform("start", "end"));
}
diff --git a/test/919-obsolete-fields/src/art/Redefinition.java b/test/919-obsolete-fields/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/919-obsolete-fields/src/art/Redefinition.java
+++ b/test/919-obsolete-fields/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/919-obsolete-fields/src/art/Test919.java b/test/919-obsolete-fields/src/art/Test919.java
index d422f4e73a..11971ef2e8 100644
--- a/test/919-obsolete-fields/src/art/Test919.java
+++ b/test/919-obsolete-fields/src/art/Test919.java
@@ -149,6 +149,7 @@ public class Test919 {
}
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
TestWatcher w = new TestWatcher();
doTest(new Transform(w), w);
}
diff --git a/test/921-hello-failure/src/art/Redefinition.java b/test/921-hello-failure/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/921-hello-failure/src/art/Redefinition.java
+++ b/test/921-hello-failure/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/926-multi-obsolescence/src/art/Redefinition.java b/test/926-multi-obsolescence/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/926-multi-obsolescence/src/art/Redefinition.java
+++ b/test/926-multi-obsolescence/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/926-multi-obsolescence/src/art/Test926.java b/test/926-multi-obsolescence/src/art/Test926.java
index e114f11fc0..843d05c3fc 100644
--- a/test/926-multi-obsolescence/src/art/Test926.java
+++ b/test/926-multi-obsolescence/src/art/Test926.java
@@ -123,6 +123,7 @@ public class Test926 {
"AHwDAAA="));
public static void run() throws Exception {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform(), new Transform2());
}
diff --git a/test/930-hello-retransform/src/art/Redefinition.java b/test/930-hello-retransform/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/930-hello-retransform/src/art/Redefinition.java
+++ b/test/930-hello-retransform/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/930-hello-retransform/src/art/Test930.java b/test/930-hello-retransform/src/art/Test930.java
index 0dc84e35ec..6c0fc16dad 100644
--- a/test/930-hello-retransform/src/art/Test930.java
+++ b/test/930-hello-retransform/src/art/Test930.java
@@ -64,6 +64,7 @@ public class Test930 {
"yAIAAAMQAAABAAAA2AIAAAYgAAABAAAA5AIAAAAQAAABAAAA9AIAAA==");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_RETRANSFORM);
doTest(new Transform());
}
diff --git a/test/932-transform-saves/src/art/Redefinition.java b/test/932-transform-saves/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/932-transform-saves/src/art/Redefinition.java
+++ b/test/932-transform-saves/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/932-transform-saves/src/art/Test932.java b/test/932-transform-saves/src/art/Test932.java
index 69bf609a65..3a622322aa 100644
--- a/test/932-transform-saves/src/art/Test932.java
+++ b/test/932-transform-saves/src/art/Test932.java
@@ -102,6 +102,7 @@ public class Test932 {
"yAIAAAMQAAABAAAA2AIAAAYgAAABAAAA5AIAAAAQAAABAAAA9AIAAA==");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_RETRANSFORM);
doTest(new Transform());
}
diff --git a/test/934-load-transform/src/art/Redefinition.java b/test/934-load-transform/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/934-load-transform/src/art/Redefinition.java
+++ b/test/934-load-transform/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/935-non-retransformable/src/art/Redefinition.java b/test/935-non-retransformable/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/935-non-retransformable/src/art/Redefinition.java
+++ b/test/935-non-retransformable/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/937-hello-retransform-package/src/art/Redefinition.java b/test/937-hello-retransform-package/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/937-hello-retransform-package/src/art/Redefinition.java
+++ b/test/937-hello-retransform-package/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/938-load-transform-bcp/src/art/Redefinition.java b/test/938-load-transform-bcp/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/938-load-transform-bcp/src/art/Redefinition.java
+++ b/test/938-load-transform-bcp/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/939-hello-transformation-bcp/src/art/Redefinition.java b/test/939-hello-transformation-bcp/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/939-hello-transformation-bcp/src/art/Redefinition.java
+++ b/test/939-hello-transformation-bcp/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/940-recursive-obsolete/src/art/Redefinition.java b/test/940-recursive-obsolete/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/940-recursive-obsolete/src/art/Redefinition.java
+++ b/test/940-recursive-obsolete/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/940-recursive-obsolete/src/art/Test940.java b/test/940-recursive-obsolete/src/art/Test940.java
index 9a9382e110..d67d7726da 100644
--- a/test/940-recursive-obsolete/src/art/Test940.java
+++ b/test/940-recursive-obsolete/src/art/Test940.java
@@ -91,6 +91,7 @@ public class Test940 {
"AxAAAAEAAACcBAAABiAAAAEAAACoBAAAABAAAAEAAAC4BAAA");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform());
}
diff --git a/test/941-recurive-obsolete-jit/src/art/Redefinition.java b/test/941-recurive-obsolete-jit/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/941-recurive-obsolete-jit/src/art/Redefinition.java
+++ b/test/941-recurive-obsolete-jit/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/942-private-recursive/src/art/Redefinition.java b/test/942-private-recursive/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/942-private-recursive/src/art/Redefinition.java
+++ b/test/942-private-recursive/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/942-private-recursive/src/art/Test942.java b/test/942-private-recursive/src/art/Test942.java
index 1666a08cac..cccc2fd9e0 100644
--- a/test/942-private-recursive/src/art/Test942.java
+++ b/test/942-private-recursive/src/art/Test942.java
@@ -100,6 +100,7 @@ public class Test942 {
"BAAAAxAAAAEAAADYBAAABiAAAAEAAADkBAAAABAAAAEAAAD0BAAA");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform());
}
diff --git a/test/943-private-recursive-jit/src/art/Redefinition.java b/test/943-private-recursive-jit/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/943-private-recursive-jit/src/art/Redefinition.java
+++ b/test/943-private-recursive-jit/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/944-transform-classloaders/src/art/Redefinition.java b/test/944-transform-classloaders/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/944-transform-classloaders/src/art/Redefinition.java
+++ b/test/944-transform-classloaders/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/944-transform-classloaders/src/art/Test944.java b/test/944-transform-classloaders/src/art/Test944.java
index e7747c2e0f..fe1c024ec4 100644
--- a/test/944-transform-classloaders/src/art/Test944.java
+++ b/test/944-transform-classloaders/src/art/Test944.java
@@ -115,6 +115,7 @@ public class Test944 {
"AgAAAMwCAAADEAAAAQAAANwCAAAGIAAAAQAAAOgCAAAAEAAAAQAAAPgCAAA="));
public static void run() throws Exception {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest();
System.out.println("Passed");
}
diff --git a/test/945-obsolete-native/src/art/Redefinition.java b/test/945-obsolete-native/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/945-obsolete-native/src/art/Redefinition.java
+++ b/test/945-obsolete-native/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/945-obsolete-native/src/art/Test945.java b/test/945-obsolete-native/src/art/Test945.java
index f77323d84c..6cf31f6d05 100644
--- a/test/945-obsolete-native/src/art/Test945.java
+++ b/test/945-obsolete-native/src/art/Test945.java
@@ -81,6 +81,7 @@ public class Test945 {
"AQAAALgDAAA=");
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_REDEFINE);
doTest(new Transform());
}
diff --git a/test/946-obsolete-throw/src/art/Redefinition.java b/test/946-obsolete-throw/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/946-obsolete-throw/src/art/Redefinition.java
+++ b/test/946-obsolete-throw/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/947-reflect-method/src/art/Redefinition.java b/test/947-reflect-method/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/947-reflect-method/src/art/Redefinition.java
+++ b/test/947-reflect-method/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/948-change-annotations/src/art/Redefinition.java b/test/948-change-annotations/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/948-change-annotations/src/art/Redefinition.java
+++ b/test/948-change-annotations/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/949-in-memory-transform/src/art/Redefinition.java b/test/949-in-memory-transform/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/949-in-memory-transform/src/art/Redefinition.java
+++ b/test/949-in-memory-transform/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/950-redefine-intrinsic/src/art/Redefinition.java b/test/950-redefine-intrinsic/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/950-redefine-intrinsic/src/art/Redefinition.java
+++ b/test/950-redefine-intrinsic/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/951-threaded-obsolete/src/art/Redefinition.java b/test/951-threaded-obsolete/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/951-threaded-obsolete/src/art/Redefinition.java
+++ b/test/951-threaded-obsolete/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/980-redefine-object/src/art/Redefinition.java b/test/980-redefine-object/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/980-redefine-object/src/art/Redefinition.java
+++ b/test/980-redefine-object/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/981-dedup-original-dex/src/art/Redefinition.java b/test/981-dedup-original-dex/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/981-dedup-original-dex/src/art/Redefinition.java
+++ b/test/981-dedup-original-dex/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/981-dedup-original-dex/src/art/Test981.java b/test/981-dedup-original-dex/src/art/Test981.java
index 42a76471c2..3a97268ef9 100644
--- a/test/981-dedup-original-dex/src/art/Test981.java
+++ b/test/981-dedup-original-dex/src/art/Test981.java
@@ -138,6 +138,7 @@ public class Test981 {
"AyAAAAIAAAAWAgAAACAAAAEAAAAhAgAAABAAAAEAAAAwAgAA");
public static void run() throws Exception {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_RETRANSFORM);
doTest();
}
diff --git a/test/982-ok-no-retransform/src/art/Redefinition.java b/test/982-ok-no-retransform/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/982-ok-no-retransform/src/art/Redefinition.java
+++ b/test/982-ok-no-retransform/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/982-ok-no-retransform/src/art/Test982.java b/test/982-ok-no-retransform/src/art/Test982.java
index c043bbd111..080d47facc 100644
--- a/test/982-ok-no-retransform/src/art/Test982.java
+++ b/test/982-ok-no-retransform/src/art/Test982.java
@@ -26,6 +26,7 @@ public class Test982 {
}
public static void run() {
+ Redefinition.setTestConfiguration(Redefinition.Config.COMMON_RETRANSFORM);
doTest(new Transform());
}
diff --git a/test/983-source-transform-verify/src/art/Redefinition.java b/test/983-source-transform-verify/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/983-source-transform-verify/src/art/Redefinition.java
+++ b/test/983-source-transform-verify/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/984-obsolete-invoke/src/art/Redefinition.java b/test/984-obsolete-invoke/src/art/Redefinition.java
index 8cd2568d4e..0350ab42ad 100644
--- a/test/984-obsolete-invoke/src/art/Redefinition.java
+++ b/test/984-obsolete-invoke/src/art/Redefinition.java
@@ -36,6 +36,25 @@ public class Redefinition {
}
}
+ // A set of possible test configurations. Test should set this if they need to.
+ // This must be kept in sync with the defines in ti-agent/common_helper.cc
+ public static enum Config {
+ COMMON_REDEFINE(0),
+ COMMON_RETRANSFORM(1),
+ COMMON_TRANSFORM(2);
+
+ private final int val;
+ private Config(int val) {
+ this.val = val;
+ }
+ }
+
+ public static void setTestConfiguration(Config type) {
+ nativeSetTestConfiguration(type.val);
+ }
+
+ private static native void nativeSetTestConfiguration(int type);
+
// Transforms the class
public static native void doCommonClassRedefinition(Class<?> target,
byte[] classfile,
diff --git a/test/ti-agent/common_helper.cc b/test/ti-agent/common_helper.cc
index 154d7563e7..dc9e26dd8a 100644
--- a/test/ti-agent/common_helper.cc
+++ b/test/ti-agent/common_helper.cc
@@ -17,18 +17,15 @@
#include "common_helper.h"
#include <dlfcn.h>
+#include <map>
#include <stdio.h>
#include <sstream>
#include <deque>
+#include <vector>
#include "android-base/stringprintf.h"
-#include "art_method.h"
#include "jni.h"
-#include "jni_internal.h"
#include "jvmti.h"
-#include "scoped_thread_state_change-inl.h"
-#include "stack.h"
-#include "utils.h"
#include "jni_binder.h"
#include "jvmti_helper.h"
@@ -37,6 +34,10 @@
namespace art {
+static void SetupCommonRetransform();
+static void SetupCommonRedefine();
+static void SetupCommonTransform();
+
template <bool is_redefine>
static void throwCommonRedefinitionError(jvmtiEnv* jvmti,
JNIEnv* env,
@@ -152,11 +153,7 @@ jint OnLoad(JavaVM* vm,
printf("Unable to get jvmti env!\n");
return 1;
}
- jvmtiCapabilities caps;
- jvmti_env->GetPotentialCapabilities(&caps);
- caps.can_retransform_classes = 0;
- caps.can_retransform_any_class = 0;
- jvmti_env->AddCapabilities(&caps);
+ SetupCommonRedefine();
return 0;
}
@@ -331,14 +328,7 @@ jint OnLoad(JavaVM* vm,
printf("Unable to get jvmti env!\n");
return 1;
}
- SetAllCapabilities(jvmti_env);
- jvmtiEventCallbacks cb;
- memset(&cb, 0, sizeof(cb));
- cb.ClassFileLoadHook = CommonClassFileLoadHookRetransformable;
- if (jvmti_env->SetEventCallbacks(&cb, sizeof(cb)) != JVMTI_ERROR_NONE) {
- printf("Unable to set class file load hook cb!\n");
- return 1;
- }
+ SetupCommonRetransform();
return 0;
}
@@ -346,8 +336,6 @@ jint OnLoad(JavaVM* vm,
namespace common_transform {
-using art::common_retransform::CommonClassFileLoadHookRetransformable;
-
// Get all capabilities except those related to retransformation.
jint OnLoad(JavaVM* vm,
char* options ATTRIBUTE_UNUSED,
@@ -356,6 +344,34 @@ jint OnLoad(JavaVM* vm,
printf("Unable to get jvmti env!\n");
return 1;
}
+ SetupCommonTransform();
+ return 0;
+}
+
+} // namespace common_transform
+
+#define CONFIGURATION_COMMON_REDEFINE 0
+#define CONFIGURATION_COMMON_RETRANSFORM 1
+#define CONFIGURATION_COMMON_TRANSFORM 2
+
+static void SetupCommonRedefine() {
+ jvmtiCapabilities caps;
+ jvmti_env->GetPotentialCapabilities(&caps);
+ caps.can_retransform_classes = 0;
+ caps.can_retransform_any_class = 0;
+ jvmti_env->AddCapabilities(&caps);
+}
+
+static void SetupCommonRetransform() {
+ SetAllCapabilities(jvmti_env);
+ jvmtiEventCallbacks cb;
+ memset(&cb, 0, sizeof(cb));
+ cb.ClassFileLoadHook = common_retransform::CommonClassFileLoadHookRetransformable;
+ jvmtiError res = jvmti_env->SetEventCallbacks(&cb, sizeof(cb));
+ CHECK_EQ(res, JVMTI_ERROR_NONE);
+}
+
+static void SetupCommonTransform() {
// Don't set the retransform caps
jvmtiCapabilities caps;
jvmti_env->GetPotentialCapabilities(&caps);
@@ -366,14 +382,30 @@ jint OnLoad(JavaVM* vm,
// Use the same callback as the retransform test.
jvmtiEventCallbacks cb;
memset(&cb, 0, sizeof(cb));
- cb.ClassFileLoadHook = CommonClassFileLoadHookRetransformable;
- if (jvmti_env->SetEventCallbacks(&cb, sizeof(cb)) != JVMTI_ERROR_NONE) {
- printf("Unable to set class file load hook cb!\n");
- return 1;
- }
- return 0;
+ cb.ClassFileLoadHook = common_retransform::CommonClassFileLoadHookRetransformable;
+ jvmtiError res = jvmti_env->SetEventCallbacks(&cb, sizeof(cb));
+ CHECK_EQ(res, JVMTI_ERROR_NONE);
}
-} // namespace common_transform
-
+extern "C" JNIEXPORT void JNICALL Java_art_Redefinition_nativeSetTestConfiguration(JNIEnv*,
+ jclass,
+ jint type) {
+ switch (type) {
+ case CONFIGURATION_COMMON_REDEFINE: {
+ SetupCommonRedefine();
+ return;
+ }
+ case CONFIGURATION_COMMON_RETRANSFORM: {
+ SetupCommonRetransform();
+ return;
+ }
+ case CONFIGURATION_COMMON_TRANSFORM: {
+ SetupCommonTransform();
+ return;
+ }
+ default: {
+ LOG(FATAL) << "Unknown test configuration: " << type;
+ }
+ }
+}
} // namespace art
diff --git a/test/ti-agent/common_load.cc b/test/ti-agent/common_load.cc
index 9e7b75daf2..3455409b2d 100644
--- a/test/ti-agent/common_load.cc
+++ b/test/ti-agent/common_load.cc
@@ -60,31 +60,17 @@ static jint MinimalOnLoad(JavaVM* vm,
// MinimalOnLoad.
static AgentLib agents[] = {
{ "901-hello-ti-agent", Test901HelloTi::OnLoad, nullptr },
- { "902-hello-transformation", common_redefine::OnLoad, nullptr },
{ "909-attach-agent", nullptr, Test909AttachAgent::OnAttach },
- { "914-hello-obsolescence", common_redefine::OnLoad, nullptr },
- { "915-obsolete-2", common_redefine::OnLoad, nullptr },
{ "916-obsolete-jit", common_redefine::OnLoad, nullptr },
- { "917-fields-transformation", common_redefine::OnLoad, nullptr },
- { "919-obsolete-fields", common_redefine::OnLoad, nullptr },
{ "921-hello-failure", common_retransform::OnLoad, nullptr },
- { "926-multi-obsolescence", common_redefine::OnLoad, nullptr },
- { "930-hello-retransform", common_retransform::OnLoad, nullptr },
- { "932-transform-saves", common_retransform::OnLoad, nullptr },
{ "934-load-transform", common_retransform::OnLoad, nullptr },
{ "935-non-retransformable", common_transform::OnLoad, nullptr },
{ "936-search-onload", Test936SearchOnload::OnLoad, nullptr },
{ "937-hello-retransform-package", common_retransform::OnLoad, nullptr },
{ "938-load-transform-bcp", common_retransform::OnLoad, nullptr },
{ "939-hello-transformation-bcp", common_redefine::OnLoad, nullptr },
- { "940-recursive-obsolete", common_redefine::OnLoad, nullptr },
{ "941-recursive-obsolete-jit", common_redefine::OnLoad, nullptr },
- { "942-private-recursive", common_redefine::OnLoad, nullptr },
{ "943-private-recursive-jit", common_redefine::OnLoad, nullptr },
- { "944-transform-classloaders", common_redefine::OnLoad, nullptr },
- { "945-obsolete-native", common_redefine::OnLoad, nullptr },
- { "981-dedup-original-dex", common_retransform::OnLoad, nullptr },
- { "982-ok-no-retransform", common_retransform::OnLoad, nullptr },
{ "983-source-transform-verify", Test983SourceTransformVerify::OnLoad, nullptr },
};