langtools/test/tools/javac/versions/check.sh
author sogoel
Thu, 05 Jun 2014 10:57:10 -0700
changeset 24797 850ebd4d80a7
parent 22151 cb8daa93eeb1
child 25445 603f0c93d5c9
permissions -rw-r--r--
8044072: Group 2: create .out files for OverrideChecks tests in tools/javac dir Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
#
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
     2
# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
#
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
# published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
#
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
# accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
#
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
#
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2983
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2983
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2983
diff changeset
    21
# questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
#
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
# @test
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
    25
# @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
# @summary Check interpretation of -target and -source options
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
# @build CheckClassFileVersion
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
    28
# @run shell check.sh 
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
TESTJAVA=${TESTJAVA:?}
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
TC=${TESTCLASSES-.}
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
J="$TESTJAVA/bin/java" 
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
JC="$TESTJAVA/bin/javac" 
8222
28db72eee100 6581775: Fix the white space problem in javac shell tests
jjg
parents: 5520
diff changeset
    35
CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion"
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
rm -f $TC/X.java $TC/X.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
echo 'public class X { }' > $TC/X.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
echo 'public enum Y { }' > $TC/Y.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
# Check class-file versions
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
check() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
  V=$1; shift
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
  echo "+ javac $* [$V]"
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
    47
  "$JC" ${TESTTOOLVMOPTS} -Xlint:-options -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
14445
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    50
# check for all combinations of target values
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    51
check_target() {
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    52
  check $1 -source $2 -target $3
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    53
  check $1 -source $2 -target 1.${3}
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    54
}
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    55
# check for all combinations of source and target values
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    56
check_source_target() {
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    57
  check_target $1 $2     $3
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    58
  check_target $1 1.${2} $3
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    59
}
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    60
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
check 48.0 -source 1.4
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
    62
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
check 49.0 -source 1.4 -target 1.5
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
    64
check 49.0 -source 1.5 -target 1.5
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
    65
14445
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    66
check_target        50.0 1.4 6
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    67
check_target        50.0 1.5 6
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    68
check_source_target 50.0 6   6
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    69
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    70
check_target        51.0 1.4 7
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    71
check_target        51.0 1.5 7
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    72
check_source_target 51.0 6   7
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    73
check_source_target 51.0 7   7
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
    74
14445
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    75
check_target        52.0 1.4 8
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    76
check_target        52.0 1.5 8
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    77
check_source_target 52.0 6   8
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    78
check_source_target 52.0 7   8
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    79
check_source_target 52.0 8   8
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
    81
check_target        52.0 1.5 9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
    82
check_source_target 52.0 8   9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
    83
check_source_target 52.0 9   9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
    84
14445
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    85
# and finally the default with no options
835eb1433d39 8001112: Make -target 8 in javac generate version 52.0 classfile
ksrini
parents: 10180
diff changeset
    86
check 52.0
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
# Check source versions
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
fail() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
  echo "+ javac $*"
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
    92
  if "$JC" ${TESTTOOLVMOPTS} -Xlint:-options -d $TC $*; then
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    echo "-- did not fail as expected"
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    exit 3
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
  else
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    echo "-- failed as expected"
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
  fi
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
pass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
  echo "+ javac $*"
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   102
  if "$JC" ${TESTTOOLVMOPTS} -Xlint:options -d $TC $*; then
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    echo "-- passed"
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
  else
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    echo "-- failed"
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    exit 4
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
  fi
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
}
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   110
# the following need to be updated when -source 7 features are available
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
checksrc16() { checksrc15 $* ; }
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   114
checksrc17() { checksrc15 $* ; }
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   115
checksrc18() { checksrc15 $* ; }
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   116
checksrc19() { checksrc15 $* ; }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
checksrc14 -source 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
checksrc14 -source 1.4 -target 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
checksrc15 -source 1.5
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   122
checksrc15 -source 1.5 -target 1.5
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
checksrc16 -source 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
checksrc16 -source 6
2983
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   126
checksrc16 -source 1.6 -target 1.6
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   127
checksrc16 -source 6 -target 6
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   128
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   129
checksrc17 -source 1.7
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   130
checksrc17 -source 7
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   131
checksrc17 -source 1.7 -target 1.7
1d164c36212a 6843648: tools/javac/versions/check.sh is broken
jjg
parents: 10
diff changeset
   132
checksrc17 -source 7 -target 7
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   134
checksrc18 -source 1.8
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   135
checksrc18 -source 8
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   136
checksrc18 -source 1.8 -target 1.8
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   137
checksrc18 -source 8 -target 8
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   138
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   139
checksrc19
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   140
checksrc19 -source 1.9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   141
checksrc19 -source 9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   142
checksrc19 -source 1.9 -target 1.9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   143
checksrc19 -source 9 -target 9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   144
checksrc19 -target 1.9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   145
checksrc19 -target 9
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   146
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
fail -source 1.5 -target 1.4 $TC/X.java
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
fail -source 1.6 -target 1.4 $TC/X.java
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
fail -source 6   -target 1.4 $TC/X.java
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
fail -source 1.6 -target 1.5 $TC/X.java
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
fail -source 6   -target 1.5 $TC/X.java
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   152
fail -source 7   -target 1.6 $TC/X.java
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   153
fail -source 8   -target 1.6 $TC/X.java
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9087
diff changeset
   154
fail -source 8   -target 1.7 $TC/X.java
22151
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   155
fail -source 9   -target 1.7 $TC/X.java
cb8daa93eeb1 8028545: Add -source 9 and -target 9 to javac
darcy
parents: 14445
diff changeset
   156
fail -source 9   -target 1.8 $TC/X.java