1b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe/*
2b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * Copyright (C) 2015 The Android Open Source Project
3b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe *
4b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * Licensed under the Apache License, Version 2.0 (the "License");
5b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * you may not use this file except in compliance with the License.
6b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * You may obtain a copy of the License at
7b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe *
8b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe *      http://www.apache.org/licenses/LICENSE-2.0
9b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe *
10b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * Unless required by applicable law or agreed to in writing, software
11b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * distributed under the License is distributed on an "AS IS" BASIS,
12b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * See the License for the specific language governing permissions and
14b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * limitations under the License.
15b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe */
16b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe
175872d7cd6ceffe67550d0b021191ec66f1a34c5dJeff Haoimport dalvik.system.DexClassLoader;
18b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampeimport java.io.File;
19b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampeimport java.lang.reflect.Method;
20b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe
21b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe/**
22b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe * Structural hazard test.
23b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe */
24b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampepublic class Main {
25b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe    public static void main(String[] args) {
26b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe        new Main().run();
27b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe    }
28b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe
29b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe    private void run() {
30b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe        System.out.println(new A().i);
31b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe
32b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe        // Now run the class from the -ex file.
33b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe
345872d7cd6ceffe67550d0b021191ec66f1a34c5dJeff Hao        String dexPath = System.getenv("DEX_LOCATION") + "/138-duplicate-classes-check-ex.jar";
355872d7cd6ceffe67550d0b021191ec66f1a34c5dJeff Hao        String optimizedDirectory = System.getenv("DEX_LOCATION");
365872d7cd6ceffe67550d0b021191ec66f1a34c5dJeff Hao        String librarySearchPath = null;
375872d7cd6ceffe67550d0b021191ec66f1a34c5dJeff Hao        DexClassLoader loader = new DexClassLoader(dexPath, optimizedDirectory, librarySearchPath,
385872d7cd6ceffe67550d0b021191ec66f1a34c5dJeff Hao                getClass().getClassLoader());
39b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe
40b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe        try {
41b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe            Class testEx = loader.loadClass("TestEx");
42b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe            Method test = testEx.getDeclaredMethod("test");
43b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe            test.invoke(null);
44b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe        } catch (Exception exc) {
45b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe            exc.printStackTrace();
46b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe        }
47b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe    }
48b9aec2ccd8b9f39a4ddadde5ca8304cea6b1b188Andreas Gampe}
49