1 # |
1 # |
2 # Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. |
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. |
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 # |
4 # |
5 # This code is free software; you can redistribute it and/or modify it |
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 |
6 # under the terms of the GNU General Public License version 2 only, as |
7 # published by the Free Software Foundation. |
7 # published by the Free Software Foundation. |
20 # or visit www.oracle.com if you need additional information or have any |
20 # or visit www.oracle.com if you need additional information or have any |
21 # questions. |
21 # questions. |
22 # |
22 # |
23 |
23 |
24 # @test |
24 # @test |
25 # @bug 4981566 5028634 5094412 6304984 7025786 7025789 |
25 # @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 |
26 # @summary Check interpretation of -target and -source options |
26 # @summary Check interpretation of -target and -source options |
27 # @build CheckClassFileVersion |
27 # @build CheckClassFileVersion |
28 # @run shell check.sh |
28 # @run shell check.sh |
29 |
29 |
30 TESTJAVA=${TESTJAVA:?} |
30 TESTJAVA=${TESTJAVA:?} |
45 V=$1; shift |
45 V=$1; shift |
46 echo "+ javac $* [$V]" |
46 echo "+ javac $* [$V]" |
47 "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2 |
47 "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2 |
48 } |
48 } |
49 |
49 |
|
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 } |
|
60 |
50 check 48.0 -source 1.4 |
61 check 48.0 -source 1.4 |
51 |
62 |
52 check 49.0 -source 1.4 -target 1.5 |
63 check 49.0 -source 1.4 -target 1.5 |
53 check 49.0 -source 1.5 -target 1.5 |
64 check 49.0 -source 1.5 -target 1.5 |
54 |
65 |
55 check 50.0 -source 1.4 -target 1.6 |
66 check_target 50.0 1.4 6 |
56 check 50.0 -source 1.5 -target 1.6 |
67 check_target 50.0 1.5 6 |
57 check 50.0 -source 1.6 -target 1.6 |
68 check_source_target 50.0 6 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 |
69 |
62 check 51.0 |
70 check_target 51.0 1.4 7 |
63 check 51.0 -source 1.5 |
71 check_target 51.0 1.5 7 |
64 check 51.0 -source 1.6 |
72 check_source_target 51.0 6 7 |
65 check 51.0 -source 6 |
73 check_source_target 51.0 7 7 |
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 |
74 |
71 # Update when class file version is revved |
75 check_target 52.0 1.4 8 |
72 check 51.0 -source 1.8 |
76 check_target 52.0 1.5 8 |
73 check 51.0 -source 8 |
77 check_source_target 52.0 6 8 |
74 check 51.0 -target 1.8 |
78 check_source_target 52.0 7 8 |
75 check 51.0 -target 8 |
79 check_source_target 52.0 8 8 |
|
80 |
|
81 # and finally the default with no options |
|
82 check 52.0 |
76 |
83 |
77 # Check source versions |
84 # Check source versions |
78 |
85 |
79 fail() { |
86 fail() { |
80 echo "+ javac $*" |
87 echo "+ javac $*" |