jherkel commented on code in PR #9802:
URL: https://github.com/apache/netbeans/pull/9802#discussion_r4583687416
##########
java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/Bundle.properties:
##########
@@ -79,6 +79,7 @@ ERR_PullUp_MemberAlreadyExists=Member "{0}" already exists in
the target type.
ERR_CannotPullupDuplicateMembers=Cannot pull up two members with the same
signature.
ERR_PullupNonPublicToInterface=Member "{0}" is being moved to interface, but
is not public.
ERR_PullupStaticToInterface=Member "{0}" cannot be pulled up to interface, it
is static.
+ERR_PullupNonNotInitializedToInterface=Member "{0}" cannot be pulled up to
interface, it is not initialized.
Review Comment:
I see your point but IMHO refactoring should avoid cases when correct code
(from syntax point of view) is transformed to non valid code. It means:
1) incorrect syntax - this is not a big problem because you see it
immediately after compilation. Except a user can blame IDE that it allowed
this.
2) Side effects like change computation flow for example. More you can see
here https://assdfsdafasfa.github.io/RefactoringEnginesTesting). This one is
much more problematic because one might not realize it. Of course some of cases
in link are little bit artificial but for illustration what I mean.
So I cannot agree with your conclusion "this is not a bug" (your comment in
issue). But agree with "Suggesting to add an initializer avoids the syntax
error but the developer may miss the larger semantic difference it creates".
Maybe the user can be warned (like Member "value" is being moved to interface,
but is not public for non public field) if he tries to move non static/not
final field. Of course the user can still shoot himself in the foot if he tries
to move for example mutable List. But I don't think refactoring can protect
someone from doing mistakes in all cases.
But after your comment I realize :-) that my patch also breaks what I
mentioned above about compilation error . i.e
```
public interface I {
class C implements I {
boolean value = false;
public void aaa() {
value = true;
}
}
}
```
I will check what I can do with that but maybe partial fix is better than no
fix.
--
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