X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Fruntime%2FExpressionClassLoader.java;h=0c134ee5c1130b5e9e730dd9552e01401f367c43;hp=c91daab91147480b6437b32a52be87a261b50261;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ExpressionClassLoader.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ExpressionClassLoader.java index c91daab91..0c134ee5c 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ExpressionClassLoader.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ExpressionClassLoader.java @@ -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);