1 #!/bin/bash 2 3 javac -d . ../../../../../../make/jdk/src/classes/build/tools/spp/Spp.java 4 5 SPP=build.tools.spp.Spp 6 7 # Generates variable handle tests for objects and all primitive types 8 # This is likely to be a temporary testing approach as it may be more 9 # desirable to generate code using ASM which will allow more flexibility 10 # in the kinds of tests that are generated. 11 12 for type in boolean byte short char int long float double String Point 13 do 14 Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" 15 args="-K$type -Dtype=$type -DType=$Type" 16 17 args="$args -KCAS" 18 19 case $type in 20 byte|short|char|int|long|float|double) 21 args="$args -KAtomicAdd" 22 ;; 23 esac 24 25 case $type in 26 boolean|byte|short|char|int|long) 27 args="$args -KBitwise" 28 ;; 29 esac 30 31 case $type in 32 boolean|byte|short|char|int|long|float|double|Point) 33 args="$args -KValue" 34 ;; 35 esac 36 37 case $type in 38 String|Point) 39 args="$args -KClass" 40 ;; 41 esac 42 43 wrong_primitive_type=boolean 44 45 case $type in 46 boolean) 47 value1=true 48 value2=false 49 value3=false 50 wrong_primitive_type=int 51 ;; 52 byte) 53 value1=(byte)0x01 54 value2=(byte)0x23 55 value3=(byte)0x45 56 ;; 57 short) 58 value1=(short)0x0123 59 value2=(short)0x4567 60 value3=(short)0x89AB 61 ;; 62 char) 63 value1=\'\\\\u0123\' 64 value2=\'\\\\u4567\' 65 value3=\'\\\\u89AB\' 66 ;; 67 int) 68 value1=0x01234567 69 value2=0x89ABCDEF 70 value3=0xCAFEBABE 71 ;; 72 long) 73 value1=0x0123456789ABCDEFL 74 value2=0xCAFEBABECAFEBABEL 75 value3=0xDEADBEEFDEADBEEFL 76 ;; 77 float) 78 value1=1.0f 79 value2=2.0f 80 value3=3.0f 81 ;; 82 double) 83 value1=1.0d 84 value2=2.0d 85 value3=3.0d 86 ;; 87 String) 88 value1=\"foo\" 89 value2=\"bar\" 90 value3=\"baz\" 91 ;; 92 Point) 93 value1="Point.getInstance(1,1)" 94 value2="Point.getInstance(2,2)" 95 value3="Point.getInstance(3,3)" 96 ;; 97 esac 98 99 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3 -Dwrong_primitive_type=$wrong_primitive_type" 100 101 echo $args 102 out=VarHandleTestAccess${Type}.java 103 rm -f $out 104 java $SPP -nel $args -iX-VarHandleTestAccess.java.template -o$out 105 out=VarHandleTestMethodHandleAccess${Type}.java 106 rm -f $out 107 java $SPP -nel $args -iX-VarHandleTestMethodHandleAccess.java.template -o$out 108 out=VarHandleTestMethodType${Type}.java 109 rm -f $out 110 java $SPP -nel $args -iX-VarHandleTestMethodType.java.template -o$out 111 done 112 113 for type in short char int long float double 114 do 115 Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" 116 args="-K$type -Dtype=$type -DType=$Type" 117 118 BoxType=$Type 119 case $type in 120 char) 121 BoxType=Character 122 ;; 123 int) 124 BoxType=Integer 125 ;; 126 esac 127 args="$args -DBoxType=$BoxType" 128 129 case $type in 130 int|long|float|double) 131 args="$args -KCAS" 132 ;; 133 esac 134 135 case $type in 136 int|long) 137 args="$args -KAtomicAdd" 138 ;; 139 esac 140 141 case $type in 142 int|long) 143 args="$args -KBitwise" 144 ;; 145 esac 146 147 # The value of `value3` is chosen such that when added to `value1` or `value2` 148 # it will result in carrying of bits over to the next byte, thereby detecting 149 # possible errors in endianness conversion e.g. if say for atomic addition the 150 # augend is incorrectly processed 151 case $type in 152 short) 153 value1=(short)0x0102 154 value2=(short)0x1112 155 value3=(short)0xFFFE 156 ;; 157 char) 158 value1=(char)0x0102 159 value2=(char)0x1112 160 value3=(char)0xFFFE 161 ;; 162 int) 163 value1=0x01020304 164 value2=0x11121314 165 value3=0xFFFEFDFC 166 ;; 167 long) 168 value1=0x0102030405060708L 169 value2=0x1112131415161718L 170 value3=0xFFFEFDFCFBFAF9F8L 171 ;; 172 float) 173 value1=0x01020304 174 value2=0x11121314 175 value3=0xFFFEFDFC 176 ;; 177 double) 178 value1=0x0102030405060708L 179 value2=0x1112131415161718L 180 value3=0xFFFEFDFCFBFAF9F8L 181 ;; 182 esac 183 184 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3" 185 186 echo $args 187 out=VarHandleTestByteArrayAs${Type}.java 188 rm -f $out 189 java $SPP -nel $args -iX-VarHandleTestByteArrayView.java.template -o$out 190 done 191 192 rm -fr build