Thu, 07 Jun 2012 20:30:57 -0700
7170079: Adjustments to build-infra makefiles
Reviewed-by: ohair, ohrstrom, ihse, jonas
Contributed-by: jonas <jonas.oreland@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
1 #
2 # Copyright (c) 2004, 2011, 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
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 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 -source 7 -target 1.7
69 check 51.0 -source 7 -target 7
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
77 # Check source versions
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 }
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 }
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 $* ; }
106 checksrc14 -source 1.4
107 checksrc14 -source 1.4 -target 1.5
109 checksrc15 -source 1.5
110 checksrc15 -source 1.5 -target 1.5
112 checksrc16 -source 1.6
113 checksrc16 -source 6
114 checksrc16 -source 1.6 -target 1.6
115 checksrc16 -source 6 -target 6
117 checksrc17 -source 1.7
118 checksrc17 -source 7
119 checksrc17 -source 1.7 -target 1.7
120 checksrc17 -source 7 -target 7
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
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