Storing annotations on exception parameters

Jonathan Gibbons jonathan.gibbons at oracle.com
Tue Nov 27 18:26:47 PST 2012


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


More information about the type-annotations-dev mailing list