Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 353790 - Test for NULL results in egl.lang.NullType can not be resolved
Summary: Test for NULL results in egl.lang.NullType can not be resolved
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jeff Douglas CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-03 11:49 EDT by Kathy Carroll CLA
Modified: 2017-02-23 14:20 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 Kathy Carroll CLA 2011-08-03 11:49:56 EDT
EGL code 

 mystring string?;
  if (mystring == null )
     writeStdout("got it");
  end

Error in generated Java
   egl.lang.NullType cannot be resolved to a type

Java code:
  if (egl.lang.NullType.equals(EString.ezeBox(mystring), null)) {
    String eze$Temp7 = Constants.EMPTY_STRING;
    eze$Temp7 = "got it";
    java.lang.System.out.println(eze$Temp7);
  }

JavaScript has no error and it is using egl.egl.lang.NullType
Comment 1 Matt Heitz CLA 2011-08-04 17:15:10 EDT
Jeff, this needs to be fixed in I11 (so tomorrow...sorry) if possible.  I'd do it myself but I'm out of time before my vacation.

I checked in a lot of changes related to nulls in the runtime's Exxx classes.  Methods like plus and concat now return null instead of throwing an exception on null input.  The equals and notEquals methods now return false when either operand is null.  These changes bring EDT in line with RBD.

I believe we need a NullType generator to deal with expressions that do x == null, null == x, x != null, and null != x.  That will fix this defect.  It's also necessary because, as I mentioned in the last paragraph, equals and notEquals will return false when either operand is null.  Without a special NullType generator to handle those four comparisons I think we'll end up using equals or notEquals from an Exxx class and the testcase in this defect won't work properly.

What I've said may seem strange, but try this in RBD:

s1 string? = null;
s2 string? = "I'm not null";
if ( s1 == null ) writeStdout( "s1 eq null" ); else writeStdout( "s1 not eq null" ); end
if ( s1 != null ) writeStdout( "s1 not eq null" ); else writeStdout( "s1 eq null" ); end
if ( s1 == s2 ) writeStdout( "s1 eq s2" ); else writeStdout( "s1 not eq s2" ); end
if ( s1 != s2 ) writeStdout( "s1 not eq s2" ); else writeStdout( "s1 eq s2" ); end

The first two comparisons tell you if s1 is null or not.  The last two comparisons both result in false, making s1 and s2 seem both equal and not equal!
Comment 2 Jeff Douglas CLA 2011-08-04 22:07:19 EDT
I've added the NullType logic. We still need to provide code for the asNullType method
Comment 3 Jeff Douglas CLA 2011-08-09 21:38:12 EDT
I think that the asNullType should just return null, which it does. So, I am resolving this defect.
Comment 4 Kathy Carroll CLA 2011-08-10 08:24:16 EDT
Verified
Comment 5 Lisa Lasher CLA 2011-10-11 16:22:32 EDT
Closing this defect.