Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Exception parsing a form composite whose constructor contains additional parameters.
Exception parsing a form composite whose constructor contains additional parameters. [message #760526] Fri, 02 December 2011 17:15 Go to next message
Steve Goldberg is currently offline Steve Goldberg
Messages: 2
Registered: December 2011
Junior Member
Greetings, I'm reporting this bug here so it can be easily accessible to anyone searching for a similar problem.

Description:

If I create or use a form composite whose constructor contains additional parameters before the 'parent' parameter, I get the following exception:

Exception during 'super' constructor evaluation
An exception happened during evaluation of constructor Composite(Composite,int) using arguments {<null>,0}.

java.lang.IllegalArgumentException: Argument cannot be null
at java.lang.Throwable.<init>(Throwable.java:67)
at org.eclipse.swt.SWT.error(SWT.java:3742)
at org.eclipse.swt.SWT.error(SWT.java:3695)
at org.eclipse.swt.SWT.error(SWT.java:3666)
at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
at org.eclipse.swt.widgets.Widget.checkParent(Widget.java:273)
at org.eclipse.swt.widgets.Widget.<init>(Widget.java:146)
at org.eclipse.swt.widgets.Control.<init>(Control.java:101)
at org.eclipse.swt.widgets.Composite$$EnhancerByCGLIB$$9db19d9f.<init>(<generated>)

Additional information in the attached report (ZIP file).

Note that this does *not* happen if I move the additional parameters to the end of the parameter list.


Steps to reproduce:

1. Create a new form composite (WindowBuilder > SWT Designer > Forms > Composite). Observe the constructor contains the following parameters:

Composite parent, int style

2. Modify the constructor by adding an integer parameter before the parent and style parameters. It should look like this:

int someValue, Composite parent, int style

3. Attempt to switch to design mode. The error occurs.
4. Revise the method so that the new parameter is at the end, like this:

Composite parent, int style, int someValue

5. Attempt to switch to design mode. The design view appears correctly.

Additional details

Product name: WindowBuilder
Edition: 1.1.0
Eclipse version: 3.4
OS Name/Version: Windows XP
Priority: Standard
Workaround: Yes (revise the order of the parameters)
Eclipse Log Attached: Yes (see ZIP file)

-----
Steve Goldberg
Advisory Software Developer, IBM
Re: Exception parsing a form composite whose constructor contains additional parameters. [message #761133 is a reply to message #760526] Tue, 06 December 2011 00:13 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric Clayberg
Messages: 862
Registered: July 2009
Location: Boston, MA
Senior Member
First, I would suggest updating to the latest 1.2.0 build of WB (rather than 1.1.0) and Eclipse 3.7/3.8 (rather than 3.4 which we no longer support). I tried an example based on what you described, and it worked.

Second, we don't really consider this to be a bug in WB since WB is designed to expect custom SWT widgets to follow normal SWT conventions (at best this would be a lack of a feature). The "parent" and "style" arguments should always be the first and second arguments in an SWT constructor. Any additional arguments should appear after those and (ideally) be optional (e.g., you should also always include the standard default two-arg constructor when defining a custom SWT widget).

You can, of course, define your class any way that you want, but you are, in effect, defining your own API that does not conform to normal SWT conventions. In general, you could always add support and teach WB about your new type of component, but that is a non-trivial exercise. In this case, you don't need to since WB appears to handle this non-standard case just fine as long as you are using the latest 1.2.0 build.

WB's expectations/requirements for custom widgets are described in the WB FAQ.
Re: Exception parsing a form composite whose constructor contains additional parameters. [message #761554 is a reply to message #761133] Tue, 06 December 2011 16:42 Go to previous messageGo to next message
Steve Goldberg is currently offline Steve Goldberg
Messages: 2
Registered: December 2011
Junior Member
Hello Eric,

Thank you for your reply. I agree with most of your points.

I will look into upgrading Eclipse in the near future. Currently, our team cannot upgrade due to development restrictions that limit what version we can use.

I understand that 3.4 is no longer supported. Since I have a workaround, I can wait until we are able to upgrade Eclipse and get a more recent version of WB.

I reviewed the FAQ's list of limitations at your suggestion. In our case, we need to pass additional information to the constructor, but it wasn't a problem to change the order of the arguments so the parent and style were first.

The one thing I disagree with is the classification of this issue as a feature. If a constructor with arguments preceding the parent is not supposed to work, then the bug is an unclear error message. An error message should be shown to indicate that the constructor does not have the expected arguments. This is the message I saw, which does not indicate that the constructor itself is incorrect:

!MESSAGE Designer [1.0.0.r34x201106081531.201112011556]: 313 (Exception during 'super' constructor evaluation). Composite(Composite,int) {<null>,0} java.lang.IllegalArgumentException: Argument cannot be null

Since this appears to have been fixed in more recent versions, this is only a bug in the WB version for 3.4.

Again, thank you for taking the time to respond.

-----

Steve Goldberg
Advisory Software Developer, IBM
Re: Exception parsing a form composite whose constructor contains additional parameters. [message #761631 is a reply to message #761554] Tue, 06 December 2011 19:15 Go to previous message
Eric Clayberg is currently offline Eric Clayberg
Messages: 862
Registered: July 2009
Location: Boston, MA
Senior Member
I disagree that this was a bug. This was not a case of an unknown, unexpected exception. The exception that was triggered was one of a number of very specific, known exceptions (#313 in this case) that the tool triggers intentionally when faced with a bad, broken, or non-standard components. There are a number of cases that could end up at this specific exception, and we never felt the need to split it into more finer grained cases with more explicit messages.

The feature that was added was to make the tool a bit more lenient when faced with a specific class of non-standard components.
Previous Topic:how to increase height of windowbuilder's editor?
Next Topic:Binding through several instances?
Goto Forum:
  


Current Time: Wed Oct 01 04:22:38 GMT 2014

Powered by FUDForum. Page generated in 0.01644 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software