Community
Participate
Working Groups
Build Identifier: This would be useful to avoid the compile error you get after performing this refactor. Reproducible: Always
Example (convert "var" to field, initialize in field declaration): package xy; public class Try { void foo() throws ClassNotFoundException { String var= Class.forName("ABC").getName(); System.out.println(var); } } As the error on the field tells, a solution is to add the thrown exception to all constructors, e.g. add this: public Try() throws ClassNotFoundException { } So we should not block this option, since that's maybe exactly what the user wants. We could add a warning about this problem to the refactoring, but I wouldn't silently add the throws clauses or the constructor. But a Quick Fix that adds the throws clauses or the constructor would be nice.
Thanks for clarifying. I didn't think about being able to throw the exception from the constructors. Could the Quick Fix also happen when you convert the local variable to a field? I'm not sure if that would desirable or not, tbh.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.