diff -r 8cb6ebbd4823 -r 804f6f982f4e rt/emul/mini/src/main/java/java/lang/Class.java
--- a/rt/emul/mini/src/main/java/java/lang/Class.java Thu Oct 03 14:45:25 2013 +0200
+++ b/rt/emul/mini/src/main/java/java/lang/Class.java Thu Oct 03 15:51:55 2013 +0200
@@ -29,6 +29,7 @@
import org.apidesign.bck2brwsr.emul.reflect.AnnotationImpl;
import java.io.InputStream;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.TypeVariable;
@@ -975,6 +976,319 @@
}
/**
+ * Returns an array of {@code Field} objects reflecting all the fields
+ * declared by the class or interface represented by this
+ * {@code Class} object. This includes public, protected, default
+ * (package) access, and private fields, but excludes inherited fields.
+ * The elements in the array returned are not sorted and are not in any
+ * particular order. This method returns an array of length 0 if the class
+ * or interface declares no fields, or if this {@code Class} object
+ * represents a primitive type, an array class, or void.
+ *
+ *
See The Java Language Specification, sections 8.2 and 8.3.
+ *
+ * @return the array of {@code Field} objects representing all the
+ * declared fields of this class
+ * @exception SecurityException
+ * If a security manager, s, is present and any of the
+ * following conditions is met:
+ *
+ *
+ *
+ * - invocation of
+ * {@link SecurityManager#checkMemberAccess
+ * s.checkMemberAccess(this, Member.DECLARED)} denies
+ * access to the declared fields within this class
+ *
+ *
- the caller's class loader is not the same as or an
+ * ancestor of the class loader for the current class and
+ * invocation of {@link SecurityManager#checkPackageAccess
+ * s.checkPackageAccess()} denies access to the package
+ * of this class
+ *
+ *
+ *
+ * @since JDK1.1
+ */
+ public Field[] getDeclaredFields() throws SecurityException {
+ throw new SecurityException();
+ }
+
+ /**
+ * Bck2Brwsr emulation can only seek public methods, otherwise it
+ * throws a {@code SecurityException}.
+ *
+ * Returns a {@code Method} object that reflects the specified
+ * declared method of the class or interface represented by this
+ * {@code Class} object. The {@code name} parameter is a
+ * {@code String} that specifies the simple name of the desired
+ * method, and the {@code parameterTypes} parameter is an array of
+ * {@code Class} objects that identify the method's formal parameter
+ * types, in declared order. If more than one method with the same
+ * parameter types is declared in a class, and one of these methods has a
+ * return type that is more specific than any of the others, that method is
+ * returned; otherwise one of the methods is chosen arbitrarily. If the
+ * name is "<init>"or "<clinit>" a {@code NoSuchMethodException}
+ * is raised.
+ *
+ * @param name the name of the method
+ * @param parameterTypes the parameter array
+ * @return the {@code Method} object for the method of this class
+ * matching the specified name and parameters
+ * @exception NoSuchMethodException if a matching method is not found.
+ * @exception NullPointerException if {@code name} is {@code null}
+ * @exception SecurityException
+ * If a security manager, s, is present and any of the
+ * following conditions is met:
+ *
+ *
+ *
+ * - invocation of
+ * {@link SecurityManager#checkMemberAccess
+ * s.checkMemberAccess(this, Member.DECLARED)} denies
+ * access to the declared method
+ *
+ *
- the caller's class loader is not the same as or an
+ * ancestor of the class loader for the current class and
+ * invocation of {@link SecurityManager#checkPackageAccess
+ * s.checkPackageAccess()} denies access to the package
+ * of this class
+ *
+ *
+ *
+ * @since JDK1.1
+ */
+ public Method getDeclaredMethod(String name, Class>... parameterTypes)
+ throws NoSuchMethodException, SecurityException {
+ try {
+ return getMethod(name, parameterTypes);
+ } catch (NoSuchMethodException ex) {
+ throw new SecurityException();
+ }
+ }
+
+ /**
+ * Returns a {@code Field} object that reflects the specified declared
+ * field of the class or interface represented by this {@code Class}
+ * object. The {@code name} parameter is a {@code String} that
+ * specifies the simple name of the desired field. Note that this method
+ * will not reflect the {@code length} field of an array class.
+ *
+ * @param name the name of the field
+ * @return the {@code Field} object for the specified field in this
+ * class
+ * @exception NoSuchFieldException if a field with the specified name is
+ * not found.
+ * @exception NullPointerException if {@code name} is {@code null}
+ * @exception SecurityException
+ * If a security manager, s, is present and any of the
+ * following conditions is met:
+ *
+ *
+ *
+ * - invocation of
+ * {@link SecurityManager#checkMemberAccess
+ * s.checkMemberAccess(this, Member.DECLARED)} denies
+ * access to the declared field
+ *
+ *
- the caller's class loader is not the same as or an
+ * ancestor of the class loader for the current class and
+ * invocation of {@link SecurityManager#checkPackageAccess
+ * s.checkPackageAccess()} denies access to the package
+ * of this class
+ *
+ *
+ *
+ * @since JDK1.1
+ */
+ public Field getDeclaredField(String name)
+ throws SecurityException {
+ throw new SecurityException();
+ }
+
+ /**
+ * Returns an array containing {@code Constructor} objects reflecting
+ * all the public constructors of the class represented by this
+ * {@code Class} object. An array of length 0 is returned if the
+ * class has no public constructors, or if the class is an array class, or
+ * if the class reflects a primitive type or void.
+ *
+ * Note that while this method returns an array of {@code
+ * Constructor} objects (that is an array of constructors from
+ * this class), the return type of this method is {@code
+ * Constructor>[]} and not {@code Constructor[]} as
+ * might be expected. This less informative return type is
+ * necessary since after being returned from this method, the
+ * array could be modified to hold {@code Constructor} objects for
+ * different classes, which would violate the type guarantees of
+ * {@code Constructor[]}.
+ *
+ * @return the array of {@code Constructor} objects representing the
+ * public constructors of this class
+ * @exception SecurityException
+ * If a security manager, s, is present and any of the
+ * following conditions is met:
+ *
+ *
+ *
+ * - invocation of
+ * {@link SecurityManager#checkMemberAccess
+ * s.checkMemberAccess(this, Member.PUBLIC)} denies
+ * access to the constructors within this class
+ *
+ *
- the caller's class loader is not the same as or an
+ * ancestor of the class loader for the current class and
+ * invocation of {@link SecurityManager#checkPackageAccess
+ * s.checkPackageAccess()} denies access to the package
+ * of this class
+ *
+ *
+ *
+ * @since JDK1.1
+ */
+ public Constructor>[] getConstructors() throws SecurityException {
+ return MethodImpl.findConstructors(this, 0x01);
+ }
+
+ /**
+ * Returns a {@code Constructor} object that reflects the specified
+ * public constructor of the class represented by this {@code Class}
+ * object. The {@code parameterTypes} parameter is an array of
+ * {@code Class} objects that identify the constructor's formal
+ * parameter types, in declared order.
+ *
+ * If this {@code Class} object represents an inner class
+ * declared in a non-static context, the formal parameter types
+ * include the explicit enclosing instance as the first parameter.
+ *
+ * The constructor to reflect is the public constructor of the class
+ * represented by this {@code Class} object whose formal parameter
+ * types match those specified by {@code parameterTypes}.
+ *
+ * @param parameterTypes the parameter array
+ * @return the {@code Constructor} object of the public constructor that
+ * matches the specified {@code parameterTypes}
+ * @exception NoSuchMethodException if a matching method is not found.
+ * @exception SecurityException
+ * If a security manager, s, is present and any of the
+ * following conditions is met:
+ *
+ *
+ *
+ * - invocation of
+ * {@link SecurityManager#checkMemberAccess
+ * s.checkMemberAccess(this, Member.PUBLIC)} denies
+ * access to the constructor
+ *
+ *
- the caller's class loader is not the same as or an
+ * ancestor of the class loader for the current class and
+ * invocation of {@link SecurityManager#checkPackageAccess
+ * s.checkPackageAccess()} denies access to the package
+ * of this class
+ *
+ *
+ *
+ * @since JDK1.1
+ */
+ public Constructor getConstructor(Class>... parameterTypes)
+ throws NoSuchMethodException, SecurityException {
+ Constructor c = MethodImpl.findConstructor(this, parameterTypes);
+ if (c == null) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(getName()).append('(');
+ String sep = "";
+ for (int i = 0; i < parameterTypes.length; i++) {
+ sb.append(sep).append(parameterTypes[i].getName());
+ sep = ", ";
+ }
+ sb.append(')');
+ throw new NoSuchMethodException(sb.toString());
+ }
+ return c;
+ }
+
+ /**
+ * Returns an array of {@code Constructor} objects reflecting all the
+ * constructors declared by the class represented by this
+ * {@code Class} object. These are public, protected, default
+ * (package) access, and private constructors. The elements in the array
+ * returned are not sorted and are not in any particular order. If the
+ * class has a default constructor, it is included in the returned array.
+ * This method returns an array of length 0 if this {@code Class}
+ * object represents an interface, a primitive type, an array class, or
+ * void.
+ *
+ * See The Java Language Specification, section 8.2.
+ *
+ * @return the array of {@code Constructor} objects representing all the
+ * declared constructors of this class
+ * @exception SecurityException
+ * If a security manager, s, is present and any of the
+ * following conditions is met:
+ *
+ *
+ *
+ * - invocation of
+ * {@link SecurityManager#checkMemberAccess
+ * s.checkMemberAccess(this, Member.DECLARED)} denies
+ * access to the declared constructors within this class
+ *
+ *
- the caller's class loader is not the same as or an
+ * ancestor of the class loader for the current class and
+ * invocation of {@link SecurityManager#checkPackageAccess
+ * s.checkPackageAccess()} denies access to the package
+ * of this class
+ *
+ *
+ *
+ * @since JDK1.1
+ */
+ public Constructor>[] getDeclaredConstructors() throws SecurityException {
+ throw new SecurityException();
+ }
+ /**
+ * Returns a {@code Constructor} object that reflects the specified
+ * constructor of the class or interface represented by this
+ * {@code Class} object. The {@code parameterTypes} parameter is
+ * an array of {@code Class} objects that identify the constructor's
+ * formal parameter types, in declared order.
+ *
+ * If this {@code Class} object represents an inner class
+ * declared in a non-static context, the formal parameter types
+ * include the explicit enclosing instance as the first parameter.
+ *
+ * @param parameterTypes the parameter array
+ * @return The {@code Constructor} object for the constructor with the
+ * specified parameter list
+ * @exception NoSuchMethodException if a matching method is not found.
+ * @exception SecurityException
+ * If a security manager, s, is present and any of the
+ * following conditions is met:
+ *
+ *
+ *
+ * - invocation of
+ * {@link SecurityManager#checkMemberAccess
+ * s.checkMemberAccess(this, Member.DECLARED)} denies
+ * access to the declared constructor
+ *
+ *
- the caller's class loader is not the same as or an
+ * ancestor of the class loader for the current class and
+ * invocation of {@link SecurityManager#checkPackageAccess
+ * s.checkPackageAccess()} denies access to the package
+ * of this class
+ *
+ *
+ *
+ * @since JDK1.1
+ */
+ public Constructor getDeclaredConstructor(Class>... parameterTypes)
+ throws NoSuchMethodException, SecurityException {
+ return getConstructor(parameterTypes);
+ }
+
+
+ /**
* Character.isDigit answers {@code true} to some non-ascii
* digits. This one does not.
*/