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