Skip to content

Commit

Permalink
fix silent NumberFormatException in SourceMapper #1834
Browse files Browse the repository at this point in the history
#1834

tested by
dom.ASTModelBridgeTests.testBinaryMemberTypeFromAnonymousClassFile1
dom.ASTModelBridgeTests.testBinaryMemberTypeFromAnonymousClassFile2
model.AttachSourceTests.testInnerClass2
model.AttachSourceTests.testInnerClass3
model.AttachSourceTests.testInnerClass4
model.AttachSourceTests.testInnerClass7
model.JavaSearchTests.testLocalVariableReference3
model.ResolveTests.testLocalNameForClassFile
model.ResolveTests.testMethodDeclarationInAnonymous4
model.TypeResolveTests.testResolveTypeInBinary3
  • Loading branch information
jukzi committed Jan 20, 2025
1 parent 834a03e commit 6998fbf
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1568,12 +1568,16 @@ public synchronized ISourceRange mapSource(

char[] fullName = info.getName();
if (isAnonymousClass) {
String eltName = this.binaryTypeOrModule.getParent().getElementName();
eltName = eltName.substring(eltName.lastIndexOf('$') + 1, eltName.length());
String eName = this.binaryTypeOrModule.getParent().getElementName();
String eltName = eName.substring(eName.lastIndexOf('$') + 1, eName.length());
if (eltName.endsWith(".class")) { //$NON-NLS-1$
eltName = eltName.substring(0, eltName.length() - ".class".length()); //$NON-NLS-1$
}
try {
this.anonymousClassName = Integer.parseInt(eltName);
} catch(NumberFormatException e) {
// ignore
throw new RuntimeException("Failed to parse anonymous class name '" //$NON-NLS-1$
+ eName + "'", e); //$NON-NLS-1$
}
}
doFullParse = hasToRetrieveSourceRangesForLocalClass(fullName);
Expand Down

0 comments on commit 6998fbf

Please sign in to comment.