Skip to main content

Class

Struct Class 

Source
pub struct Class<'a> {
    pub minor_version: u16,
    pub major_version: u16,
    pub constant_pool: ConstantPool<'a>,
    pub access_flags: ClassAccessFlags,
    pub this_class: CpIndex,
    pub super_class: Option<CpIndex>,
    pub interfaces: Vec<CpIndex>,
    pub fields: Vec<FieldInfo<'a>>,
    pub methods: Vec<MethodInfo<'a>>,
    pub attributes: Vec<AttributeInfo<'a>>,
}
Expand description

A parsed class file, borrowing from the bytes it was read from.

See JVMS §4.1.

Fields§

§minor_version: u16§major_version: u16§constant_pool: ConstantPool<'a>§access_flags: ClassAccessFlags§this_class: CpIndex§super_class: Option<CpIndex>§interfaces: Vec<CpIndex>§fields: Vec<FieldInfo<'a>>§methods: Vec<MethodInfo<'a>>§attributes: Vec<AttributeInfo<'a>>

Implementations§

Source§

impl<'a> Class<'a>

Source

pub fn parse(bytes: &'a [u8]) -> Result<Self>

Parses a complete class file, rejecting any trailing bytes.

Source

pub fn try_read(cursor: &mut Cursor<'a>) -> Result<Self>

Reads a class file from cursor, leaving whatever follows it untouched.

Source

pub fn name(&self) -> Result<Cow<'a, str>>

Returns the internal name of this class, e.g. java/lang/String.

Source

pub fn signature( &self, constant_pool: &ConstantPool<'a>, ) -> Result<Option<Cow<'a, str>>>

Returns the generic signature from the Signature attribute, if present.

Source

pub fn inner_classes(&self) -> Result<Option<&Vec<InnerClass>>>

Returns the InnerClasses attribute entries, if present.

Trait Implementations§

Source§

impl<'a> Debug for Class<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Class<'a>

§

impl<'a> RefUnwindSafe for Class<'a>

§

impl<'a> Send for Class<'a>

§

impl<'a> Sync for Class<'a>

§

impl<'a> Unpin for Class<'a>

§

impl<'a> UnsafeUnpin for Class<'a>

§

impl<'a> UnwindSafe for Class<'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.