Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/jdi/PrimitiveValueImpl.java @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2002-2003 Sun Microsystems, Inc. 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. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 package sun.jvm.hotspot.jdi; | |
26 | |
27 import com.sun.jdi.*; | |
28 | |
29 public abstract class PrimitiveValueImpl extends ValueImpl | |
30 implements PrimitiveValue { | |
31 | |
32 PrimitiveValueImpl(VirtualMachine aVm) { | |
33 super(aVm); | |
34 } | |
35 | |
36 abstract public boolean booleanValue(); | |
37 abstract public byte byteValue(); | |
38 abstract public char charValue(); | |
39 abstract public short shortValue(); | |
40 abstract public int intValue(); | |
41 abstract public long longValue(); | |
42 abstract public float floatValue(); | |
43 abstract public double doubleValue(); | |
44 | |
45 /* | |
46 * The checked versions of the value accessors throw | |
47 * InvalidTypeException if the required conversion is | |
48 * narrowing and would result in the loss of information | |
49 * (either magnitude or precision). | |
50 * | |
51 * Default implementations here do no checking; subclasses | |
52 * override as necessary to do the proper checking. | |
53 */ | |
54 byte checkedByteValue() throws InvalidTypeException { | |
55 return byteValue(); | |
56 } | |
57 char checkedCharValue() throws InvalidTypeException { | |
58 return charValue(); | |
59 } | |
60 short checkedShortValue() throws InvalidTypeException { | |
61 return shortValue(); | |
62 } | |
63 int checkedIntValue() throws InvalidTypeException { | |
64 return intValue(); | |
65 } | |
66 long checkedLongValue() throws InvalidTypeException { | |
67 return longValue(); | |
68 } | |
69 float checkedFloatValue() throws InvalidTypeException { | |
70 return floatValue(); | |
71 } | |
72 | |
73 final boolean checkedBooleanValue() throws InvalidTypeException { | |
74 /* | |
75 * Always disallow a conversion to boolean from any other | |
76 * primitive | |
77 */ | |
78 if (this instanceof BooleanValue) { | |
79 return booleanValue(); | |
80 } else { | |
81 throw new InvalidTypeException("Can't convert non-boolean value to boolean"); | |
82 } | |
83 } | |
84 | |
85 final double checkedDoubleValue() throws InvalidTypeException { | |
86 /* | |
87 * Can't overflow by converting to double, so this method | |
88 * is never overridden | |
89 */ | |
90 return doubleValue(); | |
91 } | |
92 | |
93 } |