This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit ce634b1e3e7c3c5dc6cad31d832da666240f023e
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Nov 27 18:02:20 2022 -0500

    Fix compiler warning
    
    Could not be an NPE previously anyway
---
 .../bcel/verifier/structurals/InstConstraintVisitor.java  | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git 
a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java 
b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
index d4ec88b5..1c92576d 100644
--- 
a/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
+++ 
b/src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
@@ -943,19 +943,18 @@ public class InstConstraintVisitor extends EmptyVisitor {
             shouldBe = Type.INT;
         }
         if (t instanceof ReferenceType) {
-            ReferenceType rValue = null;
             if (value instanceof ReferenceType) {
-                rValue = (ReferenceType) value;
+                ReferenceType rValue = (ReferenceType) value;
                 referenceTypeIsInitialized(o, rValue);
+                // TODO: This can possibly only be checked using 
Staerk-et-al's "set-of-object types", not
+                // using "wider cast object types" created during verification.
+                // Comment it out if you encounter problems. See also the 
analogon at visitPUTFIELD|visitPUTSTATIC.
+                if (!rValue.isAssignmentCompatibleWith(shouldBe)) {
+                    constraintViolated(o, "The stack top type '" + value + "' 
is not assignment compatible with '" + shouldBe + "'.");
+                }
             } else {
                 constraintViolated(o, "The stack top type '" + value + "' is 
not of a reference type as expected.");
             }
-            // TODO: This can possibly only be checked using Staerk-et-al's 
"set-of-object types", not
-            // using "wider cast object types" created during verification.
-            // Comment it out if you encounter problems. See also the analogon 
at visitPUTFIELD|visitPUTSTATIC.
-            if (!rValue.isAssignmentCompatibleWith(shouldBe)) {
-                constraintViolated(o, "The stack top type '" + value + "' is 
not assignment compatible with '" + shouldBe + "'.");
-            }
         } else if (shouldBe != value) {
             constraintViolated(o, "The stack top type '" + value + "' is not 
of type '" + shouldBe + "' as expected.");
         }

Reply via email to