@@ -101,9 +101,9 @@ public long getSymbolAddress(long handle, String name, SymbolProvider parent) {
101
101
private final String libraryPath ;
102
102
private final Map <String , Function > functions = new HashMap <>();
103
103
private final SymbolProvider symbolProvider ;
104
- final int callFlags ;
105
- private String encoding ;
106
- final Map <String , ?> options ;
104
+ private final int callFlags ;
105
+ private final String encoding ;
106
+ private final Map <String , ?> options ;
107
107
108
108
private static final Map <String , Reference <NativeLibrary >> libraries = new HashMap <>();
109
109
@@ -120,6 +120,7 @@ private static String functionKey(String name, int flags, String encoding) {
120
120
return name + "|" + flags + "|" + encoding ;
121
121
}
122
122
123
+ @ SuppressWarnings ("LeakingThisInConstructor" )
123
124
private NativeLibrary (String libraryName , String libraryPath , long handle , Map <String , ?> options ) {
124
125
this .libraryName = getLibraryName (libraryName );
125
126
this .libraryPath = libraryPath ;
@@ -129,17 +130,18 @@ private NativeLibrary(String libraryName, String libraryPath, long handle, Map<S
129
130
int callingConvention = option instanceof Number ? ((Number )option ).intValue () : Function .C_CONVENTION ;
130
131
this .callFlags = callingConvention ;
131
132
this .options = options ;
132
- this .encoding = (String )options .get (Library .OPTION_STRING_ENCODING );
133
133
SymbolProvider optionSymbolProvider = (SymbolProvider )options .get (Library .OPTION_SYMBOL_PROVIDER );
134
134
if (optionSymbolProvider == null ) {
135
135
this .symbolProvider = NATIVE_SYMBOL_PROVIDER ;
136
136
} else {
137
137
this .symbolProvider = optionSymbolProvider ;
138
138
}
139
139
140
- if (this .encoding == null ) {
141
- this .encoding = Native .getDefaultStringEncoding ();
140
+ String encodingValue = (String ) options .get (Library .OPTION_STRING_ENCODING );
141
+ if (encodingValue == null ) {
142
+ encodingValue = Native .getDefaultStringEncoding ();
142
143
}
144
+ this .encoding = encodingValue ;
143
145
144
146
// Special workaround for w32 kernel32.GetLastError
145
147
// Short-circuit the function to use built-in GetLastError access
0 commit comments