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   case $type in
  32     boolean|byte|short|char|int|long|float|double)
  33       args="$args -KValue"
  34       ;;
  35   esac
  36 
  37   wrong_primitive_type=boolean
  38 
  39   case $type in
  40     boolean)
  41       value1=true
  42       value2=false
  43       value3=false
  44       wrong_primitive_type=int
  45       ;;
  46     byte)
  47       value1=(byte)0x01
  48       value2=(byte)0x23
  49       value3=(byte)0x45
  50       ;;
  51     short)
  52       value1=(short)0x0123
  53       value2=(short)0x4567
  54       value3=(short)0x89AB
  55       ;;
  56     char)
  57       value1=\'\\\\u0123\'
  58       value2=\'\\\\u4567\'
  59       value3=\'\\\\u89AB\'
  60       ;;
  61     int)
  62       value1=0x01234567
  63       value2=0x89ABCDEF
  64       value3=0xCAFEBABE
  65       ;;
  66     long)
  67       value1=0x0123456789ABCDEFL
  68       value2=0xCAFEBABECAFEBABEL
  69       value3=0xDEADBEEFDEADBEEFL
  70       ;;
  71     float)
  72       value1=1.0f
  73       value2=2.0f
  74       value3=3.0f
  75       ;;
  76     double)
  77       value1=1.0d
  78       value2=2.0d
  79       value3=3.0d
  80       ;;
  81     String)
  82       value1=\"foo\"
  83       value2=\"bar\"
  84       value3=\"baz\"
  85       ;;
  86   esac
  87 
  88   args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3 -Dwrong_primitive_type=$wrong_primitive_type"
  89 
  90   echo $args
  91   java $SPP -nel $args < X-VarHandleTestAccess.java.template > VarHandleTestAccess${Type}.java
  92   java $SPP -nel $args < X-VarHandleTestMethodHandleAccess.java.template > VarHandleTestMethodHandleAccess${Type}.java
  93   java $SPP -nel $args < X-VarHandleTestMethodType.java.template > VarHandleTestMethodType${Type}.java
  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   java $SPP -nel $args < X-VarHandleTestByteArrayView.java.template > VarHandleTestByteArrayAs${Type}.java
 171 done
 172 
 173 rm -fr build