Ejemplo n.º 1
0
 /* (non-Javadoc)
  * @see ch.epfl.labos.iu.orm.queryll2.PathAnalysisMethodChecker#isMethodSafe(ch.epfl.labos.iu.orm.queryll2.symbolic.MethodSignature, ch.epfl.labos.iu.orm.queryll2.symbolic.TypedValue, java.util.List)
  */
 @Override
 public OperationSideEffect isMethodSafe(
     MethodSignature m, TypedValue base, List<TypedValue> args) {
   if (isObjectEqualsSafe && objectEquals.equals(m)) {
     return OperationSideEffect.NONE;
   } else if (safeMethods.contains(m)
       || subqueryMethods.contains(m)
       || jpqlFunctionMethods.contains(m)) {
     return OperationSideEffect.NONE;
   } else {
     // Use reflection to get info about the method (or would it be better
     // to do this through direct bytecode inspection?), and see if it's
     // annotated as safe
     try {
       Method reflectedMethod = Annotations.asmMethodSignatureToReflectionMethod(m);
       // Special handling of Collection.contains() for subclasses of Collection.
       if (isCollectionContainsSafe
           && "contains".equals(m.name)
           && "(Ljava/lang/Object;)Z".equals(m.desc)
           && Collection.class.isAssignableFrom(reflectedMethod.getDeclaringClass()))
         return OperationSideEffect.NONE;
       if (Annotations.methodHasSomeAnnotations(reflectedMethod, safeMethodAnnotations))
         return OperationSideEffect.NONE;
     } catch (ClassNotFoundException | NoSuchMethodException e) {
       // Eat the error
     }
     return OperationSideEffect.UNSAFE;
   }
 }