Skip to content

Commit

Permalink
Prevent NPE caused by JD-Core errors
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed May 22, 2019
1 parent bdcff86 commit fef37ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class StringBuilderPrinter implements Printer {
public void append(String s) { stringBuffer.append(s); }

protected void printEscape(String s) {
if (unicodeEscape) {
if (unicodeEscape && (s != null)) {
int length = s.length();

for (int i=0; i<length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,21 @@ public void start(int maxLineNumber, int majorVersion, int minorVersion) {
}

// --- Add strings --- //
@Override public void printStringConstant(String constant, String ownerInternalName) {
@Override
public void printStringConstant(String constant, String ownerInternalName) {
if (constant == null) constant = "null";
if (ownerInternalName == null) ownerInternalName = "null";

strings.add(new TypePage.StringData(stringBuffer.length(), constant.length(), constant, ownerInternalName));
super.printStringConstant(constant, ownerInternalName);
}

@Override public void printDeclaration(int flags, String internalTypeName, String name, String descriptor) {
@Override
public void printDeclaration(int flags, String internalTypeName, String name, String descriptor) {
if (internalTypeName == null) internalTypeName = "null";
if (name == null) name = "null";
if (descriptor == null) descriptor = "null";

switch (flags) {
case TYPE_FLAG:
TypePage.DeclarationData data = new TypePage.DeclarationData(stringBuffer.length(), name.length(), internalTypeName, null, null);
Expand All @@ -177,7 +186,12 @@ public void start(int maxLineNumber, int majorVersion, int minorVersion) {
super.printDeclaration(flags, internalTypeName, name, descriptor);
}

@Override public void printReference(int flags, String internalTypeName, String name, String descriptor, String ownerInternalName) {
@Override
public void printReference(int flags, String internalTypeName, String name, String descriptor, String ownerInternalName) {
if (internalTypeName == null) internalTypeName = "null";
if (name == null) name = "null";
if (descriptor == null) descriptor = "null";

switch (flags) {
case TYPE_FLAG:
addHyperlink(new TypePage.HyperlinkReferenceData(stringBuffer.length(), name.length(), newReferenceData(internalTypeName, null, null, ownerInternalName)));
Expand All @@ -192,11 +206,13 @@ public void start(int maxLineNumber, int majorVersion, int minorVersion) {
super.printReference(flags, internalTypeName, name, descriptor, ownerInternalName);
}

@Override public void startLine(int lineNumber) {
@Override
public void startLine(int lineNumber) {
super.startLine(lineNumber);
setLineNumber(textAreaLineNumber, lineNumber);
}
@Override public void endLine() {
@Override
public void endLine() {
super.endLine();
textAreaLineNumber++;
}
Expand Down

0 comments on commit fef37ed

Please sign in to comment.