vlsi / mat-calcite-plugin

Heap query plugin for Eclipse Memory Analyzer
Apache License 2.0
148 stars 24 forks source link

Allow to query on class metadata #20

Closed gunnarmorling closed 3 years ago

gunnarmorling commented 3 years ago

First off: really nice idea with this plug-in!

I tried to come up with a query for selecting classes loaded more than once, something like so:

select c. this
from "java.lang.Class" c, join "java.lang.Classloader" cl on cl.this = c.classLoader
group by c
having count (*) > 1

But the classLoader attribute of the java.lang.Class objects seems not populated. Any idea how this could be done? Given there's a "duplicate classes" view in MAT itself, I suppose there must be some way.

vlsi commented 3 years ago

Currently I use org.eclipse.mat.snapshot.model.IClass#getFieldDescriptors to get the list of "fields", and, apparently, it does not return fields like "class", "superclass", "classloader".

Of course, the information is available (e.g. org.eclipse.mat.snapshot.model.IObject#getClazz), so it should be added to SQL schema.

gunnarmorling commented 3 years ago

Wow, that was fast, thanks! Are you planning to push a release with this some time soon?

vlsi commented 3 years ago

Well, all the commits are pushed to the early-access repository (see https://github.com/vlsi/mat-calcite-plugin#early-access-versions)

I've just pushed v1.5.0, please check it :)

gunnarmorling commented 3 years ago

Oh, I wasn't aware of the EA repo. Can confirm in any case it works, see https://twitter.com/gunnarmorling/status/1315634755325566976. Thanks a lot!