git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@256 30ef5769-5b8d-40dd-aea6-55b5d6557bb3tags/rel_3_17_1_ga
@@ -281,6 +281,8 @@ see javassist.Dump. | |||
<h2>Changes</h2> | |||
<p>- version 3.2 | |||
<p>- version 3.1 on February 23, 2006 | |||
<ul> |
@@ -51,7 +51,7 @@ public abstract class CtClass { | |||
/** | |||
* 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. | |||
@@ -460,6 +460,17 @@ public abstract class CtClass { | |||
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. | |||
* | |||
@@ -571,7 +582,7 @@ public abstract class CtClass { | |||
/** | |||
* 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. |
@@ -369,6 +369,32 @@ class CtClassType extends CtClass { | |||
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"); |