Skip to content

Commit

Permalink
[GR-60604] Improve causality reporting for unresolved elements.
Browse files Browse the repository at this point in the history
PullRequest: graal/19676
  • Loading branch information
cstancu authored and ansalond committed Jan 3, 2025
2 parents f9386f8 + bfcc0bb commit a8db17b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ protected Object loadReferenceTypeLock() {

@Override
protected void maybeEagerlyResolve(int cpi, int bytecode) {
lastUnresolvedElementException = null;
try {
super.maybeEagerlyResolve(cpi, bytecode);
} catch (UnresolvedElementException e) {
Expand All @@ -294,12 +295,19 @@ protected void maybeEagerlyResolve(int cpi, int bytecode) {
* ConstantPool.lookupType() which should return an UnresolvedJavaType which we
* know how to deal with.
*/
lastUnresolvedElementException = e;
} else {
throw e;
}
}
}

/**
* The type resolution error, if any, encountered in the last call to
* {@link #maybeEagerlyResolve}.
*/
UnresolvedElementException lastUnresolvedElementException;

@Override
protected JavaType maybeEagerlyResolve(JavaType type, ResolvedJavaType accessingClass) {
try {
Expand Down Expand Up @@ -594,7 +602,7 @@ private static Class<?>[] signatureToClasses(JavaMethod method) {
}

private void reportUnresolvedElement(String elementKind, String elementAsString) {
reportUnresolvedElement(elementKind, elementAsString, null);
reportUnresolvedElement(elementKind, elementAsString, lastUnresolvedElementException);
}

private void reportUnresolvedElement(String elementKind, String elementAsString, Throwable cause) {
Expand Down

0 comments on commit a8db17b

Please # to comment.