24
24
/*
25
25
* @test
26
26
* @enablePreview
27
- * @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" | os.arch=="riscv64"
27
+ * @requires jdk.foreign.linker != "UNSUPPORTED"
28
+ * @modules java.base/jdk.internal.foreign
28
29
* @run testng TestLinker
29
30
*/
30
31
32
+ import jdk .internal .foreign .CABI ;
31
33
import org .testng .annotations .DataProvider ;
32
34
import org .testng .annotations .Test ;
33
35
34
36
import java .lang .foreign .FunctionDescriptor ;
35
37
import java .lang .foreign .Linker ;
36
38
import java .lang .invoke .MethodHandle ;
39
+ import java .util .ArrayList ;
40
+ import java .util .Arrays ;
41
+ import java .util .List ;
37
42
38
43
import static java .lang .foreign .MemoryLayout .*;
39
44
import static java .lang .foreign .ValueLayout .JAVA_CHAR ;
43
48
44
49
public class TestLinker extends NativeTestHelper {
45
50
51
+ static final boolean IS_FALLBACK_LINKER = CABI .current () == CABI .FALLBACK ;
52
+
46
53
record LinkRequest (FunctionDescriptor descriptor , Linker .Option ... options ) {}
47
54
48
55
@ Test (dataProvider = "notSameCases" )
@@ -75,7 +82,7 @@ public void testNamedLinkerCache(FunctionDescriptor f1, FunctionDescriptor f2) {
75
82
76
83
@ DataProvider
77
84
public static Object [][] namedDescriptors () {
78
- return new Object [][]{
85
+ List < Object []> cases = new ArrayList <>( Arrays . asList ( new Object [][]{
79
86
{ FunctionDescriptor .ofVoid (C_INT ),
80
87
FunctionDescriptor .ofVoid (C_INT .withName ("x" )) },
81
88
{ FunctionDescriptor .ofVoid (structLayout (C_INT )),
@@ -90,17 +97,22 @@ public static Object[][] namedDescriptors() {
90
97
FunctionDescriptor .ofVoid (structLayout (sequenceLayout (1 , C_INT ).withName ("x" ))) },
91
98
{ FunctionDescriptor .ofVoid (structLayout (sequenceLayout (1 , C_INT ))),
92
99
FunctionDescriptor .ofVoid (structLayout (sequenceLayout (1 , C_INT .withName ("x" )))) },
93
- { FunctionDescriptor .ofVoid (unionLayout (C_INT )),
94
- FunctionDescriptor .ofVoid (unionLayout (C_INT ).withName ("x" )) },
95
- { FunctionDescriptor .ofVoid (unionLayout (C_INT )),
96
- FunctionDescriptor .ofVoid (unionLayout (C_INT .withName ("x" ))) },
97
100
{ FunctionDescriptor .ofVoid (C_POINTER ),
98
101
FunctionDescriptor .ofVoid (C_POINTER .withName ("x" )) },
99
102
{ FunctionDescriptor .ofVoid (C_POINTER .withTargetLayout (C_INT )),
100
103
FunctionDescriptor .ofVoid (C_POINTER .withTargetLayout (C_INT .withName ("x" ))) },
101
104
{ FunctionDescriptor .ofVoid (C_POINTER .withTargetLayout (C_INT )),
102
105
FunctionDescriptor .ofVoid (C_POINTER .withName ("x" ).withTargetLayout (C_INT .withName ("x" ))) },
103
- };
106
+ }));
107
+
108
+ if (!IS_FALLBACK_LINKER ) {
109
+ cases .add (new Object []{ FunctionDescriptor .ofVoid (unionLayout (C_INT )),
110
+ FunctionDescriptor .ofVoid (unionLayout (C_INT ).withName ("x" )) });
111
+ cases .add (new Object []{ FunctionDescriptor .ofVoid (unionLayout (C_INT )),
112
+ FunctionDescriptor .ofVoid (unionLayout (C_INT .withName ("x" ))) });
113
+ }
114
+
115
+ return cases .toArray (Object [][]::new );
104
116
}
105
117
106
118
@ DataProvider
0 commit comments