Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore JDK6 compatibility for jna-platform #1545

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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