@Override public void buildAnalysisScope() throws IOException { scope = makeSourceAnalysisScope(); if (getExclusionsFile() != null) { try (final InputStream is = new File(getExclusionsFile()).exists()? new FileInputStream(getExclusionsFile()): FileProvider.class.getClassLoader().getResourceAsStream(getExclusionsFile())) { scope.setExclusions(new FileOfClasses(is)); } } for (Module M : this.systemEntries) { scope.addToScope(scope.getPrimordialLoader(), M); } // add user stuff addApplicationModulesToScope(); }
@Override public void buildAnalysisScope() throws IOException { scope = makeSourceAnalysisScope(); if (getExclusionsFile() != null) { try (final InputStream is = new File(getExclusionsFile()).exists()? new FileInputStream(getExclusionsFile()): FileProvider.class.getClassLoader().getResourceAsStream(getExclusionsFile())) { scope.setExclusions(new FileOfClasses(is)); } } for (Module M : this.systemEntries) { scope.addToScope(scope.getPrimordialLoader(), M); } // add user stuff addApplicationModulesToScope(); }
/** * @return the rt.jar (1.4) or core.jar (1.5) file, or null if not found. */ private JarFile getRtJar() { return RtJar.getRtJar( new MapIterator<Module,JarFile>( new FilterIterator<>(getModules(getPrimordialLoader()).iterator(), JarFileModule.class::isInstance), M -> ((JarFileModule) M).getJarFile())); }
/** * @return the rt.jar (1.4) or core.jar (1.5) file, or null if not found. */ private JarFile getRtJar() { return RtJar.getRtJar( new MapIterator<Module,JarFile>( new FilterIterator<>(getModules(getPrimordialLoader()).iterator(), JarFileModule.class::isInstance), M -> ((JarFileModule) M).getJarFile())); }
/** * Set up the AnalysisScope object */ public void buildAnalysisScope() throws IOException { if (j2seLibs == null) { Assertions.UNREACHABLE("no j2selibs specified. You probably did not call AppAnalysisEngine.setJ2SELibrary."); } scope = AnalysisScopeReader.readJavaScope(SYNTHETIC_J2SE_MODEL, (new FileProvider()).getFile(getExclusionsFile()), getClass() .getClassLoader()); // add standard libraries for (Module j2seLib : j2seLibs) { scope.addToScope(scope.getPrimordialLoader(), j2seLib); } // add user stuff addApplicationModulesToScope(); }
/** * Set up the AnalysisScope object */ public void buildAnalysisScope() throws IOException { if (j2seLibs == null) { Assertions.UNREACHABLE("no j2selibs specified. You probably did not call AppAnalysisEngine.setJ2SELibrary."); } scope = AnalysisScopeReader.readJavaScope(SYNTHETIC_J2SE_MODEL, (new FileProvider()).getFile(getExclusionsFile()), getClass() .getClassLoader()); // add standard libraries for (Module j2seLib : j2seLibs) { scope.addToScope(scope.getPrimordialLoader(), j2seLib); } // add user stuff addApplicationModulesToScope(); }
@Test public void testFromJar() throws ClassHierarchyException, IOException { if (analyzingJar()) return; AnalysisScope scope = null; scope = AnalysisScopeReader.readJavaScope(TestConstants.HELLO, null, MY_CLASSLOADER); // TODO: it's annoying to have to build a class hierarchy here. // open a feature to fix this ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreate(scope.getPrimordialLoader(), CLASS_IN_PRIMORDIAL_JAR); IClass klass = cha.lookupClass(t); Assert.assertTrue(klass != null); String sourceFile = klass.getSourceFileName(); Assert.assertTrue(sourceFile != null); System.err.println("Source file: " + sourceFile); Module container = ((BytecodeClass<?>)klass).getContainer(); Assert.assertTrue(container != null); System.err.println("container: " + container); } }