1 #!/bin/bash
   2 
   3 #
   4 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
   5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6 #
   7 # This code is free software; you can redistribute it and/or modify it
   8 # under the terms of the GNU General Public License version 2 only, as
   9 # published by the Free Software Foundation.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 javac -d . ../../../../jdk/make/src/classes/build/tools/spp/Spp.java
  27 
  28 SPP=build.tools.spp.Spp
  29 
  30 # Generates unsafe access tests for objects and all primitive types
  31 # $1 = package name to Unsafe, sun.misc | jdk.internal.misc
  32 # $2 = test class qualifier name, SunMisc | JdkInternalMisc
  33 function generate {
  34     package=$1
  35     Qualifier=$2
  36 
  37     for type in boolean byte short char int long float double Object
  38     do
  39       Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}"
  40       args="-K$type -Dtype=$type -DType=$Type"
  41 
  42       case $type in
  43         Object|int|long)
  44           args="$args -KCAS -KOrdered"
  45           ;;
  46       esac
  47 
  48       case $type in
  49         int|long)
  50           args="$args -KAtomicAdd"
  51           ;;
  52       esac
  53 
  54       case $type in
  55         short|char|int|long)
  56           args="$args -KUnaligned"
  57           ;;
  58       esac
  59 
  60       case $type in
  61         boolean)
  62           value1=true
  63           value2=false
  64           value3=false
  65           ;;
  66         byte)
  67           value1=(byte)1
  68           value2=(byte)2
  69           value3=(byte)3
  70           ;;
  71         short)
  72           value1=(short)1
  73           value2=(short)2
  74           value3=(short)3
  75           ;;
  76         char)
  77           value1=\'a\'
  78           value2=\'b\'
  79           value3=\'c\'
  80           ;;
  81         int)
  82           value1=1
  83           value2=2
  84           value3=3
  85           ;;
  86         long)
  87           value1=1L
  88           value2=2L
  89           value3=3L
  90           ;;
  91         float)
  92           value1=1.0f
  93           value2=2.0f
  94           value3=3.0f
  95           ;;
  96         double)
  97           value1=1.0d
  98           value2=2.0d
  99           value3=3.0d
 100           ;;
 101         Object)
 102           value1=\"foo\"
 103           value2=\"bar\"
 104           value3=\"baz\"
 105           ;;
 106       esac
 107 
 108       args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3"
 109 
 110       echo $args
 111       java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier \
 112           $args < X-UnsafeAccessTest.java.template > ${Qualifier}UnsafeAccessTest${Type}.java
 113     done
 114 }
 115 
 116 generate sun.misc SunMisc
 117 generate jdk.internal.misc JdkInternalMisc
 118 
 119 rm -fr build