-
Notifications
You must be signed in to change notification settings - Fork 3
/
FinalizerQuery.java
67 lines (60 loc) · 3.24 KB
/
FinalizerQuery.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
* Copyright (c) 2008, 2023 SAP AG and IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* SAP AG - initial API and implementation
* IBM Corporation - enhancements and fixes
*******************************************************************************/
package org.eclipse.mat.inspections.finalizer;
import org.eclipse.mat.internal.Messages;
import org.eclipse.mat.query.IQuery;
import org.eclipse.mat.query.IResult;
import org.eclipse.mat.query.annotations.Argument;
import org.eclipse.mat.query.annotations.CommandName;
import org.eclipse.mat.query.annotations.HelpUrl;
import org.eclipse.mat.query.annotations.Icon;
import org.eclipse.mat.report.Params;
import org.eclipse.mat.report.QuerySpec;
import org.eclipse.mat.report.SectionSpec;
import org.eclipse.mat.snapshot.ISnapshot;
import org.eclipse.mat.snapshot.query.SnapshotQuery;
import org.eclipse.mat.util.IProgressListener;
import org.eclipse.mat.util.SimpleMonitor;
@CommandName("finalizer_overview")
@Icon("/META-INF/icons/finalizer.gif")
@HelpUrl("/org.eclipse.mat.ui.help/tasks/analyzingfinalizer.html")
public class FinalizerQuery implements IQuery
{
@Argument
public ISnapshot snapshot;
public IResult execute(IProgressListener listener) throws Exception
{
SimpleMonitor monitor = new SimpleMonitor(Messages.FinalizerQuery_Finalizers, listener, new int[] { 100, 100, 100, 100 });
SectionSpec spec = new SectionSpec(Messages.FinalizerQuery_Finalizers);
IResult result = SnapshotQuery.lookup("finalizer_in_processing", snapshot).execute(monitor.nextMonitor()); //$NON-NLS-1$
QuerySpec inProcessing = new QuerySpec(Messages.FinalizerQuery_InProcessing, result);
inProcessing.setCommand("finalizer_in_processing"); //$NON-NLS-1$
spec.add(inProcessing);
result = SnapshotQuery.lookup("finalizer_queue", snapshot).execute(monitor.nextMonitor()); //$NON-NLS-1$
QuerySpec finalizerQueue = new QuerySpec(Messages.FinalizerQuery_ReadyForFinalizer, result);
finalizerQueue.setCommand("finalizer_queue"); //$NON-NLS-1$
spec.add(finalizerQueue);
finalizerQueue.set(Params.Html.SHOW_HEADING, Boolean.FALSE.toString());
result = SnapshotQuery.lookup("finalizer_thread", snapshot).execute(monitor.nextMonitor()); //$NON-NLS-1$
QuerySpec finalizerThread = new QuerySpec(Messages.FinalizerQuery_FinalizerThread, result);
finalizerThread.setCommand("finalizer_thread"); //$NON-NLS-1$
spec.add(finalizerThread);
result = SnapshotQuery.lookup("finalizer_thread_locals", snapshot).execute(monitor.nextMonitor()); //$NON-NLS-1$
QuerySpec finalizerLocals = new QuerySpec(Messages.FinalizerQuery_FinalizerThreadLocals, result);
finalizerLocals.setCommand("finalizer_thread_locals"); //$NON-NLS-1$
spec.add(finalizerLocals);
listener.done();
return spec;
}
}