diff --git a/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperties.java b/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperties.java index d5362530e6b..fe955ed6852 100644 --- a/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperties.java +++ b/dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperties.java @@ -141,6 +141,17 @@ public List getStrings(String key) { return properties.get(key); } + /** + * Returns all the values of a multi-valued configuration property, or null + * if not found. + * + *

A single-valued and unset configuration property will be returned as a list + * containing one null. + */ + public List getStringsOrNull(String key) { + return properties.get(key); + } + /** * Reads a configuration property as a comma-separated list of strings. * It may be a single-valued or multi-valued property. If multi-valued, diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java index 515e9d5df46..1ced427faca 100644 --- a/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java +++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java @@ -47,6 +47,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -74,13 +75,20 @@ public void endVisit(JPermutationDependentValue x, Context ctx) { } private JExpression propertyValueExpression(JPermutationDependentValue x) { - List propertyValues = props.getConfigurationProperties().getStrings(x.getRequestedValue()); - - String propertyValue = propertyValues.isEmpty() ? null : Joiner.on(",").join(propertyValues); - - if (propertyValue != null) { + List propertyValues = props.getConfigurationProperties() + .getStringsOrNull(x.getRequestedValue()); + if (propertyValues != null) { // It is a configuration property. - return program.getLiteral(x.getSourceInfo(), propertyValue); + // If no values are set, propertyValues is either empty (multivalued properties) + // or contains a single null (other properties). + if (propertyValues.stream().anyMatch(Objects::nonNull)) { + return program.getLiteral(x.getSourceInfo(), + Joiner.on(",").skipNulls().join(propertyValues)); + } + if (x.getDefaultValueExpression() != null) { + return x.getDefaultValueExpression(); + } + return program.getLiteralNull(); } if (isSoftPermutationProperty(x.getRequestedValue())) { @@ -88,7 +96,7 @@ private JExpression propertyValueExpression(JPermutationDependentValue x) { return new JMethodCall(x.getSourceInfo(), null, method); } - propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue()); + String propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue()); if (propertyValue != null) { return program.getLiteral(x.getSourceInfo(), propertyValue); diff --git a/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml b/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml index f307fdb4644..b8a69a301f3 100644 --- a/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml +++ b/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml @@ -33,4 +33,6 @@ + + \ No newline at end of file diff --git a/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java b/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java index 696978a3388..0b390e05832 100644 --- a/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java +++ b/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java @@ -36,5 +36,9 @@ public void testBindingProperties() { String expectedResult = "safari".equals(System.getProperty("user.agent")) ? "InSafari" : "NotInSafari"; assertEquals(expectedResult, System.getProperty("someDynamicProperty")); + assertEquals("foo", System.getProperty("configPropertyUnset", "foo")); + assertNull(System.getProperty("configPropertyUnset")); + assertEquals("foo", System.getProperty("multivaluedConfigPropertyUnset", "foo")); + assertNull(System.getProperty("multivaluedConfigPropertyUnset")); } }