Convert anonymous classes to inner classes (gradle build support).

This commit is contained in:
James Roseborough
2015-03-08 20:22:30 +00:00
parent c0e043403f
commit c5081c5de1
9 changed files with 259 additions and 155 deletions

View File

@@ -180,6 +180,21 @@ public class luajc {
}
}
private static final class LocalClassLoader extends ClassLoader {
private final Hashtable t;
private LocalClassLoader(Hashtable t) {
this.t = t;
}
public Class findClass(String classname) throws ClassNotFoundException {
byte[] bytes = (byte[]) t.get(classname);
if ( bytes != null )
return defineClass(classname, bytes, 0, bytes.length);
return super.findClass(classname);
}
}
class InputFile {
public String luachunkname;
public String srcfilename;
@@ -230,14 +245,7 @@ public class luajc {
// try to load the files
if ( loadclasses ) {
ClassLoader loader = new ClassLoader() {
public Class findClass(String classname) throws ClassNotFoundException {
byte[] bytes = (byte[]) t.get(classname);
if ( bytes != null )
return defineClass(classname, bytes, 0, bytes.length);
return super.findClass(classname);
}
};
ClassLoader loader = new LocalClassLoader(t);
for ( Enumeration e = t.keys(); e.hasMoreElements(); ) {
String classname = (String) e.nextElement();
try {