Search in sources :

Example 1 with JavaPlatform

use of scala.tools.nsc.backend.JavaPlatform in project zeppelin by apache.

the class SparkDependencyResolver method updateCompilerClassPath.

private void updateCompilerClassPath(URL[] urls) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    JavaPlatform platform = (JavaPlatform) global.platform();
    MergedClassPath<AbstractFile> newClassPath = mergeUrlsIntoClassPath(platform, urls);
    Method[] methods = platform.getClass().getMethods();
    for (Method m : methods) {
        if (m.getName().endsWith("currentClassPath_$eq")) {
            m.invoke(platform, new Some(newClassPath));
            break;
        }
    }
    // NOTE: Must use reflection until this is exposed/fixed upstream in Scala
    List<String> classPaths = new LinkedList<>();
    for (URL url : urls) {
        classPaths.add(url.getPath());
    }
    // Reload all jars specified into our compiler
    global.invalidateClassPathEntries(scala.collection.JavaConversions.asScalaBuffer(classPaths).toList());
}
Also used : AbstractFile(scala.reflect.io.AbstractFile) Some(scala.Some) JavaPlatform(scala.tools.nsc.backend.JavaPlatform) Method(java.lang.reflect.Method) LinkedList(java.util.LinkedList) URL(java.net.URL)

Aggregations

Method (java.lang.reflect.Method)1 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 Some (scala.Some)1 AbstractFile (scala.reflect.io.AbstractFile)1 JavaPlatform (scala.tools.nsc.backend.JavaPlatform)1