Bug 9969

Summary: CodeFormatter: Bug when formatting try/catch Block
Product: [Eclipse Project] JDT Reporter: Marc Schier <mschier>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: raye
Version: 2.0   
Target Milestone: 2.0 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Marc Schier CLA 2002-02-17 18:34:49 EST
Stable Build 20020214:
In the following code the first catch (IllegalArgumentException) Block is 
always incorrectly formatted using the context menus Format as shown here:
    try
    {
      Object target = this.getClass().getDeclaredField(field).get(this);
      Class[] targetInterfaces = target.getClass().getInterfaces();
      DelegateHandler delegate = new DelegateHandler(target);
      Object proxy =
        Proxy.newProxyInstance(
          RoleProxy.class.getClassLoader(),
          targetInterfaces,
          delegate);
      return proxy;
    }
    catch (IllegalArgumentException e)
    
      {
    }
    catch (SecurityException e)
    {
    }
    catch (IllegalAccessException e)
    {
    }
    catch (NoSuchFieldException e)
    {
    }

Preferences Settings CodeFormatter (Status of checkboxes starting from the top):
NewLines:
Checked
Checked
Not checked
Checked
Checked
Line splitting: 80
Style:
Not checked
Checked / Not checked
2 spaces per tab


I cannot find a workaround. For me it's critical to use in production, but for 
others it will rather seem to be cosmetic.
Comment 1 Philipe Mulet CLA 2002-02-25 17:09:04 EST
Olivier - Can you please investigate a fix (if simple) ?
Comment 2 Olivier Thomann CLA 2002-02-25 17:49:08 EST
I reproduced the problem. I'll try to investigate a fix for it.
Comment 3 Olivier Thomann CLA 2002-02-27 18:18:49 EST
I am investigating a solution. The .class inside the code is responsible of the bad formatting. If 
you simply replace RoleProxy.class with RoleProxy, it works fine. The class literal seems to 
have a pretty bad side effect on the formatter.
Comment 4 Olivier Thomann CLA 2002-02-27 23:32:33 EST
Fixed and released in HEAD.
Comment 5 Olivier Thomann CLA 2002-03-05 09:37:57 EST
*** Bug 10749 has been marked as a duplicate of this bug. ***