Uses 1311K of libraries. Click here for Pure Java version (5763L/32K).
1 | import org.apache.bcel.classfile.InnerClasses; |
2 | import org.apache.bcel.classfile.InnerClass; |
3 | import org.apache.bcel.generic.ClassGen; |
4 | |
5 | static File bcelFixDuplicateInnerClassesECJBug(File/S jar, S classFileInJar) { |
6 | |
7 | //extractProjectForLocalCompilation(#1033411, userDir("dev/1033411")) |
8 | |
9 | File file = jar; |
10 | S path = classFileInJar; |
11 | JavaClass c = bcel_classInZip(file, path); |
12 | //dm_showText(pnlToString(sortedAlphaNumIC(map(c.getAttributes(), a -> a.getNameIndex() + ": " + a))); |
13 | var ic = firstThat(c.getAttributes(), a -> eq(a.getName(), "InnerClasses")); |
14 | print(ic := className(ic)); |
15 | cast ic to InnerClasses; |
16 | |
17 | InnerClass[] icList = ic.getInnerClasses(); |
18 | //dm_showText(lines(icList)); |
19 | var dup = duplicates(allToString(icList)); |
20 | printMultiSet(dup); |
21 | if (nempty(dup)) { |
22 | print("DUPLICATES!!"); |
23 | Cl<InnerClass> filtered = values(mapToKeys toString(icList)); |
24 | |
25 | //ClassGen cg = new ClassGen(c); |
26 | /*Attribute[] attributesCG = cg.getAttributes(); |
27 | var ic2 = firstThat(attributesCG, a -> eq(a.getName(), "InnerClasses")); |
28 | printVars(ic2 := className(ic), same := (ic == ic2)); |
29 | cast ic2 to InnerClasses;*/ |
30 | |
31 | ic.setInnerClasses(toArrayOfType InnerClass(filtered)); |
32 | c = new ClassGen(c).getJavaClass(); // rotate!? |
33 | printFileInfo(bcelSave(c, newFileInSameDir(file, path))); |
34 | File newJar = appendToBaseName(jar, ".bytecodefix"); |
35 | replaceFileZip2Zip(jar, newJar, path, c.getBytes()); |
36 | printFileInfo(newJar); |
37 | ret newJar; |
38 | } |
39 | null; |
40 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033513 |
Snippet name: | bcelFixDuplicateInnerClassesECJBug |
Eternal ID of this version: | #1033513/8 |
Text MD5: | acdaa9b62a2cf47e01132548c2355f4a |
Transpilation MD5: | 00f159f9f40f01953eed2824898fed3d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-29 09:27:20 |
Source code size: | 1535 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 400 / 478 |
Version history: | 7 change(s) |
Referenced in: | [show references] |