java - Why does LongProperty implement Property<Number> but not Property<Long>? -
i have come across seems peculiarity in javafx api: longproperty implements property<number>, not property<long>.
what reason this? sort of idea stems java's inherent problem covariance , contravariance, because generics implemented stupidly via erasure, maintain backwards compatibility bytecode; problem have arisen having longproperty implement both property<number> and property<long>?
edit: question originated problem: apply longproperty tablecolumn programmatically (vs semantically)
it can't implement both.
to that, need implement 2 versions of each method in interface uses generic. let's take 1 example:
bindbidirectional(property<long> other) { ... } under hood, erasure means gets compiled down to:
bindbidirectional(property other) { ... } so then, implements property<number> , property<long> do? have 2 methods:
bindbidirectional(property<long> other) { ... } bindbidirectional(property<number> other) { ... } ... compile down, after erasure, 2 methods:
bindbidirectional(property other) { ... } bindbidirectional(property other) { ... } these 2 methods conflict, , there'd no way resolve them @ runtime.
even if used compiler trickery around this, happens when uses longproperty raw property?
property rawlongproperty = new longproperty(); rawlongproperty.bindbidirectional(someotherrawproperty); there's no way know of 2 binddirectional variants meant resolve to.
Comments
Post a Comment