import org.eclipse.core.runtime.FileLocator;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
import org.osgi.framework.wiring.BundleWiring;
import org.simantics.scl.compiler.internal.codegen.types.JavaReferenceValidatorFactory;
import org.simantics.scl.compiler.module.ImportDeclaration;
}
return digest.digest();
} catch (NoSuchAlgorithmException e) {
- LOGGER.error("No SHA1 algorithm available", e);
+ LOGGER.error("No SHA1 algorithm found", e);
return new byte[0];
} finally {
stream.close();
}
} catch(IOException e) {
- LOGGER.error("Could not compute digest for {}", this);
+ LOGGER.error("Could not compute digest for {}", getModuleName(), e);
return new byte[0];
}
}
}
return url.openStream();
}
-
+
@Override
public ClassLoader getClassLoader() {
- if(bundle.getSymbolicName().equals("org.simantics.scl.runtime"))
+ if (bundle.getSymbolicName().equals("org.simantics.scl.runtime"))
return Type.class.getClassLoader();
else {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
- if(wiring != null)
+ if (wiring == null && bundle.getState() == Bundle.INSTALLED) {
+ try {
+ bundle.start();
+ } catch (BundleException e) {
+ LOGGER.error("Could not start bundle {}", bundle.getSymbolicName(), e);
+ }
+ wiring = bundle.adapt(BundleWiring.class);
+ }
+ if (wiring != null) {
return wiring.getClassLoader();
- else
+ } else {
+ LOGGER.error("Couldn't find class loader for bundle {} with state {}", bundle.getSymbolicName(), BundleUtils.resolveBundleState(bundle));
return getClass().getClassLoader();
+ }
}
}
return;
Files.write(path, newSourceText.getBytes(Charset.forName("UTF-8")));
} catch(IOException e) {
- LOGGER.error("Could not update {} with {}", this, newSourceText, e);
+ LOGGER.error("Could not update module {} in url {} with text {}", getModuleName(), url, newSourceText);
}
checkUpdates();
}