diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-08-09 19:05:15 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-10-18 17:44:39 +0200 |
commit | f7c6213ee7cd4afb6f11b5ce14479aa68974b01c (patch) | |
tree | 904e07144a033bc25f0618217deec608b3fac3d2 /test/files/run/t6240a/StepOne.java | |
parent | f94b2246361ed6ed19300d27033aedad7e3ddd9d (diff) | |
download | scala-f7c6213ee7cd4afb6f11b5ce14479aa68974b01c.tar.gz scala-f7c6213ee7cd4afb6f11b5ce14479aa68974b01c.tar.bz2 scala-f7c6213ee7cd4afb6f11b5ce14479aa68974b01c.zip |
tests for fancy classloader configurations
Diffstat (limited to 'test/files/run/t6240a/StepOne.java')
-rw-r--r-- | test/files/run/t6240a/StepOne.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/files/run/t6240a/StepOne.java b/test/files/run/t6240a/StepOne.java new file mode 100644 index 0000000000..7abd148d69 --- /dev/null +++ b/test/files/run/t6240a/StepOne.java @@ -0,0 +1,41 @@ +import java.io.File; +import java.io.IOException; +import java.lang.ClassNotFoundException; +import java.lang.NoSuchMethodException; +import java.lang.IllegalAccessException; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.MalformedURLException; + +public class StepOne { + public static void main(String[] args) + throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, IOException { + String[] launchPaths = System.getProperty("launch.classpath").split(":"); + + // move away StepThree + File tempDir = File.createTempFile("temp", Long.toString(System.nanoTime())); + System.setProperty("launch.step.three", tempDir.getAbsolutePath()); + tempDir.delete(); + tempDir.mkdir(); + File[] testClasses = new File(launchPaths[0]).listFiles(); + for (int i = 0; i < testClasses.length; i++) { + File testClass = testClasses[i]; + if (testClass.getPath().contains("StepThree")) { + File testClassMoved = new File(tempDir.getAbsolutePath() + "/" + testClass.getName()); + testClass.renameTo(testClassMoved); + } + } + + // launch StepTwo + URL[] launchURLs = new URL[launchPaths.length]; + for (int i = 0; i < launchPaths.length; i++) { + launchURLs[i] = new File(launchPaths[i]).toURL(); + } + URLClassLoader classLoader = new URLClassLoader(launchURLs, Object.class.getClassLoader()); + Class<?> stepTwo = classLoader.loadClass("StepTwo"); + Method main = stepTwo.getDeclaredMethod("main", String[].class); + main.invoke(null, (Object)(new String[]{})); + } +}
\ No newline at end of file |