public void reload(LazyLoader loader) throws IOException { List<StructClass> lstClasses = new ArrayList<>(); for (StructClass cl : classes) { String oldName = cl.qualifiedName; StructClass newCl; try (DataInputFullStream in = loader.getClassStream(oldName)) { newCl = new StructClass(in, cl.isOwn(), loader); } lstClasses.add(newCl); Link lnk = loader.getClassLink(oldName); loader.removeClassLink(oldName); loader.addClassLink(newCl.qualifiedName, lnk); } classes = lstClasses; }
if (cl.isOwn() && !mapRootClasses.containsKey(cl.qualifiedName)) { if (bDecompileInner) { StructInnerClassesAttribute inner = cl.getAttribute(StructGeneralAttribute.ATTRIBUTE_INNER_CLASSES); if (enclosingClass != null && enclosingClass.isOwn()) { // own classes only Inner existingRec = mapInnerClasses.get(innerName); if (existingRec == null) { node.access = cl.getAccessFlags(); mapRootClasses.put(cl.qualifiedName, node); if (setNestedClasses != null) { StructClass scl = superNode.classStruct; StructInnerClassesAttribute inner = scl.getAttribute(StructGeneralAttribute.ATTRIBUTE_INNER_CLASSES); int[] interfaces = cl.getInterfaces(); if (interfaces.length > 0) { nestedNode.anonymousClassType = new VarType(cl.getInterface(0), true);
StructClass cl = node.classStruct; if (cl.getBytecodeVersion() < CodeConstants.BYTECODE_JAVA_8) { // lambda beginning with Java 8 return; cl.getAttribute(StructGeneralAttribute.ATTRIBUTE_BOOTSTRAP_METHODS); if (bootstrap == null || bootstrap.getMethodsNumber() == 0) { return; // no bootstrap constants in pool for (StructMethod mt : cl.getMethods()) { mt.expandData(); LinkConstant invoke_dynamic = cl.getPool().getLinkConstant(instr.operand(0));
Collections.addAll(queue, currentClass.getInterfaceNames()); for (StructField f : currentClass.getFields()) { setFieldNames.add(f.getName()); StructInnerClassesAttribute attribute = currentClass.getAttribute(StructGeneralAttribute.ATTRIBUTE_INNER_CLASSES); if (attribute != null) { for (StructInnerClassesAttribute.Entry entry : attribute.getEntries()) {
StructClass cl = wrapper.getClassStruct(); int flags = node.type == ClassNode.CLASS_ROOT ? cl.getAccessFlags() : node.access; boolean isDeprecated = cl.hasAttribute(StructGeneralAttribute.ATTRIBUTE_DEPRECATED); boolean isSynthetic = (flags & CodeConstants.ACC_SYNTHETIC) != 0 || cl.hasAttribute(StructGeneralAttribute.ATTRIBUTE_SYNTHETIC); boolean isEnum = DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM) && (flags & CodeConstants.ACC_ENUM) != 0; boolean isInterface = (flags & CodeConstants.ACC_INTERFACE) != 0; int[] interfaces = cl.getInterfaces(); if (interfaces.length > 0) { buffer.append(isInterface ? "extends " : "implements "); buffer.append(ExprProcessor.getCastTypeName(new VarType(cl.getInterface(i), true)));
private static boolean isAnonymous(StructClass cl, StructClass enclosingCl) { int[] interfaces = cl.getInterfaces(); if (interfaces.length > 0) { boolean hasNonTrivialSuperClass = cl.superClass != null && !VarType.VARTYPE_OBJECT.equals(new VarType(cl.superClass.getString(), true)); ConstantPool pool = enclosingCl.getPool(); StructEnclosingMethodAttribute attribute = cl.getAttribute(StructGeneralAttribute.ATTRIBUTE_ENCLOSING_METHOD); String enclosingMethod = attribute != null ? attribute.getMethodName() : null; for (StructMethod mt : enclosingCl.getMethods()) { if (enclosingMethod != null && !enclosingMethod.equals(mt.getName())) { continue;
for (StructMethod md : cl.getMethods()) { setMethodNames.add(md.getName()); VBStyleCollection<StructMethod, String> methods = cl.getMethods(); for (int i = 0; i < methods.size(); i++) { if (!cl.isOwn() || mt.hasModifier(CodeConstants.ACC_NATIVE)) { if (!cl.isOwn()) { return; for (StructField fd : cl.getFields()) { setFieldNames.add(fd.getName()); for (StructField fd : cl.getFields()) { if (helper.toBeRenamed(IIdentifierRenamer.Type.ELEMENT_FIELD, classOldFullName, fd.getName(), fd.getDescriptor())) { String newName;
if (!cl.isOwn()) { continue; boolean isInterface = clStr.hasModifier(CodeConstants.ACC_INTERFACE); boolean found_parent = false; for (String ifName : clStr.getInterfaceNames()) { StructClass clParent = classes.get(ifName); if (clParent != null) {
for (StructField fd : cl.getFields()) { boolean hide = fd.isSynthetic() && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_SYNTHETIC) || wrapper.getHiddenMembers().contains(InterpreterUtil.makeUniqueKey(fd.getName(), fd.getDescriptor())); for (StructMethod mt : cl.getMethods()) { boolean hide = mt.isSynthetic() && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_SYNTHETIC) || mt.hasModifier(CodeConstants.ACC_BRIDGE) && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_BRIDGE) || if (inner.type == ClassNode.CLASS_MEMBER) { StructClass innerCl = inner.classStruct; boolean isSynthetic = (inner.access & CodeConstants.ACC_SYNTHETIC) != 0 || innerCl.isSynthetic(); boolean hide = isSynthetic && DecompilerContext.getOption(IFernflowerPreferences.REMOVE_SYNTHETIC) || wrapper.getHiddenMembers().contains(innerCl.qualifiedName);
private static boolean hideConstructor(ClassNode node, boolean init, boolean throwsExceptions, int paramCount, int methodAccessFlags) { if (!init || throwsExceptions || paramCount > 0 || !DecompilerContext.getOption(IFernflowerPreferences.HIDE_DEFAULT_CONSTRUCTOR)) { return false; } ClassWrapper wrapper = node.getWrapper(); StructClass cl = wrapper.getClassStruct(); int classAccesFlags = node.type == ClassNode.CLASS_ROOT ? cl.getAccessFlags() : node.access; boolean isEnum = cl.hasModifier(CodeConstants.ACC_ENUM) && DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_ENUM); // default constructor requires same accessibility flags. Exception: enum constructor which is always private if(!isEnum && ((classAccesFlags & ACCESSIBILITY_FLAGS) != (methodAccessFlags & ACCESSIBILITY_FLAGS))) { return false; } int count = 0; for (StructMethod mt : cl.getMethods()) { if (CodeConstants.INIT_NAME.equals(mt.getName())) { if (++count > 1) { return false; } } } return true; }
if ((child.access & CodeConstants.ACC_SYNTHETIC) != 0 || cl.isSynthetic()) { child.simpleName = "SyntheticClass_" + (++synthetics); child.simpleName = "NamelessClass_" + (++nameless); child.namelessConstructorStub = !cl.hasModifier(CodeConstants.ACC_STATIC) && cl.getMethods().size() + cl.getFields().size() == 0; else if (child.type == ClassNode.CLASS_ANONYMOUS && (child.access & CodeConstants.ACC_SYNTHETIC) != 0 || cl.isSynthetic()) { child.namelessConstructorStub = !cl.hasModifier(CodeConstants.ACC_STATIC) && cl.getMethods().size() + cl.getFields().size() == 0;
if (child.classStruct.isSynthetic()) { continue; StructEnclosingMethodAttribute attr = child.classStruct.getAttribute(StructGeneralAttribute.ATTRIBUTE_ENCLOSING_METHOD); if (attr != null && attr.getMethodName() != null && node.classStruct.qualifiedName.equals(attr.getClassName()) && node.classStruct.getMethod(attr.getMethodName(), attr.getMethodDescriptor()) != null) { child.enclosingMethod = InterpreterUtil.makeUniqueKey(attr.getMethodName(), attr.getMethodDescriptor()); continue;
public boolean hasField(String name, String descriptor) { return getField(name, descriptor) != null; }
if (child.classStruct.hasModifier(CodeConstants.ACC_SYNTHETIC)) { continue; (StructEnclosingMethodAttribute)child.classStruct.getAttribute("EnclosingMethod"); if (attr != null && attr.getMethodName() != null && node.classStruct.qualifiedName.equals(attr.getClassName()) && node.classStruct.getMethod(attr.getMethodName(), attr.getMethodDescriptor()) != null) { child.enclosingMethod = InterpreterUtil.makeUniqueKey(attr.getMethodName(), attr.getMethodDescriptor()); continue;
boolean testMode = DecompilerContext.getOption(IFernflowerPreferences.UNIT_TEST_MODE); for (StructMethod mt : classStruct.getMethods()) { DecompilerContext.getLogger().startMethod(mt.getName() + " " + mt.getDescriptor()); classStruct.getFields().forEach(f -> namesCollector.addName(f.getName())); varProc.refreshVarNames(namesCollector);
VBStyleCollection<Instruction, Integer> instructions = new VBStyleCollection<>(); int bytecode_version = classStruct.getBytecodeVersion(); if (classStruct.isVersionGE_1_7()) { // instruction unused in Java 6 and before operands.add(in.readUnsignedShort()); in.discard(2);
public void processBlock(BasicBlockStatement stat, PrimitiveExprsList data, StructClass cl) { ConstantPool pool = cl.getPool(); StructBootstrapMethodsAttribute bootstrap = cl.getAttribute(StructGeneralAttribute.ATTRIBUTE_BOOTSTRAP_METHODS);
public void setDebugVarNames(Map<Integer, String> mapDebugVarNames) { if (varVersions == null) { return; } Map<Integer, Integer> mapOriginalVarIndices = varVersions.getMapOriginalVarIndices(); List<VarVersionPair> listVars = new ArrayList<>(mapVarNames.keySet()); listVars.sort(Comparator.comparingInt(o -> o.var)); Map<String, Integer> mapNames = new HashMap<>(); for (VarVersionPair pair : listVars) { String name = mapVarNames.get(pair); Integer index = mapOriginalVarIndices.get(pair.var); if (index != null) { String debugName = mapDebugVarNames.get(index); if (debugName != null && TextUtil.isValidIdentifier(debugName, method.getClassStruct().getBytecodeVersion())) { name = debugName; } } Integer counter = mapNames.get(name); mapNames.put(name, counter == null ? counter = 0 : ++counter); if (counter > 0) { name += String.valueOf(counter); } mapVarNames.put(pair, name); } }
for (StructField fd : cl.getFields()) { String descriptor = fd.getDescriptor(); if (fd.isSynthetic() && descriptor.equals("[L" + cl.qualifiedName + ";")) {