Thu, 30 Jul 2009 10:29:53 +0100
6827648: Extremely slow compilation time for visitor pattern code + generics
Summary: Javac unnecessarily recomputates type-substitutions multiple times
Reviewed-by: jjg
duke@1 | 1 | #!/bin/sh |
duke@1 | 2 | |
duke@1 | 3 | # |
duke@1 | 4 | # Copyright 2004-2007 Sun Microsystems, Inc. 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 | # |
duke@1 | 21 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | # CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | # have any 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 |
duke@1 | 36 | Windows* | CYGWIN* ) |
duke@1 | 37 | SEP=";" |
duke@1 | 38 | ;; |
duke@1 | 39 | |
duke@1 | 40 | * ) |
duke@1 | 41 | SEP=":" |
duke@1 | 42 | ;; |
duke@1 | 43 | esac |
duke@1 | 44 | |
duke@1 | 45 | # Construct path to apt executable |
darcy@331 | 46 | APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message " |
duke@1 | 47 | |
duke@1 | 48 | printf "%s\n" "-classpath ${TESTCLASSES}" > options |
duke@1 | 49 | printf "%s\n" "-factorypath ./nullap.jar" >> options |
duke@1 | 50 | printf "%s\n" "-sourcepath ${TESTSRC} " >> options |
duke@1 | 51 | printf "%s\n" "-nocompile" >> options |
duke@1 | 52 | printf "%s\n" "-XListAnnotationTypes" >> options |
duke@1 | 53 | |
duke@1 | 54 | printf "%s\n" "-classpath ${TESTCLASSES}" > options1 |
duke@1 | 55 | printf "%s\n" "-factorypath ./nullap.jar" >> options1 |
duke@1 | 56 | printf "%s\n" "-sourcepath ${TESTSRC} " >> options1 |
duke@1 | 57 | printf "%s\n" "-nocompile" >> options1 |
duke@1 | 58 | printf "%s\n" "-XListAnnotationTypes" >> options1 |
duke@1 | 59 | printf "%s\n" "-XclassesAsDecls" >> options1 |
duke@1 | 60 | |
darcy@331 | 61 | |
duke@1 | 62 | # Construct path to javac executable |
duke@1 | 63 | JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " |
duke@1 | 64 | JAR="${TESTJAVA}/bin/jar " |
duke@1 | 65 | |
duke@1 | 66 | $JAVAC ${TESTSRC}/NullAPF.java \ |
duke@1 | 67 | ${TESTSRC}/FreshnessApf.java \ |
duke@1 | 68 | ${TESTSRC}/TestGetTypeDeclarationApf.java \ |
duke@1 | 69 | ${TESTSRC}/TestGetPackageApf.java |
duke@1 | 70 | RESULT=$? |
duke@1 | 71 | |
duke@1 | 72 | case "${RESULT}" in |
duke@1 | 73 | 0 ) |
duke@1 | 74 | ;; |
duke@1 | 75 | |
duke@1 | 76 | * ) |
duke@1 | 77 | echo "Compilation failed." |
duke@1 | 78 | exit 1 |
duke@1 | 79 | esac |
duke@1 | 80 | |
duke@1 | 81 | echo "Making services directory and copying services information." |
duke@1 | 82 | mkdir -p META-INF/services |
duke@1 | 83 | cp ${TESTSRC}/com.sun.mirror.apt.AnnotationProcessorFactory ./META-INF/services |
duke@1 | 84 | $JAR cvf0 nullap.jar NullAPF*.class META-INF |
duke@1 | 85 | |
duke@1 | 86 | ANNOTATION_FILES="${TESTSRC}/ClassAnnotations.java \ |
duke@1 | 87 | ${TESTSRC}/MethodAnnotations.java \ |
duke@1 | 88 | ${TESTSRC}/NestedClassAnnotations.java \ |
duke@1 | 89 | ${TESTSRC}/StaticFieldAnnotations.java \ |
duke@1 | 90 | ${TESTSRC}/StaticMethodAnnotations.java \ |
duke@1 | 91 | ${TESTSRC}/ParameterAnnotations.java" |
duke@1 | 92 | |
duke@1 | 93 | for i in ${ANNOTATION_FILES} |
duke@1 | 94 | do |
duke@1 | 95 | printf "%s\n" "Testing annotations on source file ${i}" |
duke@1 | 96 | ${APT} @options ${i} 2> result.txt |
duke@1 | 97 | diff ${TESTSRC}/golden.txt result.txt |
duke@1 | 98 | |
duke@1 | 99 | RESULT=$? |
duke@1 | 100 | case "$RESULT" in |
duke@1 | 101 | 0 ) |
duke@1 | 102 | ;; |
duke@1 | 103 | |
duke@1 | 104 | * ) |
duke@1 | 105 | echo "Unexpected set of annotations on source files found." |
duke@1 | 106 | exit 1 |
duke@1 | 107 | esac |
duke@1 | 108 | |
duke@1 | 109 | CLASS=`basename ${i} .java` |
duke@1 | 110 | printf "%s\n" "Testing annotations on class file ${CLASS}" |
duke@1 | 111 | ${APT} @options1 ${CLASS} 2> result2.txt |
duke@1 | 112 | diff ${TESTSRC}/golden.txt result2.txt |
duke@1 | 113 | |
duke@1 | 114 | RESULT=$? |
duke@1 | 115 | case "$RESULT" in |
duke@1 | 116 | 0 ) |
duke@1 | 117 | ;; |
duke@1 | 118 | |
duke@1 | 119 | * ) |
duke@1 | 120 | echo "Unexpected set of annotations on class files found." |
duke@1 | 121 | exit 1 |
duke@1 | 122 | esac |
duke@1 | 123 | done |
duke@1 | 124 | |
duke@1 | 125 | # Verify source files are favored over class files |
duke@1 | 126 | |
duke@1 | 127 | printf "%s\n" "-factorypath ." > options2 |
duke@1 | 128 | printf "%s\n" "-factory FreshnessApf" >> options2 |
duke@1 | 129 | printf "%s\n" "-sourcepath ${TESTSRC}" >> options2 |
duke@1 | 130 | printf "%s\n" "-classpath ${TESTCLASSES}" >> options2 |
duke@1 | 131 | printf "%s\n" "-nocompile" >> options2 |
duke@1 | 132 | |
duke@1 | 133 | ${APT} @options2 ${TESTSRC}/Indirect.java |
duke@1 | 134 | |
duke@1 | 135 | RESULT=$? |
duke@1 | 136 | case "$RESULT" in |
duke@1 | 137 | 0 ) |
duke@1 | 138 | ;; |
duke@1 | 139 | |
duke@1 | 140 | * ) |
duke@1 | 141 | exit 1 |
duke@1 | 142 | esac |
duke@1 | 143 | |
duke@1 | 144 | # Verify new classes can be loaded by getTypeDeclaration |
duke@1 | 145 | |
duke@1 | 146 | printf "%s\n" "-factorypath ." > options3 |
duke@1 | 147 | printf "%s\n" "-factory TestGetTypeDeclarationApf" >> options3 |
duke@1 | 148 | printf "%s\n" "-sourcepath ${TESTSRC}" >> options3 |
duke@1 | 149 | |
duke@1 | 150 | # ${APT} @options3 |
duke@1 | 151 | |
duke@1 | 152 | RESULT=$? |
duke@1 | 153 | case "$RESULT" in |
duke@1 | 154 | 0 ) |
duke@1 | 155 | ;; |
duke@1 | 156 | |
duke@1 | 157 | * ) |
duke@1 | 158 | exit 1 |
duke@1 | 159 | esac |
duke@1 | 160 | |
duke@1 | 161 | # Verify packages can be loaded by getPackage |
duke@1 | 162 | |
duke@1 | 163 | printf "%s\n" "-factorypath ." > options4 |
duke@1 | 164 | printf "%s\n" "-factory TestGetPackageApf" >> options4 |
duke@1 | 165 | printf "%s\n" "-sourcepath ${TESTSRC}" >> options4 |
duke@1 | 166 | |
duke@1 | 167 | ${APT} @options4 |
duke@1 | 168 | |
duke@1 | 169 | RESULT=$? |
duke@1 | 170 | case "$RESULT" in |
duke@1 | 171 | 0 ) |
duke@1 | 172 | ;; |
duke@1 | 173 | |
duke@1 | 174 | * ) |
duke@1 | 175 | exit 1 |
duke@1 | 176 | esac |
duke@1 | 177 | exit 0 |