package org.eclipse.tracecompass.btf.core.tests.utils;
-import java.io.IOException;
-
import org.eclipse.tracecompass.btf.core.trace.BtfTrace;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
* exception
*/
public static void main(String[] args) throws TmfTraceException {
- try (BtfTrace trace = new BtfTrace()) {
- trace.initTrace(null, BtfTestTrace.BTF_TEST.getFullPath(), null);
- System.out.println(trace.toString());
- ITmfContext ctx = trace.seekEvent(0);
- ITmfContext ctx1 = trace.seekEvent(10);
- ITmfEvent event = trace.getNext(ctx);
- ITmfEvent compare = null;
- while (event != null) {
- if (event.getRank() == 10) {
- compare = event;
- }
- printEvent(event);
- event = trace.getNext(ctx);
+ BtfTrace trace = new BtfTrace();
+ trace.initTrace(null, BtfTestTrace.BTF_TEST.getFullPath(), null);
+ System.out.println(trace.toString());
+
+ ITmfContext ctx = trace.seekEvent(0);
+ ITmfContext ctx1 = trace.seekEvent(10);
+ ITmfEvent event = trace.getNext(ctx);
+ ITmfEvent compare = null;
+ while (event != null) {
+ if (event.getRank() == 10) {
+ compare = event;
}
- ITmfEvent other = trace.getNext(ctx1);
- printEvent(other);
- printEvent(compare);
- } catch (IOException e) {
- e.printStackTrace();
+ printEvent(event);
+ event = trace.getNext(ctx);
}
+ ITmfEvent other = trace.getNext(ctx1);
+ printEvent(other);
+ printEvent(compare);
+
+ trace.dispose();
}
private static void printEvent(ITmfEvent event) {
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tracecompass.btf.core;singleton:=true
Bundle-Activator: org.eclipse.tracecompass.btf.core.Activator
*
* @author Matthew Khouzam
*/
-public class BtfTrace extends TmfTrace implements ITmfPersistentlyIndexable, ITmfTraceProperties, AutoCloseable {
+public class BtfTrace extends TmfTrace implements ITmfPersistentlyIndexable, ITmfTraceProperties {
private static final int MAX_FIELDS = 7;
}
@Override
- public void close() throws IOException {
- if (fFileInput != null) {
- fFileInput.close();
+ public synchronized void dispose() {
+ RandomAccessFile raf = fFileInput;
+ if (raf != null) {
+ try {
+ raf.close();
+ } catch (IOException e) {
+ }
}
+ super.dispose();
}
}