(@NotNull Application zeze, @NotNull String handleClassName)
| 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 | } |
no test coverage detected