Skip to content

Commit 1152bb7

Browse files
Restore JDK6 compatibility for jna-platform
1 parent c32053e commit 1152bb7

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Bug Fixes
1313
---------
1414
* [#1501](https://github.com/java-native-access/jna/pull/1501): `Library.OPTION_STRING_ENCODING` is ignore for string arguments function calls - [@matthiasblaesing](https://github.com/matthiasblaesing).
1515
* [#1504](https://github.com/java-native-access/jna/pull/1504): Increase maximum supported fixed args on varargs calls from 3 to 255 - [@andrew-nowak](https://github.com/andrew-nowak).
16+
* [#1545](https://github.com/java-native-access/jna/pull/1545): Fix Java 6 incompatibility in `c.s.j.p.win32.Kerne32Util` and `c.s.j.p.win32.DBT` - [@matthiasblaesing](https://github.com/matthiasblaesing).
1617

1718
Important Changes
1819
-----------------

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import com.sun.jna.platform.win32.WinNT.HANDLE;
3333
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
3434
import com.sun.jna.win32.W32APITypeMapper;
35-
import java.nio.charset.StandardCharsets;
35+
import java.io.UnsupportedEncodingException;
3636
import java.util.logging.Logger;
3737

3838
/**
@@ -326,7 +326,13 @@ public String getDbcpName() {
326326
if(W32APITypeMapper.DEFAULT == W32APITypeMapper.ASCII) {
327327
return Native.toString(this.dbcp_name);
328328
} else {
329-
return new String(this.dbcp_name, StandardCharsets.UTF_16LE);
329+
try {
330+
return new String(this.dbcp_name, "UTF-16LE");
331+
} catch (UnsupportedEncodingException ex) {
332+
// UTF-16LE is documented to be present at least beginning
333+
// with JDK 6
334+
throw new RuntimeException(ex);
335+
}
330336
}
331337
}
332338
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ public static final String QueryFullProcessImageName(int pid, int dwFlags) {
954954
if (we == null) {
955955
we = e;
956956
} else {
957-
we.addSuppressed(e);
957+
we.addSuppressedReflected(e);
958958
}
959959
}
960960
if (we != null) {

0 commit comments

Comments
 (0)