author | sogoel |
Thu, 05 Jun 2014 10:57:10 -0700 | |
changeset 24797 | 850ebd4d80a7 |
parent 22151 | cb8daa93eeb1 |
child 25445 | 603f0c93d5c9 |
permissions | -rw-r--r-- |
10 | 1 |
# |
22151 | 2 |
# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
# |
|
5 |
# This code is free software; you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
|
7 |
# published by the Free Software Foundation. |
|
8 |
# |
|
9 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
# accompanied this code). |
|
14 |
# |
|
15 |
# You should have received a copy of the GNU General Public License version |
|
16 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
# |
|
5520 | 19 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
# or visit www.oracle.com if you need additional information or have any |
|
21 |
# questions. |
|
10 | 22 |
# |
23 |
||
24 |
# @test |
|
22151 | 25 |
# @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 |
10 | 26 |
# @summary Check interpretation of -target and -source options |
27 |
# @build CheckClassFileVersion |
|
2983 | 28 |
# @run shell check.sh |
10 | 29 |
|
30 |
TESTJAVA=${TESTJAVA:?} |
|
31 |
TC=${TESTCLASSES-.} |
|
32 |
||
33 |
J="$TESTJAVA/bin/java" |
|
34 |
JC="$TESTJAVA/bin/javac" |
|
8222
28db72eee100
6581775: Fix the white space problem in javac shell tests
jjg
parents:
5520
diff
changeset
|
35 |
CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion" |
10 | 36 |
|
37 |
rm -f $TC/X.java $TC/X.java |
|
38 |
echo 'public class X { }' > $TC/X.java |
|
39 |
echo 'public enum Y { }' > $TC/Y.java |
|
40 |
||
41 |
||
42 |
# Check class-file versions |
|
43 |
||
44 |
check() { |
|
45 |
V=$1; shift |
|
46 |
echo "+ javac $* [$V]" |
|
22151 | 47 |
"$JC" ${TESTTOOLVMOPTS} -Xlint:-options -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2 |
10 | 48 |
} |
49 |
||
14445
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
50 |
# check for all combinations of target values |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
51 |
check_target() { |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
52 |
check $1 -source $2 -target $3 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
53 |
check $1 -source $2 -target 1.${3} |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
54 |
} |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
55 |
# check for all combinations of source and target values |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
56 |
check_source_target() { |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
57 |
check_target $1 $2 $3 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
58 |
check_target $1 1.${2} $3 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
59 |
} |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
60 |
|
10 | 61 |
check 48.0 -source 1.4 |
2983 | 62 |
|
10 | 63 |
check 49.0 -source 1.4 -target 1.5 |
2983 | 64 |
check 49.0 -source 1.5 -target 1.5 |
65 |
||
14445
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
66 |
check_target 50.0 1.4 6 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
67 |
check_target 50.0 1.5 6 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
68 |
check_source_target 50.0 6 6 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
69 |
|
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
70 |
check_target 51.0 1.4 7 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
71 |
check_target 51.0 1.5 7 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
72 |
check_source_target 51.0 6 7 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
73 |
check_source_target 51.0 7 7 |
2983 | 74 |
|
14445
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
75 |
check_target 52.0 1.4 8 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
76 |
check_target 52.0 1.5 8 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
77 |
check_source_target 52.0 6 8 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
78 |
check_source_target 52.0 7 8 |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
79 |
check_source_target 52.0 8 8 |
10 | 80 |
|
22151 | 81 |
check_target 52.0 1.5 9 |
82 |
check_source_target 52.0 8 9 |
|
83 |
check_source_target 52.0 9 9 |
|
84 |
||
14445
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
85 |
# and finally the default with no options |
835eb1433d39
8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents:
10180
diff
changeset
|
86 |
check 52.0 |
10 | 87 |
|
88 |
# Check source versions |
|
89 |
||
90 |
fail() { |
|
91 |
echo "+ javac $*" |
|
22151 | 92 |
if "$JC" ${TESTTOOLVMOPTS} -Xlint:-options -d $TC $*; then |
10 | 93 |
echo "-- did not fail as expected" |
94 |
exit 3 |
|
95 |
else |
|
96 |
echo "-- failed as expected" |
|
97 |
fi |
|
98 |
} |
|
99 |
||
100 |
pass() { |
|
101 |
echo "+ javac $*" |
|
22151 | 102 |
if "$JC" ${TESTTOOLVMOPTS} -Xlint:options -d $TC $*; then |
10 | 103 |
echo "-- passed" |
104 |
else |
|
105 |
echo "-- failed" |
|
106 |
exit 4 |
|
107 |
fi |
|
108 |
} |
|
109 |
||
2983 | 110 |
# the following need to be updated when -source 7 features are available |
10 | 111 |
checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; } |
112 |
checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; } |
|
113 |
checksrc16() { checksrc15 $* ; } |
|
2983 | 114 |
checksrc17() { checksrc15 $* ; } |
10180 | 115 |
checksrc18() { checksrc15 $* ; } |
22151 | 116 |
checksrc19() { checksrc15 $* ; } |
10 | 117 |
|
118 |
checksrc14 -source 1.4 |
|
119 |
checksrc14 -source 1.4 -target 1.5 |
|
120 |
||
121 |
checksrc15 -source 1.5 |
|
2983 | 122 |
checksrc15 -source 1.5 -target 1.5 |
10 | 123 |
|
124 |
checksrc16 -source 1.6 |
|
125 |
checksrc16 -source 6 |
|
2983 | 126 |
checksrc16 -source 1.6 -target 1.6 |
127 |
checksrc16 -source 6 -target 6 |
|
128 |
||
129 |
checksrc17 -source 1.7 |
|
130 |
checksrc17 -source 7 |
|
131 |
checksrc17 -source 1.7 -target 1.7 |
|
132 |
checksrc17 -source 7 -target 7 |
|
10 | 133 |
|
10180 | 134 |
checksrc18 -source 1.8 |
135 |
checksrc18 -source 8 |
|
136 |
checksrc18 -source 1.8 -target 1.8 |
|
137 |
checksrc18 -source 8 -target 8 |
|
138 |
||
22151 | 139 |
checksrc19 |
140 |
checksrc19 -source 1.9 |
|
141 |
checksrc19 -source 9 |
|
142 |
checksrc19 -source 1.9 -target 1.9 |
|
143 |
checksrc19 -source 9 -target 9 |
|
144 |
checksrc19 -target 1.9 |
|
145 |
checksrc19 -target 9 |
|
146 |
||
10 | 147 |
fail -source 1.5 -target 1.4 $TC/X.java |
148 |
fail -source 1.6 -target 1.4 $TC/X.java |
|
149 |
fail -source 6 -target 1.4 $TC/X.java |
|
150 |
fail -source 1.6 -target 1.5 $TC/X.java |
|
151 |
fail -source 6 -target 1.5 $TC/X.java |
|
10180 | 152 |
fail -source 7 -target 1.6 $TC/X.java |
153 |
fail -source 8 -target 1.6 $TC/X.java |
|
154 |
fail -source 8 -target 1.7 $TC/X.java |
|
22151 | 155 |
fail -source 9 -target 1.7 $TC/X.java |
156 |
fail -source 9 -target 1.8 $TC/X.java |