Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/apache/maven/plugin/compiler/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ private boolean checkNumberOfArguments(String option, int count, boolean immedia
if (expected == count) {
warning = null;
return true;
} else if (expected < 1) {
} else if (expected == 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might still be wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just need to replace if (expected < 1) by if (expected < 0). This is the only correction needed (no need to change order or add another if condition).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code looks like this:

        } else if (expected < 1) {
            if (checker instanceof ForkedCompiler) {
                return true; // That implementation actually knows nothing about which options are supported.
            }
            warning = "The '" + option + "' option is not supported.";
        } else if (expected == 0) {
            warning = "The '" + option + "' option does not expect any argument.";
        } 

So if expected == 0 do we still need to check if checker instanceof ForkedCompiler?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if expected == 0 do we still need to check if checker instanceof ForkedCompiler?

No, ForkedCompiler unconditionally returns -1 because it has no information about which options are supported by external tool.

warning = "The '" + option + "' option does not expect any argument.";
} else if (expected < 0) {
if (checker instanceof ForkedCompiler) {
return true; // That implementation actually knows nothing about which options are supported.
}
warning = "The '" + option + "' option is not supported.";
} else if (expected == 0) {
warning = "The '" + option + "' option does not expect any argument.";
} else if (expected == 1) {
warning = "The '" + option + "' option expects a single argument.";
} else {
Expand Down