Closed mbien closed 2 months ago
In addition to your changes to the TreeFactory
, you have to IMHO change also the org.netbeans.modules.java.source.pretty.VeryPretty.visitClassDef(...)
to generate records properly.
In addition to your changes to the
TreeFactory
, you have to IMHO change also theorg.netbeans.modules.java.source.pretty.VeryPretty.visitClassDef(...)
to generate records properly.
@dbalek thanks for the hint! I believe this was the missing piece why I could not figure out why it kept generating final classes. I will give this another attempt.
this would be a bit more work, due to the fact that VeryPretty
would need access to the members while writing the record header, those are visited later however.
I think we could get this into NB 23 so that is generates the record as final class instead of throwing an exception. It can be still properly implemented later.
generates a final class as workaround instead of throwing an exception
fixes https://github.com/apache/netbeans/issues/7570 (see for reproducer)
So i tried to implement this properly at first, but there is some magic behind the scenes in the javac impl which kept generating final classes even though everything seemed to be correct. I had this in
TreeFactory
which works analog toEnum
:since this had no effect, I decided to change this back to a minimal impact quickfix which simply calls
make.Class
right away, without introducing public API changes. This would also have to be updated to extendAbstractElementVisitor14
as the todo indicates.Edit: I might give this a second attempt to implement it properly