|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jode.decompiler.OuterValues
A list of local variables that a method scoped class inherits from its declaring method.
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.
Unfortunately there is no definite way to distinguish this outer value parameters from the real parameters, so jode has to do a 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.
On the other hand the TransformConstructor class assumes at some point that some parameters are outer values. If later a contradiction occurs, jode has to give up and complain loudly.
Every class interested in outer values, may register itself as OuterValueListener. It will then be notified every time the outer values shrink. Sometimes there are real listener queues: if 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.
A non static _class_ scoped class (i.e. a normal inner class) also
has a hidden parameter, namely the instance of its outer class.
This hidden parameter is not considered as outer value though.
Note that you can even explicitly invoke the constructor with a
different outer class instance, by using the
outerInstance.new InnerClass()
construct. This
exception doesn't apply to method scoped classes, though.
Anonymous classes can of course also extend class or method scoped classes. If they are compiled by jikes the constructor takes as 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.
addOuterValueListener(net.sf.jode.decompiler.OuterValueListener)
Constructor Summary | |
OuterValues(ClassAnalyzer ca,
Expression[] head)
|
Method Summary | |
void |
addOuterValueListener(OuterValueListener l)
|
int |
getCount()
|
Expression |
getValue(int i)
|
Expression |
getValueBySlot(int slot)
Get the outer value corresponding to a given slot. |
boolean |
isImplicitOuterClass()
Javac 1.3 doesn't give an outer class reference for anonymous classes that extend inner classes, provided the outer class is the normal this parameter. |
boolean |
isJikesAnonymousInner()
Jikes gives the outer class reference in an unusual place (as last parameter) for anonymous classes that extends an inner (or method scope) class. |
void |
setCount(int newHeadCount)
|
void |
setImplicitOuterClass(boolean value)
|
void |
setJikesAnonymousInner(boolean value)
Jikes gives the outer class reference in an unusual place (as last parameter) for anonymous classes that extends an inner (or method scope) class. |
void |
setMinCount(int newMin)
|
java.lang.String |
toString()
|
boolean |
unifyOuterValues(int nr,
Expression otherExpr)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public OuterValues(ClassAnalyzer ca, Expression[] head)
Method Detail |
public Expression getValue(int i)
public int getCount()
public Expression getValueBySlot(int slot)
public boolean unifyOuterValues(int nr, Expression otherExpr)
public boolean isJikesAnonymousInner()
public boolean isImplicitOuterClass()
public void addOuterValueListener(OuterValueListener l)
public void setJikesAnonymousInner(boolean value)
public void setImplicitOuterClass(boolean value)
public void setMinCount(int newMin)
public void setCount(int newHeadCount)
public java.lang.String toString()
|
Jode 1.90-CVS Build Aug 6, 2004 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |