Community
Participate
Working Groups
Build 20020129 - I had a legitimate compilation error in a field initializer in WorkbenchPage: private SelectionService selectionService = new SelectionService(); I had marked SelectionService as abstract, so this was expected. - I got an unreachable catch block in the following code in WorkbenchWindow: WorkbenchPage result = null; try { result = new WorkbenchPage(this, pageMem, input); pageList.add(result); pageListeners.firePageOpened(result); addShortcut(result); } catch (WorkbenchException e) { WorkbenchPlugin.log("Unable to restore perspective - constructor failed.");//$NON-NLS-1$ continue; } This was not expected. It looks to me that WorkbenchPage got a problem constructor due to the error with its field, but that it didn't declare any exceptions. Is this the intended behaviour?
The signature of the WorkbenchPage constructor is: public WorkbenchPage(WorkbenchWindow w, IMemento memento, IAdaptable input) throws WorkbenchException None of the other calls in the catch block above throw any checked exceptions.
I think this is due to the fact that the problem constructor created when an exception is reported in a field initializer doesn't contain the right thrown exceptions.
A simpler test case is: [package prs; import java.io.IOException; public class Test1 { String s = 3; Test1() throws IOException { } }] [package prs; import java.io.IOException; public class Test2 { public void foo() { try { Test1 t = new Test1(); System.out.println(); } catch(IOException e) { e.printStackTrace(); } } }] The problem is gone if you replace s = 3; with s = "3";. I will investigate this case. It seems that we might want to change the way we generate problem constructor and problem methods.
In order to get it, the second file has to be compiled using the first class from binary and not from source. If both classes are compiled in the same time, there is no problem.
In fact the fix is quite obvious. We never generated the exception attributes for the problem constructors, but we did for the problem methods. I added the following attributes for problem constructors: - exception - deprecated - synthetic I added a call to generateMethodInfoAttribute(MethodBinding). This will add the right attributes automatically. Fixed and released in HEAD.
Fixed.
Regression test added.