Fixed LuaJC not writing java package to bytecode correctly

This commit is contained in:
Thomas Cashman
2018-12-18 18:21:03 +00:00
parent e61e5694fa
commit 0e0533e2e6
2 changed files with 21 additions and 2 deletions

View File

@@ -189,8 +189,10 @@ public class luajc {
public Class findClass(String classname) throws ClassNotFoundException { public Class findClass(String classname) throws ClassNotFoundException {
byte[] bytes = (byte[]) t.get(classname); byte[] bytes = (byte[]) t.get(classname);
if ( bytes != null ) if ( bytes != null ) {
classname = classname.replace('/', '.');
return defineClass(classname, bytes, 0, bytes.length); return defineClass(classname, bytes, 0, bytes.length);
}
return super.findClass(classname); return super.findClass(classname);
} }
} }

View File

@@ -114,7 +114,24 @@ public class LuaJC implements Globals.Loader {
StringBuffer classname = new StringBuffer(); StringBuffer classname = new StringBuffer();
for (int i = 0, n = stub.length(); i < n; ++i) { for (int i = 0, n = stub.length(); i < n; ++i) {
final char c = stub.charAt(i); final char c = stub.charAt(i);
classname.append((((i == 0) && Character.isJavaIdentifierStart(c)) || ((i > 0) && Character.isJavaIdentifierPart(c)))? c: '_'); switch(i) {
case 0:
if(Character.isJavaIdentifierStart(c)) {
classname.append(c);
} else {
classname.append('_');
}
break;
default:
if(c == '/') {
classname.append(c);
} else if(Character.isJavaIdentifierPart(c)) {
classname.append(c);
} else {
classname.append('_');
}
break;
}
} }
return classname.toString(); return classname.toString();
} }