/**
* The version number of this release.
*/
- public static final String version = "3.1";
+ public static final String version = "3.2 beta";
/**
* Prints the version number and the copyright notice.
return new Object[0];
}
+ /**
+ * Returns an array of nested classes declared in the class.
+ * Nested classes are inner classes, anonymous classes, local classes,
+ * and static nested classes.
+ *
+ * @since 3.2
+ */
+ public CtClass[] getNestedClasses() throws NotFoundException {
+ return new CtClass[0];
+ }
+
/**
* Sets the modifiers.
*
/**
* Makes a new public nested class. If this method is called,
* the <code>CtClass</code>, which encloses the nested class, is modified
- * since a class file includes a list of inner classes.
+ * since a class file includes a list of nested classes.
*
* <p>The current implementation only supports a static nested class.
* <code>isStatic</code> must be true.
return AccessFlag.toModifier(acc);
}
+ public CtClass[] getNestedClasses() throws NotFoundException {
+ ClassFile cf = getClassFile2();
+ InnerClassesAttribute ica
+ = (InnerClassesAttribute)cf.getAttribute(InnerClassesAttribute.tag);
+ if (ica == null)
+ return new CtClass[0];
+
+ String thisName = cf.getName();
+ int n = ica.tableLength();
+ ArrayList list = new ArrayList(n);
+ for (int i = 0; i < n; i++) {
+ String outer = ica.outerClass(i);
+ /*
+ * If a nested class is local or anonymous,
+ * the outer_class_info_index is 0.
+ */
+ if (outer == null || outer.equals(thisName)) {
+ String inner = ica.innerClass(i);
+ if (inner != null)
+ list.add(classPool.get(inner));
+ }
+ }
+
+ return (CtClass[])list.toArray(new CtClass[list.size()]);
+ }
+
public void setModifiers(int mod) {
if (Modifier.isStatic(mod))
throw new RuntimeException("cannot set to static");