You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code as is from test ExampleApp.java returns error:
Exception in thread "main" java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;
at com.eatthepath.otp.HmacOneTimePasswordGenerator.generateOneTimePassword(HmacOneTimePasswordGenerator.java:140)
at com.eatthepath.otp.TimeBasedOneTimePasswordGenerator.generateOneTimePassword(TimeBasedOneTimePasswordGenerator.java:143)
at com.eatthepath.otp.TimeBasedOneTimePasswordGenerator.generateOneTimePasswordString(TimeBasedOneTimePasswordGenerator.java:175)
at com.eatthepath.otp.TimeBasedOneTimePasswordGenerator.generateOneTimePasswordString(TimeBasedOneTimePasswordGenerator.java:160)
at simple.ExampleApp.main(ExampleApp.java:30)
packagesimple;
importjavax.crypto.KeyGenerator;
importcom.eatthepath.otp.TimeBasedOneTimePasswordGenerator;
importjava.security.InvalidKeyException;
importjava.security.Key;
importjava.security.NoSuchAlgorithmException;
importjava.time.Instant;
publicclassExampleApp {
publicstaticvoidmain(finalString[] args) throwsNoSuchAlgorithmException, InvalidKeyException {
finalTimeBasedOneTimePasswordGeneratortotp = newTimeBasedOneTimePasswordGenerator();
finalKeykey;
{
finalKeyGeneratorkeyGenerator = KeyGenerator.getInstance(totp.getAlgorithm());
// Key length should match the length of the HMAC output (160 bits for SHA-1, 256 bits// for SHA-256, and 512 bits for SHA-512).keyGenerator.init(160);
key = keyGenerator.generateKey();
}
finalInstantnow = Instant.now();
finalInstantlater = now.plus(totp.getTimeStep());
System.out.println("Current password: " + totp.generateOneTimePasswordString(key, now));
System.out.println("Future password: " + totp.generateOneTimePasswordString(key, later));
}
}
I am unable to reproduce the problem and strongly, strongly suspect some kind of JVM. java.nio.ByteBuffer.clear() has been part of the JDK since Java 7.
I'm going to move this to a discussion because it appears to be a request for general support rather than a bug report or feature request.
Repository owner locked and limited conversation to collaborators on Sep 21, 2021
Activity
vitsin commentedon Sep 21, 2021
Running on Java 1.8.0 u281
jchambers commentedon Sep 21, 2021
I am unable to reproduce the problem and strongly, strongly suspect some kind of JVM.
java.nio.ByteBuffer.clear()has been part of the JDK since Java 7.I'm going to move this to a discussion because it appears to be a request for general support rather than a bug report or feature request.