Scala Programming Language
  1. Scala Programming Language
  2. SI-5343

scalac can't load class which refers a class not from classpath

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1
    • Fix Version/s: Scala 2.10.0
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      So I use a library which is supposed to work on jdk6 and jdk7. In some places it uses nio2.
      Javac is to use this library just fine, but scalac throws

      error: error while loading TFile, Missing dependency 'class java.nio.file.Path', required by c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-file\7.4.3\truezip-file-7.4.3.jar(de/schlichtherle/truezip/file/TFile.class)
      

      here is a transcript:

      D:\>javac -cp c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-file\7.4.3\truezip-file-7.4.3.jar;c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-driver-file\7.4.3\truezip-driver-file-7.4.3.jar;c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-kernel\7.4.3\truezip-kernel-7.4.3.jar test.java
      de\schlichtherle\truezip\file\TFile.class(de\schlichtherle\truezip\file:TFile.class): warning: Cannot find annotation method 'value()' in type 'edu.umd.cs.findbugs.annotations.DefaultAnnotation': class file for edu.umd.cs.findbugs.annotations.DefaultAnnotation not found
      de\schlichtherle\truezip\file\TFile.class(de\schlichtherle\truezip\file:TFile.class): warning: Cannot find annotation method 'value()' in type 'edu.umd.cs.findbugs.annotations.SuppressWarnings': class file for edu.umd.cs.findbugs.annotations.SuppressWarnings not found
      de\schlichtherle\truezip\fs\FsMountPoint.class(de\schlichtherle\truezip\fs:FsMountPoint.class): warning: Cannot find annotation method 'value()' in type 'edu.umd.cs.findbugs.annotations.DefaultAnnotation'
      de\schlichtherle\truezip\fs\FsMountPoint.class(de\schlichtherle\truezip\fs:FsMountPoint.class): warning: Cannot find annotation method 'value()' in type 'edu.umd.cs.findbugs.annotations.SuppressWarnings'
      de\schlichtherle\truezip\fs\FsPath.class(de\schlichtherle\truezip\fs:FsPath.class): warning: Cannot find annotation method 'value()' in type 'edu.umd.cs.findbugs.annotations.DefaultAnnotation'
      de\schlichtherle\truezip\fs\FsPath.class(de\schlichtherle\truezip\fs:FsPath.class): warning: Cannot find annotation method 'value()' in type 'edu.umd.cs.findbugs.annotations.SuppressWarnings'
      6 warnings
      
      D:\>java -cp c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-file\7.4.3\truezip-file-7.4.3.jar;c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-driver-file\7.4.3\truezip-driver-file-7.4.3.jar;c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-kernel\7.4.3\truezip-kernel-7.4.3.jar;.
      test
      D:\
      
      D:\>scalac -cp c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-file\7.4.3\truezip-file-7.4.3.jar;c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-driver-file\7.4.3\truezip-driver-file-7.4.3.jar;c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-kernel\7.4.3\truezip-kernel-7.4.3.jar
      test.scala
      error: error while loading TFile, Missing dependency 'class java.nio.file.Path', required by c:\Users\OlegYch\.m2\repository\de\schlichtherle\truezip\truezip-file\7.4.3\truezip-file-7.4.3.jar(de/schlichtherle/truezip/file/TFile.class)
      one error found
      
      D:\>java -version
      java version "1.6.0_24"
      Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
      Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode)
      
      D:\>scala -version
      Scala code runner version 2.9.1.final -- Copyright 2002-2011, LAMP/EPFL
      

      here is test.scala

      object Main extends App {
        System.out.println(new de.schlichtherle.truezip.file.TFile("").getAbsoluteFile());
      }
      

      here is test.java

      public class test {
        public static void main(String[] args) {
          System.out.println(new de.schlichtherle.truezip.file.TFile("").getAbsoluteFile());
        }
      }
      

      here is path to dependency packed as one jar
      http://repo1.maven.org/maven2/de/schlichtherle/truezip/truezip-samples/7.4.3/truezip-samples-7.4.3-jar-with-dependencies.jar

        Activity

        Hide
        Pedro Furlanetto added a comment - - edited

        A sequence of bash commands creating and running a small test case.

        echo "public class A { public B b; }" > A.java
        echo "public class B { public C c; }" > B.java
        echo "public class C { }" > C.java
        echo class A_scala { var b:B = _ }  > A.scala # only to avoid name .class file name confusion
        
        javac *.java
        scalac A.scala
        

        Every thing works fine so far.

         
        rm C.class
        rm A.class
        

        Now comes the interesting part:

        javac A.java
        ls
        

        As you can see, Java compiles just fine.

        scalac A.scala
        

        This will cause

        error: error while loading B, Missing dependency 'class C', required by ./B.class
        one error found

        Scalac seems to be trying to load dependencies of B, despite B being already compiled.

        Show
        Pedro Furlanetto added a comment - - edited A sequence of bash commands creating and running a small test case. echo "public class A { public B b; }" > A.java echo "public class B { public C c; }" > B.java echo "public class C { }" > C.java echo class A_scala { var b:B = _ } > A.scala # only to avoid name .class file name confusion javac *.java scalac A.scala Every thing works fine so far. rm C.class rm A.class Now comes the interesting part: javac A.java ls As you can see, Java compiles just fine. scalac A.scala This will cause error: error while loading B, Missing dependency 'class C', required by ./B.class one error found Scalac seems to be trying to load dependencies of B, despite B being already compiled.
        Hide
        Pedro Furlanetto added a comment -

        BTW, it's related to https://issues.scala-lang.org/browse/SI-3506, which never got a self contained test case.

        Show
        Pedro Furlanetto added a comment - BTW, it's related to https://issues.scala-lang.org/browse/SI-3506 , which never got a self contained test case.
        Hide
        Paul Phillips added a comment -

        1684baefd2

        Show
        Paul Phillips added a comment - 1684baefd2
        Hide
        Oleg Aleshko added a comment -

        thanks, it works

        Show
        Oleg Aleshko added a comment - thanks, it works

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Oleg Aleshko
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development