@@ -221,7 +221,7 @@ static boolean isCompatibleVersion(String expectedVersion, String nativeVersion)
221221 loadNativeDispatchLibrary ();
222222
223223 if (! isCompatibleVersion (VERSION_NATIVE , getNativeVersion ())) {
224- String LS = System .getProperty ( "line.separator" );
224+ String LS = System .lineSeparator ( );
225225 throw new Error (LS + LS
226226 + "There is an incompatible JNA native library installed on this system" + LS
227227 + "Expected: " + VERSION_NATIVE + LS
@@ -397,11 +397,7 @@ private static Charset getCharset(String encoding) {
397397 try {
398398 charset = Charset .forName (encoding );
399399 }
400- catch (IllegalCharsetNameException e ) {
401- LOG .log (Level .WARNING , "JNA Warning: Encoding ''{0}'' is unsupported ({1})" ,
402- new Object []{encoding , e .getMessage ()});
403- }
404- catch (UnsupportedCharsetException e ) {
400+ catch (IllegalCharsetNameException | UnsupportedCharsetException e ) {
405401 LOG .log (Level .WARNING , "JNA Warning: Encoding ''{0}'' is unsupported ({1})" ,
406402 new Object []{encoding , e .getMessage ()});
407403 }
@@ -517,7 +513,7 @@ public static List<String> toStringList(char[] buf) {
517513 * @return A {@link List} of all the strings in the buffer
518514 */
519515 public static List <String > toStringList (char [] buf , int offset , int len ) {
520- List <String > list = new ArrayList <String >();
516+ List <String > list = new ArrayList <>();
521517 int lastPos = offset ;
522518 int maxPos = offset + len ;
523519 for (int curPos = offset ; curPos < maxPos ; curPos ++) {
@@ -691,7 +687,7 @@ private static void loadLibraryInstance(Class<?> cls) {
691687 && Modifier .isStatic (field .getModifiers ())) {
692688 // Ensure the field gets initialized by reading it
693689 field .setAccessible (true ); // interface might be private
694- libraries .put (cls , new WeakReference <Object >(field .get (null )));
690+ libraries .put (cls , new WeakReference <>(field .get (null )));
695691 break ;
696692 }
697693 }
@@ -785,7 +781,7 @@ public static Map<String, Object> getLibraryOptions(Class<?> type) {
785781 throw new IllegalArgumentException ("OPTIONS must be a public field of type java.util.Map (" + e + "): " + mappingClass );
786782 }
787783 // Make a clone of the original options
788- libraryOptions = new HashMap <String , Object >(libraryOptions );
784+ libraryOptions = new HashMap <>(libraryOptions );
789785 if (!libraryOptions .containsKey (Library .OPTION_TYPE_MAPPER )) {
790786 libraryOptions .put (Library .OPTION_TYPE_MAPPER , lookupField (mappingClass , "TYPE_MAPPER" , TypeMapper .class ));
791787 }
@@ -1552,8 +1548,8 @@ public static void setCallbackThreadInitializer(Callback cb, CallbackThreadIniti
15521548 CallbackReference .setCallbackThreadInitializer (cb , initializer );
15531549 }
15541550
1555- private static final Map <Class <?>, long []> registeredClasses = new WeakHashMap <Class <?>, long [] >();
1556- private static final Map <Class <?>, NativeLibrary > registeredLibraries = new WeakHashMap <Class <?>, NativeLibrary >();
1551+ private static final Map <Class <?>, long []> registeredClasses = new WeakHashMap <>();
1552+ private static final Map <Class <?>, NativeLibrary > registeredLibraries = new WeakHashMap <>();
15571553
15581554 private static void unregisterAll () {
15591555 synchronized (registeredClasses ) {
@@ -1786,7 +1782,7 @@ public static void register(Class<?> cls, String libName) {
17861782 // method name, library name, call conv
17871783 public static void register (Class <?> cls , NativeLibrary lib ) {
17881784 Method [] methods = cls .getDeclaredMethods ();
1789- List <Method > mlist = new ArrayList <Method >();
1785+ List <Method > mlist = new ArrayList <>();
17901786 Map <String , ?> options = lib .getOptions ();
17911787 TypeMapper mapper = (TypeMapper ) options .get (Library .OPTION_TYPE_MAPPER );
17921788 boolean allowObjects = Boolean .TRUE .equals (options .get (Library .OPTION_ALLOW_OBJECTS ));
@@ -1926,11 +1922,11 @@ public static void register(Class<?> cls, NativeLibrary lib) {
19261922 * looking them up later.
19271923 */
19281924 private static Map <String , Object > cacheOptions (Class <?> cls , Map <String , ?> options , Object proxy ) {
1929- Map <String , Object > libOptions = new HashMap <String , Object >(options );
1925+ Map <String , Object > libOptions = new HashMap <>(options );
19301926 libOptions .put (_OPTION_ENCLOSING_LIBRARY , cls );
19311927 typeOptions .put (cls , libOptions );
19321928 if (proxy != null ) {
1933- libraries .put (cls , new WeakReference <Object >(proxy ));
1929+ libraries .put (cls , new WeakReference <>(proxy ));
19341930 }
19351931
19361932 // If it's a direct mapping, AND implements a Library interface,
0 commit comments