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: | 828 / 994 |
| Version history: | 16 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1018925 - classSizeInBytes #1031286 - filesFromClassLoader #1031474 - inputStreamForFileInDirOrZip #1031552 - byteCodePathForClass - use getBytecodePathForClass instead #1033452 - inputStreamForClass_forURLClassLoader |