Skip to content

Commit eeaecea

Browse files
authored
Merge branch 'java-native-access:master' into master
2 parents bdc2e56 + 86a2ff1 commit eeaecea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+297
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ jobs:
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
matrix:
19-
java: [8, 11, 17, 21, 23-ea]
19+
java: [8, 21, 24]
2020
# macos-13 is x86, macos-latest is aarch64
21-
os: [ubuntu-latest, macos-13, macos-latest]
22-
exclude:
23-
# 23-ea is not available for mac OS
24-
- java: 23-ea
25-
os: macos-latest
21+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-13]
2622
# Run all tests even if one fails
2723
fail-fast: false
2824
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
@@ -36,7 +32,9 @@ jobs:
3632
distribution: 'zulu'
3733
- name: Linux requirements
3834
if: contains(matrix.os, 'ubuntu')
39-
run: sudo apt-get install -yq --force-yes zip unzip libtool automake libltdl-dev texinfo ant ant-optional debhelper-compat default-jdk javahelper libasm-java libffi-dev libx11-dev libxt-dev maven-repo-helper pkg-config
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get install -yq --allow-downgrades zip unzip libtool automake libltdl-dev texinfo ant ant-optional debhelper-compat default-jdk javahelper libasm-java libffi-dev libx11-dev libxt-dev maven-repo-helper pkg-config
4038
- name: macOS requirements
4139
if: contains(matrix.os, 'macos')
4240
run: |

