reworked comment.

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1251 379699f6-c40d-0410-875b-85095c16579e
master
hoenicke 25 years ago
parent b99c87a98d
commit ff73414ef3
  1. 75
      jode/jode/decompiler/OuterValues.java

@ -30,44 +30,69 @@ import java.util.Vector;
import java.util.Enumeration; import java.util.Enumeration;
/** /**
* OuterValues are used in method scoped classes: If a method * A list of local variables that a method scoped class inherits
* scoped class uses a local of the surrounding method, the java * from its declaring method.
* compiler adds the locals to the param list of each constructor
* of the method scoped class. Each invocation of the constructor
* must give the correct values for these locals.
* *
* These extra parameters are the outerValues. * A method scoped class is a class that is declared in a method and
* it can access other (final) local variables declared earlier. To
* realize this the java compiler adds hidden parameters to the
* constructor of the method scoped class, where it passes the values
* of the local varaiables. If a method scoped class has more than
* one constructor, each gets this hidden parameters. These hidden
* parameters are the outerValues, because they are used to transport
* a value of a local variable from an outer method.
* *
* The main problem here is, that we don't know immediately if a * Unfortunately there is no definite way to distinguish this outer
* parameter is a standard parameter or a local of the outer * value parameters from the real parameters, so jode has to do a
* method. We may shrink this array if we notice a problem later. * guess: It first assumes that everything is an outer value parameter
* added by the compiler and if this leads to contradiction shrinks
* the count of these parameters. A contradiction can occur, because
* the constructor is called two times with different values.
* *
* Every class interested in outer values, may register itself * On the other hand the TransformConstructor class assumes at some
* as OuterValueListener. It will then be notified every time the * point that some parameters are outer values. If later a
* outer values shrink. * contradiction occurs, jode has to give up and complain loudly.
* *
* The outer instance of a non static _class_ scoped class is not * Every class interested in outer values, may register itself as
* considered as outer value, mainly because it can be changed. With * OuterValueListener. It will then be notified every time the outer
* jikes method scoped classes also have an outer class instance, but * values shrink. Sometimes there are real listener queues: if
* that is considered as outer value. * another method scoped class creates instances of the first in its
* constructor by passing some of its own outer value parameter, it
* may first seem that all parameters of the first class's constructor
* are outer values. Because we can't be sure that the parameter from
* the second class's constructor is really an outer value, we have to
* add a listener. If later a constructor invokation for the second
* class is found, where a parameter does not have the right outer
* value, the listener will also shrink the outer values list of the
* first class.
* *
* Under jikes anonymous classes that extends class or method scoped * A non static _class_ scoped class (i.e. a normal inner class) also
* classes have as last parameter the outer instance of the parent * has a hidden parameter, namely the instance of its outer class.
* class. This should really be the first parameter (just after the * This hidden parameter is not considered as outer value though.
* outerValues), like it is under javac. We mark such classes as * Note that you can even explicitly invoke the constructor with a
* jikesAnonymousInner. This is done in the initialize() pass. * different outer class instance, by using the
* <code>outerInstance.new InnerClass()</code> construct. This
* exception doesn't apply to method scoped classes, though.
* *
* Under javac the outer class paramter for anonymous classes that * Anonymous classes can of course also extend class or method scoped
* extends class scoped classes is at the right position, just before * classes. If they are compiled by jikes the constructor takes as
* the other parameters. * last parameter the outer instance of its super class. This should
* really be the first parameter just after the outerValues, as it
* is under javac. We mark such classes as jikesAnonymousInner. This
* is done in the initialize() pass.
* *
* @see #shrinkOuterValues * @see #shrinkOuterValues
* @see #addOuterValueListener * @see #addOuterValueListener
* @since 1.0.93 */ * @since 1.0.93
*/
public class OuterValues public class OuterValues
{ {
private ClassAnalyzer clazzAnalyzer; private ClassAnalyzer clazzAnalyzer;
/**
* The outer values. An outer value is either a
* LocalLoadOperator, a ThisOperator, or a OuterLocalOperator.
*/
private Expression[] head; private Expression[] head;
private Vector ovListeners; private Vector ovListeners;
private boolean jikesAnonymousInner; private boolean jikesAnonymousInner;

Loading…
Cancel
Save