kotlinx-lincheck icon indicating copy to clipboard operation
kotlinx-lincheck copied to clipboard

Try to improve caller (a.k.a. owner) names via tracking local variables

Open diffitask opened this issue 10 months ago • 1 comments

When calling Object#1.foo(), we would like to make the call more intuitive:

  • in case this equals Object#1, we drop the caller name and show only foo()
  • in case there is a local variable referencing Object#1, we would like to show the local variable name, thus, showing variableName.foo()
  • in case there exists a field of this that references Object#1, we would like to replace Object#1 with the field name, thus, showing fieldName.foo()
  • otherwise, we show Object#1.foo()

One important note is that objects referenced by only static final fields are presented as the corresponding field names. E.g., when manipulating the BROKEN object below, it should shown in the trace as BROKEN, not smth like Object#25.

class Foo {
  private static final BROKEN = new Object();
}

Let's analyze how good the suggested semantics is and try to achieve the best.

Related task: Track local variables #507

diffitask avatar Feb 05 '25 22:02 diffitask

Consider printing varName[ObjectClass#<id>] for shared objects, making it easier to track shared objects

ndkoval avatar Mar 04 '25 10:03 ndkoval

@eupp, should we close this issue, or is there something that should be fixed before that?

ndkoval avatar Apr 01 '25 07:04 ndkoval

There are a lot of various problems and design questions around this feature, let's discuss on a meeting. We will probably need to split it into sub-tasks.

eupp avatar Apr 01 '25 10:04 eupp