CHANGES.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,33 @@ NOTE: as of JNA 4.0, JNA is now dual-licensed under LGPL and AL 2.0 (see LICENSE
22

33
NOTE: JNI native support is typically incompatible between minor versions, and almost always incompatible between major versions.
44

5-
Next Release (5.16.0)
5+
Next Release (5.18.0)
66
=====================
77

8+
Features
9+
--------
10+
* [#1671](https://github.com/java-native-access/jna/pull/1671): Add `isRISCV` to `c.s.j.Platform` - [@Glavo](https://github.com/Glavo).
11+
* [#1672](https://github.com/java-native-access/jna/pull/1672): Add `CFLocale`, `CFLocaleCopyCurrent`, `CFCFDateFormatter`, `CFDateFormatterStyle`, `CFDateFormatterCreate` and `CFDateFormatterGetFormat` to `c.s.j.p.mac.CoreFoundation` - [@dbwiddis](https://github.com/dbwiddis).
12+
13+
Bug Fixes
14+
---------
15+
16+
17+
Release (5.17.0)
18+
================
19+
20+
Features
21+
--------
22+
* [#1658](https://github.com/java-native-access/jna/pull/1658): Add win32 power event constants, types, and functions - [@eranl](https://github.com/eranl).
23+
24+
Bug Fixes
25+
---------
26+
* [#1647](https://github.com/java-native-access/jna/issues/1647): Fix calls to jnidispatch on Android with 16KB page size (part 2) - [@BugsBeGone](https://github.com/BugsBeGone).
27+
28+
29+
Release 5.16.0
30+
==============
31+
832
Features
933
--------
1034
* [#1626](https://github.com/java-native-access/jna/pull/1626): Add caching of field list and field validation in `Structure` along with more efficient reentrant read-write locking instead of synchronized() blocks - [@BrettWooldridge](https://github.com/brettwooldridge)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1
1+
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
22

33
Java Native Access (JNA) is licensed under the LGPL, version 2.1
44
or later, or (from version 4.0 onward) the Apache License,

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Java Native Access (JNA)
88
========================
99

10-
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://java-native-access.github.io/jna/5.15.0/javadoc/). Please read the [overview](http://java-native-access.github.io/jna/5.15.0/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
10+
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://java-native-access.github.io/jna/5.17.0/javadoc/). Please read the [overview](http://java-native-access.github.io/jna/5.17.0/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
1111

1212
JNA provides Java programs easy access to native shared libraries without writing anything but Java code - no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes.
1313

@@ -66,20 +66,20 @@ Pre-built platform support may be found [here](https://github.com/java-native-ac
6666
Download
6767
========
6868

69-
Version 5.15.0
69+
Version 5.17.0
7070

7171
JNA
7272
---
7373

74-
[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna/5.15.0/jar) [jna-5.15.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.15.0/jna-5.15.0.jar) [jna-jpms-5.15.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-jpms/5.15.0/jna-jpms-5.15.0.jar)
74+
[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna/5.17.0/jar) [jna-5.17.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.17.0/jna-5.17.0.jar) [jna-jpms-5.17.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-jpms/5.17.0/jna-jpms-5.17.0.jar)
7575

7676
This is the core artifact of JNA and contains only the binding library and the
7777
core helper classes.
7878

7979
JNA Platform
8080
------------
8181

82-
[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna-platform.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna-platform/5.15.0/jar) [jna-platform-5.15.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.15.0/jna-platform-5.15.0.jar) [jna-platform-jpms-5.15.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform-jpms/5.15.0/jna-platform-jpms-5.15.0.jar)
82+
[![Maven Central](https://img.shields.io/maven-central/v/net.java.dev.jna/jna-platform.svg?label=Maven%20Central)](https://search.maven.org/artifact/net.java.dev.jna/jna-platform/5.17.0/jar) [jna-platform-5.17.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/5.17.0/jna-platform-5.17.0.jar) [jna-platform-jpms-5.17.0.jar](https://repo1.maven.org/maven2/net/java/dev/jna/jna-platform-jpms/5.17.0/jna-platform-jpms-5.17.0.jar)
8383

8484
This artifact holds cross-platform mappings and mappings for a number of commonly used platform
8585
functions, including a large number of Win32 mappings as well as a set of utility classes
@@ -147,12 +147,12 @@ Using the Library
147147
* [Platform Library](https://github.com/java-native-access/jna/blob/master/www/PlatformLibrary.md)
148148
* [Direct Method Mapping](https://github.com/java-native-access/jna/blob/master/www/DirectMapping.md) (Optimization)
149149
* [Frequently Asked Questions (FAQ)](https://github.com/java-native-access/jna/blob/master/www/FrequentlyAskedQuestions.md)
150-
* [Avoiding Crashes](http://java-native-access.github.io/jna/5.15.0/javadoc/overview-summary.html#crash-protection)
150+
* [Avoiding Crashes](http://java-native-access.github.io/jna/5.17.0/javadoc/overview-summary.html#crash-protection)
151151

152152
Primary Documentation (JavaDoc)
153153
===============================
154154

155-
The definitive JNA reference is in the [JavaDoc](http://java-native-access.github.io/jna/5.15.0/javadoc/).
155+
The definitive JNA reference is in the [JavaDoc](http://java-native-access.github.io/jna/5.17.0/javadoc/).
156156

157157
Developers
158158
==========

build.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ osname=macosx;processor=aarch64
424424
<attribute name="Multi-Release" value="true"/>
425425
</manifest>
426426
<manifest file="@{target}" mode="update" unless:true="@{module-info}">
427+
<attribute name="ModuleMainClass" value="com.sun.jna.Native"/>
427428
<attribute name="Automatic-Module-Name" value="com.sun.jna"/>
428429
</manifest>
429430
</sequential>
@@ -433,6 +434,7 @@ osname=macosx;processor=aarch64
433434
<build-manifest target="${build}/manifest/module.mf" module-info="true"/>
434435
<build-manifest target="${build}/manifest/automatic.mf" module-info="false"/>
435436
<ModuleGenerator
437+
mainClass="com.sun.jna.Native"
436438
targetFile="${build}/manifest/module-info.class"
437439
name="com.sun.jna"
438440
version="${jna.major}.${jna.minor}.${jna.revision}"
@@ -1235,6 +1237,10 @@ cd ..
12351237
<propertyref prefix="java.awt.headless"/>
12361238
</propertyset>
12371239
<junit fork="${test.fork}" forkmode="${test.forkmode}" failureproperty="testfailure" tempdir="${build}">
1240+
<!-- let JVM ignore unknown flags -->
1241+
<jvmarg value="-XX:+IgnoreUnrecognizedVMOptions" />
1242+
<!-- enable JNI on JDK 24+ -->
1243+
<jvmarg value="--enable-native-access=ALL-UNNAMED" />
12381244
<jvmarg if:set="test.jdwp" value="${test.jdwp}" />
12391245
<!-- optionally run headless -->
12401246
<syspropertyset refid="headless"/>
@@ -1315,6 +1321,7 @@ cd ..
13151321
<javadoc package="true"
13161322
windowtitle="JNA API"
13171323
encoding="UTF-8"
1324+
locale="en_US"
13181325
sourcepathref="javadoc.src.path"
13191326
classpathref="javadoc.compile.path"
13201327
maxmemory="256m"
@@ -1343,7 +1350,16 @@ cd ..
13431350
<group title="Platform Specific" packages="com.sun.jna.platform.*"/>
13441351

13451352
<arg value="-notimestamp"/>
1353+
<!-- force locale to be "en_US", as Javadoc tool ignores locale parameter for some texts -->
1354+
<arg line="-J-Duser.language=en -J-Duser.country=US"/>
13461355
</javadoc>
1356+
<!--
1357+
Create an empty resources/fonts/dejavu.css - the file is reference by default
1358+
javadoc output, yet not provided by it. People seem to be irritated by the
1359+
generated 404, so provide an empty file.
1360+
-->
1361+
<mkdir dir="${javadoc}/resources/fonts/" />
1362+
<echo file="${javadoc}/resources/fonts/dejavu.css">/* Intentionally left empty */</echo>
13471363
<jar jarfile="${platform-javadoc-jar}" createUnicodeExtraFields="never" encoding="UTF-8">
13481364
<fileset dir="${javadoc}" />
13491365
</jar>

common.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<!-- JNA library release version - android versionCode is derived from mjar/minor/revision -->
1010
<property name="jna.major" value="5"/>
11-
<property name="jna.minor" value="16"/>
11+
<property name="jna.minor" value="18"/>
1212
<property name="jna.revision" value="0"/>
1313
<property name="jna.build" value="0"/> <!--${build.number}-->
1414
<condition property="version.suffix" value="" else="-SNAPSHOT">
@@ -22,7 +22,7 @@
2222
<!-- jnidispatch library release version -->
2323
<property name="jni.major" value="7"/>
2424
<property name="jni.minor" value="0"/>
25-
<property name="jni.revision" value="3"/>
25+
<property name="jni.revision" value="4"/>
2626
<property name="jni.build" value="0"/> <!--${build.number}-->
2727
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
2828
<property name="jni.md5" value="5fb98531302accd485c534c452dd952a"/>

contrib/platform/build.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ com.sun.jna.platform.wince;version=&quot;${osgi.version}&quot;;uses:=&quot;com.s
317317
<propertyref name="w32.ascii"/>
318318
</propertyset>
319319
<junit fork="${test.fork}" failureproperty="testfailure" tempdir="${build}">
320+
<!-- let JVM ignore unknown flags -->
321+
<jvmarg value="-XX:+IgnoreUnrecognizedVMOptions" />
322+
<!-- enable JNI on JDK 24+ -->
323+
<jvmarg value="--enable-native-access=ALL-UNNAMED" />
320324
<jvmarg if:set="test.jdwp" value="${test.jdwp}" />
321325
<!-- optionally run headless -->
322326
<syspropertyset refid="headless"/>

contrib/platform/src/com/sun/jna/platform/mac/CoreFoundation.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,4 +1142,70 @@ CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef alloc, CFIndex c
11421142
* @return The type identifier for the {@code CFString} opaque type.
11431143
*/
11441144
CFTypeID CFStringGetTypeID();
1145+
1146+
/**
1147+
* The CFLocale opaque type provides support for obtaining available locales, obtaining localized locale names, and converting among locale data formats.
1148+
*/
1149+
class CFLocale extends CFTypeRef {
1150+
}
1151+
1152+
/**
1153+
* Returns a copy of the logical locale for the current user.
1154+
* @return The logical locale for the current user that is formed from the settings for the current user’s
1155+
* chosen system locale overlaid with any custom settings the user has specified in System Preferences.
1156+
* May return a retained cached object, not a new object.
1157+
* <p>
1158+
* This reference must be released with {@link #CFRelease} to avoid leaking references.
1159+
*/
1160+
CFLocale CFLocaleCopyCurrent();
1161+
1162+
/**
1163+
* CFDateFormatter objects format the textual representations of CFDate and CFAbsoluteTime objects, and convert textual representations of dates and times into CFDate and CFAbsoluteTime objects.
1164+
*/
1165+
class CFDateFormatter extends CFTypeRef {
1166+
}
1167+
1168+
/**
1169+
* Enum of values used for {@link CFDateFormatterStyle} in {@link #CFDateFormatterCreate}.
1170+
* Use {@link CFDateFormatterStyle#index} for the expected integer value corresponding to the C-style enum.
1171+
*/
1172+
enum CFDateFormatterStyle {
1173+
kCFDateFormatterNoStyle,
1174+
kCFDateFormatterShortStyle,
1175+
kCFDateFormatterMediumStyle,
1176+
kCFDateFormatterLongStyle,
1177+
kCFDateFormatterFullStyle;
1178+
1179+
/**
1180+
* Style for the type of {@link CFDateFormatterStyle} stored.
1181+
*
1182+
* @return a {@link CFIndex} representing the enum ordinal.
1183+
*/
1184+
public CFIndex index() {
1185+
return new CFIndex(this.ordinal());
1186+
}
1187+
}
1188+
1189+
/**
1190+
* Creates a new CFDateFormatter object, localized to the given locale, which will format dates to the given date and time styles.
1191+
* @param allocator The allocator to use to allocate memory for the new object.
1192+
* Pass {@code null} or {@code kCFAllocatorDefault} to use the current default allocator.
1193+
* @param locale The locale to use for localization.
1194+
* If {@code null} uses the default system locale.
1195+
* Use {@link #CFLocaleCopyCurrent()} to specify the locale of the current user.
1196+
* @param dateStyle The date style to use when formatting dates.
1197+
* @param timeStyle The time style to use when formatting times.
1198+
* @return A new date formatter, localized to the given locale, which will format dates to the given date and time styles.
1199+
* Returns {@code null} if there was a problem creating the object.
1200+
* <p>
1201+
* This reference must be released with {@link #CFRelease} to avoid leaking references.
1202+
*/
1203+
CFDateFormatter CFDateFormatterCreate(CFAllocatorRef allocator, CFLocale locale, CFIndex dateStyle, CFIndex timeStyle);
1204+
1205+
/**
1206+
* Returns a format string for the given date formatter object.
1207+
* @param formatter The date formatter to examine.
1208+
* @return The format string for {@code formatter}.
1209+
*/
1210+
CFStringRef CFDateFormatterGetFormat(CFDateFormatter formatter);
11451211
}

contrib/platform/src/com/sun/jna/platform/win32/WinNT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,4 +4420,6 @@ public IO_COUNTERS(Pointer memory) {
44204420
class TOKEN_ELEVATION extends Structure {
44214421
public int TokenIsElevated;
44224422
}
4423+
4424+
Guid.GUID GUID_CONSOLE_DISPLAY_STATE = new Guid.GUID("6FE69556-704A-47A0-8F24-C28D936FDA47");
44234425
}

contrib/platform/src/com/sun/jna/platform/win32/WinUser.java

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.sun.jna.Structure.FieldOrder;
3131
import com.sun.jna.Union;
3232
import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR;
33-
import com.sun.jna.platform.win32.WinDef.HKL;
3433
import com.sun.jna.platform.win32.WinNT.HANDLE;
3534
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
3635
import com.sun.jna.win32.W32APITypeMapper;
@@ -2088,4 +2087,79 @@ public String toString() {
20882087
* Bitmask for the RESERVED2 key modifier.
20892088
*/
20902089
int MODIFIER_RESERVED2_MASK = 32;
2090+
2091+
class HPOWERNOTIFY extends PVOID {
2092+
public HPOWERNOTIFY() {
2093+
}
2094+
2095+
public HPOWERNOTIFY(Pointer pointer) {
2096+
super(pointer);
2097+
}
2098+
}
2099+
2100+
/**
2101+
* Registers the application to receive power setting notifications for the specific power setting event.
2102+
* @param hRecipient Handle indicating where the power setting notifications are to be sent.
2103+
* For interactive applications, the Flags parameter should be DEVICE_NOTIFY_WINDOW_HANDLE,
2104+
* and the hRecipient parameter should be a window handle.
2105+
* For services, the Flags parameter should be DEVICE_NOTIFY_SERVICE_HANDLE, and the hRecipient
2106+
* parameter should be a SERVICE_STATUS_HANDLE as returned from RegisterServiceCtrlHandlerEx.
2107+
* @param PowerSettingGuid The GUID of the power setting for which notifications are to be sent.
2108+
* @param Flags
2109+
* <li>DEVICE_NOTIFY_WINDOW_HANDLE - Notifications are sent using WM_POWERBROADCAST messages
2110+
* with a wParam parameter of PBT_POWERSETTINGCHANGE.
2111+
* <li>DEVICE_NOTIFY_SERVICE_HANDLE - Notifications are sent to the HandlerEx callback function with a dwControl
2112+
* parameter of SERVICE_CONTROL_POWEREVENT and a dwEventType of PBT_POWERSETTINGCHANGE.
2113+
* @return a notification handle for unregistering for power notifications. If the function fails, the return
2114+
* value is NULL. To get extended error information, call GetLastError.
2115+
*/
2116+
HPOWERNOTIFY RegisterPowerSettingNotification(
2117+
/*[in]*/ HANDLE hRecipient,
2118+
/*[in]*/ Guid.GUID PowerSettingGuid,
2119+
/*[in]*/ int Flags);
2120+
2121+
/**
2122+
* Unregisters the power setting notification.
2123+
* @param Handle The handle returned from the RegisterPowerSettingNotification function.
2124+
* @return If the function succeeds, the return value is nonzero.
2125+
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
2126+
*/
2127+
BOOL UnregisterPowerSettingNotification(
2128+
/*[in]*/ HPOWERNOTIFY Handle
2129+
);
2130+
2131+
int WM_POWERBROADCAST = 0x0218;
2132+
2133+
int PBT_APMQUERYSUSPEND = 0x0000;
2134+
int PBT_APMQUERYSTANDBY = 0x0001;
2135+
int PBT_APMQUERYSUSPENDFAILED = 0x0002;
2136+
int PBT_APMQUERYSTANDBYFAILED = 0x0003;
2137+
int PBT_APMSUSPEND = 0x0004;
2138+
int PBT_APMSTANDBY = 0x0005;
2139+
int PBT_APMRESUMECRITICAL = 0x0006;
2140+
int PBT_APMRESUMESUSPEND = 0x0007;
2141+
int PBT_APMRESUMESTANDBY = 0x0008;
2142+
int PBT_APMBATTERYLOW = 0x0009;
2143+
int PBT_APMPOWERSTATUSCHANGE = 0x000A;
2144+
int PBT_APMOEMEVENT = 0x000B;
2145+
int PBT_APMRESUMEAUTOMATIC = 0x0012;
2146+
int PBT_POWERSETTINGCHANGE = 0x8013;
2147+
2148+
@FieldOrder({"PowerSetting", "DataLength", "Data"})
2149+
class POWERBROADCAST_SETTING extends Structure {
2150+
public Guid.GUID PowerSetting;
2151+
public int DataLength;
2152+
public byte Data[] = new byte[1];
2153+
2154+
public POWERBROADCAST_SETTING(Pointer p) {
2155+
super(p);
2156+
read();
2157+
}
2158+
2159+
@Override
2160+
public final void read() {
2161+
Data = new byte[getPointer().getInt(fieldOffset("DataLength"))];
2162+
super.read();
2163+
}
2164+
}
20912165
}

0 commit comments

Comments
 (0)