Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalac fails to load references from a manifest-only jar #4355

Closed
scabug opened this issue Mar 18, 2011 · 4 comments
Closed

scalac fails to load references from a manifest-only jar #4355

scabug opened this issue Mar 18, 2011 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented Mar 18, 2011

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)
@scabug
Copy link
Author

scabug commented Mar 18, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4355?orig=1
Reporter: Pete (cur.m.geon)
Attachments:

  • manifestjar.jar (created on Mar 18, 2011 6:07:27 PM UTC, 357 bytes)
  • Sample.scala (created on Mar 18, 2011 6:09:23 PM UTC, 142 bytes)
  • SimpleJava.java (created on Mar 18, 2011 6:08:53 PM UTC, 200 bytes)
  • thejar.jar (created on Mar 18, 2011 6:06:57 PM UTC, 1007 bytes)

@scabug
Copy link
Author

scabug commented Mar 22, 2011

@ingoem said:
Do you know more about this, Paul?

@scabug
Copy link
Author

scabug commented Apr 13, 2011

@paulp said:
Replying to [comment:2 imaier]:

Do you know more about this, Paul?

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

@scabug
Copy link
Author

scabug commented Nov 21, 2011

Commit Message Bot (anonymous) said:
(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 #4355, review by harrah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants