How to do embedded query using OQL in MAT Eclipse

2019-05-26 03:22发布

问题:

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?

回答1:

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/



标签: java eclipse oql