private NameEnvironmentAnswer findStandType(final String name) throws ClassFormatException {
if (notFoundTypes.contains(name)) {
return null;
}
RythmEngine engine = engine();
byte[] bytes = engine.classLoader().getClassDefinition(name);
if (bytes != null) {
ClassFileReader classFileReader = new ClassFileReader(bytes, name.toCharArray(), true);
return new NameEnvironmentAnswer(classFileReader, null);
}
if (engine.isProdMode()) {
notFoundTypes.add(name);
} else if (name.matches("^(java\\.|play\\.|com\\.greenlaw110\\.).*")) {
notFoundTypes.add(name);
}
return null;
}
private NameEnvironmentAnswer findType(final String name) {
try {
if (!name.contains(TemplateClass.CN_SUFFIX)) {
return findStandType(name);
}
char[] fileName = name.toCharArray();
TemplateClass templateClass = classCache.getByClassName(name);
// TemplateClass exists
if (templateClass != null) {
if (templateClass.javaByteCode != null) {
ClassFileReader classFileReader = new ClassFileReader(templateClass.javaByteCode, fileName, true);
return new NameEnvironmentAnswer(classFileReader, null);
}
// Cascade compilation
ICompilationUnit compilationUnit = new CompilationUnit(name);
return new NameEnvironmentAnswer(compilationUnit, null);
}
// So it's a standard class
return findStandType(name);
} catch (ClassFormatException e) {
// Something very very bad
throw new RuntimeException(e);
}
}
@Override
public boolean isPackage(char[][] parentPackageName, char[] packageName) {
// Rebuild something usable
StringBuilder sb = new StringBuilder();
if (parentPackageName != null) {
for (char[] p : parentPackageName) {
sb.append(new String(p));
sb.append(".");
}
}
sb.append(new String(packageName));
String name = sb.toString();
if (packagesCache.containsKey(name)) {
return packagesCache.get(name).booleanValue();
}
// Check if thera a .java or .class for this resource
if (engine().classLoader().getClassDefinition(name) != null) {
packagesCache.put(name, false);
return false;
}
if (engine().classes().getByClassName(name) != null) {
packagesCache.put(name, false);
return false;
}
packagesCache.put(name, true);
return true;
}
public void cleanup() {
}
};
final RythmEngine engine = engine();
/**
* Compilation result
*/
ICompilerRequestor compilerRequestor = new ICompilerRequestor() {