use of com.intellij.compiler.instrumentation.InstrumentationClassFinder in project intellij-community by JetBrains.
the class ClassProcessingBuilder method createInstrumentationClassFinder.
// utility methods
public static InstrumentationClassFinder createInstrumentationClassFinder(@Nullable JpsSdk<?> sdk, Collection<File> platformCp, Collection<File> cp, final OutputConsumer outputConsumer) throws MalformedURLException {
final URL[] platformUrls;
int index = 0;
if (sdk != null && JpsJavaSdkType.getJavaVersion(sdk) >= 9) {
platformUrls = new URL[1 + platformCp.size()];
platformUrls[index++] = InstrumentationClassFinder.createJDKPlatformUrl(sdk.getHomePath());
} else {
platformUrls = new URL[platformCp.size()];
}
for (File file : platformCp) {
platformUrls[index++] = file.toURI().toURL();
}
final URL[] urls = new URL[cp.size()];
index = 0;
for (File file : cp) {
urls[index++] = file.toURI().toURL();
}
return new InstrumentationClassFinder(platformUrls, urls) {
protected InputStream lookupClassBeforeClasspath(String internalClassName) {
final BinaryContent content = outputConsumer.lookupClassBytes(internalClassName.replace("/", "."));
if (content != null) {
return new ByteArrayInputStream(content.getBuffer(), content.getOffset(), content.getLength());
}
return null;
}
};
}
Aggregations