@Override public String signature() { if (signature == null) { signature = ""; if (owner != null) { signature += owner.getType().fullyQualifiedName(); } signature += "#" + name + desc(); } return signature; }
@Override public String signature() { if (signature == null) { signature = ""; if (owner != null) { signature += owner.getType().fullyQualifiedName(); } signature += "#" + name + desc(); } return signature; }
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; // Handle covariance of arrays. if (supType.isTagged(ARRAY)) { return elementType.isSubtypeOf(((ArrayType) supType).elementType()); } if (supType.isTagged(WILDCARD)) { return ((WildCardType) superType).isSubtypeOfBound(this); } // Only possibility to be supertype of array without being an array is to be Object. return "java.lang.Object".equals(supType.fullyQualifiedName()); }
private JavaType getIteratedObjectType(JavaType type, Set<String> knownTypes) { if (type.isUnknown()) { return Symbols.unknownType; } String fullyQualifiedName = type.fullyQualifiedName(); if (knownTypes.contains(fullyQualifiedName)) { // already visited, early return to avoid loops in type hierarchy return Symbols.unknownType; } knownTypes.add(fullyQualifiedName); if (type.is("java.lang.Iterable")) { if (!type.isParameterized()) { // raw type return symbols.objectType; } ParametrizedTypeJavaType ptjt = (ParametrizedTypeJavaType) type; return ptjt.substitution(ptjt.typeParameters().get(0)); } return type.directSuperTypes().stream() .map(superType -> getIteratedObjectType(superType, knownTypes)) .filter(resolved -> !resolved.isUnknown()) .findFirst().orElse(Symbols.unknownType); }
private JavaType getIteratedObjectType(JavaType type, Set<String> knownTypes) { if (type.isUnknown()) { return Symbols.unknownType; } String fullyQualifiedName = type.fullyQualifiedName(); if (knownTypes.contains(fullyQualifiedName)) { // already visited, early return to avoid loops in type hierarchy return Symbols.unknownType; } knownTypes.add(fullyQualifiedName); if (type.is("java.lang.Iterable")) { if (!type.isParameterized()) { // raw type return symbols.objectType; } ParametrizedTypeJavaType ptjt = (ParametrizedTypeJavaType) type; return ptjt.substitution(ptjt.typeParameters().get(0)); } return type.directSuperTypes().stream() .map(superType -> getIteratedObjectType(superType, knownTypes)) .filter(resolved -> !resolved.isUnknown()) .findFirst().orElse(Symbols.unknownType); }
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; // Handle covariance of arrays. if (supType.isTagged(ARRAY)) { return elementType.isSubtypeOf(((ArrayType) supType).elementType()); } if (supType.isTagged(WILDCARD)) { return ((WildCardType) superType).isSubtypeOfBound(this); } // Only possibility to be supertype of array without being an array is to be Object. return "java.lang.Object".equals(supType.fullyQualifiedName()); }
public String getFullyQualifiedName() { if(fullyQualifiedName == null) { String newQualification = ""; if (owner.isPackageSymbol()) { if (!owner.name.isEmpty()) { newQualification = owner.name + "."; } } else if (owner.isTypeSymbol()) { newQualification = owner.type.fullyQualifiedName() + "$"; } else if (owner.isMethodSymbol()) { newQualification = owner.owner.type().fullyQualifiedName() + "$"; } else { throw new IllegalStateException("" + owner); } fullyQualifiedName = newQualification + getInternalName(); } return fullyQualifiedName; }
public String getFullyQualifiedName() { if (bytecodeName != null) { return bytecodeName; } if(fullyQualifiedName == null) { String newQualification = ""; if (owner.isPackageSymbol()) { if (!owner.name.isEmpty()) { newQualification = owner.name + "."; } } else if (owner.isTypeSymbol()) { newQualification = owner.type.fullyQualifiedName() + "$"; } else if (owner.isMethodSymbol()) { newQualification = owner.owner.type().fullyQualifiedName() + "$"; } else { throw new IllegalStateException("" + owner); } fullyQualifiedName = newQualification + getInternalName(); } return fullyQualifiedName; }
public String getFullyQualifiedName() { if (bytecodeName != null) { return bytecodeName; } if(fullyQualifiedName == null) { String newQualification = ""; if (owner.isPackageSymbol()) { if (!owner.name.isEmpty()) { newQualification = owner.name + "."; } } else if (owner.isTypeSymbol()) { newQualification = owner.type.fullyQualifiedName() + "$"; } else if (owner.isMethodSymbol()) { newQualification = owner.owner.type().fullyQualifiedName() + "$"; } else { throw new IllegalStateException("" + owner); } fullyQualifiedName = newQualification + getInternalName(); } return fullyQualifiedName; }
case JavaType.CLASS: case JavaType.UNKNOWN: return org.objectweb.asm.Type.getObjectType(Convert.bytecodeName(javaType.fullyQualifiedName())); case JavaType.ARRAY: JavaType element = ((ArrayJavaType) javaType).elementType;
case JavaType.CLASS: case JavaType.UNKNOWN: return org.objectweb.asm.Type.getObjectType(Convert.bytecodeName(javaType.fullyQualifiedName())); case JavaType.ARRAY: JavaType element = ((ArrayJavaType) javaType).elementType;
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; if (isTagged(ARRAY)) { //Handle covariance of arrays. if(supType.isTagged(ARRAY)) { return ((ArrayType) this).elementType().isSubtypeOf(((ArrayType) supType).elementType()); } //Only possibility to be supertype of array without being an array is to be Object. return "java.lang.Object".equals(supType.fullyQualifiedName()); } else if(isTagged(TYPEVAR)) { return this.equals(superType) || erasure().isSubtypeOf(superType.erasure()); } return false; }
@Override public boolean isSubtypeOf(Type superType) { JavaType supType = (JavaType) superType; if (isTagged(ARRAY)) { //Handle covariance of arrays. if(supType.isTagged(ARRAY)) { return ((ArrayType) this).elementType().isSubtypeOf(((ArrayType) supType).elementType()); } //Only possibility to be supertype of array without being an array is to be Object. return "java.lang.Object".equals(supType.fullyQualifiedName()); } else if(isTagged(TYPEVAR)) { if (supType.isTagged(WILDCARD)) { return ((WildCardType) supType).isSubtypeOfBound(this); } return this.equals(superType) || erasure().isSubtypeOf(superType.erasure()); } return false; }
private boolean isValueOfInvocation(ExpressionTree abstractTypedTree) { if (!abstractTypedTree.is(Kind.METHOD_INVOCATION)) { return false; } Type type = abstractTypedTree.symbolType(); MethodInvocationMatcher valueOfMatcher = MethodInvocationMatcher.create() .typeDefinition(type.fullyQualifiedName()) .name("valueOf") .addParameter(((JavaType) type).primitiveType().fullyQualifiedName()); return valueOfMatcher.matches((MethodInvocationTree) abstractTypedTree); } }
private static boolean isValueOfInvocation(ExpressionTree abstractTypedTree) { if (!abstractTypedTree.is(Kind.METHOD_INVOCATION)) { return false; } Type type = abstractTypedTree.symbolType(); MethodMatcher valueOfMatcher = MethodMatcher.create() .typeDefinition(type.fullyQualifiedName()) .name("valueOf") .addParameter(((JavaType) type).primitiveType().fullyQualifiedName()); return valueOfMatcher.matches((MethodInvocationTree) abstractTypedTree); } }
private static boolean isValueOfInvocation(ExpressionTree abstractTypedTree) { if (!abstractTypedTree.is(Kind.METHOD_INVOCATION)) { return false; } Type type = abstractTypedTree.symbolType(); MethodMatcher valueOfMatcher = MethodMatcher.create() .typeDefinition(type.fullyQualifiedName()) .name("valueOf") .addParameter(((JavaType) type).primitiveType().fullyQualifiedName()); return valueOfMatcher.matches((MethodInvocationTree) abstractTypedTree); } }