]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ExpressionClassLoader.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / runtime / ExpressionClassLoader.java
index c91daab91147480b6437b32a52be87a261b50261..0c134ee5c1130b5e9e730dd9552e01401f367c43 100644 (file)
@@ -60,6 +60,34 @@ public class ExpressionClassLoader extends ClassLoader implements MutableClassLo
         return defineClass(name, bytes, 0, bytes.length);
     }
     
+    public byte[] getBytes(String name) {
+        // Non-SCL classes are not handled here
+        if(!name.startsWith(SCL_PACKAGE_PREFIX))
+            return null;
+
+        // Determine the id of the class loader which is responsible of the class
+        String requestedModuleName = RuntimeModule.extractClassLoaderId(name);
+
+        // Is class defined locally in this class loader?
+        if(requestedModuleName.equals(basePackageName)) {
+            String internalName = name.replace('.', '/');
+            byte[] bytes = localClasses.get(internalName);
+            if(bytes != null)
+                return bytes;
+            return localClasses.get(internalName);
+        }
+        
+        // Find suitable class loader that has this class locally
+        {
+            RuntimeModule parentModule = runtimeModuleMap.get(requestedModuleName);
+            if(parentModule == null)
+                return null;
+
+            // Find the class from the ancestor class loader
+            return parentModule.classLoader.getBytes(name);
+        }
+    }
+    
     private Class<?> getClass(String name) throws ClassNotFoundException {
         //System.out.println("getClass " + name);