Open sebbASF opened 10 months ago
The synch. here appears to be unnecessary: https://github.com/java-native-access/jna/blob/365629530635440381f63939f7891456992fe91b/src/com/sun/jna/NativeLibrary.java#L186-L188
searchPaths is a ConcurrentHashMap, so does it need synch? It also does not make sense to me to synch. on the value being added, rather than the target being updated.
That guard looks unnecessary, but this might be problematic:
https://github.com/java-native-access/jna/blob/365629530635440381f63939f7891456992fe91b/src/com/sun/jna/NativeLibrary.java#L521-L529
Here is a real race and that could now (JDK8 as baseline) be fixed using ConcurrentHashMap#computeIfAbsent.
ConcurrentHashMap#computeIfAbsent
The synch. here appears to be unnecessary: https://github.com/java-native-access/jna/blob/365629530635440381f63939f7891456992fe91b/src/com/sun/jna/NativeLibrary.java#L186-L188
searchPaths is a ConcurrentHashMap, so does it need synch? It also does not make sense to me to synch. on the value being added, rather than the target being updated.