Skip to content

Commit

Permalink
Restore JDK6 compatibility for jna-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblaesing committed Aug 8, 2023
1 parent c32053e commit 1152bb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------
Expand Down
10 changes: 8 additions & 2 deletions contrib/platform/src/com/sun/jna/platform/win32/DBT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1152bb7

Please sign in to comment.