Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/jdi/CatchPatternTest.sh
38855 views
#!/bin/sh12#3# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425# @test26# @bug 467183827# @summary TTY: surprising ExceptionSpec.resolveEventRequest() wildcard results28# @author Tim Bell29#30# @run shell CatchPatternTest.sh31classname=CatchPatternTestTarg32createJavaFile()33{34cat <<EOF > $classname.java.135public class $classname {36public void bark(int i) {37System.out.println(" bark: " + i);38switch (i) {39case 0:40throw new IllegalArgumentException("IllegalArgumentException");41case 1:42throw new ArithmeticException("ArithmeticException");43case 2:44throw new IllegalMonitorStateException("IllegalMonitorStateException");45case 3:46throw new IndexOutOfBoundsException("IndexOutOfBoundsException");47default:48throw new Error("should not happen");49}50}51public void loop(int max) {52for (int i = 0; i <= max; i++) {53try {54bark(i);55} catch(RuntimeException re) {56System.out.println(" loop: " + re.getMessage() +57" caught and ignored.");58}59}60}61public void partOne() {62loop(2);63System.out.println("partOne completed");64}65public void partTwo() {66loop(3);67System.out.println("partTwo completed");68}69public static void main(String[] args) {70System.out.println("Howdy!");71$classname my = new $classname();72my.partOne();73my.partTwo();74System.out.println("Goodbye from $classname!");75}76}77EOF78}7980# This is called to feed cmds to jdb.81dojdbCmds()82{83#set -x84cmd stop in ${classname}.main85cmd stop in ${classname}.partTwo86runToBkpt87cmd ignore uncaught java.lang.Throwable88cmd catch all java.lang.I*89cmd cont90cmd cont91cmd cont92cmd ignore all java.lang.I*93cmd cont94cmd quit95}9697mysetup()98{99if [ -z "$TESTSRC" ] ; then100TESTSRC=.101fi102103for ii in . $TESTSRC $TESTSRC/.. ; do104if [ -r "$ii/ShellScaffold.sh" ] ; then105. $ii/ShellScaffold.sh106break107fi108done109}110111# You could replace this next line with the contents112# of ShellScaffold.sh and this script will run just the same.113mysetup114115runit116#117jdbFailIfNotPresent "Exception occurred: java.lang.IllegalArgumentException"118jdbFailIfNotPresent "Exception occurred: java.lang.IllegalMonitorStateException"119jdbFailIfPresent "Exception occurred: ArithmeticException"120jdbFailIfPresent "Exception occurred: IndexOutOfBoundsException"121jdbFailIfPresent "Exception occurred: IllegalStateException"122jdbFailIfPresent "should not happen"123debuggeeFailIfNotPresent "partOne completed"124debuggeeFailIfNotPresent "partTwo completed"125#126pass127128129