}
@JRubyMethod
public RubyArray declared_classes() {
Ruby runtime = getRuntime();
RubyArray result = runtime.newArray();
Class<?> javaClass = javaClass();
try {
Class<?>[] classes = javaClass.getDeclaredClasses();
for (int i = 0; i < classes.length; i++) {
if (Modifier.isPublic(classes[i].getModifiers())) {
result.append(get(runtime, classes[i]));
}
}
} catch (SecurityException e) {
// restrictive security policy; no matter, we only want public
// classes anyway
try {
Class<?>[] classes = javaClass.getClasses();
for (int i = 0; i < classes.length; i++) {
if (javaClass == classes[i].getDeclaringClass()) {
result.append(get(runtime, classes[i]));
}
}
} catch (SecurityException e2) {
// very restrictive policy (disallows Member.PUBLIC)
// we'd never actually get this far in that case