Regression Bug?
I am not sure when this bug crept in - but its in idea823.
If I have a "static final" member variable, and I Generate Constructor, I quite correctly dont have that member listed in my "Choose Fields to Initialize by Constructor".
However, if I make it just a "final" member (ie not static) then it is incorrectly listed to be initialized by the constructor (when it cannot be because it is final).
-Nick
请先登录再写评论。
"Nick Minutello" <jiveadmin@jetbrains.com> wrote in message news:17059521.1055250435491.JavaMail.itn@is.intellij.net...
you can (are allowed) to initilize final members in constructor,
-m
addition to my previous response, here are java specs:
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#35962
Errr.. you are quite right :-S
I was actually thrown off by IntelliJ highlighting it as an error (because I had already initialised it on declaration).
So, the problem is in fact that IntelliJ lists it for initialisation when it has already been initialised...
-Nick
You can instatiate final members in a constructor.
If you have a static final member, you can do this:
You are right of course - but thats not the issue at hand.
(you are initialising it in a static block)
The problem remains that IntelliJ list a final (non static) member for initialisation in a constructor when it has already been initialised (you cant intialise it twice)
Should this be raised as a Bug?
-Nick
In case the final field has been initialized it should not be proposed by the generator. This is a bug, especially because it creates illegal code if you select that field (and immediately displays the error).