Fix backwards compatibility problem for JNI 2.6.
authorBernd Hufmann <bhufmann@gmail.com>
Tue, 26 Jul 2011 17:45:17 +0000 (13:45 -0400)
committerBernd Hufmann <bhufmann@gmail.com>
Tue, 26 Jul 2011 17:45:17 +0000 (13:45 -0400)
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTrace_v2_6.java

index 14d8e9b468bb9d8b9980558742a252f62ecf613a..6911255b521a1dbaf7467af639a21746b89b59e5 100644 (file)
@@ -77,6 +77,9 @@ public abstract class JniTrace extends Jni_C_Common {
     // Should we print debug in the C library or not?
     private boolean printLttDebug = DEFAULT_LTT_DEBUG;
     
+    // flag determine if live trace is supported or not
+    private boolean isLiveTraceSupported = false;
+    
     
     // This need to be called prior to any operation
     protected native int ltt_initializeHandle(String libname);
@@ -268,8 +271,16 @@ public abstract class JniTrace extends Jni_C_Common {
                // Call the LTT to open the trace
                // Note that the libraryId is not yet and the pointer
                long newPtr;
+               
                if (isLiveTraceSupported()) {
-                       newPtr = ltt_openTraceLive(newLibraryId, tracepath, printLttDebug);
+                   try {
+                       newPtr = ltt_openTraceLive(newLibraryId, tracepath, printLttDebug);
+                   } catch (UnsatisfiedLinkError e) {
+                       // JNI library doesn't support live trace read. Set flag for live trace support to false and
+                       // open trace in offline mode.
+                       setLiveTraceSupported(false);
+                       newPtr = ltt_openTrace(newLibraryId, tracepath, printLttDebug);
+                   }
                } else {
                        newPtr = ltt_openTrace(newLibraryId, tracepath, printLttDebug);
                }
@@ -785,12 +796,20 @@ public abstract class JniTrace extends Jni_C_Common {
 
     /**
      * Indicate whether a trace can be opened in live mode.
-     * Override if live mode is supported
      * 
      * @return true if the trace version supports live
      */
     public boolean isLiveTraceSupported() {
-       return false;
+        return isLiveTraceSupported;
+    }
+    
+    /**
+     * Sets whether a trace can be opened in live mode.
+     * 
+     * @param isSupported
+     */
+    protected void setLiveTraceSupported(boolean isSupported) {
+        isLiveTraceSupported = isSupported;
     }
     
     /**
index 12a2c84a3bb900df8e3030be4d92a5d7b86d645f..99bfa28636c886224aade731e7f4d962e08386ca 100644 (file)
@@ -37,8 +37,10 @@ public class JniTrace_v2_6 extends JniTrace {
         */
        protected JniTrace_v2_6() {
                super();
+               // Set live trace supported for 2.6 to true by default.
+               // Will be set to false if open live trace fails. 
+               setLiveTraceSupported(true);
     }
-    
        
        public JniTrace_v2_6(String newpath) throws JniException {
                super(newpath);
@@ -83,18 +85,4 @@ public class JniTrace_v2_6 extends JniTrace {
        public JniTracefile allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException {
        return new JniTracefile_v2_6(newPtr, newParentTrace);
     }
-
-
-    /**
-     * Indicate whether a trace can be opened in live mode.
-     * Override if live mode is supported
-     * 
-     * @return true if the trace version supports live
-     */
-       @Override
-       public boolean isLiveTraceSupported() {
-               return true;
-       }
-    
-    
 }
This page took 0.027516 seconds and 5 git commands to generate.