Skip to content

Sipmlify getWrapperClass#93

Merged
gselzer merged 1 commit into
mainfrom
scijava/scijava-ops-engine/simplify-op-wrapping
Oct 19, 2023
Merged

Sipmlify getWrapperClass#93
gselzer merged 1 commit into
mainfrom
scijava/scijava-ops-engine/simplify-op-wrapping

Conversation

@gselzer

@gselzer gselzer commented Oct 19, 2023

Copy link
Copy Markdown
Member

I made these changes while investigating scijava/scijava#51. It seems like there is no longer any errors thrown with the DoubleFunction type, unless we make following Op call without making a `DoubleFunctionOpWrapper:

DoubleFunction func = ops.op("some.name", new Nil<DoubleFunction>() {}, new Nil[] {new Nil<Double>() {}}, new Nil<Double>() {})

In the case someone makes this Op call, they'll get a ClassCastException because the return is wrapped by the Function1OpWrapper - i.e. it is a Function, but not a DoubleFunction. You'll need a DoubleFunctionOpWrapper to get that type back, and this PR adds a warning that is logged when it is attempted.

I also made a change to the way that we find the wrapper; now, we no longer call instanceof on every wrapper class. We instead call contains on the inheritance hierarchy, which should be both more robust and faster.

Closes scijava/scijava#51

@gselzer gselzer added the bug Something isn't working label Oct 19, 2023
@gselzer gselzer self-assigned this Oct 19, 2023
@gselzer gselzer force-pushed the scijava/scijava-ops-engine/simplify-op-wrapping branch 2 times, most recently from 1ad17e0 to b98addf Compare October 19, 2023 18:59
This way, we don't call an instanceof check on every wrapper class. We
instead call contains on the inheritance hierarchy, which should be both
more robust and faster
@gselzer gselzer force-pushed the scijava/scijava-ops-engine/simplify-op-wrapping branch from b98addf to 3571f19 Compare October 19, 2023 19:04
@gselzer gselzer merged commit 54b8af3 into main Oct 19, 2023
@gselzer gselzer deleted the scijava/scijava-ops-engine/simplify-op-wrapping branch October 19, 2023 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Handle isSafeAssignable failures when Op interface does not declare a functional method

1 participant