Merge branch 'tidy-config'
diff --git a/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java b/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
index 943c9b1..e2bd4a2 100644
--- a/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
+++ b/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
@@ -127,7 +127,7 @@
         @Override protected ConfigInheritance getDelegate() { return DELEGATE; }
     }
     /** Indicates that a key's value should never be inherited, even if inherited from a value set on a container that does not know the key.
-     * (Most usages will prefer {@link #NOT_REINHERITED}.) */
+     * (Many usages will prefer {@link #NOT_REINHERITED}, to allow unknown dynamic keys set in an ancestor accessible from descendants.) */
     public static final ConfigInheritance NEVER_INHERITED = new NeverInherited();
 
     /** In case we deserialize an old copy; the last arg (ancestor inherit default) is irrelevant
diff --git a/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java b/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
index 9c1f4c4..80ba2f8 100644
--- a/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
+++ b/core/src/main/java/org/apache/brooklyn/core/config/internal/AbstractConfigMapImpl.java
@@ -27,6 +27,7 @@
 import org.apache.brooklyn.api.mgmt.TaskFactory;
 import org.apache.brooklyn.api.objs.BrooklynObject;
 import org.apache.brooklyn.config.ConfigInheritance;
+import org.apache.brooklyn.config.ConfigInheritance.ConfigInheritanceContext;
 import org.apache.brooklyn.config.ConfigInheritances;
 import org.apache.brooklyn.config.ConfigInheritances.BasicConfigValueAtContainer;
 import org.apache.brooklyn.config.ConfigKey;
@@ -70,12 +71,7 @@
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigMapImpl.class);
 
-    @Deprecated /** @deprecated since 0.10.0 - see method which uses it */
-    protected final transient org.apache.brooklyn.core.entity.internal.ConfigMapViewWithStringKeys mapViewWithStringKeys = new org.apache.brooklyn.core.entity.internal.ConfigMapViewWithStringKeys(this);
-
-    // TODO make final when not working with previously serialized instances
-    // (we shouldn't be, but just in case!)
-    protected TContainer bo;
+    protected final TContainer bo;
 
     /**
      * Map of configuration information that is defined at start-up time for the entity. These
@@ -142,27 +138,6 @@
         }
     }
 
-    /** an immutable copy of the config visible at this entity, local and inherited (preferring local) */
-    @Override @Deprecated
-    public Map<ConfigKey<?>,Object> getAllConfig() {
-        Map<ConfigKey<?>,Object> result = new LinkedHashMap<ConfigKey<?>,Object>();
-        if (getParent()!=null)
-            result.putAll( getParentInternal().config().getInternalConfigMap().getAllConfig() );
-        putAllOwnConfigIntoSafely(result);
-        return Collections.unmodifiableMap(result);
-    }
-
-    /** Creates an immutable copy of the config visible at this entity, local and inherited (preferring local), including those that did not match config keys */
-    @Deprecated
-    public ConfigBag getAllConfigBag() {
-        ConfigBag result = putAllOwnConfigIntoSafely(ConfigBag.newInstance());
-        if (getParent()!=null) {
-            result.putIfAbsent(
-                    ((AbstractConfigMapImpl<?>)getParentInternal().config().getInternalConfigMap()).getAllConfigBag() );
-        }
-        return result.seal();
-    }
-
     /** As {@link #getAllConfigLocalRaw()} } but in a {@link ConfigBag} for convenience */
     public ConfigBag getLocalConfigBag() {
         return putAllOwnConfigIntoSafely(ConfigBag.newInstance()).seal();
@@ -322,11 +297,6 @@
     }
 
     @Override
-    public Map<String,Object> asMapWithStringKeys() {
-        return mapViewWithStringKeys;
-    }
-
-    @Override
     public int size() {
         return ownConfig.size();
     }
@@ -644,11 +614,12 @@
         return getSelectedConfigInheritedRaw(null, true);
     }
 
-    protected Map<ConfigKey<?>,ReferenceWithError<ConfigValueAtContainer<TContainer,?>>> getSelectedConfigInheritedRaw(Map<ConfigKey<?>,ConfigKey<?>> knownKeys, boolean onlyReinheritable) {
+    protected Map<ConfigKey<?>,ReferenceWithError<ConfigValueAtContainer<TContainer,?>>> getSelectedConfigInheritedRaw(Map<ConfigKey<?>,ConfigKey<?>> knownKeysAtDescendants,
+            /* if true, only returns keys which are intended for inheritance by our descendants */ boolean onlyReinheritable) {
         Map<ConfigKey<?>, ConfigKey<?>> knownKeysOnType = MutableMap.of();
         for (ConfigKey<?> k: getKeysAtContainer(getContainer())) knownKeysOnType.put(k, k);
 
-        Map<ConfigKey<?>, ConfigKey<?>> knownKeysIncludingDescendants = MutableMap.copyOf(knownKeys);
+        Map<ConfigKey<?>, ConfigKey<?>> knownKeysIncludingDescendants = MutableMap.copyOf(knownKeysAtDescendants);
         knownKeysIncludingDescendants.putAll(knownKeysOnType);
 
         Map<ConfigKey<?>,ReferenceWithError<ConfigValueAtContainer<TContainer,?>>> parents = MutableMap.of();
@@ -676,7 +647,15 @@
 
             // if no key on type, we must use any descendant declared key here 
             // so that the correct descendant conflict resolution strategy is applied
-            ConfigInheritance inhHereOrDesc = ConfigInheritances.findInheritance(kTypeOrDescendant, InheritanceContext.RUNTIME_MANAGEMENT, getDefaultRuntimeInheritance());
+            ConfigInheritance inhHereOrDesc = ConfigInheritances.findInheritance(kTypeOrDescendant, InheritanceContext.RUNTIME_MANAGEMENT, null);
+            if (inhHereOrDesc==null) {
+                inhHereOrDesc = kSet.getInheritanceByContext(InheritanceContext.RUNTIME_MANAGEMENT);
+                if (inhHereOrDesc != null) {
+                    kOnType = kTypeOrDescendant = kSet;  // prefer kset if it has inheritance set (locally by value but not on type, e.g. because key was removed from type while still present)
+                } else {
+                    inhHereOrDesc = getDefaultRuntimeInheritance();
+                }
+            }
 
             // however for the purpose of qualifying we must not give any key except what is exactly declared here,
             // else reinheritance will be incorrectly deduced
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/internal/ConfigMapViewWithStringKeys.java b/core/src/main/java/org/apache/brooklyn/core/entity/internal/ConfigMapViewWithStringKeys.java
deleted file mode 100644
index 38f83c7..0000000
--- a/core/src/main/java/org/apache/brooklyn/core/entity/internal/ConfigMapViewWithStringKeys.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.entity.internal;
-
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.config.ConfigMap;
-import org.apache.brooklyn.core.config.BasicConfigKey;
-
-import com.google.common.collect.Sets;
-
-/**
- * Internal class that presents a view over a ConfigMap, so it looks like a Map (with the
- * keys being the config key names).
- * 
- * @deprecated since 0.10.0 removed support, no longer needed
- */
-@Deprecated
-public class ConfigMapViewWithStringKeys implements Map<String,Object> {
-
-    private ConfigMap target;
-
-    public ConfigMapViewWithStringKeys(ConfigMap target) {
-        this.target = target;
-    }
-    
-    @Override
-    public int size() {
-        return target.getAllConfig().size();
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return target.getAllConfig().isEmpty();
-    }
-
-    @Override
-    public boolean containsKey(Object key) {
-        return keySet().contains(key);
-    }
-
-    @Override
-    public boolean containsValue(Object value) {
-        return values().contains(value);
-    }
-
-    @Override
-    public Object get(Object key) {
-        return target.getConfig(new BasicConfigKey<Object>(Object.class, (String)key));
-    }
-
-    @Override
-    public Object put(String key, Object value) {
-        throw new UnsupportedOperationException("This view is read-only");
-    }
-
-    @Override
-    public Object remove(Object key) {
-        throw new UnsupportedOperationException("This view is read-only");
-    }
-
-    @Override
-    public void putAll(Map<? extends String, ? extends Object> m) {
-        throw new UnsupportedOperationException("This view is read-only");
-    }
-
-    @Override
-    public void clear() {
-        throw new UnsupportedOperationException("This view is read-only");
-    }
-
-    @Override
-    public Set<String> keySet() {
-        LinkedHashSet<String> result = Sets.newLinkedHashSet();
-        Set<Map.Entry<ConfigKey<?>, Object>> set = target.getAllConfig().entrySet();
-        for (final Map.Entry<ConfigKey<?>, Object> entry: set) {
-            result.add(entry.getKey().getName());
-        }
-        return result;
-    }
-
-    @Override
-    public Collection<Object> values() {
-        return target.getAllConfig().values();
-    }
-
-    @Override
-    public Set<Map.Entry<String, Object>> entrySet() {
-        LinkedHashSet<Map.Entry<String, Object>> result = Sets.newLinkedHashSet();
-        Set<Map.Entry<ConfigKey<?>, Object>> set = target.getAllConfig().entrySet();
-        for (final Map.Entry<ConfigKey<?>, Object> entry: set) {
-            result.add(new Map.Entry<String, Object>() {
-                @Override
-                public String getKey() {
-                    return entry.getKey().getName();
-                }
-
-                @Override
-                public Object getValue() {
-                    return entry.getValue();
-                }
-
-                @Override
-                public Object setValue(Object value) {
-                    return entry.setValue(value);
-                }
-            });
-        }
-        return result;
-    }
-    
-}
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
index cd7464a..f30f2fb 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/internal/EntityConfigMap.java
@@ -18,27 +18,27 @@
  */
 package org.apache.brooklyn.core.entity.internal;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ExecutionContext;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.api.objs.BrooklynObject;
+import org.apache.brooklyn.config.ConfigInheritance.ConfigInheritanceContext;
 import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.BasicConfigInheritance;
 import org.apache.brooklyn.core.config.ConfigConstraints;
+import org.apache.brooklyn.core.config.ConfigKeys.InheritanceContext;
 import org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl;
 import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.objs.BrooklynObjectInternal.ConfigurationSupportInternal;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Predicate;
-import com.google.common.collect.Maps;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 public class EntityConfigMap extends AbstractConfigMapImpl<Entity> {
 
@@ -53,9 +53,6 @@
         super(checkNotNull(entity, "entity must be specified"), checkNotNull(storage, "storage map must be specified"));
     }
 
-    /** entity against which config resolution / task execution will occur
-     * @deprecated since 0.10.0 kept for serialization */ @Deprecated
-    private EntityInternal entity;
     @Override
     public EntityInternal getContainer() {
         Entity result = super.getContainer();
@@ -64,15 +61,13 @@
         synchronized (this) {
             result = super.getContainer();
             if (result!=null) return (EntityInternal) result;
-            bo = entity;
-            entity = null;
         }
         return (EntityInternal) super.getBrooklynObject();
     }
 
     @Override
     public <T> void assertValid(ConfigKey<T> key, T val) {
-        ConfigConstraints.assertValid((Entity) getContainer(), key, val);
+        ConfigConstraints.assertValid(getContainer(), key, val);
     }
 
     protected EntityInternal getEntity() {
@@ -109,7 +104,20 @@
     @Override
     protected <T> ConfigKey<?> getKeyAtContainerImpl(Entity container, ConfigKey<T> queryKey) {
         if (queryKey==null) return null;
-        return container.getEntityType().getConfigKey(queryKey.getName());
+        ConfigKey<?> kOnType = container.getEntityType().getConfigKey(queryKey.getName());
+        if (kOnType!=null) return kOnType;
+        ConfigKey<?> kOnTypeUndeclared;
+        Map<ConfigKey<?>, Object> ownConfig = ((EntityConfigMap) ((EntityInternal) container).config().getInternalConfigMap()).ownConfig;
+        synchronized (ownConfig) {
+            kOnTypeUndeclared = ownConfig.keySet().stream().filter(ck -> Objects.equals(queryKey.getName(), ck.getName())).findAny().orElse(null);
+        }
+        if (kOnTypeUndeclared!=null) {
+            // if a never inherited key is set, but not declared, it should be returned
+            if (BasicConfigInheritance.NEVER_INHERITED.equals(kOnTypeUndeclared.getInheritanceByContext(InheritanceContext.RUNTIME_MANAGEMENT))) {
+                return kOnTypeUndeclared;
+            }
+        }
+        return null;
     }
 
     @Override
@@ -117,22 +125,6 @@
         return container.getEntityType().getConfigKeys();
     }
 
-    @Override @Deprecated
-    public EntityConfigMap submap(Predicate<ConfigKey<?>> filter) {
-        EntityConfigMap m = new EntityConfigMap(getEntity(), Maps.<ConfigKey<?>, Object>newLinkedHashMap());
-        synchronized (ownConfig) {
-            for (Map.Entry<ConfigKey<?>,Object> entry: ownConfig.entrySet()) {
-                if (filter.apply(entry.getKey())) {
-                    m.ownConfig.put(entry.getKey(), entry.getValue());
-                }
-            }
-        }
-        if (getEntity().getParent()!=null) {
-            merge(m, ((EntityConfigMap) ((ConfigurationSupportInternal)getEntity().getParent().config()).getInternalConfigMap()).submap(filter));
-        }
-        return m;
-    }
-
     @Deprecated
     private void merge(EntityConfigMap local, EntityConfigMap parent) {
         for (ConfigKey<?> k: parent.ownConfig.keySet()) {
diff --git a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java
index 0126e23..aa36f3f 100644
--- a/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java
+++ b/core/src/main/java/org/apache/brooklyn/core/internal/BrooklynProperties.java
@@ -332,7 +332,7 @@
     @Override
     public Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean includeInherited);
 
-    @Override @Deprecated
+    @Deprecated
     public Map<ConfigKey<?>, Object> getAllConfig();
 
     @Override
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/internal/LocationConfigMap.java b/core/src/main/java/org/apache/brooklyn/core/location/internal/LocationConfigMap.java
index cc75230..afea458 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/internal/LocationConfigMap.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/internal/LocationConfigMap.java
@@ -91,11 +91,6 @@
     }
 
     @Override
-    public LocationConfigMap submap(Predicate<ConfigKey<?>> filter) {
-        throw new UnsupportedOperationException("Location does not support submap");
-    }
-
-    @Override
     protected <T> Object coerceConfigValAndValidate(ConfigKey<T> key, Object v, boolean validate) {
         if ((Class.class.isAssignableFrom(key.getType()) || Function.class.isAssignableFrom(key.getType())) && v instanceof String) {
             // for locations only strings can be written where classes/functions are permitted;
diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
index ff56c29..0391458 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
@@ -274,7 +274,11 @@
     @Override
     // see super; we aspire to depreate this due to poor treatment of inheritance
     public ConfigBag getBag() {
-        return getConfigsInternal().getAllConfigBag();
+        ConfigBag result = ConfigBag.newInstance();
+        AbstractConfigMapImpl<? extends BrooklynObject> ci = getConfigsInternal();
+        ci.findKeysPresent(x -> true).forEach(k ->
+                result.put((ConfigKey)k, ci.getConfigRaw(k, true).or(k.getDefaultValue()) ) );
+        return result;
     }
 
     /**
diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java b/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java
index 8c92db8..412d184 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/AdjunctConfigMap.java
@@ -18,24 +18,19 @@
  */
 package org.apache.brooklyn.core.objs;
 
-import java.util.Map;
 import java.util.Set;
 
-import org.apache.brooklyn.api.entity.Entity;
+import com.google.common.base.Preconditions;
 import org.apache.brooklyn.api.mgmt.ExecutionContext;
 import org.apache.brooklyn.api.objs.BrooklynObject;
 import org.apache.brooklyn.api.objs.EntityAdjunct;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigConstraints;
 import org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl;
-import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-
 public class AdjunctConfigMap extends AbstractConfigMapImpl<EntityAdjunct> {
 
     @SuppressWarnings("unused")
@@ -56,8 +51,6 @@
         synchronized (this) {
             result = super.getContainer();
             if (result!=null) return result;
-            bo = adjunct;
-            adjunct = null;
         }
         return super.getContainer();
     }
@@ -79,15 +72,6 @@
     }
     
     @Override
-    public AdjunctConfigMap submap(Predicate<ConfigKey<?>> filter) {
-        AdjunctConfigMap m = new AdjunctConfigMap((AbstractEntityAdjunct)getContainer());
-        for (Map.Entry<ConfigKey<?>,Object> entry: ownConfig.entrySet())
-            if (filter.apply(entry.getKey()))
-                m.ownConfig.put(entry.getKey(), entry.getValue());
-        return m;
-    }
-
-    @Override
     protected EntityAdjunct getParentOfContainer(EntityAdjunct container) {
         return null;
     }
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
index 3ed0519..07d7059 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
@@ -20,17 +20,22 @@
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
+import com.google.common.collect.Iterables;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.config.ConfigMap.ConfigMapWithInheritance;
 import org.apache.brooklyn.config.ConfigValueAtContainer;
 import org.apache.brooklyn.core.config.BasicConfigInheritance;
+import org.apache.brooklyn.core.config.BasicConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.config.internal.AbstractConfigMapImpl;
 import org.apache.brooklyn.core.entity.EntityConfigTest.MyOtherEntity;
 import org.apache.brooklyn.core.entity.EntityConfigTest.MyOtherEntityImpl;
+import org.apache.brooklyn.core.entity.internal.EntityConfigMap;
 import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
 import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey.IntegerAttributeSensorAndConfigKey;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
@@ -42,8 +47,6 @@
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import com.google.common.collect.Iterables;
-
 public class ConfigEntityInheritanceTest extends BrooklynAppUnitTestSupport {
 
     protected void checkKeys(Entity entity2, Integer value) {
@@ -170,19 +173,81 @@
         app.config().set(MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE, "maybe");
         return app.addChild(EntitySpec.create(MyEntityWithPartiallyHeritableConfig.class));
     }
-    
+
+    private boolean isKeyInInternalConfigMapInherited(Entity entity, ConfigKey k) {
+        return isKeyInInternalConfigMapInherited(entity, k.getName());
+    }
+    private boolean isKeyInInternalConfigMapInherited(Entity entity, String s) {
+        Map<ConfigKey<?>, Object> cfgMap = ((EntityInternal) entity).config().getInternalConfigMap().getAllConfigInheritedRawValuesIgnoringErrors();
+        Set<String> cfgs = cfgMap.keySet().stream().map(k -> k.getName()).collect(Collectors.toSet());
+        return cfgs.contains(s);
+    }
+
     @Test
     public void testConfigKeysInheritance() throws Exception {
+        ConfigKey<Object> WAS_NEVER_INHERIT_BUT_NOW_DEFAULT_INHERITANCE = ConfigKeys.builder(Object.class, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT.getName()).build();
+
         Entity child = setupBasicInheritanceTest();
         
         Assert.assertNotNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.HERITABLE_BY_DEFAULT));
         Assert.assertNotNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.ALWAYS_HERITABLE));
         Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Assert.assertNull(child.getConfig(WAS_NEVER_INHERIT_BUT_NOW_DEFAULT_INHERITANCE));
         
         // it's reinheritable unless explicitly declared
         Assert.assertNotNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE));
