public class ClassResolver extends Object
Limitations: this does not handle inner classes very well.
Constructor and Description |
---|
ClassResolver(ClassLoader loader,
String pkg,
Set<String> imports)
Creates a new
ClassResolver instance. |
Modifier and Type | Method and Description |
---|---|
boolean |
isLoadable(String name) |
Class<?> |
resolve(String name,
String currentClass)
Attempts to resolve the Class for a specified name.
|
Class<?> |
safeLoad(String name)
Will load a specified class is such a way that it will NOT be
initialised.
|
public ClassResolver(ClassLoader loader, String pkg, Set<String> imports)
ClassResolver
instance.loader
- the ClassLoader to load classes with.pkg
- the name of the package the class may belong toimports
- set of imports to check if the class belongs topublic Class<?> resolve(String name, String currentClass) throws ClassNotFoundException
name
- name of the class to resolvecurrentClass
- name of current class (for inner classes).ClassNotFoundException
- if unable to resolve the classpublic boolean isLoadable(String name)
name
- name of the class to checkpublic Class<?> safeLoad(String name) throws ClassNotFoundException
name
- name of the class to loadClass
for the specified classClassNotFoundException
- if an error occursCopyright © 2001–2015. All rights reserved.