cheerpj-meta icon indicating copy to clipboard operation
cheerpj-meta copied to clipboard

undeserved (and impossible?) NullPointerException

Open ddyer0 opened this issue 3 years ago • 0 comments

I get a NullPointerException from a guaranteed non-null reference, in the code below.

public static byte[] getMACAddress()
{
try {
    InetAddress address = InetAddress.getLocalHost();
     if(address!=null)
    {
    NetworkInterface networkInterface = NetworkInterface.getByInetAddress(address);  // this is where the exception is thrown
    if(networkInterface!=null)
    {
    byte [] ad = networkInterface.getHardwareAddress();
    return(ad);
    }
}}
catch (Throwable err) { G.print("getMACAdress "+err); }
return(null);
}

ddyer0 avatar Feb 04 '22 19:02 ddyer0