1/*
2 * Copyright (C) 2013 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
17package com.android.dx.multidex;
18
19/**
20 * Test that DexMerge works by merging dex files, and then loading them into
21 * the current VM.
22 */
23public final class MainDexListTest {
24
25    public static void main(String[] args) throws Exception {
26        // simplify the javac classpath by not depending directly on 'dalvik.system' classes
27        ClassLoader mainLoader = (ClassLoader) Class.forName("dalvik.system.PathClassLoader")
28                .getConstructor(String.class, ClassLoader.class)
29                .newInstance("out/classes.dex", MainDexListTest.class.getClassLoader());
30        ClassLoader secondaryLoader = (ClassLoader) Class.forName("dalvik.system.PathClassLoader")
31                .getConstructor(String.class, ClassLoader.class)
32                .newInstance("out/classes2.dex", MainDexListTest.class.getClassLoader());
33
34        mainLoader.loadClass("testdata.InMainDex");
35        secondaryLoader.loadClass("testdata.InSecondaryDex");
36       try {
37           secondaryLoader.loadClass("testdata.InMainDex");
38           throw new AssertionError();
39       } catch (ClassNotFoundException e) {
40           // expected
41       }
42       try {
43           mainLoader.loadClass("testdata.InSecondaryDex");
44           throw new AssertionError();
45       } catch (ClassNotFoundException e) {
46           // expected
47       }
48
49    }
50
51}
52