1 #!/bin/bash 2 3 # 4 # Copyright (c) 2015, 2019, 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 . ../../../../../make/jdk/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 if [ "$Type" == "Object" -a "$package" == "jdk.internal.misc" ]; then 45 args="$args -DMethodAffix=Reference" 46 else 47 args="$args -DMethodAffix=$Type" 48 fi 49 50 case $type in 51 Object|int|long) 52 args="$args -KCAS -KOrdered" 53 ;; 54 esac 55 56 case $type in 57 int|long) 58 args="$args -KAtomicAdd" 59 ;; 60 esac 61 62 if [ "$package" == "jdk.internal.misc" ]; then 63 case $type in 64 boolean|byte|char|short|float|double) 65 args="$args -KCAS" 66 ;; 67 esac 68 case $type in 69 byte|char|short|float|double) 70 args="$args -KAtomicAdd" 71 ;; 72 esac 73 fi 74 75 case $type in 76 short|char|int|long) 77 args="$args -KUnaligned" 78 ;; 79 esac 80 81 case $type in 82 boolean) 83 value1=true 84 value2=false 85 value3=false 86 ;; 87 byte) 88 value1=(byte)0x01 89 value2=(byte)0x23 90 value3=(byte)0x45 91 ;; 92 short) 93 value1=(short)0x0123 94 value2=(short)0x4567 95 value3=(short)0x89AB 96 ;; 97 char) 98 value1=\'\\\\u0123\' 99 value2=\'\\\\u4567\' 100 value3=\'\\\\u89AB\' 101 ;; 102 int) 103 value1=0x01234567 104 value2=0x89ABCDEF 105 value3=0xCAFEBABE 106 ;; 107 long) 108 value1=0x0123456789ABCDEFL 109 value2=0xCAFEBABECAFEBABEL 110 value3=0xDEADBEEFDEADBEEFL 111 ;; 112 float) 113 value1=1.0f 114 value2=2.0f 115 value3=3.0f 116 ;; 117 double) 118 value1=1.0d 119 value2=2.0d 120 value3=3.0d 121 ;; 122 Object) 123 value1=\"foo\" 124 value2=\"bar\" 125 value3=\"baz\" 126 ;; 127 esac 128 129 args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3" 130 131 echo $args 132 out=${Qualifier}UnsafeAccessTest${Type}.java 133 rm -rf "$out" 134 java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier -Dmodule=$module \ 135 $args -iX-UnsafeAccessTest.java.template -o$out 136 done 137 } 138 139 generate sun.misc SunMisc jdk.unsupported 140 generate jdk.internal.misc JdkInternalMisc java.base 141 142 rm -fr build