Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362751 - NullValueException not thrown on setMethod
Summary: NullValueException not thrown on setMethod
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Huang Ji Yong CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-02 23:14 EDT by fahua jin CLA
Modified: 2017-02-23 14:18 EST (History)
4 users (show)

See Also:


Attachments
The sample EGL file. (2.46 KB, application/octet-stream)
2011-11-02 23:16 EDT, fahua jin CLA
no flags Details
Patch to resolve the defect (1.02 KB, patch)
2011-11-14 21:52 EST, Huang Ji Yong CLA
lasher: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description fahua jin CLA 2011-11-02 23:14:56 EDT
Build Identifier: 0.7.0.v201111012101

1) Import the H3.egl and opened with VE.
2) Click in the input field, and then click anywhere out of the input field. The 'null' is displayed in the error label, which is different from the RBD.

Reproducible: Always
Comment 1 fahua jin CLA 2011-11-02 23:16:45 EDT
Created attachment 206378 [details]
The sample EGL file.
Comment 2 Justin Spadea CLA 2011-11-03 11:56:43 EDT
This is a JSGen problem. What MVC is doing is there is a string? field with a null value. It gets assigned to the text field of the widget. The widget's text field is not nullable. It has a setMethod defined for setting the value, and the string parameter in the set method is also not nullable. The generated code is passing in the null value instead of a blank string. If you do an assignment of a nullable string to non-nullable string without a setMethod, it does properly assign a blank value.

Testcase:

    t textlabel{};
    function test()
    	s string?;
    	t.text = s;
    end

Generated code:
    var s = null;
    this.t.setText(s);
Comment 3 Justin Spadea CLA 2011-11-03 16:19:11 EDT
We discussed this today, and a NullValueException should occur here instead of converting null to blank. If you do an assignment of a null string to a non-nullable string field, that too should throw a NullValueException.

I've updated the MVC code to check for null before updating the error label, but I'm leaving this open because JSGen is not yet throwing the expected exception. I didn't verify this, but I'm told JavaGen already works this way.
Comment 4 Huang Ji Yong CLA 2011-11-14 05:11:15 EST
Hi Justin,
This test case is about string type.
How about assign a null value to an unnullable int type or other types?
For example:
a int?
b int = 5;
b = a;

Does this case throw a NullValueException?
Comment 5 Justin Spadea CLA 2011-11-14 15:09:33 EST
Yes, this holds true for all types. So when a nullable type is assigned to a non-nullable type, it should be wrapped in egl.checkNull().
Comment 6 Huang Ji Yong CLA 2011-11-14 21:52:55 EST
Created attachment 207000 [details]
Patch to resolve the defect
Comment 7 Huang Ji Yong CLA 2011-11-15 21:01:43 EST
When assigning a Null value to a non-nullable type will throw NullValueException now.
Comment 8 fahua jin CLA 2011-11-16 22:19:55 EST
Verified in 0.7.0.v201111160901.