assets/src/org/ruboto/JRubyAdapter.java in ruboto-0.11.0 vs assets/src/org/ruboto/JRubyAdapter.java in ruboto-0.12.0.rc.0
- old
+ new
@@ -21,96 +21,10 @@
private static boolean initialized = false;
private static String localContextScope = "SINGLETON"; // FIXME(uwe): Why not CONCURRENT ? Help needed!
private static String localVariableBehavior = "TRANSIENT";
private static String RUBOTO_CORE_VERSION_NAME;
- /**
- * @deprecated As of Ruboto 0.7.1, replaced by {@link #runRubyMethod(Object receiver, String methodName, Object... args)}
- */
- @Deprecated public static void callMethod(Object receiver, String methodName, Object[] args) {
- runRubyMethod(receiver, methodName, args);
- }
-
- /**
- * @deprecated As of Ruboto 0.7.1, replaced by {@link #runRubyMethod(Object receiver, String methodName, Object... args)}
- */
- @Deprecated public static void callMethod(Object object, String methodName, Object arg) {
- runRubyMethod(object, methodName, arg);
- }
-
- /**
- * @deprecated As of Ruboto 0.7.1, replaced by {@link #runRubyMethod(Object receiver, String methodName, Object... args)}
- */
- @Deprecated public static void callMethod(Object object, String methodName) {
- runRubyMethod(object, methodName, new Object[] {});
- }
-
- /**
- * @deprecated As of Ruboto 0.7.1, replaced by {@link #runRubyMethod(Class<T> returnType, Object receiver, String methodName, Object... args)}
- */
- @SuppressWarnings("unchecked")
- @Deprecated public static <T> T callMethod(Object receiver, String methodName, Object[] args, Class<T> returnType) {
- return (T) runRubyMethod(returnType, receiver, methodName, args);
- }
-
- /**
- * @deprecated As of Ruboto 0.7.1, replaced by {@link #runRubyMethod(Class<T> returnType, Object receiver, String methodName, Object... args)}
- */
- @SuppressWarnings("unchecked")
- @Deprecated public static <T> T callMethod(Object receiver, String methodName, Object arg, Class<T> returnType) {
- return (T) runRubyMethod(returnType, receiver, methodName, arg);
- }
-
- /**
- * @deprecated As of Ruboto 0.7.1, replaced by {@link #runRubyMethod(Class<T> returnType, Object receiver, String methodName, Object... args)}
- */
- @SuppressWarnings("unchecked")
- @Deprecated public static <T> T callMethod(Object receiver, String methodName, Class<T> returnType) {
- return (T) runRubyMethod(returnType, receiver, methodName);
- }
-
- /**
- * @deprecated As of Ruboto 0.7.0, replaced by {@link #put(String name, Object object)}
- */
- @Deprecated public static void defineGlobalConstant(String name, Object object) {
- put(name, object);
- }
-
- /**
- * @deprecated As of Ruboto 0.7.0, replaced by {@link #put(String name, Object object)}
- */
- @Deprecated public static void defineGlobalVariable(String name, Object object) {
- put(name, object);
- }
-
- /**
- * @deprecated As of Ruboto 0.7.0, replaced by {@link #runScriptlet(String code)}
- */
- @Deprecated public static Object exec(String code) {
- try {
- Method runScriptletMethod = ruby.getClass().getMethod("runScriptlet", String.class);
- return runScriptletMethod.invoke(ruby, code);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae);
- } catch (java.lang.reflect.InvocationTargetException ite) {
- if (isDebugBuild) {
- throw ((RuntimeException) ite.getCause());
- } else {
- return null;
- }
- }
- }
-
- /**
- * @deprecated As of Ruboto 0.7.0, replaced by {@link #runScriptlet(String code)}
- */
- @Deprecated public static String execute(String code) {
- return (String) runRubyMethod(String.class, exec(code), "inspect");
- }
-
public static Object get(String name) {
try {
Method getMethod = ruby.getClass().getMethod("get", String.class);
return getMethod.invoke(ruby, name);
} catch (NoSuchMethodException nsme) {
@@ -130,25 +44,12 @@
return (String) callScriptingContainerMethod(String.class, "getScriptFilename");
}
public static Object runRubyMethod(Object receiver, String methodName, Object... args) {
try {
- // FIXME(uwe): Simplify when we stop supporting JRuby < 1.7.0
- if (isJRubyPreOneSeven()) {
- if (args.length == 0) {
- Method m = ruby.getClass().getMethod("callMethod", Object.class, String.class, Class.class);
- // System.out.println("Calling callMethod(" + receiver + ", " + methodName + ", " + Object.class + ")");
- return m.invoke(ruby, receiver, methodName, Object.class);
- } else {
- Method m = ruby.getClass().getMethod("callMethod", Object.class, String.class, Object[].class, Class.class);
- // System.out.println("Calling callMethod(" + receiver + ", " + methodName + ", " + args + ", " + Object.class + ")");
- return m.invoke(ruby, receiver, methodName, args, Object.class);
- }
- } else {
- Method m = ruby.getClass().getMethod("runRubyMethod", Class.class, Object.class, String.class, Object[].class);
- return m.invoke(ruby, Object.class, receiver, methodName, args);
- }
+ Method m = ruby.getClass().getMethod("runRubyMethod", Class.class, Object.class, String.class, Object[].class);
+ return m.invoke(ruby, Object.class, receiver, methodName, args);
} catch (NoSuchMethodException nsme) {
throw new RuntimeException(nsme);
} catch (IllegalAccessException iae) {
throw new RuntimeException(iae);
} catch (java.lang.reflect.InvocationTargetException ite) {
@@ -161,23 +62,12 @@
}
@SuppressWarnings("unchecked")
public static <T> T runRubyMethod(Class<T> returnType, Object receiver, String methodName, Object... args) {
try {
- // FIXME(uwe): Simplify when we stop supporting JRuby < 1.7.0
- if (isJRubyPreOneSeven()) {
- if (args.length == 0) {
- Method m = ruby.getClass().getMethod("callMethod", Object.class, String.class, Class.class);
- return (T) m.invoke(ruby, receiver, methodName, returnType);
- } else {
- Method m = ruby.getClass().getMethod("callMethod", Object.class, String.class, Object[].class, Class.class);
- return (T) m.invoke(ruby, receiver, methodName, args, returnType);
- }
- } else {
- Method m = ruby.getClass().getMethod("runRubyMethod", Class.class, Object.class, String.class, Object[].class);
- return (T) m.invoke(ruby, returnType, receiver, methodName, args);
- }
+ Method m = ruby.getClass().getMethod("runRubyMethod", Class.class, Object.class, String.class, Object[].class);
+ return (T) m.invoke(ruby, returnType, receiver, methodName, args);
} catch (NoSuchMethodException nsme) {
throw new RuntimeException(nsme);
} catch (IllegalAccessException iae) {
throw new RuntimeException(iae);
} catch (java.lang.reflect.InvocationTargetException ite) {
@@ -260,15 +150,10 @@
// Used to enable JRuby to generate proxy classes
System.setProperty("jruby.ji.proxyClassFactory", "org.ruboto.DalvikProxyClassFactory");
System.setProperty("jruby.class.cache.path", appContext.getDir("dex", 0).getAbsolutePath());
- // Workaround for bug in Android 2.2
- // http://code.google.com/p/android/issues/detail?id=9431
- // System.setProperty("java.net.preferIPv4Stack", "true");
- // System.setProperty("java.net.preferIPv6Addresses", "false");
-
ClassLoader classLoader;
Class<?> scriptingContainerClass;
String apkName = null;
try {
@@ -457,20 +342,10 @@
Log.e(e.getMessage() != null ? e.getMessage() : e.getClass().getName());
e.printStackTrace();
ruby = null;
}
- // FIXME(uwe): Remove when we stop supporting JRuby < 1.7.0
- @Deprecated public static boolean isJRubyPreOneSeven() {
- return ((String)get("JRUBY_VERSION")).equals("1.7.0.dev") || ((String)get("JRUBY_VERSION")).startsWith("1.6.");
- }
-
- // FIXME(uwe): Remove when we stop supporting JRuby < 1.7.0
- @Deprecated public static boolean isJRubyOneSeven() {
- return !isJRubyPreOneSeven() && ((String)get("JRUBY_VERSION")).startsWith("1.7.");
- }
-
// FIXME(uwe): Remove when we stop supporting Ruby 1.8
@Deprecated public static boolean isRubyOneEight() {
return ((String)get("RUBY_VERSION")).startsWith("1.8.");
}
@@ -494,32 +369,10 @@
}
private static String scriptsDirName(Context context) {
File storageDir = null;
if (isDebugBuild()) {
-
- // FIXME(uwe): Simplify this as soon as we drop support for android-7
- if (android.os.Build.VERSION.SDK_INT >= 8) {
- try {
- Method method = context.getClass().getMethod("getExternalFilesDir", String.class);
- storageDir = (File) method.invoke(context, (Object) null);
- } catch (SecurityException e) {
- printStackTrace(e);
- } catch (NoSuchMethodException e) {
- printStackTrace(e);
- } catch (IllegalArgumentException e) {
- printStackTrace(e);
- } catch (IllegalAccessException e) {
- printStackTrace(e);
- } catch (InvocationTargetException e) {
- printStackTrace(e);
- }
- } else {
- storageDir = new File(Environment.getExternalStorageDirectory(), "Android/data/" + context.getPackageName() + "/files");
- Log.e("Calculated path to sdcard the old way: " + storageDir);
- }
- // FIXME end
-
+ storageDir = context.getExternalFilesDir(null);
if (storageDir == null || (!storageDir.exists() && !storageDir.mkdirs())) {
Log.e("Development mode active, but sdcard is not available. Make sure you have added\n<uses-permission android:name='android.permission.WRITE_EXTERNAL_STORAGE' />\nto your AndroidManifest.xml file.");
storageDir = context.getFilesDir();
}
} else {