Skip to content

Commit

Permalink
Prevent NPE if source method does not have a line number table
Browse files Browse the repository at this point in the history
  • Loading branch information
tvoc-gs authored and mrjameshamilton committed Jul 3, 2023
1 parent 5694a24 commit 3063e20
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ private static class MyLineFixer implements AttributeVisitor

public void visitCodeAttribute(Clazz sourceClass, Method sourceMethod, CodeAttribute sourceMethodCodeAttribute) {
LineNumberTableAttribute sourceMethodLineNumberTableAttribute = (LineNumberTableAttribute) sourceMethodCodeAttribute.getAttribute(sourceClass, Attribute.LINE_NUMBER_TABLE);
int lowestLineNumber = sourceMethodLineNumberTableAttribute.getLowestLineNumber();
int highestLineNumber = sourceMethodLineNumberTableAttribute.getHighestLineNumber();
int lowestLineNumber = sourceMethodLineNumberTableAttribute == null
? 0
: sourceMethodLineNumberTableAttribute.getLowestLineNumber();
int highestLineNumber = sourceMethodLineNumberTableAttribute == null
? 0
: sourceMethodLineNumberTableAttribute.getHighestLineNumber();

String newSource = initializeLineNumberInfoSource(sourceClass,
sourceMethod,
Expand Down

0 comments on commit 3063e20

Please sign in to comment.