如何在MAT Eclipse中使用OQL进行嵌入式查询

时间:2012-07-19 04:57:08

标签: java eclipse oql

我可以使用查询获取所有Thread对象,如下所示

SELECT OBJECTS dominators(s) FROM java.lang.Thread s

那么如果我想对返回的结果对象进行进一步的分析,我认为OQL应该如下所示:

SELECT * from (SELECT OBJECTS dominators(s) FROM java.lang.Thread s)

但它转向ClassCastException。

Problem reported: 
ClassCastException occured. Remember: sub queries with the modifier INSTANCESOF or INCLUDING SUBCLASSES must return only class objects 

java.lang.ClassCastException: org.eclipse.mat.parser.model.InstanceImpl cannot be cast to org.eclipse.mat.snapshot.model.IClass
    at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.doSubQuery(OQLQueryImpl.java:752)
    at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.internalExecute(OQLQueryImpl.java:642)
    at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.execute(OQLQueryImpl.java:627)
    at org.eclipse.mat.inspections.OQLQuery.execute(OQLQuery.java:50)
    at org.eclipse.mat.inspections.OQLQuery.execute(OQLQuery.java:1)
    at org.eclipse.mat.query.registry.ArgumentSet.execute(ArgumentSet.java:129)
    at org.eclipse.mat.ui.snapshot.panes.OQLPane$OQLJob.doRun(OQLPane.java:339)
    at org.eclipse.mat.ui.editor.AbstractPaneJob.run(AbstractPaneJob.java:34)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

MAT Eclipse中的OQL是否支持嵌入式查询,如何获得我想要的结果?

1 个答案:

答案 0 :(得分:3)

使子查询工作有点棘手。请尝试以下方法:

SELECT * from OBJECTS (SELECT OBJECTS dominators(s) FROM java.lang.Thread s)

我从以下链接获得了解决方案: https://www.eclipse.org/forums/index.php/t/608746/