Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Memory Analyzer » OQL query problem
OQL query problem [message #696757] Thu, 14 July 2011 19:10 Go to next message
jonathan.oexner is currently offline jonathan.oexnerFriend
Messages: 2
Registered: July 2011
Junior Member
Hi,
I'm trying to list all the classes in the heap dump in a certain package, but I'm having trouble getting the query to work. Here's what I have:

SELECT getName() as name
FROM java.lang.Class
WHERE name.startsWith("com.myco")


And running it from MAT 1.1.0, I get a NullPointerException

What am I doing wrong?
Re: OQL query problem [message #696812 is a reply to message #696757] Thu, 14 July 2011 21:20 Go to previous messageGo to next message
jonathan.oexner is currently offline jonathan.oexnerFriend
Messages: 2
Registered: July 2011
Junior Member
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]
Re: OQL query problem [message #698535 is a reply to message #696812] Tue, 19 July 2011 16:05 Go to previous messageGo to next message
Jonathan Lawrence is currently offline Jonathan LawrenceFriend
Messages: 16
Registered: July 2009
Junior Member
Try this:

SELECT * FROM java.lang.Class c WHERE c.@getName().startsWith("com.myco")

I think you've also found a bug anyway, as Memory Analyzer should not throw a NullPointer exception whatever syntax you enter for an OQL query.
Re: OQL query problem [message #698539 is a reply to message #698535] Tue, 19 July 2011 16:14 Go to previous messageGo to next message
Jonathan Lawrence is currently offline Jonathan LawrenceFriend
Messages: 16
Registered: July 2009
Junior Member
This also works:

SELECT * FROM java.lang.Class c WHERE c.getName().startsWith("com.myco")
Re: OQL query problem [message #698541 is a reply to message #698539] Tue, 19 July 2011 16:22 Go to previous messageGo to next message
Jonathan Lawrence is currently offline Jonathan LawrenceFriend
Messages: 16
Registered: July 2009
Junior Member
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.
Re: OQL query problem [message #977819 is a reply to message #696812] Fri, 09 November 2012 15:59 Go to previous message
Andrew Johnson is currently offline Andrew JohnsonFriend
Messages: 205
Registered: July 2009
Senior Member
I think there is another bug here:

Quote:
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)


I'm following this up in Bugzilla 393982 OQL method invocations with overloaded methods can fail
Previous Topic:Memory Analyzer 1.2.1 is released
Next Topic:OQL enhancements
Goto Forum:
  


Current Time: Tue Apr 16 16:09:31 GMT 2024

Powered by FUDForum. Page generated in 0.84529 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top