Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362140 - Print a null variable throws eglx.lang.NullValueException
Summary: Print a null variable throws eglx.lang.NullValueException
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: Jeff Douglas CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-26 20:54 EDT by fahua jin CLA
Modified: 2017-02-23 14:14 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fahua jin CLA 2011-10-26 20:54:46 EDT
Build Identifier: 0.7.0.v201110241434

Create a program, and copy following two lines of EGL code to the main function.

--------------------------
times timeStamp?;
syslib.writeStdout(times);
--------------------------

Following exception will be thrown when running the program.

A null value was used.
eglx.lang.NullValueException A null value was used.
	at eglx.lang.AnyException.fillInStackTrace(AnyException.java:187)
	at java.lang.Throwable.<init>(Throwable.java:181)
	at java.lang.Exception.<init>(Exception.java:29)
	at java.lang.RuntimeException.<init>(RuntimeException.java:32)
	at eglx.lang.AnyException.<init>(AnyException.java:32)
	at eglx.lang.NullValueException.<init>(NullValueException.java:17)
	at org.eclipse.edt.javart.util.JavartUtil.checkNullable(JavartUtil.java:243)
	at server.PrimitiveNotInitPrg.main(PrimitiveNotInitPrg.java:33)
	at org.eclipse.edt.javart.resources.RunUnitBase.start(RunUnitBase.java:244)
	at server.PrimitiveNotInitPrg.main(PrimitiveNotInitPrg.java:18)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.edt.javart.ide.MainProgramLauncher.main(MainProgramLauncher.java:68)


I don't think simply print the null object should throw the exception. I made another test - if use this statement "syslib.writeStdout(null);", then the console print an empty line. It looks to me that the behavior of the same syntax have is different.


Reproducible: Always
Comment 1 fahua jin CLA 2011-10-26 20:55:21 EDT
Brian, could you please advise on this?
Comment 2 Brian Svihovec CLA 2011-10-27 13:49:59 EDT
I talked with Matt about this defect, and he pointed out that the signature for writestdout is:

static function writeStdout(text string in);

This means that passing a null value to this function would be the equivalent of doing an assignment of that null value to a temporary variable of type "string".  

This can also be tested using the following example:

function main()
		var1 String;
		//var1 = null; Compile Error
		var2 Timestamp?;
		var1 = var2;
		
	end

If you run the program above, you get the same exception as listed in the initial Description for this defect.  This means that passing 'times' to writestdout is working correctly.  During our discussion, we also determined that passing Null to writestdout should throw the same exception.  

NOTE: There should already be a defect opened for producing a better error message.

I have subscribed Jing as well, since the test group will need to verify that this behavior is the same on Java and JavaScript.
Comment 3 Jing Qian CLA 2011-10-27 14:22:15 EDT
Kathy will add this into the EUnit tests as part of null testing. 

- pass in the literal null
- pass in the null variable
Comment 4 Jeff Douglas CLA 2011-10-27 17:17:06 EDT
Fixed. A NullValueException will now be throw on writestdout and writestderr.
Comment 5 Jing Qian CLA 2011-10-27 21:41:58 EDT
Jeff, I hope this means anywhere a string is used, not just writestdout and writestderr.
Comment 6 fahua jin CLA 2011-10-28 01:42:00 EDT
Verified in 0.7.0.v201110272101 for the test scenario in this defect.