< prev index next >

test/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


  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 /*
  27  * @test
  28  * @bug 8155608
  29  * @summary Verifies that string intrinsics throw array out of bounds exceptions.
  30  * @library /compiler/patches /testlibrary /test/lib /

  31  * @build java.base/java.lang.Helper
  32  * @build compiler.intrinsics.string.TestStringIntrinsicRangeChecks
  33  * @run main compiler.intrinsics.string.TestStringIntrinsicRangeChecks
  34  */

  35 package compiler.intrinsics.string;
  36 
  37 import java.lang.Helper;
  38 import java.lang.reflect.*;
  39 
  40 public class TestStringIntrinsicRangeChecks {
  41     // Prepare test arrays
  42     private static int SIZE = 16;
  43     private static byte[] byteArray = new byte[SIZE];
  44     private static char[] charArray = new char[SIZE];
  45 
  46     public static void check(Method m, boolean shouldThrow, Object... args) throws Exception {
  47         // Prepare error message
  48         String message = m.getName() + "(";
  49         for (int i = 0; i < args.length; ++i) {
  50             message += args[i];
  51             message += (i+1 < args.length) ? ", " : ")";
  52         }
  53 
  54         try {
  55             m.invoke(null, args);
  56         } catch (InvocationTargetException e) {
  57             // Get actual exception
  58             Throwable t = e.getTargetException();




  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 /*
  27  * @test
  28  * @bug 8155608
  29  * @summary Verifies that string intrinsics throw array out of bounds exceptions.
  30  * @library /compiler/patches /testlibrary /test/lib
  31  *
  32  * @build java.base/java.lang.Helper
  33  * @build compiler.intrinsics.string.TestStringIntrinsicRangeChecks
  34  * @run main compiler.intrinsics.string.TestStringIntrinsicRangeChecks
  35  */
  36 
  37 package compiler.intrinsics.string;
  38 
  39 import java.lang.reflect.InvocationTargetException;
  40 import java.lang.reflect.Method;
  41 
  42 public class TestStringIntrinsicRangeChecks {
  43     // Prepare test arrays
  44     private static int SIZE = 16;
  45     private static byte[] byteArray = new byte[SIZE];
  46     private static char[] charArray = new char[SIZE];
  47 
  48     public static void check(Method m, boolean shouldThrow, Object... args) throws Exception {
  49         // Prepare error message
  50         String message = m.getName() + "(";
  51         for (int i = 0; i < args.length; ++i) {
  52             message += args[i];
  53             message += (i+1 < args.length) ? ", " : ")";
  54         }
  55 
  56         try {
  57             m.invoke(null, args);
  58         } catch (InvocationTargetException e) {
  59             // Get actual exception
  60             Throwable t = e.getTargetException();


< prev index next >