< prev index next >

test/compiler/intrinsics/string/TestStringIntrinsicRangeChecks.java

Print this page




  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/othervm -Xbatch -XX:CompileThreshold=100 -XX:-TieredCompilation compiler.intrinsics.string.TestStringIntrinsicRangeChecks
  34  */
  35 package compiler.intrinsics.string;
  36 
  37 import java.lang.Helper;
  38 import java.lang.reflect.InvocationTargetException;
  39 import java.lang.reflect.Method;
  40 
  41 public class TestStringIntrinsicRangeChecks {
  42     // Prepare test arrays
  43     private static int SIZE = 16;
  44     private static byte[] byteArray = new byte[SIZE];
  45     private static char[] charArray = new char[SIZE];
  46 
  47     public static void check(Method m, boolean shouldThrow, Object... args) throws Exception {
  48         // Prepare error message
  49         String message = m.getName() + "(";
  50         for (int i = 0; i < args.length; ++i) {
  51             message += args[i];
  52             message += (i+1 < args.length) ? ", " : ")";




  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 /test/lib
  31  * @build java.base/java.lang.Helper

  32  * @run main/othervm -Xbatch -XX:CompileThreshold=100 -XX:-TieredCompilation compiler.intrinsics.string.TestStringIntrinsicRangeChecks
  33  */
  34 package compiler.intrinsics.string;
  35 
  36 import java.lang.Helper;
  37 import java.lang.reflect.InvocationTargetException;
  38 import java.lang.reflect.Method;
  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) ? ", " : ")";


< prev index next >