From f4ee67c08b732eb271c92f4cad4b8b3b755495c9 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 10 Dec 2019 10:45:07 -0500 Subject: [PATCH] Fixed gradle complaining about absolutely nothing --- .../anuke/mindustry/AndroidRhinoContext.java | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/android/src/io/anuke/mindustry/AndroidRhinoContext.java b/android/src/io/anuke/mindustry/AndroidRhinoContext.java index 78ee040b50..82a8f7179d 100644 --- a/android/src/io/anuke/mindustry/AndroidRhinoContext.java +++ b/android/src/io/anuke/mindustry/AndroidRhinoContext.java @@ -12,7 +12,6 @@ import com.android.dx.merge.*; import dalvik.system.*; import io.anuke.arc.*; import io.anuke.arc.backends.android.surfaceview.*; -import io.anuke.mindustry.AndroidRhinoContext.BaseAndroidClassLoader.*; import org.mozilla.javascript.*; import java.io.*; @@ -149,77 +148,78 @@ public class AndroidRhinoContext{ } return loadedClass; } + } - /** Might be thrown in any Rhino method that loads bytecode if the loading failed. */ - public static class FatalLoadingException extends RuntimeException{ - FatalLoadingException(Throwable t){ - super("Failed to define class", t); - } + + /** Might be thrown in any Rhino method that loads bytecode if the loading failed. */ + public static class FatalLoadingException extends RuntimeException{ + FatalLoadingException(Throwable t){ + super("Failed to define class", t); + } + } + + static class FileAndroidClassLoader extends BaseAndroidClassLoader{ + private static int instanceCounter = 0; + private final File dexFile; + + public FileAndroidClassLoader(ClassLoader parent, File cacheDir){ + super(parent); + int id = instanceCounter++; + dexFile = new File(cacheDir, id + ".dex"); + cacheDir.mkdirs(); + reset(); } - static class FileAndroidClassLoader extends BaseAndroidClassLoader{ - private static int instanceCounter = 0; - private final File dexFile; - - public FileAndroidClassLoader(ClassLoader parent, File cacheDir){ - super(parent); - int id = instanceCounter++; - dexFile = new File(cacheDir, id + ".dex"); - cacheDir.mkdirs(); - reset(); + @Override + protected Class loadClass(Dex dex, String name) throws ClassNotFoundException{ + try{ + dex.writeTo(dexFile); + }catch(IOException e){ + e.printStackTrace(); } + return new DexClassLoader(dexFile.getPath(), ((AndroidApplication)Core.app).getContext().getCacheDir().getAbsolutePath(), null, getParent()).loadClass(name); + } - @Override - protected Class loadClass(Dex dex, String name) throws ClassNotFoundException{ + @Override + protected Dex getLastDex(){ + if(dexFile.exists()){ try{ - dex.writeTo(dexFile); + return new Dex(dexFile); }catch(IOException e){ e.printStackTrace(); } - return new DexClassLoader(dexFile.getPath(), ((AndroidApplication)Core.app).getContext().getCacheDir().getAbsolutePath(), null, getParent()).loadClass(name); - } - - @Override - protected Dex getLastDex(){ - if(dexFile.exists()){ - try{ - return new Dex(dexFile); - }catch(IOException e){ - e.printStackTrace(); - } - } - return null; - } - - @Override - protected void reset(){ - dexFile.delete(); } + return null; } - @TargetApi(Build.VERSION_CODES.O) - static class InMemoryAndroidClassLoader extends BaseAndroidClassLoader{ - private Dex last; + @Override + protected void reset(){ + dexFile.delete(); + } + } - public InMemoryAndroidClassLoader(ClassLoader parent){ - super(parent); - } + @TargetApi(Build.VERSION_CODES.O) + static class InMemoryAndroidClassLoader extends BaseAndroidClassLoader{ + private Dex last; - @Override - protected Class loadClass(Dex dex, String name) throws ClassNotFoundException{ - last = dex; - return new InMemoryDexClassLoader(ByteBuffer.wrap(dex.getBytes()), getParent()).loadClass(name); - } + public InMemoryAndroidClassLoader(ClassLoader parent){ + super(parent); + } - @Override - protected Dex getLastDex(){ - return last; - } + @Override + protected Class loadClass(Dex dex, String name) throws ClassNotFoundException{ + last = dex; + return new InMemoryDexClassLoader(ByteBuffer.wrap(dex.getBytes()), getParent()).loadClass(name); + } - @Override - protected void reset(){ - last = null; - } + @Override + protected Dex getLastDex(){ + return last; + } + + @Override + protected void reset(){ + last = null; } } }