diff --git a/test/jdk/internal/jimage/JImageFindResourceTest.java b/test/jdk/internal/jimage/JImageFindResourceTest.java
new file mode 100644
--- /dev/null
+++ b/test/jdk/internal/jimage/JImageFindResourceTest.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @modules java.base/jdk.internal.jimage
+ * @summary Additional test scenarios for JIMAGE_Open/JIMAGE_Close methods
+ */
+
+import java.io.File;
+
+import jdk.internal.jimage.BasicImageReader;
+import jdk.internal.jimage.ImageNativeSubstrate;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.testng.TestNG;
+
+@Test
+public class JImageFindResourceTest {
+
+    static String JAVA_HOME = System.getProperty("java.home");
+
+    static String imageFile = JAVA_HOME + File.separator + "lib" + File.separator
+                              + "modules" + File.separator + "bootmodules.jimage";
+
+    @DataProvider(name="handles")
+    static Object[][] loadHandles() {
+        return new Object[][] {
+            { new Long(0) },
+            { new Long(7L) },
+            { new Long(-7L) },
+            { new Long(Long.MAX_VALUE) },
+            { new Long(Long.MIN_VALUE) }
+        };
+    }
+
+    @DataProvider(name="modules")
+    static Object[][] loadModules() {
+        return new Object[][] {
+            { "bad.module" },
+            { null },
+        };
+    }
+
+    @DataProvider(name="classes")
+    static Object[][] loadClasses() {
+        return new Object[][] {
+            { "no/such/Class.class" },
+            { null },
+        };
+    }
+
+    @DataProvider(name="versions")
+    static Object[][] loadVersions() {
+        return new Object[][] {
+            { "version" },
+            { "8.0" },
+            { null },
+        };
+    }
+
+    @Test(dataProvider="handles")
+    static void badHandleTest(Long badHandle) {
+        long handle = badHandle.longValue();
+        long[] size = new long[1];
+        long result = ImageNativeSubstrate.JIMAGE_FindResource(
+            handle,  "java.base", "9.0", "java/lang/String.class", size);
+
+        System.out.println("FindResource with bad handle " + handle + " returns " + result);
+        Assert.assertTrue(result == 0, "FindResource returns " + result + " instead of 0");
+    }
+
+    @Test(dataProvider="modules")
+    static void badModuleNameTest(String badModule) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long[] size = new long[1];
+        long result = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle, badModule, "9.0", "java/lang/String.class", size);
+
+        System.out.println("FindResource with bad module " + badModule + " returns " + result);
+        Assert.assertTrue(result == 0, "FindResource returns " + result + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test(dataProvider="classes")
+    static void badClassNameTest(String badClass) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long[] size = new long[1];
+        long result = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle, "java.base", "9.0", badClass, size);
+
+        System.out.println("FindResource with bad class " + badClass + " returns " + result);
+        Assert.assertTrue(result == 0, "FindResource returns " + result + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test(dataProvider="versions")
+    static void badVersionTest(String badVersion) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long[] size = new long[1];
+        long result = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle, "java.base", badVersion, "java/lang/String.class", size);
+
+        System.out.println("FindResource with bad version " + badVersion + " returns " + result);
+        Assert.assertTrue(result == 0, "FindResource returns " + result + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test
+    static void badSizeTest() throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long result = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle, "java.base", "9.0", "java/lang/String.class", null);
+
+        System.out.println("FindResource with null instead of size returns " + result);
+        Assert.assertTrue(result == 0, "FindResource returns " + result + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    // main method to run standalone from jtreg
+
+    @Test(enabled=false)
+    @Parameters({"x"})
+    @SuppressWarnings("raw_types")
+    public static void main(@Optional String[] args) {
+        Class<?>[] testclass = { JImageFindResourceTest.class };
+        TestNG testng = new TestNG();
+        testng.setTestClasses(testclass);
+        testng.run();
+    }
+}
diff --git a/test/jdk/internal/jimage/JImageGetResourceTest.java b/test/jdk/internal/jimage/JImageGetResourceTest.java
new file mode 100644
--- /dev/null
+++ b/test/jdk/internal/jimage/JImageGetResourceTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @modules java.base/jdk.internal.jimage
+ * @summary Additional test scenarios for JIMAGE_Open/JIMAGE_Close methods
+ */
+
+import java.io.File;
+
+import jdk.internal.jimage.BasicImageReader;
+import jdk.internal.jimage.ImageNativeSubstrate;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.testng.TestNG;
+
+@Test
+public class JImageGetResourceTest {
+
+    static String JAVA_HOME = System.getProperty("java.home");
+
+    static String imageFile = JAVA_HOME + File.separator + "lib" + File.separator
+                              + "modules" + File.separator + "bootmodules.jimage";
+
+    static long maxCount = max();
+    static long resSize = size();
+
+    @DataProvider(name="handles")
+    static Object[][] loadHandles() {
+        return new Object[][] {
+            { new Long(0) },
+            { new Long(7L) },
+            { new Long(-7L) },
+            { new Long(Long.MAX_VALUE) },
+            { new Long(Long.MIN_VALUE) }
+        };
+    }
+
+    @DataProvider(name="locations")
+    static Object[][] loadLocations() {
+        return new Object[][] {
+            { new Long(-1) },
+            { new Long(0) },
+            { new Long(Long.MAX_VALUE) },
+            { new Long(maxCount + 1) },
+            { new Long(maxCount + 5) }
+        };
+    }
+
+    @DataProvider(name="buffers")
+    static Object[][] loadBuffers() {
+        return new Object[][] {
+            { "zero size" },
+            { "half size" },
+            { "null" }
+        };
+    }
+
+    @DataProvider(name="sizes")
+    static Object[][] loadSizes() {
+        return new Object[][] {
+            { new Long(-1) },
+            { new Long(0) },
+            { new Long(resSize / 2) },
+            { new Long(resSize + 1024) }
+        };
+    }
+
+    @Test(dataProvider="handles")
+    static void badHandleTest(Long badHandle) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long handle = badHandle.longValue();
+        long[] size = new long[1];
+        long location = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle,  "java.base", "9.0", "java/lang/String.class", size);
+
+        long desiredSize = size[0];
+        byte[] buffer = new byte[(int)desiredSize];
+        long actualSize = ImageNativeSubstrate.JIMAGE_GetResource(
+            handle, location, buffer, desiredSize);
+
+        System.out.println("GetResource with bad handle " + handle + " returns " + actualSize);
+        Assert.assertTrue(actualSize == 0, "GetResource returns " + actualSize + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test(dataProvider="locations")
+    static void badLocationRefTest(Long badLocation) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long badLoc = badLocation.longValue();
+
+        long[] size = new long[1];
+        long location = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle,  "java.base", "9.0", "java/lang/String.class", size);
+
+        long desiredSize = size[0];
+        byte[] buffer = new byte[(int)desiredSize];
+        long actualSize = ImageNativeSubstrate.JIMAGE_GetResource(
+            jimageHandle, badLoc, buffer, desiredSize);
+
+        System.out.println("GetResource with bad location ref returns " + actualSize);
+        Assert.assertTrue(actualSize == 0, "GetResource returns " + actualSize + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test(dataProvider="buffers")
+    static void badLocationRefTest(String badBuffer) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long[] size = new long[1];
+        long location = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle,  "java.base", "9.0", "java/lang/String.class", size);
+
+        long desiredSize = size[0];
+        byte[] buffer = null;
+        switch (badBuffer) {
+            case "zero size":
+                buffer = new byte[] {};
+                break;
+            case "half size":
+                buffer = new byte[(int)desiredSize / 2];
+                break;
+        }
+
+        long actualSize = ImageNativeSubstrate.JIMAGE_GetResource(
+            jimageHandle, location, buffer, desiredSize);
+
+        System.out.println("GetResource with bad buffer " + badBuffer + " returns " + actualSize);
+        Assert.assertTrue(actualSize == 0, "GetResource returns " + actualSize + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test(dataProvider="sizes")
+    static void badSizeTest(Long badSize) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long[] size = new long[1];
+        long location = ImageNativeSubstrate.JIMAGE_FindResource(
+            jimageHandle,  "java.base", "9.0", "java/lang/String.class", size);
+
+        long desiredBadSize = badSize.longValue();
+        byte[] buffer = new byte[(int)desiredBadSize];
+        long actualSize = ImageNativeSubstrate.JIMAGE_GetResource(
+            jimageHandle, location, buffer, desiredBadSize);
+
+        System.out.println("GetResource with bad size " + desiredBadSize
+            + " and real size " + size[0] + " returns " + actualSize);
+        long refSize = (desiredBadSize <= 0) ? 0 : desiredBadSize;
+        Assert.assertTrue(actualSize == refSize, "GetResource returns " + desiredBadSize + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    static long max() {
+        try {
+            long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+            String[] names = new String[1];
+            int max = ImageNativeSubstrate.JIMAGE_Resources(jimageHandle, names);
+            return (long)max;
+        } catch (Exception e) {
+            return 0;
+        }
+    }
+
+    static long size() {
+        try {
+            long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+            long[] size = new long[1];
+            long location = ImageNativeSubstrate.JIMAGE_FindResource(
+                jimageHandle,  "java.base", "9.0", "java/lang/String.class", size);
+            ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+            return size[0];
+        } catch (Exception e) {
+            return 0;
+        }
+    }
+
+    // main method to run standalone from jtreg
+
+    @Test(enabled=false)
+    @Parameters({"x"})
+    @SuppressWarnings("raw_types")
+    public static void main(@Optional String[] args) {
+        Class<?>[] testclass = { JImageGetResourceTest.class };
+        TestNG testng = new TestNG();
+        testng.setTestClasses(testclass);
+        testng.run();
+    }
+}
diff --git a/test/jdk/internal/jimage/JImageOpenCloseTest.java b/test/jdk/internal/jimage/JImageOpenCloseTest.java
new file mode 100644
--- /dev/null
+++ b/test/jdk/internal/jimage/JImageOpenCloseTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @modules java.base/jdk.internal.jimage
+ * @summary Additional test scenarios for JIMAGE_Open/JIMAGE_Close methods
+ */
+
+import java.io.File;
+
+import jdk.internal.jimage.BasicImageReader;
+import jdk.internal.jimage.ImageNativeSubstrate;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.testng.TestNG;
+
+@Test
+public class JImageOpenCloseTest {
+
+    static String JAVA_HOME = System.getProperty("java.home");
+    static String TEST_SRC  = System.getProperty("test.src");
+    static String TEST_DATA = TEST_SRC + File.separator + "data";
+
+    static String imageFile = JAVA_HOME + File.separator + "lib" + File.separator
+                              + "modules" + File.separator + "bootmodules.jimage";
+
+    @DataProvider(name="badimages")
+    static Object[][] getImages() {
+        return new Object[][] {
+            { TEST_DATA + File.separator + "nonexisting.jimage" },
+            { TEST_DATA + File.separator + "empty.jimage" },
+            { TEST_DATA + File.separator + "wrongmagic.jimage" }
+        };
+    }
+
+    @DataProvider(name="handles")
+    static Object[][] loadHandles() {
+        return new Object[][] {
+            { new Long(0) },
+            { new Long(7L) },
+            { new Long(-7L) },
+            { new Long(Long.MAX_VALUE) },
+            { new Long(Long.MIN_VALUE) }
+        };
+    }
+
+    @Test
+    static void multipleOpenTest() throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long jimageHandle1 = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+        jimageHandle1 = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+        jimageHandle1 = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+        jimageHandle1 = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        System.out.println("Multiple open ids first = " + jimageHandle + "; last = " + jimageHandle1);
+        Assert.assertTrue(jimageHandle == jimageHandle1, "multiple open should have same handle");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test(dataProvider="badimages")
+    public static void badJImagesTest(String jimageName) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(jimageName);
+
+        System.out.println("Open bad image: " + jimageName + " returns " + jimageHandle);
+        Assert.assertTrue(jimageHandle == 0, "bad jimage should not be opened");
+    }
+
+    @Test
+    static void multipleCloseTest() throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        System.out.println("Close the same jimage several times");
+        for (int i = 0; i < 10; i++) {
+            ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+        }
+    }
+
+    @Test(dataProvider="handles")
+    static void badCloseTest(Long wrongHandle) throws Exception {
+        long handle = wrongHandle.longValue();
+        System.out.println("Close call with wrong handle = " + handle);
+        ImageNativeSubstrate.JIMAGE_Close(handle);
+    }
+
+    // main method to run standalone from jtreg
+
+    @Test(enabled=false)
+    @Parameters({"x"})
+    @SuppressWarnings("raw_types")
+    public static void main(@Optional String[] args) {
+        Class<?>[] testclass = { JImageOpenCloseTest.class };
+        TestNG testng = new TestNG();
+        testng.setTestClasses(testclass);
+        testng.run();
+    }
+}
diff --git a/test/jdk/internal/jimage/JImagePackageToModuleTest.java b/test/jdk/internal/jimage/JImagePackageToModuleTest.java
new file mode 100644
--- /dev/null
+++ b/test/jdk/internal/jimage/JImagePackageToModuleTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @modules java.base/jdk.internal.jimage
+ * @summary Additional test scenarios for JIMAGE_Open/JIMAGE_Close methods
+ */
+
+import java.io.File;
+
+import jdk.internal.jimage.BasicImageReader;
+import jdk.internal.jimage.ImageNativeSubstrate;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.testng.TestNG;
+
+@Test
+public class JImagePackageToModuleTest {
+
+    static String JAVA_HOME = System.getProperty("java.home");
+
+    static String imageFile = JAVA_HOME + File.separator + "lib" + File.separator
+                              + "modules" + File.separator + "bootmodules.jimage";
+
+    @DataProvider(name="packages")
+    static Object[][] loadPackages() {
+        return new Object[][] {
+            { "does/not/exist" },
+            { null }
+        };
+    }
+
+    @DataProvider(name="handles")
+    static Object[][] loadHandles() {
+        return new Object[][] {
+            { new Long(0) },
+            { new Long(7L) },
+            { new Long(-7L) },
+            { new Long(Long.MAX_VALUE) },
+            { new Long(Long.MIN_VALUE) }
+        };
+    }
+
+    @Test(dataProvider="packages")
+    static void incorrectPackageValueTest(String packageName) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        String modName = ImageNativeSubstrate.JIMAGE_PackageToModule(jimageHandle, packageName);
+
+        System.out.println("PackageToModule with package " + packageName + " returns " + modName);
+        Assert.assertTrue(modName == null, "PackageToModule with package " + packageName
+            + " returns " + modName + " instead of null");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test(dataProvider="handles")
+    static void incorrectImageHandlaTest(Long wrongHandle) throws Exception {
+        long handle = wrongHandle.longValue();
+
+        System.out.println("PackageToModule for java/lang with handle = " + handle);
+        String modName = ImageNativeSubstrate.JIMAGE_PackageToModule(handle, "java/lang");
+        Assert.assertTrue(modName == null, "PackageToModule for java/lang with handle = "
+            + " returns " + modName + " instead of null");
+    }
+
+    // main method to run standalone from jtreg
+
+    @Test(enabled=false)
+    @Parameters({"x"})
+    @SuppressWarnings("raw_types")
+    public static void main(@Optional String[] args) {
+        Class<?>[] testclass = { JImagePackageToModuleTest.class };
+        TestNG testng = new TestNG();
+        testng.setTestClasses(testclass);
+        testng.run();
+    }
+}
diff --git a/test/jdk/internal/jimage/JImageResourcesTest.java b/test/jdk/internal/jimage/JImageResourcesTest.java
new file mode 100644
--- /dev/null
+++ b/test/jdk/internal/jimage/JImageResourcesTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @modules java.base/jdk.internal.jimage
+ * @summary Additional test scenarios for JIMAGE_Open/JIMAGE_Close methods
+ */
+
+import java.io.File;
+
+import jdk.internal.jimage.BasicImageReader;
+import jdk.internal.jimage.ImageNativeSubstrate;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.testng.TestNG;
+
+@Test
+public class JImageResourcesTest {
+
+    static String JAVA_HOME = System.getProperty("java.home");
+
+    static String imageFile = JAVA_HOME + File.separator + "lib" + File.separator
+                              + "modules" + File.separator + "bootmodules.jimage";
+
+    @DataProvider(name="handles")
+    static Object[][] loadHandles() {
+        return new Object[][] {
+            { new Long(0) },
+            { new Long(7L) },
+            { new Long(-7L) },
+            { new Long(Long.MAX_VALUE) },
+            { new Long(Long.MIN_VALUE) }
+        };
+    }
+
+    @Test(dataProvider="handles")
+    static void badHandleTest(Long badHandle) throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        long handle = badHandle.longValue();
+
+        String[] names = new String[1024];
+        int max = ImageNativeSubstrate.JIMAGE_Resources(handle, names);
+
+        System.out.println("Resources with bad handle " + handle + " returns " + max);
+        Assert.assertTrue(max == 0, "GetResource returns " + max + " instead of 0");
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    @Test
+    static void badNamesArrayTest() throws Exception {
+        long jimageHandle = ImageNativeSubstrate.JIMAGE_Open(imageFile);
+
+        String[] names = new String[1024];
+        int max1 = ImageNativeSubstrate.JIMAGE_Resources(jimageHandle, names);
+        int max2 = ImageNativeSubstrate.JIMAGE_Resources(jimageHandle, null);
+
+        System.out.println("Resources with null array returns " + max2);
+        Assert.assertTrue(max1 == max2, "GetResource returns " + max2 + " instead of " + max1);
+
+        ImageNativeSubstrate.JIMAGE_Close(jimageHandle);
+    }
+
+    // main method to run standalone from jtreg
+
+    @Test(enabled=false)
+    @Parameters({"x"})
+    @SuppressWarnings("raw_types")
+    public static void main(@Optional String[] args) {
+        Class<?>[] testclass = { JImageResourcesTest.class };
+        TestNG testng = new TestNG();
+        testng.setTestClasses(testclass);
+        testng.run();
+    }
+}
diff --git a/test/jdk/internal/jimage/data/empty.jimage b/test/jdk/internal/jimage/data/empty.jimage
new file mode 100644
diff --git a/test/jdk/internal/jimage/data/wrongmagic.jimage b/test/jdk/internal/jimage/data/wrongmagic.jimage
new file mode 100644
--- /dev/null
+++ b/test/jdk/internal/jimage/data/wrongmagic.jimage
@@ -0,0 +1,1 @@
+±±þÊ
\ No newline at end of file
