Skip to main content

ConstantPool

Struct ConstantPool 

Source
pub struct ConstantPool<'a> { /* private fields */ }
Expand description

Constant pool of a class file, indexed from 1.

Long and Double constants take two slots; the second one is unusable.

See JVMS §4.4.

Implementations§

Source§

impl<'a> ConstantPool<'a>

Source

pub fn len(&self) -> usize

Returns the number of slots, including the reserved slot 0.

Source

pub fn is_empty(&self) -> bool

Returns true if the pool holds no entries.

Source

pub fn iter(&self) -> impl Iterator<Item = (CpIndex, &ConstantPoolInfo<'a>)>

Iterates over the usable entries together with their indices.

Source

pub fn get(&self, index: CpIndex) -> Result<&ConstantPoolInfo<'a>>

Returns the entry at index.

Source

pub fn class_name_index(&self, index: CpIndex) -> Result<CpIndex>

Returns the name index of the Class entry at index.

Source

pub fn utf8(&self, index: CpIndex) -> Result<Cesu8Bytes<'a>>

Returns the raw bytes of the Utf8 entry at index.

Source

pub fn str(&self, index: CpIndex) -> Result<Cow<'a, str>>

Returns the decoded Utf8 entry at index.

Source

pub fn name_and_type(&self, index: CpIndex) -> Result<(CpIndex, CpIndex)>

Returns the name and descriptor indices of the NameAndType entry at index.

Source

pub fn expect_constant_value(&self, index: CpIndex) -> Result<()>

Checks that index refers to an entry usable as a ConstantValue.

Trait Implementations§

Source§

impl Debug for ConstantPool<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ConstantPool<'a>

§

impl<'a> RefUnwindSafe for ConstantPool<'a>

§

impl<'a> Send for ConstantPool<'a>

§

impl<'a> Sync for ConstantPool<'a>

§

impl<'a> Unpin for ConstantPool<'a>

§

impl<'a> UnsafeUnpin for ConstantPool<'a>

§

impl<'a> UnwindSafe for ConstantPool<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.