146 // For class extends, implements, and throws clauses |
146 // For class extends, implements, and throws clauses |
147 public final int type_index; |
147 public final int type_index; |
148 |
148 |
149 // For exception parameters, index into exception table. In |
149 // For exception parameters, index into exception table. In |
150 // com.sun.tools.javac.jvm.Gen.genCatch, we first use this to hold |
150 // com.sun.tools.javac.jvm.Gen.genCatch, we first use this to hold |
151 // the catch type index. Then in |
151 // the catch type's constant pool entry index. Then in |
152 // com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions we |
152 // com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions we |
153 // use that value to determine the exception table index. |
153 // use that value to determine the exception table index. |
|
154 // When read from class file, this holds |
154 private int exception_index = Integer.MIN_VALUE; |
155 private int exception_index = Integer.MIN_VALUE; |
155 |
156 |
156 // If this type annotation is within a lambda expression, |
157 // If this type annotation is within a lambda expression, |
157 // store a pointer to the lambda expression tree in order |
158 // store a pointer to the lambda expression tree in order |
158 // to allow a later translation to the right method. |
159 // to allow a later translation to the right method. |
301 public boolean hasExceptionIndex() { |
302 public boolean hasExceptionIndex() { |
302 return exception_index >= 0; |
303 return exception_index >= 0; |
303 } |
304 } |
304 |
305 |
305 public int getExceptionIndex() { |
306 public int getExceptionIndex() { |
306 Assert.check(exception_index >= 0, "exception_index does not contain a bytecode offset"); |
307 Assert.check(exception_index >= 0, "exception_index is not set"); |
307 return exception_index; |
308 return exception_index; |
308 } |
309 } |
309 |
310 |
310 public void setExceptionIndex(final int exception_index) { |
311 public void setExceptionIndex(final int exception_index) { |
311 Assert.check(hasCatchType(), "exception_index already contains a bytecode offset"); |
312 Assert.check(!hasExceptionIndex(), "exception_index already set"); |
312 Assert.check(exception_index >= 0, "Expected a valid bytecode offset"); |
313 Assert.check(exception_index >= 0, "Expected a valid index into exception table"); |
313 this.exception_index = exception_index; |
314 this.exception_index = exception_index; |
314 } |
315 } |
315 |
316 |
316 public boolean hasCatchType() { |
317 public boolean hasCatchType() { |
317 return exception_index < 0 && exception_index != Integer.MIN_VALUE; |
318 return exception_index < 0 && exception_index != Integer.MIN_VALUE; |
328 "exception_index does not contain valid catch info"); |
329 "exception_index does not contain valid catch info"); |
329 return ((-this.exception_index) - 1) >> 8 ; |
330 return ((-this.exception_index) - 1) >> 8 ; |
330 } |
331 } |
331 |
332 |
332 public void setCatchInfo(final int catchType, final int startPos) { |
333 public void setCatchInfo(final int catchType, final int startPos) { |
333 Assert.check(this.exception_index < 0, |
334 Assert.check(!hasExceptionIndex(), |
334 "exception_index already contains a bytecode index"); |
335 "exception_index is already set"); |
335 Assert.check(catchType >= 0, "Expected a valid catch type"); |
336 Assert.check(catchType >= 0, "Expected a valid catch type"); |
336 this.exception_index = -((catchType | startPos << 8) + 1); |
337 this.exception_index = -((catchType | startPos << 8) + 1); |
337 } |
338 } |
338 |
339 |
339 /** |
340 /** |