/** * Constructs an instance. This constructor is private; use {@link #make}. * * @param descriptor the method descriptor */ private CstMethodType(CstString descriptor) { prototype = Prototype.fromDescriptor(descriptor.getString()); }
/** * Returns the unique instance corresponding to the * given method descriptor. See vmspec-2 sec4.3.3 for details on the * field descriptor syntax. * * @param descriptor {@code non-null;} the descriptor * @return {@code non-null;} the corresponding instance * @throws IllegalArgumentException thrown if the descriptor has * invalid syntax */ public static Prototype intern(String descriptor) { if (descriptor == null) { throw new NullPointerException("descriptor == null"); } Prototype result = internTable.get(descriptor); if (result != null) { return result; } result = fromDescriptor(descriptor); return putIntern(result); }
/** * Returns the unique instance corresponding to the * given method descriptor. See vmspec-2 sec4.3.3 for details on the * field descriptor syntax. * * @param descriptor {@code non-null;} the descriptor * @return {@code non-null;} the corresponding instance * @throws IllegalArgumentException thrown if the descriptor has * invalid syntax */ public static Prototype intern(String descriptor) { if (descriptor == null) { throw new NullPointerException("descriptor == null"); } Prototype result = internTable.get(descriptor); if (result != null) { return result; } result = fromDescriptor(descriptor); return putIntern(result); }
/** * Constructs an instance. This constructor is private; use {@link #make}. * * @param bootstrapMethodIndex The index of the bootstrap method in the bootstrap method table * @param nat the name and type */ private CstInvokeDynamic(int bootstrapMethodIndex, CstNat nat) { this.bootstrapMethodIndex = bootstrapMethodIndex; this.nat = nat; this.prototype = Prototype.fromDescriptor(nat.getDescriptor().toHuman()); this.references = new ArrayList<>(); }
/** * 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(); if (isSignaturePolymorphic()) { // The prototype for signature polymorphic methods is used to // construct call-site information and select the true invocation // target (invoke() or invokeExact(). The prototype is created // without being interned to avoid polluting the DEX file with // unused data. this.prototype = Prototype.fromDescriptor(descriptor); } else { 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(); if (isSignaturePolymorphic()) { // The prototype for signature polymorphic methods is used to // construct call-site information and select the true invocation // target (invoke() or invokeExact(). The prototype is created // without being interned to avoid polluting the DEX file with // unused data. this.prototype = Prototype.fromDescriptor(descriptor); } else { this.prototype = Prototype.intern(descriptor); } this.instancePrototype = null; }
/** * Creates an instance of a {@code CstCallSite}. * * @param bootstrapHandle {@code non-null;} the bootstrap method handle to invoke * @param nat {@code non-null;} the name and type to be resolved by the bootstrap method handle * @param optionalArguments {@code null-ok;} optional arguments to provide to the bootstrap * method * @return a new {@code CstCallSite} instance */ public static CstCallSite make(CstMethodHandle bootstrapHandle, CstNat nat, BootstrapMethodArgumentsList optionalArguments) { if (bootstrapHandle == null) { throw new NullPointerException("bootstrapMethodHandle == null"); } else if (nat == null) { throw new NullPointerException("nat == null"); } List list = new List(3 + optionalArguments.size()); list.set(0, bootstrapHandle); list.set(1, nat.getName()); list.set(2, new CstProtoRef(Prototype.fromDescriptor(nat.getDescriptor().getString()))); if (optionalArguments != null) { for (int i = 0; i < optionalArguments.size(); ++i) { list.set(i + 3, optionalArguments.get(i)); } } list.setImmutable(); return new CstCallSite(list); }