30 |
30 |
31 import com.sun.tools.classfile.AccessFlags; |
31 import com.sun.tools.classfile.AccessFlags; |
32 import com.sun.tools.classfile.ClassFile; |
32 import com.sun.tools.classfile.ClassFile; |
33 import com.sun.tools.classfile.ConstantPoolException; |
33 import com.sun.tools.classfile.ConstantPoolException; |
34 import com.sun.tools.classfile.Dependencies; |
34 import com.sun.tools.classfile.Dependencies; |
|
35 import com.sun.tools.classfile.Dependencies.ClassFileError; |
35 import com.sun.tools.classfile.Dependency; |
36 import com.sun.tools.classfile.Dependency; |
36 import com.sun.tools.classfile.Dependency.Location; |
37 import com.sun.tools.classfile.Dependency.Location; |
37 |
38 |
38 import java.io.IOException; |
39 import java.io.IOException; |
39 import java.io.UncheckedIOException; |
40 import java.io.UncheckedIOException; |
170 return Optional.empty(); |
171 return Optional.empty(); |
171 |
172 |
172 parsedArchives.get(finder).add(archive); |
173 parsedArchives.get(finder).add(archive); |
173 |
174 |
174 trace("parsing %s %s%n", archive.getName(), archive.path()); |
175 trace("parsing %s %s%n", archive.getName(), archive.path()); |
175 FutureTask<Set<Location>> task = new FutureTask<>(new Callable<>() { |
176 FutureTask<Set<Location>> task = new FutureTask<>(() -> { |
176 public Set<Location> call() throws Exception { |
177 Set<Location> targets = new HashSet<>(); |
177 Set<Location> targets = new HashSet<>(); |
178 for (ClassFile cf : archive.reader().getClassFiles()) { |
178 for (ClassFile cf : archive.reader().getClassFiles()) { |
179 if (cf.access_flags.is(AccessFlags.ACC_MODULE)) |
179 if (cf.access_flags.is(AccessFlags.ACC_MODULE)) |
180 continue; |
180 continue; |
181 |
181 |
182 String classFileName; |
182 String classFileName; |
183 try { |
183 try { |
184 classFileName = cf.getName(); |
184 classFileName = cf.getName(); |
185 } catch (ConstantPoolException e) { |
185 } catch (ConstantPoolException e) { |
186 throw new ClassFileError(e); |
186 throw new Dependencies.ClassFileError(e); |
187 } |
|
188 |
|
189 // filter source class/archive |
|
190 String cn = classFileName.replace('/', '.'); |
|
191 if (!finder.accept(archive, cn, cf.access_flags)) |
|
192 continue; |
|
193 |
|
194 // tests if this class matches the -include |
|
195 if (!filter.matches(cn)) |
|
196 continue; |
|
197 |
|
198 for (Dependency d : finder.findDependencies(cf)) { |
|
199 if (filter.accepts(d)) { |
|
200 archive.addClass(d.getOrigin(), d.getTarget()); |
|
201 targets.add(d.getTarget()); |
|
202 } else { |
|
203 // ensure that the parsed class is added the archive |
|
204 archive.addClass(d.getOrigin()); |
187 } |
205 } |
188 |
206 parsedClasses.putIfAbsent(d.getOrigin(), archive); |
189 // filter source class/archive |
|
190 String cn = classFileName.replace('/', '.'); |
|
191 if (!finder.accept(archive, cn, cf.access_flags)) |
|
192 continue; |
|
193 |
|
194 // tests if this class matches the -include |
|
195 if (!filter.matches(cn)) |
|
196 continue; |
|
197 |
|
198 for (Dependency d : finder.findDependencies(cf)) { |
|
199 if (filter.accepts(d)) { |
|
200 archive.addClass(d.getOrigin(), d.getTarget()); |
|
201 targets.add(d.getTarget()); |
|
202 } else { |
|
203 // ensure that the parsed class is added the archive |
|
204 archive.addClass(d.getOrigin()); |
|
205 } |
|
206 parsedClasses.putIfAbsent(d.getOrigin(), archive); |
|
207 } |
|
208 } |
207 } |
209 |
|
210 return targets; |
|
211 } |
208 } |
|
209 |
|
210 return targets; |
212 }); |
211 }); |
213 tasks.add(task); |
212 tasks.add(task); |
214 pool.submit(task); |
213 pool.submit(task); |
215 return Optional.of(task); |
214 return Optional.of(task); |
216 } |
215 } |