langtools/test/tools/apt/Basics/CheckAptIsRemovedTest.java
author attila
Thu, 27 Mar 2014 14:09:40 +0100
changeset 24732 e7d905b01c08
parent 22444 c79ee1e6742f
child 26100 bb7dd001d190
permissions -rw-r--r--
8038416: Access to undefined scoped variables deoptimized too much Reviewed-by: jlaskey, lagergren
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16304
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     1
/*
22444
c79ee1e6742f 8031745: Remove unneeded/obsolete -source/-target options in javac tests, part 1
darcy
parents: 16304
diff changeset
     2
 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
16304
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     4
 *
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     8
 *
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    13
 * accompanied this code).
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    14
 *
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    18
 *
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    21
 * questions.
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    22
 */
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    23
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    24
/*
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    25
 * @test
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    26
 * @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    27
 * @summary Make sure apt is removed and doesn't come back
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    28
 * @library /tools/javac/lib
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    29
 * @build ToolBox
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    30
 * @run main CheckAptIsRemovedTest
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    31
 */
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    32
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    33
import java.nio.file.Files;
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    34
import java.nio.file.Path;
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    35
import java.nio.file.Paths;
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    36
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    37
//original test: test/tools/apt/Basics/apt.sh
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    38
public class CheckAptIsRemovedTest {
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    39
    //I think this class can be let with the imports only and that should be enough for as test's purpose
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    40
    private static final String NullAPFSrc =
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    41
        "import com.sun.mirror.apt.*;\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    42
        "import com.sun.mirror.declaration.*;\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    43
        "import com.sun.mirror.type.*;\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    44
        "import com.sun.mirror.util.*;\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    45
        "import java.util.Collection;\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    46
        "import java.util.Set;\n\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    47
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    48
        "public class NullAPF implements AnnotationProcessorFactory {\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    49
        "    static class NullAP implements AnnotationProcessor {\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    50
        "        NullAP(AnnotationProcessorEnvironment ape) {}\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    51
        "        public void process() {return;}\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    52
        "    }\n\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    53
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    54
        "    static Collection<String> supportedTypes;\n\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    55
        "    static {\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    56
        "        String types[] = {\"*\"};\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    57
        "        supportedTypes = java.util.Arrays.asList(types);\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    58
        "    }\n\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    59
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    60
        "    public Collection<String> supportedOptions() {\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    61
        "        return java.util.Collections.emptySet();\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    62
        "    }\n\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    63
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    64
        "    public Collection<String> supportedAnnotationTypes() {\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    65
        "        return supportedTypes;\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    66
        "    }\n\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    67
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    68
        "    public AnnotationProcessor getProcessorFor(" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    69
        "        Set<AnnotationTypeDeclaration> atds,\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    70
        "        AnnotationProcessorEnvironment env) {\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    71
        "        return new NullAP(env);\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    72
        "    }\n" +
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    73
        "}";
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    74
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    75
    public static void main(String[] args) throws Exception {
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    76
        String testJDK = System.getProperty("test.jdk");
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    77
        Path aptLin = Paths.get(testJDK, "bin", "apt");
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    78
        Path aptWin = Paths.get(testJDK, "bin", "apt.exe");
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    79
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    80
//        if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    81
        if (Files.exists(aptLin) || Files.exists(aptWin)) {
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    82
            throw new AssertionError("apt executable should not exist");
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    83
        }
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    84
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    85
//        JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    86
//        $JAVAC ${TESTSRC}/NullAPF.java
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    87
        Path classpath = Paths.get(testJDK, "lib", "tools.jar");
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    88
        ToolBox.JavaToolArgs javacArgs =
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    89
                new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
22444
c79ee1e6742f 8031745: Remove unneeded/obsolete -source/-target options in javac tests, part 1
darcy
parents: 16304
diff changeset
    90
                .setOptions("-sourcepath", ".",
16304
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    91
                    "-classpath", classpath.toString())
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    92
                .setSources(NullAPFSrc);
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    93
        ToolBox.javac(javacArgs);
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    94
    }
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    95
475504933a2d 8006212: javac, convert jtreg tests from shell script to java
vromero
parents:
diff changeset
    96
}