/** * Verifies legal descriptor ordering. * * @throws InvalidObjectException if any descriptor is <code>null</code>, * or the descriptors array is empty, or if any descriptor is preceded by * another descriptor that matches at least the same methods * * Default de-serialization is vulnerable to finalizer and reference * stealer attacks. */ private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); checkSerial(descs); }
/** * Creates a new StringMethodConstraints instance from BasicMethodConstraints. * * @param constraints */ public StringMethodConstraints(BasicMethodConstraints constraints){ this(true, convert(constraints.getMethodDescs())); }
); StringMethodDesc[] newDescs = constraints.getMethodDescs(); for (int i = 0, l = newDescs.length; i < l; i++){ MethodKey key = new MethodKey( return new StringMethodConstraints(check(combinedDescs), combinedDescs);
if (existing instanceof BasicMethodConstraints ) existing = new StringMethodConstraints((BasicMethodConstraints) existing); mc = new StringMethodConstraints((BasicMethodConstraints) mc); mc = ((StringMethodConstraints)mc).combine((StringMethodConstraints)existing);
/** * Creates an instance with the specified ordered array of descriptors. * The {@link #getConstraints getConstraints} method searches the * descriptors in the specified order. For any given descriptor in the * array, no preceding descriptor can match at least the same methods as * the given descriptor; that is, more specific descriptors must precede * less specific descriptors. The array passed to the constructor is * neither modified nor retained; subsequent changes to that array have * no effect on the instance created. * * @param descs the descriptors * @throws NullPointerException if the argument is <code>null</code> or * any element of the argument is <code>null</code> * @throws IllegalArgumentException if the descriptors array is empty, or * if any descriptor is preceded by another descriptor that matches at * least the same methods */ public StringMethodConstraints(StringMethodDesc[] descs) { this(check(descs), descs.clone()); }
/** * Returns a hash code value for this object. */ public int hashCode() { return hash(descs); }
private static StringMethodDesc[] convert(MethodDesc[] descs){ int len = descs.length; StringMethodDesc[] result = new StringMethodDesc[len]; for (int i = 0; i < len; i++){ result [i] = descs[i].getName() != null ? new StringMethodDesc( descs[i].getName(), descs[i].getParameterTypes(), descs[i].getConstraints() ) : new StringMethodDesc(descs[i].getConstraints()); } check(result); return result; }
/** * Constructor for {@link AtomicSerial}. * * @see AtomicSerial * @param arg GetArg serial fields * @throws IOException if there are I/O errors while reading from GetArg's * underlying <code>InputStream</code> * @throws InvalidObjectException if object invariants aren't satisfied. */ public StringMethodConstraints(GetArg arg) throws IOException, ClassNotFoundException{ this(checkSerial(arg.get("descs", null, StringMethodDesc[].class)), arg.get("descs", new StringMethodDesc[0], StringMethodDesc[].class).clone()); }