/** * checks if two sets have a non-empty intersection * * @return {@code true} if the sets intersect; {@code false} otherwise */ public static <T> boolean intersecting(final Set<T> s1, final Set<T> s2) { return forSome(s1, s2::contains); }
/** * @return the amount of memory currently being used, in bytes. Often inaccurate, but there's no better thing to do from within * the JVM. */ public static long getUsedMemory() { gc(); long totalMemory = Runtime.getRuntime().totalMemory(); gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long usedMemory = totalMemory - freeMemory; return usedMemory; }
public static String toJSON(Map<String, Set<String>> map) { StringBuilder res = new StringBuilder(); res.append("{\n"); res.append(joinWith(Util.mapToSet(map.entrySet(), e -> { StringBuilder res1 = new StringBuilder(); if(e.getValue().size() > 0) { res1.append(" \"").append(e.getKey()).append("\": [\n"); res1.append(joinWith(Util.mapToSet(e.getValue(), str -> " \"" + str + '"'), ",\n")); res1.append("\n ]"); } return res1.length() == 0 ? null : res1.toString(); }), ",\n")); res.append("\n}"); return res.toString(); }
StringBuilder buf = new StringBuilder(FULLY_QUALIFIED_NAMES ? c.getName() : removePackageName(c.getName())); while (c != Object.class) { Field[] fields = c.getDeclaredFields(); buf = buf.append(value == null ? "null" : value.toString()); buf = buf.append(" : "); buf = buf.append(FULLY_QUALIFIED_NAMES ? type.getName() : removePackageName(type.getName())); } catch (IllegalAccessException e) { e.printStackTrace();
/** * do all instance keys in p2set pass ikeyPred? */ private static boolean passesPred(Collection<InstanceKeyAndState> curP2Set, final Predicate<InstanceKey> ikeyPred) { return Util.forAll(curP2Set, t -> ikeyPred.test(t.getInstanceKey())); }
public static String toJSON(Map<String, Set<String>> map) { StringBuilder res = new StringBuilder(); res.append("{\n"); res.append(joinWith(Util.mapToSet(map.entrySet(), e -> { StringBuilder res1 = new StringBuilder(); if(e.getValue().size() > 0) { res1.append(" \"").append(e.getKey()).append("\": [\n"); res1.append(joinWith(Util.mapToSet(e.getValue(), str -> " \"" + str + '"'), ",\n")); res1.append("\n ]"); } return res1.length() == 0 ? null : res1.toString(); }), ",\n")); res.append("\n}"); return res.toString(); }
StringBuilder buf = new StringBuilder(FULLY_QUALIFIED_NAMES ? c.getName() : removePackageName(c.getName())); while (c != Object.class) { Field[] fields = c.getDeclaredFields(); buf = buf.append(value == null ? "null" : value.toString()); buf = buf.append(" : "); buf = buf.append(FULLY_QUALIFIED_NAMES ? type.getName() : removePackageName(type.getName())); } catch (IllegalAccessException e) { e.printStackTrace();
/** * do all instance keys in p2set pass ikeyPred? */ private static boolean passesPred(Collection<InstanceKeyAndState> curP2Set, final Predicate<InstanceKey> ikeyPred) { return Util.forAll(curP2Set, t -> ikeyPred.test(t.getInstanceKey())); }
public static Map<String, Set<String>> extractEdges(CallGraph cg) { Map<String, Set<String>> edges = HashMapFactory.make(); for(CGNode nd : cg) { if(!isRealFunction(nd.getMethod())) continue; AstMethod method = (AstMethod)nd.getMethod(); for(CallSiteReference callsite : Iterator2Iterable.make(nd.iterateCallSites())) { Set<IMethod> targets = Util.mapToSet(cg.getPossibleTargets(nd, callsite), CGNode::getMethod); serializeCallSite(method, callsite, targets, edges); } } return edges; }
/** * @return the amount of memory currently being used, in bytes. Often inaccurate, but there's no better thing to do from within * the JVM. */ public static long getUsedMemory() { gc(); long totalMemory = Runtime.getRuntime().totalMemory(); gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long usedMemory = totalMemory - freeMemory; return usedMemory; }
/** * checks if two sets have a non-empty intersection * * @return {@code true} if the sets intersect; {@code false} otherwise */ public static <T> boolean intersecting(final Set<T> s1, final Set<T> s2) { return forSome(s1, s2::contains); }
StringBuilder buf = new StringBuilder(FULLY_QUALIFIED_NAMES ? c.getName() : removePackageName(c.getName())); while (c != Object.class) { Field[] fields = c.getDeclaredFields(); buf = buf.append(value == null ? "null" : value.toString()); buf = buf.append(" : "); buf = buf.append(FULLY_QUALIFIED_NAMES ? type.getName() : removePackageName(type.getName())); } catch (IllegalAccessException e) { e.printStackTrace();
public static Map<String, Set<String>> extractEdges(CallGraph cg) { Map<String, Set<String>> edges = HashMapFactory.make(); for(CGNode nd : cg) { if(!isRealFunction(nd.getMethod())) continue; AstMethod method = (AstMethod)nd.getMethod(); for(CallSiteReference callsite : Iterator2Iterable.make(nd.iterateCallSites())) { Set<IMethod> targets = Util.mapToSet(cg.getPossibleTargets(nd, callsite), CGNode::getMethod); serializeCallSite(method, callsite, targets, edges); } } return edges; }
/** * @return the amount of memory currently being used, in bytes. Often inaccurate, but there's no better thing to do from within * the JVM. */ public static long getUsedMemory() { gc(); long totalMemory = Runtime.getRuntime().totalMemory(); gc(); long freeMemory = Runtime.getRuntime().freeMemory(); long usedMemory = totalMemory - freeMemory; return usedMemory; }
/** * checks if two sets have a non-empty intersection * * @return {@code true} if the sets intersect; {@code false} otherwise */ public static <T> boolean intersecting(final Set<T> s1, final Set<T> s2) { return forSome(s1, s2::contains); }