RFR 8072595: nashorn should not use obj.getClass() for null checks

Attila Szegedi attila.szegedi at oracle.com
Thu Feb 5 08:54:50 UTC 2015

Object.requireNonNull JavaDoc suggests that when it's used for constructor parameter validation it's used as the RHS of field assignments. So instead of 

  this.clazz = clazz;


  this.clazz = Objects.requireNonNull(clazz);

Obviously, this is no big deal, but the fact that requireNonNull returns its argument could be leveraged.


On Feb 5, 2015, at 9:25 AM, A. Sundararajan <sundararajan.athijegannathan at oracle.com> wrote:

> Please review http://cr.openjdk.java.net/~sundar/8072595/ for https://bugs.openjdk.java.net/browse/JDK-8072595
> 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

More information about the nashorn-dev mailing list