3

I can get all Thread objects by using query as below

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

then if I want to do further analysis of the returned result objects, the OQL I think should be like below:

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

But it turns to 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)

Does OQL in MAT Eclipse supports embedded query, and how can I get the results I want?

Y.Huang
  • 119
  • 2
  • 11
  • Just like the message says and is documented, the sub-query HAS to return class objects, see here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Freference%2Foqlsyntaxfrom.html – haridsv Aug 01 '12 at 13:28
  • Perhaps you can state what you are trying to achieve with such a query? – haridsv Aug 01 '12 at 13:28
  • Do you want to see Threads which are in dominators? – Anton Feb 01 '13 at 10:32

1 Answers1

7

It is a little bit tricky to make the sub-query work. Try following:

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

I got the solution from below link: https://www.eclipse.org/forums/index.php/t/608746/

painlet
  • 71
  • 1
  • 2