jtulach@258: /* jtulach@258: * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. jtulach@258: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jtulach@258: * jtulach@258: * This code is free software; you can redistribute it and/or modify it jtulach@258: * under the terms of the GNU General Public License version 2 only, as jtulach@258: * published by the Free Software Foundation. Oracle designates this jtulach@258: * particular file as subject to the "Classpath" exception as provided jtulach@258: * by Oracle in the LICENSE file that accompanied this code. jtulach@258: * jtulach@258: * This code is distributed in the hope that it will be useful, but WITHOUT jtulach@258: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jtulach@258: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jtulach@258: * version 2 for more details (a copy is included in the LICENSE file that jtulach@258: * accompanied this code). jtulach@258: * jtulach@258: * You should have received a copy of the GNU General Public License version jtulach@258: * 2 along with this work; if not, write to the Free Software Foundation, jtulach@258: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jtulach@258: * jtulach@258: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jtulach@258: * or visit www.oracle.com if you need additional information or have any jtulach@258: * questions. jtulach@258: */ jtulach@258: jtulach@258: package java.lang.reflect; jtulach@258: jtulach@258: import java.lang.annotation.Annotation; jaroslav@262: import org.apidesign.bck2brwsr.core.JavaScriptBody; jaroslav@266: import org.apidesign.bck2brwsr.emul.AnnotationImpl; jaroslav@391: import org.apidesign.bck2brwsr.emul.MethodImpl; jtulach@258: jtulach@258: /** jtulach@258: * A {@code Method} provides information about, and access to, a single method jtulach@258: * on a class or interface. The reflected method may be a class method jtulach@258: * or an instance method (including an abstract method). jtulach@258: * jtulach@258: *
A {@code Method} permits widening conversions to occur when matching the
jtulach@258: * actual parameters to invoke with the underlying method's formal
jtulach@258: * parameters, but it throws an {@code IllegalArgumentException} if a
jtulach@258: * narrowing conversion would occur.
jtulach@258: *
jtulach@258: * @see Member
jtulach@258: * @see java.lang.Class
jtulach@258: * @see java.lang.Class#getMethods()
jtulach@258: * @see java.lang.Class#getMethod(String, Class[])
jtulach@258: * @see java.lang.Class#getDeclaredMethods()
jtulach@258: * @see java.lang.Class#getDeclaredMethod(String, Class[])
jtulach@258: *
jtulach@258: * @author Kenneth Russell
jtulach@258: * @author Nakul Saraiya
jtulach@258: */
jtulach@258: public final
jtulach@258: class Method extends AccessibleObject implements GenericDeclaration,
jtulach@258: Member {
jaroslav@262: private final Class> clazz;
jaroslav@262: private final String name;
jaroslav@262: private final Object data;
jaroslav@264: private final String sig;
jtulach@258:
jtulach@258: // Generics infrastructure
jtulach@258:
jaroslav@262: private String getGenericSignature() {return null;}
jtulach@258:
jtulach@258: /**
jtulach@258: * Package-private constructor used by ReflectAccess to enable
jtulach@258: * instantiation of these objects in Java code from the java.lang
jtulach@258: * package via sun.reflect.LangReflectAccess.
jtulach@258: */
jaroslav@264: Method(Class> declaringClass, String name, Object data, String sig)
jtulach@258: {
jtulach@258: this.clazz = declaringClass;
jtulach@258: this.name = name;
jaroslav@262: this.data = data;
jaroslav@264: this.sig = sig;
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Package-private routine (exposed to java.lang.Class via
jtulach@258: * ReflectAccess) which returns a copy of this Method. The copy's
jtulach@258: * "root" field points to this Method.
jtulach@258: */
jtulach@258: Method copy() {
jaroslav@262: return this;
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns the {@code Class} object representing the class or interface
jtulach@258: * that declares the method represented by this {@code Method} object.
jtulach@258: */
jtulach@258: public Class> getDeclaringClass() {
jtulach@258: return clazz;
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns the name of the method represented by this {@code Method}
jtulach@258: * object, as a {@code String}.
jtulach@258: */
jtulach@258: public String getName() {
jtulach@258: return name;
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns the Java language modifiers for the method represented
jtulach@258: * by this {@code Method} object, as an integer. The {@code Modifier} class should
jtulach@258: * be used to decode the modifiers.
jtulach@258: *
jtulach@258: * @see Modifier
jtulach@258: */
jtulach@258: public int getModifiers() {
jaroslav@392: return getAccess(data);
jtulach@258: }
jaroslav@392:
jaroslav@392: @JavaScriptBody(args = "self", body = "return self.access;")
jaroslav@392: private static native int getAccess(Object self);
jaroslav@392:
jtulach@258: /**
jtulach@258: * Returns an array of {@code TypeVariable} objects that represent the
jtulach@258: * type variables declared by the generic declaration represented by this
jtulach@258: * {@code GenericDeclaration} object, in declaration order. Returns an
jtulach@258: * array of length 0 if the underlying generic declaration declares no type
jtulach@258: * variables.
jtulach@258: *
jtulach@258: * @return an array of {@code TypeVariable} objects that represent
jtulach@258: * the type variables declared by this generic declaration
jtulach@258: * @throws GenericSignatureFormatError if the generic
jtulach@258: * signature of this generic declaration does not conform to
jtulach@258: * the format specified in
jtulach@258: * The Java™ Virtual Machine Specification
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public TypeVariable If the return type is a parameterized type,
jtulach@258: * the {@code Type} object returned must accurately reflect
jtulach@258: * the actual type parameters used in the source code.
jtulach@258: *
jtulach@258: * If the return type is a type variable or a parameterized type, it
jtulach@258: * is created. Otherwise, it is resolved.
jtulach@258: *
jtulach@258: * @return a {@code Type} object that represents the formal return
jtulach@258: * type of the underlying method
jtulach@258: * @throws GenericSignatureFormatError
jtulach@258: * if the generic method signature does not conform to the format
jtulach@258: * specified in
jtulach@258: * The Java™ Virtual Machine Specification
jtulach@258: * @throws TypeNotPresentException if the underlying method's
jtulach@258: * return type refers to a non-existent type declaration
jtulach@258: * @throws MalformedParameterizedTypeException if the
jtulach@258: * underlying method's return typed refers to a parameterized
jtulach@258: * type that cannot be instantiated for any reason
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public Type getGenericReturnType() {
jaroslav@260: throw new UnsupportedOperationException();
jtulach@258: }
jtulach@258:
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns an array of {@code Class} objects that represent the formal
jtulach@258: * parameter types, in declaration order, of the method
jtulach@258: * represented by this {@code Method} object. Returns an array of length
jtulach@258: * 0 if the underlying method takes no parameters.
jtulach@258: *
jtulach@258: * @return the parameter types for the method this object
jtulach@258: * represents
jtulach@258: */
jtulach@258: public Class>[] getParameterTypes() {
jaroslav@262: throw new UnsupportedOperationException();
jaroslav@262: //return (Class>[]) parameterTypes.clone();
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns an array of {@code Type} objects that represent the formal
jtulach@258: * parameter types, in declaration order, of the method represented by
jtulach@258: * this {@code Method} object. Returns an array of length 0 if the
jtulach@258: * underlying method takes no parameters.
jtulach@258: *
jtulach@258: * If a formal parameter type is a parameterized type,
jtulach@258: * the {@code Type} object returned for it must accurately reflect
jtulach@258: * the actual type parameters used in the source code.
jtulach@258: *
jtulach@258: * If a formal parameter type is a type variable or a parameterized
jtulach@258: * type, it is created. Otherwise, it is resolved.
jtulach@258: *
jtulach@258: * @return an array of Types that represent the formal
jtulach@258: * parameter types of the underlying method, in declaration order
jtulach@258: * @throws GenericSignatureFormatError
jtulach@258: * if the generic method signature does not conform to the format
jtulach@258: * specified in
jtulach@258: * The Java™ Virtual Machine Specification
jtulach@258: * @throws TypeNotPresentException if any of the parameter
jtulach@258: * types of the underlying method refers to a non-existent type
jtulach@258: * declaration
jtulach@258: * @throws MalformedParameterizedTypeException if any of
jtulach@258: * the underlying method's parameter types refer to a parameterized
jtulach@258: * type that cannot be instantiated for any reason
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public Type[] getGenericParameterTypes() {
jaroslav@260: throw new UnsupportedOperationException();
jtulach@258: }
jtulach@258:
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns an array of {@code Class} objects that represent
jtulach@258: * the types of the exceptions declared to be thrown
jtulach@258: * by the underlying method
jtulach@258: * represented by this {@code Method} object. Returns an array of length
jtulach@258: * 0 if the method declares no exceptions in its {@code throws} clause.
jtulach@258: *
jtulach@258: * @return the exception types declared as being thrown by the
jtulach@258: * method this object represents
jtulach@258: */
jtulach@258: public Class>[] getExceptionTypes() {
jaroslav@262: throw new UnsupportedOperationException();
jaroslav@262: //return (Class>[]) exceptionTypes.clone();
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns an array of {@code Type} objects that represent the
jtulach@258: * exceptions declared to be thrown by this {@code Method} object.
jtulach@258: * Returns an array of length 0 if the underlying method declares
jtulach@258: * no exceptions in its {@code throws} clause.
jtulach@258: *
jtulach@258: * If an exception type is a type variable or a parameterized
jtulach@258: * type, it is created. Otherwise, it is resolved.
jtulach@258: *
jtulach@258: * @return an array of Types that represent the exception types
jtulach@258: * thrown by the underlying method
jtulach@258: * @throws GenericSignatureFormatError
jtulach@258: * if the generic method signature does not conform to the format
jtulach@258: * specified in
jtulach@258: * The Java™ Virtual Machine Specification
jtulach@258: * @throws TypeNotPresentException if the underlying method's
jtulach@258: * {@code throws} clause refers to a non-existent type declaration
jtulach@258: * @throws MalformedParameterizedTypeException if
jtulach@258: * the underlying method's {@code throws} clause refers to a
jtulach@258: * parameterized type that cannot be instantiated for any reason
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public Type[] getGenericExceptionTypes() {
jaroslav@260: throw new UnsupportedOperationException();
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Compares this {@code Method} against the specified object. Returns
jtulach@258: * true if the objects are the same. Two {@code Methods} are the same if
jtulach@258: * they were declared by the same class and have the same name
jtulach@258: * and formal parameter types and return type.
jtulach@258: */
jtulach@258: public boolean equals(Object obj) {
jtulach@258: if (obj != null && obj instanceof Method) {
jtulach@258: Method other = (Method)obj;
jaroslav@262: return data == other.data;
jtulach@258: }
jtulach@258: return false;
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns a hashcode for this {@code Method}. The hashcode is computed
jtulach@258: * as the exclusive-or of the hashcodes for the underlying
jtulach@258: * method's declaring class name and the method's name.
jtulach@258: */
jtulach@258: public int hashCode() {
jtulach@258: return getDeclaringClass().getName().hashCode() ^ getName().hashCode();
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns a string describing this {@code Method}. The string is
jtulach@258: * formatted as the method access modifiers, if any, followed by
jtulach@258: * the method return type, followed by a space, followed by the
jtulach@258: * class declaring the method, followed by a period, followed by
jtulach@258: * the method name, followed by a parenthesized, comma-separated
jtulach@258: * list of the method's formal parameter types. If the method
jtulach@258: * throws checked exceptions, the parameter list is followed by a
jtulach@258: * space, followed by the word throws followed by a
jtulach@258: * comma-separated list of the thrown exception types.
jtulach@258: * For example:
jtulach@258: * The access modifiers are placed in canonical order as
jtulach@258: * specified by "The Java Language Specification". This is
jtulach@258: * {@code public}, {@code protected} or {@code private} first,
jtulach@258: * and then other modifiers in the following order:
jtulach@258: * {@code abstract}, {@code static}, {@code final},
jtulach@258: * {@code synchronized}, {@code native}, {@code strictfp}.
jtulach@258: */
jtulach@258: public String toString() {
jtulach@258: try {
jtulach@258: StringBuilder sb = new StringBuilder();
jtulach@258: int mod = getModifiers() & Modifier.methodModifiers();
jtulach@258: if (mod != 0) {
jtulach@258: sb.append(Modifier.toString(mod)).append(' ');
jtulach@258: }
jtulach@258: sb.append(Field.getTypeName(getReturnType())).append(' ');
jtulach@258: sb.append(Field.getTypeName(getDeclaringClass())).append('.');
jtulach@258: sb.append(getName()).append('(');
jaroslav@262: /*
jtulach@258: Class>[] params = parameterTypes; // avoid clone
jtulach@258: for (int j = 0; j < params.length; j++) {
jtulach@258: sb.append(Field.getTypeName(params[j]));
jtulach@258: if (j < (params.length - 1))
jtulach@258: sb.append(',');
jtulach@258: }
jtulach@258: sb.append(')');
jtulach@258: Class>[] exceptions = exceptionTypes; // avoid clone
jtulach@258: if (exceptions.length > 0) {
jtulach@258: sb.append(" throws ");
jtulach@258: for (int k = 0; k < exceptions.length; k++) {
jtulach@258: sb.append(exceptions[k].getName());
jtulach@258: if (k < (exceptions.length - 1))
jtulach@258: sb.append(',');
jtulach@258: }
jtulach@258: }
jaroslav@262: */
jtulach@258: return sb.toString();
jtulach@258: } catch (Exception e) {
jtulach@258: return "<" + e + ">";
jtulach@258: }
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns a string describing this {@code Method}, including
jtulach@258: * type parameters. The string is formatted as the method access
jtulach@258: * modifiers, if any, followed by an angle-bracketed
jtulach@258: * comma-separated list of the method's type parameters, if any,
jtulach@258: * followed by the method's generic return type, followed by a
jtulach@258: * space, followed by the class declaring the method, followed by
jtulach@258: * a period, followed by the method name, followed by a
jtulach@258: * parenthesized, comma-separated list of the method's generic
jtulach@258: * formal parameter types.
jtulach@258: *
jtulach@258: * If this method was declared to take a variable number of
jtulach@258: * arguments, instead of denoting the last parameter as
jtulach@258: * "Type[]", it is denoted as
jtulach@258: * "Type...".
jtulach@258: *
jtulach@258: * A space is used to separate access modifiers from one another
jtulach@258: * and from the type parameters or return type. If there are no
jtulach@258: * type parameters, the type parameter list is elided; if the type
jtulach@258: * parameter list is present, a space separates the list from the
jtulach@258: * class name. If the method is declared to throw exceptions, the
jtulach@258: * parameter list is followed by a space, followed by the word
jtulach@258: * throws followed by a comma-separated list of the generic thrown
jtulach@258: * exception types. If there are no type parameters, the type
jtulach@258: * parameter list is elided.
jtulach@258: *
jtulach@258: * The access modifiers are placed in canonical order as
jtulach@258: * specified by "The Java Language Specification". This is
jtulach@258: * {@code public}, {@code protected} or {@code private} first,
jtulach@258: * and then other modifiers in the following order:
jtulach@258: * {@code abstract}, {@code static}, {@code final},
jtulach@258: * {@code synchronized}, {@code native}, {@code strictfp}.
jtulach@258: *
jtulach@258: * @return a string describing this {@code Method},
jtulach@258: * include type parameters
jtulach@258: *
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public String toGenericString() {
jtulach@258: try {
jtulach@258: StringBuilder sb = new StringBuilder();
jtulach@258: int mod = getModifiers() & Modifier.methodModifiers();
jtulach@258: if (mod != 0) {
jtulach@258: sb.append(Modifier.toString(mod)).append(' ');
jtulach@258: }
jtulach@258: TypeVariable>[] typeparms = getTypeParameters();
jtulach@258: if (typeparms.length > 0) {
jtulach@258: boolean first = true;
jtulach@258: sb.append('<');
jtulach@258: for(TypeVariable> typeparm: typeparms) {
jtulach@258: if (!first)
jtulach@258: sb.append(',');
jtulach@258: // Class objects can't occur here; no need to test
jtulach@258: // and call Class.getName().
jtulach@258: sb.append(typeparm.toString());
jtulach@258: first = false;
jtulach@258: }
jtulach@258: sb.append("> ");
jtulach@258: }
jtulach@258:
jtulach@258: Type genRetType = getGenericReturnType();
jtulach@258: sb.append( ((genRetType instanceof Class>)?
jtulach@258: Field.getTypeName((Class>)genRetType):genRetType.toString()))
jtulach@258: .append(' ');
jtulach@258:
jtulach@258: sb.append(Field.getTypeName(getDeclaringClass())).append('.');
jtulach@258: sb.append(getName()).append('(');
jtulach@258: Type[] params = getGenericParameterTypes();
jtulach@258: for (int j = 0; j < params.length; j++) {
jtulach@258: String param = (params[j] instanceof Class)?
jtulach@258: Field.getTypeName((Class)params[j]):
jtulach@258: (params[j].toString());
jtulach@258: if (isVarArgs() && (j == params.length - 1)) // replace T[] with T...
jtulach@258: param = param.replaceFirst("\\[\\]$", "...");
jtulach@258: sb.append(param);
jtulach@258: if (j < (params.length - 1))
jtulach@258: sb.append(',');
jtulach@258: }
jtulach@258: sb.append(')');
jtulach@258: Type[] exceptions = getGenericExceptionTypes();
jtulach@258: if (exceptions.length > 0) {
jtulach@258: sb.append(" throws ");
jtulach@258: for (int k = 0; k < exceptions.length; k++) {
jtulach@258: sb.append((exceptions[k] instanceof Class)?
jtulach@258: ((Class)exceptions[k]).getName():
jtulach@258: exceptions[k].toString());
jtulach@258: if (k < (exceptions.length - 1))
jtulach@258: sb.append(',');
jtulach@258: }
jtulach@258: }
jtulach@258: return sb.toString();
jtulach@258: } catch (Exception e) {
jtulach@258: return "<" + e + ">";
jtulach@258: }
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Invokes the underlying method represented by this {@code Method}
jtulach@258: * object, on the specified object with the specified parameters.
jtulach@258: * Individual parameters are automatically unwrapped to match
jtulach@258: * primitive formal parameters, and both primitive and reference
jtulach@258: * parameters are subject to method invocation conversions as
jtulach@258: * necessary.
jtulach@258: *
jtulach@258: * If the underlying method is static, then the specified {@code obj}
jtulach@258: * argument is ignored. It may be null.
jtulach@258: *
jtulach@258: * If the number of formal parameters required by the underlying method is
jtulach@258: * 0, the supplied {@code args} array may be of length 0 or null.
jtulach@258: *
jtulach@258: * If the underlying method is an instance method, it is invoked
jtulach@258: * using dynamic method lookup as documented in The Java Language
jtulach@258: * Specification, Second Edition, section 15.12.4.4; in particular,
jtulach@258: * overriding based on the runtime type of the target object will occur.
jtulach@258: *
jtulach@258: * If the underlying method is static, the class that declared
jtulach@258: * the method is initialized if it has not already been initialized.
jtulach@258: *
jtulach@258: * If the method completes normally, the value it returns is
jtulach@258: * returned to the caller of invoke; if the value has a primitive
jtulach@258: * type, it is first appropriately wrapped in an object. However,
jtulach@258: * if the value has the type of an array of a primitive type, the
jtulach@258: * elements of the array are not wrapped in objects; in
jtulach@258: * other words, an array of primitive type is returned. If the
jtulach@258: * underlying method return type is void, the invocation returns
jtulach@258: * null.
jtulach@258: *
jtulach@258: * @param obj the object the underlying method is invoked from
jtulach@258: * @param args the arguments used for the method call
jtulach@258: * @return the result of dispatching the method represented by
jtulach@258: * this object on {@code obj} with parameters
jtulach@258: * {@code args}
jtulach@258: *
jtulach@258: * @exception IllegalAccessException if this {@code Method} object
jtulach@258: * is enforcing Java language access control and the underlying
jtulach@258: * method is inaccessible.
jtulach@258: * @exception IllegalArgumentException if the method is an
jtulach@258: * instance method and the specified object argument
jtulach@258: * is not an instance of the class or interface
jtulach@258: * declaring the underlying method (or of a subclass
jtulach@258: * or implementor thereof); if the number of actual
jtulach@258: * and formal parameters differ; if an unwrapping
jtulach@258: * conversion for primitive arguments fails; or if,
jtulach@258: * after possible unwrapping, a parameter value
jtulach@258: * cannot be converted to the corresponding formal
jtulach@258: * parameter type by a method invocation conversion.
jtulach@258: * @exception InvocationTargetException if the underlying method
jtulach@258: * throws an exception.
jtulach@258: * @exception NullPointerException if the specified object is null
jtulach@258: * and the method is an instance method.
jtulach@258: * @exception ExceptionInInitializerError if the initialization
jtulach@258: * provoked by this method fails.
jtulach@258: */
jaroslav@354: public Object invoke(Object obj, Object... args)
jaroslav@354: throws IllegalAccessException, IllegalArgumentException,
jaroslav@354: InvocationTargetException
jaroslav@354: {
jaroslav@413: if ((getModifiers() & Modifier.STATIC) == 0 && obj == null) {
jaroslav@413: throw new NullPointerException();
jaroslav@413: }
jaroslav@354: Object res = invoke0(this, obj, args);
jaroslav@354: if (getReturnType().isPrimitive()) {
jaroslav@354: res = fromPrimitive(getReturnType(), res);
jaroslav@354: }
jaroslav@354: return res;
jaroslav@354: }
jaroslav@354:
jaroslav@262: @JavaScriptBody(args = { "method", "self", "args" }, body =
jaroslav@262: "if (args.length > 0) throw 'unsupported now';"
jaroslav@262: + "return method.fld_data(self);"
jaroslav@262: )
jaroslav@354: private static native Object invoke0(Method m, Object self, Object[] args);
jaroslav@354:
jaroslav@354: private static Object fromPrimitive(Class> type, Object o) {
jaroslav@354: if (type == Integer.TYPE) {
jaroslav@355: return fromRaw(Integer.class, "valueOf__Ljava_lang_Integer_2I", o);
jaroslav@354: }
jaroslav@355: if (type == Long.TYPE) {
jaroslav@355: return fromRaw(Long.class, "valueOf__Ljava_lang_Long_2J", o);
jaroslav@355: }
jaroslav@355: if (type == Double.TYPE) {
jaroslav@355: return fromRaw(Double.class, "valueOf__Ljava_lang_Double_2D", o);
jaroslav@355: }
jaroslav@355: if (type == Float.TYPE) {
jaroslav@355: return fromRaw(Float.class, "valueOf__Ljava_lang_Float_2F", o);
jaroslav@355: }
jaroslav@355: if (type == Byte.TYPE) {
jaroslav@355: return fromRaw(Byte.class, "valueOf__Ljava_lang_Byte_2B", o);
jaroslav@355: }
jaroslav@355: if (type == Boolean.TYPE) {
jaroslav@355: return fromRaw(Boolean.class, "valueOf__Ljava_lang_Boolean_2Z", o);
jaroslav@355: }
jaroslav@355: if (type == Short.TYPE) {
jaroslav@355: return fromRaw(Short.class, "valueOf__Ljava_lang_Short_2S", o);
jaroslav@355: }
jaroslav@413: if (type.getName().equals("void")) {
jaroslav@413: return null;
jaroslav@413: }
jaroslav@355: throw new IllegalStateException("Can't convert " + o);
jtulach@258: }
jaroslav@354:
jaroslav@355: @JavaScriptBody(args = { "cls", "m", "o" },
jaroslav@355: body = "return cls.cnstr(false)[m](o);"
jaroslav@355: )
jaroslav@355: private static native Integer fromRaw(Class> cls, String m, Object o);
jaroslav@354:
jtulach@258: /**
jtulach@258: * Returns {@code true} if this method is a bridge
jtulach@258: * method; returns {@code false} otherwise.
jtulach@258: *
jtulach@258: * @return true if and only if this method is a bridge
jtulach@258: * method as defined by the Java Language Specification.
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public boolean isBridge() {
jtulach@258: return (getModifiers() & Modifier.BRIDGE) != 0;
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns {@code true} if this method was declared to take
jtulach@258: * a variable number of arguments; returns {@code false}
jtulach@258: * otherwise.
jtulach@258: *
jtulach@258: * @return {@code true} if an only if this method was declared to
jtulach@258: * take a variable number of arguments.
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public boolean isVarArgs() {
jtulach@258: return (getModifiers() & Modifier.VARARGS) != 0;
jtulach@258: }
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns {@code true} if this method is a synthetic
jtulach@258: * method; returns {@code false} otherwise.
jtulach@258: *
jtulach@258: * @return true if and only if this method is a synthetic
jtulach@258: * method as defined by the Java Language Specification.
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public boolean isSynthetic() {
jtulach@258: return Modifier.isSynthetic(getModifiers());
jtulach@258: }
jtulach@258:
jaroslav@266: @JavaScriptBody(args = { "self", "ac" },
jaroslav@266: body =
jaroslav@266: "if (self.fld_data.anno) {"
jaroslav@266: + " return self.fld_data.anno['L' + ac.jvmName + ';'];"
jaroslav@266: + "} else return null;"
jaroslav@266: )
jaroslav@266: private Object getAnnotationData(Class> annotationClass) {
jaroslav@266: throw new UnsupportedOperationException();
jaroslav@266: }
jaroslav@266:
jtulach@258: /**
jtulach@258: * @throws NullPointerException {@inheritDoc}
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: public
jtulach@258: * public boolean java.lang.Object.equals(java.lang.Object)
jtulach@258: *
jtulach@258: *
jtulach@258: *