fix: inst#getAllLoadedClasses() may cause NullPointerException when search class(IBM jvm 1.7) (#1840)

This commit is contained in:
qxo 2021-07-04 14:21:12 +08:00 committed by GitHub
parent dca9bc3149
commit 5f31bbff97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,9 @@ public class SearchUtils {
}
final Set<Class<?>> matches = new HashSet<Class<?>>();
for (Class<?> clazz : inst.getAllLoadedClasses()) {
if (clazz == null) {
continue;
}
if (classNameMatcher.matching(clazz.getName())) {
matches.add(clazz);
}
@ -107,6 +110,9 @@ public class SearchUtils {
public static Set<Class<?>> searchSubClass(Instrumentation inst, Set<Class<?>> classSet) {
final Set<Class<?>> matches = new HashSet<Class<?>>();
for (Class<?> clazz : inst.getAllLoadedClasses()) {
if (clazz == null) {
continue;
}
for (Class<?> superClass : classSet) {
if (superClass.isAssignableFrom(clazz)) {
matches.add(clazz);