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