Open kgilpin opened 1 year ago
@apotterri should recording of getters and setters be disabled by default? In Ruby and Python we don't record field access and no one seems to care.
Methods that start with get
and set
are currently ignored. The problem with this is that they might not be getters and setters (since naming methods this way is just a convention).
I originally wrote this issue because some non-getter methods with names that started with get
were missing from an AppMap I was looking at. TBH, I don't remember whether that recording was from a user's app, or something I stumbled on.
Huh, actually looks like you wrote this issue. :) Maybe I meant to and forgot....
This behavior trips users up all the time: https://appmap-group.slack.com/archives/C03GZSGT41X/p1707477689987499?thread_ts=1707476013.248799&cid=C03GZSGT41X .
I think it actually might be better to not only make the recording configurable, but make the default be to record getters. The user could then disable recording if the getters blow up their recordings.
@kgilpin WDYT?
To me, a getter is not only the naming pattern, but also the implementation.
getUser() {
return this.user;
}
That sort of thing.
So, you think the agent should analyze the bytecode to see how complicated the method is? Do any of the other agents do that?
Well, in other languages this type of situation would usually be a field access rather than a function call, so it would not be recorded.
Hmmm, yeah, ok.
So, I looked at the bytecode for Lombok's @Getter
methods, Java record
s (available in Java 14+), and the code generated for a method like the one you wrote. They're all exactly the same three instructions, so it seems like it should be (relatively) straightforward to detect methods like those and ignore them.
I'd suggest that is*
and has*
methods aren't really a thing in Java. Maybe we can just drop detecting these?
The agent currently assumes that methods that start with
get.*
,is.*
, andhas.*
are getters of some sort, and so are not interesting enough to record.This assumption isn't valid in some applications, so it should possible to disable it.