[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jsonp-dev] UnsupportedOperationExceptions in weird places
|
Hi,
On 9/2/19 11:00 PM, Todd O'Bryan wrote:
I'm trying to write an implementation of the API and am finding that
the API throws UnsupportedOperationExceptions in places I wouldn't
expect them, but doesn't in places that I would.
For example, JsonArrayBuilder has tons of operations that, by default,
throw UnsupportedOperationExceptions, but seem like they're fairly
straightforward to implement. Because they have a default
implementation, my IDE doesn't mark them as necessary to implement the
interface, so it's very easy to miss them and end up with an
UnsupportedOperationException where I didn't mean to have one.
methods throwing 'UnsupportedOperationException' are new in 1.1 (Java EE
8), they were not present in 1.0 (Java EE 7) and they were done this way
to keep backward compatibility + allowance to use 1.1 on Java SE 7. I
believe there was one more reason to not use 'default' implementation in
interfaces but don't remember what exactly that was.
thanks,
--lukas
In contrast, JsonArray implements List, but is immutable. It seems
like it would make complete sense to add default implementation for
all of the mutative List operations so that people don't accidentally
implement them when they shouldn't.
Is there a method to this that I'm not seeing or are things just in a
weird in-between state at the moment?
Todd
_______________________________________________
jsonp-dev mailing list
jsonp-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jsonp-dev