1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/versions/check.sh Wed Apr 27 01:34:52 2016 +0800 1.3 @@ -0,0 +1,144 @@ 1.4 +# 1.5 +# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 +# 1.8 +# This code is free software; you can redistribute it and/or modify it 1.9 +# under the terms of the GNU General Public License version 2 only, as 1.10 +# published by the Free Software Foundation. 1.11 +# 1.12 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.13 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 +# version 2 for more details (a copy is included in the LICENSE file that 1.16 +# accompanied this code). 1.17 +# 1.18 +# You should have received a copy of the GNU General Public License version 1.19 +# 2 along with this work; if not, write to the Free Software Foundation, 1.20 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 +# 1.22 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 +# or visit www.oracle.com if you need additional information or have any 1.24 +# questions. 1.25 +# 1.26 + 1.27 +# @test 1.28 +# @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 1.29 +# @summary Check interpretation of -target and -source options 1.30 +# @build CheckClassFileVersion 1.31 +# @run shell check.sh 1.32 + 1.33 +TESTJAVA=${TESTJAVA:?} 1.34 +TC=${TESTCLASSES-.} 1.35 + 1.36 +J="$TESTJAVA/bin/java" 1.37 +JC="$TESTJAVA/bin/javac" 1.38 +CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion" 1.39 + 1.40 +rm -f $TC/X.java $TC/X.java 1.41 +echo 'public class X { }' > $TC/X.java 1.42 +echo 'public enum Y { }' > $TC/Y.java 1.43 + 1.44 + 1.45 +# Check class-file versions 1.46 + 1.47 +check() { 1.48 + V=$1; shift 1.49 + echo "+ javac $* [$V]" 1.50 + "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2 1.51 +} 1.52 + 1.53 +# check for all combinations of target values 1.54 +check_target() { 1.55 + check $1 -source $2 -target $3 1.56 + check $1 -source $2 -target 1.${3} 1.57 +} 1.58 +# check for all combinations of source and target values 1.59 +check_source_target() { 1.60 + check_target $1 $2 $3 1.61 + check_target $1 1.${2} $3 1.62 +} 1.63 + 1.64 +check 48.0 -source 1.4 1.65 + 1.66 +check 49.0 -source 1.4 -target 1.5 1.67 +check 49.0 -source 1.5 -target 1.5 1.68 + 1.69 +check_target 50.0 1.4 6 1.70 +check_target 50.0 1.5 6 1.71 +check_source_target 50.0 6 6 1.72 + 1.73 +check_target 51.0 1.4 7 1.74 +check_target 51.0 1.5 7 1.75 +check_source_target 51.0 6 7 1.76 +check_source_target 51.0 7 7 1.77 + 1.78 +check_target 52.0 1.4 8 1.79 +check_target 52.0 1.5 8 1.80 +check_source_target 52.0 6 8 1.81 +check_source_target 52.0 7 8 1.82 +check_source_target 52.0 8 8 1.83 + 1.84 +# and finally the default with no options 1.85 +check 52.0 1.86 + 1.87 +# Check source versions 1.88 + 1.89 +fail() { 1.90 + echo "+ javac $*" 1.91 + if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then 1.92 + echo "-- did not fail as expected" 1.93 + exit 3 1.94 + else 1.95 + echo "-- failed as expected" 1.96 + fi 1.97 +} 1.98 + 1.99 +pass() { 1.100 + echo "+ javac $*" 1.101 + if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then 1.102 + echo "-- passed" 1.103 + else 1.104 + echo "-- failed" 1.105 + exit 4 1.106 + fi 1.107 +} 1.108 + 1.109 +# the following need to be updated when -source 7 features are available 1.110 +checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; } 1.111 +checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; } 1.112 +checksrc16() { checksrc15 $* ; } 1.113 +checksrc17() { checksrc15 $* ; } 1.114 +checksrc18() { checksrc15 $* ; } 1.115 + 1.116 +checksrc14 -source 1.4 1.117 +checksrc14 -source 1.4 -target 1.5 1.118 + 1.119 +checksrc15 -source 1.5 1.120 +checksrc15 -source 1.5 -target 1.5 1.121 + 1.122 +checksrc16 -source 1.6 1.123 +checksrc16 -source 6 1.124 +checksrc16 -source 1.6 -target 1.6 1.125 +checksrc16 -source 6 -target 6 1.126 + 1.127 +checksrc17 -source 1.7 1.128 +checksrc17 -source 7 1.129 +checksrc17 -source 1.7 -target 1.7 1.130 +checksrc17 -source 7 -target 7 1.131 + 1.132 +checksrc18 1.133 +checksrc18 -target 1.8 1.134 +checksrc18 -target 8 1.135 +checksrc18 -source 1.8 1.136 +checksrc18 -source 8 1.137 +checksrc18 -source 1.8 -target 1.8 1.138 +checksrc18 -source 8 -target 8 1.139 + 1.140 +fail -source 1.5 -target 1.4 $TC/X.java 1.141 +fail -source 1.6 -target 1.4 $TC/X.java 1.142 +fail -source 6 -target 1.4 $TC/X.java 1.143 +fail -source 1.6 -target 1.5 $TC/X.java 1.144 +fail -source 6 -target 1.5 $TC/X.java 1.145 +fail -source 7 -target 1.6 $TC/X.java 1.146 +fail -source 8 -target 1.6 $TC/X.java 1.147 +fail -source 8 -target 1.7 $TC/X.java