Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
1 #
2 # Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
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 #
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.
22 #
24 # @test
25 # @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112
26 # @summary Check interpretation of -target and -source options
27 # @build CheckClassFileVersion
28 # @run shell check.sh
30 TESTJAVA=${TESTJAVA:?}
31 TC=${TESTCLASSES-.}
33 J="$TESTJAVA/bin/java"
34 JC="$TESTJAVA/bin/javac"
35 CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion"
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
42 # Check class-file versions
44 check() {
45 V=$1; shift
46 echo "+ javac $* [$V]"
47 "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2
48 }
50 # check for all combinations of target values
51 check_target() {
52 check $1 -source $2 -target $3
53 check $1 -source $2 -target 1.${3}
54 }
55 # check for all combinations of source and target values
56 check_source_target() {
57 check_target $1 $2 $3
58 check_target $1 1.${2} $3
59 }
61 check 48.0 -source 1.4
63 check 49.0 -source 1.4 -target 1.5
64 check 49.0 -source 1.5 -target 1.5
66 check_target 50.0 1.4 6
67 check_target 50.0 1.5 6
68 check_source_target 50.0 6 6
70 check_target 51.0 1.4 7
71 check_target 51.0 1.5 7
72 check_source_target 51.0 6 7
73 check_source_target 51.0 7 7
75 check_target 52.0 1.4 8
76 check_target 52.0 1.5 8
77 check_source_target 52.0 6 8
78 check_source_target 52.0 7 8
79 check_source_target 52.0 8 8
81 # and finally the default with no options
82 check 52.0
84 # Check source versions
86 fail() {
87 echo "+ javac $*"
88 if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then
89 echo "-- did not fail as expected"
90 exit 3
91 else
92 echo "-- failed as expected"
93 fi
94 }
96 pass() {
97 echo "+ javac $*"
98 if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then
99 echo "-- passed"
100 else
101 echo "-- failed"
102 exit 4
103 fi
104 }
106 # the following need to be updated when -source 7 features are available
107 checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; }
108 checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
109 checksrc16() { checksrc15 $* ; }
110 checksrc17() { checksrc15 $* ; }
111 checksrc18() { checksrc15 $* ; }
113 checksrc14 -source 1.4
114 checksrc14 -source 1.4 -target 1.5
116 checksrc15 -source 1.5
117 checksrc15 -source 1.5 -target 1.5
119 checksrc16 -source 1.6
120 checksrc16 -source 6
121 checksrc16 -source 1.6 -target 1.6
122 checksrc16 -source 6 -target 6
124 checksrc17 -source 1.7
125 checksrc17 -source 7
126 checksrc17 -source 1.7 -target 1.7
127 checksrc17 -source 7 -target 7
129 checksrc18
130 checksrc18 -target 1.8
131 checksrc18 -target 8
132 checksrc18 -source 1.8
133 checksrc18 -source 8
134 checksrc18 -source 1.8 -target 1.8
135 checksrc18 -source 8 -target 8
137 fail -source 1.5 -target 1.4 $TC/X.java
138 fail -source 1.6 -target 1.4 $TC/X.java
139 fail -source 6 -target 1.4 $TC/X.java
140 fail -source 1.6 -target 1.5 $TC/X.java
141 fail -source 6 -target 1.5 $TC/X.java
142 fail -source 7 -target 1.6 $TC/X.java
143 fail -source 8 -target 1.6 $TC/X.java
144 fail -source 8 -target 1.7 $TC/X.java