Community
Participate
Working Groups
This is a FUP of bug 340029. Though the message has improved with bug 340029, It can be further improved. Compiling the following code: public enum X { A, B; private X() throws Exception { } } reports error at A, B. Ideally the error should be reported at X.
When you have no constructor, where would you report the error message ?
(In reply to comment #1) > When you have no constructor, where would you report the error message ? Then there is no exception. If enum values have a constructor which throws an exception, we do give a message at throws itself.
The way these errors are reported means that we would end up with two errors reported on the constructor declaration in this case. We could potentially get as many errors reported against the constructor declarations as the number of enum constants. Is this really what you want?
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.
I think the existing error reporting is fine. If multiple enum constructors are defined, individual enum constants have the option to invoke a non-throwing constructor and thus would be clean. Ergo: only when looking at an enum constant we can decide whether or not to raise the error. Example: //---- public enum X { A, B, C(1) ; private X() throws Exception { } private X(int i) {} } //---- ecj reports: ---------- 1. ERROR in /tmp/X.java (at line 2) A, B, ^ Unhandled exception type Exception ---------- 2. ERROR in /tmp/X.java (at line 2) A, B, ^ Unhandled exception type Exception ---------- 2 problems (2 errors) i.e., we remain silent about C(1), which is correct. If all enum constants use the 2nd constructor, the only complaint would be about an unused constructor.