Attribute parameters should be final

Issue #220 resolved
Jesper Öqvist created an issue

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)

  1. Jesper Öqvist 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.

  2. Jesper Öqvist reporter

    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.

  3. Log in to comment