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