[foreign-memaccess] RFR: 8256466: MemoryLayout factories do not guard against null layouts
Jorn Vernee
jvernee at openjdk.java.net
Wed Nov 18 19:33:13 UTC 2020
On Wed, 18 Nov 2020 18:09:32 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This is a trivial, but a bit bigger than expected patch which fixes mentions of NPEs in the foreign memory access API javadoc. Almost all API points are affected, from memory layouts, to memory segments, etc.
> This patch does a number of things:
> * Document the various possible NPEs with corresponding `@throws` javadoc tags
> * Add `Objects::requireNotNull calls` where required
> * Added tests to check for nulls
> * Added a brand new test for `MemoryAccess`; this is both to check normal behavior, and also to check behavior when it comes to nulls
Changes requested by jvernee (Committer).
src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayout.java line 454:
> 452: private static <Z> Z computePathOp(LayoutPath path, Function<LayoutPath, Z> finalizer,
> 453: Set<LayoutPath.PathElementImpl.PathKind> badKinds, PathElement... elements) {
> 454: for (PathElement e : elements) {
What if `elements` itself is `null`? Doesn't seem to be covered currently in either impl or doc.
test/jdk/java/foreign/TestSpliterator.java line 232:
> 230:
> 231: @Test(expectedExceptions = NullPointerException.class)
> 232: public void testNullSpliteratoorLayout() {
typo:
Suggestion:
public void testNullSpliteratorLayout() {
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/395
More information about the panama-dev
mailing list