rootvector2 commented on code in PR #502:
URL: https://github.com/apache/commons-bcel/pull/502#discussion_r3419446380


##########
src/test/java/org/apache/bcel/classfile/UtilityTest.java:
##########
@@ -178,4 +180,31 @@ void testSignatureToStringWithGenerics() throws Exception {
         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) {
+                throw new AssertionError(e);

Review Comment:
   done, switched both `catch` blocks to `fail(String, Throwable)`.



##########
src/test/java/org/apache/bcel/classfile/UtilityTest.java:
##########
@@ -178,4 +180,31 @@ void testSignatureToStringWithGenerics() throws Exception {
         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) {
+                throw new AssertionError(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) {
+                throw new AssertionError(e);

Review Comment:
   done here too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to