为什么以下列方式初始化此缓冲区?

问题描述 投票:1回答:3

我可以在javax.crypto.CipherInputStream中看到以下初始化(第77行)

private byte[] ibuffer = new byte['Ȁ'];

Ȁ是什么意思,为什么缓冲区以这种方式初始化?

java initialization declaration
3个回答
1
投票

从这个源代码:javax/crypto/CipherInputStream.java,这个数组初始化为

 /* the buffer holding data that have been read in from the
  underlying stream, but have not been processed by the cipher
  engine. the size 512 bytes is somewhat randomly chosen */

 private byte[] ibuffer = new byte[512];

512是字符'Ȁ'的整数值,因此它是相同的初始化。

尝试:System.out.println((char) 512);


2
投票

这是一个char转换为int。值为512


0
投票

这是反编译器的一个问题,它们只查看字节码并尝试重建源代码。

如果您查看javax.crypto.CipherInputStream (Line 77)中的原始源,您将看到该行最初

 private byte[] ibuffer = new byte[512];

'Ȁ'的类型为char,如果你把它转换为int,它的值为512.你的反编译器重建了一种可能的方法来生成那个字节码 - 但在这种情况下,没有理智的程序员会这样写它(除了打高尔夫球时)或故意混淆代码)。

© www.soinside.com 2019 - 2024. All rights reserved.