---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 27 Edition"
java_version: 27
chapter: "Chapter 4. The class File Format"
section: "4.10.1.9.ifnonnull"
heading: "ifnonnull, ifnull"
parent: "4.10.1.9. Type Checking Instructions"
source: https://docs.oracle.com/javase/specs/jvms/se27/html/jvms-4.html#jvms-4.10.1.9.ifnonnull
id: "4.10.1.9.ifnonnull"
url: https://jvm.obfuscated.software/jvms/se27/4.10.1.9.ifnonnull.html
raw: https://jvm.obfuscated.software/jvms/se27/4.10.1.9.ifnonnull.md
---

# ifnonnull, ifnull

An *ifnonnull* instruction is type safe iff one can validly pop a type matching `Object` off the incoming operand stack yielding the outgoing type state `NextStackFrame`, and the operand of the instruction, `Target`, is a valid branch target assuming an incoming type state of `NextStackFrame`.

```
instructionIsTypeSafe(ifnonnull(Target), Environment, _Offset, StackFrame,
                      NextStackFrame, ExceptionStackFrame) :-
    isBootstrapLoader(BL),
    canPop(StackFrame, [class('java/lang/Object', BL)], NextStackFrame),
    targetIsTypeSafe(Environment, NextStackFrame, Target),
    exceptionStackFrame(StackFrame, ExceptionStackFrame).
```

An *ifnull* instruction is type safe iff the equivalent *ifnonnull* instruction is type safe.

```
instructionHasEquivalentTypeRule(ifnull(Target), ifnonnull(Target)).
```
