/** * Try to create the database using a no-arg constructor. * * @return the database, or null if there is no no-arg constructor * @throws CheckedAnalysisException */ private E createUsingConstructor() throws CheckedAnalysisException { Constructor<E> constructor; try { constructor = databaseClass.getConstructor(new Class[0]); } catch (NoSuchMethodException e) { return null; } try { return constructor.newInstance(new Object[0]); } catch (InstantiationException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } catch (IllegalAccessException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } catch (InvocationTargetException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } }
public CheckedAnalysisException(CheckedAnalysisException e) { super(e.getMessage(), e.getCause()); }
@Override public Class<?> findClass(@DottedClassName String name) throws ClassNotFoundException { if (TypeQualifierValue.DEBUG_CLASSLOADING) { System.out.println("Looking for class data for " + name); } if (name.startsWith("javax.annotation")) { return Class.forName(name); } try { byte[] b = TypeQualifierValue.loadClassData(name); return findClass(name, b); } catch (CheckedAnalysisException e) { if (TypeQualifierValue.DEBUG_CLASSLOADING) { e.printStackTrace(); } return super.findClass(name); } catch (RuntimeException e) { if (TypeQualifierValue.DEBUG_CLASSLOADING) { e.printStackTrace(); } throw e; } }
@Override public String getMessage() { return super.getMessage() + " in " + codeBaseEntry; } }
private <Analysis> Analysis getMethodAnalysis(Class<Analysis> analysisClass, Method method) throws DataflowAnalysisException, CFGBuilderException { try { MethodDescriptor methodDescriptor = BCELUtil.getMethodDescriptor(jclass, method); return Global.getAnalysisCache().getMethodAnalysis(analysisClass, methodDescriptor); } catch (DataflowAnalysisException e) { throw e; } catch (CFGBuilderException e) { throw e; } catch (CheckedAnalysisException e) { Throwable cause = e.getCause(); if (cause instanceof CFGBuilderException) { throw (CFGBuilderException) cause; } String message = "Should not happen: bad CAE: " + e.getClass().getName() + " for " + analysisClass.getName() + " of " + method; IllegalStateException ise = new IllegalStateException(message); ise.initCause(e); throw ise; } }
@Override public String getMessage() { return super.getMessage() + " in " + codeBaseEntry; } }
private <Analysis> Analysis getMethodAnalysis(Class<Analysis> analysisClass, Method method) throws DataflowAnalysisException, CFGBuilderException { try { MethodDescriptor methodDescriptor = BCELUtil.getMethodDescriptor(jclass, method); return Global.getAnalysisCache().getMethodAnalysis(analysisClass, methodDescriptor); } catch (DataflowAnalysisException e) { throw e; } catch (CFGBuilderException e) { throw e; } catch (CheckedAnalysisException e) { Throwable cause = e.getCause(); if (cause instanceof CFGBuilderException) { throw (CFGBuilderException) cause; } String message = "Should not happen: bad CAE: " + e.getClass().getName() + " for " + analysisClass.getName() + " of " + method; IllegalStateException ise = new IllegalStateException(message); ise.initCause(e); throw ise; } }
/** * Try to create the database using a static create() method. * * @return the database, or null if there is no static create() method * @throws CheckedAnalysisException */ private E createUsingStaticCreateMethod() throws CheckedAnalysisException { Method createMethod; try { createMethod = databaseClass.getMethod("create", new Class[0]); } catch (NoSuchMethodException e) { return null; } if (!Modifier.isStatic(createMethod.getModifiers())) { return null; } if (createMethod.getReturnType() != databaseClass) { return null; } try { return databaseClass.cast(createMethod.invoke(null, new Object[0])); } catch (InvocationTargetException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } catch (IllegalAccessException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } }
public CheckedAnalysisException(CheckedAnalysisException e) { super(e.getMessage(), e.getCause()); }
cc.dumpSimpleDataflowInformation(cfg.getMethodGen().getMethod()); } catch (CheckedAnalysisException e) { e.printStackTrace(System.out);
@Override public E createDatabase() throws CheckedAnalysisException { E database; database = createUsingStaticCreateMethod(); if (database != null) { return database; } database = createUsingConstructor(); if (database != null) { return database; } throw new CheckedAnalysisException("Could not find a way to create database " + databaseClass.getName()); }
@Override public Class<?> findClass(@DottedClassName String name) throws ClassNotFoundException { if (TypeQualifierValue.DEBUG_CLASSLOADING) { System.out.println("Looking for class data for " + name); } if (name.startsWith("javax.annotation")) { return Class.forName(name); } try { byte[] b = TypeQualifierValue.loadClassData(name); return findClass(name, b); } catch (CheckedAnalysisException e) { if (TypeQualifierValue.DEBUG_CLASSLOADING) { e.printStackTrace(); } return super.findClass(name); } catch (RuntimeException e) { if (TypeQualifierValue.DEBUG_CLASSLOADING) { e.printStackTrace(); } throw e; } }
private static Iterator<Location> getLocationIterator(ClassContext classContext, Method method) throws CheckedAnalysisException { try { return classContext.getCFG(method).locationIterator(); } catch (CFGBuilderException ex) { throw new CheckedAnalysisException("cannot get control flow graph", ex); } }
} catch (CheckedAnalysisException e1) { e1.printStackTrace(); } catch (IOException e1) {
static @Nonnull XMethod getInvokedMethod(XClass xClass, String name, String sig, boolean isStatic) throws CheckedAnalysisException { IAnalysisCache cache = Global.getAnalysisCache(); while (true) { XMethod result = xClass.findMethod(name, sig, isStatic); if (result != null) { return result; } if (isStatic) { throw new CheckedAnalysisException(); } ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor(); if (superclassDescriptor == null) { throw new CheckedAnalysisException(); } xClass = cache.getClassAnalysis(XClass.class, superclassDescriptor); } }
cc.dumpSimpleDataflowInformation(cfg.getMethodGen().getMethod()); } catch (CheckedAnalysisException e) { e.printStackTrace(System.out);
/** * Try to create the database using a no-arg constructor. * * @return the database, or null if there is no no-arg constructor * @throws CheckedAnalysisException */ private E createUsingConstructor() throws CheckedAnalysisException { Constructor<E> constructor; try { constructor = databaseClass.getConstructor(new Class[0]); } catch (NoSuchMethodException e) { return null; } try { return constructor.newInstance(new Object[0]); } catch (InstantiationException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } catch (IllegalAccessException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } catch (InvocationTargetException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } }
/** * Try to create the database using a static create() method. * * @return the database, or null if there is no static create() method * @throws CheckedAnalysisException */ private E createUsingStaticCreateMethod() throws CheckedAnalysisException { Method createMethod; try { createMethod = databaseClass.getMethod("create", new Class[0]); } catch (NoSuchMethodException e) { return null; } if (!Modifier.isStatic(createMethod.getModifiers())) { return null; } if (createMethod.getReturnType() != databaseClass) { return null; } try { return databaseClass.cast(createMethod.invoke(null, new Object[0])); } catch (InvocationTargetException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } catch (IllegalAccessException e) { throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e); } }
@Override public E createDatabase() throws CheckedAnalysisException { E database; database = createUsingStaticCreateMethod(); if (database != null) { return database; } database = createUsingConstructor(); if (database != null) { return database; } throw new CheckedAnalysisException("Could not find a way to create database " + databaseClass.getName()); }
private static Iterator<Location> getLocationIterator(ClassContext classContext, Method method) throws CheckedAnalysisException { try { return classContext.getCFG(method).locationIterator(); } catch (CFGBuilderException ex) { throw new CheckedAnalysisException("cannot get control flow graph", ex); } }