blob: 307c987cda5e56d68163554136d31ea7276a6d57 [file] [log] [blame]
Nicolas Geoffray6f5c41f2014-11-06 08:59:20 +00001/*
2 * Copyright (C) 2014 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
17public class Main {
18 public static Object a;
19
20 public static void assertTrue(boolean value) {
21 if (!value) {
22 throw new Error("Wrong result");
23 }
24 }
25
26 public static void assertFalse(boolean value) {
27 if (value) {
28 throw new Error("Wrong result");
29 }
30 }
31
32 public static boolean $opt$InstanceOfMain() {
33 return a instanceof Main;
34 }
35
36 public static boolean $opt$InstanceOfFinalClass() {
37 return a instanceof FinalClass;
38 }
39
40 public static void main(String[] args) {
41 $opt$TestMain();
42 $opt$TestFinalClass();
43 }
44
45 public static void $opt$TestMain() {
46 a = new Main();
47 assertTrue($opt$InstanceOfMain());
48 a = null;
49 assertFalse($opt$InstanceOfMain());
50 a = new MainChild();
51 assertTrue($opt$InstanceOfMain());
52 a = new Object();
53 assertFalse($opt$InstanceOfMain());
54 }
55
56 public static void $opt$TestFinalClass() {
57 a = new FinalClass();
58 assertTrue($opt$InstanceOfFinalClass());
59 a = null;
60 assertFalse($opt$InstanceOfFinalClass());
61 a = new Main();
62 assertFalse($opt$InstanceOfFinalClass());
63 a = new Object();
64 assertFalse($opt$InstanceOfFinalClass());
65 }
66
67 static class MainChild extends Main {}
68
69 static final class FinalClass {}
70}