langtools/test/tools/javac/Paths/AbsolutePathTest.java
changeset 36778 e04318f39f92
parent 36526 3b41f1c69604
equal deleted inserted replaced
36777:28d33fb9097f 36778:e04318f39f92
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    26  * @bug 8030046 8055500
    26  * @bug 8030046 8055500
    27  * @summary javac incorrectly handles absolute paths in manifest classpath
    27  * @summary javac incorrectly handles absolute paths in manifest classpath
    28  * @author govereau
    28  * @author govereau
    29  * @library /tools/lib
    29  * @library /tools/lib
    30  * @modules jdk.compiler/com.sun.tools.javac.api
    30  * @modules jdk.compiler/com.sun.tools.javac.api
    31  *          jdk.compiler/com.sun.tools.javac.file
       
    32  *          jdk.compiler/com.sun.tools.javac.main
    31  *          jdk.compiler/com.sun.tools.javac.main
    33  *          jdk.jdeps/com.sun.tools.javap
       
    34  * @ignore 8055768 ToolBox does not close opened files
    32  * @ignore 8055768 ToolBox does not close opened files
    35  * @build ToolBox
    33  * @build toolbox.ToolBox toolbox.JavacTask toolbox.JarTask
    36  * @run main AbsolutePathTest
    34  * @run main AbsolutePathTest
    37  */
    35  */
    38 
    36 
    39 import java.io.File;
    37 import java.io.File;
    40 import java.nio.file.Files;
    38 import java.nio.file.Files;
    41 import java.nio.file.Paths;
    39 import java.nio.file.Paths;
    42 
    40 
       
    41 import toolbox.JarTask;
       
    42 import toolbox.JavacTask;
       
    43 import toolbox.ToolBox;
       
    44 
    43 public class AbsolutePathTest {
    45 public class AbsolutePathTest {
    44     public static void main(String... cmdline) throws Exception {
    46     public static void main(String... cmdline) throws Exception {
    45         ToolBox tb = new ToolBox();
    47         ToolBox tb = new ToolBox();
    46 
    48 
    47         // compile test.Test
    49         // compile test.Test
    48         tb.new JavacTask()
    50         new JavacTask(tb)
    49                 .outdir(".") // this is needed to get the classfiles in test
    51                 .outdir(".") // this is needed to get the classfiles in test
    50                 .sources("package test; public class Test{}")
    52                 .sources("package test; public class Test{}")
    51                 .run();
    53                 .run();
    52 
    54 
    53         // build test.jar containing test.Test
    55         // build test.jar containing test.Test
    54         // we need the jars in a directory different from the working
    56         // we need the jars in a directory different from the working
    55         // directory to trigger the bug.
    57         // directory to trigger the bug.
    56         Files.createDirectory(Paths.get("jars"));
    58         Files.createDirectory(Paths.get("jars"));
    57         tb.new JarTask("jars/test.jar")
    59         new JarTask(tb, "jars/test.jar")
    58                 .files("test/Test.class")
    60                 .files("test/Test.class")
    59                 .run();
    61                 .run();
    60 
    62 
    61         // build second jar in jars directory using
    63         // build second jar in jars directory using
    62         // an absolute path reference to the first jar
    64         // an absolute path reference to the first jar
    63         tb.new JarTask("jars/test2.jar")
    65         new JarTask(tb, "jars/test2.jar")
    64                 .classpath(new File("jars/test.jar").getAbsolutePath())
    66                 .classpath(new File("jars/test.jar").getAbsolutePath())
    65                 .run();
    67                 .run();
    66 
    68 
    67         // this should not fail
    69         // this should not fail
    68         tb.new JavacTask()
    70         new JavacTask(tb)
    69                 .outdir(".")
    71                 .outdir(".")
    70                 .classpath("jars/test2.jar")
    72                 .classpath("jars/test2.jar")
    71                 .sources("import test.Test; class Test2 {}")
    73                 .sources("import test.Test; class Test2 {}")
    72                 .run()
    74                 .run()
    73                 .writeAll();
    75                 .writeAll();