1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 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 } --- EOF ---