Code review comment: I think you can leave the test to `registry == null` and skip the part about profiles, since you've already made sure this exception mapper is only registered in DEV mode.

Code before review:
public Response toResponse(NotFoundException exception) {
TemplateHtmlBuilder sb = new TemplateHtmlBuilder();
if (registry == null || !LaunchMode.DEVELOPMENT.getDefaultProfile().equals(ProfileManager.getActiveProfile())) {
return Response.status(Status.NOT_FOUND).entity(sb.toString()).build();
}
Map<String, List<ResourceInvoker>> bounded = null;
if (registry instanceof ResourceMethodRegistry) {
bounded = ((ResourceMethodRegistry) registry).getBounded();
} else if (Proxy.isProxyClass(registry.getClass())
&& registry.toString().startsWith(ResourceMethodRegistry.class.getName())) {
try {
bounded = (Map<String, List<ResourceInvoker>>) Proxy.getInvocationHandler(registry).invoke(registry,
ResourceMethodRegistry.class.getMethod("getBounded"), new Object[0]);
} catch (Throwable e) {
}
}
if (bounded == null) {
return Response.status(Status.NOT_FOUND).entity(sb.toString()).build();
}
List<ResourceDescription> descriptions = ResourceDescription
.fromBoundResourceInvokers(bounded
.entrySet());
sb.header("Resource Not Found", "REST interface overview");
for (ResourceDescription resource : descriptions) {
sb.resourcePath(resource.basePath);
for (MethodDescription method : resource.calls) {
sb.method(method.method, method.fullPath);
if (method.consumes != null) {
sb.consumes(method.consumes);
}
if (method.produces != null) {
sb.produces(method.produces);
}
sb.methodEnd();
}
sb.resourceEnd();
}
return Response.status(Status.NOT_FOUND).entity(sb.toString()).build();
}

Line under review: if (registry == null || !LaunchMode.DEVELOPMENT.getDefaultProfile().equals(ProfileManager.getActiveProfile())) {

Code after addressing the review:
public Response toResponse(NotFoundException exception) {
TemplateHtmlBuilder sb = new TemplateHtmlBuilder();
if (registry == null) {
return Response.status(Status.NOT_FOUND).entity(sb.toString()).build();
}
Map<String, List<ResourceInvoker>> bounded = null;
if (registry instanceof ResourceMethodRegistry) {
bounded = ((ResourceMethodRegistry) registry).getBounded();
} else if (Proxy.isProxyClass(registry.getClass())
&& registry.toString().startsWith(ResourceMethodRegistry.class.getName())) {
try {
bounded = (Map<String, List<ResourceInvoker>>) Proxy.getInvocationHandler(registry).invoke(registry,
ResourceMethodRegistry.class.getMethod("getBounded"), new Object[0]);
} catch (Throwable e) {
}
}
if (bounded == null) {
return Response.status(Status.NOT_FOUND).entity(sb.toString()).build();
}
List<ResourceDescription> descriptions = ResourceDescription
.fromBoundResourceInvokers(bounded
.entrySet());
sb.header("Resource Not Found", "REST interface overview");
for (ResourceDescription resource : descriptions) {
sb.resourcePath(resource.basePath);
for (MethodDescription method : resource.calls) {
sb.method(method.method, method.fullPath);
if (method.consumes != null) {
sb.consumes(method.consumes);
}
if (method.produces != null) {
sb.produces(method.produces);
}
sb.methodEnd();
}
sb.resourceEnd();
}
return Response.status(Status.NOT_FOUND).entity(sb.toString()).build();
}