leaningtech / cheerpj-meta

Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins.
https://labs.leaningtech.com/cheerpj
434 stars 21 forks source link

undeserved (and impossible?) NullPointerException #142

Closed ddyer0 closed 5 months ago

ddyer0 commented 2 years ago

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);
}
alexp-sssup commented 5 months ago

NPEs are not raised anymore with CheerpJ 3.0, SocketExceptions might still be raised depending on the networking setup.