MCPcopy Index your code
hub / github.com/java-native-access/jna / NativeLibrary

Method NativeLibrary

src/com/sun/jna/NativeLibrary.java:123–164  ·  view source on GitHub ↗
(String libraryName, String libraryPath, long handle, Map<String, ?> options)

Source from the content-addressed store, hash-verified

121 }
122
123 @SuppressWarnings("LeakingThisInConstructor")
124 private NativeLibrary(String libraryName, String libraryPath, long handle, Map<String, ?> options) {
125 this.libraryName = getLibraryName(libraryName);
126 this.libraryPath = libraryPath;
127 this.handle = handle;
128 this.cleanable = Cleaner.getCleaner().register(this, new NativeLibraryDisposer(handle));
129 Object option = options.get(Library.OPTION_CALLING_CONVENTION);
130 int callingConvention = option instanceof Number ? ((Number)option).intValue() : Function.C_CONVENTION;
131 this.callFlags = callingConvention;
132 this.options = options;
133 SymbolProvider optionSymbolProvider = (SymbolProvider)options.get(Library.OPTION_SYMBOL_PROVIDER);
134 if (optionSymbolProvider == null) {
135 this.symbolProvider = NATIVE_SYMBOL_PROVIDER;
136 } else {
137 this.symbolProvider = optionSymbolProvider;
138 }
139
140 String encodingValue = (String) options.get(Library.OPTION_STRING_ENCODING);
141 if (encodingValue == null) {
142 encodingValue = Native.getDefaultStringEncoding();
143 }
144 this.encoding = encodingValue;
145
146 // Special workaround for w32 kernel32.GetLastError
147 // Short-circuit the function to use built-in GetLastError access
148 if (Platform.isWindows() && "kernel32".equals(this.libraryName.toLowerCase())) {
149 synchronized(functions) {
150 Function f = new Function(this, "GetLastError", Function.ALT_CONVENTION, encoding) {
151 @Override
152 Object invoke(Object[] args, Class<?> returnType, boolean b, int fixedArgs) {
153 return Integer.valueOf(Native.getLastError());
154 }
155
156 @Override
157 Object invoke(Method invokingMethod, Class<?>[] paramTypes, Class<?> returnType, Object[] inArgs, Map<String, ?> options) {
158 return Integer.valueOf(Native.getLastError());
159 }
160 };
161 functions.put(functionKey("GetLastError", callFlags, encoding), f);
162 }
163 }
164 }
165
166 private static final int DEFAULT_OPEN_OPTIONS = -1;
167 private static int openFlags(Map<String, ?> options) {

Callers

nothing calls this directly

Calls 10

getLibraryNameMethod · 0.95
getCleanerMethod · 0.95
isWindowsMethod · 0.95
functionKeyMethod · 0.95
putMethod · 0.80
registerMethod · 0.45
getMethod · 0.45
intValueMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected