Expand class customization capabilities
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / loader / RootCodecClassLoader.java
index 225941dcfdeafc6fe3bde7b3bcabf1089913da13..1b2b8023d9e198307699767a329f63c85f3247f0 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Set;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -80,6 +81,14 @@ final class RootCodecClassLoader extends CodecClassLoader {
         }
     }
 
+    @Override
+    void appendLoaders(final Set<LeafCodecClassLoader> newLoaders) {
+        // Root loader should never see the requirement for other loaders, as that would violate loop-free nature
+        // of generated code: if a binding class is hosted in root loader, all its references must be visible from
+        // the root loader and hence all the generated code ends up residing in the root loader, too.
+        throw new IllegalStateException("Attempted to extend root loader with " + newLoaders);
+    }
+
     private boolean isOurClass(final Class<?> bindingClass) {
         final Class<?> ourClass;
         try {