-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.1, 1.4.0
-
generic
-
generic
Name: elR10090 Date: 01/11/2001
The specification for the method Field.type() given below
is undefined for array fields:
public Type type() throws ClassNotLoadedException
Returns the type of the this Field. For primitive fields, an
appropriate PrimitiveType is always returned. For object fields,
the appropriate ReferenceType is returned if it has been loaded
through the enclosing type's (that is, the type returned by
TypeComponent#enclosingType) class loader.
1. Specification implicitly implies that method Field.type() throws
ClassNotLoadedException for each field of array type.
According to The Java Virtual Machine Specification Second
Edition (5.3):
'Array classes do not have an external binary representation;
they are created by the Java virtual machine rather than by a
class loader.'
Therefore, ReferenceType is not loaded by a class loader if it
is an array. This implies that method Field.type() must throw
ClassNotLoadedException for each field of array of primitive
or reference type.
If ClassNotLoadedException is not thrown on any array field, returned
Type is still undefined.
2. TypeComponent#enclosingType is undefined in specification.
4399657: JDI: Field.type() spec refers to undefined
TypeComponent#enclosingType
So both enclosing type and enclosing type's class loader are undefined.
This problem is concerned not only for fields of array types, but for
all reference type fields.
3. Term 'apropriate ReferenceType' is not clear, because in some cases
ReferenceType logicaly could be one of several Type's.
a). If a field is an array of a primitive type (boolean), apropriate
ReferenceType is undefined. It could be java.lang.Boolean, or
boolean[].class, or Boolean[].class.
b). If a field is an array of a reference type (T), apropriate
ReferenceType is not defined also. It could be T, or T[].class.
So, I believe that specification for Field.type() needs clarification --
especially in the case when the field is an array. Probably, it would be
more convenient to specify this case separately from other simpler cases
when the field is scalar of primitive or reference type.
======================================================================
- duplicates
-
JDK-4452253 JDI spec: spec for core interfaces Type and Value is misleading and very thin
-
- Closed
-
- relates to
-
JDK-4399657 JDI: Field.type() spec refers to undefined TypeComponent#enclosingType
-
- Closed
-