File tree Expand file tree Collapse file tree
src/main/java/org/scijava/ops/matcher Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929
3030package org .scijava .ops .matcher ;
3131
32+ import java .lang .reflect .Constructor ;
33+ import java .lang .reflect .InvocationTargetException ;
3234import java .lang .reflect .Type ;
3335import java .util .List ;
3436
@@ -106,12 +108,14 @@ public StructInstance<?> createOpInstance() {
106108 // TODO: Consider whether this is really the best way to
107109 // instantiate the op class here. No framework usage?
108110 // E.g., what about pluginService.createInstance?
109- object = opClass .newInstance ();
110- } catch (final InstantiationException | IllegalAccessException e ) {
111+ Constructor <? extends Op > ctor = opClass .getDeclaredConstructor ();
112+ ctor .setAccessible (true );
113+ object = ctor .newInstance ();
114+ } catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException e ) {
111115 // TODO: Think about whether exception handling here should be
112116 // different.
113117 throw new IllegalStateException ("Unable to instantiate op: '" + opClass .getName ()
114- + "' Each op must have a no-args constructor." , e );
118+ + "' Ensure that the Op has a no-args constructor." , e );
115119 }
116120 return struct ().createInstance (object );
117121 }
You can’t perform that action at this time.
0 commit comments