Permalink
Browse files

enabled loading of kilim/S_ classes when running from within a Cygwin…

… shell
  • Loading branch information...
1 parent 17d9a08 commit b14797a6534d7dbc603df3d02d4601a03b81a660 @pavlobaron committed Dec 26, 2010
Showing with 18 additions and 8 deletions.
  1. +3 −3 erjang_cfg.properties
  2. +11 −4 src/main/java/erjang/EModuleClassLoader.java
  3. +4 −1 src/main/java/erjang/EModuleLoader.java
View
@@ -1,6 +1,6 @@
-erjang.otp.root = /usr/local/lib/erlang
-# erjang.erts.version = 5.8
-# erjang.otp.version = R14A
+erjang.otp.root = c:/erlang
+erjang.erts.version = 5.8.1.1
+erjang.otp.version = R14B
# erjang.debug.port=true
# erjang.debug.inet=true
@@ -28,7 +28,7 @@
* Each module has it's own class loader.
*/
public class EModuleClassLoader extends URLClassLoader {
-
+
/**
* @param urls
*/
@@ -50,15 +50,14 @@ public EModuleClassLoader(URL loadFrom) {
String ETUPLE_NAME = ETuple.class.getName();
String EFUN_NAME = EFun.class.getName();
-
+
/*
* (non-Javadoc)
*
* @see java.lang.ClassLoader#findClass(java.lang.String)
*/
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
-
if (name.startsWith(ETUPLE_NAME)) {
int arity = Integer.parseInt(name.substring(ETUPLE_NAME.length()));
return ETuple.get_tuple_class(arity);
@@ -74,7 +73,15 @@ public EModuleClassLoader(URL loadFrom) {
InputStream resource = super.getResourceAsStream(classFileName);
if (resource == null) {
- throw new ClassNotFoundException(name, new Error("while loading "+this.getURLs()[0]));
+ /* old problem - Java never knows we're on Cygwin so it thinks we're on Windows and uses
+ /* '\\' instead of '/' as file separator. Further, we can't reliably know we have been
+ * executed from a Cygwin shell (too many ways to to this). So simply fall back to '/'
+ * and try to get the resource stream again. Then, fail finally */
+ classFileName = classFileName.replace(File.separatorChar, '/');
+ resource = super.getResourceAsStream(classFileName);
+ if (resource == null) {
+ throw new ClassNotFoundException(name, new Error("while loading "+this.getURLs()[0]));
+ }
}
try {
@@ -138,7 +138,10 @@ private static void addLoadPaths(List<File> out, String path) {
@SuppressWarnings("unchecked")
public static EModule load_compiled_module(String mod, URL jarUrl) {
-// System.err.println("EML| load_compiled_module: "+mod+" @ "+jarUrl);
+ if (DEBUG_MODULE_LOAD) {
+ System.err.println("EML| load_compiled_module: "+mod+" @ "+jarUrl);
+ }
+
String internalName = erjang.beam.Compiler.moduleClassName(mod);
String java_name = internalName.replace('/', '.');
EModuleClassLoader loader = new EModuleClassLoader(jarUrl);

0 comments on commit b14797a

Please sign in to comment.