Bug 9969 - CodeFormatter: Bug when formatting try/catch Block
Summary: CodeFormatter: Bug when formatting try/catch Block
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 10749 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-02-17 18:34 EST by Marc Schier CLA
Modified: 2002-03-05 09:37 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***