- edited description
Attribute parameters should be final
JastAdd2 2.1.11-32-geb021ae
Generated code for attributes has parameters declared as non-final. It seems like the parameters should be final. Non-final attribute parameters prevents using the parameter values in nested classes used in the attribute, with some Java versions.
Comments (5)
-
reporter -
reporter - edited description
-
reporter - changed status to resolved
Fixed by commit 0eb07ff
-
reporter - changed status to open
I have reverted the commit fixing this because JModelica has some code using parameters as local variables. Since this is a non-backward compatible change which requires a bit more work to conform to than I had expected, it might be better to save the change to a later release.
-
reporter - changed status to resolved
I have changed my mind about this issue and think that it's best not to make attribute parameters final. The only case where it would be useful is when passing the parameters to an anonymous class inside the attribute code. This is such an unusual case and there is a simple workaround - just copy the parameters to final variables.
Making attribute parameters final would break a few existing attributes, for little benefit.
Closing this now since I seemed to be the only one who cared about it, and I no longer do.
- Log in to comment