Skip to content

Commit

Permalink
improve causality reporting for unresolved elements
Browse files Browse the repository at this point in the history
(cherry picked from commit 77e3a57)
  • Loading branch information
dougxc authored and Karm committed Dec 20, 2024
1 parent 98be8a1 commit dcd9e5d
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ protected Object loadReferenceTypeLock() {

@Override
protected void maybeEagerlyResolve(int cpi, int bytecode) {
lastUnresolvedElementException = null;
try {
super.maybeEagerlyResolve(cpi, bytecode);
} catch (UnresolvedElementException e) {
Expand All @@ -252,12 +253,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 @@ -541,7 +549,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 dcd9e5d

Please sign in to comment.