Libraryless. Click here for Pure Java version (8113L/46K).
1 | // Idea: Every class loader makes only a single class so they can be |
2 | // garbage collected more easily. |
3 | |
4 | srecord noeq LASMultiClassLoader(ClassLoader parent) is ILASClassLoader { |
5 | settable bool rememberClassBytes; |
6 | |
7 | gettable Map<S, Class> definedClasses = syncMap(); |
8 | |
9 | Lock lock = lock(); |
10 | |
11 | *(Class parent) { this(parent.getClassLoader()); } |
12 | |
13 | public Class<?> defineLASClass(S name, IF0<byte[]> generateClass) { |
14 | lock lock; |
15 | |
16 | try object definedClasses.get(name); |
17 | |
18 | var cl = new InMemoryClassLoader(parent); |
19 | print("Generating class " + name); |
20 | Class c = cl.defineAClass(name, generateClass!); |
21 | definedClasses.put(name, c); |
22 | ret c; |
23 | } |
24 | } |
Began life as a copy of #1035329
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035348 |
Snippet name: | LASMultiClassLoader backup before weak references |
Eternal ID of this version: | #1035348/1 |
Text MD5: | 4a3f62ceea18d22cafbb311500b2fe8b |
Transpilation MD5: | 552cf38743db58a616dd5c2ffc5db969 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-01 19:34:52 |
Source code size: | 701 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 113 / 157 |
Referenced in: | [show references] |