Skip to content

Commit 68c0f82

Browse files
committed
svm: add an @alias for Module.layer to make it non-final
1 parent 0cdf55a commit 68c0f82

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_java_lang_Module.java

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package com.oracle.svm.core.jdk;
2626

2727
import com.oracle.svm.core.annotate.Alias;
28+
import com.oracle.svm.core.annotate.RecomputeFieldValue;
2829
import com.oracle.svm.core.annotate.Substitute;
2930
import com.oracle.svm.core.annotate.TargetClass;
3031
import com.oracle.svm.core.annotate.TargetElement;
@@ -40,6 +41,19 @@
4041
@SuppressWarnings("unused")
4142
@TargetClass(value = java.lang.Module.class)
4243
public final class Target_java_lang_Module {
44+
45+
/**
46+
* {@link Alias} to make {@code Module.layer} non-final. The actual run-time value is set via
47+
* reflection in {@code ModuleLayerFeatureUtils#patchModuleLayerField}, which is called after
48+
* analysis. Thus, we cannot leave it {@code final}, because the analysis might otherwise
49+
* constant-fold the initial {@code null} value. Ideally, we would make it {@code @Stable}, but
50+
* our substitution system currently does not allow this (GR-60154).
51+
*/
52+
@Alias //
53+
@RecomputeFieldValue(isFinal = false, kind = RecomputeFieldValue.Kind.None)
54+
// @Stable (no effect currently GR-60154)
55+
private ModuleLayer layer;
56+
4357
@Substitute
4458
@TargetElement(onlyWith = ForeignDisabled.class)
4559
@SuppressWarnings("static-method")

0 commit comments

Comments
 (0)