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;
11:
12: import java.io.DataInputStream;
13: import java.io.IOException;
14:
15: import org.eclipse.jdi.internal.jdwp.JdwpClassObjectID;
16: import org.eclipse.jdi.internal.jdwp.JdwpCommandPacket;
17: import org.eclipse.jdi.internal.jdwp.JdwpID;
18: import org.eclipse.jdi.internal.jdwp.JdwpReplyPacket;
19:
20: import com.sun.jdi.ClassObjectReference;
21: import com.sun.jdi.ReferenceType;
22:
23: /**
24: * this class implements the corresponding interfaces
25: * declared by the JDI specification. See the com.sun.jdi package
26: * for more information.
27: *
28: */
29: public class ClassObjectReferenceImpl extends ObjectReferenceImpl
30: implements ClassObjectReference {
31: /** JDWP Tag. */
32: public static final byte tag = JdwpID.CLASS_OBJECT_TAG;
33:
34: /**
35: * Creates new ClassObjectReferenceImpl.
36: */
37: public ClassObjectReferenceImpl(VirtualMachineImpl vmImpl,
38: JdwpClassObjectID classObjectID) {
39: super ("ClassObjectReference", vmImpl, classObjectID); //$NON-NLS-1$
40: }
41:
42: /**
43: * @returns Returns Value tag.
44: */
45: public byte getTag() {
46: return tag;
47: }
48:
49: /**
50: * @returns Returns the ReferenceType corresponding to this class object.
51: */
52: public ReferenceType reflectedType() {
53: initJdwpRequest();
54: try {
55: JdwpReplyPacket replyPacket = requestVM(
56: JdwpCommandPacket.COR_REFLECTED_TYPE, this );
57: defaultReplyErrorHandler(replyPacket.errorCode());
58: DataInputStream replyData = replyPacket.dataInStream();
59: return ReferenceTypeImpl.readWithTypeTag(this , replyData);
60: } catch (IOException e) {
61: defaultIOExceptionHandler(e);
62: return null;
63: } finally {
64: handledJdwpRequest();
65: }
66: }
67:
68: /**
69: * @return Reads JDWP representation and returns new instance.
70: */
71: public static ClassObjectReferenceImpl read(MirrorImpl target,
72: DataInputStream in) throws IOException {
73: VirtualMachineImpl vmImpl = target.virtualMachineImpl();
74: JdwpClassObjectID ID = new JdwpClassObjectID(vmImpl);
75: ID.read(in);
76: if (target.fVerboseWriter != null)
77: target.fVerboseWriter.println(
78: "classObjectReference", ID.value()); //$NON-NLS-1$
79:
80: if (ID.isNull())
81: return null;
82:
83: ClassObjectReferenceImpl mirror = new ClassObjectReferenceImpl(
84: vmImpl, ID);
85: return mirror;
86: }
87: }
|