com.jrockit.memleak
Interface IValue

All Known Subinterfaces:
IFieldValue
All Known Implementing Classes:
PrimitiveFieldValue, PrimitiveValue, ReferenceFieldValue, ReferenceValue

public interface IValue

Represents a value - either a primitive value or a reference. Used for field values and array elements.


Field Summary
static IValue[] EMPTY_ARRAY
          An empty IValue array.
 
Method Summary
<T> T
get(java.lang.Class<T> type)
          Retrieve the actual primitive wrapper or object representation held by this instance if it can be assigned to a variable declared as being of class type, as per isAssignableTo(Class).
 java.lang.Object getPrimitiveValue()
          Returns the value of the primitive field.
 IObjectInfo getReference()
          Returns the reference for this field.
 boolean isAssignableTo(java.lang.Class<?> type)
          Check if the actual primitive wrapper or object representation held by this instance and returned by get() can be assigned to a variable declared as being of class type, with one additional requirement.
 boolean isPrimitive()
           
 

Field Detail

EMPTY_ARRAY

static final IValue[] EMPTY_ARRAY
An empty IValue array.

Method Detail

isPrimitive

boolean isPrimitive()
Returns:
true if this field is a primitive type.

getPrimitiveValue

java.lang.Object getPrimitiveValue()
Returns the value of the primitive field. The returned Object will be an instance of one of the primitive wrapper classes or null if isPrimitive() returns false.

Returns:
value of the primitive field

getReference

IObjectInfo getReference()
Returns the reference for this field. Will be null if isPrimitive() returns true.

Returns:
reference in the field

isAssignableTo

boolean isAssignableTo(java.lang.Class<?> type)
Check if the actual primitive wrapper or object representation held by this instance and returned by get() can be assigned to a variable declared as being of class type, with one additional requirement. If type is a primitive wrapper class, Number.class, or Serializable.class, the value must also be non-null. This is to facilitate safe unboxing into primitives.

This method is mainly usable for filters to differentiate between different kinds of primitives, as well as between primitives, references or arrays.

The full list of supported type arguments, and the corresponding values from the actual heap they correspond to, is as follows:

The primitive wrapper classes (Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class) Matches their corresponding primitive
Number.class Matches byte, short, int, long, float, double
Serializable.class Matches all primitives
Object.class Matches all primitives and all references
IObjectInfo.class Matches all references (including null)
IArrayInfo.class Matches all references that are arrays or null

Parameters:
type - one of the classes above
Returns:
true iff the value can be assigned to type and, if type is a primitive wrapper class, be unboxed.

get

<T> T get(java.lang.Class<T> type)
Retrieve the actual primitive wrapper or object representation held by this instance if it can be assigned to a variable declared as being of class type, as per isAssignableTo(Class). Otherwise, null is returned. Note that null may be returned even if isAssignableTo(Class) with the same type argument returns true, unless type is a primitive wrapper class, Number.class, or Serializable.class. This is to facilitate safe unboxing into primitives.

The full list of supported type arguments, and the corresponding values from the actual heap they correspond to, is as follows:

The primitive wrapper classes (Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class) Matches their corresponding primitive
Number.class Matches byte, short, int, long, float, double
Serializable.class Matches all primitives
Object.class Matches all primitives and all references
IObjectInfo.class Matches all references (including null)
IArrayInfo.class Matches all references that are arrays or null

Type Parameters:
T - implicit
Parameters:
type - one of the classes above, never null
Returns:
an instance of T (that is, a primitive wrapper or an IObjectInfo), or null


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.