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 | # |
duke@1 | 2 | # Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | # |
duke@1 | 5 | # This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | # under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | # published by the Free Software Foundation. |
duke@1 | 8 | # |
duke@1 | 9 | # This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | # version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | # accompanied this code). |
duke@1 | 14 | # |
duke@1 | 15 | # You should have received a copy of the GNU General Public License version |
duke@1 | 16 | # 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | # |
duke@1 | 19 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 20 | # CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 21 | # have any questions. |
duke@1 | 22 | # |
duke@1 | 23 | |
duke@1 | 24 | # @test |
duke@1 | 25 | # @bug 4981566 5028634 5094412 6304984 |
duke@1 | 26 | # @summary Check interpretation of -target and -source options |
duke@1 | 27 | # @build CheckClassFileVersion |
jjg@287 | 28 | # @run shell check.sh |
duke@1 | 29 | |
duke@1 | 30 | TESTJAVA=${TESTJAVA:?} |
duke@1 | 31 | TC=${TESTCLASSES-.} |
duke@1 | 32 | |
duke@1 | 33 | J="$TESTJAVA/bin/java" |
duke@1 | 34 | JC="$TESTJAVA/bin/javac" |
duke@1 | 35 | CFV="$J ${TESTVMOPTS} -cp $TC CheckClassFileVersion" |
duke@1 | 36 | |
duke@1 | 37 | rm -f $TC/X.java $TC/X.java |
duke@1 | 38 | echo 'public class X { }' > $TC/X.java |
duke@1 | 39 | echo 'public enum Y { }' > $TC/Y.java |
duke@1 | 40 | |
duke@1 | 41 | |
duke@1 | 42 | # Check class-file versions |
duke@1 | 43 | |
duke@1 | 44 | check() { |
duke@1 | 45 | V=$1; shift |
duke@1 | 46 | echo "+ javac $* [$V]" |
duke@1 | 47 | $JC ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && $CFV $TC/X.class $V || exit 2 |
duke@1 | 48 | } |
duke@1 | 49 | |
duke@1 | 50 | check 48.0 -source 1.4 |
jjg@287 | 51 | |
duke@1 | 52 | check 49.0 -source 1.4 -target 1.5 |
jjg@287 | 53 | check 49.0 -source 1.5 -target 1.5 |
jjg@287 | 54 | |
jjg@287 | 55 | check 50.0 -source 1.4 -target 1.6 |
jjg@287 | 56 | check 50.0 -source 1.5 -target 1.6 |
jjg@287 | 57 | check 50.0 -source 1.6 -target 1.6 |
jjg@287 | 58 | check 50.0 -source 1.6 -target 6 |
jjg@287 | 59 | check 50.0 -source 6 -target 1.6 |
jjg@287 | 60 | check 50.0 -source 6 -target 6 |
jjg@287 | 61 | |
jjg@287 | 62 | check 51.0 |
jjg@287 | 63 | check 51.0 -source 1.5 |
jjg@287 | 64 | check 51.0 -source 1.6 |
jjg@287 | 65 | check 51.0 -source 6 |
jjg@287 | 66 | check 51.0 -source 1.7 |
jjg@287 | 67 | check 51.0 -source 7 |
duke@1 | 68 | check 51.0 -target 1.7 |
duke@1 | 69 | check 51.0 -target 7 |
duke@1 | 70 | |
duke@1 | 71 | |
duke@1 | 72 | # Check source versions |
duke@1 | 73 | |
duke@1 | 74 | fail() { |
duke@1 | 75 | echo "+ javac $*" |
duke@1 | 76 | if $JC ${TESTTOOLVMOPTS} -d $TC $*; then |
duke@1 | 77 | echo "-- did not fail as expected" |
duke@1 | 78 | exit 3 |
duke@1 | 79 | else |
duke@1 | 80 | echo "-- failed as expected" |
duke@1 | 81 | fi |
duke@1 | 82 | } |
duke@1 | 83 | |
duke@1 | 84 | pass() { |
duke@1 | 85 | echo "+ javac $*" |
duke@1 | 86 | if $JC ${TESTTOOLVMOPTS} -d $TC $*; then |
duke@1 | 87 | echo "-- passed" |
duke@1 | 88 | else |
duke@1 | 89 | echo "-- failed" |
duke@1 | 90 | exit 4 |
duke@1 | 91 | fi |
duke@1 | 92 | } |
duke@1 | 93 | |
jjg@287 | 94 | # the following need to be updated when -source 7 features are available |
duke@1 | 95 | checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; } |
duke@1 | 96 | checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; } |
duke@1 | 97 | checksrc16() { checksrc15 $* ; } |
jjg@287 | 98 | checksrc17() { checksrc15 $* ; } |
duke@1 | 99 | |
duke@1 | 100 | checksrc14 -source 1.4 |
duke@1 | 101 | checksrc14 -source 1.4 -target 1.5 |
duke@1 | 102 | |
duke@1 | 103 | checksrc15 -source 1.5 |
jjg@287 | 104 | checksrc15 -source 1.5 -target 1.5 |
duke@1 | 105 | |
duke@1 | 106 | checksrc16 -source 1.6 |
duke@1 | 107 | checksrc16 -source 6 |
jjg@287 | 108 | checksrc16 -source 1.6 -target 1.6 |
jjg@287 | 109 | checksrc16 -source 6 -target 6 |
jjg@287 | 110 | |
jjg@287 | 111 | checksrc17 |
jjg@287 | 112 | checksrc17 -target 1.7 |
jjg@287 | 113 | checksrc17 -target 7 |
jjg@287 | 114 | checksrc17 -source 1.7 |
jjg@287 | 115 | checksrc17 -source 7 |
jjg@287 | 116 | checksrc17 -source 1.7 -target 1.7 |
jjg@287 | 117 | checksrc17 -source 7 -target 7 |
duke@1 | 118 | |
duke@1 | 119 | fail -source 1.5 -target 1.4 $TC/X.java |
duke@1 | 120 | fail -source 1.6 -target 1.4 $TC/X.java |
duke@1 | 121 | fail -source 6 -target 1.4 $TC/X.java |
duke@1 | 122 | fail -source 1.6 -target 1.5 $TC/X.java |
duke@1 | 123 | fail -source 6 -target 1.5 $TC/X.java |