Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359168

Summary: A null value is added to array when determine if it is null
Product: z_Archived Reporter: Huang Ji Yong <hjiyong>
Component: EDTAssignee: Project Inbox <edt.javagen-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: greer, jeffdouglas
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Huang Ji Yong CLA 2011-09-27 22:52:08 EDT
This defect only happens when the && is used such as
if (options != null && options.getSize() > 0)

Testcase
---------
package client;

// RUI Handler

//
//

handler testArrayNull type RUIhandler{onConstructionFunction = start, cssFile = "css/testBugs.css", title = "testArrayNull"}

    options String[] = ["coffee", "tea", "sugar"];

    function start()
    	if (options != null && options.getSize() > 0)
//    	if (options != null)
			printOptions(options);
		end
    end
    
    function printOptions(opts String[] in)
    	for (index int from 1 to opts.getSize() by 1)
    		syslib.writeStdout(opts[index]);
    	end
    end
end

-----
The generated js for if (options != null && options.getSize() > 0) is like
eze$Temp1 = ((egl.eglx.lang.EBoolean.ezeCast({eze$$value : this.options.appendElement(null), eze$$signature : "Teglx/lang/EList;"}) && ((this.options.getSize() > 0))));

In which append null to this.options is wrong
---------------

The RadioGroup widget suffers from this defect, can have a workaround to bypass it. But such kind of boolean statement is used frequently, so set the severity to major.
Comment 1 Scott Greer CLA 2011-09-28 21:45:43 EDT
Jeff,

I was able to create this same problem in Java gen;  I think reorgcode is the culprit.  visit(BinaryExpression ...) has logic that injects appendAll / appendElement, so perhaps that logic is too simplistic as illustrated by this testcase.
Comment 2 Jeff Douglas CLA 2011-09-30 14:12:20 EDT
fixed
Comment 3 Huang Ji Yong CLA 2011-10-21 00:44:22 EDT
Verified in 201110202102