KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdi > internal > request > ReenterStepRequestImpl


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdi.internal.request;
12
13
14 import java.io.ByteArrayOutputStream JavaDoc;
15 import java.io.DataInputStream JavaDoc;
16 import java.io.DataOutputStream JavaDoc;
17 import java.io.IOException JavaDoc;
18
19 import org.eclipse.jdi.internal.VirtualMachineImpl;
20 import org.eclipse.jdi.internal.event.EventImpl;
21 import org.eclipse.jdi.internal.jdwp.JdwpCommandPacket;
22 import org.eclipse.jdi.internal.jdwp.JdwpReplyPacket;
23
24 /**
25  * this class implements the corresponding interfaces
26  * declared by the OTI Hot Code Replacement extentions of the
27  * JDI specification.
28  */

29
30 public class ReenterStepRequestImpl extends StepRequestImpl implements org.eclipse.jdi.hcr.ReenterStepRequest {
31     /**
32      * Creates new ReenterStepRequestImpl.
33      */

34     public ReenterStepRequestImpl(VirtualMachineImpl vmImpl) {
35         super("ReenterStepRequest", vmImpl); //$NON-NLS-1$
36
}
37     
38     /**
39      * @return Returns JDWP constant for step depth.
40      */

41     public int threadStepDepthJDWP(int threadStepDepth) {
42         return STEP_DEPTH_REENTER_JDWP_HCR;
43     }
44
45     /**
46      * Enables event request.
47      */

48     public void enable() {
49         if (isEnabled())
50             return;
51
52         initJdwpRequest();
53         try {
54             ByteArrayOutputStream JavaDoc outBytes = new ByteArrayOutputStream JavaDoc();
55             DataOutputStream JavaDoc outData = new DataOutputStream JavaDoc(outBytes);
56             writeByte(eventKind(), "event kind", EventImpl.eventKindMap(), outData); // Always 01 for Step event. //$NON-NLS-1$
57
writeByte(suspendPolicyJDWP(), "suspend policy", outData); //$NON-NLS-1$
58
writeInt(modifierCount(), "modifiers", outData); //$NON-NLS-1$
59
writeModifiers(outData);
60             
61             JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.HCR_REENTER_ON_EXIT, outBytes);
62             defaultReplyErrorHandler(replyPacket.errorCode());
63             DataInputStream JavaDoc replyData = replyPacket.dataInStream();
64             fRequestID = RequestID.read(this, replyData);
65             virtualMachineImpl().eventRequestManagerImpl().addRequestIDMapping(this);
66         } catch (IOException JavaDoc e) {
67             defaultIOExceptionHandler(e);
68         } finally {
69             handledJdwpRequest();
70         }
71     }
72 }
73
Popular Tags