Fri, 23 Jul 2010 16:42:36 -0700
Added tag jdk7-b102 for changeset ff9c0a0bf7ed
1 #
2 # Copyright (c) 2004, 2006, 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
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="$J ${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 && $CFV $TC/X.class $V || exit 2
48 }
50 check 48.0 -source 1.4
52 check 49.0 -source 1.4 -target 1.5
53 check 49.0 -source 1.5 -target 1.5
55 check 50.0 -source 1.4 -target 1.6
56 check 50.0 -source 1.5 -target 1.6
57 check 50.0 -source 1.6 -target 1.6
58 check 50.0 -source 1.6 -target 6
59 check 50.0 -source 6 -target 1.6
60 check 50.0 -source 6 -target 6
62 check 51.0
63 check 51.0 -source 1.5
64 check 51.0 -source 1.6
65 check 51.0 -source 6
66 check 51.0 -source 1.7
67 check 51.0 -source 7
68 check 51.0 -target 1.7
69 check 51.0 -target 7
72 # Check source versions
74 fail() {
75 echo "+ javac $*"
76 if $JC ${TESTTOOLVMOPTS} -d $TC $*; then
77 echo "-- did not fail as expected"
78 exit 3
79 else
80 echo "-- failed as expected"
81 fi
82 }
84 pass() {
85 echo "+ javac $*"
86 if $JC ${TESTTOOLVMOPTS} -d $TC $*; then
87 echo "-- passed"
88 else
89 echo "-- failed"
90 exit 4
91 fi
92 }
94 # the following need to be updated when -source 7 features are available
95 checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; }
96 checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
97 checksrc16() { checksrc15 $* ; }
98 checksrc17() { checksrc15 $* ; }
100 checksrc14 -source 1.4
101 checksrc14 -source 1.4 -target 1.5
103 checksrc15 -source 1.5
104 checksrc15 -source 1.5 -target 1.5
106 checksrc16 -source 1.6
107 checksrc16 -source 6
108 checksrc16 -source 1.6 -target 1.6
109 checksrc16 -source 6 -target 6
111 checksrc17
112 checksrc17 -target 1.7
113 checksrc17 -target 7
114 checksrc17 -source 1.7
115 checksrc17 -source 7
116 checksrc17 -source 1.7 -target 1.7
117 checksrc17 -source 7 -target 7
119 fail -source 1.5 -target 1.4 $TC/X.java
120 fail -source 1.6 -target 1.4 $TC/X.java
121 fail -source 6 -target 1.4 $TC/X.java
122 fail -source 1.6 -target 1.5 $TC/X.java
123 fail -source 6 -target 1.5 $TC/X.java