/** * Get the RepositoryLookupFailureCallback. * * @return the RepositoryLookupFailureCallback */ public RepositoryLookupFailureCallback getLookupFailureCallback() { return analysisContext.getLookupFailureCallback(); }
public void logAnError(String msg) { RepositoryLookupFailureCallback lookupFailureCallback = getLookupFailureCallback(); if (lookupFailureCallback != null) { lookupFailureCallback.logError(msg); } }
private static @CheckForNull RepositoryLookupFailureCallback getCurrentLookupFailureCallback() { AnalysisContext currentAnalysisContext2 = currentAnalysisContext(); if (currentAnalysisContext2 == null) { return null; } if (currentAnalysisContext2.missingClassWarningsSuppressed) { return null; } return currentAnalysisContext2.getLookupFailureCallback(); }
/** * Write an interprocedural property database. * * @param <DatabaseType> * actual type of the database * @param <KeyType> * type of key (e.g., method or field) * @param <Property> * type of properties stored in the database * @param database * the database * @param fileName * name of database file * @param description * description of the database */ public <DatabaseType extends PropertyDatabase<KeyType, Property>, KeyType extends FieldOrMethodDescriptor, Property> void storePropertyDatabase( DatabaseType database, String fileName, String description) { try { File dbFile = new File(getDatabaseOutputDir(), fileName); if (DEBUG) { System.out.println("Writing " + description + " to " + dbFile.getPath() + "..."); } database.writeToFile(dbFile.getPath()); } catch (IOException e) { getLookupFailureCallback().logError("Error writing " + description, e); } }
return database; } catch (IOException e) { getLookupFailureCallback().logError("Error loading " + description, e); } catch (PropertyDatabaseFormatException e) { getLookupFailureCallback().logError("Invalid " + description, e);
getLookupFailureCallback().logError("Error loading " + description, e); } catch (PropertyDatabaseFormatException e) { getLookupFailureCallback().logError("Invalid " + description, e);
public static void logMissingAnnotationClass(MissingClassException e) { ClassDescriptor c = e.getClassDescriptor(); if (c.getClassName().startsWith("javax.annotation")) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(c); } }
/** * Constructor. * * @param methodGen * the method to build a CFG for */ public BetterCFGBuilder2(@Nonnull MethodDescriptor descriptor, @Nonnull MethodGen methodGen) { this.methodGen = methodGen; this.cpg = methodGen.getConstantPool(); IAnalysisCache analysisCache = Global.getAnalysisCache(); StandardTypeMerger merger = null; ExceptionSetFactory exceptionSetFactory; try { exceptionSetFactory = analysisCache.getMethodAnalysis(ExceptionSetFactory.class, descriptor); merger = new StandardTypeMerger( AnalysisContext.currentAnalysisContext() .getLookupFailureCallback(), exceptionSetFactory); } catch (CheckedAnalysisException e) { AnalysisContext.logError("Unable to generate exceptionSetFactory for " + descriptor, e); } this.exceptionHandlerMap = new ExceptionHandlerMap(methodGen, merger); this.usedInstructionSet = new BitSet(); this.jsrSubroutineMap = new IdentityHashMap<>(); this.subroutineWorkList = new LinkedList<>(); }
LoadedFieldSet loadedFieldSet = getLoadedFieldSet(analysisCache, descriptor); ValueNumberAnalysis analysis = new ValueNumberAnalysis(methodGen, dfs, loadedFieldSet, AnalysisContext .currentAnalysisContext().getLookupFailureCallback()); analysis.setMergeTree(new MergeTree(analysis.getFactory())); CFG cfg = getCFG(analysisCache, descriptor);
RepositoryLookupFailureCallback lookupFailureCallback = currentAnalysisContext2.getLookupFailureCallback(); if (lookupFailureCallback != null) { lookupFailureCallback.logError(msg, e);
AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e.getClassNotFoundException()); } catch (CheckedAnalysisException e) { AnalysisContext.logError("Error looking up annotation class " + typeQualifier.toDottedClassName(), e);
.traverseSupertypesDepthFirst(xmethod.getClassDescriptor(), visitor); } catch (ClassNotFoundException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e); return Collections.<TypeQualifierValue<?>> emptySet(); } catch (UncheckedAnalysisException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback() .logError("Error getting relevant type qualifiers for " + xmethod.toString(), e); return Collections.<TypeQualifierValue<?>> emptySet();
String superclassName = jclass.getSuperclassName(); if (codeLength > 6000 && Const.STATIC_INITIALIZER_NAME.equals(methodName) && "java.lang.Enum".equals(superclassName)) { analysisContext.getLookupFailureCallback().reportSkippedAnalysis( new JavaClassAndMethod(jclass, method).toMethodDescriptor()); return null; analysisContext.getLookupFailureCallback().reportSkippedAnalysis( new JavaClassAndMethod(jclass, method).toMethodDescriptor()); return null;
XMethod xmethod = XFactory.createXMethod(classContext.getJavaClass(), method); AnalysisContext.currentAnalysisContext().getLookupFailureCallback() .logError("Error analyzing " + xmethod + " for unconditional deref training", e); } catch (DataflowAnalysisException e) { XMethod xmethod = XFactory.createXMethod(classContext.getJavaClass(), method); AnalysisContext.currentAnalysisContext().getLookupFailureCallback() .logError("Error analyzing " + xmethod + " for unconditional deref training", e);
/** * Get the effective inherited TypeQualifierAnnotation on the given instance * method parameter. * * @param xmethod * an instance method * @param parameter * a parameter (0 == first parameter) * @param typeQualifierValue * the kind of TypeQualifierValue we are looking for * @return effective inherited TypeQualifierAnnotation on the parameter, or * null if there is not effective TypeQualifierAnnotation */ public static @CheckForNull TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod xmethod, int parameter, TypeQualifierValue<?> typeQualifierValue) { assert !xmethod.isStatic(); ParameterAnnotationAccumulator accumulator = new ParameterAnnotationAccumulator(typeQualifierValue, xmethod, parameter); try { AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypesDepthFirst(xmethod.getClassDescriptor(), accumulator); TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation(); if (result == null && accumulator.overrides()) { return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION; } return result; } catch (ClassNotFoundException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e); return null; } }
analysisContext.getLookupFailureCallback().reportMissingClass(e);
/** * Get the effective inherited TypeQualifierAnnotation on given instance * method. * * @param o * an XMethod * @param typeQualifierValue * the kind of TypeQualifierValue we are looking for * @return effective TypeQualifierAnnotation inherited from overridden * supertype methods, or null if there is no inherited * TypeQualifierAnnotation */ public static TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod o, TypeQualifierValue<?> typeQualifierValue) { assert !o.isStatic(); ReturnTypeAnnotationAccumulator accumulator = new ReturnTypeAnnotationAccumulator(typeQualifierValue, o); try { AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypesDepthFirst(o.getClassDescriptor(), accumulator); TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation(); if (result == null && accumulator.overrides()) { return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION; } return result; } catch (ClassNotFoundException e) { AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e); return null; } }
AnalysisContext.currentAnalysisContext().getLookupFailureCallback() .logError("Error analyzing " + xmethod + " for unconditional deref training", e);
AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e);
.getLookupFailureCallback(), exceptionSetFactory);