diff options
author | Paul Phillips <paulp@improving.org> | 2011-11-21 20:38:58 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-11-21 20:38:58 +0000 |
commit | eb0643210f2007775df3d116f237056ec5916874 (patch) | |
tree | b568cfb05b6a881dc32d67fbff54497fbbcb7a0c /test/script-tests/jar-manifest/src | |
parent | f9278123ebc33bbd4833e431575c4d1b22404d57 (diff) | |
download | scala-eb0643210f2007775df3d116f237056ec5916874.tar.gz scala-eb0643210f2007775df3d116f237056ec5916874.tar.bz2 scala-eb0643210f2007775df3d116f237056ec5916874.zip |
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.
Diffstat (limited to 'test/script-tests/jar-manifest/src')
-rw-r--r-- | test/script-tests/jar-manifest/src/jar-test.scala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/script-tests/jar-manifest/src/jar-test.scala b/test/script-tests/jar-manifest/src/jar-test.scala new file mode 100644 index 0000000000..80e3aafff0 --- /dev/null +++ b/test/script-tests/jar-manifest/src/jar-test.scala @@ -0,0 +1,34 @@ +import scala.tools.nsc.util.HasClassPath + +package bippy { + object Runner { + var line = 0 + def echo(msgs: Any*) = { + line += 1 + Console.println("%-2s %s".format(line, msgs mkString " ")) + } + + def bippyBoo(quuxParameter: Int) = 5 + def bippyBingle(imparametorium: String, antidisestablish: Int, x: Float) = () + + def main(args: Array[String]): Unit = { + echo(new dingus.Printable) + val namer = new com.thoughtworks.paranamer.BytecodeReadingParanamer + getClass.getMethods filter (_.getName startsWith "bippy") foreach { m => + echo(m.getName, "has parameters:", namer.lookupParameterNames(m).mkString(", ")) + } + echo("") + echo("Urls exposed through the classloader:") + getClass.getClassLoader match { + case x: HasClassPath => x.classPathURLs foreach (x => echo(x)) + case _ => echo("None! Seems unlikely we'd get this far then.") + } + } + } +} + +package dingus { + class Printable { + override def toString = "\"Greetings from dingus.jar!\"" + } +}
\ No newline at end of file |