Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8098119

[Android] new versions of FX launcher classes on Dalvik

    XMLWordPrintable

    Details

      Description

      The implementation for launching a JavaFX application on Dalvik has changed a couple of times in the android-bitbucket repository. (i.e. allow more than 1 dex file, optimize startup performance)
      The following patch incorporates these changes.

      diff -r 9f5303fb78fb modules/graphics/src/dalvik/java/javafxports/android/DalvikLauncher.java
      --- a/modules/graphics/src/dalvik/java/javafxports/android/DalvikLauncher.java Fri Jun 13 12:36:57 2014 +1200
      +++ b/modules/graphics/src/dalvik/java/javafxports/android/DalvikLauncher.java Fri Jun 13 11:05:29 2014 +0200
      @@ -27,10 +27,8 @@
       import android.app.Activity;
       import android.content.Context;
       import android.content.pm.PackageManager;
      -import android.content.res.AssetManager;
       import android.util.Log;
       import dalvik.system.DexClassLoader;
      -import dalvik.system.PathClassLoader;
       import java.io.BufferedInputStream;
       
       import java.io.File;
      @@ -65,7 +63,7 @@
               this.activity = a;
               this.preloaderClassName = preloaderClassName;
               this.mainClassName = mainClassName;
      -
      +
               InputStream is = null;
               Properties userProperties = new Properties();
               try {
      @@ -81,10 +79,15 @@
                   System.getProperties().list(System.out);
       
               } catch (IOException e) {
      + Log.v(TAG, "Can't load properties");
                   throw new RuntimeException("Can't load properties", e);
               } finally {
      - try { is.close(); } catch(Exception e) {}
      -
      + try {
      + is.close();
      + } catch (Exception e) {
      + Log.v(TAG, "Exception closing properties InputStream");
      + }
      +
               }
       
               Log.v(TAG, "Launch JavaFX application on dalvik vm.");
      @@ -140,9 +143,9 @@
                   Log.e(TAG, "Launch failed with exception.", e);
               }
           }
      -
      +
           private static ClassLoader applicationClassLoader;
      -
      +
           private ClassLoader getApplicationClassLoader() {
               if (applicationClassLoader == null) {
                   // Internal storage where the DexClassLoader writes the optimized dex file to.
      @@ -150,11 +153,10 @@
       
                   // Initialize the class loader with the secondary dex file.
                   // This includes the javafx, compatibility and application classes
      -
                   ClassLoader cl = new DexClassLoader(FXActivity.dexClassPath,
      - optimizedDexOutputPath.getAbsolutePath(),
      - FXActivity.getInstance().getApplicationInfo().nativeLibraryDir,
      - activity.getClassLoader());
      + optimizedDexOutputPath.getAbsolutePath(),
      + FXActivity.getInstance().getApplicationInfo().nativeLibraryDir,
      + activity.getClassLoader());
                   Thread.currentThread().setContextClassLoader(cl);
                   applicationClassLoader = cl;
                   Log.v(TAG, "Application classloader initialized: " + applicationClassLoader);
      @@ -171,7 +173,7 @@
               FXActivity.getInstance().setOnSurfaceRedrawNeededNativeMethod(dalvikInputClass.getMethod("onSurfaceRedrawNeededNative"));
               FXActivity.getInstance().setOnConfigurationChangedNativeMethod(dalvikInputClass.getMethod("onConfigurationChangedNative", int.class));
           }
      -
      +
           private Class resolveApplicationClass()
                   throws PackageManager.NameNotFoundException, ClassNotFoundException {
       
      diff -r 9f5303fb78fb modules/graphics/src/dalvik/java/javafxports/android/FXActivity.java
      --- a/modules/graphics/src/dalvik/java/javafxports/android/FXActivity.java Fri Jun 13 12:36:57 2014 +1200
      +++ b/modules/graphics/src/dalvik/java/javafxports/android/FXActivity.java Fri Jun 13 11:05:29 2014 +0200
      @@ -68,7 +68,8 @@
               SurfaceHolder.Callback2 {
       
           private static final String TAG = "FXActivity";
      -
      + private static final String JFX_BUILD = "8udev";
      +
           private static final String ACTIVITY_LIB = "activity";
           private static final String META_DATA_LAUNCHER_CLASS = "launcher.class";
           private static final String DEFAULT_LAUNCHER_CLASS = "javafxports.android.DalvikLauncher";
      @@ -133,7 +134,7 @@
           protected void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
       
      - Log.v(TAG, "onCreate FXActivity");
      + Log.v(TAG, "onCreate called, using "+JFX_BUILD);
               if (launcher != null) {
                   Log.v(TAG, "JavaFX application is already running");
                   return;

        Attachments

          Activity

            People

            Assignee:
            ddhill David Hill (Inactive)
            Reporter:
            jvos Johan Vos
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: