Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/apt/Basics/CheckAptIsRemovedTest.java
47867 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 704124926* @summary Make sure apt is removed and doesn't come back27* @library /tools/javac/lib28* @build ToolBox29* @run main CheckAptIsRemovedTest30*/3132import java.nio.file.Files;33import java.nio.file.Path;34import java.nio.file.Paths;3536//original test: test/tools/apt/Basics/apt.sh37public class CheckAptIsRemovedTest {38//I think this class can be let with the imports only and that should be enough for as test's purpose39private static final String NullAPFSrc =40"import com.sun.mirror.apt.*;\n" +41"import com.sun.mirror.declaration.*;\n" +42"import com.sun.mirror.type.*;\n" +43"import com.sun.mirror.util.*;\n" +44"import java.util.Collection;\n" +45"import java.util.Set;\n\n" +4647"public class NullAPF implements AnnotationProcessorFactory {\n" +48" static class NullAP implements AnnotationProcessor {\n" +49" NullAP(AnnotationProcessorEnvironment ape) {}\n" +50" public void process() {return;}\n" +51" }\n\n" +5253" static Collection<String> supportedTypes;\n\n" +54" static {\n" +55" String types[] = {\"*\"};\n" +56" supportedTypes = java.util.Arrays.asList(types);\n" +57" }\n\n" +5859" public Collection<String> supportedOptions() {\n" +60" return java.util.Collections.emptySet();\n" +61" }\n\n" +6263" public Collection<String> supportedAnnotationTypes() {\n" +64" return supportedTypes;\n" +65" }\n\n" +6667" public AnnotationProcessor getProcessorFor(" +68" Set<AnnotationTypeDeclaration> atds,\n" +69" AnnotationProcessorEnvironment env) {\n" +70" return new NullAP(env);\n" +71" }\n" +72"}";7374public static void main(String[] args) throws Exception {75String testJDK = System.getProperty("test.jdk");76Path aptLin = Paths.get(testJDK, "bin", "apt");77Path aptWin = Paths.get(testJDK, "bin", "apt.exe");7879// if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then80if (Files.exists(aptLin) || Files.exists(aptWin)) {81throw new AssertionError("apt executable should not exist");82}8384// JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "85// $JAVAC ${TESTSRC}/NullAPF.java86Path classpath = Paths.get(testJDK, "lib", "tools.jar");87ToolBox.JavaToolArgs javacArgs =88new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)89.setOptions("-source", "1.5", "-sourcepath", ".",90"-classpath", classpath.toString())91.setSources(NullAPFSrc);92ToolBox.javac(javacArgs);93}9495}969798