You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Andrew Cornwall <an...@gmail.com> on 2008/01/24 20:03:33 UTC
[classlib][pack200] Computing inner classes
I'm in the process of looking at inner classes. The pack200 spec has an
algorithm for calculating which classes are relevant for a specific class.
Part of that algorithm is:
- ic_Relevant(X) is initially empty.
- Every four-tuple from ic_All which mentions the current class
(defined by X) as an outer class is added to ic_Relevant(X).
- For every class constant K referenced from both ic_this_class and
cp(X), the corresponding four-tuple from ic_All is selected, and added
to ic_Relevant(X), if not already there.
- The previous step is repeated until closure. (That is, until
ic_Relevant(X) no longer changes.)
- The set ic_Relevant(X) is ordered into a sequence, so that its order
is consistent with ic_All. (I.e., it is a subsequence of ic_All.)
I don't understand step 4 - it doesn't look as if step 3 will not change
anything after the first time it runs. (In other words, it looks as if
multiple iterations aren't necessary). Perhaps that's because I don't
understand inner classes well enough - does anyone have any idea which
classes need to be added to the InnerClasses attribute for a specific class?
Andrew Jr.
Re: [classlib][pack200] Computing inner classes
Posted by Alex Blewitt <al...@gmail.com>.
On Jan 24, 2008 7:03 PM, Andrew Cornwall <an...@gmail.com> wrote:
> I'm in the process of looking at inner classes. The pack200 spec has an
> algorithm for calculating which classes are relevant for a specific class.
> Part of that algorithm is:
>
> (4) The previous step is repeated until closure. (That is, until
> ic_Relevant(X) no longer changes.)
> (5) The set ic_Relevant(X) is ordered into a sequence, so that its order
> is consistent with ic_All. (I.e., it is a subsequence of ic_All.)
>
> I don't understand step 4 - it doesn't look as if step 3 will not change
> anything after the first time it runs. (In other words, it looks as if
> multiple iterations aren't necessary). Perhaps that's because I don't
> understand inner classes well enough - does anyone have any idea which
> classes need to be added to the InnerClasses attribute for a specific class?
I suspect it's to do with things like subclassing. Consider:
public class A {
private B b;
public class B extends C {
}
public class C {
}
}
A directly references B, but will also need to transmit C as well. But
you only know that you need C when you hit B. On the plus side, you
only do 2 runs through and if ic_relevant isn't changed, you terminate
then; so in your examples so far, you can implement the iterative
behaviour without changing it :-)
Alex