From 2c5a057fc204307ea4a3db2f633b757ee7a124c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Tue, 7 Jan 2025 08:28:19 +0100 Subject: [PATCH] BinaryTypeBinding: enrich RuntimeException with filename During internal errors it is not clear which file did contain the problematic binary. For example: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/3516 Example output will be like: "java.lang.RuntimeException: RuntimeException loading =P/libGh375.jar|TestGh375.class" --- .../internal/compiler/lookup/BinaryTypeBinding.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java index 08e20333b9e..f50c11f9942 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java @@ -434,7 +434,17 @@ public MethodBinding[] availableMethods() { return availableMethods; } -void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) { +final void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) { + try { + cachePartsFrom2(binaryType, needFieldsAndMethods); + } catch (AbortCompilation e) { + throw e; + } catch (RuntimeException e) { + throw new RuntimeException("RuntimeException loading " + new String(binaryType.getFileName()), e); //$NON-NLS-1$ + } +} + +private void cachePartsFrom2(IBinaryType binaryType, boolean needFieldsAndMethods) { if (!isPrototype()) throw new IllegalStateException(); ReferenceBinding previousRequester = this.environment.requestingType; this.environment.requestingType = this;