Typically the importHandler.resolveClass(String) function is used something like... result = ctx.getImportHandler().resolveClass("MyClass"); if (result != null) return result; However the current functionality will fail (before classes are cached) if MyClass is in package "com.test" and "org.apache" is imported after com.test is... eg. ctx.getImportHandler().importPackage("com.test"); ctx.getImportHandler().importPackage("org.apache"); Object result = ctx.getImportHandler().resolveClass("MyClass"); At this point result is null the first time ran through, because resolveClass loops through all packages finding the className in each package before it returns the temp variable its been using... which when it comes to org.apache.MyClass it will be null, when com.test.MyClass was actually found... but method returns null. I would think the expected result should be to return the first matching class. To continue its current logic for multi match detection, it can be modified to save the first match and return that variable... Like so. public java.lang.Class<?> resolveClass(String name) { Class<?> result = clazzes.get(name); if (result == null) { // Search the package imports - note there may be multiple matches // (which correctly triggers an error) for (String p : packages) { String className = p + '.' + name; Class<?> tmpClass = findClass(className, true); if (result == null && tmpClass != null) { result = tmpClass; } } } return result; }
Thanks for the report. This has been fixed in 8.0.x for 8.0.15 onwards.