[type-annos-observers] Comments on the Nov 7 specification
Eric Bruneton
ebruneton at free.fr
Sat Nov 24 08:28:47 PST 2012
20/11/2012 21:37, Michael Ernst wrote:
> Eric Bruneton said:
>
>> From an ASM point of view,
>> ...
>> The important
>> point is that all paths should be "from outside to inside" (e.g. for nested
>> types, the path should go from outer to inner, not the other way around as
>> proposed in the Nov 7 specification).
>
> Eric, I'm willing to make this change, but I would like to be able to give
> a more specific justification for the design choice. Can you explain the
> rationale, or what difference it makes to ASM? Is the reason that the
> identifiers appear left-to-right in the class file and you want to process
> them in that order, or is it something else?
Right, it's basically that. For instance, consider the problem of
extracting the part of a type signature in the class file format (e.g.
Ljava.util.Map<+Ljava.lang.String;Ljava.util.List<Ljava.lang.Object;>;>;) that
corresponds to a given type_path. With 'outside to inside' paths, this
can be done with a simple recursive function, like
extract(signature,path)
- if empty path return signature
- otherwise parse the first signature element from the left, check
conformity with first path element, and call recursively with tail of
signature and tail of path.
With 'inside to outside' paths, you have to parse the three inner types
in the signature to realize that
"inner_path{inner_path{inner_path{empty_path}}}", for instance, was in
fact the first parsed type (then you either have to save state during
parsing, or do another parsing pass).
I'm not sure I'm clear, but I hope you get the idea.
Eric
More information about the type-annotations-spec-comments
mailing list