KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdi > internal > ClassObjectReferenceImpl


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;
12
13
14 import java.io.DataInputStream JavaDoc;
15 import java.io.IOException JavaDoc;
16
17 import org.eclipse.jdi.internal.jdwp.JdwpClassObjectID;
18 import org.eclipse.jdi.internal.jdwp.JdwpCommandPacket;
19 import org.eclipse.jdi.internal.jdwp.JdwpID;
20 import org.eclipse.jdi.internal.jdwp.JdwpReplyPacket;
21
22 import com.sun.jdi.ClassObjectReference;
23 import com.sun.jdi.ReferenceType;
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 ClassObjectReferenceImpl extends ObjectReferenceImpl implements ClassObjectReference {
32     /** JDWP Tag. */
33     public static final byte tag = JdwpID.CLASS_OBJECT_TAG;
34
35     /**
36      * Creates new ClassObjectReferenceImpl.
37      */

38     public ClassObjectReferenceImpl(VirtualMachineImpl vmImpl, 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(JdwpCommandPacket.COR_REFLECTED_TYPE, this);
56             defaultReplyErrorHandler(replyPacket.errorCode());
57             DataInputStream JavaDoc replyData = replyPacket.dataInStream();
58             return ReferenceTypeImpl.readWithTypeTag(this, replyData);
59         } catch (IOException JavaDoc e) {
60             defaultIOExceptionHandler(e);
61             return null;
62         } finally {
63             handledJdwpRequest();
64         }
65     }
66     
67     /**
68      * @return Reads JDWP representation and returns new instance.
69      */

70     public static ClassObjectReferenceImpl read(MirrorImpl target, DataInputStream JavaDoc in) throws IOException JavaDoc {
71         VirtualMachineImpl vmImpl = target.virtualMachineImpl();
72         JdwpClassObjectID ID = new JdwpClassObjectID(vmImpl);
73         ID.read(in);
74         if (target.fVerboseWriter != null)
75             target.fVerboseWriter.println("classObjectReference", ID.value()); //$NON-NLS-1$
76

77         if (ID.isNull())
78             return null;
79
80         ClassObjectReferenceImpl mirror = new ClassObjectReferenceImpl(vmImpl, ID);
81         return mirror;
82     }
83 }
84
Popular Tags