- Object references are not null when dereferenced
- Array subscripts are within array bounds
- Down cast object references are instances of the expected class
L is intended to be by default1 a type safe environment where all operations have a defined result. Many illegal or
undefined operations will not compile (for example assigning a string to a variable of type int). The legality of
some operations cannot be determined until run-time. In particular L checks at run-time that:
These checks combined with the fact that L code cannot normally cause variables of object to hold anything other
than either null references or references to variables of assignment compatible type2
mean that L program run-time behaviour is always defined.
1run-time checks can be selectively disabled, for specific methods, classes or for the
whole program2because all variables are initialized to null and all subsequent assignments are either compile time or run-time type checked
Source:
namespace Checks is
use System.Object;
use System.String;
use System.ArrayBoundsException;
use System.CastException;
use System.NullPointerException;
class Main is
void checkBounds() is
// this array has lower bound of zero (as do all L arrays) and
// upper bound of 2:
var a = { 1, 2, 3 };
try
// Array access requires a run-time bounds check:
a[-1] = -1;
catch ArrayBoundsException be
// Bounds check fails because -1 is not within bounds of
// array 'a'
IO.Std.out.println( "a[-1] caused: " + be );
yrt
si
void checkCast() is
// o is an instance of System.Object and is not a
// System.String:
var o = new Object();
try
// As System.String is not assignable from System.Object
// this cast requires a runtime check:
var s = cast String(o);
catch CastException ce
// Run-time cast check failed because o is not assignable
// to System.String:
IO.Std.out.println( "cast String(o) caused: " + ce );
yrt
si
void checkNull() is
// o does not reference any object:
System.Object o = null;
try
// read of Class property requires a run-time
// null reference check:
var s = o.Class.Name;
catch NullPointerException npe
// Run-time null check fails because o is null
IO.Std.out.println( "o.Class.Name caused: " + npe );
yrt
si
void init() is
IO.Std.err.println( "run time checks..." );
checkBounds();
checkCast();
checkNull();
IO.Std.err.println( "done" );
si
si
si
a[-1] caused: System.ArrayBoundsException: array index out of bounds
/var/giantblob/lsp/lsp.fcgi(_ZN6System20ArrayBoundsException11throwBoundsEv+0x32) [0x49d9a2]
[0x7f539308ff0c]
[0x7f539308ffff]
/var/giantblob/lsp/lsp.fcgi(_ZN6System5Class6createEv+0x58) [0x4c2fb8]
/var/giantblob/lsp/lsp.fcgi(_ZN7LSPPage9Giantblob7exampleEN6System5ClassE+0xc2) [0x4b9b12]
[0x7f539308fa01]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Page5onGetEv+0x56) [0x4a8376]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request10renderPageEN6System6StringEb+0x78d) [0x4a7dad]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request7processEv+0xc47) [0x4a7557]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Main4initEv+0x138) [0x49e2a8]
/var/giantblob/lsp/lsp.fcgi(_ZN6System7Startup4run1EN6System6ObjectE+0xd) [0x4c804d]
/var/giantblob/lsp/lsp.fcgi(main+0x3e) [0x48582e]
cast String(o) caused: System.CastException: invalid cast
/var/giantblob/lsp/lsp.fcgi(_ZN6System13CastException9throwCastEv+0x32) [0x48f652]
[0x7f539308fd39]
[0x7f539309000e]
/var/giantblob/lsp/lsp.fcgi(_ZN6System5Class6createEv+0x58) [0x4c2fb8]
/var/giantblob/lsp/lsp.fcgi(_ZN7LSPPage9Giantblob7exampleEN6System5ClassE+0xc2) [0x4b9b12]
[0x7f539308fa01]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Page5onGetEv+0x56) [0x4a8376]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request10renderPageEN6System6StringEb+0x78d) [0x4a7dad]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request7processEv+0xc47) [0x4a7557]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Main4initEv+0x138) [0x49e2a8]
/var/giantblob/lsp/lsp.fcgi(_ZN6System7Startup4run1EN6System6ObjectE+0xd) [0x4c804d]
/var/giantblob/lsp/lsp.fcgi(main+0x3e) [0x48582e]
o.Class.Name caused: System.NullPointerException: null pointer dereference
/var/giantblob/lsp/lsp.fcgi(_ZN6System20NullPointerException8throwNPEEv+0x32) [0x4b8ca2]
[0x7f539308fafd]
[0x7f539309001d]
/var/giantblob/lsp/lsp.fcgi(_ZN6System5Class6createEv+0x58) [0x4c2fb8]
/var/giantblob/lsp/lsp.fcgi(_ZN7LSPPage9Giantblob7exampleEN6System5ClassE+0xc2) [0x4b9b12]
[0x7f539308fa01]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Page5onGetEv+0x56) [0x4a8376]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request10renderPageEN6System6StringEb+0x78d) [0x4a7dad]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request7processEv+0xc47) [0x4a7557]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Main4initEv+0x138) [0x49e2a8]
/var/giantblob/lsp/lsp.fcgi(_ZN6System7Startup4run1EN6System6ObjectE+0xd) [0x4c804d]
/var/giantblob/lsp/lsp.fcgi(main+0x3e) [0x48582e]
/var/giantblob/lsp/lsp.fcgi(_ZN6System20ArrayBoundsException11throwBoundsEv+0x32) [0x49d9a2]
[0x7f539308ff0c]
[0x7f539308ffff]
/var/giantblob/lsp/lsp.fcgi(_ZN6System5Class6createEv+0x58) [0x4c2fb8]
/var/giantblob/lsp/lsp.fcgi(_ZN7LSPPage9Giantblob7exampleEN6System5ClassE+0xc2) [0x4b9b12]
[0x7f539308fa01]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Page5onGetEv+0x56) [0x4a8376]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request10renderPageEN6System6StringEb+0x78d) [0x4a7dad]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request7processEv+0xc47) [0x4a7557]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Main4initEv+0x138) [0x49e2a8]
/var/giantblob/lsp/lsp.fcgi(_ZN6System7Startup4run1EN6System6ObjectE+0xd) [0x4c804d]
/var/giantblob/lsp/lsp.fcgi(main+0x3e) [0x48582e]
cast String(o) caused: System.CastException: invalid cast
/var/giantblob/lsp/lsp.fcgi(_ZN6System13CastException9throwCastEv+0x32) [0x48f652]
[0x7f539308fd39]
[0x7f539309000e]
/var/giantblob/lsp/lsp.fcgi(_ZN6System5Class6createEv+0x58) [0x4c2fb8]
/var/giantblob/lsp/lsp.fcgi(_ZN7LSPPage9Giantblob7exampleEN6System5ClassE+0xc2) [0x4b9b12]
[0x7f539308fa01]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Page5onGetEv+0x56) [0x4a8376]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request10renderPageEN6System6StringEb+0x78d) [0x4a7dad]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request7processEv+0xc47) [0x4a7557]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Main4initEv+0x138) [0x49e2a8]
/var/giantblob/lsp/lsp.fcgi(_ZN6System7Startup4run1EN6System6ObjectE+0xd) [0x4c804d]
/var/giantblob/lsp/lsp.fcgi(main+0x3e) [0x48582e]
o.Class.Name caused: System.NullPointerException: null pointer dereference
/var/giantblob/lsp/lsp.fcgi(_ZN6System20NullPointerException8throwNPEEv+0x32) [0x4b8ca2]
[0x7f539308fafd]
[0x7f539309001d]
/var/giantblob/lsp/lsp.fcgi(_ZN6System5Class6createEv+0x58) [0x4c2fb8]
/var/giantblob/lsp/lsp.fcgi(_ZN7LSPPage9Giantblob7exampleEN6System5ClassE+0xc2) [0x4b9b12]
[0x7f539308fa01]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Page5onGetEv+0x56) [0x4a8376]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request10renderPageEN6System6StringEb+0x78d) [0x4a7dad]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML7Request7processEv+0xc47) [0x4a7557]
/var/giantblob/lsp/lsp.fcgi(_ZN4HTML4Main4initEv+0x138) [0x49e2a8]
/var/giantblob/lsp/lsp.fcgi(_ZN6System7Startup4run1EN6System6ObjectE+0xd) [0x4c804d]
/var/giantblob/lsp/lsp.fcgi(main+0x3e) [0x48582e]
site design and content copyright (C) jeek 1995-2010  
[
13132
]