Possible bug in StackFrameInfo#getByteCodeIndex?

Martin Buchholz martinrb at google.com
Tue Dec 12 02:31:33 UTC 2017


Java has an unsigned 16 bit type.  Could bci be of type "char" ?

On Mon, Dec 11, 2017 at 1:53 PM, mandy chung <mandy.chung at oracle.com> wrote:

> I filed https://bugs.openjdk.java.net/browse/JDK-8193325.   I can sponsor
> this patch for you.
>
> --- a/src/java.base/share/classes/java/lang/StackFrameInfo.java
> +++ b/src/java.base/share/classes/java/lang/StackFrameInfo.java
> @@ -93,7 +93,7 @@
>          if (isNativeMethod())
>              return -1;
>
> -        return bci;
> +        return bci & 0xffff;
>      }
>
> Mandy
>
>
> On 12/7/17 8:19 PM, David Lloyd wrote:
>
>> I was doing some research related to AccessController, and I noted
>> this code [1] in StackFrameInfo#getByteCodeIndex():
>>
>> @Override
>> public int getByteCodeIndex() {
>>      // bci not available for native methods
>>      if (isNativeMethod())
>>          return -1;
>>
>>      return bci;
>> }
>>
>> Now bci is of type short, and given the spec of the method, should the
>> return not be:
>>
>>      return bci & 0xffff;
>>
>> instead?  Else it would return wrong values for methods with more than
>> 32767 bytecodes in them.
>>
>> [1] http://hg.openjdk.java.net/jdk/jdk/file/e3b6cb90d7ce/src/jav
>> a.base/share/classes/java/lang/StackFrameInfo.java#l96
>>
>>
>


More information about the core-libs-dev mailing list