I also tried this. Leaving off the WHERE clause lets me see which classes match, but filtering or sorting on the index column results in an internal error with the same message ("Method getName not found...")
Executed Query:
SELECT
c AS clazz,
c.getName() AS name,
c.getName().indexOf("com.myco") AS index
FROM
java.lang.Class c
WHERE
c.getName().indexOf("com.myco") != 0
Problem reported:
Method getName not found in object java.lang.Class [id=0x12d3d8c38]
The problem with your original query is that the string "name" is just a label for the column in the result table, not a variable, so the value "name" in the WHERE clause is not bound to any value, resulting in the NullPointerException.
Maybe this can be caught and a more informative message issued.
Executed Query:
SELECT
c AS clazz,
c.getName() AS name,
c.getName().indexOf("com.myco") AS index
FROM
java.lang.Class c
WHERE
c.getName().indexOf("com.myco") != 0
Problem reported: Method getName not found in object java.lang.Class [id=0x12d3d8c38]
I get
Problem reported:
java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.eclipse.mat.parser.internal.oql.compiler.MethodCallExpression.compute(MethodCallExpression.java:107)
at org.eclipse.mat.parser.internal.oql.compiler.PathExpression.compute(PathExpression.java:117)
at org.eclipse.mat.parser.internal.oql.compiler.Operation$RelationalOperation.compute(Operation.java:87)
at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.accept(OQLQueryImpl.java:1035)
at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.accept(OQLQueryImpl.java:1025)
at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.filterClasses(OQLQueryImpl.java:1007)
at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.doFromItem(OQLQueryImpl.java:853)
at org.eclipse.mat.parser.internal.oql.OQLQueryImpl.internalExecute(OQLQueryImpl.java:650)
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)