Skip to content

Commit ce634b1

Browse files
committed
Fix compiler warning
Could not be an NPE previously anyway
1 parent be4aec1 commit ce634b1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/main/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,19 +943,18 @@ private Field visitFieldInstructionInternals(final FieldInstruction o) throws Cl
943943
shouldBe = Type.INT;
944944
}
945945
if (t instanceof ReferenceType) {
946-
ReferenceType rValue = null;
947946
if (value instanceof ReferenceType) {
948-
rValue = (ReferenceType) value;
947+
ReferenceType rValue = (ReferenceType) value;
949948
referenceTypeIsInitialized(o, rValue);
949+
// TODO: This can possibly only be checked using Staerk-et-al's "set-of-object types", not
950+
// using "wider cast object types" created during verification.
951+
// Comment it out if you encounter problems. See also the analogon at visitPUTFIELD|visitPUTSTATIC.
952+
if (!rValue.isAssignmentCompatibleWith(shouldBe)) {
953+
constraintViolated(o, "The stack top type '" + value + "' is not assignment compatible with '" + shouldBe + "'.");
954+
}
950955
} else {
951956
constraintViolated(o, "The stack top type '" + value + "' is not of a reference type as expected.");
952957
}
953-
// TODO: This can possibly only be checked using Staerk-et-al's "set-of-object types", not
954-
// using "wider cast object types" created during verification.
955-
// Comment it out if you encounter problems. See also the analogon at visitPUTFIELD|visitPUTSTATIC.
956-
if (!rValue.isAssignmentCompatibleWith(shouldBe)) {
957-
constraintViolated(o, "The stack top type '" + value + "' is not assignment compatible with '" + shouldBe + "'.");
958-
}
959958
} else if (shouldBe != value) {
960959
constraintViolated(o, "The stack top type '" + value + "' is not of type '" + shouldBe + "' as expected.");
961960
}

0 commit comments

Comments
 (0)