Skip to content

Commit

Permalink
feat: jna over static jni
Browse files Browse the repository at this point in the history
- chore: switch to jna snapshot
- chore: add new jna graalvm artifact
- chore: opt-in to static jna feature
- chore: cleanup superfluous configs

Adopts java-native-access/jna#1608

Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Jun 13, 2024
1 parent 4c838ac commit c0c1fbf
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 391 deletions.
3 changes: 2 additions & 1 deletion gradle/elide.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jimfs = "1.3.0"
jline = "3.26.1"
jmh-lib = "1.37"
jmh-plugin = "0.7.2"
jna = "5.14.0"
jna = "5.15.0-SNAPSHOT"
jprofiler = "14.0.1"
json = "20240303"
jsoup = "1.17.2"
Expand Down Expand Up @@ -557,6 +557,7 @@ jline-terminal-jna = { module = "org.jline:jline-terminal-jna", version.ref = "j
jline-terminal-jni = { module = "org.jline:jline-terminal-jni", version.ref = "jline" }
jna = { group = "net.java.dev.jna", name = "jna", version.ref = "jna" }
jna-jpms = { group = "net.java.dev.jna", name = "jna-jpms", version.ref = "jna" }
jna-graalvm = { group = "net.java.dev.jna", name = "jna-graalvm", version.ref = "jna" }
json = { group = "org.json", name = "json", version.ref = "json" }
jsoup = { group = "org.jsoup", name = "jsoup", version.ref = "jsoup" }
junit = "junit:junit:4.13.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,64 +19,6 @@
"name":"com.apple.eawt._AppMenuBarHandler",
"methods":[{"name":"initMenuStates","parameterTypes":["boolean","boolean","boolean","boolean"] }]
},
{
"name":"com.sun.jna.Callback"
},
{
"name":"com.sun.jna.CallbackReference",
"methods":[{"name":"getCallback","parameterTypes":["java.lang.Class","com.sun.jna.Pointer","boolean"] }, {"name":"getFunctionPointer","parameterTypes":["com.sun.jna.Callback","boolean"] }, {"name":"getNativeString","parameterTypes":["java.lang.Object","boolean"] }, {"name":"initializeThread","parameterTypes":["com.sun.jna.Callback","com.sun.jna.CallbackReference$AttachOptions"] }]
},
{
"name":"com.sun.jna.CallbackReference$AttachOptions"
},
{
"name":"com.sun.jna.FromNativeConverter",
"methods":[{"name":"nativeType","parameterTypes":[] }]
},
{
"name":"com.sun.jna.IntegerType",
"fields":[{"name":"value"}]
},
{
"name":"com.sun.jna.JNIEnv"
},
{
"name":"com.sun.jna.Native",
"methods":[{"name":"dispose","parameterTypes":[] }, {"name":"fromNative","parameterTypes":["com.sun.jna.FromNativeConverter","java.lang.Object","java.lang.reflect.Method"] }, {"name":"fromNative","parameterTypes":["java.lang.Class","java.lang.Object"] }, {"name":"fromNative","parameterTypes":["java.lang.reflect.Method","java.lang.Object"] }, {"name":"nativeType","parameterTypes":["java.lang.Class"] }, {"name":"toNative","parameterTypes":["com.sun.jna.ToNativeConverter","java.lang.Object"] }]
},
{
"name":"com.sun.jna.Native$ffi_callback",
"methods":[{"name":"invoke","parameterTypes":["long","long","long"] }]
},
{
"name":"com.sun.jna.NativeMapped",
"methods":[{"name":"toNative","parameterTypes":[] }]
},
{
"name":"com.sun.jna.Pointer",
"fields":[{"name":"peer"}],
"methods":[{"name":"<init>","parameterTypes":["long"] }]
},
{
"name":"com.sun.jna.PointerType",
"fields":[{"name":"pointer"}]
},
{
"name":"com.sun.jna.Structure",
"fields":[{"name":"memory"}, {"name":"typeInfo"}],
"methods":[{"name":"autoRead","parameterTypes":[] }, {"name":"autoWrite","parameterTypes":[] }, {"name":"getTypeInfo","parameterTypes":[] }, {"name":"newInstance","parameterTypes":["java.lang.Class","long"] }]
},
{
"name":"com.sun.jna.Structure$ByValue"
},
{
"name":"com.sun.jna.Structure$FFIType$FFITypes",
"fields":[{"name":"ffi_type_double"}, {"name":"ffi_type_float"}, {"name":"ffi_type_longdouble"}, {"name":"ffi_type_pointer"}, {"name":"ffi_type_sint16"}, {"name":"ffi_type_sint32"}, {"name":"ffi_type_sint64"}, {"name":"ffi_type_sint8"}, {"name":"ffi_type_uint16"}, {"name":"ffi_type_uint32"}, {"name":"ffi_type_uint64"}, {"name":"ffi_type_uint8"}, {"name":"ffi_type_void"}]
},
{
"name":"com.sun.jna.WString",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"name":"com.sun.management.internal.DiagnosticCommandArgumentInfo",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","boolean","boolean","int"] }]
Expand Down Expand Up @@ -503,4 +445,4 @@
"name":"sun.nio.ch.FileChannelImpl",
"fields":[{"name":"fd"}]
}
]
]
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
[
{
"interfaces":["com.github.ajalt.mordant.internal.jna.MacosLibC"]
},
{
"interfaces":["com.sun.jna.platform.mac.CoreFoundation"]
},
{
"interfaces":["com.sun.jna.platform.mac.IOKit"]
},
{
"interfaces":["com.sun.jna.platform.mac.SystemB"]
},
{
"interfaces":["kotlin.jvm.functions.Function2"]
},
{
"interfaces":["oshi.jna.platform.mac.SystemB"]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -345,58 +345,6 @@
"name":"com.sun.crypto.provider.TlsPrfGenerator$V12",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.CallbackProxy",
"methods":[{"name":"callback","parameterTypes":["java.lang.Object[]"] }]
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFAllocatorRef",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFDataRef",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFIndex",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFMutableDictionaryRef",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFStringRef",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFTypeID",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFTypeRef",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.IOKit$IOIterator",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.mac.IOKit$IORegistryEntry",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.platform.unix.LibCAPI$size_t",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.ptr.IntByReference",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.jna.ptr.PointerByReference",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"com.sun.management.GarbageCollectorMXBean",
"queryAllPublicMethods":true
Expand Down Expand Up @@ -10937,4 +10885,4 @@
"name":"sun.security.x509.SubjectKeyIdentifierExtension",
"methods":[{"name":"<init>","parameterTypes":["java.lang.Boolean","java.lang.Object"] }]
}
]
]
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
[

]
[]
5 changes: 5 additions & 0 deletions packages/runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ val enablePgoSampling = false
val enablePgoInstrumentation = false
val enablePgoReport = true
val enableJna = true
val enableJnaStatic = true
val enableSbom = oracleGvm
val enableSbomStrict = false
val glibcTarget = "glibc"
Expand Down Expand Up @@ -441,6 +442,9 @@ dependencies {
jvmOnly(libs.jna.jpms)
} else {
implementation(libs.jna.jpms)
if (enableJnaStatic) {
implementation(libs.jna.graalvm)
}
}

