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 # @author Staffan Larsen 29 # @key intermittent 30 # @run shell JdbExprTest.sh 31 32 # These are variables that can be set to control execution 33 34 #pkg=untitled7 35 classname=JdbExprTest 36 compileOptions=-g 37 #java="java_g" 38 #set -x 39 40 createJavaFile() 41 { 42 cat <<EOF > $classname.java.1 43 import java.util.*; 44 import java.net.URLClassLoader; 45 import java.net.URL; 46 47 class $classname { 48 49 static long aLong; 50 static int anInt; 51 static boolean aBoolean; 52 53 public static void bkpt() { 54 int i = 0; //@1 breakpoint 55 } 56 57 public static void main(String[] args) { 58 bkpt(); 59 } 60 } 61 EOF 62 } 63 64 65 # drive jdb by sending cmds to it and examining its output 66 dojdbCmds() 67 { 68 setBkpts @1 69 runToBkpt @1 70 71 cmd print java.lang.Long.MAX_VALUE 72 jdbFailIfNotPresent " \= 9223372036854775807" 3 73 74 cmd print java.lang.Long.MIN_VALUE 75 jdbFailIfNotPresent " \= \-9223372036854775808" 3 76 77 cmd print 9223372036854775807L 78 jdbFailIfNotPresent "9223372036854775807L = 9223372036854775807" 3 79 cmd print 9223372036854775807 80 jdbFailIfNotPresent "9223372036854775807 = 9223372036854775807" 3 81 82 cmd print -9223372036854775807L 83 jdbFailIfNotPresent "\-9223372036854775807L = \-9223372036854775807" 3 84 cmd print -9223372036854775807 85 jdbFailIfNotPresent "\-9223372036854775807 = \-9223372036854775807" 3 86 87 cmd print -1 88 jdbFailIfNotPresent "\-1 = \-1" 3 89 cmd print 1L 90 jdbFailIfNotPresent "1L = 1" 3 91 cmd print -1L 92 jdbFailIfNotPresent "\-1L = \-1" 3 93 cmd print 0x1 94 jdbFailIfNotPresent "0x1 = 1" 3 95 96 cmd set $classname.aLong = 9223372036854775807L 97 cmd print $classname.aLong 98 jdbFailIfNotPresent "$classname.aLong = 9223372036854775807" 3 99 100 cmd set $classname.anInt = java.lang.Integer.MAX_VALUE + 1 101 cmd print $classname.anInt 102 jdbFailIfNotPresent "$classname.anInt = \-2147483648" 3 103 104 cmd set $classname.aLong = java.lang.Integer.MAX_VALUE + 1L 105 cmd print $classname.aLong 106 jdbFailIfNotPresent "$classname.aLong = 2147483648" 3 107 108 cmd set $classname.anInt = 0x80000000 109 jdbFailIfNotPresent "InvalidTypeException: .* convert 2147483648 to int" 3 110 cmd set $classname.anInt = 0x8000000000000000L 111 jdbFailIfNotPresent "java.lang.NumberFormatException: For input string: \"8000000000000000\"" 3 112 113 cmd set $classname.anInt = 0x7fffffff 114 jdbFailIfNotPresent "0x7fffffff = 2147483647" 3 115 cmd set $classname.aLong = 0x7fffffffffffffff 116 jdbFailIfNotPresent "0x7fffffffffffffff = 9223372036854775807" 3 117 118 cmd print 3.1415 119 jdbFailIfNotPresent "3.1415 = 3.1415" 3 120 cmd print -3.1415 121 jdbFailIfNotPresent "\-3.1415 = \-3.1415" 3 122 cmd print 011 123 jdbFailIfNotPresent "011 = 9" 3 124 125 cmd set $classname.aBoolean = false 126 jdbFailIfNotPresent "JdbExprTest.aBoolean = false = false" 3 127 cmd print $classname.aBoolean 128 jdbFailIfNotPresent "JdbExprTest.aBoolean = false" 3 129 cmd print !$classname.aBoolean 130 jdbFailIfNotPresent "JdbExprTest.aBoolean = true" 3 131 132 cmd print ~1 133 jdbFailIfNotPresent "~1 = -2" 3 134 } 135 136 137 mysetup() 138 { 139 if [ -z "$TESTSRC" ] ; then 140 TESTSRC=. 141 fi 142 143 for ii in . $TESTSRC $TESTSRC/.. ; do 144 if [ -r "$ii/ShellScaffold.sh" ] ; then 145 . $ii/ShellScaffold.sh 146 break 147 fi 148 done 149 } 150 151 # You could replace this next line with the contents 152 # of ShellScaffold.sh and this script will run just the same. 153 mysetup 154 155 runit 156 jdbFailIfNotPresent "Breakpoint hit" 157 pass