1 #!/bin/bash 2 3 javac -d . ../../../../../make/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 case $type in 18 String|boolean|byte|short|char|int|long) 19 args="$args -KCAS" 20 ;; 21 esac 22 23 case $type in 24 byte|short|char|int|long) 25 args="$args -KAtomicAdd" 26 ;; 27 esac 28 29 wrong_primitive_type=boolean 30 31 case $type in 32 boolean) 33 value1=true 34 value2=false 35 value3=false 36 wrong_primitive_type=int 37 ;; 38 byte) 39 value1=(byte)0x01 40 value2=(byte)0x23 41 value3=(byte)0x45 42 ;; 43 short) 44 value1=(short)0x0123 45 value2=(short)0x4567 46 value3=(short)0x89AB 47 ;; 48 char) 49 value1=\'\\\\u0123\' 50 value2=\'\\\\u4567\' 51 value3=\'\\\\u89AB\' 52 ;; 53 int) 54 value1=0x01234567 55 value2=0x89ABCDEF 56 value3=0xCAFEBABE 57 ;; 58 long) 59 value1=0x0123456789ABCDEFL 60 value2=0xCAFEBABECAFEBABEL 61 value3=0xDEADBEEFDEADBEEFL 62 ;; 63 float) 64 value1=1.0f 65 value2=2.0f 66 value3=3.0f 67 ;; 68 double) 69 value1=1.0d 70 value2=2.0d 71 value3=3.0d 72 ;; 73 String) 74 value1=\"foo\" 75 value2=\"bar\" 76 value3=\"baz\" 77 ;; 78 esac 79 80 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3 -Dwrong_primitive_type=$wrong_primitive_type" 81 82 echo $args 83 java $SPP -nel $args < X-VarHandleTestAccess.java.template > VarHandleTestAccess${Type}.java 84 java $SPP -nel $args < X-VarHandleTestMethodHandleAccess.java.template > VarHandleTestMethodHandleAccess${Type}.java 85 java $SPP -nel $args < X-VarHandleTestMethodType.java.template > VarHandleTestMethodType${Type}.java 86 done 87 88 for type in short char int long float double 89 do 90 Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" 91 args="-K$type -Dtype=$type -DType=$Type" 92 93 BoxType=$Type 94 case $type in 95 char) 96 BoxType=Character 97 ;; 98 int) 99 BoxType=Integer 100 ;; 101 esac 102 args="$args -DBoxType=$BoxType" 103 104 case $type in 105 int|long|float|double) 106 args="$args -KCAS" 107 ;; 108 esac 109 110 case $type in 111 int|long) 112 args="$args -KAtomicAdd" 113 ;; 114 esac 115 116 case $type in 117 short) 118 value1=(short)0x0102 119 value2=(short)0x1112 120 value3=(short)0x2122 121 ;; 122 char) 123 value1=(char)0x0102 124 value2=(char)0x1112 125 value3=(char)0x2122 126 ;; 127 int) 128 value1=0x01020304 129 value2=0x11121314 130 value3=0x21222324 131 ;; 132 long) 133 value1=0x0102030405060708L 134 value2=0x1112131415161718L 135 value3=0x2122232425262728L 136 ;; 137 float) 138 value1=0x01020304 139 value2=0x11121314 140 value3=0x21222324 141 ;; 142 double) 143 value1=0x0102030405060708L 144 value2=0x1112131415161718L 145 value3=0x2122232425262728L 146 ;; 147 esac 148 149 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3" 150 151 echo $args 152 java $SPP -nel $args < X-VarHandleTestByteArrayView.java.template > VarHandleTestByteArrayAs${Type}.java 153 done 154 155 rm -fr build