0

I'm using VisualVM 1.3.8 to analyze a heap dump and the following query shows up with 0 results:

select s from java.lang.String s where s.count >= 0

Doing select s from java.lang.String shows several strings of size >= 0 so I don't see why this wouldn't work. This also applies when using other types of custom objects and trying to query based on a field (e.g. myObj.value). I'm wondering if this is a bug or there is in fact a special way to access the fields that is not documented. I'm using OpenJDK 8 fwiw.

Edit: the query about is basically given as an example on the visualvm site so I'm having trouble understanding why it doesn't work.

yshavit
  • 42,327
  • 7
  • 87
  • 124
  • The String in jdk 8 (since 7, actually) doesn't have a `count`. Substrings just get a new `char[]` of the right length. – yshavit Jun 06 '16 at 21:57
  • 1
    s.length does not work either – user3927950 Jun 07 '16 at 12:13
  • It doesn't have that, either. The only fields it has are `char value[]` and `int hash`: [source on grepcode](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8-b132/java/lang/String.java?av=f). – yshavit Jun 07 '16 at 14:06
  • So how could I do that query or any query pertaining to filtering out objects based on a member variable? Also that is the example from the visualvm site (linked in the question now) – user3927950 Jun 07 '16 at 15:54
  • I don't know that aspect of visualvm well enough to answer (which is why I didn't post an answer :) ). Their example is probably a holdover from JDK 6 and before, when String did have a `count` field. What you basically want is conceptually like `s.value.length` -- but I don't know if visualvm lets you do that. – yshavit Jun 07 '16 at 16:16
  • thanks for feedback~ – user3927950 Jun 08 '16 at 15:28

0 Answers0