When browsing the object list, the Memory Analyzer prints a class specific name next to the object address. This could be the content of the char[] for a java.lang.String or the name attribute of a java.lang.Thread object.
Use this extension point to provide custom name resolvers: for example the title for catalog objects, the user id of authenticated session, etc. etc.
<!ELEMENT extension (resolver)+>
<!ATTLIST extension
point CDATA #REQUIRED
id CDATA #IMPLIED
name CDATA #IMPLIED>
<!ELEMENT resolver EMPTY>
<!ATTLIST resolver
impl CDATA #REQUIRED>
The implemenation could look like this:<extension point=
"org.eclipse.mat.api.nameResolver"
>
<resolver impl=
"org.eclipse.mat.inspections.CommonNameResolver$ThreadResolver"
/>
</extension>
@Subject("java.lang.Thread") public static class ThreadResolver implements IClassSpecificNameResolver { public String resolve(IObject obj) throws SnapshotException { IObject name = (IObject) obj.resolveValue("name"); return name != null ? name.getClassSpecificName() : null; } }The @Subject tells the Memory Analyzer, to use this name resolver for all instances of type "java.lang.Thread". The implementation then extracts the name attribute (which is a String or a char[] object, depending on the implementation of the JDK) and returns its class specific name.
Copyright (c) 2008 SAP AG and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0 which
accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html