test/hotspot/jtreg/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
24 package java.lang.invoke; |
24 package java.lang.invoke; |
25 |
25 |
26 import java.lang.invoke.MethodHandles.Lookup; |
26 import java.lang.invoke.MethodHandles.Lookup; |
27 import jdk.internal.vm.annotation.DontInline; |
27 import jdk.internal.vm.annotation.DontInline; |
28 import jdk.internal.vm.annotation.ForceInline; |
28 import jdk.internal.vm.annotation.ForceInline; |
|
29 |
29 /** |
30 /** |
30 * Helper class to inject into java.lang.invoke that provides access to |
31 * Helper class to inject into java.lang.invoke that provides access to |
31 * package-private methods in this package. |
32 * package-private methods in this package. |
32 */ |
33 */ |
33 |
|
34 public class MethodHandleHelper { |
34 public class MethodHandleHelper { |
35 |
35 |
36 private MethodHandleHelper() { } |
36 private MethodHandleHelper() { } |
37 |
37 |
38 public static final Lookup IMPL_LOOKUP = Lookup.IMPL_LOOKUP; |
38 public static final Lookup IMPL_LOOKUP = Lookup.IMPL_LOOKUP; |
77 } |
77 } |
78 |
78 |
79 public static LambdaForm getLambdaForm(MethodHandle mh) { |
79 public static LambdaForm getLambdaForm(MethodHandle mh) { |
80 return mh.form; |
80 return mh.form; |
81 } |
81 } |
82 |
|
83 public static class NonInlinedReinvoker extends DelegatingMethodHandle { |
|
84 private final MethodHandle target; |
|
85 |
|
86 private NonInlinedReinvoker(MethodHandle target, LambdaForm lf) { |
|
87 super(target.type(), lf); |
|
88 this.target = target; |
|
89 } |
|
90 @Override |
|
91 public MethodHandle getTarget() { |
|
92 return target; |
|
93 } |
|
94 |
|
95 @Override |
|
96 public MethodHandle asTypeUncached(MethodType newType) { |
|
97 return asTypeCache = target.asType(newType); |
|
98 } |
|
99 |
|
100 public static MethodHandle make(MethodHandle target) { |
|
101 LambdaForm lform = DelegatingMethodHandle.makeReinvokerForm( |
|
102 target, -1, DelegatingMethodHandle.class, |
|
103 /*forceInline=*/false, DelegatingMethodHandle.NF_getTarget, null); |
|
104 return new NonInlinedReinvoker(target, lform); |
|
105 } |
|
106 } |
|
107 } |
82 } |