Skip to content

Commit 32fa2ca

Browse files
committed
Correct JML cast error in KeyBlob.toByteArray()
1 parent 9d5e139 commit 32fa2ca

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/main/java/com/amazonaws/encryptionsdk/model/KeyBlob.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,13 +487,11 @@ public int deserialize(final byte[] b, final int off) {
487487
//@ assignable \nothing;
488488
//@ ensures \fresh(\result);
489489
//@ ensures \result.length == 3 * Short.BYTES + providerId.length + providerInformation.length + encryptedDataKey.length;
490+
//@ code_java_math // necessary, or else casts to short are warnings
490491
public byte[] toByteArray() {
491492
final int outLen = 3 * (Short.SIZE / Byte.SIZE) + keyProviderIdLen_ + keyProviderInfoLen_ + encryptedKeyLen_;
492493
final ByteBuffer out = ByteBuffer.allocate(outLen);
493494

494-
//@ // JML bug: it treats it as an error to cast a value too large to be
495-
//@ // a signed short (but small enough to be an unsigned short) to short
496-
//@ // see https://github.com/OpenJML/OpenJML/issues/649
497495
out.putShort((short) keyProviderIdLen_);
498496
out.put(keyProviderId_, 0, keyProviderIdLen_);
499497

0 commit comments

Comments
 (0)