diff --git a/CHANGES.md b/CHANGES.md index 69ae91cca..8df24df9a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Bug Fixes --------- * [#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). * [#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). +* [#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). Important Changes ----------------- diff --git a/contrib/platform/src/com/sun/jna/platform/win32/DBT.java b/contrib/platform/src/com/sun/jna/platform/win32/DBT.java index 182c0cbf5..e2c8d27b0 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/DBT.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/DBT.java @@ -32,7 +32,7 @@ import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY; import com.sun.jna.win32.W32APITypeMapper; -import java.nio.charset.StandardCharsets; +import java.io.UnsupportedEncodingException; import java.util.logging.Logger; /** @@ -326,7 +326,13 @@ public String getDbcpName() { if(W32APITypeMapper.DEFAULT == W32APITypeMapper.ASCII) { return Native.toString(this.dbcp_name); } else { - return new String(this.dbcp_name, StandardCharsets.UTF_16LE); + try { + return new String(this.dbcp_name, "UTF-16LE"); + } catch (UnsupportedEncodingException ex) { + // UTF-16LE is documented to be present at least beginning + // with JDK 6 + throw new RuntimeException(ex); + } } } } diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java b/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java index db9373a36..e34cb3647 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java @@ -954,7 +954,7 @@ public static final String QueryFullProcessImageName(int pid, int dwFlags) { if (we == null) { we = e; } else { - we.addSuppressed(e); + we.addSuppressedReflected(e); } } if (we != null) {