1/*
2 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.jdi;
27
28/**
29 * The mirror for a value in the target VM.
30 * This interface is the root of a
31 * value hierarchy encompassing primitive values and object values.
32 * <P>
33 * Some examples of where values may be accessed:
34 * <BLOCKQUOTE><TABLE><CAPTION style="display:none">layout</CAPTION>
35 * <TR>
36 *   <TD>{@link ObjectReference#getValue(com.sun.jdi.Field)
37 *                 ObjectReference.getValue(Field)}
38 *   <TD>- value of a field
39 * <TR>
40 *   <TD>{@link StackFrame#getValue(com.sun.jdi.LocalVariable)
41 *                 StackFrame.getValue(LocalVariable)}
42 *   <TD>- value of a variable
43 * <TR>
44 *   <TD>{@link VirtualMachine#mirrorOf(double)
45 *                 VirtualMachine.mirrorOf(double)}
46 *   <TD>- created in the target VM by the JDI client
47 * <TR>
48 *   <TD>{@link com.sun.jdi.event.ModificationWatchpointEvent#valueToBe()
49 *                 ModificationWatchpointEvent.valueToBe()}
50 *   <TD>- returned with an event
51 * </TABLE></BLOCKQUOTE>
52 * <P>
53 * The following table illustrates which subinterfaces of Value
54 * are used to mirror values in the target VM --
55 * <TABLE BORDER="1">
56 * <CAPTION style="display:none">Maps each kind of value to a mirrored
57 *  instance of a subinterface of Value</CAPTION>
58 * <TR style="background-color:#EEEEFF">
59 *   <TH id="primval" colspan=4>Subinterfaces of {@link PrimitiveValue}</TH>
60 * <TR style="background-color:#EEEEFF">
61 *   <TH id="kind"     style="text-align:left">Kind of value</TH>
62 *   <TH id="example"  style="text-align:left">For example -<br>expression in target</TH>
63 *   <TH id="mirrored" style="text-align:left">Is mirrored as an<br>instance of</TH>
64 *   <TH id="type"     style="text-align:left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
65 * <TR>
66 *   <TD headers="primval kind">     a boolean</TD>
67 *   <TD headers="primval example">  {@code true}</TD>
68 *   <TD headers="primval mirrored"> {@link BooleanValue}</TD>
69 *   <TD headers="primval type">     {@link BooleanType}</TD>
70 * <TR>
71 *   <TD headers="primval kind">     a byte</TD>
72 *   <TD headers="primval example">  {@code (byte)4}</TD>
73 *   <TD headers="primval mirrored"> {@link ByteValue}</TD>
74 *   <TD headers="primval type">     {@link ByteType}</TD>
75 * <TR>
76 *   <TD headers="primval kind">     a char</TD>
77 *   <TD headers="primval example">  {@code 'a'}</TD>
78 *   <TD headers="primval mirrored"> {@link CharValue}</TD>
79 *   <TD headers="primval type">     {@link CharType}</TD>
80 * <TR>
81 *   <TD headers="primval kind">     a double</TD>
82 *   <TD headers="primval example">  {@code 3.1415926}</TD>
83 *   <TD headers="primval mirrored"> {@link DoubleValue}</TD>
84 *   <TD headers="primval type">     {@link DoubleType}</TD>
85 * <TR>
86 *   <TD headers="primval kind">     a float</TD>
87 *   <TD headers="primval example">  {@code 2.5f}</TD>
88 *   <TD headers="primval mirrored"> {@link FloatValue}</TD>
89 *   <TD headers="primval type">     {@link FloatType}</TD>
90 * <TR>
91 *   <TD headers="primval kind">     an int</TD>
92 *   <TD headers="primval example">  {@code 22}</TD>
93 *   <TD headers="primval mirrored"> {@link IntegerValue}</TD>
94 *   <TD headers="primval type">     {@link IntegerType}</TD>
95 * <TR>
96 *   <TD headers="primval kind">     a long</TD>
97 *   <TD headers="primval example">  {@code 1024L}</TD>
98 *   <TD headers="primval mirrored"> {@link LongValue}</TD>
99 *   <TD headers="primval type">     {@link LongType}</TD>
100 * <TR>
101 *   <TD headers="primval kind">     a short</TD>
102 *   <TD headers="primval example">  {@code (short)12}</TD>
103 *   <TD headers="primval mirrored"> {@link ShortValue}</TD>
104 *   <TD headers="primval type">     {@link ShortType}</TD>
105 * <TR>
106 *   <TD headers="primval kind">     a void</TD>
107 *   <TD headers="primval example">  </TD>
108 *   <TD headers="primval mirrored"> {@link VoidValue}</TD>
109 *   <TD headers="primval type">     {@link VoidType}</TD>
110 * <TR style="background-color:#EEEEFF">
111 *   <TH id="objref" colspan=4>Subinterfaces of {@link ObjectReference}</TH>
112 * <TR style="background-color:#EEEEFF">
113 *   <TH id="kind2"     style="text-align:left">Kind of value</TH>
114 *   <TH id="example2"  style="text-align:left">For example -<br>expression in target</TH>
115 *   <TH id="mirrored2" style="text-align:left">Is mirrored as an<br>instance of</TH>
116 *   <TH id="type2"     style="text-align:left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
117 * <TR>
118 *   <TD headers="objref kind2">     a class instance</TD>
119 *   <TD headers="objref example2">  {@code this}</TD>
120 *   <TD headers="objref mirrored2"> {@link ObjectReference}</TD>
121 *   <TD headers="objref type2">     {@link ClassType}</TD>
122 * <TR>
123 *   <TD headers="objref kind2">     an array</TD>
124 *   <TD headers="objref example2">  {@code new int[5]}</TD>
125 *   <TD headers="objref mirrored2"> {@link ArrayReference}</TD>
126 *   <TD headers="objref type2">     {@link ArrayType}</TD>
127 * <TR>
128 *   <TD headers="objref kind2">     a string</TD>
129 *   <TD headers="objref example2">  {@code "hello"}</TD>
130 *   <TD headers="objref mirrored2"> {@link StringReference}</TD>
131 *   <TD headers="objref type2">     {@link ClassType}</TD>
132 * <TR>
133 *   <TD headers="objref kind2">     a thread</TD>
134 *   <TD headers="objref example2">  {@code Thread.currentThread()}</TD>
135 *   <TD headers="objref mirrored2"> {@link ThreadReference}</TD>
136 *   <TD headers="objref type2">     {@link ClassType}</TD>
137 * <TR>
138 *   <TD headers="objref kind2">     a thread group</TD>
139 *   <TD headers="objref example2">  {@code Thread.currentThread()}<br>&nbsp;&nbsp;{@code .getThreadGroup()}</TD>
140 *   <TD headers="objref mirrored2"> {@link ThreadGroupReference}</TD>
141 *   <TD headers="objref type2">     {@link ClassType}</TD>
142 * <TR>
143 *   <TD headers="objref kind2">     a {@code java.lang.Class}<br>instance</TD>
144 *   <TD headers="objref example2">  {@code this.getClass()}</TD>
145 *   <TD headers="objref mirrored2"> {@link ClassObjectReference}</TD>
146 *   <TD headers="objref type2">     {@link ClassType}</TD>
147 * <TR>
148 *   <TD headers="objref kind2">     a class loader</TD>
149 *   <TD headers="objref example2">  {@code this.getClass()}<br>&nbsp;&nbsp;{@code .getClassLoader()}</TD>
150 *   <TD headers="objref mirrored2"> {@link ClassLoaderReference}</TD>
151 *   <TD headers="objref type2">     {@link ClassType}</TD>
152 * <TR style="background-color:#EEEEFF">
153 *   <TH id="other" colspan=4>Other</TH>
154 * <TR style="background-color:#EEEEFF">
155 *   <TD id="kind3"     style="text-align:left">Kind of value</TD>
156 *   <TD id="example3"  style="text-align:left">For example -<br>expression in target</TD>
157 *   <TD id="mirrored3" style="text-align:left">Is mirrored as</TD>
158 *   <TD id="type3"     style="text-align:left">{@link Type} of value</TD>
159 * <TR>
160 *   <TD headers="other kind3">     null</TD>
161 *   <TD headers="other example3">  {@code null}</TD>
162 *   <TD headers="other mirrored3"> {@code null}</TD>
163 *   <TD headers="other type3">     n/a</TD>
164 * </TABLE>
165 *
166 * @author Robert Field
167 * @author Gordon Hirsch
168 * @author James McIlree
169 * @since  1.3
170 */
171
172public interface Value extends Mirror {
173    /**
174     * Returns the run-time type of this value.
175     *
176     * @see Type
177     * @return a {@link Type} which mirrors the value's type in the
178     * target VM.
179     */
180    Type type();
181}
182