Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,12 @@ public static void updateMaxJavaStackTraceDepth(EconomicMap<OptionKey<?>, Object
@Option(help = "Verify naming conventions during image construction.")//
public static final HostedOptionKey<Boolean> VerifyNamingConventions = new HostedOptionKey<>(false);

@Option(help = "Disable the substitutions matched by the option value. " +
"A value can be a fully qualified method name with parameter list, a fully qualified method name without parameter list, or a fully qualified type name. " +
"When multiple methods match a value, then all matching substitutions are disabled.")//
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> DisableSubstitution = new HostedOptionKey<>(
AccumulatingLocatableMultiOptionValue.Strings.build());

@Option(help = "Deprecated, has no effect.", deprecated = true) //
public static final HostedOptionKey<Boolean> MultiThreaded = new HostedOptionKey<>(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BooleanSupplier;
import java.util.function.Function;
Expand Down Expand Up @@ -116,6 +117,7 @@ public class AnnotationSubstitutionProcessor extends SubstitutionProcessor {
private final Map<ResolvedJavaField, ResolvedJavaField> fieldSubstitutions;
private Map<Field, Object> unsafeAccessedFields = new HashMap<>();
private final ClassInitializationSupport classInitializationSupport;
private final Set<String> disabledSubstitutions;

public AnnotationSubstitutionProcessor(ImageClassLoader imageClassLoader, MetaAccessProvider metaAccess, ClassInitializationSupport classInitializationSupport) {
this.imageClassLoader = imageClassLoader;
Expand All @@ -127,6 +129,7 @@ public AnnotationSubstitutionProcessor(ImageClassLoader imageClassLoader, MetaAc
methodSubstitutions = new ConcurrentHashMap<>();
polymorphicMethodSubstitutions = new HashMap<>();
fieldSubstitutions = new ConcurrentHashMap<>();
disabledSubstitutions = Set.copyOf(SubstrateOptions.DisableSubstitution.getValue().values());
}

@Override
Expand Down Expand Up @@ -422,6 +425,18 @@ private void handleMethodInAliasClass(Executable annotatedMethod, Class<?> origi
return;
}

if (!disabledSubstitutions.isEmpty()) {
/*
* Substitutions can be disabled on the command line. The three formats to match are
* specified in the help text of the option DisableSubstitution.
*/
if (disabledSubstitutions.contains(annotated.format("%H")) ||
disabledSubstitutions.contains(annotated.format("%H.%n")) ||
disabledSubstitutions.contains(annotated.format("%H.%n(%P)"))) {
return;
}
}

if (deleteAnnotation != null) {
if (SubstrateOptions.VerifyNamingConventions.getValue()) {
int modifiers = original.getModifiers();
Expand Down