Re: Proposed Final Draft -- Java 8 Implementation


Pavel Bucek
 

Well, if you look at the rest of the API, the pattern is to use IAE even when parameter is null, so .. being consistent with existing API wins over anything else..

On 07/07/2017 17:15, Markus KARG wrote:
So it is by intention that you still use IllegalArgumentException instead of NPE. Understood. :-)

-----Original Message-----
From: jaxrs-spec@javaee.groups.io [mailto:jaxrs-spec@javaee.groups.io] On Behalf Of Pavel Bucek
Sent: Freitag, 7. Juli 2017 08:11
To: jaxrs-spec@javaee.groups.io
Subject: Re: [jaxrs] Proposed Final Draft -- Java 8 Implementation

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..

Regards,
Pavel


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.

-Markus

-----Original Message-----
From: jaxrs-spec@javaee.groups.io [mailto:jaxrs-spec@javaee.groups.io]
On Behalf Of Pavel Bucek
Sent: Donnerstag, 22. Juni 2017 13:23
To: jaxrs-spec@javaee.groups.io
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

[1] https://jcp.org/en/jsr/detail?id=370











Join jaxrs-spec@javaee.groups.io to automatically receive all group messages.