jjzjj

Destroyable

全部标签

java8 : dealing with default methods

在编写加密实用程序类时,我遇到了以下方法的问题:publicstaticvoiddestroy(Keykey)throwsDestroyFailedException{if(Destroyable.class.isInstance(key)){((Destroyable)key).destroy();}}@TestpublicvoiddestroySecretKeySpec(){byte[]rawKey=newbyte[32];newSecureRandom().nextBytes(rawKey);try{destroy(newSecretKeySpec(rawKey,"AES"));