@Override public String toString() { return desc.getDottedClassName() + "." + value; }
public boolean matches(Class<?> c) { return getDottedClassName().equals(c.getName()); } /**
/** * Get the name of the class in dotted format. * * @return the name of the class in dotted format * * @deprecated use {@link #getDottedClassName()} instead. */ @Deprecated public @DottedClassName String toDottedClassName() { return getDottedClassName(); }
@Override public String toString() { return (isStatic ? "static " : "") + getClassDescriptor().getDottedClassName() + "." + name + signature; }
@Override protected void writeKey(Writer writer, FieldDescriptor key) throws IOException { writer.write(key.getClassDescriptor().getDottedClassName()); writer.write(","); writer.write(key.getName()); writer.write(","); writer.write(key.getSignature()); writer.write(","); XField xField = XFactory.createXField(key); int flags = xField.getAccessFlags() & 0xf; writer.write(String.valueOf(flags)); }
@SuppressWarnings("unchecked") private static <A> Class<A> getQualifierClass(ClassDescriptor typeQualifier) throws ClassNotFoundException { @DottedClassName String className = typeQualifier.getDottedClassName(); if (DEBUG_CLASSLOADING) { System.out.println("Getting qualifier class for " + className); } if (className.startsWith("javax.annotation")) { return (Class<A>) Class.forName(className); } try { Global.getAnalysisCache().getClassAnalysis(ClassData.class, typeQualifier); } catch (CheckedAnalysisException e) { throw new ClassNotFoundException("No class data found for " + className); } ValidatorClassLoader validatorLoader = ValidatorClassLoader.INSTANCE; return (Class<A>) validatorLoader.loadClass(typeQualifier.getDottedClassName()); }
static boolean containsNullness(Collection<AnnotationValue> annotations, NullnessAnnotation nullness) { for (AnnotationValue annotation : annotations) { NullnessAnnotation check = Parser.parse(annotation.getAnnotationClass().getDottedClassName()); if (check == nullness) { return true; } } return false; }
@Override public boolean shouldAnalyzeClass(ClassContext classContext) { String className = classContext.getClassDescriptor().getDottedClassName(); return !InterfaceUtils.isSubtype(className, STRUTS_UTILITY_CLASSES); } }
private void annotateWarningWithTypeQualifier(BugInstance warning, TypeQualifierValue<?> typeQualifierValue) { if (TypeQualifierValue.hasMultipleVariants(typeQualifierValue)) { StringBuilder buf = new StringBuilder(); buf.append("@"); buf.append(typeQualifierValue.typeQualifier.getDottedClassName()); // When there are multiple variants, qualify the type // qualifier with the value indicating which variant. buf.append("("); buf.append(typeQualifierValue.value); buf.append(")"); warning.addString(buf.toString()).describe(StringAnnotation.TYPE_QUALIFIER_ROLE); } else { warning.addClass(typeQualifierValue.typeQualifier).describe(ClassAnnotation.TYPE_QUALIFIER_ROLE); } }
try { if ("java.util.EnumMap".equals(d.getDottedClassName())) { return false; if ("java.util.Map".equals(d.getDottedClassName())) { return true; d = classNameAndInfo.getSuperclassDescriptor(); for (ClassDescriptor i : is) { if ("java.util.Map".equals(i.getDottedClassName())) { return true;
static public void reportMissingClass(ClassDescriptor c) { requireNonNull(c, "argument is null"); if (!analyzingApplicationClass()) { return; } String missing = c.getDottedClassName(); if (missing.length() == 1) { System.out.println(c); } if (skipReportingMissingClass(missing)) { return; } RepositoryLookupFailureCallback lookupFailureCallback = getCurrentLookupFailureCallback(); if (lookupFailureCallback != null) { lookupFailureCallback.reportMissingClass(c); } }
protected UnresolvedXField(FieldDescriptor m) { super(m.getClassDescriptor().getDottedClassName(), m.getName(), m.getSignature(), m.isStatic() ? Const.ACC_STATIC : 0); if (m.getSignature().charAt(0) == '(') { throw new IllegalArgumentException("Bad signature: " + m.getSignature()); } if (XFactory.DEBUG_UNRESOLVED) { System.out.println("Unresolved xmethod: " + this); } }
protected UnresolvedXMethod(MethodDescriptor m) { super(m.getClassDescriptor().getDottedClassName(), m.getName(), m.getSignature(), m.isStatic() ? Const.ACC_STATIC : 0); if (XFactory.DEBUG_UNRESOLVED) { System.out.println("Unresolved xmethod: " + this); } }
public String getFullyQualifiedMethodName(Method method) { return getClassDescriptor().getDottedClassName() + "." + method.getName() + method.getSignature(); }
/** * Determine whether the class descriptor ultimately inherits from * java.lang.Exception * * @param d * class descriptor we want to check * @return true iff the descriptor ultimately inherits from Exception */ private static boolean mightInheritFromException(ClassDescriptor d) { while (d != null) { try { if ("java.lang.Exception".equals(d.getDottedClassName())) { return true; } XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, d); d = classNameAndInfo.getSuperclassDescriptor(); } catch (CheckedAnalysisException e) { return true; // don't know } } return false; }
private boolean extendsConcurrentMap(@DottedClassName String className) { if ("java.util.concurrent.ConcurrentHashMap".equals(className) || className.equals(concurrentMapDescriptor.getDottedClassName())) { return true; } ClassDescriptor c = DescriptorFactory.createClassDescriptorFromDottedClassName(className); Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); try { if (subtypes2.isSubtype(c, concurrentMapDescriptor)) { return true; } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } return false; }
@Override public String toString() { return (isStatic() ? "static " : "") + getClassDescriptor().getDottedClassName() + "." + getName() + " " + getSignature(); }
/** * Factory method. Construct from a FieldDescriptor. * * @param fieldDescriptor * the FieldDescriptor * @return the FieldAnnotation */ public static FieldAnnotation fromFieldDescriptor(FieldDescriptor fieldDescriptor) { return new FieldAnnotation(fieldDescriptor.getClassDescriptor().getDottedClassName(), fieldDescriptor.getName(), fieldDescriptor.getSignature(), fieldDescriptor.isStatic()); }
if (DEBUG_DEREFS) { System.out.println("Checking for guaranteed derefs in " + classContext.getClassDescriptor().getDottedClassName() + "." + method.getName() + method.getSignature()); } catch (CheckedAnalysisException e) { AnalysisContext.logError("Error while checking guaranteed derefs in " + classContext.getClassDescriptor().getDottedClassName() + "." + method.getName() + method.getSignature(), e); } finally { profiler.end(this.getClass());
@Test public void testSimpleName() { ClassDescriptor p = DescriptorFactory.createClassDescriptor("com/bla/Parent"); assertEquals("com/bla/Parent", p.getClassName()); assertEquals("com.bla.Parent", p.getDottedClassName()); assertEquals("Lcom/bla/Parent;", p.getSignature()); assertEquals("com.bla", p.getPackageName()); assertEquals("Parent", p.getSimpleName()); ClassDescriptor c = DescriptorFactory.createClassDescriptor("com/bla/Parent$Child"); assertEquals("com/bla/Parent$Child", c.getClassName()); assertEquals("com.bla.Parent$Child", c.getDottedClassName()); assertEquals("Lcom/bla/Parent$Child;", c.getSignature()); assertEquals("com.bla", c.getPackageName()); assertEquals("Child", c.getSimpleName()); ClassDescriptor a = DescriptorFactory.createClassDescriptor("com/bla/Parent$Child$1"); assertEquals("com/bla/Parent$Child$1", a.getClassName()); assertEquals("com.bla.Parent$Child$1", a.getDottedClassName()); assertEquals("Lcom/bla/Parent$Child$1;", a.getSignature()); assertEquals("com.bla", a.getPackageName()); assertEquals("1", a.getSimpleName()); } }