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   out=VarHandleTestAccess${Type}.java
  92   rm -f $out
  93   java $SPP -nel $args -iX-VarHandleTestAccess.java.template -o$out
  94   out=VarHandleTestMethodHandleAccess${Type}.java
  95   rm -f $out
  96   java $SPP -nel $args -iX-VarHandleTestMethodHandleAccess.java.template -o$out
  97   out=VarHandleTestMethodType${Type}.java
  98   rm -f $out
  99   java $SPP -nel $args -iX-VarHandleTestMethodType.java.template -o$out
 100 done
 101 
 102 for type in short char int long float double
 103 do
 104   Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}"
 105   args="-K$type -Dtype=$type -DType=$Type"
 106 
 107   BoxType=$Type
 108   case $type in
 109     char)
 110       BoxType=Character
 111       ;;
 112     int)
 113       BoxType=Integer
 114       ;;
 115   esac
 116   args="$args -DBoxType=$BoxType"
 117 
 118   case $type in
 119     int|long|float|double)
 120       args="$args -KCAS"
 121       ;;
 122   esac
 123 
 124   case $type in
 125     int|long)
 126       args="$args -KAtomicAdd"
 127       ;;
 128   esac
 129 
 130   case $type in
 131     int|long)
 132       args="$args -KBitwise"
 133       ;;
 134   esac
 135 
 136   # The value of `value3` is chosen such that when added to `value1` or `value2`
 137   # it will result in carrying of bits over to the next byte, thereby detecting
 138   # possible errors in endianness conversion e.g. if say for atomic addition the
 139   # augend is incorrectly processed
 140   case $type in
 141     short)
 142       value1=(short)0x0102
 143       value2=(short)0x1112
 144       value3=(short)0xFFFE
 145       ;;
 146     char)
 147       value1=(char)0x0102
 148       value2=(char)0x1112
 149       value3=(char)0xFFFE
 150       ;;
 151     int)
 152       value1=0x01020304
 153       value2=0x11121314
 154       value3=0xFFFEFDFC
 155       ;;
 156     long)
 157       value1=0x0102030405060708L
 158       value2=0x1112131415161718L
 159       value3=0xFFFEFDFCFBFAF9F8L
 160       ;;
 161     float)
 162       value1=0x01020304
 163       value2=0x11121314
 164       value3=0xFFFEFDFC
 165       ;;
 166     double)
 167       value1=0x0102030405060708L
 168       value2=0x1112131415161718L
 169       value3=0xFFFEFDFCFBFAF9F8L
 170       ;;
 171   esac
 172 
 173   args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3"
 174 
 175   echo $args
 176   out=VarHandleTestByteArrayAs${Type}.java
 177   rm -f $out
 178   java $SPP -nel $args -iX-VarHandleTestByteArrayView.java.template -o$out
 179 done
 180 
 181 rm -fr build