Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340955

Summary: Missing "throw" in AbstractChannel.setServiceProxy
Product: [Tools] TCF Reporter: Anton Leherbauer <aleherb+eclipse>
Component: CoreAssignee: Project Inbox <tcf.core-inbox>
Status: RESOLVED FIXED QA Contact: Eugene Tarassov <eugene>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 0.3   
Target Milestone: 0.4.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Insert "throw" keyword cdtdoug: iplog-

Description Anton Leherbauer CLA 2011-03-25 09:27:02 EDT
Created attachment 191907 [details]
Insert "throw" keyword

By accident I stumbled across this line in AbstractChannel.setServiceProxy():

        if (!notifying_channel_opened) new Error("setServiceProxe() can be called only from channel open call-back");

which is obviously missing the "throw" keyword.
Attached patch fixes this.
Comment 1 Eugene Tarassov CLA 2011-03-25 13:04:38 EDT
This is intentional.

From Java language specs:

11.2.1 Why Errors are Not Checked

Those unchecked exception classes which are the error classes (Error and its subclasses) are exempted from compile-time checking because they can occur at many points in the program and recovery from them is difficult or impossible. A Java program declaring such exceptions would be cluttered, pointlessly.


And I like this particular exception to be Error - to make recovery difficult or impossible. The intend is to kill a client immediately if it does not honor API contract.
Comment 2 Anton Leherbauer CLA 2011-03-28 02:51:15 EDT
I think there is a misunderstanding.  I don't suggest to add a throws clause to the method declaration.  Sorry if I was not clear.

The issue is that the line

  if (!notifying_channel_opened) new Error(...);

is obsolete without "throw" before "new", i.e. it should be

  if (!notifying_channel_opened) throw new Error(...);

That's all.
Comment 3 Eugene Tarassov CLA 2011-03-28 11:56:44 EDT
Of course, you are absolutely right. My fault - I misunderstood you.
Committed the patch.
Thanks!