From 31ff465b0d04bb0cb0dbfd89b48ff15e1747c800 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sat, 11 Jul 2026 12:06:28 +0200 Subject: [PATCH] Add null check in ClassRileReader.getMemberTypes() #5186 Calling `InnerClassInfo.getSourceName()` may return null and thus leads to a `NullPointerException` when determining its length. Closes https://github.com/eclipse-jdt/eclipse.jdt.core/issues/5186 --- .../jdt/internal/compiler/classfmt/ClassFileReader.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java index 8f0bc208aa4..0c25e17ef5f 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2026 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -810,10 +810,11 @@ public IBinaryNestedType[] getMemberTypes() { * So I added this extra check to filter out this anonymous class from the * member types. */ + char[] innerSourceName = currentInnerInfo.getSourceName(); if (outerClassNameIdx != 0 && innerNameIndex != 0 && outerClassNameIdx == this.classNameIndex - && currentInnerInfo.getSourceName().length != 0) { + && innerSourceName != null && innerSourceName.length != 0) { memberTypes[memberTypeIndex++] = currentInnerInfo; } }