1 #!/bin/sh 2 3 # 4 # Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 # 7 # This code is free software; you can redistribute it and/or modify it 8 # under the terms of the GNU General Public License version 2 only, as 9 # published by the Free Software Foundation. 10 # 11 # This code is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 # version 2 for more details (a copy is included in the LICENSE file that 15 # accompanied this code). 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 # @test 27 # @bug 4660158 28 # @key intermittent 29 # @author Staffan Larsen 30 # 31 # @run shell JdbExprTest.sh 32 33 # These are variables that can be set to control execution 34 35 #pkg=untitled7 36 classname=JdbExprTest 37 compileOptions=-g 38 #java="java_g" 39 #set -x 40 41 createJavaFile() 42 { 43 cat <<EOF > $classname.java.1 44 import java.util.*; 45 import java.net.URLClassLoader; 46 import java.net.URL; 47 48 class $classname { 49 50 static long aLong; 51 static int anInt; 52 static boolean aBoolean; 53 54 public static void bkpt() { 55 int i = 0; //@1 breakpoint 56 } 57 58 public static void main(String[] args) { 59 bkpt(); 60 } 61 } 62 EOF 63 } 64 65 66 # drive jdb by sending cmds to it and examining its output 67 dojdbCmds() 68 { 69 setBkpts @1 70 runToBkpt @1 71 72 cmd print java.lang.Long.MAX_VALUE 73 jdbFailIfNotPresent " \= 9223372036854775807" 3 74 75 cmd print java.lang.Long.MIN_VALUE 76 jdbFailIfNotPresent " \= \-9223372036854775808" 3 77 78 cmd print 9223372036854775807L 79 jdbFailIfNotPresent "9223372036854775807L = 9223372036854775807" 3 80 cmd print 9223372036854775807 81 jdbFailIfNotPresent "9223372036854775807 = 9223372036854775807" 3 82 83 cmd print -9223372036854775807L 84 jdbFailIfNotPresent "\-9223372036854775807L = \-9223372036854775807" 3 85 cmd print -9223372036854775807 86 jdbFailIfNotPresent "\-9223372036854775807 = \-9223372036854775807" 3 87 88 cmd print -1 89 jdbFailIfNotPresent "\-1 = \-1" 3 90 cmd print 1L 91 jdbFailIfNotPresent "1L = 1" 3 92 cmd print -1L 93 jdbFailIfNotPresent "\-1L = \-1" 3 94 cmd print 0x1 95 jdbFailIfNotPresent "0x1 = 1" 3 96 97 cmd set $classname.aLong = 9223372036854775807L 98 cmd print $classname.aLong 99 jdbFailIfNotPresent "$classname.aLong = 9223372036854775807" 3 100 101 cmd set $classname.anInt = java.lang.Integer.MAX_VALUE + 1 102 cmd print $classname.anInt 103 jdbFailIfNotPresent "$classname.anInt = \-2147483648" 3 104 105 cmd set $classname.aLong = java.lang.Integer.MAX_VALUE + 1L 106 cmd print $classname.aLong 107 jdbFailIfNotPresent "$classname.aLong = 2147483648" 3 108 109 cmd set $classname.anInt = 0x80000000 110 jdbFailIfNotPresent "InvalidTypeException: .* convert 2147483648 to int" 3 111 cmd set $classname.anInt = 0x8000000000000000L 112 jdbFailIfNotPresent "java.lang.NumberFormatException: For input string: \"8000000000000000\"" 3 113 114 cmd set $classname.anInt = 0x7fffffff 115 jdbFailIfNotPresent "0x7fffffff = 2147483647" 3 116 cmd set $classname.aLong = 0x7fffffffffffffff 117 jdbFailIfNotPresent "0x7fffffffffffffff = 9223372036854775807" 3 118 119 cmd print 3.1415 120 jdbFailIfNotPresent "3.1415 = 3.1415" 3 121 cmd print -3.1415 122 jdbFailIfNotPresent "\-3.1415 = \-3.1415" 3 123 cmd print 011 124 jdbFailIfNotPresent "011 = 9" 3 125 126 cmd set $classname.aBoolean = false 127 jdbFailIfNotPresent "JdbExprTest.aBoolean = false = false" 3 128 cmd print $classname.aBoolean 129 jdbFailIfNotPresent "JdbExprTest.aBoolean = false" 3 130 cmd print !$classname.aBoolean 131 jdbFailIfNotPresent "JdbExprTest.aBoolean = true" 3 132 133 cmd print ~1 134 jdbFailIfNotPresent "~1 = -2" 3 135 } 136 137 138 mysetup() 139 { 140 if [ -z "$TESTSRC" ] ; then 141 TESTSRC=. 142 fi 143 144 for ii in . $TESTSRC $TESTSRC/.. ; do 145 if [ -r "$ii/ShellScaffold.sh" ] ; then 146 . $ii/ShellScaffold.sh 147 break 148 fi 149 done 150 } 151 152 # You could replace this next line with the contents 153 # of ShellScaffold.sh and this script will run just the same. 154 mysetup 155 156 runit 157 jdbFailIfNotPresent "Breakpoint hit" 158 pass