|
24 | 24 | */
|
25 | 25 | package com.oracle.svm.core.methodhandles;
|
26 | 26 |
|
| 27 | +import org.graalvm.nativeimage.hosted.FieldValueTransformer; |
| 28 | + |
27 | 29 | import com.oracle.svm.core.annotate.Alias;
|
28 | 30 | import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
29 | 31 | import com.oracle.svm.core.annotate.Substitute;
|
30 | 32 | import com.oracle.svm.core.annotate.TargetClass;
|
31 | 33 | import com.oracle.svm.core.invoke.Target_java_lang_invoke_MemberName;
|
| 34 | +import com.oracle.svm.util.ReflectionUtil; |
32 | 35 |
|
33 | 36 | @TargetClass(className = "java.lang.invoke.LambdaForm")
|
34 | 37 | public final class Target_java_lang_invoke_LambdaForm {
|
35 | 38 |
|
36 | 39 | @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset)//
|
37 | 40 | Target_java_lang_invoke_MemberName vmentry;
|
38 | 41 |
|
| 42 | + @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Custom, declClass = LambdaFormCacheTransformer.class)// |
| 43 | + volatile Object transformCache; |
| 44 | + |
39 | 45 | @Alias
|
40 | 46 | native String lambdaName();
|
41 | 47 |
|
@@ -64,6 +70,19 @@ private boolean forceInterpretation() {
|
64 | 70 | native Object interpretWithArguments(Object... argumentValues) throws Throwable;
|
65 | 71 | }
|
66 | 72 |
|
| 73 | +final class LambdaFormCacheTransformer implements FieldValueTransformer { |
| 74 | + |
| 75 | + @Override |
| 76 | + public Object transform(Object receiver, Object originalValue) { |
| 77 | + Class<?> lambdaFormClass = ReflectionUtil.lookupClass(false, "java.lang.invoke.LambdaForm"); |
| 78 | + if (lambdaFormClass.isInstance(originalValue)) { |
| 79 | + // Stores the original LambdaForm for a customized one. |
| 80 | + return originalValue; |
| 81 | + } |
| 82 | + return null; |
| 83 | + } |
| 84 | +} |
| 85 | + |
67 | 86 | @TargetClass(className = "java.lang.invoke.LambdaForm", innerClass = "NamedFunction")
|
68 | 87 | final class Target_java_lang_invoke_LambdaForm_NamedFunction {
|
69 | 88 | @Alias
|
|
0 commit comments