lahodaj commented on PR #9800:
URL: https://github.com/apache/netbeans/pull/9800#issuecomment-6853642767
First, thank you for looking into this!
Regarding the class -> record conversion, unless I misread the code, it will
convert classes with mutable fields, but it won't convert classes that have any
explicit constructor. To me, personally, it feels like a class that is
conceptually very far from a record: it basically relies on being constructed
"empty" and then the fields are set later. Which cannot be done with records.
E.g., I didn't try, but I think the code will convert this:
```
class Mutable {
private int i;
public int getI() { return i; }
public void setI() { this.i = i; }
}
```
to me, this class is very unsuitable to become a record.
OTOH, for classes that would be very suitable to become records, like:
```
class RecordLike {
private final int i;
public RecordLike(int i) {
this.i = i;
}
public int i() {
return i;
}
//possibly equals, hashCode, toString
}
```
will not be converted, as they have the constructor and accessor (despite
neither the constructor, nor the accessor do anything funny).
Do I miss something?
For the record->class conversion, I think I would second to Jaroslav's
sentiment around `equals`/`hashCode`/`toString` - those methods are part of the
backbone of records. I think doing the conversion and ignore those is not ideal.
(I think I am mostly fine with ignoring the serialization aspect - in the
worst case, denying the conversion or warning the user serialization may change
for serializable records. I hope truly (binary) serializable records are/will
be rare, and we can't detect other kinds of "serialization" anyway.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists