Make JnaCardTerminals (not JnaTerminalFactorySpi) the owner of SCardContext.
Make JnaCardTerminals (not JnaTerminalFactorySpi) the owner of SCardContext.

Perform SCardEstablishContext in TerminalFactory.terminals() instead of the JnaTerminalFactorySpi constructor (called by TerminalFactory.getInstance). This will make it easier for the user to re-establish context when the daemon is restarted.

Also, throw EstablishContextException(JnaPCSCException) instead of IllegalStateException(JnaPCSCException), so that it is more catchable.

jnasmartcardio/jnasmartcardio,0x7678/jnasmartcardio