Skip to content

Commit

Permalink
[GR-51609] Execute bootstrap methods for switch statements at build t…
Browse files Browse the repository at this point in the history
…ime.

PullRequest: graal/16719
  • Loading branch information
pejovica committed Jan 29, 2024
2 parents 13d247e + 72f95a1 commit b006347
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,15 @@ public BootstrapMethodConfiguration() {
/* Causes deadlock in Permission feature. */
Method bootstrap = ReflectionUtil.lookupMethod(ObjectMethods.class, "bootstrap", MethodHandles.Lookup.class, String.class, TypeDescriptor.class, Class.class, String.class,
MethodHandle[].class);

/*
* Bootstrap methods used for switch statements. Executing these methods at run time implies
* defining hidden classes at run time, which is unsupported.
*/
Method typeSwitch = ReflectionUtil.lookupMethod(SwitchBootstraps.class, "typeSwitch", MethodHandles.Lookup.class, String.class, MethodType.class, Object[].class);
Method enumSwitch = ReflectionUtil.lookupMethod(SwitchBootstraps.class, "enumSwitch", MethodHandles.Lookup.class, String.class, MethodType.class, Object[].class);

indyBuildTimeAllowList = Set.of(metafactory, altMetafactory, makeConcat, makeConcatWithConstants, bootstrap, typeSwitch);
indyBuildTimeAllowList = Set.of(metafactory, altMetafactory, makeConcat, makeConcatWithConstants, bootstrap, typeSwitch, enumSwitch);

/* Bootstrap methods used for various dynamic constants. */
Method nullConstant = ReflectionUtil.lookupMethod(ConstantBootstraps.class, "nullConstant", MethodHandles.Lookup.class, String.class, Class.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.security.ProtectionDomain;
import java.util.concurrent.ConcurrentHashMap;

import com.oracle.svm.core.SubstrateUtil;
Expand All @@ -46,6 +47,13 @@ final class Target_java_lang_invoke_MethodHandles_Lookup {
static ConcurrentHashMap<Target_java_lang_invoke_MemberName, MethodHandle> LOOKASIDE_TABLE;
// Checkstyle: resume

/*
* Reset the field to avoid image build errors in case the field becomes reachable (plus the
* hosted values would be wrong at run time anyway).
*/
@Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) //
private volatile ProtectionDomain cachedProtectionDomain;

@SuppressWarnings("static-method")
@Substitute
public Class<?> defineClass(@SuppressWarnings("unused") byte[] bytes) {
Expand Down

0 comments on commit b006347

Please sign in to comment.