test/compiler/intrinsics/mathexact/sanity/MathIntrinsic.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8130832-review Sdiff test/compiler/intrinsics/mathexact/sanity

test/compiler/intrinsics/mathexact/sanity/MathIntrinsic.java

Print this page
rev 8688 : 1234567: Invalid bug number
Summary: This is a local commit to reduce jprt submit time.
Reviewed-by: kvn


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.lang.reflect.Executable;
  25 import java.util.concurrent.Callable;
  26 
  27 public class MathIntrinsic {
  28 
  29     enum IntIntrinsic implements CompilerWhiteBoxTest.TestCase {
  30         Add {
  31             @Override





  32             Object execMathMethod() {
  33                 return intR = Math.addExact(int1, int2);
  34             }
  35         },
  36         Subtract {
  37             @Override





  38             Object execMathMethod() {
  39                 return intR = Math.subtractExact(int1, int2);
  40             }
  41         },
  42         Multiply {
  43             @Override





  44             Object execMathMethod() {
  45                 return intR = Math.multiplyExact(int1, int2);
  46             }
  47         },
  48         Increment {
  49             @Override





  50             Object execMathMethod() {
  51                 return intR = Math.incrementExact(int1);
  52             }
  53         },
  54         Decrement {
  55             @Override





  56             Object execMathMethod() {
  57                 return intR = Math.decrementExact(int1);
  58             }
  59         },
  60         Negate {
  61             @Override





  62             Object execMathMethod() {
  63                 return intR = Math.negateExact(int1);
  64             }
  65         };

  66         protected int int1;
  67         protected int int2;
  68         protected int intR;
  69 

  70         abstract Object execMathMethod();
  71 










  72         @Override
  73         public Executable getExecutable() {
  74             try {
  75                 return getClass().getDeclaredMethod("execMathMethod");
  76             } catch (NoSuchMethodException e) {
  77                 throw new RuntimeException("Test bug, no such method: " + e);
  78             }
  79         }
  80 
  81         @Override
  82         public Callable<Integer> getCallable() {
  83             return null;
  84         }
  85 
  86         @Override
  87         public boolean isOsr() {
  88             return false;
  89         }
  90 
  91     }
  92 
  93     enum LongIntrinsic implements CompilerWhiteBoxTest.TestCase {
  94         Add {
  95             @Override





  96             Object execMathMethod() {
  97                 return longR = Math.addExact(long1, long2);
  98             }
  99         },
 100         Subtract {
 101             @Override





 102             Object execMathMethod() {
 103                 return longR = Math.subtractExact(long1, long2);
 104             }
 105         },
 106         Multiply {
 107             @Override





 108             Object execMathMethod() {
 109                 return longR = Math.multiplyExact(long1, long2);
 110             }
 111         },
 112         Increment {
 113             @Override





 114             Object execMathMethod() {
 115                 return longR = Math.incrementExact(long1);
 116             }
 117         },
 118         Decrement {
 119             @Override





 120             Object execMathMethod() {
 121                 return longR = Math.decrementExact(long1);
 122             }
 123         },
 124         Negate {
 125             @Override





 126             Object execMathMethod() {
 127                 return longR = Math.negateExact(long1);
 128             }
 129         };
 130         protected long long1;
 131         protected long long2;
 132         protected long longR;
 133 

 134         abstract Object execMathMethod();










 135 
 136         @Override
 137         public Executable getExecutable() {
 138             try {
 139                 return getClass().getDeclaredMethod("execMathMethod");
 140             } catch (NoSuchMethodException e) {
 141                 throw new RuntimeException("Test bug, no such method: " + e);
 142             }
 143         }
 144 
 145         @Override
 146         public Callable<Integer> getCallable() {
 147             return null;
 148         }
 149 
 150         @Override
 151         public boolean isOsr() {
 152             return false;
 153         }
 154     }


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.lang.reflect.Executable;
  25 import java.util.concurrent.Callable;
  26 
  27 public class MathIntrinsic {
  28 
  29     enum IntIntrinsic implements CompilerWhiteBoxTest.TestCase {
  30         Add {
  31             @Override
  32             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
  33                 return Class.forName("java.lang.Math").getDeclaredMethod("addExact", int.class, int.class);
  34             }
  35 
  36             @Override
  37             Object execMathMethod() {
  38                 return intR = Math.addExact(int1, int2);
  39             }
  40         },
  41        Subtract {
  42             @Override
  43             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
  44                 return Class.forName("java.lang.Math").getDeclaredMethod("subtractExact", int.class, int.class);
  45             }
  46 
  47             @Override
  48             Object execMathMethod() {
  49                 return intR = Math.subtractExact(int1, int2);
  50             }
  51         },
  52         Multiply {
  53             @Override
  54             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
  55                 return Class.forName("java.lang.Math").getDeclaredMethod("multiplyExact", int.class, int.class);
  56             }
  57 
  58             @Override
  59             Object execMathMethod() {
  60                 return intR = Math.multiplyExact(int1, int2);
  61             }
  62         },
  63         Increment {
  64             @Override
  65             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
  66                 return Class.forName("java.lang.Math").getDeclaredMethod("incrementExact", int.class);
  67             }
  68 
  69             @Override
  70             Object execMathMethod() {
  71                 return intR = Math.incrementExact(int1);
  72             }
  73         },
  74         Decrement {
  75             @Override
  76             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
  77                 return Class.forName("java.lang.Math").getDeclaredMethod("decrementExact", int.class);
  78             }
  79 
  80             @Override
  81             Object execMathMethod() {
  82                 return intR = Math.decrementExact(int1);
  83             }
  84         },
  85         Negate {
  86             @Override
  87             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
  88                 return Class.forName("java.lang.Math").getDeclaredMethod("negateExact", int.class);
  89             }
  90 
  91             @Override
  92             Object execMathMethod() {
  93                 return intR = Math.negateExact(int1);
  94             }
  95         };
  96 
  97         protected int int1;
  98         protected int int2;
  99         protected int intR;
 100 
 101         abstract Executable testMethod() throws NoSuchMethodException, ClassNotFoundException;
 102         abstract Object execMathMethod();
 103 
 104         public Executable getTestMethod() {
 105             try {
 106                 return testMethod();
 107             } catch (NoSuchMethodException e) {
 108                 throw new RuntimeException("Test bug, no such method: " + e);
 109             } catch (ClassNotFoundException e) {
 110                 throw new RuntimeException("Test bug, no such class: " + e);
 111             }
 112         }
 113 
 114         @Override
 115         public Executable getExecutable() {
 116             try {
 117                 return getClass().getDeclaredMethod("execMathMethod");
 118             } catch (NoSuchMethodException e) {
 119                 throw new RuntimeException("Test bug, no such method: " + e);
 120             }
 121         }
 122 
 123         @Override
 124         public Callable<Integer> getCallable() {
 125             return null;
 126         }
 127 
 128         @Override
 129         public boolean isOsr() {
 130             return false;
 131         }
 132 
 133     }
 134 
 135     enum LongIntrinsic implements CompilerWhiteBoxTest.TestCase {
 136         Add {
 137             @Override
 138             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
 139                 return Class.forName("java.lang.Math").getDeclaredMethod("addExact", long.class, long.class);
 140             }
 141 
 142             @Override
 143             Object execMathMethod() {
 144                 return longR = Math.addExact(long1, long2);
 145             }
 146         },
 147         Subtract {
 148             @Override
 149             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
 150                 return Class.forName("java.lang.Math").getDeclaredMethod("subtractExact", long.class, long.class);
 151             }
 152 
 153             @Override
 154             Object execMathMethod() {
 155                 return longR = Math.subtractExact(long1, long2);
 156             }
 157         },
 158         Multiply {
 159             @Override
 160             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
 161                 return Class.forName("java.lang.Math").getDeclaredMethod("multiplyExact", long.class, long.class);
 162             }
 163 
 164             @Override
 165             Object execMathMethod() {
 166                 return longR = Math.multiplyExact(long1, long2);
 167             }
 168         },
 169         Increment {
 170             @Override
 171             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
 172                 return Class.forName("java.lang.Math").getDeclaredMethod("incrementExact", long.class);
 173             }
 174 
 175             @Override
 176             Object execMathMethod() {
 177                 return longR = Math.incrementExact(long1);
 178             }
 179         },
 180         Decrement {
 181             @Override
 182             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
 183                 return Class.forName("java.lang.Math").getDeclaredMethod("decrementExact", long.class);
 184             }
 185 
 186             @Override
 187             Object execMathMethod() {
 188                 return longR = Math.decrementExact(long1);
 189             }
 190         },
 191         Negate {
 192             @Override
 193             Executable testMethod() throws NoSuchMethodException, ClassNotFoundException {
 194                 return Class.forName("java.lang.Math").getDeclaredMethod("negateExact", long.class);
 195             }
 196 
 197             @Override
 198             Object execMathMethod() {
 199                 return longR = Math.negateExact(long1);
 200             }
 201         };
 202         protected long long1;
 203         protected long long2;
 204         protected long longR;
 205 
 206         abstract Executable testMethod() throws NoSuchMethodException, ClassNotFoundException;
 207         abstract Object execMathMethod();
 208 
 209         public Executable getTestMethod() {
 210             try {
 211                 return testMethod();
 212             } catch (NoSuchMethodException e) {
 213                 throw new RuntimeException("Test bug, no such method: " + e);
 214             } catch (ClassNotFoundException e) {
 215                 throw new RuntimeException("Test bug, no such class: " + e);
 216             }
 217         }
 218 
 219         @Override
 220         public Executable getExecutable() {
 221             try {
 222                 return getClass().getDeclaredMethod("execMathMethod");
 223             } catch (NoSuchMethodException e) {
 224                 throw new RuntimeException("Test bug, no such method: " + e);
 225             }
 226         }
 227 
 228         @Override
 229         public Callable<Integer> getCallable() {
 230             return null;
 231         }
 232 
 233         @Override
 234         public boolean isOsr() {
 235             return false;
 236         }
 237     }
test/compiler/intrinsics/mathexact/sanity/MathIntrinsic.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File