3

Is it possible in OQL to retrieve all the objects that belongs to a package? Or can I query with wildcards?

As @haridsv suggested I tried:

SELECT * from "com.example.*"

and

SELECT a from "com\.example\..*"

but in VisualVM it complaints that no such package exists.

Even

SELECT a from "java.io.File" a

Fails.

Thanks!

ssedano.

ssedano
  • 8,322
  • 9
  • 60
  • 98

3 Answers3

5

You can use regular expression like this:

SELECT * from "<packagename>.*"

If the package name is "java.io" you would use:

SELECT * from "java\.io\..*"

Note the quotes around the regex and how the dots in the path are protected.

haridsv
  • 9,065
  • 4
  • 62
  • 65
  • Using the OQL console in visualvm those selects does not work. but thanks for answer !! – ssedano Sep 17 '12 at 08:20
  • 3
    I was suggesting OQL for Eclipse MAT, where as the OQL syntax for VisualVM is quite different. My apologies if I missed to see your requirements clearly. – haridsv Sep 17 '12 at 10:46
  • It didn't occur to me that I should clarify, may be because I had my head deep in a heap analysis with MAT :) – haridsv Sep 18 '12 at 03:49
  • @haridsv: I was using Android's memory analyzer and your queries were exactly what I needed. I found the example given in the selected answer and it doesn't work but your suggestion did. Thanks! – gMale Nov 26 '13 at 19:42
5

I found the answer in VisualVM OQL help.

select filter(heap.classes(), "/com.example./(it.name)")
Neeme Praks
  • 8,956
  • 5
  • 47
  • 47
ssedano
  • 8,322
  • 9
  • 60
  • 98
0

From VisualVM limited documentation:

  • select all classes that have name pattern java.net.*

select filter(heap.classes(), "/java.net./.test(it.name)")

https://visualvm.github.io/documentation.html

The trick is in the "test(it.name)"

Mike
  • 1
  • 1