Re: Proposed Final Draft -- Java 8 Implementation

Pavel Bucek

Hi Markus,

I'm sorry I'm responding so late, I must have missed this email.

The main issue with Object.requireNonNull is that it throws a NPE instead of IAE, so we can't really use it on most of places - and I believe checking the value and throwing the exception would be much faster than calling Object.requireNonNull, catching the exception, etc..


On 24/06/2017 00:01, Markus KARG wrote:
A target of JAX-RS 2.1 is support for Java 8. So I wonder why still idioms of the pre-8 age are used in the API implementation instead of Java 8 idioms. For example:

default OutboundSseEvent newEvent(String data) {
if (data == null) {
throw new IllegalArgumentException("Parameter 'data' must not be null.");

return newEventBuilder().data(String.class, data).build();

This rather looks like Java 7 style, because since Java 8 this typically would be done with Objects utility:

default OutboundSseEvent newEvent(String data) {
Objects.requireNonNull(data, "Parameter 'data' must not be null.");
return newEventBuilder().data(String.class, data).build();

(BTW It is simply a question of style whether one would even inline the check instead of using two code lines, since requireNonNull actually is function.)

The result not only is a smaller binary but also faster execution, as less custom byte code will get created, verified and loaded. Hence the shared requireNonNull method is much earlier eligible for native compilation.


-----Original Message-----
From: [] On Behalf Of Pavel Bucek
Sent: Donnerstag, 22. Juni 2017 13:23
Subject: [jaxrs] Proposed Final Draft

Dear experts,

we'd like to announce that Proposed Final Draft was published on JCP JSR
370 page [1].

I'd like to encourage you all to review provided artifacts and let us know if you have any feedback.

Thanks and regards,
Pavel & Santiago


Join to automatically receive all group messages.