Skip to content

Commit

Permalink
Encoding could/should be final
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Nov 8, 2023
1 parent a4aca64 commit 20cbd56
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/com/sun/jna/NativeLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public long getSymbolAddress(long handle, String name, SymbolProvider parent) {
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

0 comments on commit 20cbd56

Please sign in to comment.