RFR (M) 8207359: Make SymbolTable increment_refcount disallow zero
Kim Barrett
kim.barrett at oracle.com
Thu Jul 19 03:59:07 UTC 2018
> On Jul 18, 2018, at 10:48 PM, coleen.phillimore at oracle.com wrote:
>
> On 7/18/18 6:14 PM, Kim Barrett wrote:
>> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Symbol.java
>> 78 public long getLength() {
>> 79 int i = (int)length.getValue(this.addr);
>> 80 return (i >> 16);
>> 81 }
>>
>> Consider a symbol whose length is in the range [2^15, 2^16). The cast
>> result is implementation defined. The right shift of a negative value
>> is implemention defined, and might (or might not) return a negative value.
>
> There is no unsigned int in Java, so I added back the & 0xffff which seems to work, maybe with less undefined behavior (?)
>
> public long getLength() {
> long i = length.getValue(this.addr);
> return (i >> 16) & 0xffff;
> }
Oh, right, this is Java, so it’s all portably defined, and yes, the mask is needed and sufficient.
More information about the hotspot-runtime-dev
mailing list