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 1999-2003 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 | |
duke@1 | 27 | # @test |
duke@1 | 28 | # @bug 4241229 4785453 |
duke@1 | 29 | # @summary Test -classpath option and classpath defaults. |
duke@1 | 30 | # @author maddox |
duke@1 | 31 | # |
duke@1 | 32 | # @run shell/timeout=180 ClassPathTest.sh |
duke@1 | 33 | |
duke@1 | 34 | # TODO: Should test sourcepath and classpath separately. |
duke@1 | 35 | |
duke@1 | 36 | if [ "${TESTSRC}" = "" ] |
duke@1 | 37 | then |
duke@1 | 38 | echo "TESTSRC not set. Test cannot execute. Failed." |
duke@1 | 39 | exit 1 |
duke@1 | 40 | fi |
duke@1 | 41 | echo "TESTSRC=${TESTSRC}" |
duke@1 | 42 | if [ "${TESTJAVA}" = "" ] |
duke@1 | 43 | then |
duke@1 | 44 | echo "TESTJAVA not set. Test cannot execute. Failed." |
duke@1 | 45 | exit 1 |
duke@1 | 46 | fi |
duke@1 | 47 | echo "TESTJAVA=${TESTJAVA}" |
duke@1 | 48 | if [ "${TESTCLASSES}" = "" ] |
duke@1 | 49 | then |
duke@1 | 50 | echo "TESTCLASSES not set. Test cannot execute. Failed." |
duke@1 | 51 | exit 1 |
duke@1 | 52 | fi |
duke@1 | 53 | echo "TESTCLASSES=${TESTCLASSES}" |
duke@1 | 54 | echo "CLASSPATH=${CLASSPATH}" |
duke@1 | 55 | |
duke@1 | 56 | # set platform-dependent variables |
duke@1 | 57 | OS=`uname -s` |
duke@1 | 58 | case "$OS" in |
duke@1 | 59 | SunOS | Linux ) |
duke@1 | 60 | NULL=/dev/null |
duke@1 | 61 | PS=":" |
duke@1 | 62 | FS="/" |
duke@1 | 63 | ;; |
duke@1 | 64 | Windows* ) |
duke@1 | 65 | NULL=NUL |
duke@1 | 66 | PS=";" |
duke@1 | 67 | FS="\\" |
duke@1 | 68 | ;; |
duke@1 | 69 | * ) |
duke@1 | 70 | echo "Unrecognized system!" |
duke@1 | 71 | exit 1; |
duke@1 | 72 | ;; |
duke@1 | 73 | esac |
duke@1 | 74 | |
duke@1 | 75 | javac="${TESTJAVA}${FS}bin${FS}javac" |
duke@1 | 76 | |
duke@1 | 77 | cleanup() { |
duke@1 | 78 | rm -f *.class pkg${FS}*.class foo${FS}pkg${FS}*.class bar${FS}pkg${FS}*.class |
duke@1 | 79 | cp -rf $TESTSRC${FS}* . |
duke@1 | 80 | } |
duke@1 | 81 | |
duke@1 | 82 | fail() { |
duke@1 | 83 | echo "FAIL: $1" |
duke@1 | 84 | failed="yes" |
duke@1 | 85 | } |
duke@1 | 86 | |
duke@1 | 87 | # report expectedResult $? |
duke@1 | 88 | report() { |
duke@1 | 89 | if test "$1" = "success" -a "$2" = 0; then |
duke@1 | 90 | echo "PASS: succeeded as expected" |
duke@1 | 91 | elif test "$1" = "failure" -a "$2" != 0; then |
duke@1 | 92 | echo "PASS: failed as expected" |
duke@1 | 93 | elif test "$1" = "success" -a "$2" != 0; then |
duke@1 | 94 | fail "test failed unexpectedly" |
duke@1 | 95 | elif test "$1" = "failure" -a "$2" = 0; then |
duke@1 | 96 | fail "test succeeded unexpectedly" |
duke@1 | 97 | else |
duke@1 | 98 | fail "internal error" |
duke@1 | 99 | fi |
duke@1 | 100 | } |
duke@1 | 101 | |
duke@1 | 102 | # testJavac expectedResult javacArgs... |
duke@1 | 103 | testJavac() { |
duke@1 | 104 | expectedResult="$1"; shift |
duke@1 | 105 | cleanup |
duke@1 | 106 | echo $javac ${TESTTOOLVMOPTS} "$@" |
duke@1 | 107 | $javac ${TESTTOOLVMOPTS} "$@" |
duke@1 | 108 | report $expectedResult $? |
duke@1 | 109 | } |
duke@1 | 110 | |
duke@1 | 111 | unset CLASSPATH |
duke@1 | 112 | |
duke@1 | 113 | # classpath should default to current directory |
duke@1 | 114 | |
duke@1 | 115 | testJavac success ClassPathTest3.java |
duke@1 | 116 | testJavac failure ClassPathTest1.java |
duke@1 | 117 | |
duke@1 | 118 | # if CLASSPATH is set, it should be honored |
duke@1 | 119 | |
duke@1 | 120 | CLASSPATH=bar; export CLASSPATH |
duke@1 | 121 | |
duke@1 | 122 | testJavac success ClassPathTest2.java |
duke@1 | 123 | testJavac failure ClassPathTest1.java |
duke@1 | 124 | testJavac failure ClassPathTest3.java |
duke@1 | 125 | |
duke@1 | 126 | # -classpath option should override default |
duke@1 | 127 | |
duke@1 | 128 | testJavac success -classpath foo ClassPathTest1.java |
duke@1 | 129 | testJavac failure -classpath foo ClassPathTest2.java |
duke@1 | 130 | testJavac failure -classpath foo ClassPathTest3.java |
duke@1 | 131 | |
duke@1 | 132 | if test -n "$failed"; then |
duke@1 | 133 | echo "Some tests failed" |
duke@1 | 134 | exit 1 |
duke@1 | 135 | else |
duke@1 | 136 | echo PASS: all tests gave expected results |
duke@1 | 137 | exit 0 |
duke@1 | 138 | fi |