[9] RFR of 8065556: (bf) Buffer.position and other methods should include detail in IAE

Brian Burkhalter brian.burkhalter at oracle.com
Mon Mar 23 22:16:23 UTC 2015


Moving thread completely to nio-dev …

All good points. I know what you intended the first time but somehow got sidetracked. Will update.

Thanks,

Brian

On Mar 23, 2015, at 3:12 PM, Martin Buchholz <martinrb at google.com> wrote:

> Previous maintainers were nervous about improving the error messages because of the risk of performance loss in these performance critical methods.
> 
> Notice that the below method contains both cold code and hot code - you want to segregate them as I suggested in my previous message.
> 
> Because this is a critical low-level core library:
> I would not have a checkPositionBounds method at all and save a branch by using | instead of || and optimize for the current hotspot implementation:
> 
> if ((newPosition > limit) | (newPosition < 0)) 
>   throw new IllegalArgumentException(positionOutOfBoundsMsg(newPosition));
> 
> Also, if we're going to this much trouble to craft a high quality error message, we can figure out the "or" for the user.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20150323/1e0151d8/attachment.html>


More information about the nio-dev mailing list