blob: 1fe259961d12a10c16fe78eecd7fe83feea90c02 [file] [log] [blame]
Alex Light460d1b42017-01-10 15:37:17 +00001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Alex Light0e692732017-01-10 15:00:05 -080017import java.util.ArrayList;
Alex Light460d1b42017-01-10 15:37:17 +000018public class Main {
19
20 public static void main(String[] args) {
21 System.loadLibrary(args[1]);
22 NewName.doTest(new Transform());
23 DifferentAccess.doTest(new Transform());
24 NewInterface.doTest(new Transform2());
25 MissingInterface.doTest(new Transform2());
26 ReorderInterface.doTest(new Transform2());
Alex Light0e692732017-01-10 15:00:05 -080027 MultiRedef.doTest(new Transform(), new Transform2());
Alex Light460d1b42017-01-10 15:37:17 +000028 }
29
30 // Transforms the class. This throws an exception if something goes wrong.
31 public static native void doCommonClassRedefinition(Class<?> target,
32 byte[] classfile,
33 byte[] dexfile) throws Exception;
Alex Light0e692732017-01-10 15:00:05 -080034
35 public static void doMultiClassRedefinition(CommonClassDefinition... defs) throws Exception {
36 ArrayList<Class<?>> classes = new ArrayList<>();
37 ArrayList<byte[]> class_files = new ArrayList<>();
38 ArrayList<byte[]> dex_files = new ArrayList<>();
39
40 for (CommonClassDefinition d : defs) {
41 classes.add(d.target);
42 class_files.add(d.class_file_bytes);
43 dex_files.add(d.dex_file_bytes);
44 }
45 doCommonMultiClassRedefinition(classes.toArray(new Class<?>[0]),
46 class_files.toArray(new byte[0][]),
47 dex_files.toArray(new byte[0][]));
48 }
49
50 public static native void doCommonMultiClassRedefinition(Class<?>[] targets,
51 byte[][] classfiles,
52 byte[][] dexfiles) throws Exception;
Alex Light460d1b42017-01-10 15:37:17 +000053}