slachiewicz / caliper

Automatically exported from code.google.com/p/caliper
Apache License 2.0
0 stars 0 forks source link

Caliper 0.5-RC1 uses java.class.path as the child JVM's classpath instead of finding the effective classpath #246

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Caliper 0.5-RC1 uses java.class.path to launch the child JVM, which doesn't 
work if a different classloader is effective.

For example, I am running caliper 0.5-RC1 within sbt, which means that 
java.class.path is "C:\Program Files (x86)\sbt\jansi.jar;C:\Program Files 
(x86)\sbt\sbt-launch.jar;C:\Program Files (x86)\sbt\classes" There is a 
classloader that has the proper classpath, however, so I can invoke

new Runner().run("some.class");

without, but the child JVM has the wrong classpath, resulting in a 
java.lang.NoClassDefFoundError.

This is with caliper 0.5-rc1, which seems to be the latest one in Maven 
central. The code in central seems very different from the current one here, 
though.

What steps will reproduce the problem?
1. Execute Caliper programmatically in an environment where java.class.path 
does not reflect the effective classpath. For testing, one can do 
System.setProperty("java.class.path", "thisdoesnotwork")
2. There is no step 2

What is the expected output? What do you see instead?

java.lang.NoClassDefFoundError

What version of the product are you using? On what operating system?

com.google.caliper caliper 0.5-rc1 from Maven central

Workaround:

If running from sbt (as we are):
System.setProperty("java.class.path",
  Thread.currentThread().getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.toList.map(_.getPath).mkString(File.pathSeparator)
)

If running from Java, setting the "java.class.path" property with something 
like the suggestion from 
http://stackoverflow.com/questions/11613988/how-to-get-classpath-from-classloade
r would probably work.

Original issue reported on code.google.com by jeanfran...@gmail.com on 2 May 2013 at 5:37

GoogleCodeExporter commented 9 years ago
Should be "without any problems", not "without,".

Original comment by jeanfran...@gmail.com on 2 May 2013 at 5:39