Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Warn if the user sets a property that we don't recognise.
  • Loading branch information
chrisseaton committed Oct 4, 2014
1 parent b775ac1 commit a9a9d25
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
26 changes: 23 additions & 3 deletions core/src/main/java/org/jruby/util/cli/ArgumentProcessor.java
Expand Up @@ -39,9 +39,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;

/**
* Encapsulated logic for processing JRuby's command-line arguments.
Expand Down Expand Up @@ -94,6 +92,8 @@ public void processArguments() {
}

public void processArguments(boolean inline) {
checkProperties();

while (argumentIndex < arguments.size() && isInterpreterArgument(arguments.get(argumentIndex).originalValue)) {
processArgument();
argumentIndex++;
Expand Down Expand Up @@ -679,4 +679,24 @@ public static void checkGraalVersion() {
}
}

private void checkProperties() {
final Set<String> propertyNames = new HashSet<>();
propertyNames.addAll(Options.getPropertyNames());
propertyNames.add("jruby.home");
propertyNames.add("jruby.script");
propertyNames.add("jruby.shell");
propertyNames.add("jruby.lib");
propertyNames.add("jruby.bindir");
propertyNames.add("jruby.jar");
propertyNames.add("jruby.compat.version");

for (String propertyName : System.getProperties().stringPropertyNames()) {
if (propertyName.startsWith("jruby.")) {
if (!propertyNames.contains(propertyName)) {
System.err.println("jruby: warning: unknown property " + propertyName);
}
}
}
}

}
15 changes: 11 additions & 4 deletions core/src/main/java/org/jruby/util/cli/Options.java
Expand Up @@ -28,10 +28,7 @@
***** END LICENSE BLOCK *****/
package org.jruby.util.cli;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.*;

import com.headius.options.Option;
import org.jruby.TruffleBridge;
Expand Down Expand Up @@ -338,4 +335,14 @@ private static void list(SearchMode mode, String string) {
}
}

public static Set<String> getPropertyNames() {
final Set<String> propertyNames = new HashSet<String>();

for (Option option : PROPERTIES) {
propertyNames.add(option.propertyName());
}

return Collections.unmodifiableSet(propertyNames);
}

}

2 comments on commit a9a9d25

@enebo
Copy link
Member

@enebo enebo commented on a9a9d25 Oct 6, 2014

Choose a reason for hiding this comment

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

@chrisseaton Could you disable star globbing imports for non-Truffle code? We expand all classes as a convention (perhaps there are a couple of unusual exceptions).

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, yeah I'll do that. I guess I can persuade IntelliJ to do it for me.

Please sign in to comment.