RFR: 8221503: vmTestbase/nsk/jdb/eval/eval001/eval001.java fails with: com.sun.jdi.InvalidTypeException: Can't assign double[][][] to double[][][]
Fairoz Matte
fmatte at openjdk.java.net
Wed Apr 28 08:01:52 UTC 2021
On Tue, 27 Apr 2021 23:47:26 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> findComponentType() logic is wrong. In findComponentType() method, We always get vm.classesByName() retruns empty list
>> list = vm.classesByName(parser.typeName());
>> We have "parser.typeName()" retruns " double[][]"
>> vm.classesByName("") is expecting the fully qualified name example "java.lang.Double"
>> This always returns empty list, resulting into ClassNotLoadedException as it assumes the Component class has not yet been loaded, hence the test case fails.
>>
>> There was a suggested fix from Egor Ushakov from JetBrains, I am proposing the same to get this fix. I have verified the patch with required testing it works fine.
>
> src/jdk.jdi/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java line 94:
>
>> 92: */
>> 93: Type findComponentType(String signature) throws ClassNotLoadedException {
>> 94: return findType(signature);
>
> Do we even need `findComponentType()` any more? Isn't `ReferenceTypeImpl.findType()` sufficient.
>
> The comment above `findComponentType()` is kind of explicit as to why it was needed. Are you sure none of that still applies, and there isn't some edge case that `findType()` is not covering?
Hi Chris,
Thanks for looking into this,
>Do we even need findComponentType() any more? Isn't ReferenceTypeImpl.findType() sufficient.
We still need findComponentType(),
Difference between findType() and findComponentType() is that, findComponentType() tries to get the list of ReferenceType from the "vm.classesByName". In case list is empty, it explicitly throws ClassNotLoadedException.
This exception check is required in validateAssignment(ValueContainer destination) call from ObjectReferenceImpl.java.
https://github.com/openjdk/jdk/blob/master/src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java#L579
diff --git a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
index e544c81ae3e..54deba43894 100644
--- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
+++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/ArrayTypeImpl.java
@@ -95,20 +95,13 @@ public class ArrayTypeImpl extends ReferenceTypeImpl
JNITypeParser sig = new JNITypeParser(signature);
if (sig.isReference()) {
// It's a reference type
- JNITypeParser parser = new JNITypeParser(componentSignature());
- List<ReferenceType> list = vm.classesByName(parser.typeName());
- Iterator<ReferenceType> iter = list.iterator();
- while (iter.hasNext()) {
- ReferenceType type = iter.next();
- ClassLoaderReference cl = type.classLoader();
- if ((cl == null)?
- (classLoader() == null) :
- (cl.equals(classLoader()))) {
- return type;
- }
+ try {
+ Type componentType = findType(componentSignature());
+ return componentType;
+ // Component class has not yet been loaded
+ } catch (ClassNotLoadedException ex) {
+ throw new ClassNotLoadedException(componentTypeName());
}
- // Component class has not yet been loaded
- throw new ClassNotLoadedException(componentTypeName());
} else {
// It's a primitive type
return vm.primitiveTypeMirror(sig.jdwpTag());
Thanks,
-------------
PR: https://git.openjdk.java.net/jdk/pull/3658
More information about the serviceability-dev
mailing list