22 */ 23 24 import java.lang.reflect.Method; 25 import java.foreign.annotations.NativeStruct; 26 import java.nio.file.Path; 27 import org.testng.annotations.Test; 28 29 import static org.testng.Assert.assertEquals; 30 import static org.testng.Assert.assertNotNull; 31 32 /* 33 * @test 34 * @modules jdk.jextract 35 * @build JextractToolRunner 36 * @run testng ArrayTest 37 */ 38 public class ArrayTest extends JextractToolRunner { 39 @Test 40 public void arrayInStruct() { 41 Path clzPath = getOutputFilePath("tmp.jar"); 42 checkSuccess(null,"-o", clzPath.toString(), 43 getInputFilePath("arrayTest.h").toString()); 44 Class<?> cls = loadClass("arrayTest", clzPath); 45 46 Class<?>[] inners = cls.getDeclaredClasses(); 47 // FIXME: should really be two without duplicate callback 48 assertEquals(inners.length, 3); 49 50 Class<?> struct = findClass(inners, "EndWithArray"); 51 NativeStruct ns = struct.getAnnotation(NativeStruct.class); 52 assertNotNull(ns); 53 54 Method m = findMethod(cls, "construct", int.class, int.class, java.foreign.memory.Pointer.class); 55 assertNotNull(m); 56 57 deleteFile(clzPath); 58 } 59 } | 22 */ 23 24 import java.lang.reflect.Method; 25 import java.foreign.annotations.NativeStruct; 26 import java.nio.file.Path; 27 import org.testng.annotations.Test; 28 29 import static org.testng.Assert.assertEquals; 30 import static org.testng.Assert.assertNotNull; 31 32 /* 33 * @test 34 * @modules jdk.jextract 35 * @build JextractToolRunner 36 * @run testng ArrayTest 37 */ 38 public class ArrayTest extends JextractToolRunner { 39 @Test 40 public void arrayInStruct() { 41 Path clzPath = getOutputFilePath("tmp.jar"); 42 run("-o", clzPath.toString(), 43 getInputFilePath("arrayTest.h").toString()).checkSuccess(); 44 Class<?> cls = loadClass("arrayTest", clzPath); 45 46 Class<?>[] inners = cls.getDeclaredClasses(); 47 // FIXME: should really be two without duplicate callback 48 assertEquals(inners.length, 3); 49 50 Class<?> struct = findClass(inners, "EndWithArray"); 51 NativeStruct ns = struct.getAnnotation(NativeStruct.class); 52 assertNotNull(ns); 53 54 Method m = findMethod(cls, "construct", int.class, int.class, java.foreign.memory.Pointer.class); 55 assertNotNull(m); 56 57 deleteFile(clzPath); 58 } 59 } |