MCPcopy Create free account
hub / github.com/e2wugui/zeze / findHandle

Method findHandle

ZezeJava/ZezeJava/src/main/java/Zeze/Hot/HotHandle.java:30–61  ·  view source on GitHub ↗
(@NotNull Application zeze, @NotNull String handleClassName)

Source from the content-addressed store, hash-verified

28 }
29
30 @SuppressWarnings("unchecked")
31 public @NotNull THandle findHandle(@NotNull Application zeze, @NotNull String handleClassName) {
32 var handle = handleCache.get(handleClassName);
33 if (handle != null)
34 return handle;
35
36 lock();
37 try {
38 handle = handleCache.get(handleClassName);
39 if (handle != null)
40 return handle;
41
42 var handleClass = findClass(zeze, handleClassName);
43 var cl = handleClass.getClassLoader();
44 if (HotManager.isHotModule(cl)) {
45 var hotModule = (HotModule)cl;
46 // 这里每次都注册,简化框架关联。
47 classNameWithHotModule.computeIfAbsent(hotModule, (key) -> new HashSet<>()).add(handleClassName);
48 hotModule.stopEvents.add(this::onHotModuleStop);
49 }
50
51 var ctorMethod = handleClass.getDeclaredConstructor((Class<?>[])null);
52 ctorMethod.setAccessible(true);
53 handle = (THandle)ctorMethod.newInstance((Object[])null);
54 handleCache.put(handleClassName, handle);
55 return handle;
56 } catch (ReflectiveOperationException e) {
57 throw Task.forceThrow(e);
58 } finally {
59 unlock();
60 }
61 }
62}

Callers 4

triggerThreadMethod · 0.80
triggerEmbedMethod · 0.80
triggerProcedureMethod · 0.80
findTimerHandleMethod · 0.80

Calls 11

findClassMethod · 0.95
isHotModuleMethod · 0.95
forceThrowMethod · 0.95
getClassLoaderMethod · 0.80
setAccessibleMethod · 0.80
getMethod · 0.65
lockMethod · 0.65
addMethod · 0.65
computeIfAbsentMethod · 0.65
putMethod · 0.65
unlockMethod · 0.65

Tested by

no test coverage detected