Class JavaElement

java.lang.Object
  |
  +--JavaElement
Direct Known Subclasses:
CodeAttribute, FieldInfo, Klass, MethodInfo, NativeRef

abstract class JavaElement
extends java.lang.Object

JavaElement is the superclass of all components of a runnable Java program.

This abstract class contains or defines the methods necessary for the decisions whether a component is needed in the resulting program. This class supports different modes of being needed, e.g. a class can be

These basic modes are ordered: a mode with a higher numeric value implies and supersedes one with a lower value.

In addition to the basic modes described above (excluding one another) there are add-on modes that can be combined with the basic modes and with one another.

Basic modes range from 0 to 255, add-on modes are bit masks from 256 upwards.


Field Summary
(package private) static int EXACT_INSTANCE_NEEDED
          needed-mode constant: instances of this class needed with byte-exact layout of all fields.
(package private) static int INSTANCE_NEEDED
          needed-mode constant: instances of this class needed.
(package private) static int NEEDED
          needed-mode constant: needed in default-mode.
(package private) static int NEEDED_INSTANCEOF
          needed-mode constant for classes: instances of other classes are checked to belong to this class.
(package private) static int NEEDED_VIRTUALLY
          needed-mode constant: method is being called virtually.
(package private)  int neededModeAddOn
          the add-on modes modifying how this element is needed.
(package private)  int neededModeBasic
          the basic mode describing how this element is needed.
(package private)  java.util.Vector neededReasons
          reasons why this element is needed.
(package private) static int UNNEEDED
          needed-mode constant: element unneeded
 
Constructor Summary
(package private) JavaElement()
           
 
Method Summary
(package private)  boolean isNeeded()
          check whether this element is needed in any mode.
(package private)  boolean isNeeded(int mode)
          check whether this element is needed at least in the specified mode.
(package private)  void markNeeded(java.lang.Object reason, int mode)
          mark this Java element needed in a specific mode, adding logically to the current mode.
(package private) abstract  void updateNeeded()
          update the 'needed'-state of all Java elements that this one depends upon.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

UNNEEDED

static final int UNNEEDED
needed-mode constant: element unneeded

NEEDED

static final int NEEDED
needed-mode constant: needed in default-mode.

INSTANCE_NEEDED

static final int INSTANCE_NEEDED
needed-mode constant: instances of this class needed.

EXACT_INSTANCE_NEEDED

static final int EXACT_INSTANCE_NEEDED
needed-mode constant: instances of this class needed with byte-exact layout of all fields.

NEEDED_VIRTUALLY

static final int NEEDED_VIRTUALLY
needed-mode constant: method is being called virtually. This is an add-on mode to be combined with UNNEEDED or NEEDED.

NEEDED_VIRTUALLY can be combined with UNNEEDED, if only subclasses of the method's class have instances and all the subclasses have their own implementation of the method. Then there's no chance that the method being called virtually is really executed - the subclass methods will be executed instead.


NEEDED_INSTANCEOF

static final int NEEDED_INSTANCEOF
needed-mode constant for classes: instances of other classes are checked to belong to this class. This is an add-on mode to be combined with NEEDED, INSTANCE_NEEDED or EXACT_INSTANCE_NEEDED.

neededModeBasic

int neededModeBasic
the basic mode describing how this element is needed.

neededModeAddOn

int neededModeAddOn
the add-on modes modifying how this element is needed.

neededReasons

java.util.Vector neededReasons
reasons why this element is needed.
Constructor Detail

JavaElement

JavaElement()
Method Detail

markNeeded

void markNeeded(java.lang.Object reason,
                int mode)
mark this Java element needed in a specific mode, adding logically to the current mode. As a side-effect, all elements that this one depends upon, are also marked 'needed' recursively.
Parameters:
reason - the reason why this element is needed (normally another Java element referencing this one).
mode - a mode constant describing how this element is needed.

isNeeded

boolean isNeeded(int mode)
check whether this element is needed at least in the specified mode.

isNeeded

boolean isNeeded()
check whether this element is needed in any mode.

updateNeeded

abstract void updateNeeded()
update the 'needed'-state of all Java elements that this one depends upon. This method must be implemented in all subclasses of JavaElement.