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 # $3 = module name containing the Unsafe class, for @modules 34 function generate { 35 package=$1 36 Qualifier=$2 37 module=$3 38 39 for type in boolean byte short char int long float double Object 40 do 41 Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" 42 args="-K$type -Dtype=$type -DType=$Type" 43 44 case $type in 45 Object|int|long) 46 args="$args -KCAS -KOrdered" 47 ;; 48 esac 49 50 case $type in 51 int|long) 52 args="$args -KAtomicAdd" 53 ;; 54 esac 55 56 case $type in 57 short|char|int|long) 58 args="$args -KUnaligned" 59 ;; 60 esac 61 62 case $type in 63 boolean) 64 value1=true 65 value2=false 66 value3=false 67 ;; 68 byte) 69 value1=(byte)1 70 value2=(byte)2 71 value3=(byte)3 72 ;; 73 short) 74 value1=(short)1 75 value2=(short)2 76 value3=(short)3 77 ;; 78 char) 79 value1=\'a\' 80 value2=\'b\' 81 value3=\'c\' 82 ;; 83 int) 84 value1=1 85 value2=2 86 value3=3 87 ;; 88 long) 89 value1=1L 90 value2=2L 91 value3=3L 92 ;; 93 float) 94 value1=1.0f 95 value2=2.0f 96 value3=3.0f 97 ;; 98 double) 99 value1=1.0d 100 value2=2.0d 101 value3=3.0d 102 ;; 103 Object) 104 value1=\"foo\" 105 value2=\"bar\" 106 value3=\"baz\" 107 ;; 108 esac 109 110 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3" 111 112 echo $args 113 java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier -Dmodule=$module \ 114 $args < X-UnsafeAccessTest.java.template > ${Qualifier}UnsafeAccessTest${Type}.java 115 done 116 } 117 118 generate sun.misc SunMisc jdk.unsupported 119 generate jdk.internal.misc JdkInternalMisc java.base 120 121 rm -fr build