Libraryless. Click here for Pure Java version (4543L/27K).
1 | static class JavaXClassLoaderWithParents extends JavaXClassLoaderWithParent { |
2 | // keys: full class names or package names |
3 | // (inner classes are automatically included) |
4 | NavigableMap<S, ClassLoader> parentMap = syncTreeMap(); |
5 | |
6 | *(S progID, L<File> files, ClassLoader virtualParent) { |
7 | super(progID, files, virtualParent); |
8 | } |
9 | |
10 | *(S progID, L<File> files) { |
11 | super(progID, files, null); |
12 | } |
13 | |
14 | protected Class<?> findClass(S name) throws ClassNotFoundException { |
15 | ClassLoader parent = findParentForClass(name); |
16 | if (parent != null) |
17 | ret parent.loadClass(name); |
18 | else |
19 | ret super.findClass(name); |
20 | } |
21 | |
22 | ClassLoader findParentForClass(S name) { |
23 | ClassLoader cl = parentMap.get(name); |
24 | if (cl != null) ret cl; |
25 | S s = parentMap.floorKey(name); |
26 | if (startsWithOneOf(name, s + "$", s + ".")) |
27 | ret parentMap.get(s); |
28 | null; |
29 | } |
30 | |
31 | void addParent(S name, ClassLoader loader) { |
32 | parentMap.put(name, loader); |
33 | } |
34 | } |
Began life as a copy of #1011216
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019855 |
Snippet name: | JavaXClassLoaderWithParents - takes certain classes from different parents, in addition to the virtualParent for libraries |
Eternal ID of this version: | #1019855/10 |
Text MD5: | 8098f9b409046db3b3dc9841eb1d4adf |
Transpilation MD5: | 66a675a26ef91ed9d327eaac8a7966bd |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-02 15:40:56 |
Source code size: | 998 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 350 / 926 |
Version history: | 9 change(s) |
Referenced in: | [show references] |