static Map<Class, Int> classSizeInBytes_cache = weakHashMap();
static int classSizeInBytes(Class c) {
Int size = classSizeInBytes_cache.get(c);
if (size == null)
classSizeInBytes_cache.put(c, size = classSizeInBytes_uncached(c));
ret size;
}
static int classSizeInBytes_uncached(Class c) ctex {
L<File> files = cast get(getClassLoader(c), 'files);
S name = c.getName().replace('.', '/') + ".class";
for (File location : files)
if (location.isDirectory()) {
File f = new File(location, name);
if (f.exists()) ret toInt_checked(fileSize(f));
} else if (location.isFile()) pcall {
temp ZipFile zip = new ZipFile(location);
ZipEntry entry = zip.getEntry(name);
if (entry != null) ret toInt_checked(entry.getSize());
}
print(name + " not found in: " + files);
ret -1;
}Began life as a copy of #1012231
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1018925 |
| Snippet name: | classSizeInBytes |
| Eternal ID of this version: | #1018925/10 |
| Text MD5: | 4782674025da33b3b3b82f40419a145d |
| Author: | stefan |
| Category: | javax / byte code |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-10-16 01:58:47 |
| Source code size: | 852 bytes / 24 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 899 / 906 |
| Version history: | 9 change(s) |
| Referenced in: | [show references] |