Storing annotations on exception parameters
Werner Dietl
wdietl at gmail.com
Tue Jan 1 21:50:39 PST 2013
Thanks for the pointer, Jon!
I implemented this feature in this changeset:
http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/0cb5302df6a3
I also implemented storage of annotations on resource variables.
There are no test cases for local and resource variable storage in the
tools/javac/annotations/typeAnnotations/referenceinfos/
directory. I think adding some tests would be good, but a bit painful.
As always, comments and more test cases very welcome.
Happy 2013!
cu, WMD.
On Tue, Nov 27, 2012 at 6:26 PM, Jonathan Gibbons
<jonathan.gibbons at oracle.com> wrote:
> On 11/27/2012 05:49 PM, Werner Dietl wrote:
>>
>> As discussed on the type-annotations-spec-experts list (see
>>
>> http://mail.openjdk.java.net/pipermail/type-annotations-spec-experts/2012-November/000038.html)
>> Section 3.3.8 of the JSR 308 specification will stay unchanged.
>>
>> For local variables, method:
>>
>> com.sun.tools.javac.jvm.Code.fillLocalVarPosition(LocalVar)
>>
>> determines the necessary information.
>>
>> Could somebody point me to a place where I could determine the
>> exception table index for an exception parameter?
>> I found method
>>
>> com.sun.tools.javac.jvm.Gen.genCatch(JCCatch, Env<GenContext>, int,
>> int, List<Integer>)
>>
>> but I didn't see an exception table index there.
>>
>> Thanks,
>> cu, WMD.
>>
>
> Werner,
>
> I believe the data structure you should be looking at is this one in
> Code.java
>
> /** A buffer for expression catch data. Each enter is a vector
> * of four unsigned shorts.
> */
> ListBuffer<char[]> catchInfo = new ListBuffer<char[]>();
>
> And this method:
>
> /** Add a catch clause to code.
> */
> public void addCatch(
> char startPc, char endPc, char handlerPc, char catchType) {
> catchInfo.append(new char[]{startPc, endPc, handlerPc,
> catchType});
> }
>
> So, on the face of it, the index in the catchInfo array is the value you
> want. But life is never that simple, since there's this method too:
>
> public void compressCatchTable() {
>
> which can eliminate some entries. You may need to search catchInfo for the
> handler you need.
>
> -- Jon
--
http://www.google.com/profiles/wdietl
More information about the type-annotations-dev
mailing list