blob: 139a1720f49a4e1760a447dc1aed4af78eeefb9a [file] [log] [blame]
Orion Hodson36bce3b2018-02-26 10:04:25 +00001/*
2 * Copyright (C) 2018 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
Orion Hodson4c213cb2018-02-26 10:25:41 +000017import annotations.BootstrapMethod;
Orion Hodson36bce3b2018-02-26 10:04:25 +000018import annotations.CalledByIndy;
19import annotations.Constant;
Orion Hodson36bce3b2018-02-26 10:04:25 +000020import java.lang.invoke.MethodHandles;
21import java.lang.invoke.MethodType;
22
23class TestLinkerUnrelatedBSM extends TestBase {
24 @CalledByIndy(
Orion Hodson4c213cb2018-02-26 10:25:41 +000025 bootstrapMethod =
26 @BootstrapMethod(
Orion Hodson36bce3b2018-02-26 10:04:25 +000027 enclosingType = UnrelatedBSM.class,
Orion Hodson4c213cb2018-02-26 10:25:41 +000028 parameterTypes = {
Orion Hodson36bce3b2018-02-26 10:04:25 +000029 MethodHandles.Lookup.class,
30 String.class,
31 MethodType.class,
32 Class.class
33 },
34 name = "bsm"
35 ),
Orion Hodson4c213cb2018-02-26 10:25:41 +000036 fieldOrMethodName = "_addf",
Orion Hodson36bce3b2018-02-26 10:04:25 +000037 returnType = float.class,
Orion Hodson4c213cb2018-02-26 10:25:41 +000038 parameterTypes = {float.class, float.class},
39 constantArgumentsForBootstrapMethod = {@Constant(classValue = TestLinkerUnrelatedBSM.class)}
Orion Hodson36bce3b2018-02-26 10:04:25 +000040 )
41 private static float addf(float a, float b) {
42 assertNotReached();
43 return Float.MIN_VALUE;
44 }
45
46 public static float _addf(float a, float b) {
47 return a + b;
48 }
49
50 @CalledByIndy(
Orion Hodson4c213cb2018-02-26 10:25:41 +000051 bootstrapMethod =
52 @BootstrapMethod(
Orion Hodson36bce3b2018-02-26 10:04:25 +000053 enclosingType = UnrelatedBSM.class,
Orion Hodson4c213cb2018-02-26 10:25:41 +000054 parameterTypes = {
Orion Hodson36bce3b2018-02-26 10:04:25 +000055 MethodHandles.Lookup.class,
56 String.class,
57 MethodType.class,
58 Class.class
59 },
60 name = "bsm"
61 ),
Orion Hodson4c213cb2018-02-26 10:25:41 +000062 fieldOrMethodName = "_subf",
Orion Hodson36bce3b2018-02-26 10:04:25 +000063 returnType = float.class,
Orion Hodson4c213cb2018-02-26 10:25:41 +000064 parameterTypes = {float.class, float.class},
65 constantArgumentsForBootstrapMethod = {@Constant(classValue = TestLinkerUnrelatedBSM.class)}
Orion Hodson36bce3b2018-02-26 10:04:25 +000066 )
67 private static float subf(float a, float b) {
68 assertNotReached();
69 return Float.MIN_VALUE;
70 }
71
72 private static float _subf(float a, float b) {
73 return a - b;
74 }
75
76 public static void test() {
77 System.out.println(TestLinkerUnrelatedBSM.class.getName());
78 assertEquals(2.5f, addf(2.0f, 0.5f));
79 assertEquals(1.5f, subf(2.0f, 0.5f));
80 }
81}