Andreas Gampe | aa8b60c | 2016-10-12 12:51:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | import java.util.Arrays; |
| 18 | import java.util.Collections; |
| 19 | import java.util.HashSet; |
| 20 | |
| 21 | public class Main { |
| 22 | public static void main(String[] args) throws Exception { |
| 23 | System.loadLibrary(args[1]); |
| 24 | |
| 25 | doTest(); |
| 26 | } |
| 27 | |
| 28 | public static void doTest() throws Exception { |
| 29 | // Ensure some classes are loaded. |
| 30 | A a = new A(); |
| 31 | B b = new B(); |
| 32 | A[] aArray = new A[5]; |
| 33 | |
| 34 | String[] classes = getLoadedClasses(); |
| 35 | HashSet<String> classesSet = new HashSet<>(Arrays.asList(classes)); |
| 36 | |
| 37 | String[] shouldBeLoaded = new String[] { |
| 38 | "java.lang.Object", "java.lang.Class", "java.lang.String", "Main$A", "Main$B", "[LMain$A;" |
| 39 | }; |
| 40 | |
| 41 | boolean error = false; |
| 42 | for (String s : shouldBeLoaded) { |
| 43 | if (!classesSet.contains(s)) { |
| 44 | System.out.println("Did not find " + s); |
| 45 | error = true; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | if (error) { |
| 50 | System.out.println(Arrays.toString(classes)); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | static class A { |
| 55 | } |
| 56 | |
| 57 | static class B { |
| 58 | } |
| 59 | |
| 60 | private static native String[] getLoadedClasses(); |
| 61 | } |