Skip to content

Commit

Permalink
Fix #5
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed Jul 8, 2013
1 parent 939c3c6 commit c9ef380
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -14,11 +14,21 @@ static ContextAccess getContextAccess() {
ContextAccess contextAccess = (ContextAccess) clazz.newInstance();
Class<?> currentClass = contextAccess.getContext(0);
if (currentClass != ContextAccessProvider.class) {
throw new Error("Wrong class returned: " + currentClass + ", expected ContextAccessProvider");
StringBuilder sb = new StringBuilder();
sb.append("Stack:\n");
for (int i = -2; i < 3; i++) {
try {
sb.append(contextAccess.getContext(i).getName()).append(" at ").append(i).append('\n');
} catch (Throwable ignored) {
}
}
throw new Error("Wrong class returned: " + currentClass + ", expected ContextAccessProvider. " + sb);
}
return contextAccess;
} catch (Throwable t) {
Log.warning("Failed to instantiate " + clazz, t);
if (Log.debug) {
Log.debug("Unable to set up context access class " + clazz + ". " + t.getMessage() + ", falling back to slower context access. On JRE: " + System.getProperty("java.version"));
}
}
}
throw new Error("Failed to set up any context access");
Expand Down

0 comments on commit c9ef380

Please sign in to comment.