org.vostok.lang.classes.bytecode
Class RawClassDecoding

java.lang.Object
  extended by org.vostok.lang.classes.bytecode.RawClassDecoding

public class RawClassDecoding
extends java.lang.Object

rawClassDecoding decode informations for a class (such as class name, interfaces, runtime annotations...), from a binary stream, a file or an url without loading it.

Getting deeping into byte code is beyond the scope of this class, you should consider tools like asm, javassist or instance the class and use reflexion instead.

Note : build on jdk1.6, target up to jdk 1.7, future features might not be recognized

Since:
1.2
Version:
0.8
Author:
levreau.jerome@vostoksystem.eu
See Also:
http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1

Nested Class Summary
protected  class RawClassDecoding.Constant
          internal use
 class RawClassDecoding.Field
          describ a field for this class
 class RawClassDecoding.Method
          describe a method signature for this class
 
Constructor Summary
RawClassDecoding(byte[] buffer)
          construct a new RawClassDecoding using plain byte array for input data
RawClassDecoding(java.io.File file)
          construct a new RawClassDecoding using an file object to a .class file (file extension not mandatory, check done by magic number)
RawClassDecoding(java.io.InputStream stream)
          construct a new RawClassDecoding object, using an InputStream for data
RawClassDecoding(java.lang.String path)
          construct a new RawClassDecoding using an absolute path to a .class file (file extension not mandatory, check done by magic number)
 
Method Summary
 int getAccess()
          return access flag for this class
 java.lang.String[] getAnnotations()
          return a simple list of class runtime annotation. can be empty but never null
 java.lang.String getBinaryClassName()
          return the binary name this class would link to.
 RawClassDecoding.Field[] getFields()
          return fields list, can be empty but neve null
 java.lang.String[] getInterfaces()
          return the interface list this class implement. can be empty but never null
 int getMajorVersion()
          return the major version number for this class
 RawClassDecoding.Method[] getMethods()
          return methods list, can be empty but never null
 int getMinorVersion()
          return the minor version for this class
 byte[] getRawData()
          return raw data this decoder is using
 java.lang.String getSuperName()
          return the binary name for the super class.
 void printDebug()
          dump to System.out a description of the raw class data.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RawClassDecoding

public RawClassDecoding(byte[] buffer)
                 throws java.lang.ClassFormatError,
                        java.lang.NullPointerException
construct a new RawClassDecoding using plain byte array for input data

Parameters:
bu -
Throws:
java.lang.ClassFormatError
java.lang.NullPointerException

RawClassDecoding

public RawClassDecoding(java.lang.String path)
                 throws java.lang.ClassFormatError,
                        java.lang.NullPointerException,
                        java.io.FileNotFoundException,
                        java.io.IOException
construct a new RawClassDecoding using an absolute path to a .class file (file extension not mandatory, check done by magic number)

Parameters:
path -
Throws:
java.lang.ClassFormatError
java.lang.NullPointerException
java.io.FileNotFoundException
java.io.IOException

RawClassDecoding

public RawClassDecoding(java.io.File file)
                 throws java.io.FileNotFoundException,
                        java.io.IOException
construct a new RawClassDecoding using an file object to a .class file (file extension not mandatory, check done by magic number)

Parameters:
file -
Throws:
java.io.FileNotFoundException
java.io.IOException

RawClassDecoding

public RawClassDecoding(java.io.InputStream stream)
                 throws java.lang.ClassFormatError,
                        java.lang.NullPointerException,
                        java.io.IOException
construct a new RawClassDecoding object, using an InputStream for data

Parameters:
stream -
Throws:
java.lang.ClassFormatError
java.lang.NullPointerException
java.io.IOException
Method Detail

getRawData

public byte[] getRawData()
return raw data this decoder is using

Returns:

getMinorVersion

public int getMinorVersion()
return the minor version for this class

Returns:

getMajorVersion

public int getMajorVersion()
return the major version number for this class

Returns:

getAccess

public int getAccess()
return access flag for this class

Returns:

getBinaryClassName

public java.lang.String getBinaryClassName()
return the binary name this class would link to.

Returns:
See Also:
ClassLoader

getSuperName

public java.lang.String getSuperName()
return the binary name for the super class. Null if none

Returns:

getInterfaces

public java.lang.String[] getInterfaces()
return the interface list this class implement. can be empty but never null

Returns:

getAnnotations

public java.lang.String[] getAnnotations()
return a simple list of class runtime annotation. can be empty but never null

Returns:

getFields

public RawClassDecoding.Field[] getFields()
return fields list, can be empty but neve null

Returns:

getMethods

public RawClassDecoding.Method[] getMethods()
return methods list, can be empty but never null

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

printDebug

public void printDebug()
dump to System.out a description of the raw class data.