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# This is the test suite runner. It is written in smali rather than
17# Java pending support in dx/dxmerge for invoke-polymorphic (b/33191712).
18
19.source "Main.smali"
20
21.class public LMain;
22.super Ljava/lang/Object;
23
24.method public constructor<init>()V
25.registers 1
26  invoke-direct {v0}, Ljava/lang/Object;-><init>()V
27  return-void
28.end method
29
30.method public static main([Ljava/lang/String;)V
31.registers 1
32  # New tests should be added here.
33  const-string v0, "MethodHandleNotInvoke"
34  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
35  const-string v0, "MethodHandleToString"
36  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
37  const-string v0, "NonReference"
38  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
39  const-string v0, "TooFewArguments"
40  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
41  const-string v0, "TooManyArguments"
42  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
43  const-string v0, "BadThis"
44  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
45  const-string v0, "FakeSignaturePolymorphic"
46  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
47  const-string v0, "BetterFakeSignaturePolymorphic"
48  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
49  const-string v0, "Subclass"
50  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
51  const-string v0, "Unresolved"
52  invoke-static {v0}, LMain;->test(Ljava/lang/String;)V
53  return-void
54.end method
55
56.method public static test(Ljava/lang/String;)V
57.registers 6
58 :try_start_1
59  invoke-static {v5}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
60  move-result-object v0
61  invoke-virtual {v0}, Ljava/lang/Class;->newInstance()Ljava/lang/Object;
62 :try_end_1
63  .catch Ljava/lang/VerifyError; {:try_start_1 .. :try_end_1} :catch_verifier
64  return-void
65 :catch_verifier
66  move-exception v3
67  invoke-virtual {v3}, Ljava/lang/Exception;->toString()Ljava/lang/String;
68  move-result-object v3
69  sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
70  invoke-virtual {v2, v3}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
71  return-void
72.end method
73
74# A test method called "invoke", but on a class other than MethodHandle.
75.method public invoke([Ljava/lang/Object;)Ljava/lang/Object;
76.registers 2
77  const/4 v0, 0
78  aget-object v0, p0, v0
79  return-object v0
80.end method
81
82# A test method called "invokeExact" that is native varargs, but is on a class
83# other than MethodHandle.
84.method public native varargs invokeExact([Ljava/lang/Object;)Ljava/lang/Object;
85.end method