Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Improve causalilty reporting for unresolved elements #34

Merged
merged 1 commit into from
Dec 18, 2024
Merged
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 @@ -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