Jode 1.90-CVS
Build Aug 6, 2004

Package net.sf.jode.bytecode

Provides easy access to class files and their contents.

See:
          Description

Interface Summary
Opcodes This is an interface containing the constants for the byte code opcodes.
 

Class Summary
BasicBlocks Represents the byte code of a method in form of basic blocks.
BinaryInfo Represents a container for user specified attributes.
Block Represents a single basic block.
ClassInfo Represents a class or interface.
ClassPath A path in which class files are searched for.
ClassPath.Location A location is a single component of the ClassPath.
ConstantPool This class represent the constant pool.
FieldInfo Represents a java bytecode field (class variable).
GrowableConstantPool This class represent a constant pool, where new constants can be added to.
Handler A simple class containing the info about one try-catch block.
Instruction This class represents an instruction in the byte code.
LocalVariableInfo A simple class containing the info of the LocalVariableTable.
MethodInfo Represents a java bytecode method.
Reference This class represents a field or method reference.
TypeSignature This class contains some static methods to handle type signatures.
 

Exception Summary
ClassFormatException Thrown when a class file with an unknown or illegal format is loaded.
 

Package net.sf.jode.bytecode Description

Provides easy access to class files and their contents. To use it you create a ClassPath object giving it the locations where it should search for classes. Then you can ask this object for a class and get a ClassInfo object. As third step you can actually load the class.

Please notify me if you want to use this package. I will inform you about updates, help you with problems, etc. WARNING: Some parts of this package may change in the future in incompatible ways. Ask me for more information.

Here is a short example, how you can use this package, see the documentation of the classes for more details.

 ...
 ClassPath path = new ClassPath("/usr/lib/java/lib/classes.zip");
 ClassInfo clazz = path.getClassInfo("java.util.Hashtable");

 try {
   clazz.load(ClassInfo.DECLARATIONS);
 } catch (ClassFormatException ex) {
   System.err.println("Something is wrong with HashTable, giving up!");
   return;
 } catch (IOException ex) {
   System.err.println("Can't load HashTable, giving up!");
   return;
 }

 MethodInfo[] methods = clazz.getMethods();
 for (int i = 0; i < methods.length; i++) {
     String type = methods[i].getType();
     if (TypeSignature.getReturnType(type) == TypeSignature.INT_TYPE)
         System.out.println("Found integer method: "+method.getName());
 }
 ...
You can also use this package to create and write new classes:
 ...
 ClassPath path = new ClassPath("/usr/lib/java/lib/classes.zip");
 ClassInfo clazz = path.getClassInfo("my.new.Class");
 clazz.setModifiers(Modifier.PUBLIC);
 clazz.setSourceFile("Class.pl");
 clazz.set...
 clazz.write(zipOutputStream);
 ...

Advantages of this bytecode package

Disadvantages


Jochen Hoenicke
Last modified: Sat Aug 11 18:44:19 MEST 2001


Jode 1.90-CVS
Build Aug 6, 2004

Copyright © 1998-2004 by Jochen Hoenicke.