Skip to content

Commit d01ff88

Browse files
committed
svm: add DisableSubstitutionReturnTypeCheck option [GR-48152]
1 parent 69c5dd7 commit d01ff88

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
150150
@Option(help = "Deprecated", type = User)//
151151
static final HostedOptionKey<Boolean> AllowIncompleteClasspath = new HostedOptionKey<>(false);
152152

153+
@Option(help = "Disable substitution return type checking", type = Debug, deprecated = true, stability = OptionStability.EXPERIMENTAL, deprecationMessage = "This option will be removed soon and the return type check will be mandatory.")//
154+
public static final HostedOptionKey<Boolean> DisableSubstitutionReturnTypeCheck = new HostedOptionKey<>(false);
155+
153156
@SuppressWarnings("all")
154157
private static boolean areAssertionsEnabled() {
155158
boolean assertsEnabled = false;

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/substitute/AnnotationSubstitutionProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,8 @@ private ResolvedJavaMethod findOriginalMethod(Executable annotatedMethod, Class<
854854
Method originalMethod = originalClass.getDeclaredMethod(originalName, originalParams);
855855

856856
guarantee(Modifier.isStatic(annotatedMethod.getModifiers()) == Modifier.isStatic(originalMethod.getModifiers()), "Static modifier mismatch: %s, %s", annotatedMethod, originalMethod);
857-
guarantee(getTargetClass(((Method) annotatedMethod).getReturnType()).equals(originalMethod.getReturnType()),
857+
858+
guarantee(NativeImageOptions.DisableSubstitutionReturnTypeCheck.getValue() || getTargetClass(((Method) annotatedMethod).getReturnType()).equals(originalMethod.getReturnType()),
858859
"Return type mismatch:%n %s%n %s", annotatedMethod, originalMethod);
859860
return metaAccess.lookupJavaMethod(originalMethod);
860861

0 commit comments

Comments
 (0)