From 64fa04c77041914346bdce73c2a6bcd474575bbb Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Sun, 15 Dec 2024 13:43:21 +0100 Subject: [PATCH] improve causality reporting for unresolved elements (cherry picked from commit 77e3a5785ab5530d1e2d7496743294aee1155a2f) --- .../svm/hosted/phases/SharedGraphBuilderPhase.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java index 6a9e064b6e3..a844f0aa7f0 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/SharedGraphBuilderPhase.java @@ -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) { @@ -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 { @@ -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) {