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

scalac fails to load references from a manifest-only jar

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      I am dealing with a project that requires a large number of entries in a class path, which results in very large command line values for the -classpath argument. Given the limitation on certain platforms (windows) for command line length, the solution for our java projects is to create a manifest-only jar, which has a class-path entry pointing to all of the dirs/jars required in the build.

      The issue I have encountered is what appears to be an inability in scalac to properly load the referenced entries contained in a manifest-only jar.

      Given the java class:

      package a.b.c;
      public class SimpleJava {
      	
      	public String toString() {
      		return SimpleJava.class.getName();
      	}
      	
      	public static void main(String[] args) {
      		System.out.println("hello from jar");
      	}
      }
      

      Compiled and packaged into a jar (thejar.jar) and then create a manifest-only jar (manifestjar.jar) that references the jar containing SimpleJava

      Given scala object Sample:

      import a.b.c.SimpleJava
      
      object Sample {
      
        def main(args: Array[String]) {
      	  val simple = new SimpleJava;
      	  println(simple toString);
        }
      }
      

      The command 'scalac -classpath ./manifestjar.jar Sample.scala' produces:

      Sample.scala:1: error: not found: value a
      import a.b.c.SimpleJava
      ^
      one error found

      Where: scalac -classpath ./thejar.jar .Sample.scala succeeds.

      === What is the expected behavior? ===
      The expectation would be that scalac would examine the classpath entries' manifest to see if there is a class-path entry and if so load the referenced dirs/jars for use in the compile.

      === What do you see instead? ===
      The compile fails with 'not found' errors for elements referenced in the manifest-only jar.

      === What versions of the following are you using? ===

      • Scala: 2.8.1
      • Java: 1.6.0_24
      • Operating system: Mac OS X 10.6.6 (10J567)
      1. Sample.scala
        0.1 kB
        Jira Admin
      2. SimpleJava.java
        0.2 kB
        Jira Admin

        Activity

        Hide
        Ingo Maier added a comment -

        Do you know more about this, Paul?

        Show
        Ingo Maier added a comment - Do you know more about this, Paul?
        Hide
        Paul Phillips added a comment -

        Replying to [comment:2 imaier]:
        > Do you know more about this, Paul?

        It's just yet-to-be-implemented. Certainly it's desirable.

        Show
        Paul Phillips added a comment - Replying to [comment:2 imaier] : > Do you know more about this, Paul? It's just yet-to-be-implemented. Certainly it's desirable.
        Hide
        Commit Message Bot added a comment -

        (extempore in r26041) Implemented manifest-based class-paths.

        If you run a jar directly, like

        scala foo.jar

        Then if a Class-Path attribute is present in the jar manifest, the
        classpath will be constructed from that instead of the arguments. Some
        things remain to be determined, like whether it's supposed to replace
        a classpath given on the command line or supplement it, and whether
        the master jar should be on the classpath or only and exactly the jars
        listed in the manifest.

        There's a really nice test case, which won't be run of course, but I
        can't stand going any further without tests for these hard to test on
        all platforms things. The faux .check file shows what I see.

        Closes SI-4355, review by harrah.

        Show
        Commit Message Bot added a comment - (extempore in r26041 ) Implemented manifest-based class-paths. If you run a jar directly, like scala foo.jar Then if a Class-Path attribute is present in the jar manifest, the classpath will be constructed from that instead of the arguments. Some things remain to be determined, like whether it's supposed to replace a classpath given on the command line or supplement it, and whether the master jar should be on the classpath or only and exactly the jars listed in the manifest. There's a really nice test case, which won't be run of course, but I can't stand going any further without tests for these hard to test on all platforms things. The faux .check file shows what I see. Closes SI-4355 , review by harrah.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Pete
            TracCC:
            Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development