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 #
23
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
29
30 TESTJAVA=${TESTJAVA:?}
31 TC=${TESTCLASSES-.}
32
33 J="$TESTJAVA/bin/java"
34 JC="$TESTJAVA/bin/javac"
35 CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion"
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
48 }
49
50 check 48.0 -source 1.4
51
52 check 49.0 -source 1.4 -target 1.5
53 check 49.0 -source 1.5 -target 1.5
54
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
61
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
70
71
72 # Check source versions
73
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 }
83
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 }
93
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 $* ; }
99
100 checksrc14 -source 1.4
101 checksrc14 -source 1.4 -target 1.5
102
103 checksrc15 -source 1.5
104 checksrc15 -source 1.5 -target 1.5
105
106 checksrc16 -source 1.6
107 checksrc16 -source 6
108 checksrc16 -source 1.6 -target 1.6
109 checksrc16 -source 6 -target 6
110
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
118
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
|
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 #
23
24 # @test
25 # @bug 4981566 5028634 5094412 6304984 7025786 7025789
26 # @summary Check interpretation of -target and -source options
27 # @build CheckClassFileVersion
28 # @run shell check.sh
29
30 TESTJAVA=${TESTJAVA:?}
31 TC=${TESTCLASSES-.}
32
33 J="$TESTJAVA/bin/java"
34 JC="$TESTJAVA/bin/javac"
35 CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion"
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
48 }
49
50 check 48.0 -source 1.4
51
52 check 49.0 -source 1.4 -target 1.5
53 check 49.0 -source 1.5 -target 1.5
54
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
61
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 -source 7 -target 1.7
69 check 51.0 -source 7 -target 7
70
71 # Update when class file version is revved
72 check 51.0 -source 1.8
73 check 51.0 -source 8
74 check 51.0 -target 1.8
75 check 51.0 -target 8
76
77 # Check source versions
78
79 fail() {
80 echo "+ javac $*"
81 if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then
82 echo "-- did not fail as expected"
83 exit 3
84 else
85 echo "-- failed as expected"
86 fi
87 }
88
89 pass() {
90 echo "+ javac $*"
91 if "$JC" ${TESTTOOLVMOPTS} -d $TC $*; then
92 echo "-- passed"
93 else
94 echo "-- failed"
95 exit 4
96 fi
97 }
98
99 # the following need to be updated when -source 7 features are available
100 checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; }
101 checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
102 checksrc16() { checksrc15 $* ; }
103 checksrc17() { checksrc15 $* ; }
104 checksrc18() { checksrc15 $* ; }
105
106 checksrc14 -source 1.4
107 checksrc14 -source 1.4 -target 1.5
108
109 checksrc15 -source 1.5
110 checksrc15 -source 1.5 -target 1.5
111
112 checksrc16 -source 1.6
113 checksrc16 -source 6
114 checksrc16 -source 1.6 -target 1.6
115 checksrc16 -source 6 -target 6
116
117 checksrc17 -source 1.7
118 checksrc17 -source 7
119 checksrc17 -source 1.7 -target 1.7
120 checksrc17 -source 7 -target 7
121
122 checksrc18
123 checksrc18 -target 1.8
124 checksrc18 -target 8
125 checksrc18 -source 1.8
126 checksrc18 -source 8
127 checksrc18 -source 1.8 -target 1.8
128 checksrc18 -source 8 -target 8
129
130 fail -source 1.5 -target 1.4 $TC/X.java
131 fail -source 1.6 -target 1.4 $TC/X.java
132 fail -source 6 -target 1.4 $TC/X.java
133 fail -source 1.6 -target 1.5 $TC/X.java
134 fail -source 6 -target 1.5 $TC/X.java
135 fail -source 7 -target 1.6 $TC/X.java
136 fail -source 8 -target 1.6 $TC/X.java
137 fail -source 8 -target 1.7 $TC/X.java
|