private MethodDefinition findMethodInType(TypeDefinition typeDef, String uniqueStr) { String[] linkParts = uniqueStr.split("\\|"); if (linkParts.length != 5) return null; String methodName = linkParts[3]; String methodErasedSignature = linkParts[4]; if (methodName.trim().length() <= 0 || methodErasedSignature.trim().length() <= 0) return null; List<MethodDefinition> declaredMethods = typeDef.getDeclaredMethods(); if (declaredMethods == null) return null; boolean isFound = false; for (MethodDefinition declaredMethod : declaredMethods) { isFound = (declaredMethod != null && methodName.equals(declaredMethod.getName())); isFound = (isFound && methodErasedSignature.equals(declaredMethod.getErasedSignature())); if (isFound) { if (declaredMethod.isSynthetic() && !settings.getShowSyntheticMembers()) { return null; } else { return declaredMethod; } } } return null; }
public static boolean isSerializationMethod(MethodDefinition md) { return SERIALIZATION_METHODS.contains(md.getName()); } }
@MethodVisitor public boolean check(MethodDefinition md, TypeDefinition td) { // Skip some autogenerated methods if(md.getName().equals("yyparse") && md.getReturnType().getInternalName().equals("java/lang/Object")) return false; if(md.getName().startsWith("jj") && td.getName().endsWith("TokenManager")) return false; if(md.getName().equals("getNextToken") && md.getSignature().equals("()I")) return false; return true; }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName) { final TypeDefinition declaringType = getDeclaringType(); if (declaringType != null) { return declaringType.appendName(sb, true, false).append('.').append(getName()); } } return sb.append(_name); }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName) { final TypeDefinition declaringType = getDeclaringType(); if (declaringType != null) { return declaringType.appendName(sb, true, false).append('.').append(getName()); } } return sb.append(_name); }
@Override protected StringBuilder appendName(final StringBuilder sb, final boolean fullName, final boolean dottedName) { if (fullName) { final TypeDefinition declaringType = getDeclaringType(); if (declaringType != null) { return declaringType.appendName(sb, true, false).append('.').append(getName()); } } return sb.append(_name); }
private MemberInfo getMistakeFix(MethodDefinition md) { if (md.getName().equals("hashcode") && md.getSignature().equals("()I")) { return new MemberInfo("java/lang/Object", "hashCode", md.getSignature()); } if (md.getName().equals("tostring") && md.getSignature().equals("()Ljava/lang/String;")) { return new MemberInfo("java/lang/Object", "toString", md.getSignature()); } if (md.getName().equals("equal") && md.getSignature().equals("(Ljava/lang/Object;)Z")) { return new MemberInfo("java/lang/Object", "equals", md.getSignature()); } return null; }
@Override public boolean test(final MethodReference reference) { return StringUtilities.equals(reference.getName(), method.getName()); } },
@Override public boolean test(final MethodReference reference) { return StringUtilities.equals(reference.getName(), method.getName()); } },
@Override public boolean test(final MethodReference reference) { return StringUtilities.equals(reference.getName(), method.getName()); } },
@MethodVisitor public boolean check(MethodDefinition md, TypeDefinition td) { if(md.isSynthetic()) return false; if(md.getName().equals("compare") && md.getParameters().size() == 2 && md.getReturnType().getSimpleType() == JvmType.Integer && Types.isInstance(td, "java/util/Comparator")) return true; if(md.getName().equals("compareTo") && md.getParameters().size() == 1 && md.getReturnType().getSimpleType() == JvmType.Integer && Types.isInstance(td, "java/lang/Comparable")) return true; return false; }
@Override public boolean equals(final Object obj) { if (obj instanceof MethodDefinition) { final MethodDefinition other = (MethodDefinition) obj; return StringUtilities.equals(getName(), other.getName()) && StringUtilities.equals(getErasedSignature(), other.getErasedSignature()) && typeNamesMatch(getDeclaringType(), other.getDeclaringType()); } return false; }
public boolean isApplicable(MethodDefinition md) { if (!anno.methodName().isEmpty() && !anno.methodName().equals(md.getName())) return false; if (!anno.methodSignature().isEmpty() && !anno.methodSignature().equals(md.getSignature())) return false; if (anno.minVersion() > 0 && md.getDeclaringType().getCompilerMajorVersion() - 44 < anno.minVersion()) return false; return true; } }
@Override public boolean equals(final Object obj) { if (obj instanceof MethodDefinition) { final MethodDefinition other = (MethodDefinition) obj; return StringUtilities.equals(getName(), other.getName()) && StringUtilities.equals(getErasedSignature(), other.getErasedSignature()) && typeNamesMatch(getDeclaringType(), other.getDeclaringType()); } return false; }
@Override public boolean equals(final Object obj) { if (obj instanceof MethodDefinition) { final MethodDefinition other = (MethodDefinition) obj; return StringUtilities.equals(getName(), other.getName()) && StringUtilities.equals(getErasedSignature(), other.getErasedSignature()) && typeNamesMatch(getDeclaringType(), other.getDeclaringType()); } return false; }
public boolean checkMethod(MethodDefinition md) { if(!md.getReturnType().isArray() && !TYPE_TO_WARNING.containsKey(md.getReturnType().getInternalName())) return false; if(md.getName().equals("getName") && md.getReturnType().getSignature().equals("[B") && md.getParameters().size() == 1 && Types.isInstance(md.getDeclaringType(), "java/sql/ResultSet")) return false; return true; }
private static boolean isSwitchMapMethod(final MethodReference method) { if (method == null) { return false; } final MethodDefinition definition = method instanceof MethodDefinition ? (MethodDefinition) method : method.resolve(); return definition != null && definition.isSynthetic() && definition.isStatic() && definition.isPackagePrivate() && StringUtilities.startsWith(definition.getName(), "$SWITCH_TABLE$") && MetadataResolver.areEquivalent(BuiltinTypes.Integer.makeArrayType(), definition.getReturnType()); }
private static boolean isSwitchMapMethod(final MethodReference method) { if (method == null) { return false; } final MethodDefinition definition = method instanceof MethodDefinition ? (MethodDefinition) method : method.resolve(); return definition != null && definition.isSynthetic() && definition.isStatic() && definition.isPackagePrivate() && StringUtilities.startsWith(definition.getName(), "$SWITCH_TABLE$") && MetadataResolver.areEquivalent(BuiltinTypes.Integer.makeArrayType(), definition.getReturnType()); }
private static boolean isSwitchMapMethod(final MethodReference method) { if (method == null) { return false; } final MethodDefinition definition = method instanceof MethodDefinition ? (MethodDefinition) method : method.resolve(); return definition != null && definition.isSynthetic() && definition.isStatic() && definition.isPackagePrivate() && StringUtilities.startsWith(definition.getName(), "$SWITCH_TABLE$") && MetadataResolver.areEquivalent(BuiltinTypes.Integer.makeArrayType(), definition.getReturnType()); }