1 /*
2  * Copyright (C) 2008 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 /**
18  * Try different kinds of method calls.
19  */
20 public class MethodCall extends MethodCallBase {
MethodCall()21     MethodCall() {
22         super();
23         System.out.println("  MethodCall ctor");
24     }
25 
26     /* overridden method */
tryThing()27     int tryThing() {
28         int val = super.tryThing();
29         Main.assertTrue(val == 7);
30         return val;
31     }
32 
33     /* do-nothing private instance method */
directly()34     private void directly() {}
35 
36     /*
37      * Function with many arguments.
38      */
manyArgs(int a0, long a1, int a2, long a3, int a4, long a5, int a6, int a7, double a8, float a9, double a10, short a11, int a12, char a13, int a14, int a15, byte a16, boolean a17, int a18, int a19, long a20, long a21, int a22, int a23, int a24, int a25, int a26, String[][] a27, String[] a28, String a29)39     static void manyArgs(int a0, long a1, int a2, long a3, int a4, long a5,
40         int a6, int a7, double a8, float a9, double a10, short a11, int a12,
41         char a13, int a14, int a15, byte a16, boolean a17, int a18, int a19,
42         long a20, long a21, int a22, int a23, int a24, int a25, int a26,
43         String[][] a27, String[] a28, String a29)
44     {
45         System.out.println("MethodCalls.manyArgs");
46         Main.assertTrue(a0 == 0);
47         Main.assertTrue(a9 > 8.99 && a9 < 9.01);
48         Main.assertTrue(a16 == -16);
49         Main.assertTrue(a25 == 25);
50         Main.assertTrue(a29.equals("twenty nine"));
51     }
52 
run()53     public static void run() {
54         MethodCall inst = new MethodCall();
55 
56         MethodCallBase base = inst;
57         base.tryThing();
58         inst.tryThing();
59 
60         inst = null;
61         try {
62             inst.directly();
63             Main.assertTrue(false);
64         } catch (NullPointerException npe) {
65             // good
66         }
67 
68         manyArgs(0, 1L, 2, 3L, 4, 5L, 6, 7, 8.0, 9.0f, 10.0, (short)11, 12,
69             (char)13, 14, 15, (byte)-16, true, 18, 19, 20L, 21L, 22, 23, 24,
70             25, 26, null, null, "twenty nine");
71     }
72 }
73 
74 class MethodCallBase {
MethodCallBase()75     MethodCallBase() {
76         System.out.println("  MethodCallBase ctor");
77     }
78 
tryThing()79     int tryThing() {
80         return 7;
81     }
82 }
83