Fri, 24 Apr 2020 03:58:51 +0100
Merge
duke@1 | 1 | # |
ksrini@1395 | 2 | # Copyright (c) 2004, 2012, Oracle and/or its affiliates. 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 | # |
ohair@554 | 19 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | # or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | # questions. |
duke@1 | 22 | # |
duke@1 | 23 | |
duke@1 | 24 | # @test |
ksrini@1395 | 25 | # @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 |
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" |
jjg@838 | 35 | CFV="${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]" |
jjg@838 | 47 | "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2 |
duke@1 | 48 | } |
duke@1 | 49 | |
ksrini@1395 | 50 | # check for all combinations of target values |
ksrini@1395 | 51 | check_target() { |
ksrini@1395 | 52 | check $1 -source $2 -target $3 |
ksrini@1395 | 53 | check $1 -source $2 -target 1.${3} |
ksrini@1395 | 54 | } |
ksrini@1395 | 55 | # check for all combinations of source and target values |
ksrini@1395 | 56 | check_source_target() { |
ksrini@1395 | 57 | check_target $1 $2 $3 |
ksrini@1395 | 58 | check_target $1 1.${2} $3 |
ksrini@1395 | 59 | } |
ksrini@1395 | 60 | |
duke@1 | 61 | check 48.0 -source 1.4 |
jjg@287 | 62 | |
duke@1 | 63 | check 49.0 -source 1.4 -target 1.5 |
jjg@287 | 64 | check 49.0 -source 1.5 -target 1.5 |
jjg@287 | 65 | |
ksrini@1395 | 66 | check_target 50.0 1.4 6 |
ksrini@1395 | 67 | check_target 50.0 1.5 6 |
ksrini@1395 | 68 | check_source_target 50.0 6 6 |
jjg@287 | 69 | |
ksrini@1395 | 70 | check_target 51.0 1.4 7 |
ksrini@1395 | 71 | check_target 51.0 1.5 7 |
ksrini@1395 | 72 | check_source_target 51.0 6 7 |
ksrini@1395 | 73 | check_source_target 51.0 7 7 |
duke@1 | 74 | |
ksrini@1395 | 75 | check_target 52.0 1.4 8 |
ksrini@1395 | 76 | check_target 52.0 1.5 8 |
ksrini@1395 | 77 | check_source_target 52.0 6 8 |
ksrini@1395 | 78 | check_source_target 52.0 7 8 |
ksrini@1395 | 79 | check_source_target 52.0 8 8 |
ksrini@1395 | 80 | |
ksrini@1395 | 81 | # and finally the default with no options |
ksrini@1395 | 82 | check 52.0 |
duke@1 | 83 | |
duke@1 | 84 | # Check source versions |
duke@1 | 85 | |
duke@1 | 86 | fail() { |
duke@1 | 87 | echo "+ javac $*" |
jjg@838 | 88 | if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then |
duke@1 | 89 | echo "-- did not fail as expected" |
duke@1 | 90 | exit 3 |
duke@1 | 91 | else |
duke@1 | 92 | echo "-- failed as expected" |
duke@1 | 93 | fi |
duke@1 | 94 | } |
duke@1 | 95 | |
duke@1 | 96 | pass() { |
duke@1 | 97 | echo "+ javac $*" |
jjg@838 | 98 | if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then |
duke@1 | 99 | echo "-- passed" |
duke@1 | 100 | else |
duke@1 | 101 | echo "-- failed" |
duke@1 | 102 | exit 4 |
duke@1 | 103 | fi |
duke@1 | 104 | } |
duke@1 | 105 | |
jjg@287 | 106 | # the following need to be updated when -source 7 features are available |
duke@1 | 107 | checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; } |
duke@1 | 108 | checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; } |
duke@1 | 109 | checksrc16() { checksrc15 $* ; } |
jjg@287 | 110 | checksrc17() { checksrc15 $* ; } |
darcy@1042 | 111 | checksrc18() { checksrc15 $* ; } |
duke@1 | 112 | |
duke@1 | 113 | checksrc14 -source 1.4 |
duke@1 | 114 | checksrc14 -source 1.4 -target 1.5 |
duke@1 | 115 | |
duke@1 | 116 | checksrc15 -source 1.5 |
jjg@287 | 117 | checksrc15 -source 1.5 -target 1.5 |
duke@1 | 118 | |
duke@1 | 119 | checksrc16 -source 1.6 |
duke@1 | 120 | checksrc16 -source 6 |
jjg@287 | 121 | checksrc16 -source 1.6 -target 1.6 |
jjg@287 | 122 | checksrc16 -source 6 -target 6 |
jjg@287 | 123 | |
jjg@287 | 124 | checksrc17 -source 1.7 |
jjg@287 | 125 | checksrc17 -source 7 |
jjg@287 | 126 | checksrc17 -source 1.7 -target 1.7 |
jjg@287 | 127 | checksrc17 -source 7 -target 7 |
duke@1 | 128 | |
darcy@1042 | 129 | checksrc18 |
darcy@1042 | 130 | checksrc18 -target 1.8 |
darcy@1042 | 131 | checksrc18 -target 8 |
darcy@1042 | 132 | checksrc18 -source 1.8 |
darcy@1042 | 133 | checksrc18 -source 8 |
darcy@1042 | 134 | checksrc18 -source 1.8 -target 1.8 |
darcy@1042 | 135 | checksrc18 -source 8 -target 8 |
darcy@1042 | 136 | |
duke@1 | 137 | fail -source 1.5 -target 1.4 $TC/X.java |
duke@1 | 138 | fail -source 1.6 -target 1.4 $TC/X.java |
duke@1 | 139 | fail -source 6 -target 1.4 $TC/X.java |
duke@1 | 140 | fail -source 1.6 -target 1.5 $TC/X.java |
duke@1 | 141 | fail -source 6 -target 1.5 $TC/X.java |
darcy@1042 | 142 | fail -source 7 -target 1.6 $TC/X.java |
darcy@1042 | 143 | fail -source 8 -target 1.6 $TC/X.java |
darcy@1042 | 144 | fail -source 8 -target 1.7 $TC/X.java |