Tue, 11 Aug 2009 01:13:42 +0100
6869075: regression: javac crashes when compiling compound string assignment with generics
Summary: javac should not add syntehtic cast to the LHS of an assignment expression
Reviewed-by: jjg
jrose@267 | 1 | #!/bin/sh |
jrose@267 | 2 | |
jrose@267 | 3 | # |
jrose@267 | 4 | # Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
jrose@267 | 5 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jrose@267 | 6 | # |
jrose@267 | 7 | # This code is free software; you can redistribute it and/or modify it |
jrose@267 | 8 | # under the terms of the GNU General Public License version 2 only, as |
jrose@267 | 9 | # published by the Free Software Foundation. |
jrose@267 | 10 | # |
jrose@267 | 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
jrose@267 | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jrose@267 | 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jrose@267 | 14 | # version 2 for more details (a copy is included in the LICENSE file that |
jrose@267 | 15 | # accompanied this code). |
jrose@267 | 16 | # |
jrose@267 | 17 | # You should have received a copy of the GNU General Public License version |
jrose@267 | 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
jrose@267 | 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jrose@267 | 20 | # |
jrose@267 | 21 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
jrose@267 | 22 | # CA 95054 USA or visit www.sun.com if you need additional information or |
jrose@267 | 23 | # have any questions. |
jrose@267 | 24 | # |
jrose@267 | 25 | |
jrose@267 | 26 | # @test |
jrose@267 | 27 | # @bug 6754038 |
jrose@267 | 28 | # @summary Verify correct rejection of strongly typed return values |
jrose@267 | 29 | # @run shell MakeNegTests.sh |
jrose@267 | 30 | |
jrose@267 | 31 | default_template=InvokeMH.java |
jrose@267 | 32 | javacflags='-source 7 -target 7' |
jrose@267 | 33 | # the rest of this file is a generic "//BAD"-line tester |
jrose@267 | 34 | |
jrose@267 | 35 | : ${TESTSRC=.} ${TESTCLASSES=.} |
jrose@267 | 36 | javac="${TESTJAVA+${TESTJAVA}/bin/}javac" |
jrose@267 | 37 | |
jrose@267 | 38 | verbose=false quiet=false |
jrose@267 | 39 | |
jrose@267 | 40 | main() { |
jrose@267 | 41 | case "${@-}" in |
jrose@267 | 42 | *.java*) |
jrose@267 | 43 | for template in "$@"; do |
jrose@267 | 44 | expand_and_test "$template" |
jrose@267 | 45 | done;; |
jrose@267 | 46 | *) expand_and_test "${TESTSRC}/$default_template";; |
jrose@267 | 47 | esac |
jrose@267 | 48 | } |
jrose@267 | 49 | |
jrose@267 | 50 | expand_and_test() { |
jrose@267 | 51 | template=$1 |
jrose@267 | 52 | expand "$@" |
jrose@267 | 53 | testneg "$@" |
jrose@267 | 54 | } |
jrose@267 | 55 | |
jrose@267 | 56 | expand() { |
jrose@267 | 57 | template=$1 |
jrose@267 | 58 | badlines=` grep -n < "$template" '//BAD' ` |
jrose@267 | 59 | badcount=` echo "$badlines" | wc -l ` |
jrose@267 | 60 | [ $badcount -gt 0 ] || { echo "No negative test cases in $template"; exit 1; } |
jrose@267 | 61 | $quiet || echo "Expanding $badcount negative test cases from $template:" |
jrose@267 | 62 | $quiet || echo "$badlines" |
jrose@267 | 63 | badnums=` echo "$badlines" | sed 's/:.*//' ` |
jrose@267 | 64 | casestem=` getcasestem "$template" ` |
jrose@267 | 65 | tclassname=` basename "$template" .java ` |
jrose@267 | 66 | rm -f "$casestem"*.java |
jrose@267 | 67 | for badnum in $badnums; do |
jrose@267 | 68 | casefile="$casestem"${badnum}.java |
jrose@267 | 69 | cclassname=` basename "$casefile" .java ` |
jrose@267 | 70 | sed < "$template" > "$casefile" " |
jrose@267 | 71 | s|@compile|@compile/fail| |
jrose@267 | 72 | / @[a-z]/s|@|##| |
jrose@267 | 73 | ${badnum}s:^ *[/*]*: : |
jrose@267 | 74 | s/${tclassname}/${cclassname}/g |
jrose@267 | 75 | " |
jrose@267 | 76 | $verbose && diff -u "$template" "$casefile" |
jrose@267 | 77 | done |
jrose@267 | 78 | } |
jrose@267 | 79 | |
jrose@267 | 80 | getcasestem() { |
jrose@267 | 81 | echo "$1" | sed 's/\.java$//;s/_BAD[0-9]*$//;s/$/_BAD/' |
jrose@267 | 82 | } |
jrose@267 | 83 | |
jrose@267 | 84 | testneg() { |
jrose@267 | 85 | template=$1 |
jrose@267 | 86 | for casefile in ` getcasestem "$template" `*.java; do |
jrose@267 | 87 | $quiet || echo -------- $javac $javacflags "$casefile" |
jrose@267 | 88 | $javac $javacflags "$casefile" > "$casefile".errlog 2>&1 && { |
jrose@267 | 89 | echo "*** Compilation unexpectedly succeeded: $casefile" |
jrose@267 | 90 | exit 1 |
jrose@267 | 91 | } |
jrose@267 | 92 | $quiet || echo "Compilation failed as expected" |
jrose@267 | 93 | $quiet || head ` $verbose || echo -3 ` < "$casefile".errlog |
jrose@267 | 94 | rm "$casefile".errlog |
jrose@267 | 95 | done |
jrose@267 | 96 | } |
jrose@267 | 97 | |
jrose@267 | 98 | main "$@" |