aoqi@0: /* aoqi@0: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: /* aoqi@0: * @test aoqi@0: * @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249 aoqi@0: * @summary Make sure apt is removed and doesn't come back aoqi@0: * @library /tools/javac/lib aoqi@0: * @build ToolBox aoqi@0: * @run main CheckAptIsRemovedTest aoqi@0: */ aoqi@0: aoqi@0: import java.nio.file.Files; aoqi@0: import java.nio.file.Path; aoqi@0: import java.nio.file.Paths; aoqi@0: aoqi@0: //original test: test/tools/apt/Basics/apt.sh aoqi@0: public class CheckAptIsRemovedTest { aoqi@0: //I think this class can be let with the imports only and that should be enough for as test's purpose aoqi@0: private static final String NullAPFSrc = aoqi@0: "import com.sun.mirror.apt.*;\n" + aoqi@0: "import com.sun.mirror.declaration.*;\n" + aoqi@0: "import com.sun.mirror.type.*;\n" + aoqi@0: "import com.sun.mirror.util.*;\n" + aoqi@0: "import java.util.Collection;\n" + aoqi@0: "import java.util.Set;\n\n" + aoqi@0: aoqi@0: "public class NullAPF implements AnnotationProcessorFactory {\n" + aoqi@0: " static class NullAP implements AnnotationProcessor {\n" + aoqi@0: " NullAP(AnnotationProcessorEnvironment ape) {}\n" + aoqi@0: " public void process() {return;}\n" + aoqi@0: " }\n\n" + aoqi@0: aoqi@0: " static Collection supportedTypes;\n\n" + aoqi@0: " static {\n" + aoqi@0: " String types[] = {\"*\"};\n" + aoqi@0: " supportedTypes = java.util.Arrays.asList(types);\n" + aoqi@0: " }\n\n" + aoqi@0: aoqi@0: " public Collection supportedOptions() {\n" + aoqi@0: " return java.util.Collections.emptySet();\n" + aoqi@0: " }\n\n" + aoqi@0: aoqi@0: " public Collection supportedAnnotationTypes() {\n" + aoqi@0: " return supportedTypes;\n" + aoqi@0: " }\n\n" + aoqi@0: aoqi@0: " public AnnotationProcessor getProcessorFor(" + aoqi@0: " Set atds,\n" + aoqi@0: " AnnotationProcessorEnvironment env) {\n" + aoqi@0: " return new NullAP(env);\n" + aoqi@0: " }\n" + aoqi@0: "}"; aoqi@0: aoqi@0: public static void main(String[] args) throws Exception { aoqi@0: String testJDK = System.getProperty("test.jdk"); aoqi@0: Path aptLin = Paths.get(testJDK, "bin", "apt"); aoqi@0: Path aptWin = Paths.get(testJDK, "bin", "apt.exe"); aoqi@0: aoqi@0: // if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then aoqi@0: if (Files.exists(aptLin) || Files.exists(aptWin)) { aoqi@0: throw new AssertionError("apt executable should not exist"); aoqi@0: } aoqi@0: aoqi@0: // JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " aoqi@0: // $JAVAC ${TESTSRC}/NullAPF.java aoqi@0: Path classpath = Paths.get(testJDK, "lib", "tools.jar"); aoqi@0: ToolBox.JavaToolArgs javacArgs = aoqi@0: new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL) aoqi@0: .setOptions("-source", "1.5", "-sourcepath", ".", aoqi@0: "-classpath", classpath.toString()) aoqi@0: .setSources(NullAPFSrc); aoqi@0: ToolBox.javac(javacArgs); aoqi@0: } aoqi@0: aoqi@0: }