/** * A debugging aid. TODO: move this elsewhere */ public static void clearSoftCaches() { float occupancy = 1f - ((float)Runtime.getRuntime().freeMemory() / (float)Runtime.getRuntime().totalMemory()); if (occupancy < OCCUPANCY_TRIGGER) { return; } AnalysisCacheImpl cache = getAnalysisCache(); if (cache != null) { cache.getSSACache().wipe(); } IClassHierarchy cha = getClassHierarchy(); if (cha != null) { for (IClass klass : cha) { if (klass instanceof ShrikeClass) { ShrikeClass c = (ShrikeClass) klass; c.clearSoftCaches(); } else { if (klass.getDeclaredMethods() != null) { for (IMethod m : klass.getDeclaredMethods()) { if (m instanceof ShrikeCTMethod) { ((ShrikeCTMethod)m).clearCaches(); } } } } } } }
/** * A debugging aid. TODO: move this elsewhere */ public static void clearSoftCaches() { float occupancy = 1f - ((float)Runtime.getRuntime().freeMemory() / (float)Runtime.getRuntime().totalMemory()); if (occupancy < OCCUPANCY_TRIGGER) { return; } AnalysisCacheImpl cache = getAnalysisCache(); if (cache != null) { cache.getSSACache().wipe(); } IClassHierarchy cha = getClassHierarchy(); if (cha != null) { for (IClass klass : cha) { if (klass instanceof ShrikeClass) { ShrikeClass c = (ShrikeClass) klass; c.clearSoftCaches(); } else { if (klass.getDeclaredMethods() != null) { for (IMethod m : klass.getDeclaredMethods()) { if (m instanceof ShrikeCTMethod) { ((ShrikeCTMethod)m).clearCaches(); } } } } } } }
/** * test that type inference works in the presence of a getfield where the * field's declared type cannot be loaded */ @Test public void testBug38540() throws ClassHierarchyException, IOException { AnalysisScope scope = null; scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); AnalysisOptions options = new AnalysisOptions(); ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "Main"); IClass klass = cha.lookupClass(t); Assert.assertTrue(klass != null); ShrikeCTMethod m = (ShrikeCTMethod) klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("foo"), Descriptor .findOrCreateUTF8("()Ljava/lang/Object;"))); Assert.assertTrue(m != null); IR ir = new AnalysisCacheImpl().getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, options.getSSAOptions()); TypeInference.make(ir, false); }