This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push:
new a6dee151 Javadoc
a6dee151 is described below
commit a6dee1514cf5caf96803988ddca9b61c99726c4a
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jun 17 11:52:51 2026 +0000
Javadoc
Sort members
---
.../org/apache/bcel/classfile/UtilityTest.java | 54 +++++++++++-----------
.../apache/bcel/generic/MULTIANEWARRAYTest.java | 11 +++--
2 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/src/test/java/org/apache/bcel/classfile/UtilityTest.java
b/src/test/java/org/apache/bcel/classfile/UtilityTest.java
index 130f46fe..12ebb059 100644
--- a/src/test/java/org/apache/bcel/classfile/UtilityTest.java
+++ b/src/test/java/org/apache/bcel/classfile/UtilityTest.java
@@ -90,6 +90,33 @@ class UtilityTest {
}
}
+ @Test
+ void testCodeToStringWideIsThreadLocal() throws Exception {
+ // A WIDE opcode disassembled on one thread must not change how the
next
+ // local-variable instruction is decoded on another thread.
+ final Thread setter = new Thread(() -> {
+ try {
+ Utility.codeToString(new ByteSequence(new byte[] {(byte)
Const.WIDE}), new ConstantPool(), false);
+ } catch (final Exception e) {
+ fail("WIDE disassembly failed", e);
+ }
+ });
+ setter.start();
+ setter.join();
+ final AtomicReference<String> reader = new AtomicReference<>();
+ final Thread thread = new Thread(() -> {
+ try {
+ // iload with a single index byte; the trailing 0x02 must stay
unread.
+ reader.set(Utility.codeToString(new ByteSequence(new byte[]
{(byte) Const.ILOAD, 1, 2}), new ConstantPool(), false));
+ } catch (final Exception e) {
+ fail("iload disassembly failed", e);
+ }
+ });
+ thread.start();
+ thread.join();
+ assertEquals("iload\t\t%1", reader.get());
+ }
+
@Test
void testConvertString() {
assertEquals("\\n", Utility.convertString("\n"));
@@ -181,31 +208,4 @@ class UtilityTest {
assertEquals("<K extends Object, V extends Object> extends Object",
Utility.signatureToString("<K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/lang/Object;"),
"class signature");
}
-
- @Test
- void testCodeToStringWideIsThreadLocal() throws Exception {
- // A WIDE opcode disassembled on one thread must not change how the
next
- // local-variable instruction is decoded on another thread.
- final Thread setter = new Thread(() -> {
- try {
- Utility.codeToString(new ByteSequence(new byte[] {(byte)
Const.WIDE}), new ConstantPool(), false);
- } catch (final Exception e) {
- fail("WIDE disassembly failed", e);
- }
- });
- setter.start();
- setter.join();
- final AtomicReference<String> reader = new AtomicReference<>();
- final Thread thread = new Thread(() -> {
- try {
- // iload with a single index byte; the trailing 0x02 must stay
unread.
- reader.set(Utility.codeToString(new ByteSequence(new byte[]
{(byte) Const.ILOAD, 1, 2}), new ConstantPool(), false));
- } catch (final Exception e) {
- fail("iload disassembly failed", e);
- }
- });
- thread.start();
- thread.join();
- assertEquals("iload\t\t%1", reader.get());
- }
}
diff --git a/src/test/java/org/apache/bcel/generic/MULTIANEWARRAYTest.java
b/src/test/java/org/apache/bcel/generic/MULTIANEWARRAYTest.java
index c991319b..986f241e 100644
--- a/src/test/java/org/apache/bcel/generic/MULTIANEWARRAYTest.java
+++ b/src/test/java/org/apache/bcel/generic/MULTIANEWARRAYTest.java
@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.bcel.generic;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -24,16 +25,20 @@ import org.apache.bcel.Const;
import org.apache.bcel.util.ByteSequence;
import org.junit.jupiter.api.Test;
+/**
+ * Tests {@link MULTIANEWARRAY}.
+ *
+ * @see <a
href="https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-4.html#jvms-4.10.1.9.multianewarray">JVM
MULTIANEWARRAY specification</a>
+ */
class MULTIANEWARRAYTest {
/**
- * The {@code dimensions} operand of {@code multianewarray} is an unsigned
byte (1-255), so a value above 127 must not be
- * read as a negative number.
+ * The {@code dimensions} operand of {@code multianewarray} is an unsigned
byte (1-255), so a value above 127 must not be read as a negative number.
*/
@Test
void testInitFromFileReadsDimensionsUnsigned() throws Exception {
// multianewarray, index 0x0005, dimensions 0xC8 (200)
- final byte[] code = {(byte) Const.MULTIANEWARRAY, 0x00, 0x05, (byte)
0xC8};
+ final byte[] code = { (byte) Const.MULTIANEWARRAY, 0x00, 0x05, (byte)
0xC8 };
try (ByteSequence bytes = new ByteSequence(code)) {
final MULTIANEWARRAY instruction = (MULTIANEWARRAY)
Instruction.readInstruction(bytes);
assertEquals(200, instruction.getDimensions());