Thu, 15 Dec 2011 15:47:47 -0800
Added tag jdk8-b16 for changeset ec2c0973cc31
duke@1 | 1 | #!/bin/sh |
duke@1 | 2 | |
duke@1 | 3 | # |
ohair@554 | 4 | # Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 5 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 6 | # |
duke@1 | 7 | # This code is free software; you can redistribute it and/or modify it |
duke@1 | 8 | # under the terms of the GNU General Public License version 2 only, as |
duke@1 | 9 | # published by the Free Software Foundation. |
duke@1 | 10 | # |
duke@1 | 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | # version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | # accompanied this code). |
duke@1 | 16 | # |
duke@1 | 17 | # You should have received a copy of the GNU General Public License version |
duke@1 | 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | # |
ohair@554 | 21 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | # or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | # questions. |
duke@1 | 24 | # |
duke@1 | 25 | |
duke@1 | 26 | # @test |
duke@1 | 27 | # @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 |
duke@1 | 28 | # @run shell ../verifyVariables.sh |
duke@1 | 29 | # @build Milk MethodAnnotations NestedClassAnnotations StaticFieldAnnotations StaticMethodAnnotations ParameterAnnotations |
duke@1 | 30 | # @run shell apt.sh |
duke@1 | 31 | # @summary test consistency of annotation discovery |
duke@1 | 32 | # @author Joseph D. Darcy |
duke@1 | 33 | |
duke@1 | 34 | OS=`uname -s`; |
duke@1 | 35 | case "${OS}" in |
jjg@387 | 36 | CYGWIN* ) |
jjg@387 | 37 | DIFFOPTS="--strip-trailing-cr" |
duke@1 | 38 | ;; |
duke@1 | 39 | |
duke@1 | 40 | * ) |
duke@1 | 41 | ;; |
duke@1 | 42 | esac |
duke@1 | 43 | |
duke@1 | 44 | # Construct path to apt executable |
darcy@331 | 45 | APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message " |
duke@1 | 46 | |
duke@1 | 47 | printf "%s\n" "-classpath ${TESTCLASSES}" > options |
duke@1 | 48 | printf "%s\n" "-factorypath ./nullap.jar" >> options |
duke@1 | 49 | printf "%s\n" "-sourcepath ${TESTSRC} " >> options |
duke@1 | 50 | printf "%s\n" "-nocompile" >> options |
duke@1 | 51 | printf "%s\n" "-XListAnnotationTypes" >> options |
duke@1 | 52 | |
duke@1 | 53 | printf "%s\n" "-classpath ${TESTCLASSES}" > options1 |
duke@1 | 54 | printf "%s\n" "-factorypath ./nullap.jar" >> options1 |
duke@1 | 55 | printf "%s\n" "-sourcepath ${TESTSRC} " >> options1 |
duke@1 | 56 | printf "%s\n" "-nocompile" >> options1 |
duke@1 | 57 | printf "%s\n" "-XListAnnotationTypes" >> options1 |
duke@1 | 58 | printf "%s\n" "-XclassesAsDecls" >> options1 |
duke@1 | 59 | |
darcy@331 | 60 | |
duke@1 | 61 | # Construct path to javac executable |
duke@1 | 62 | JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " |
duke@1 | 63 | JAR="${TESTJAVA}/bin/jar " |
duke@1 | 64 | |
duke@1 | 65 | $JAVAC ${TESTSRC}/NullAPF.java \ |
duke@1 | 66 | ${TESTSRC}/FreshnessApf.java \ |
duke@1 | 67 | ${TESTSRC}/TestGetTypeDeclarationApf.java \ |
duke@1 | 68 | ${TESTSRC}/TestGetPackageApf.java |
duke@1 | 69 | RESULT=$? |
duke@1 | 70 | |
duke@1 | 71 | case "${RESULT}" in |
duke@1 | 72 | 0 ) |
duke@1 | 73 | ;; |
duke@1 | 74 | |
duke@1 | 75 | * ) |
duke@1 | 76 | echo "Compilation failed." |
duke@1 | 77 | exit 1 |
duke@1 | 78 | esac |
duke@1 | 79 | |
duke@1 | 80 | echo "Making services directory and copying services information." |
duke@1 | 81 | mkdir -p META-INF/services |
duke@1 | 82 | cp ${TESTSRC}/com.sun.mirror.apt.AnnotationProcessorFactory ./META-INF/services |
duke@1 | 83 | $JAR cvf0 nullap.jar NullAPF*.class META-INF |
duke@1 | 84 | |
duke@1 | 85 | ANNOTATION_FILES="${TESTSRC}/ClassAnnotations.java \ |
duke@1 | 86 | ${TESTSRC}/MethodAnnotations.java \ |
duke@1 | 87 | ${TESTSRC}/NestedClassAnnotations.java \ |
duke@1 | 88 | ${TESTSRC}/StaticFieldAnnotations.java \ |
duke@1 | 89 | ${TESTSRC}/StaticMethodAnnotations.java \ |
duke@1 | 90 | ${TESTSRC}/ParameterAnnotations.java" |
duke@1 | 91 | |
duke@1 | 92 | for i in ${ANNOTATION_FILES} |
duke@1 | 93 | do |
duke@1 | 94 | printf "%s\n" "Testing annotations on source file ${i}" |
duke@1 | 95 | ${APT} @options ${i} 2> result.txt |
jjg@387 | 96 | diff ${DIFFOPTS} ${TESTSRC}/golden.txt result.txt |
duke@1 | 97 | |
duke@1 | 98 | RESULT=$? |
duke@1 | 99 | case "$RESULT" in |
duke@1 | 100 | 0 ) |
duke@1 | 101 | ;; |
duke@1 | 102 | |
duke@1 | 103 | * ) |
duke@1 | 104 | echo "Unexpected set of annotations on source files found." |
duke@1 | 105 | exit 1 |
duke@1 | 106 | esac |
duke@1 | 107 | |
duke@1 | 108 | CLASS=`basename ${i} .java` |
duke@1 | 109 | printf "%s\n" "Testing annotations on class file ${CLASS}" |
duke@1 | 110 | ${APT} @options1 ${CLASS} 2> result2.txt |
jjg@387 | 111 | diff ${DIFFOPTS} ${TESTSRC}/golden.txt result2.txt |
duke@1 | 112 | |
duke@1 | 113 | RESULT=$? |
duke@1 | 114 | case "$RESULT" in |
duke@1 | 115 | 0 ) |
duke@1 | 116 | ;; |
duke@1 | 117 | |
duke@1 | 118 | * ) |
duke@1 | 119 | echo "Unexpected set of annotations on class files found." |
duke@1 | 120 | exit 1 |
duke@1 | 121 | esac |
duke@1 | 122 | done |
duke@1 | 123 | |
duke@1 | 124 | # Verify source files are favored over class files |
duke@1 | 125 | |
duke@1 | 126 | printf "%s\n" "-factorypath ." > options2 |
duke@1 | 127 | printf "%s\n" "-factory FreshnessApf" >> options2 |
duke@1 | 128 | printf "%s\n" "-sourcepath ${TESTSRC}" >> options2 |
duke@1 | 129 | printf "%s\n" "-classpath ${TESTCLASSES}" >> options2 |
duke@1 | 130 | printf "%s\n" "-nocompile" >> options2 |
duke@1 | 131 | |
duke@1 | 132 | ${APT} @options2 ${TESTSRC}/Indirect.java |
duke@1 | 133 | |
duke@1 | 134 | RESULT=$? |
duke@1 | 135 | case "$RESULT" in |
duke@1 | 136 | 0 ) |
duke@1 | 137 | ;; |
duke@1 | 138 | |
duke@1 | 139 | * ) |
duke@1 | 140 | exit 1 |
duke@1 | 141 | esac |
duke@1 | 142 | |
duke@1 | 143 | # Verify new classes can be loaded by getTypeDeclaration |
duke@1 | 144 | |
duke@1 | 145 | printf "%s\n" "-factorypath ." > options3 |
duke@1 | 146 | printf "%s\n" "-factory TestGetTypeDeclarationApf" >> options3 |
duke@1 | 147 | printf "%s\n" "-sourcepath ${TESTSRC}" >> options3 |
duke@1 | 148 | |
duke@1 | 149 | # ${APT} @options3 |
duke@1 | 150 | |
duke@1 | 151 | RESULT=$? |
duke@1 | 152 | case "$RESULT" in |
duke@1 | 153 | 0 ) |
duke@1 | 154 | ;; |
duke@1 | 155 | |
duke@1 | 156 | * ) |
duke@1 | 157 | exit 1 |
duke@1 | 158 | esac |
duke@1 | 159 | |
duke@1 | 160 | # Verify packages can be loaded by getPackage |
duke@1 | 161 | |
duke@1 | 162 | printf "%s\n" "-factorypath ." > options4 |
duke@1 | 163 | printf "%s\n" "-factory TestGetPackageApf" >> options4 |
duke@1 | 164 | printf "%s\n" "-sourcepath ${TESTSRC}" >> options4 |
duke@1 | 165 | |
duke@1 | 166 | ${APT} @options4 |
duke@1 | 167 | |
duke@1 | 168 | RESULT=$? |
duke@1 | 169 | case "$RESULT" in |
duke@1 | 170 | 0 ) |
duke@1 | 171 | ;; |
duke@1 | 172 | |
duke@1 | 173 | * ) |
duke@1 | 174 | exit 1 |
duke@1 | 175 | esac |
duke@1 | 176 | exit 0 |