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

Safe HaskellNone
LanguageHaskell2010

Language.JVM.ClassFileReader

Contents

Synopsis

Documentation

readClassFile :: ByteString -> Either ClassFileError (ClassFile High) Source #

Top level command that combines decode and evolve.

writeClassFile :: ClassFile High -> ByteString Source #

Top level command that combines devolve and encode.

writeClassFile' :: ConstantPool Low -> ClassFile High -> ByteString Source #

Top level command that combines devolve and encode, but tries to retain exact syntax of a previous run using the class pool.

Finer granularity commands

decodeClassFile :: ByteString -> Either ClassFileError (ClassFile Low) Source #

Decode a class file from a lazy ByteString. Ensures that the lazy bytestring is read to EOF, and thereby closing any open files.

encodeClassFile :: ClassFile Low -> ByteString Source #

Create a lazy byte string from a class file

evolveClassFile :: ((AttributeLocation, Text) -> Bool) -> ClassFile Low -> Either ClassFileError (ClassFile High) Source #

Evolve the class file to inline the references. A filter function is provided to remove some attributes. This will sometimes give faster loading times.

devolveClassFile :: ClassFile High -> ClassFile Low Source #

Devolve a ClassFile from High to Low. This might make the ClassFile contain invalid attributes, since we can't read all attributes. If this this is a problem see devolveClassFile'.

devolveClassFile' :: ConstantPool Low -> ClassFile High -> ClassFile Low Source #

Devolve a ClassFile form High to Low, while maintaining the class pool of the original class file. This is useful if we care that unread attributes are still valid. This can cause untended bloat as we do not want to throw away anything in the program

Helpers

roundtripCopy :: FilePath -> FilePath -> IO () Source #

A test function, essentially reading the classfile and then writing it to another file.

Evolve

data Evolve a Source #

Instances
Monad Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Methods

(>>=) :: Evolve a -> (a -> Evolve b) -> Evolve b #

(>>) :: Evolve a -> Evolve b -> Evolve b #

return :: a -> Evolve a #

fail :: String -> Evolve a #

Functor Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Methods

fmap :: (a -> b) -> Evolve a -> Evolve b #

(<$) :: a -> Evolve b -> Evolve a #

Applicative Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Methods

pure :: a -> Evolve a #

(<*>) :: Evolve (a -> b) -> Evolve a -> Evolve b #

liftA2 :: (a -> b -> c) -> Evolve a -> Evolve b -> Evolve c #

(*>) :: Evolve a -> Evolve b -> Evolve b #

(<*) :: Evolve a -> Evolve b -> Evolve a #

EvolveM Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

LabelM Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Methods

label :: String -> Evolve a -> Evolve a Source #

MonadReader EvolveConfig Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

MonadError ClassFileError Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

data ClassFileError Source #

An error while reading a class file is represented using this data structure

Instances
Eq ClassFileError Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Show ClassFileError Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Generic ClassFileError Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Associated Types

type Rep ClassFileError :: Type -> Type #

NFData ClassFileError Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Methods

rnf :: ClassFileError -> () #

MonadError ClassFileError Evolve Source # 
Instance details

Defined in Language.JVM.ClassFileReader

type Rep ClassFileError Source # 
Instance details

Defined in Language.JVM.ClassFileReader

bootstrapConstantPool :: ConstantPool Low -> Either ClassFileError (ConstantPool High) Source #

Untie the constant pool, this requires a special operation as the constant pool might reference itself.

Builder

data ConstantPoolBuilder a Source #

Instances
Monad ConstantPoolBuilder Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Functor ConstantPoolBuilder Source # 
Instance details

Defined in Language.JVM.ClassFileReader

Applicative ConstantPoolBuilder Source # 
Instance details

Defined in Language.JVM.ClassFileReader

DevolveM ConstantPoolBuilder Source # 
Instance details

Defined in Language.JVM.ClassFileReader

LabelM ConstantPoolBuilder Source # 
Instance details

Defined in Language.JVM.ClassFileReader

MonadState CPBuilder ConstantPoolBuilder Source # 
Instance details

Defined in Language.JVM.ClassFileReader