Hi everyone,
In java.lang.Integer, there is the following code snippet: static final int low = -128; // 936 int size = (high - low) + 1; // 961 int j = low; // 966 When I read the java.lang.Byte source code, I noticed that there is similar logic, but the coding style is somewhat different. So I'm considering whether I could modify the Byte source code to make their styles consistent: @@ -107,6 +107,8 @@ public Optional<DynamicConstantDesc<Byte>> describeConstable() { } private static final class ByteCache { + static final byte low = -128; + private ByteCache() {} @Stable @@ -114,13 +116,13 @@ private ByteCache() {} static Byte[] archivedCache; static { - final int size = -(-128) + 127 + 1; + int size = 127 - low + 1; // Load and use the archived cache if it exists CDS.initializeFromArchive(ByteCache.class); if (archivedCache == null || archivedCache.length != size) { Byte[] c = new Byte[size]; - byte value = (byte)-128; + byte value = low; for(int i = 0; i < size; i++) { c[i] = new Byte(value++); } The same goes for java.lang.Short, java.lang.Long. Certainly, due to limited expertise, my ideas may not be reasonable. If that's the case, I sincerely request corrections, thank you! Looking forward to receiving messages from the community. On Wed, Aug 9, 2023 at 9:00 AM Erdong Ren <erdong...@gmail.com> wrote: > Hello everyone, > > My name is Ren Erdong, and I am a Java developer from China. It's a > pleasure to meet all of you, and I'm excited to join this community. > > While reading the source code of the wrapper classes, I have identified > some areas that could potentially be optimized. However, I acknowledge that > my considerations may not be comprehensive. Therefore, I would like to > initiate a discussion with all of you to gather different perspectives and > collectively explore possible optimizations. > > Actually, prior to this, I sent an email to the community, but it was > held, stating that the message body was too large. > > *If this type of email shouldn't have been sent to this community, then I > sincerely apologize. Please forgive me as a newcomer. I would appreciate > your guidance on how to handle this matter correctly. Thank you very much!* >