55import io .arex .agent .bootstrap .model .Mocker ;
66import io .arex .agent .bootstrap .util .AdviceClassesCollector ;
77import io .arex .agent .bootstrap .util .NumberUtil ;
8+ import io .arex .agent .bootstrap .util .ReflectUtil ;
89import io .arex .agent .bootstrap .util .StringUtil ;
910import io .arex .agent .bootstrap .util .ServiceLoader ;
1011import io .arex .inst .runtime .config .Config ;
1819import io .arex .inst .runtime .serializer .StringSerializable ;
1920import io .arex .inst .runtime .util .MockUtils ;
2021
22+ import java .lang .reflect .Method ;
2123import java .util .List ;
2224
2325import java .util .Set ;
@@ -33,6 +35,7 @@ public class EventProcessor {
3335 private static final String CLOCK_METHOD = "currentTimeMillis" ;
3436 public static final String EXCLUDE_MOCK_TYPE = "java.util.HashMap-java.lang.String,java.util.HashSet" ;
3537 private static final AtomicReference <InitializeEnum > INIT_DEPENDENCY = new AtomicReference <>(InitializeEnum .START );
38+ private static final Method FIND_LOADED_METHOD = ReflectUtil .getMethod (ClassLoader .class , "findLoadedClass" , String .class );
3639 private static boolean existJacksonDependency = true ;
3740 static {
3841 try {
@@ -154,19 +157,15 @@ private static void initClass(ClassLoader contextClassLoader) {
154157 continue ;
155158 }
156159 Class .forName (initClass , true , contextClassLoader );
157- } catch (ClassNotFoundException e ) {
160+ } catch (Throwable e ) {
161+ // if the class init fails, the next class init will continue
158162 LOGGER .warn (LogManager .buildTitle ("init.class" ), e );
159163 }
160164 }
161165 }
162166
163167 private static boolean isClassLoaded (String className , ClassLoader classLoader ) {
164- try {
165- Class <?> clazz = classLoader .loadClass (className );
166- return clazz != null ;
167- } catch (ClassNotFoundException e ) {
168- return false ;
169- }
168+ return FIND_LOADED_METHOD == null || ReflectUtil .invoke (FIND_LOADED_METHOD , classLoader , className ) != null ;
170169 }
171170
172171 private static void initLog (ClassLoader contextClassLoader ) {
0 commit comments