1 15 16 package javassist; 17 18 21 final class CtArray extends CtClass { 22 protected ClassPool pool; 23 24 CtArray(String name, ClassPool cp) { 26 super(name); 27 pool = cp; 28 } 29 30 public ClassPool getClassPool() { 31 return pool; 32 } 33 34 public boolean isArray() { 35 return true; 36 } 37 38 public boolean subtypeOf(CtClass clazz) throws NotFoundException { 39 if (super.subtypeOf(clazz)) 40 return true; 41 42 String cname = clazz.getName(); 43 if (cname.equals(javaLangObject) 44 || cname.equals("java.lang.Cloneable")) 45 return true; 46 47 return clazz.isArray() 48 && getComponentType().subtypeOf(clazz.getComponentType()); 49 } 50 51 public CtClass getComponentType() throws NotFoundException { 52 String name = getName(); 53 return pool.get(name.substring(0, name.length() - 2)); 54 } 55 56 public CtClass getSuperclass() throws NotFoundException { 57 return pool.get(javaLangObject); 58 } 59 60 public CtMethod[] getMethods() { 61 try { 62 return getSuperclass().getMethods(); 63 } 64 catch (NotFoundException e) { 65 return super.getMethods(); 66 } 67 } 68 69 public CtMethod getMethod(String name, String desc) 70 throws NotFoundException 71 { 72 return getSuperclass().getMethod(name, desc); 73 } 74 75 public CtConstructor[] getConstructors() { 76 try { 77 return getSuperclass().getConstructors(); 78 } 79 catch (NotFoundException e) { 80 return super.getConstructors(); 81 } 82 } 83 } 84 | Popular Tags |