private FieldDefinition findFieldInType(TypeDefinition typeDef, String uniqueStr) { String[] linkParts = uniqueStr.split("\\|"); if (linkParts.length != 4) return null; String fieldName = linkParts[3]; if (fieldName.trim().length() <= 0) return null; List<FieldDefinition> declaredFields = typeDef.getDeclaredFields(); if (declaredFields == null) return null; boolean isFound = false; for (FieldDefinition declaredField : declaredFields) { isFound = (declaredField != null && fieldName.equals(declaredField.getName())); if (isFound) { if (declaredField.isSynthetic()) { return null; } else { return declaredField; } } } return null; }
public NameVariables(final DecompilerContext context) { _fieldNamesInCurrentType = new ArrayList<>(); for (final FieldDefinition field : context.getCurrentType().getDeclaredFields()) { _fieldNamesInCurrentType.add(field.getName()); } }
public NameVariables(final DecompilerContext context) { _fieldNamesInCurrentType = new ArrayList<>(); for (final FieldDefinition field : context.getCurrentType().getDeclaredFields()) { _fieldNamesInCurrentType.add(field.getName()); } }
public NameVariables(final DecompilerContext context) { _fieldNamesInCurrentType = new ArrayList<>(); for (final FieldDefinition field : context.getCurrentType().getDeclaredFields()) { _fieldNamesInCurrentType.add(field.getName()); } }
public FieldDefinition resolve(final FieldReference field) { final TypeDefinition resolvedType = this.resolve(); if (resolvedType != null) { return MetadataResolver.getField(resolvedType.getDeclaredFields(), field); } return null; }
public FieldDefinition resolve(final FieldReference field) { final TypeDefinition resolvedType = this.resolve(); if (resolvedType != null) { return MetadataResolver.getField(resolvedType.getDeclaredFields(), field); } return null; }
@ClassVisitor(order=VisitOrder.AFTER) public void afterClass(TypeDefinition td, ClassContext cc) { if(implementsCloneable && !hasClone && !referencesClone(td)) { cc.report("CloneableDoesNotImplementClone", td.getDeclaredFields().isEmpty() ? 10 : 0); } }
public FieldDefinition resolve(final FieldReference field) { final TypeDefinition resolvedType = this.resolve(); if (resolvedType != null) { return MetadataResolver.getField(resolvedType.getDeclaredFields(), field); } return null; }
public ClassFields(TypeDefinition td, FieldStats fieldStats, MethodStats methodStats) { this.ms = methodStats; for (FieldDefinition fd : td.getDeclaredFields()) { fields.put(new MemberInfo(fd), fd); int flags = fieldStats.getFlags(fd); if(Flags.testAny(flags, FieldStats.WRITE_CONSTRUCTOR) && !Flags.testAny(flags, FieldStats.WRITE_CLASS | FieldStats.WRITE_PACKAGE | FieldStats.WRITE_OUTSIDE) && !Annotations.hasAnnotation(fd, true)) { initializedInCtor.add(fd); } } }
final FieldDefinition getField(final TypeDefinition declaringType, final FieldReference reference) { TypeDefinition type = declaringType; while (type != null) { final FieldDefinition field = getField(type.getDeclaredFields(), reference); if (field != null) { return field; } final TypeReference baseType = type.getBaseType(); if (baseType == null) { return null; } type = resolve(baseType); } return null; }
final FieldDefinition getField(final TypeDefinition declaringType, final FieldReference reference) { TypeDefinition type = declaringType; while (type != null) { final FieldDefinition field = getField(type.getDeclaredFields(), reference); if (field != null) { return field; } final TypeReference baseType = type.getBaseType(); if (baseType == null) { return null; } type = resolve(baseType); } return null; }
final FieldDefinition getField(final TypeDefinition declaringType, final FieldReference reference) { TypeDefinition type = declaringType; while (type != null) { final FieldDefinition field = getField(type.getDeclaredFields(), reference); if (field != null) { return field; } final TypeReference baseType = type.getBaseType(); if (baseType == null) { return null; } type = resolve(baseType); } return null; }
@Override protected void visitType(TypeDefinition td) { if(!td.isPublic()) return; for(FieldDefinition fd : td.getDeclaredFields()) { if(!fd.isStatic() && !fd.isFinal() && fd.isPublic()) { getOrCreate(td); return; } } }
private static boolean isSwitchMapWrapper(final TypeReference type) { if (type == null) { return false; } final TypeDefinition definition = type instanceof TypeDefinition ? (TypeDefinition) type : type.resolve(); if (definition == null || !definition.isSynthetic() || !definition.isInnerClass()) { return false; } for (final FieldDefinition field : definition.getDeclaredFields()) { if (field.getName().startsWith("$SwitchMap$") && BuiltinTypes.Integer.makeArrayType().equals(field.getFieldType())) { return true; } } return false; } }
private static boolean isSwitchMapWrapper(final TypeReference type) { if (type == null) { return false; } final TypeDefinition definition = type instanceof TypeDefinition ? (TypeDefinition) type : type.resolve(); if (definition == null || !definition.isSynthetic() || !definition.isInnerClass()) { return false; } for (final FieldDefinition field : definition.getDeclaredFields()) { if (field.getName().startsWith("$SwitchMap$") && BuiltinTypes.Integer.makeArrayType().equals(field.getFieldType())) { return true; } } return false; } }
private static boolean isSwitchMapWrapper(final TypeReference type) { if (type == null) { return false; } final TypeDefinition definition = type instanceof TypeDefinition ? (TypeDefinition) type : type.resolve(); if (definition == null || !definition.isSynthetic() || !definition.isInnerClass()) { return false; } for (final FieldDefinition field : definition.getDeclaredFields()) { if (field.getName().startsWith("$SwitchMap$") && BuiltinTypes.Integer.makeArrayType().equals(field.getFieldType())) { return true; } } return false; } }
priority += 10; if(td.getDeclaredFields().isEmpty()) { priority += 10;
private void addTypeMembers(final TypeDeclaration astType, final TypeDefinition type) { for (final FieldDefinition field : type.getDeclaredFields()) { astType.addChild(createField(field), Roles.TYPE_MEMBER); } for (final MethodDefinition method : type.getDeclaredMethods()) { if (method.isConstructor()) { astType.addChild(createConstructor(method), Roles.TYPE_MEMBER); } else { astType.addChild(createMethod(method), Roles.TYPE_MEMBER); } } final List<TypeDefinition> nestedTypes = new ArrayList<>(); for (final TypeDefinition nestedType : type.getDeclaredTypes()) { final TypeReference declaringType = nestedType.getDeclaringType(); if (!nestedType.isLocalClass() && type.isEquivalentTo(declaringType)) { if (nestedType.isAnonymous()) { _typeDeclarations.put(type.getInternalName(), new SoftReference<>(astType)); } else { nestedTypes.add(nestedType); } } } sortNestedTypes(nestedTypes); for (final TypeDefinition nestedType : nestedTypes) { astType.addChild(createTypeNoCache(nestedType), Roles.TYPE_MEMBER); } }
private void addTypeMembers(final TypeDeclaration astType, final TypeDefinition type) { for (final FieldDefinition field : type.getDeclaredFields()) { astType.addChild(createField(field), Roles.TYPE_MEMBER); } for (final MethodDefinition method : type.getDeclaredMethods()) { if (method.isConstructor()) { astType.addChild(createConstructor(method), Roles.TYPE_MEMBER); } else { astType.addChild(createMethod(method), Roles.TYPE_MEMBER); } } final List<TypeDefinition> nestedTypes = new ArrayList<>(); for (final TypeDefinition nestedType : type.getDeclaredTypes()) { final TypeReference declaringType = nestedType.getDeclaringType(); if (!nestedType.isLocalClass() && type.isEquivalentTo(declaringType)) { if (nestedType.isAnonymous()) { _typeDeclarations.put(type.getInternalName(), new SoftReference<>(astType)); } else { nestedTypes.add(nestedType); } } } sortNestedTypes(nestedTypes); for (final TypeDefinition nestedType : nestedTypes) { astType.addChild(createTypeNoCache(nestedType), Roles.TYPE_MEMBER); } }
@ClassVisitor public void visitClass(TypeDefinition td, ClassContext cc) { isSerializable = Types.isInstance(td, "java/io/Serializable"); if(Types.isInstance(td, "java/util/Comparator") && !td.isAnonymous() && !td.isLocalClass() && !isSerializable) { int priority = 0; for(FieldDefinition fd : td.getDeclaredFields()) { TypeReference fieldType = fd.getFieldType(); while(fieldType.isArray()) fieldType = fieldType.getElementType(); if(fieldType.isPrimitive()) continue; if(Types.isInstance(fieldType, "java/io/Serializable")) { priority+=10; if(priority > 20) break; } } cc.report("ComparatorIsNotSerializable", priority, SHOULD_IMPLEMENT.create("java/io/Serializable")); } }