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 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 wrong_primitive_type=boolean 32 33 case $type in 34 boolean) 35 value1=true 36 value2=false 37 value3=false 38 wrong_primitive_type=int 39 ;; 40 byte) 41 value1=(byte)0x01 42 value2=(byte)0x23 43 value3=(byte)0x45 44 ;; 45 short) 46 value1=(short)0x0123 47 value2=(short)0x4567 48 value3=(short)0x89AB 49 ;; 50 char) 51 value1=\'\\\\u0123\' 52 value2=\'\\\\u4567\' 53 value3=\'\\\\u89AB\' 54 ;; 55 int) 56 value1=0x01234567 57 value2=0x89ABCDEF 58 value3=0xCAFEBABE 59 ;; 60 long) 61 value1=0x0123456789ABCDEFL 62 value2=0xCAFEBABECAFEBABEL 63 value3=0xDEADBEEFDEADBEEFL 64 ;; 65 float) 66 value1=1.0f 67 value2=2.0f 68 value3=3.0f 69 ;; 70 double) 71 value1=1.0d 72 value2=2.0d 73 value3=3.0d 74 ;; 75 String) 76 value1=\"foo\" 77 value2=\"bar\" 78 value3=\"baz\" 79 ;; 80 esac 81 82 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3 -Dwrong_primitive_type=$wrong_primitive_type" 83 84 echo $args 85 out=VarHandleTestAccess${Type}.java 86 rm -f $out 87 java $SPP -nel $args -iX-VarHandleTestAccess.java.template -o$out 88 out=VarHandleTestMethodHandleAccess${Type}.java 89 rm -f $out 90 java $SPP -nel $args -iX-VarHandleTestMethodHandleAccess.java.template -o$out 91 out=VarHandleTestMethodType${Type}.java 92 rm -f $out 93 java $SPP -nel $args -iX-VarHandleTestMethodType.java.template -o$out 94 done 95 96 for type in short char int long float double 97 do 98 Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" 99 args="-K$type -Dtype=$type -DType=$Type" 100 101 BoxType=$Type 102 case $type in 103 char) 104 BoxType=Character 105 ;; 106 int) 107 BoxType=Integer 108 ;; 109 esac 110 args="$args -DBoxType=$BoxType" 111 112 case $type in 113 int|long|float|double) 114 args="$args -KCAS" 115 ;; 116 esac 117 118 case $type in 119 int|long) 120 args="$args -KAtomicAdd" 121 ;; 122 esac 123 124 case $type in 125 int|long) 126 args="$args -KBitwise" 127 ;; 128 esac 129 130 # The value of `value3` is chosen such that when added to `value1` or `value2` 131 # it will result in carrying of bits over to the next byte, thereby detecting 132 # possible errors in endianness conversion e.g. if say for atomic addition the 133 # augend is incorrectly processed 134 case $type in 135 short) 136 value1=(short)0x0102 137 value2=(short)0x1112 138 value3=(short)0xFFFE 139 ;; 140 char) 141 value1=(char)0x0102 142 value2=(char)0x1112 143 value3=(char)0xFFFE 144 ;; 145 int) 146 value1=0x01020304 147 value2=0x11121314 148 value3=0xFFFEFDFC 149 ;; 150 long) 151 value1=0x0102030405060708L 152 value2=0x1112131415161718L 153 value3=0xFFFEFDFCFBFAF9F8L 154 ;; 155 float) 156 value1=0x01020304 157 value2=0x11121314 158 value3=0xFFFEFDFC 159 ;; 160 double) 161 value1=0x0102030405060708L 162 value2=0x1112131415161718L 163 value3=0xFFFEFDFCFBFAF9F8L 164 ;; 165 esac 166 167 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3" 168 169 echo $args 170 out=VarHandleTestByteArrayAs${Type}.java 171 rm -f $out 172 java $SPP -nel $args -iX-VarHandleTestByteArrayView.java.template -o$out 173 done 174 175 rm -fr build