Libraryless. Click here for Pure Java version (7685L/44K).
1 | // TODO: inner classes will not be found (need to replace . with $) |
2 | static InputStream inputStreamForClass(Class c) ctex { |
3 | if (c == null) null; |
4 | |
5 | ClassLoader cl = getClassLoader(c); |
6 | |
7 | if (cl cast InMemoryClassLoader) { |
8 | byte[] bytes = cl.getClassBytes(c); |
9 | if (bytes != null) |
10 | ret byteArrayInputStream(bytes); |
11 | } |
12 | |
13 | // handle JavaXClassLoader |
14 | Cl<File> files = cast getOpt(cl, 'files); |
15 | if (files != null) { |
16 | S name = c.getName().replace('.', '/') + ".class"; |
17 | for (File location : files) |
18 | try object InputStream in = inputStreamForFileInDirOrZip(location, name); |
19 | fail(name + " not found in: " + files); |
20 | } |
21 | |
22 | ifdef Jython |
23 | // for patched Jython class loader |
24 | if (classNameIs(cl, "org.python.core.BytecodeLoader$Loader")) { |
25 | Map<S, byte[]> rawData = cast getOpt(cl, "rawData"); |
26 | ret byteArrayInputStreamOrNull(mapGet(rawData, c.getName())); |
27 | } |
28 | endifdef |
29 | |
30 | ret null; |
31 | } |
Began life as a copy of #1012229
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jcllbfdqhrgy, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1012231 |
Snippet name: | inputStreamForClass |
Eternal ID of this version: | #1012231/17 |
Text MD5: | a86e6020b88e1a95b5d3f0f3e3c6df00 |
Transpilation MD5: | d5a800b4cb2795a01a98feb54f6b8556 |
Author: | stefan |
Category: | javax / byte code |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-29 21:06:51 |
Source code size: | 953 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 560 / 676 |
Version history: | 16 change(s) |
Referenced in: | [show references] |