+
+        Asserts.assertTrue(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.HERITABLE_BY_DEFAULT));
+        Asserts.assertTrue(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.ALWAYS_HERITABLE));
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Asserts.assertTrue(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE));
+
+        // if reinheritable is _declared_ at the app, it is null at the child
         app.getMutableEntityType().addConfigKey(MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE);
         Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE));
+        // and not found
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE));
+
+        // and returns to previous state when reverted
+        app.getMutableEntityType().removeConfigKey(MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE);
+        Assert.assertNotNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE));
+        Asserts.assertTrue(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NOT_REINHERITABLE));
+
+        // whereas never inherit is not found at child whether declared or not on parent or child
+        app.getMutableEntityType().addConfigKey(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT);
+        Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+
+        app.getMutableEntityType().removeConfigKey(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT);
+        Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+
+        ((EntityInternal)child).getMutableEntityType().addConfigKey(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT);
+        Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Assert.assertNull(child.getConfig(WAS_NEVER_INHERIT_BUT_NOW_DEFAULT_INHERITANCE));
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, WAS_NEVER_INHERIT_BUT_NOW_DEFAULT_INHERITANCE));
+
+        ((EntityInternal)child).getMutableEntityType().removeConfigKey(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT);
+        // even if removed, if the key is set, it will keep that type
+        Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        ((EntityInternal) child).config().getInternalConfigMap().getAllConfigInheritedRawValuesIgnoringErrors();
+
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Assert.assertNull(child.getConfig(WAS_NEVER_INHERIT_BUT_NOW_DEFAULT_INHERITANCE));
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, WAS_NEVER_INHERIT_BUT_NOW_DEFAULT_INHERITANCE));
+
+        // redefining at descendant doesn't change visibility
+        ConfigKey<Object> WAS_NEVER_INHERIT_BUT_NOW_OVERWRITE_AT_CHILD = ConfigKeys.builder(Object.class, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT.getName())
+                .runtimeInheritance(BasicConfigInheritance.OVERWRITE).build();
+        ((EntityInternal)child).getMutableEntityType().addConfigKey(WAS_NEVER_INHERIT_BUT_NOW_OVERWRITE_AT_CHILD);
+        Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        // (but the key is known, of course)
+        Asserts.assertTrue(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+
+        ((EntityInternal)child).getMutableEntityType().removeConfigKey(WAS_NEVER_INHERIT_BUT_NOW_OVERWRITE_AT_CHILD);
+        Assert.assertNull(child.getConfig(MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
+        Asserts.assertFalse(isKeyInInternalConfigMapInherited(child, MyEntityWithPartiallyHeritableConfig.NEVER_INHERIT));
     }
     
     @SuppressWarnings("unchecked")
diff --git a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java
index 45f0042..2045c69 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/config/ConfigMap.java
@@ -63,23 +63,7 @@
 
     /** returns a read-only map of all local config keys with their raw (unresolved+uncoerced) contents */
     public Map<ConfigKey<?>,Object> getAllConfigLocalRaw();
-    
-    /** returns a map of all config keys to their raw (unresolved+uncoerced) contents 
-     *         
-     * @deprecated since 0.10.0 in favour of {@link #getAllConfigLocalRaw()} for local
-     * and {@link ConfigMapWithInheritance} methods for inherited;
-     * kept on some sub-interfaces (eg Brooklyn properties) */
-    @Deprecated  // and confirmed no uses (besides sub-interface)
-    public Map<ConfigKey<?>,Object> getAllConfig();
 
-    /** returns submap matching the given filter predicate; see ConfigPredicates for common predicates
-     * @deprecated since 0.10.0 use {@link #findKeys(Predicate)} then do whatever is desired for the values;
-     * kept on {@link StringConfigMap} */
-    @Deprecated  // and confirmed no uses (besides sub-interface)
-    // deprecated because this becomes irritating to implement in a hierarchical world, it requires caching the predicate;
-    // also it encourages subsequent calls to deprecated methods such as #getAllConfig
-    public ConfigMap submap(Predicate<ConfigKey<?>> filter);
-    
     /** @deprecated since 0.11.0 use {@link #findKeysDeclared(Predicate)} or {@link #findKeysPresent(Predicate)}
      * <p>
      * this method is like the above but it does not compare against reference keys in the container / type context.
@@ -87,6 +71,7 @@
      * one of the above other two methods. if keys in the map are needed and not the reference keys,
      * let the brooklyn developers know to keep this functionality! */
     @Deprecated
+    // XXX
     public Set<ConfigKey<?>> findKeys(Predicate<? super ConfigKey<?>> filter);
 
     /** returns all keys present in the map matching the given filter predicate; see ConfigPredicates for common predicates.
@@ -103,16 +88,6 @@
     // TODO should include structured config keys if they have a sub element config present
     public Set<ConfigKey<?>> findKeysPresent(Predicate<? super ConfigKey<?>> filter);
 
-    /** returns a read-only map view which has string keys (corresponding to the config key names);
-     * callers encouraged to use the typed keys (and so not use this method),
-     * but in some compatibility areas having a Properties-like view is useful
-     * 
-     * @deprecated since 0.10.0 use the corresponding methods to return {@link ConfigKey}-based maps,
-     * then pass to a ConfigBag to get a string-map view; kept for {@link StringConfigMap}
-     */
-    @Deprecated  // and confirmed no uses (besides sub-interface)
-    public Map<String,Object> asMapWithStringKeys();
-    
     public int size();
     
     public boolean isEmpty();
diff --git a/utils/common/src/main/java/org/apache/brooklyn/config/StringConfigMap.java b/utils/common/src/main/java/org/apache/brooklyn/config/StringConfigMap.java
index 6b68caf..57d9a17 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/config/StringConfigMap.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/config/StringConfigMap.java
@@ -34,14 +34,12 @@
      * and 'defaultIfNone' (a default value to return if there is no such property);
      * defaults to no warning and null default value */
     public String getFirst(@SuppressWarnings("rawtypes") Map flags, String... keys);
-    
+
     /** returns submap matching the given filter predicate; see ConfigPredicates for common predicates */
-    @Override
     public StringConfigMap submap(Predicate<ConfigKey<?>> filter);
-    
+
     /** returns a read-only map view which has string keys (corresponding to the config key names);
      * callers encouraged to use the typed keys (and so not use this method),
      * but in some compatibility areas having a Properties-like view is useful */
-    @Override
     public Map<String,Object> asMapWithStringKeys();
 }