@Override public void setJ2SELibraries(JarFile[] libs) { if (libs == null) { throw new IllegalArgumentException("libs is null"); } this.j2seLibs = new Module[libs.length]; for (int i = 0; i < libs.length; i++) { j2seLibs[i] = new JarFileModule(libs[i]); } }
@Override public void setJ2SELibraries(JarFile[] libs) { if (libs == null) { throw new IllegalArgumentException("libs is null"); } this.j2seLibs = new Module[libs.length]; for (int i = 0; i < libs.length; i++) { j2seLibs[i] = new JarFileModule(libs[i]); } }
/** * Add a jar file to the scope for a loader */ @SuppressWarnings("unused") public void addToScope(ClassLoaderReference loader, JarFile file) { List<Module> s = MapUtil.findOrCreateList(moduleMap, loader); if (DEBUG_LEVEL > 0) { System.err.println(("AnalysisScope: add JarFileModule " + file.getName())); } s.add(new JarFileModule(file)); }
/** * Add a jar file to the scope for a loader */ @SuppressWarnings("unused") public void addToScope(ClassLoaderReference loader, JarFile file) { List<Module> s = MapUtil.findOrCreateList(moduleMap, loader); if (DEBUG_LEVEL > 0) { System.err.println(("AnalysisScope: add JarFileModule " + file.getName())); } s.add(new JarFileModule(file)); }
public static Module getJarFileModule(String fileName) { // Using reflection to enable this code to be built without the // org.eclipse.core.resources bundle // try { if (workspaceRoot_getFile == null) { Class<?> cls = Class.forName("org.eclipse.core.resources.ResourcesPlugin"); Method getWorkspaceMethod = cls.getDeclaredMethod("getWorkspace"); Object workspace = getWorkspaceMethod.invoke(null); Method getRoot = workspace.getClass().getDeclaredMethod("getRoot"); workspaceRoot = getRoot.invoke(workspace); workspaceRoot_getFile = workspaceRoot.getClass().getMethod("getFile", IPath.class); } IPath path = new Path(fileName); if (workspaceRoot_getFile.invoke(workspaceRoot, path) != null) { try (final JarFile jar = new JarFile(fileName, false)) { return new JarFileModule(jar); } } } catch (Exception e) { } return null; } }
/** * @return the jar file packaged with this plug-in of the given name, or null * if not found. */ private JarFileModule getFromPlugin(Plugin p, String fileName) throws IOException { URL url = getFileURLFromPlugin(p, fileName); if (url == null) return null; try (final JarFile jar = new JarFile(filePathFromURL(url))) { return new JarFileModule(jar); } }
return new JarFileModule(new JarFile(fileName, false)); } catch (ZipException e) { throw new IOException("Could not find file: " + fileName, e); JarFile f = jc.getJarFile(); JarEntry entry = jc.getJarEntry(); JarFileModule parent = new JarFileModule(f); return new NestedJarFileModule(parent, entry); } else if (url.getProtocol().equals("rsrc")) { } else if (url.getProtocol().equals("file")) { String filePath = filePathFromURL(url); return new JarFileModule(new JarFile(filePath, false)); } else { final URLConnection in = url.openConnection();
return new JarFileModule(new JarFile(fileName, false)); } catch (ZipException e) { throw new IOException("Could not find file: " + fileName, e); JarFile f = jc.getJarFile(); JarEntry entry = jc.getJarEntry(); JarFileModule parent = new JarFileModule(f); return new NestedJarFileModule(parent, entry); } else if (url.getProtocol().equals("rsrc")) { } else if (url.getProtocol().equals("file")) { String filePath = filePathFromURL(url); return new JarFileModule(new JarFile(filePath, false)); } else { final URLConnection in = url.openConnection();
protected void resolveLibraryPathEntry(ILoader loader, IPath p) { File file = makeAbsolute(p).toFile(); JarFile j; try { j = new JarFile(file); } catch (ZipException z) { // a corrupted file. ignore it. return; } catch (IOException z) { // should ignore directories as well.. return; } if (isPrimordialJarFile()) { List<Module> s = MapUtil.findOrCreateList(modules, loader); s.add(file.isDirectory() ? (Module) new BinaryDirectoryTreeModule(file) : (Module) new JarFileModule(j)); } }
/** * Take the given set of JarFiles that constitute the program, and return a set of Module files as expected by the * WALA machinery. */ private Set<JarFileModule> getModuleFiles() { Set<JarFileModule> result = HashSetFactory.make(); for (JarFile jarFile : applicationJarFiles) { result.add(new JarFileModule(jarFile)); } return result; }
scope.addToScope(ClassLoaderReference.Primordial, DexFileModule.make(new File(al))); } catch (Exception e) { scope.addToScope(ClassLoaderReference.Primordial, new JarFileModule(new JarFile(new File(al))));
public static AnalysisScope makeDalvikScope(URI[] androidLibs, File androidAPIJar, String dexFileName) throws IOException { if (androidLibs != null) { return AndroidAnalysisScope.setUpAndroidAnalysisScope( new File(dexFileName).toURI(), CallGraphTestUtil.REGRESSION_EXCLUSIONS, CallGraphTestUtil.class.getClassLoader(), androidLibs); } else { AnalysisScope scope = AndroidAnalysisScope.setUpAndroidAnalysisScope( new File(dexFileName).toURI(), CallGraphTestUtil.REGRESSION_EXCLUSIONS, CallGraphTestUtil.class.getClassLoader()); if (androidAPIJar != null) { scope.addToScope(ClassLoaderReference.Primordial, new JarFileModule(new JarFile(androidAPIJar))); } return scope; } }
scope.addToScope(ClassLoaderReference.Primordial, DexFileModule.make(new File(al))); } catch (Exception e) { scope.addToScope(ClassLoaderReference.Primordial, new JarFileModule(new JarFile(new File(al))));
public static void populateScope(JavaSourceAnalysisEngine<?> engine, Collection<String> sources, List<String> libs) { boolean foundLib = false; for (String lib : libs) { File libFile = new File(lib); if (libFile.exists()) { foundLib = true; try { engine.addSystemModule(new JarFileModule(new JarFile(libFile, false))); } catch (IOException e) { Assert.fail(e.getMessage()); } } } assert foundLib : "couldn't find library file from " + libs; for (String srcFilePath : sources) { String srcFileName = srcFilePath.substring(srcFilePath.lastIndexOf(File.separator) + 1); File f = new File(srcFilePath); Assert.assertTrue("couldn't find " + srcFilePath, f.exists()); if (f.isDirectory()) { engine.addSourceModule(new SourceDirectoryTreeModule(f)); } else { engine.addSourceModule(new SourceFileModule(f, srcFileName, null)); } } }