Project

General

Profile

Bug #11876

Various issues with oo.reflect.Property

Added by Alexandru Lungu 7 days ago. Updated 6 days ago.

Status:
WIP
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#1 Updated by Alexandru Lungu 7 days ago

  • Subject changed from Running LegacyClass.getProperties on a class without a super-class yield NPE to Running LegacyClass.getProperties on aa legacy interface yields NPE

When running a suite of unit tests I encountered a NPE with the following trace.

│  │  │  │  │                   at com.goldencode.p2j.util.ObjectOps.legacyNameWorker(ObjectOps.java:4833)
│  │  │  │  │                   at com.goldencode.p2j.util.ObjectOps.getLegacyName(ObjectOps.java:4419)
│  │  │  │  │                   at com.goldencode.p2j.oo.lang.LegacyClass.getSuperClass(LegacyClass.java:339)
│  │  │  │  │                   at com.goldencode.p2j.oo.reflect.Property.<init>(Property.java:129)
│  │  │  │  │                   at com.goldencode.p2j.oo.lang.LegacyClass._getProperties(LegacyClass.java:1842)
│  │  │  │  │                   at com.goldencode.p2j.oo.lang.LegacyClass.getProperties(LegacyClass.java:1374)
│  │  │  │  │                   at com.goldencode.p2j.oo.lang.LegacyClass.getProperties(LegacyClass.java:1360)

From my understanding, Property requires:

object superClass = getOriginatingClass().ref().getSuperClass();

which in turn calls

return getLegacyClass(ObjectOps.getLegacyName((Class) cls.getSuperclass()));

The issue is that getSuperClass() is docummented as:

If this Class represents either the Object class, an interface, a primitive type, or void, then null is returned.

The issue is that the target legacy class is in fact an interface.

#2 Updated by Alexandru Lungu 7 days ago

  • Assignee set to Alexandru Lungu
  • Status changed from New to WIP
  • reviewer Eduard Soltan added

This was a bug introduced once the support for Property was added and it was not present in 7156e (last time I managed to make the test suite pass).
I added Eduard as a watcher.

#4 Updated by Alexandru Lungu 7 days ago

  • Subject changed from Running LegacyClass.getProperties on aa legacy interface yields NPE to Various issues with oo.reflect.Property

Quickly fixing this, I stumble across:

│  │  │  │  │                   at com.goldencode.p2j.oo.reflect.Property.setter(Property.java:443)
│  │  │  │  │                   at com.goldencode.p2j.oo.lang.LegacyClass.getProperty(LegacyClass.java:1415)
│  │  │  │  │                   at com.goldencode.p2j.oo.lang.LegacyClass.getProperty(LegacyClass.java:1397)

I will have this in scope.

#5 Updated by Alexandru Lungu 7 days ago

There is also another issue with getting the value of a property using reflection. Using LegacyClass.getPropertyValue will invoke the getter, but if the getter yields an error, the error is swallowed by catch (InvocationTargetException exc) and ret remains null. This null escapes runtime and causes a NPE on a character.valueOf call.

I am not sure if the error from the getter in the application I test is a problem, but FWD runtime certainly doesn't manage well in this scenario. Just to record, the getter returns a dereference on an empty buffer (i.e. buf::field, but avail(buf) is false).

#6 Updated by Alexandru Lungu 6 days ago

For the record, I have fixes for the issues above. I am now working on:

│  │  │  │  │     caught: org.opentest4j.AssertionFailedError: Expected no errors upon DataObject serialization. (TEST-001) : ** Array subscript 1 is out of range. The indeterminate extent is fixed to a dimension of -2. (11388)
│  │  │  │  │               Stack trace:com.goldencode.p2j.oo.lang.SysError.newInstance at line 151 (SysError.java)
│  │  │  │  │               com.goldencode.p2j.oo.lang.LegacyClass.getGetterInternalEntry at line 2308 (LegacyClass.java)
│  │  │  │  │               com.goldencode.p2j.oo.lang.LegacyClass.getPropertyValueImpl at line 2403 (LegacyClass.java)
│  │  │  │  │               com.goldencode.p2j.oo.lang.LegacyClass.getPropertyValue at line 264 (LegacyClass.java)

Also available in: Atom PDF