safely-casting-long-to-int in Java

The window 'handle' parameter is normally a 'long' but it was seen as an 'int' on at least some Linux RedHat boxes. So if you have a native API to set window handle, you can use the following code to convert long to int so that the API signature does not vary between platforms:
public int longToInt(Long longVariable) 
              return Integer.valueOf(longVariable.toString());
     catch(IllegalArgumentException e) {