Skip to content

Commit

Permalink
Remove CompilerClassLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed Jan 6, 2021
1 parent 80beac4 commit 70ef66a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 144 deletions.
122 changes: 0 additions & 122 deletions sbt-bridge/src/xsbt/CompilerClassLoader.java

This file was deleted.

23 changes: 1 addition & 22 deletions sbt-bridge/src/xsbt/CompilerInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,17 @@
import xsbti.AnalysisCallback;
import xsbti.Logger;
import xsbti.Reporter;
import xsbti.Severity;
import xsbti.compile.*;

import java.io.File;

import dotty.tools.dotc.core.Contexts.ContextBase;
import dotty.tools.dotc.Main;
import dotty.tools.dotc.interfaces.*;

import java.lang.reflect.InvocationTargetException;
import java.net.URLClassLoader;

/**
* The new compiler interface is [[dotty.tools.xsbt.CompilerBridge]] that extends the new `xsbti.CompilerInterface2`.
* This interface is kept for compatibility with Mill and the sbt 1.3.x series.
*/
public final class CompilerInterface {
public CachedCompiler newCompiler(String[] options, Output output, Logger initialLog, Reporter initialDelegate) {
// The classloader that sbt uses to load the compiler bridge is broken
// (see CompilerClassLoader#fixBridgeLoader for details). To workaround
// this we construct our own ClassLoader and then run the following code
// with it:
// new CachedCompilerImpl(options, output)

try {
ClassLoader bridgeLoader = this.getClass().getClassLoader();
ClassLoader fixedLoader = CompilerClassLoader.fixBridgeLoader(bridgeLoader);
Class<?> cciClass = fixedLoader.loadClass("xsbt.CachedCompilerImpl");
return (CachedCompiler) cciClass.getConstructors()[0].newInstance(options, output);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
return new CachedCompilerImpl(options, output);
}

public void run(File[] sources, DependencyChanges changes, AnalysisCallback callback, Logger log,
Expand Down

0 comments on commit 70ef66a

Please sign in to comment.