return convertToDeclaration(modules.getLanguageModule(), "ceylon.language.Throwable", declarationType);
} else if ("java.lang.Exception".equals(typeName)) {
// FIXME: this being here is highly dubious
return convertToDeclaration(modules.getLanguageModule(), "ceylon.language.Exception", declarationType);
}
ClassMirror classMirror;
try{
classMirror = lookupClassMirror(module, typeName);
}catch(NoClassDefFoundError x){
// FIXME: this may not be the best thing to do. If the class is not there we don't know what type of declaration
// to return, but perhaps if we use annotation scanner rather than reflection we can figure it out, at least
// in cases where the supertype is missing, which throws in reflection at class load.
return logModelResolutionException(x.getMessage(), null, "Unable to load type "+typeName).getDeclaration();
}
if (classMirror == null) {
// special case when bootstrapping because we may need to pull the decl from the typechecked model
if(isBootstrap && typeName.startsWith(CEYLON_LANGUAGE+".")){
Declaration languageDeclaration = findLanguageModuleDeclarationForBootstrap(typeName);
if(languageDeclaration != null)
return languageDeclaration;
}
throw new ModelResolutionException("Failed to resolve "+typeName);
}
// we only allow source loading when it's java code we're compiling in the same go
// (well, technically before the ceylon code)
if(classMirror.isLoadedFromSource() && !classMirror.isJavaSource())
return null;
return convertToDeclaration(module, classMirror, declarationType);
}finally{
timer.stopIgnore(TIMER_MODEL_LOADER_CATEGORY);
}