private void processJarFile(File platformJar, final ByteCodeConsumer consumer) throws IOException { try (JarFile jarFile = new JarFile(platformJar)) { for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) { JarEntry entry = entries.nextElement(); if (!entry.getName().endsWith(".class")) { continue; } try (InputStream inputStream = jarFile.getInputStream(entry)) { final byte[] bytes = ByteStreams.toByteArray(inputStream); mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception { consumer.process(bytes); return null; } }); } } } }
private void handleInterfaceInheritance(@NonNull Set<T> interfaceInheritance) { for (final T klass : interfaceInheritance) { mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception {
@NonNull Iterable<PostProcessingData.UnresolvedReference<T>> unresolvedReferences) { for (final PostProcessingData.UnresolvedReference<T> unresolvedReference : unresolvedReferences) { mExecutor.execute(new Callable<Void>() { @Override public Void call() {
private void processSingle( @NonNull Path input, @NonNull Path output, @NonNull Set<? super QualifiedContent.Scope> scopes) throws Exception { waitableExecutor.execute( () -> { if (output.toString().endsWith(SdkConstants.DOT_JAR)) { Files.createDirectories(output.getParent()); } else { Files.createDirectories(output); } FileCache cacheToUse; if (Files.isRegularFile(input) && Objects.equals( scopes, Collections.singleton(QualifiedContent.Scope.EXTERNAL_LIBRARIES))) { cacheToUse = userCache; } else { cacheToUse = null; } processUsingCache(input, output, cacheToUse); return null; }); }
mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception {
/** * Walks the entire graph, starting from the roots, and increments counters for reachable nodes. */ protected void setCounters(@NonNull final CounterSet counterSet) { Map<T, DependencyType> roots = mGraph.getRoots(counterSet); for (final Map.Entry<T, DependencyType> toIncrementEntry : roots.entrySet()) { mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception { incrementCounter( toIncrementEntry.getKey(), toIncrementEntry.getValue(), counterSet); return null; } }); } waitForAllTasks(); }
/** * Sets the roots (i.e. entry points) of the graph and marks all nodes reachable from them. */ private void setCounters(@NonNull ImmutableMap<CounterSet, KeepRules> allKeepRules) { final CounterSet counterSet = CounterSet.SHRINK; final KeepRules keepRules = allKeepRules.get(counterSet); for (final T klass : mGraph.getAllProgramClasses()) { mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception { mGraph.addRoots(keepRules.getSymbolsToKeep(klass, mGraph), counterSet); return null; } }); } waitForAllTasks(); setCounters(counterSet); }
mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception {
private static Consumer<File> createAction( @NonNull Project project, @NonNull WaitableExecutor<Void> executor, @NonNull File input) { return (outputDir) -> executor.execute(() -> { PrepareLibraryTask.extract( input, outputDir, project); return null; }); }
mExecutor.execute(new Callable<Void>() { Set<T> methods = mGraph.getMethods(klass);
private void processFile( @NonNull final File rootFolder, @NonNull final File file, @NonNull final SourceFileProcessor processor) throws ProcessException, IOException { if (file.isFile()) { // get the extension of the file. if (checkExtension(file)) { if (mExecutor != null) { mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception { processor.processFile(rootFolder, file); return null; } }); } else { processor.processFile(rootFolder, file); } } } else if (file.isDirectory()) { File[] children = file.listFiles(); if (children != null) { for (File child : children) { processFile(rootFolder, child, processor); } } } }
mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception {
mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception {
waitableExecutor.execute(callable);
executor.execute(new Callable<Void>() { @Override public Void call() throws Exception { if (impactedData != null) { for (final DependencyData data: impactedData) { executor.execute(new Callable<Void>() { @Override public Void call() throws Exception { final DependencyData data2 = mainFileMap.get(entry.getKey().getAbsolutePath()); if (data2 != null) { executor.execute(new Callable<Void>() { @Override public Void call() throws Exception {
executor.execute(() -> { extractJar(outJarFolder, jarFile, extractCode); return null; switch (jarInput.getStatus()) { case CHANGED: executor.execute(() -> { FileUtils.cleanOutputDir(outJarFolder); extractJar(outJarFolder, jarFile, extractCode); break; case ADDED: executor.execute(() -> { extractJar(outJarFolder, jarFile, extractCode); return null; break; case REMOVED: executor.execute( () -> { FileUtils.cleanOutputDir(outJarFolder);
}; mExecutor.execute(() -> { byte[] newBytes = rewrite( mGraph.getClassName(klass),
executor.execute(action);
mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception {
for (File directory : getAllDirectories(input)) { for (final File classFile : getClassFiles(directory)) { mExecutor.execute(() -> { processLibraryClass(Files.toByteArray(classFile)); return null; for (File directory : getAllDirectories(input)) { for (final File classFile : getClassFiles(directory)) { mExecutor.execute(new Callable<Void>() { @Override public Void call() throws Exception {