Skip to content

Commit

Permalink
Don't ignore NoClassDefFoundError's when linking at build time
Browse files Browse the repository at this point in the history
Closes: oracle#6253
  • Loading branch information
zakkak committed Jun 2, 2023
1 parent 1300858 commit cbade8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ static final class Options {
@APIOption(name = "link-at-build-time-paths")//
@Option(help = "file:doc-files/LinkAtBuildTimePathsHelp.txt")//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> LinkAtBuildTimePaths = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.build());

// FIXME: Remove once we have a proper way to handle missing classes through JVMCI (see https://github.com/oracle/graal/issues/6253)
@Option(help = "Fail fast in case of missing classes when linking at build time.") //
public static final HostedOptionKey<Boolean> LinkAtBuildTimeFailFast = new HostedOptionKey<>(false);
}

private final ClassLoaderSupport classLoaderSupport;
Expand Down Expand Up @@ -122,4 +126,8 @@ private String linkAtBuildTimeReason(Class<?> clazz) {
Set<OptionOrigin> origins = (Set<OptionOrigin>) reason;
return origins.stream().map(OptionOrigin::toString).collect(Collectors.joining(" and "));
}

public boolean failFast() {
return Options.LinkAtBuildTimeFailFast.getValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ protected void maybeEagerlyResolve(int cpi, int bytecode) {
try {
super.maybeEagerlyResolve(cpi, bytecode);
} catch (UnresolvedElementException e) {
if (e.getCause() instanceof LinkageError || e.getCause() instanceof IllegalAccessError) {
Throwable cause = e.getCause();
if (cause instanceof NoClassDefFoundError && linkAtBuildTime && LinkAtBuildTimeSupport.singleton().failFast()) {
reportUnresolvedElement("type", method.format("%H.%n(%P)"), e);
} else if (cause instanceof LinkageError) {
/*
* Ignore LinkageError if thrown from eager resolution attempt. This is usually
* followed by a call to ConstantPool.lookupType() which should return an
Expand Down

0 comments on commit cbade8a

Please sign in to comment.