void sanityCheckSourcePathModules(List<String> moduleNames) throws ToolException {
        if (!haveSourceLocationWithModule)
            return;

        if (moduleNames.size() > 1) {
            String text = messager.getText("main.cannot_use_sourcepath_for_modules",
                    String.join(", ", moduleNames));
            throw new ToolException(CMDERR, text);
        }

        String foundModule = getModuleName(StandardLocation.SOURCE_PATH);
        if (foundModule == null) {
            String text = messager.getText("main.module_not_found_on_sourcepath", moduleNames.get(0));
            throw new ToolException(CMDERR, text);
        }

        if (!moduleNames.get(0).equals(foundModule)) {
            String text = messager.getText("main.sourcepath_does_not_contain_module", moduleNames.get(0));
            throw new ToolException(CMDERR, text);
        }
    }
void sanityCheckSourcePathModules ( List < String > moduleNames ) throws ToolException { if ( ! haveSourceLocationWithModule ) return ; if ( moduleNames . size ( ) > 1 ) { String text = messager . getText ( "main.cannot_use_sourcepath_for_modules" , String . join ( ", " , moduleNames ) ) ; throw new ToolException ( CMDERR , text ) ; } String foundModule = getModuleName ( StandardLocation . SOURCE_PATH ) ; if ( foundModule == null ) { String text = messager . getText ( "main.module_not_found_on_sourcepath" , moduleNames . get ( 0 ) ) ; throw new ToolException ( CMDERR , text ) ; } if ( ! moduleNames . get ( 0 ) . equals ( foundModule ) ) { String text = messager . getText ( "main.sourcepath_does_not_contain_module" , moduleNames . get ( 0 ) ) ; throw new ToolException ( CMDERR , text ) ; } }
/*
This method sanity checks the following cases:
a. a source-path containing a single module and many modules specified with --module
b. no modules on source-path
c. mismatched source-path and many modules specified with --module