|
Java example source code file (ExceptionEvents.java)
The ExceptionEvents.java Java example source code
/*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 4407397
* @summary Test the requesting of exception events
*
* @author Robert Field
*
* @library scaffold
* @run build TestScaffold VMConnection
* @run compile -g ExceptionEvents.java
*
* @run main/othervm ExceptionEvents N A StackOverflowCaughtTarg java.lang.Exception
* @run main/othervm ExceptionEvents C A StackOverflowCaughtTarg null
* @run main/othervm ExceptionEvents C A StackOverflowCaughtTarg java.lang.Error
* @run main/othervm ExceptionEvents C A StackOverflowCaughtTarg java.lang.StackOverflowError
* @run main/othervm ExceptionEvents N A StackOverflowCaughtTarg java.lang.NullPointerException
* @run main/othervm ExceptionEvents N T StackOverflowCaughtTarg java.lang.Exception
* @run main/othervm ExceptionEvents C T StackOverflowCaughtTarg null
* @run main/othervm ExceptionEvents C T StackOverflowCaughtTarg java.lang.Error
* @run main/othervm ExceptionEvents C T StackOverflowCaughtTarg java.lang.StackOverflowError
* @run main/othervm ExceptionEvents N T StackOverflowCaughtTarg java.lang.NullPointerException
* @run main/othervm ExceptionEvents N N StackOverflowCaughtTarg java.lang.Exception
* @run main/othervm ExceptionEvents C N StackOverflowCaughtTarg null
* @run main/othervm ExceptionEvents C N StackOverflowCaughtTarg java.lang.Error
* @run main/othervm ExceptionEvents C N StackOverflowCaughtTarg java.lang.StackOverflowError
* @run main/othervm ExceptionEvents N N StackOverflowCaughtTarg java.lang.NullPointerException
* @run main/othervm ExceptionEvents N A StackOverflowUncaughtTarg java.lang.Exception
* @run main/othervm ExceptionEvents U A StackOverflowUncaughtTarg null
* @run main/othervm ExceptionEvents U A StackOverflowUncaughtTarg java.lang.Error
* @run main/othervm ExceptionEvents U A StackOverflowUncaughtTarg java.lang.StackOverflowError
* @run main/othervm ExceptionEvents N A StackOverflowUncaughtTarg java.lang.NullPointerException
* @run main/othervm ExceptionEvents N T StackOverflowUncaughtTarg java.lang.NullPointerException
* @run main/othervm ExceptionEvents N N StackOverflowUncaughtTarg java.lang.NullPointerException
*/
import com.sun.jdi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
import java.util.*;
class StackOverflowCaughtTarg {
public static void main(String[] args) {
try {
throw new StackOverflowError();
} catch (Throwable exc) {
// ignore
}
}
}
class StackOverflowUncaughtTarg {
public static void main(String[] args) {
thrower();
}
static void thrower() {
throw new StackOverflowError();
}
}
class StackOverflowIndirectTarg {
public static void main(String[] args) {
try {
thrower();
} catch (Throwable exc) {
System.out.println("Got exception: " + exc);
}
}
static void thrower() {
throw new StackOverflowError();
}
}
public class ExceptionEvents extends TestScaffold {
static int failureCount = 0;
static StringBuffer tooManySummary = new StringBuffer();
static StringBuffer notSentSummary = new StringBuffer();
static StringBuffer unexpectedSummary = new StringBuffer();
static int globalSuspendPolicy = -1;
static String[] flags;
final String target;
final String exceptionName;
final boolean caught;
final boolean uncaught;
final int suspendPolicy;
int eventCount = 0;
ExceptionRequest request;
ExceptionEvents(String target,
String exceptionName,
boolean caught, boolean uncaught,
int suspendPolicy) {
super(flags);
this.target = target;
this.exceptionName = exceptionName;
this.caught = caught;
this.uncaught = uncaught;
this.suspendPolicy = suspendPolicy;
}
static void everything() throws Exception {
goNeither("StackOverflowCaughtTarg", "java.lang.Exception");
goCaught("StackOverflowCaughtTarg", null);
goCaught("StackOverflowCaughtTarg", "java.lang.Error");
goCaught("StackOverflowCaughtTarg", "java.lang.StackOverflowError");
goNeither("StackOverflowCaughtTarg", "java.lang.NullPointerException");
goNeither("StackOverflowUncaughtTarg", "java.lang.Exception");
goUncaught("StackOverflowUncaughtTarg", null);
goUncaught("StackOverflowUncaughtTarg", "java.lang.Error");
goUncaught("StackOverflowUncaughtTarg", "java.lang.StackOverflowError");
goNeither("StackOverflowUncaughtTarg", "java.lang.NullPointerException");
}
static void usage() throws Exception {
System.err.println("Use either with no arguments or");
System.err.println(" c|u|n a|t|n <TargetClass>
Other Java examples (source code examples)Here is a short list of links related to this Java ExceptionEvents.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.