private void addDependencies(DirectClassFile classFile) { for (Constant constant : classFile.getConstantPool().getEntries()) { if (constant instanceof CstType) { checkDescriptor(((CstType) constant).getClassType().getDescriptor()); } else if (constant instanceof CstFieldRef) { checkDescriptor(((CstFieldRef) constant).getType().getDescriptor()); } else if (constant instanceof CstBaseMethodRef) { checkPrototype(((CstBaseMethodRef) constant).getPrototype()); } } FieldList fields = classFile.getFields(); int nbField = fields.size(); for (int i = 0; i < nbField; i++) { checkDescriptor(fields.get(i).getDescriptor().getString()); } MethodList methods = classFile.getMethods(); int nbMethods = methods.size(); for (int i = 0; i < nbMethods; i++) { checkPrototype(Prototype.intern(methods.get(i).getDescriptor().getString())); } } private void checkPrototype(Prototype proto) {
/** * Gets whether this instance has the name of a standard instance * initialization method. This is just a convenient shorthand for * {@code getName().getString().equals("<init>")}. * * @return {@code true} iff this is a reference to an * instance initialization method */ public final boolean isInstanceInit() { return name.getString().equals("<init>"); }
/** * Gets whether this instance has the name of a standard class * initialization method. This is just a convenient shorthand for * {@code getName().getString().equals("<clinit>")}. * * @return {@code true} iff this is a reference to an * instance initialization method */ public final boolean isClassInit() { return name.getString().equals("<clinit>"); } }
/** * Gets whether this instance has the name of a standard class * initialization method. This is just a convenient shorthand for * {@code getName().getString().equals("<clinit>")}. * * @return {@code true} iff this is a reference to an * instance initialization method */ public final boolean isClassInit() { return name.getString().equals("<clinit>"); }
/** * Gets whether this instance has the name of a standard instance * initialization method. This is just a convenient shorthand for * {@code getName().getString().equals("<init>")}. * * @return {@code true} iff this is a reference to an * instance initialization method */ public final boolean isInstanceInit() { return name.getString().equals("<init>"); }
/** * Gets whether this instance has the name of a standard class * initialization method. This is just a convenient shorthand for * {@code getName().getString().equals("<clinit>")}. * * @return {@code true} iff this is a reference to an * instance initialization method */ public final boolean isClassInit() { return name.getString().equals("<clinit>"); } }
/** * Gets whether this instance has the name of a standard instance * initialization method. This is just a convenient shorthand for * {@code getName().getString().equals("<init>")}. * * @return {@code true} iff this is a reference to an * instance initialization method */ public final boolean isInstanceInit() { return name.getString().equals("<init>"); }
/** * Gets whether this instance has the name of a standard class * initialization method. This is just a convenient shorthand for * {@code getName().getString().equals("<clinit>")}. * * @return {@code true} iff this is a reference to an * instance initialization method */ public final boolean isClassInit() { return name.getString().equals("<clinit>"); } }
/** * Gets the field type corresponding to this instance's descriptor. * This method is only valid to call if the descriptor in fact describes * a field (and not a method). * * @return {@code non-null;} the field type */ public Type getFieldType() { return Type.intern(descriptor.getString()); }
/** * Gets the field type corresponding to this instance's descriptor. * This method is only valid to call if the descriptor in fact describes * a field (and not a method). * * @return {@code non-null;} the field type */ public Type getFieldType() { return Type.intern(descriptor.getString()); }
/** * Gets the field type corresponding to this instance's descriptor. * This method is only valid to call if the descriptor in fact describes * a field (and not a method). * * @return {@code non-null;} the field type */ public Type getFieldType() { return Type.intern(descriptor.getString()); }
/** * Constructs an instance. This constructor is private; use {@link #make}. * * @param descriptor the method descriptor */ private CstMethodType(CstString descriptor) { prototype = Prototype.fromDescriptor(descriptor.getString()); }
/** * Gets the variable's type descriptor. This is a convenient shorthand * for {@code Type.intern(getDescriptor().getString())}. * * @return {@code non-null;} the variable's type */ public Type getType() { return Type.intern(descriptor.getString()); }
/** * Gets the variable's type descriptor. This is a convenient shorthand * for {@code Type.intern(getDescriptor().getString())}. * * @return {@code non-null;} the variable's type */ public Type getType() { return Type.intern(descriptor.getString()); }
/** * Gets the variable's type descriptor. This is a convenient shorthand * for {@code Type.intern(getDescriptor().getString())}. * * @return {@code non-null;} the variable's type */ public Type getType() { return Type.intern(descriptor.getString()); }
/** * Gets the field type corresponding to this instance's descriptor. * This method is only valid to call if the descriptor in fact describes * a field (and not a method). * * @return {@code non-null;} the field type */ public Type getFieldType() { return Type.intern(descriptor.getString()); }
/** * Makes an instance for the given value. This may (but does not * necessarily) return an already-allocated instance. * * @param descriptor the method descriptor * @return {@code non-null;} the appropriate instance */ public static CstProtoRef make(CstString descriptor) { Prototype prototype = Prototype.fromDescriptor(descriptor.getString()); return new CstProtoRef(prototype); }
/** * Constructs an instance. * * @param definingClass {@code non-null;} the type of the defining class * @param nat {@code non-null;} the name-and-type */ /*package*/ CstBaseMethodRef(CstType definingClass, CstNat nat) { super(definingClass, nat); String descriptor = getNat().getDescriptor().getString(); this.prototype = Prototype.intern(descriptor); this.instancePrototype = null; }
/** * Constructs an instance. * * @param definingClass {@code non-null;} the type of the defining class * @param nat {@code non-null;} the name-and-type */ /*package*/ CstBaseMethodRef(CstType definingClass, CstNat nat) { super(definingClass, nat); String descriptor = getNat().getDescriptor().getString(); this.prototype = Prototype.intern(descriptor); this.instancePrototype = null; }
/** * Constructs an instance. * * @param definingClass {@code non-null;} the type of the defining class * @param nat {@code non-null;} the name-and-type */ /*package*/ CstBaseMethodRef(CstType definingClass, CstNat nat) { super(definingClass, nat); String descriptor = getNat().getDescriptor().getString(); this.prototype = Prototype.intern(descriptor); this.instancePrototype = null; }