01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdi.internal.event;
11:
12: import java.io.DataInputStream;
13: import java.io.IOException;
14:
15: import org.eclipse.jdi.internal.LocationImpl;
16: import org.eclipse.jdi.internal.MirrorImpl;
17: import org.eclipse.jdi.internal.ObjectReferenceImpl;
18: import org.eclipse.jdi.internal.VirtualMachineImpl;
19: import org.eclipse.jdi.internal.request.RequestID;
20:
21: import com.sun.jdi.Location;
22: import com.sun.jdi.ObjectReference;
23: import com.sun.jdi.event.ExceptionEvent;
24:
25: /**
26: * this class implements the corresponding interfaces
27: * declared by the JDI specification. See the com.sun.jdi package
28: * for more information.
29: *
30: */
31: public class ExceptionEventImpl extends LocatableEventImpl implements
32: ExceptionEvent {
33: /** Jdwp Event Kind. */
34: public static final byte EVENT_KIND = EVENT_EXCEPTION;
35:
36: /** Thrown exception. */
37: private ObjectReferenceImpl fException;
38: /** Location of catch, or 0 if not caught. */
39: private LocationImpl fCatchLocation;
40:
41: /**
42: * Creates new ExceptionEventImpl.
43: */
44: private ExceptionEventImpl(VirtualMachineImpl vmImpl,
45: RequestID requestID) {
46: super ("ExceptionEvent", vmImpl, requestID); //$NON-NLS-1$
47: }
48:
49: /**
50: * @return Creates, reads and returns new EventImpl, of which requestID has already been read.
51: */
52: public static ExceptionEventImpl read(MirrorImpl target,
53: RequestID requestID, DataInputStream dataInStream)
54: throws IOException {
55: VirtualMachineImpl vmImpl = target.virtualMachineImpl();
56: ExceptionEventImpl event = new ExceptionEventImpl(vmImpl,
57: requestID);
58: event.readThreadAndLocation(target, dataInStream);
59: event.fException = ObjectReferenceImpl.readObjectRefWithTag(
60: target, dataInStream);
61: event.fCatchLocation = LocationImpl.read(target, dataInStream);
62: return event;
63: }
64:
65: /**
66: * @return Returns the location where the exception will be caught.
67: */
68: public Location catchLocation() {
69: return fCatchLocation;
70: }
71:
72: /**
73: * @return Returns the thrown exception object.
74: */
75: public ObjectReference exception() {
76: return fException;
77: }
78: }
|