GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — DynamicCommand doesn't extend CommandModule · Issue #407 · scijava/scijava-common

DynamicCommand doesn't extend CommandModule #407

New issue
Copy link
New issue
Copy link
Open
Open
DynamicCommand doesn't extend CommandModule#407
Copy link

Description

@imagejan
imagejan
opened on Nov 17, 2020
Issue body actions

The fact that DynamicCommand extends DefaultMutableModule but not CommandModule leads to CommandService.run() returning null, as explained in the [DEBUG] output here:

scijava-common/src/main/java/org/scijava/command/DefaultCommandService.java

Lines 345 to 363 in 80d0a38

/**
* A HACK to avoid {@link ClassCastException} when calling run when the
* resultant module will not be a {@link CommandModule}. This is an API design
* flaw in CommandService currently, but for now we work around it rather than
* breaking backwards API compatibility.
*/
private Future<CommandModule> validateFuture(final Future<Module> future,
final CommandInfo info)
{
try {
final Class<?> commandClass = info.loadDelegateClass();
if (Module.class.isAssignableFrom(commandClass)) {
log.debug("The command '" + info.getIdentifier() +
"' extends Module directly. Due to a design flaw in the " +
"CommandService API, the result cannot be coerced to a " +
"Future<CommandModule>, so null will be returned instead. " +
"If you need the resulting module, please instead call " +
"moduleService.run(commandService.getCommand(commandClass), ...).");
return null;

So the workaround is to get the CommandInfo and call ModuleService#run() on it to get the Future<Module>... but is there any chance to make it extend CommandModule but still implement the required interface MutableModule without breaking backwards compatibility?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.