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

Encoding could/should be final #1560

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 8 additions & 7 deletions src/com/sun/jna/NativeLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ public long getSymbolAddress(long handle, String name, SymbolProvider parent) {
}
};

private Cleaner.Cleanable cleanable;
private final Cleaner.Cleanable cleanable;
private long handle;
private final String libraryName;
private final String libraryPath;
private final Map<String, Function> functions = new HashMap<String, Function>();
private final SymbolProvider symbolProvider;
final int callFlags;
private String encoding;
private final String encoding;
final Map<String, ?> options;

private static final Map<String, Reference<NativeLibrary>> libraries = new HashMap<String, Reference<NativeLibrary>>();
Expand All @@ -129,18 +129,19 @@ private NativeLibrary(String libraryName, String libraryPath, long handle, Map<S
int callingConvention = option instanceof Number ? ((Number)option).intValue() : Function.C_CONVENTION;
this.callFlags = callingConvention;
this.options = options;
this.encoding = (String)options.get(Library.OPTION_STRING_ENCODING);
String optionEncoding = (String)options.get(Library.OPTION_STRING_ENCODING);
if (optionEncoding == null) {
this.encoding = Native.getDefaultStringEncoding();
} else {
this.encoding = optionEncoding;
}
SymbolProvider optionSymbolProvider = (SymbolProvider)options.get(Library.OPTION_SYMBOL_PROVIDER);
if (optionSymbolProvider == null) {
this.symbolProvider = NATIVE_SYMBOL_PROVIDER;
} else {
this.symbolProvider = optionSymbolProvider;
}

if (this.encoding == null) {
this.encoding = Native.getDefaultStringEncoding();
}

// Special workaround for w32 kernel32.GetLastError
// Short-circuit the function to use built-in GetLastError access
if (Platform.isWindows() && "kernel32".equals(this.libraryName.toLowerCase())) {
Expand Down