What to do about dead labels?

Paul Sandoz paul.sandoz at oracle.com
Wed Aug 24 21:02:57 UTC 2022


Good point, we cannot reorder. (Although FWIW I suspect we could get away with it for bytecode produced by javac at least for its current implementation, since the order would be preserved. That’s nice to know, but not helpful!)

Paul.

> On Aug 24, 2022, at 1:49 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 
> 
>> Perhaps it comes down to an option to order such pseudo instructions or not?
> 
> I thought some more about this and I think we may not be able to do this.
> 
> The order of the exception table is significant (JVMS 2.10); it indicates the order in which handlers are tried.  This may, or may not, correspond to the order in which the handlers appear in the code array.  (I recall we had some earlier bugs where we were not diligent about preserving this order.)
> 
> The builder is going to write them to the exception_table in the order they are presented.  So if we perturb the presentation order, we'll be perturbing the order of the exception table, and changing the semantics of the classfile.  And if we can't do this for exceptions, there's little point in trying to do it for debug information or line numbers.
> 
> So I think that brings us to: it's an error if if any of these reference dead labels.  And I think this is the behavior of the code now.  So I think all we need here is (a) to remove the FIXME comments in DirectCodeBuilder like "@@@ Filter out LVs whose boundary labels are not defined?" and (b) write some tests for this behavior.
> 



More information about the classfile-api-dev mailing list