1 | // TODO: unload src libs when not used anymore, |
2 | // especially: old versions |
3 | static Map<File, ClassLoader> hotwire_srcLibsMap = syncMap(); |
4 | |
5 | static JavaXClassLoader hotwire_makeClassLoader_stickyAndSrcLibs(L<File> files) { |
6 | new L<File> files2; |
7 | new Map<S, ClassLoader> parents; // key = package/class name |
8 | for (File f : files) { |
9 | S libID = DiskSnippetCache_fileToLibID(f); |
10 | if (libID != null && isStickyLibrary(libID)) { |
11 | if (addLibrary(libID)) |
12 | print("Retaining sticky library " + libID); |
13 | } else if (f != first(files) && isMarkedAsSrcLib(libID = isFile(f) ? loadTextFileFromZip(f, "progID") : null)) { |
14 | ClassLoader c = hotwire_srcLibsMap.get(f); |
15 | S jname = dropSuffix(".java", getJavaSrcNameOfSrcLib(libID)); |
16 | assertNempty(libID, jname); |
17 | if (c == null) { |
18 | print("Hotwiring src lib " + libID + " / " + f); |
19 | Class cc = hotwireSpecialMainClass(libID, jname.replace("/", "."); |
20 | setCreatorTo(cc, mc()); |
21 | c = cc.getClassLoader(); |
22 | hotwire_srcLibsMap.put(f, c); |
23 | } |
24 | S pkg = beforeSlash(jname); |
25 | print("Linking src lib " + libID + " as " + pkg); |
26 | parents.put(pkg, c); |
27 | } else |
28 | files2.add(f); |
29 | } |
30 | |
31 | JavaXClassLoaderWithParents cl = new(null, files2, myClassLoader()); // progID is set later |
32 | putAll(cl.parentMap, parents); |
33 | ret cl; |
34 | } |
Began life as a copy of #1020749
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025287 |
Snippet name: | hotwire_makeClassLoader_stickyAndSrcLibs (backup) |
Eternal ID of this version: | #1025287/1 |
Text MD5: | 052ab4a9d7248c748ba73fd41b8d9be7 |
Author: | stefan |
Category: | javax / class loading |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-18 18:29:03 |
Source code size: | 1369 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 241 / 254 |
Referenced in: | [show references] |