// Tests
Expand Down Expand Up @@ -610,6 +614,7 @@ val deprecatedNativeArgs = listOf(
)

val enabledFeatures = listOfNotNull(
"com.sun.jna.SubstrateStaticJNA",
"elide.tool.feature.ToolingUmbrellaFeature",
onlyIf(enableSqlite, "elide.runtime.feature.engine.NativeSQLiteFeature"),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,162 +20,6 @@
{
"name":"[[J"
},
{
"name":"com.sun.jna.Callback",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.jna.CallbackReference",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"methods":[{"name":"getCallback","parameterTypes":["java.lang.Class","com.sun.jna.Pointer","boolean"] }, {"name":"getFunctionPointer","parameterTypes":["com.sun.jna.Callback","boolean"] }, {"name":"getNativeString","parameterTypes":["java.lang.Object","boolean"] }, {"name":"initializeThread","parameterTypes":["com.sun.jna.Callback","com.sun.jna.CallbackReference$AttachOptions"] }]
},
{
"name":"com.sun.jna.CallbackReference$AttachOptions",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.jna.FromNativeConverter",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"methods":[{"name":"nativeType","parameterTypes":[] }]
},
{
"name":"com.sun.jna.IntegerType",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"fields":[{"name":"value", "allowWrite":true}]
},
{
"name":"com.sun.jna.JNIEnv",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.jna.Native",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"methods":[
{"name":"dispose","parameterTypes":[] },
{"name":"fromNative","parameterTypes":["com.sun.jna.FromNativeConverter","java.lang.Object","java.lang.reflect.Method"] },
{"name":"fromNative","parameterTypes":["java.lang.Class","java.lang.Object"] },
{"name":"fromNative","parameterTypes":["java.lang.reflect.Method","java.lang.Object"] },
{"name":"nativeType","parameterTypes":["java.lang.Class"] },
{"name":"toNative","parameterTypes":["com.sun.jna.ToNativeConverter","java.lang.Object"]},
{"name":"open","parameterTypes":["java.lang.String","java.lang.Integer"]},
{"name":"close","parameterTypes":["java.lang.Long"]},
{"name":"findSymbol","parameterTypes":["java.lang.Long","java.lang.String"]}
]
},
{
"name":"com.sun.jna.Native$ffi_callback",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"methods":[{"name":"invoke","parameterTypes":["long","long","long"] }]
},
{
"name":"com.sun.jna.NativeLong",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.jna.NativeMapped",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"methods":[{"name":"toNative","parameterTypes":[] }]
},
{
"name":"com.sun.jna.Pointer",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"fields":[{"name":"peer", "allowWrite":true}],
"methods":[{"name":"<init>","parameterTypes":["long"] }]
},
{
"name":"com.sun.jna.PointerType",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"fields":[{"name":"pointer", "allowWrite":true}]
},
{
"name":"com.sun.jna.Structure",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"fields":[{"name":"memory", "allowWrite":true}, {"name":"typeInfo", "allowWrite":true}],
"methods":[{"name":"autoRead","parameterTypes":[] }, {"name":"autoWrite","parameterTypes":[] }, {"name":"getTypeInfo","parameterTypes":[] }, {"name":"getTypeInfo","parameterTypes":["java.lang.Object"] }, {"name":"newInstance","parameterTypes":["java.lang.Class"] }, {"name":"newInstance","parameterTypes":["java.lang.Class","long"] }, {"name":"newInstance","parameterTypes":["java.lang.Class","com.sun.jna.Pointer"] }]
},
{
"name":"com.sun.jna.Structure$ByValue",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.jna.Structure$FFIType",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.jna.Structure$FFIType$FFITypes",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"fields":[{"name":"ffi_type_double", "allowWrite":true}, {"name":"ffi_type_float", "allowWrite":true}, {"name":"ffi_type_longdouble", "allowWrite":true}, {"name":"ffi_type_pointer", "allowWrite":true}, {"name":"ffi_type_sint16", "allowWrite":true}, {"name":"ffi_type_sint32", "allowWrite":true}, {"name":"ffi_type_sint64", "allowWrite":true}, {"name":"ffi_type_sint8", "allowWrite":true}, {"name":"ffi_type_uint16", "allowWrite":true}, {"name":"ffi_type_uint32", "allowWrite":true}, {"name":"ffi_type_uint64", "allowWrite":true}, {"name":"ffi_type_uint8", "allowWrite":true}, {"name":"ffi_type_void", "allowWrite":true}]
},
{
"name":"com.sun.jna.WString",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"name":"com.sun.jna.ptr.PointerByReference",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.jna.platform.mac.CoreFoundation$CFStringRef",
"allDeclaredMethods":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true
},
{
"name":"com.sun.management.internal.DiagnosticCommandArgumentInfo",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String","java.lang.String","java.lang.String","java.lang.String","boolean","boolean","boolean","int"] }]
Expand Down
Loading

0 comments on commit c0c1fbf

Please sign in to comment.