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

# multianewarray

A *multianewarray* instruction with operands `CP` and `Dim` is type safe iff `CP` refers to a constant pool entry denoting an array type whose dimension is greater or equal to `Dim`, `Dim` is strictly positive, and one can validly replace `Dim` `int` types on the incoming operand stack with the type denoted by `CP` yielding the outgoing type state.

```
instructionIsTypeSafe(multianewarray(CP, Dim), Environment, _Offset,
                      StackFrame, NextStackFrame, ExceptionStackFrame) :-
    CP = arrayOf(_),
    classDimension(CP, Dimension),
    Dimension >= Dim,
    Dim > 0,
    /* Make a list of Dim ints */
    findall(int, between(1, Dim, _), IntList),
    validTypeTransition(Environment, IntList, CP,
                        StackFrame, NextStackFrame),
    exceptionStackFrame(StackFrame, ExceptionStackFrame).
```

The dimension of an array type whose component type is also an array type is one more than the dimension of its component type.

```
classDimension(arrayOf(X), Dimension) :-
    classDimension(X, Dimension1),
    Dimension is Dimension1 + 1.

classDimension(_, Dimension) :-
    Dimension = 0.
```
