jvm-binary-0.0.2: A library for reading Java class-files

Copyright(c) Christian Gram Kalhauge 2017
LicenseMIT
Maintainerkalhuage@cs.ucla.edu
Safe HaskellSafe
LanguageHaskell2010

Language.JVM.Constant

Contents

Description

This module contains the Constant type and the ConstantPool. These are essential for accessing data in the class-file.

Synopsis

Constant

constantSize :: Constant -> Int Source #

Some of the Constants take up more space in the constant pool than other. Notice that String and MethodType is not of size 32, but is still awarded value 1. This is due to an inconsistency in JVM.

newtype ConstantRef Source #

A constant is referenced by the ConstantRef data type. It is just a 16 bit word, but wrapped for type safety.

Constructors

ConstantRef Word16 

Instances

Constant Pool

The ConstantPool contains all the constants, and is accessible using the Lookup methods.

newtype ConstantPool Source #

A ConstantPool is just an IntMap. A IntMap is used, because constants are accessed after their byte-offset. constantSize

Constructors

ConstantPool 

lookupText :: ConstantRef -> ConstantPool -> Maybe Text Source #

Lookup a Text in the ConstantPool, returns Nothing if the reference does not point to something in the ConstantPool, if it points to something not a String Constant, or if it is impossible to decode the ByteString as Utf8.

lookupClassName :: ConstantRef -> ConstantPool -> Maybe Text Source #

Lookup a class name in the ConstantPool, returns Nothing otherwise.

toListOfConstants :: ConstantPool -> [(ConstantRef, Constant)] Source #

Return a list of reference-constant pairs.