jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.java
changeset 28760 b83d51c77b31
parent 5506 202f599c92aa
equal deleted inserted replaced
28759:fb96c297a819 28760:b83d51c77b31
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * Creates a URLClassLoader from 2 file URLs. The first
    25  * Creates a URLClassLoader from a file URL. The file URL
    26  * file URL is constructed from the given argument. The
    26  * is constructed from the given argument. Once created the test
    27  * second is the SDK tools.jar. Once created the test
       
    28  * attempts to load another test case (ListConnectors)
    27  * attempts to load another test case (ListConnectors)
    29  * using the class loader and then it invokes the list()
    28  * using the class loader and then it invokes the list()
    30  * method.
    29  * method.
    31  */
    30  */
    32 import java.net.URL;
    31 import java.net.URL;
    37 public class JdiLoadedByCustomLoader {
    36 public class JdiLoadedByCustomLoader {
    38 
    37 
    39     public static void main(String args[]) throws Exception {
    38     public static void main(String args[]) throws Exception {
    40         // create files from given arguments and tools.jar
    39         // create files from given arguments and tools.jar
    41         File f1 = new File(args[0]);
    40         File f1 = new File(args[0]);
    42         String home = System.getProperty("java.home");
       
    43         String tools = ".." + File.separatorChar + "lib" +
       
    44             File.separatorChar + "tools.jar";
       
    45         File f2 = (new File(home, tools)).getCanonicalFile();
       
    46 
    41 
    47         // create class loader
    42         // create class loader
    48         URL[] urls = { f1.toURL(), f2.toURL() };
    43         URL[] urls = { f1.toURL() };
    49         URLClassLoader cl = new URLClassLoader(urls);
    44         URLClassLoader cl = new URLClassLoader(urls);
    50 
    45 
    51         // load ListConnectors using the class loader
    46         // load ListConnectors using the class loader
    52         // and then invoke the list method.
    47         // and then invoke the list method.
    53         Class c = Class.forName("ListConnectors", true, cl);
    48         Class c = Class.forName("ListConnectors", true, cl);