private static boolean isPubCons(CtConstructor cons) { return !Modifier.isPrivate(cons.getModifiers()) && cons.isConstructor(); }
private boolean isInheritable(int mod, CtClass superclazz) { if (Modifier.isPrivate(mod)) return false; if (Modifier.isPackage(mod)) { String pname = getPackageName(); String pname2 = superclazz.getPackageName(); if (pname == null) return pname2 == null; else return pname.equals(pname2); } return true; } }
private static boolean isPubCons(CtConstructor cons) { return !Modifier.isPrivate(cons.getModifiers()) && cons.isConstructor(); }
public TransformFieldAccess(Transformer next, CtField field, String newClassname, String newFieldname) { super(next); this.fieldClass = field.getDeclaringClass(); this.fieldname = field.getName(); this.isPrivate = Modifier.isPrivate(field.getModifiers()); this.newClassname = newClassname; this.newFieldname = newFieldname; this.constPool = null; }
public TransformReadField(Transformer next, CtField field, String methodClassname, String methodName) { super(next); this.fieldClass = field.getDeclaringClass(); this.fieldname = field.getName(); this.methodClassname = methodClassname; this.methodName = methodName; this.isPrivate = Modifier.isPrivate(field.getModifiers()); }
private boolean isInheritable(int mod, CtClass superclazz) { if (Modifier.isPrivate(mod)) return false; if (Modifier.isPackage(mod)) { String pname = getPackageName(); String pname2 = superclazz.getPackageName(); if (pname == null) return pname2 == null; return pname.equals(pname2); } return true; } }
public TransformCall(Transformer next, String oldMethodName, CtMethod substMethod) { super(next); methodname = oldMethodName; methodDescriptor = substMethod.getMethodInfo2().getDescriptor(); classname = newClassname = substMethod.getDeclaringClass().getName(); newMethodname = substMethod.getName(); constPool = null; newMethodIsPrivate = Modifier.isPrivate(substMethod.getModifiers()); }
public TransformFieldAccess(Transformer next, CtField field, String newClassname, String newFieldname) { super(next); this.fieldClass = field.getDeclaringClass(); this.fieldname = field.getName(); this.isPrivate = Modifier.isPrivate(field.getModifiers()); this.newClassname = newClassname; this.newFieldname = newFieldname; this.constPool = null; }
public TransformReadField(Transformer next, CtField field, String methodClassname, String methodName) { super(next); this.fieldClass = field.getDeclaringClass(); this.fieldname = field.getName(); this.methodClassname = methodClassname; this.methodName = methodName; this.isPrivate = Modifier.isPrivate(field.getModifiers()); }
public TransformCall(Transformer next, String oldMethodName, CtMethod substMethod) { super(next); methodname = oldMethodName; methodDescriptor = substMethod.getMethodInfo2().getDescriptor(); classname = newClassname = substMethod.getDeclaringClass().getName(); newMethodname = substMethod.getName(); constPool = null; newMethodIsPrivate = Modifier.isPrivate(substMethod.getModifiers()); }
&& !Modifier.isPrivate(mod))
/** * Returns true if this member is accessible from the given class. */ public boolean visibleFrom(CtClass clazz) { int mod = getModifiers(); if (Modifier.isPublic(mod)) return true; else if (Modifier.isPrivate(mod)) return clazz == declaringClass; else { // package or protected String declName = declaringClass.getPackageName(); String fromName = clazz.getPackageName(); boolean visible; if (declName == null) visible = fromName == null; else visible = declName.equals(fromName); if (!visible && Modifier.isProtected(mod)) return clazz.subclassOf(declaringClass); return visible; } }
/** * Returns true if this member is accessible from the given class. */ public boolean visibleFrom(CtClass clazz) { int mod = getModifiers(); if (Modifier.isPublic(mod)) return true; else if (Modifier.isPrivate(mod)) return clazz == declaringClass; else { // package or protected String declName = declaringClass.getPackageName(); String fromName = clazz.getPackageName(); boolean visible; if (declName == null) visible = fromName == null; else visible = declName.equals(fromName); if (!visible && Modifier.isProtected(mod)) return clazz.subclassOf(declaringClass); return visible; } }
private static void getFields(ArrayList alist, CtClass cc) { int i, num; if (cc == null) return; try { getFields(alist, cc.getSuperclass()); } catch (NotFoundException e) {} try { CtClass[] ifs = cc.getInterfaces(); num = ifs.length; for (i = 0; i < num; ++i) getFields(alist, ifs[i]); } catch (NotFoundException e) {} CtMember.Cache memCache = ((CtClassType)cc).getMembers(); CtMember field = memCache.fieldHead(); CtMember tail = memCache.lastField(); while (field != tail) { field = field.next(); if (!Modifier.isPrivate(field.getModifiers())) alist.add(field); } }
private static void getMethods0(HashMap h, CtClass cc) { try { CtClass[] ifs = cc.getInterfaces(); int size = ifs.length; for (int i = 0; i < size; ++i) getMethods0(h, ifs[i]); } catch (NotFoundException e) {} try { CtClass s = cc.getSuperclass(); if (s != null) getMethods0(h, s); } catch (NotFoundException e) {} if (cc instanceof CtClassType) { CtMember.Cache memCache = ((CtClassType)cc).getMembers(); CtMember mth = memCache.methodHead(); CtMember mthTail = memCache.lastMethod(); while (mth != mthTail) { mth = mth.next(); if (!Modifier.isPrivate(mth.getModifiers())) h.put(((CtMethod)mth).getStringRep(), mth); } } }
private static void getFields(List<CtMember> alist, CtClass cc) { if (cc == null) return; try { getFields(alist, cc.getSuperclass()); } catch (NotFoundException e) {} try { CtClass[] ifs = cc.getInterfaces(); for (CtClass ctc : ifs) getFields(alist, ctc); } catch (NotFoundException e) {} CtMember.Cache memCache = ((CtClassType)cc).getMembers(); CtMember field = memCache.fieldHead(); CtMember tail = memCache.lastField(); while (field != tail) { field = field.next(); if (!Modifier.isPrivate(field.getModifiers())) alist.add(field); } }
private static void getMethods0(Map<String,CtMember> h, CtClass cc) { try { CtClass[] ifs = cc.getInterfaces(); for (CtClass ctc : ifs) getMethods0(h, ctc); } catch (NotFoundException e) {} try { CtClass s = cc.getSuperclass(); if (s != null) getMethods0(h, s); } catch (NotFoundException e) {} if (cc instanceof CtClassType) { CtMember.Cache memCache = ((CtClassType)cc).getMembers(); CtMember mth = memCache.methodHead(); CtMember mthTail = memCache.lastMethod(); while (mth != mthTail) { mth = mth.next(); if (!Modifier.isPrivate(mth.getModifiers())) h.put(((CtMethod)mth).getStringRep(), mth); } } }
public void addMethod(CtMethod m) throws CannotCompileException { checkModify(); if (m.getDeclaringClass() != this) throw new CannotCompileException("bad declaring class"); int mod = m.getModifiers(); if ((getModifiers() & Modifier.INTERFACE) != 0) { if (Modifier.isProtected(mod) || Modifier.isPrivate(mod)) throw new CannotCompileException( "an interface method must be public: " + m.toString()); m.setModifiers(mod | Modifier.PUBLIC); } getMembers().addMethod(m); getClassFile2().addMethod(m.getMethodInfo2()); if ((mod & Modifier.ABSTRACT) != 0) setModifiers(getModifiers() | Modifier.ABSTRACT); }
@Override public void addMethod(CtMethod m) throws CannotCompileException { checkModify(); if (m.getDeclaringClass() != this) throw new CannotCompileException("bad declaring class"); int mod = m.getModifiers(); if ((getModifiers() & Modifier.INTERFACE) != 0) { if (Modifier.isProtected(mod) || Modifier.isPrivate(mod)) throw new CannotCompileException( "an interface method must be public: " + m.toString()); m.setModifiers(mod | Modifier.PUBLIC); } getMembers().addMethod(m); getClassFile2().addMethod(m.getMethodInfo2()); if ((mod & Modifier.ABSTRACT) != 0) setModifiers(getModifiers() | Modifier.ABSTRACT); }