VM Spec

Contents | Prev | Next | Index | The JavaTM Virtual Machine Specification

A B C D F G I J L M N P R S T W

## baload

Operation

> Load `byte` or `boolean` from array

Format

> baload

Forms

> baload = 51 (0x33)

Operand Stack

> ..., arrayref, index ..., value

Description

> The arrayref must be of type `reference` and must refer to an array whose components are of type `byte` or of type `boolean`. The index must be of type `int`. Both arrayref and index are popped from the operand stack. If the components of the array are of type `byte`, the component of the array at index is retrieved and sign-extended to an `int` value. If the components of the array are of type `boolean`, the component of the array at index is retrieved and zero-extended to an `int` value. In either case the resulting value is pushed onto the operand stack.

Runtime Exceptions

> If arrayref is `null`, baload throws a `NullPointerException`.

> Otherwise, if index is not within the bounds of the array referenced by arrayref, the baload instruction throws an `ArrayIndex` `OutOfBoundsException`.

Notes

> The baload instruction is used to load values from both `byte` and `boolean` arrays. In Sun's implementation of the Java virtual machine, `boolean` arrays (arrays of type `T_BOOLEAN`; see §3.2 and the description of the newarray instruction in this chapter) are implemented as arrays of 8-bit values. Other implementations may implement packed `boolean` arrays; the baload instruction of such implementations must be used to access those arrays.

## bastore

Operation

> Store into `byte` or `boolean` array

Format

> bastore

Forms

> bastore = 84 (0x54)

Operand Stack

> ..., arrayref, index, value ...

Description

> The arrayref must be of type `reference` and must refer to an array whose components are of type `byte` or of type `boolean`. The index and the value must both be of type `int`. The arrayref, index, and value are popped from the operand stack. If the components of the array are of type `byte`, the `int` value is truncated to a `byte` and stored as the component of the array indexed by index. If the components of the array are of type `boolean`, the `int` value is truncated to its low order bit then zero-extended to the storage size for components of `boolean` arrays used by the implementation. The result is stored as the component of the array indexed by index.

Runtime Exceptions

> If arrayref is `null`, bastore throws a `NullPointerException`.

> Otherwise, if index is not within the bounds of the array referenced by arrayref, the bastore instruction throws an `ArrayIndexOutOfBoundsException`.

Notes

> The bastore instruction is used to store values into both `byte` and `boolean` arrays. In Sun's implementation of the Java virtual machine, `boolean` arrays (arrays of type `T_BOOLEAN`; see §3.2 and the description of the newarray instruction in this chapter) are implemented as arrays of 8-bit values. Other implementations may implement packed `boolean` arrays; in such implementations the bastore instruction must be able to store `boolean` values into packed `boolean` arrays as well as `byte` values into `byte` arrays.

## bipush

Operation

> Push `byte`

Format

> bipush
> byte

Forms

> bipush = 16 (0x10)

Operand Stack

> ... ..., value

Description

> The immediate byte is sign-extended to an `int` value. That value is pushed onto the operand stack.

Contents | Prev | Next | Index

The JavaTM Virtual Machine Specification
Copyright © 1999 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to jvm@java.sun.com