/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* InvocationHandler for dynamic proxy implementation of Annotation.
*
* @author Josh Bloch
* @since 1.5
*/
this.memberValues = memberValues;
}
// Handle Object and Annotation methods
return toStringImpl();
return hashCodeImpl();
return type;
// Handle annotation member accessors
if (result instanceof ExceptionProxy)
return result;
}
/**
* This method, which clones its array argument, would not be necessary
* if Cloneable had a public clone method.
*/
if (type == byte[].class) {
}
if (type == char[].class) {
}
if (type == double[].class) {
double[] doubleArray = (double[])array;
return doubleArray.clone();
}
if (type == float[].class) {
float[] floatArray = (float[])array;
return floatArray.clone();
}
if (type == int[].class) {
}
if (type == long[].class) {
}
if (type == short[].class) {
short[] shortArray = (short[])array;
return shortArray.clone();
}
if (type == boolean[].class) {
boolean[] booleanArray = (boolean[])array;
return booleanArray.clone();
}
return objectArray.clone();
}
/**
* Implementation of dynamicProxy.toString()
*/
boolean firstMember = true;
if (firstMember)
firstMember = false;
else
}
}
/**
* Translates a member value (in "dynamic proxy return form") into a string
*/
// or annotation
if (type == byte[].class)
if (type == char[].class)
if (type == double[].class)
if (type == float[].class)
if (type == int[].class)
if (type == long[].class)
if (type == short[].class)
if (type == boolean[].class)
}
/**
* Implementation of dynamicProxy.equals(Object o)
*/
if (o == this)
return true;
if (!type.isInstance(o))
return false;
if (hisHandler != null) {
} else {
try {
} catch (InvocationTargetException e) {
return false;
} catch (IllegalAccessException e) {
throw new AssertionError(e);
}
}
return false;
}
return true;
}
/**
* Returns an object's invocation handler if that object is a dynamic
* proxy with a handler of type AnnotationInvocationHandler.
* Returns null otherwise.
*/
if (handler instanceof AnnotationInvocationHandler)
return (AnnotationInvocationHandler) handler;
}
return null;
}
/**
* Returns true iff the two member values in "dynamic proxy return form"
* are equal using the appropriate equality function depending on the
* member type. The two values will be of the same type unless one of
* the containing annotations is ill-formed. If one of the containing
* annotations is ill-formed, this method will return false unless the
* two members are identical object references.
*/
// Check for primitive, string, class, enum const, annotation,
// or ExceptionProxy
// Check for array of string, class, enum const, annotation,
// or ExceptionProxy
// Check for ill formed annotation(s)
return false;
// Deal with array of primitives
if (type == byte[].class)
if (type == char[].class)
if (type == double[].class)
if (type == float[].class)
if (type == int[].class)
if (type == long[].class)
if (type == short[].class)
assert type == boolean[].class;
}
/**
* Returns the member methods for our annotation type. These are
* obtained lazily and cached, as they're expensive to obtain
* and we only need them if our equals method is invoked (which should
* be rare).
*/
if (memberMethods == null) {
new PrivilegedAction<Method[]>() {
return mm;
}
});
}
return memberMethods;
}
/**
* Implementation of dynamicProxy.hashCode()
*/
private int hashCodeImpl() {
int result = 0;
memberValueHashCode(e.getValue());
}
return result;
}
/**
* Computes hashCode of a member value (in "dynamic proxy return form")
*/
// or annotation
if (type == byte[].class)
if (type == char[].class)
if (type == double[].class)
if (type == float[].class)
if (type == int[].class)
if (type == long[].class)
if (type == short[].class)
if (type == boolean[].class)
}
s.defaultReadObject();
// Check to make sure that types have not evolved incompatibly
try {
} catch(IllegalArgumentException e) {
// Class is no longer an annotation type; time to punch out
}
// If there are annotation members without values, that
// situation is handled by the invoke method.
value instanceof ExceptionProxy)) {
}
}
}
}
}