Libraryless. Click here for Pure Java version (7685L/44K).
// TODO: inner classes will not be found (need to replace . with $) static InputStream inputStreamForClass(Class c) ctex { if (c == null) null; ClassLoader cl = getClassLoader(c); if (cl cast InMemoryClassLoader) { byte[] bytes = cl.getClassBytes(c); if (bytes != null) ret byteArrayInputStream(bytes); } // handle JavaXClassLoader Cl<File> files = cast getOpt(cl, 'files); if (files != null) { S name = c.getName().replace('.', '/') + ".class"; for (File location : files) try object InputStream in = inputStreamForFileInDirOrZip(location, name); fail(name + " not found in: " + files); } ifdef Jython // for patched Jython class loader if (classNameIs(cl, "org.python.core.BytecodeLoader$Loader")) { Map<S, byte[]> rawData = cast getOpt(cl, "rawData"); ret byteArrayInputStreamOrNull(mapGet(rawData, c.getName())); } endifdef ret null; }
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: | 558 / 674 |
Version history: | 16 change(s) |
Referenced in: | [show references] |