public ClassDescriptor getClassDescriptor() { return DescriptorFactory.createClassDescriptorFromDottedClassName(className); }
/** * @deprecated Use * {@link DescriptorFactory#createClassDescriptorFromDottedClassName(String)} * instead */ @Deprecated public static ClassDescriptor createClassDescriptorFromDottedClassName(String dottedClassName) { return DescriptorFactory.createClassDescriptorFromDottedClassName(dottedClassName); }
public static Set<XMethod> resolveVirtualMethodCallTargets(String receiverClassName, String methodName, String methodSig, boolean receiverTypeIsExact, boolean invokeSpecial) throws ClassNotFoundException { ClassDescriptor receiverDesc = DescriptorFactory.createClassDescriptorFromDottedClassName(receiverClassName); return resolveVirtualMethodCallTargets(receiverDesc, methodName, methodSig, receiverTypeIsExact, invokeSpecial); }
public static ClassDescriptor createClassDescriptor(JavaClass c) { return DescriptorFactory.createClassDescriptorFromDottedClassName(c.getClassName()); }
@Override protected void addMethodAnnotation(@DottedClassName String cName, String mName, String mSig, boolean isStatic, DefaultEncodingAnnotation annotation) { super.addMethodAnnotation(cName, mName, mSig, isStatic, annotation); classes.add(DescriptorFactory.createClassDescriptorFromDottedClassName(cName)); }
static XClass getXClassFromDottedClassName(@DottedClassName String c) throws CheckedAnalysisException { return getXClass(DescriptorFactory.createClassDescriptorFromDottedClassName(c)); }
/** * Determine whether one class (or reference type) is a subtype of another. * * @param clsName * the name of the class or reference type * @param possibleSupertypeClassName * the name of the possible superclass * @return true if clsName is a subtype of possibleSupertypeClassName, false * if not */ public static boolean isSubtype(@DottedClassName String clsName, @DottedClassName String possibleSupertypeClassName) throws ClassNotFoundException { Subtypes2 subtypes2 = Global.getAnalysisCache().getDatabase(Subtypes2.class); return subtypes2.isSubtype(DescriptorFactory.createClassDescriptorFromDottedClassName(clsName), DescriptorFactory.createClassDescriptorFromDottedClassName(possibleSupertypeClassName)); }
@Override public AnnotatedObject getContainingScope() { // TODO Auto-generated method stub return AnalysisContext.currentXFactory().getXClass( DescriptorFactory.createClassDescriptorFromDottedClassName(getClassName())); }
public static boolean instanceOf(@DottedClassName String dottedSubtype, @DottedClassName String dottedSupertype) { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); ClassDescriptor subDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSubtype); ClassDescriptor superDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSupertype); try { return subtypes2.isSubtype(subDescriptor, superDescriptor); } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); return false; } }
static byte[] loadClassData(String name) throws CheckedAnalysisException { ClassDescriptor d = DescriptorFactory.createClassDescriptorFromDottedClassName(name); ClassData data = Global.getAnalysisCache().getClassAnalysis(ClassData.class, d); return data.getData(); } static class Data {
/** * Lookup a class's source file * * @param dottedClassName * the name of the class * @return the source file for the class, or * {@link SourceLineAnnotation#UNKNOWN_SOURCE_FILE} if unable to * determine */ public final String lookupSourceFile(@Nonnull @DottedClassName String dottedClassName) { requireNonNull(dottedClassName, "className is null"); try { XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, DescriptorFactory.createClassDescriptorFromDottedClassName(dottedClassName)); String name = xClass.getSource(); if (name == null) { return SourceLineAnnotation.UNKNOWN_SOURCE_FILE; } return name; } catch (CheckedAnalysisException e) { return SourceLineAnnotation.UNKNOWN_SOURCE_FILE; } }
/** * Return whether or not the given class is an application class. * * @param className * name of a class * @return true if the class is an application class, false if not an * application class or if the class cannot be located */ public boolean isApplicationClass(@DottedClassName String className) { // try { // JavaClass javaClass = lookupClass(className); // return isApplicationClass(javaClass); // } catch (ClassNotFoundException e) { // AnalysisContext.reportMissingClass(e); // return false; // } ClassDescriptor classDesc = DescriptorFactory.createClassDescriptorFromDottedClassName(className); return getSubtypes2().isApplicationClass(classDesc); }
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; }
public static boolean instanceOf(ClassDescriptor subDescriptor, @DottedClassName String dottedSupertype) { Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); ClassDescriptor superDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSupertype); try { return subtypes2.isSubtype(subDescriptor, superDescriptor); } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); return false; } }
@Override public void parse(final ClassNameAndSuperclassInfo.Builder builder) throws InvalidClassFileFormatException { builder.setCodeBaseEntry(codeBaseEntry); builder.setAccessFlags(javaClass.getAccessFlags()); ClassDescriptor classDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(javaClass.getClassName()); if (expectedClassDescriptor != null && expectedClassDescriptor.equals(classDescriptor)) { throw new InvalidClassFileFormatException("Expected " + expectedClassDescriptor, classDescriptor, codeBaseEntry); } builder.setClassDescriptor(classDescriptor); builder.setSuperclassDescriptor(DescriptorFactory.createClassDescriptorFromDottedClassName(javaClass.getSuperclassName())); String[] allInterfaces = javaClass.getInterfaceNames(); ClassDescriptor[] allInterfaceDescriptiors; if (allInterfaces.length == 0) { allInterfaceDescriptiors = ClassDescriptor.EMPTY_ARRAY; } else { allInterfaceDescriptiors = new ClassDescriptor[allInterfaces.length]; for (int i = 0; i < allInterfaces.length; i++) { allInterfaceDescriptiors[i] = DescriptorFactory.createClassDescriptorFromDottedClassName(allInterfaces[i]); } } builder.setInterfaceDescriptorList(allInterfaceDescriptiors); }
public static boolean instanceOf(JavaClass subtype, @DottedClassName String dottedSupertype) { if (subtype.getClassName().equals(dottedSupertype) || subtype.getSuperclassName().equals(dottedSupertype)) { return true; } if ("java.lang.Object".equals(subtype.getSuperclassName()) && subtype.getInterfaceIndices().length == 0) { return false; } Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2(); ClassDescriptor subDescriptor = DescriptorFactory.createClassDescriptor(subtype); ClassDescriptor superDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(dottedSupertype); try { return subtypes2.isSubtype(subDescriptor, superDescriptor); } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); return false; } }
/** * Look up the method referenced by given InvokeInstruction. This method * does <em>not</em> look for implementations in super or subclasses * according to the virtual dispatch rules. * * @param inv * the InvokeInstruction * @param cpg * the ConstantPoolGen used by the class the InvokeInstruction * belongs to * @param chooser * JavaClassAndMethodChooser to use to pick the method from among * the candidates * @return the JavaClassAndMethod, or null if no such method is defined in * the class */ public static XMethod findExactMethod(InvokeInstruction inv, ConstantPoolGen cpg, JavaClassAndMethodChooser chooser) { String className = inv.getClassName(cpg); String methodName = inv.getName(cpg); String methodSig = inv.getSignature(cpg); XMethod result = findMethod(DescriptorFactory.createClassDescriptorFromDottedClassName(className), methodName, methodSig, inv instanceof INVOKESTATIC); return thisOrNothing(result, chooser); }
ClassDescriptor lhsDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(expectedType .getClassName()); ClassDescriptor rhsDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(actualType .getClassName());
boolean definedInSuperClassOrInterface(JavaClass clazz, String method) throws ClassNotFoundException { if (clazz == null) { return false; } JavaClass superClass = clazz.getSuperClass(); if (superClass == null) { return false; } try { XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, DescriptorFactory.createClassDescriptorFromDottedClassName(superClass.getClassName())); if (xClass.hasStubs()) { return true; } } catch (CheckedAnalysisException e) { return true; } if (definedInThisClassOrSuper(superClass, method)) { return true; } for (JavaClass i : clazz.getInterfaces()) { if (definedInThisClassOrSuper(i, method)) { return true; } } return false; }
try { if (subtypes2.isSubtype(methodDescriptor.getClassDescriptor(), DescriptorFactory.createClassDescriptorFromDottedClassName(obligation.getClassName()))) { return;