Skip to content

Commit c3a7241

Browse files
authored
Merge pull request #40 from blackducksoftware/dev/devm/handle-exceptions
Handle Malformed Classes Exception
2 parents 07751d5 + 8f2cb64 commit c3a7241

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

method-analyzer-core/src/main/java/com/blackduck/method/analyzer/core/MethodUseAnalyzer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ public Path analyze(Path sourceDirectory, Path outputDirectory, String outputFil
138138
} else {
139139
throw e;
140140
}
141+
} catch (IndexOutOfBoundsException | ClassFormatError | NegativeArraySizeException e) {
142+
//IDETECT-4924 Handle malformed classes properly
143+
brokenFiles.put(classFile, "Malformed class structure: " + Strings.nullToEmpty(e.getMessage()));
141144
}
142145
}
143146

method-analyzer-core/src/main/java/com/blackduck/method/analyzer/core/bytecode/ClassMethodReferenceVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ private Type getReturnType(String descriptor) {
221221

222222
try {
223223
return Type.getType(descriptor);
224-
} catch (StringIndexOutOfBoundsException e2) {
224+
} catch (StringIndexOutOfBoundsException | IllegalArgumentException e2) {
225225
// IDETECT-3909 This can occur for malformed signatures which are just the type, not the method, for
226226
// an unknown reason
227227
logger.warn("Malformed method descriptor, skipping reference processing: {}:{} ({})", currentClassName, currentMethodName, descriptor);
228228

229-
return Type.getType(descriptor);
229+
return Type.getType(Object.class);
230230
}
231231
}
232232
}

0 commit comments

Comments
 (0)