DeviceImpl (USB bus, String drivername, int a)
    throws IOException, SecurityException
    {
        super (null, bus, a);

        usb = bus;
        path = drivername;//f.getPath ();

        if(MacOSX.trace)
            System.err.println("in usb.macosx.DeviceImpl()\n");
        // should only fail if the device unplugged before
        // we opened it, or permissions were bogus, or ...
        long openstat = openNative (path);
        if (openstat < 0) {
            String  message = "JUSB can't open device r/w, " + path;
            throw new USBException (message, (int)(-openstat));
        } else {
            fd = (int)openstat;  //openNative() returns a DLL device handle between 1 & 127 on success
        }

        int num_descriptor_retries = 0;
        IOException descriptor_exception = null;
        do {
                // fd's open; NOW we can get the device descriptor
                try {
                        byte buf [];

                        buf = ControlMessage.getStandardDescriptor (this,
                                                                                                                Descriptor.TYPE_DEVICE, (byte) 0, 0, 18);
                        descriptor = new DeviceDescriptor (this, buf);
                        // ... and configuration descriptor
                        getConfiguration ();

                        if (MacOSX.trace)
                                System.err.println ("new: " + path);
                        return;
                } catch (USBException ue) {
                        if (MacOSX.debug)
                                ue.printStackTrace ();
                        else if(MacOSX.trace)
                                System.err.println ("get dev descr fail:  "
                                                                        + path
                                                                        + ", "
                                                                        + ue.getMessage ());
                        descriptor_exception = ue;
                } catch (IOException e) {
                        if (MacOSX.debug)
                                System.err.println ("get dev descr fail:  "
                                                                        + path
                                                                        + ", "
                                                                        + e.getMessage ());
                        throw e;
                }
        } while ( num_descriptor_retries++ < 4 );
        throw descriptor_exception;
    }