test/tools/javac/innerClassFile/InnerClassFileTest.java

Mon, 26 Oct 2015 13:23:30 -0700

author
asaha
date
Mon, 26 Oct 2015 13:23:30 -0700
changeset 2999
683b3e7e05a7
parent 0
959103a6100f
permissions
-rw-r--r--

Added tag jdk8u76-b00 for changeset 10ffafaf5340

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     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
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 4491755 4785453
    27  * @summary Prob w/static inner class with same name as a regular class
    28  * @library /tools/javac/lib
    29  * @build ToolBox
    30  * @run main InnerClassFileTest
    31  */
    33 import java.nio.file.Paths;
    35 //original test: test/tools/javac/innerClassFile/Driver.sh
    36 public class InnerClassFileTest {
    38     private static final String BSrc =
    39         "package x;\n" +
    40         "\n" +
    41         "import x.*;\n" +
    42         "\n" +
    43         "public class B {\n" +
    44         "    public static class C {}\n" +
    45         "}";
    47     private static final String CSrc =
    48         "package x;\n" +
    49         "\n" +
    50         "import x.*;\n" +
    51         "\n" +
    52         "public class C {}";
    54     private static final String MainSrc =
    55         "package y;\n" +
    56         "\n" +
    57         "class Main {\n" +
    58         "        private R1 a;\n" +
    59         "        private R2 b;\n" +
    60         "        private R3 c;\n" +
    61         "}";
    63     private static final String R1Src =
    64         "package y;\n" +
    65         "\n" +
    66         "public final class R1 {\n" +
    67         "    x.B.C a = null;\n" +
    68         "    x.C b = null;\n" +
    69         "    R2 c = new R2();\n" +
    70         "}";
    72     private static final String R2Src =
    73         "package y;\n" +
    74         "\n" +
    75         "public final class R2 {\n" +
    76         "    x.B.C a = null;\n" +
    77         "    x.C b = null;\n" +
    78         "}";
    80     private static final String R3Src =
    81         "package y;\n" +
    82         "\n" +
    83         "public final class R3 {\n" +
    84         "    x.B.C a = null;\n" +
    85         "    x.C b = null;\n" +
    86         "    R1 c = new R1();\n" +
    87         "}";
    89     public static void main(String args[]) throws Exception {
    90         new InnerClassFileTest().run();
    91     }
    93     void run() throws Exception {
    94         createFiles();
    95         compileFiles();
    96     }
    98     void createFiles() throws Exception {
    99 //        mkdir src
   100 //        cp -r ${TESTSRC}${FS}* src
   101         ToolBox.createJavaFileFromSource(Paths.get("src"), BSrc);
   102         ToolBox.createJavaFileFromSource(Paths.get("src"), CSrc);
   103         ToolBox.createJavaFileFromSource(Paths.get("src"), MainSrc);
   104         ToolBox.createJavaFileFromSource(Paths.get("src"), R1Src);
   105         ToolBox.createJavaFileFromSource(Paths.get("src"), R2Src);
   106         ToolBox.createJavaFileFromSource(Paths.get("src"), R3Src);
   107     }
   109     void compileFiles() throws Exception {
   110 //        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
   111 //              -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
   112         ToolBox.JavaToolArgs args =
   113                 new ToolBox.JavaToolArgs()
   114                 .setAllArgs("-d", ".", "-cp" , ".", "-sourcepath", "src",
   115                 "src/x/B.java", "src/x/C.java", "src/y/Main.java");
   116         ToolBox.javac(args);
   118 //        rm y/R3.class
   119         ToolBox.rm(Paths.get("y", "R3.class"));
   121 //        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
   122 //                -sourcepath src src/y/Main.java
   123         args.setAllArgs("-d", ".", "-cp", ".", "-sourcepath", "src", "src/y/Main.java");
   124         ToolBox.javac(args);
   125     }
   127 }

mercurial