import org.apache.bcel.classfile.InnerClasses; import org.apache.bcel.classfile.InnerClass; import org.apache.bcel.generic.ClassGen; static File bcelFixDuplicateInnerClassesECJBug(File/S jar, S classFileInJar) { //extractProjectForLocalCompilation(#1033411, userDir("dev/1033411")) File file = jar; S path = classFileInJar; JavaClass c = bcel_classInZip(file, path); //dm_showText(pnlToString(sortedAlphaNumIC(map(c.getAttributes(), a -> a.getNameIndex() + ": " + a))); var ic = firstThat(c.getAttributes(), a -> eq(a.getName(), "InnerClasses")); print(ic := className(ic)); cast ic to InnerClasses; InnerClass[] icList = ic.getInnerClasses(); //dm_showText(lines(icList)); var dup = duplicates(allToString(icList)); printMultiSet(dup); if (nempty(dup)) { print("DUPLICATES!!"); Cl filtered = values(mapToKeys toString(icList)); //ClassGen cg = new ClassGen(c); /*Attribute[] attributesCG = cg.getAttributes(); var ic2 = firstThat(attributesCG, a -> eq(a.getName(), "InnerClasses")); printVars(ic2 := className(ic), same := (ic == ic2)); cast ic2 to InnerClasses;*/ ic.setInnerClasses(toArrayOfType InnerClass(filtered)); c = new ClassGen(c).getJavaClass(); // rotate!? printFileInfo(bcelSave(c, newFileInSameDir(file, path))); File newJar = appendToBaseName(jar, ".bytecodefix"); replaceFileZip2Zip(jar, newJar, path, c.getBytes()); printFileInfo(newJar); ret newJar; } null; }