## com.puppycrawl.tools.checkstyle.checks
Class ClassResolver

    java.lang.Object
      com.puppycrawl.tools.checkstyle.checks.ClassResolver

public class ClassResolver
extends java.lang.Object

Utility class to resolve a class name to an actual class. Note that loaded classes are not initialized.

Limitations: this does not handle inner classes very well.

Version:
  1.0
Author:
  Oliver Burn

Constructor Summary
`ClassResolver(java.lang.ClassLoader aLoader, java.lang.String aPkg, java.util.Set aImports)` Creates a new `ClassResolver` instance.

Method Summary
`boolean` `isLoadable(java.lang.String aName)`
`java.lang.Class` `resolve(java.lang.String aName, java.lang.String aCurrentClass)` Attempts to resolve the Class for a specified name.
`java.lang.Class` `safeLoad(java.lang.String aName)` Will load a specified class is such a way that it will NOT be initialised.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ClassResolver

    public ClassResolver(java.lang.ClassLoader aLoader,
                         java.lang.String aPkg,
                         java.util.Set aImports)

  Creates a new `ClassResolver` instance.

Parameters:
  `aLoader` - the ClassLoader to load classes with.
  `aPkg` - the name of the package the class may belong to
  `aImports` - set of imports to check if the class belongs to

Method Detail

### resolve

    public java.lang.Class resolve(java.lang.String aName,
                                   java.lang.String aCurrentClass)
                            throws java.lang.ClassNotFoundException

  Attempts to resolve the Class for a specified name. The algorithm is to check: - fully qualified name - explicit imports - enclosing package - star imports

  Parameters:
    `aName` - name of the class to resolve
    `aCurrentClass` - name of current class (for inner classes).
  Returns:
    the resolved class
  Throws:
    `java.lang.ClassNotFoundException` - if unable to resolve the class

### isLoadable

    public boolean isLoadable(java.lang.String aName)

  Parameters:
    `aName` - name of the class to check
  Returns:
    whether a specified class is loadable with safeLoad().

### safeLoad

    public java.lang.Class safeLoad(java.lang.String aName)
                             throws java.lang.ClassNotFoundException

  Will load a specified class is such a way that it will NOT be initialised.

  Parameters:
    `aName` - name of the class to load
  Returns:
    the `Class` for the specified class
  Throws:
    `java.lang.ClassNotFoundException` - if an error occurs

Back to the Checkstyle Home Page