# Class Specific Name Resolver

###### Identifier:

org.eclipse.mat.api.nameResolver

###### Since:

0.7.0

###### Description:

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.

###### Configuration Markup:

<!ELEMENT extension (resolver)+>

<!ATTLIST extension

point CDATA #REQUIRED

id CDATA #IMPLIED

name CDATA #IMPLIED

>

<!ELEMENT resolver EMPTY>

<!ATTLIST resolver

impl CDATA #REQUIRED

>

- impl - implementor of `org.eclipse.mat.snapshot.extension.IClassSpecificNameResolver` annotated with `@Subject` or `@Subjects`.

###### Examples:

Following is an example of a name resolver declaration:

       <extension point="org.eclipse.mat.api.nameResolver">
          <resolver impl="org.eclipse.mat.inspections.CommonNameResolver$ThreadResolver" />
       </extension>

The implemenation could look like this:

       @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.

###### API Information:

The value of the impl attribute must represent an implementor of `org.eclipse.mat.snapshot.extension.IClassSpecificNameResolver`.

###### Supplied Implementation:

The Memory Analyzer supplies a number of name resolvers itself. Check out the `org.eclipse.mat.inspections.CommonNameResolver` for more samples.

Copyright (c) 2008,2011 SAP AG and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/