if (!CodeScanner.getFieldsRead(mtd).isEmpty() || !CodeScanner.getFieldsWritten(mtd).isEmpty() || !CodeScanner.getCallSites(mtd).isEmpty()) {
/** * @throws IllegalArgumentException if m is null */ public static Collection<FieldReference> getFieldsRead(IMethod m) throws InvalidClassFileException { if (m == null) { throw new IllegalArgumentException("m is null"); } if (m.isWalaSynthetic()) { SyntheticMethod sm = (SyntheticMethod) m; return getFieldsRead(sm.getStatements()); } else { return getFieldsReadFromShrikeBT((ShrikeCTMethod) m); } }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { SSAInstruction[] statements = getIR(node).getInstructions(); return CodeScanner.getFieldsRead(statements).iterator(); }
/** * @throws IllegalArgumentException if m is null */ public static Collection<FieldReference> getFieldsRead(IMethod m) throws InvalidClassFileException { if (m == null) { throw new IllegalArgumentException("m is null"); } if (m.isWalaSynthetic()) { SyntheticMethod sm = (SyntheticMethod) m; return getFieldsRead(sm.getStatements()); } else { return getFieldsReadFromShrikeBT((ShrikeCTMethod) m); } }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { SSAInstruction[] statements = getIR(node).getInstructions(); return CodeScanner.getFieldsRead(statements).iterator(); }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } try { return CodeScanner.getFieldsRead(node.getMethod()).iterator(); } catch (InvalidClassFileException e) { e.printStackTrace(); Assertions.UNREACHABLE(); return null; } }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } try { return CodeScanner.getFieldsRead(node.getMethod()).iterator(); } catch (InvalidClassFileException e) { e.printStackTrace(); Assertions.UNREACHABLE(); return null; } }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node); try { return CodeScanner.getFieldsRead(m).iterator(); } catch (InvalidClassFileException e) { e.printStackTrace(); Assertions.UNREACHABLE(); return null; } }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { assert understands(node); final SSAInstruction[] statements = getIR(node).getInstructions(); return CodeScanner.getFieldsRead(statements).iterator(); } }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { if (node == null) { throw new IllegalArgumentException("node is null"); } SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node); try { return CodeScanner.getFieldsRead(m).iterator(); } catch (InvalidClassFileException e) { e.printStackTrace(); Assertions.UNREACHABLE(); return null; } }
@Override public Iterator<FieldReference> iterateFieldsRead(CGNode node) { assert understands(node); final SSAInstruction[] statements = getIR(node).getInstructions(); return CodeScanner.getFieldsRead(statements).iterator(); } }
/** * Use the 'GetLoadedFields' launcher to run this program with the appropriate classpath */ public static void main(String[] args) throws IOException, ClassHierarchyException, InvalidClassFileException { // build an analysis scope representing the standard libraries, excluding no classes AnalysisScope scope = AnalysisScopeReader.readJavaScope("primordial.txt", null, MY_CLASSLOADER); // build a class hierarchy System.err.print("Build class hierarchy..."); IClassHierarchy cha = ClassHierarchyFactory.make(scope); System.err.println("Done"); int nMethods = 0; int nFields = 0; Map<IMethod, Collection<FieldReference>> method2Field = HashMapFactory.make(); for (IClass c : cha) { for (IMethod m : c.getDeclaredMethods()) { nMethods++; Collection<FieldReference> fields = CodeScanner.getFieldsRead(m); nFields += fields.size(); method2Field.put(m, fields); } } System.out.println(nMethods + " methods"); System.out.println((float)nFields/(float)nMethods + " fields read per method"); } }