See also: http://cr.openjdk.java.net/~shade/scratch/NullChecks.java
PS. Piggybacking a script engine test (which fails in 8u31 but passes in 8u40 - not sure if we had a test to cover it and hence adding it) and couple of minor issues with sample code as well.
Thanks, -Sundar
