[kaffe] CVS kaffe (dalibor): Merged more files in from GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Sat Mar 13 08:36:02 PST 2004


PatchSet 4515 
Date: 2004/03/13 16:27:20
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Merged more files in from GNU Classpath

2004-03-13  Dalibor Topic <robilad at kaffe.org>


        * libraries/javalib/java/lang/reflect/InvocationHandler.java,
        libraries/javalib/java/lang/reflect/ReflectPermission.java,
        libraries/javalib/java/lang/reflect/Modifier.java,
        libraries/javalib/java/lang/reflect/Member.java,
        libraries/javalib/java/lang/reflect/AccessibleObject.java,
        libraries/javalib/java/lang/Compiler.java,
        libraries/javalib/java/lang/RuntimePermission.java,
        libraries/javalib/java/util/PropertyResourceBundle.java,
        libraries/javalib/java/util/ListResourceBundle.java,
        libraries/javalib/java/security/Certificate.java,
        libraries/javalib/java/security/Guard.java,
        libraries/javalib/java/security/Key.java,
        libraries/javalib/java/security/Principal.java,
        libraries/javalib/java/security/PrivateKey.java,
        libraries/javalib/java/security/PrivilegedAction.java,
        libraries/javalib/java/security/PrivilegedExceptionAction.java,
        libraries/javalib/java/security/PublicKey.java,
        libraries/javalib/java/security/cert/X509Extension.java
        Merged in from GNU Classpath.

        * developers/check-classpath-unmerged:
        New file.

Members: 
	ChangeLog:1.2094->1.2095 
	developers/check-classpath-unmerged:INITIAL->1.1 
	libraries/javalib/java/lang/Compiler.java:1.3->1.4 
	libraries/javalib/java/lang/RuntimePermission.java:1.1->1.2 
	libraries/javalib/java/lang/reflect/AccessibleObject.java:1.3->1.4 
	libraries/javalib/java/lang/reflect/InvocationHandler.java:1.2->1.3 
	libraries/javalib/java/lang/reflect/Member.java:1.6->1.7 
	libraries/javalib/java/lang/reflect/Modifier.java:1.7->1.8 
	libraries/javalib/java/lang/reflect/ReflectPermission.java:1.1->1.2 
	libraries/javalib/java/security/Certificate.java:1.2->1.3 
	libraries/javalib/java/security/Guard.java:1.2->1.3 
	libraries/javalib/java/security/Key.java:1.2->1.3 
	libraries/javalib/java/security/Principal.java:1.2->1.3 
	libraries/javalib/java/security/PrivateKey.java:1.2->1.3 
	libraries/javalib/java/security/PrivilegedAction.java:1.2->1.3 
	libraries/javalib/java/security/PrivilegedExceptionAction.java:1.2->1.3 
	libraries/javalib/java/security/PublicKey.java:1.2->1.3 
	libraries/javalib/java/security/cert/X509Extension.java:1.1->1.2 
	libraries/javalib/java/util/ListResourceBundle.java:1.3->1.4 
	libraries/javalib/java/util/PropertyResourceBundle.java:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2094 kaffe/ChangeLog:1.2095
--- kaffe/ChangeLog:1.2094	Fri Mar 12 18:24:36 2004
+++ kaffe/ChangeLog	Sat Mar 13 16:27:20 2004
@@ -1,3 +1,29 @@
+2004-03-13  Dalibor Topic <robilad at kaffe.org>
+
+
+	* libraries/javalib/java/lang/reflect/InvocationHandler.java,
+	libraries/javalib/java/lang/reflect/ReflectPermission.java,
+	libraries/javalib/java/lang/reflect/Modifier.java,
+	libraries/javalib/java/lang/reflect/Member.java,
+	libraries/javalib/java/lang/reflect/AccessibleObject.java,
+	libraries/javalib/java/lang/Compiler.java,
+	libraries/javalib/java/lang/RuntimePermission.java,
+	libraries/javalib/java/util/PropertyResourceBundle.java,
+	libraries/javalib/java/util/ListResourceBundle.java,
+	libraries/javalib/java/security/Certificate.java,
+	libraries/javalib/java/security/Guard.java,
+	libraries/javalib/java/security/Key.java,
+	libraries/javalib/java/security/Principal.java,
+	libraries/javalib/java/security/PrivateKey.java,
+	libraries/javalib/java/security/PrivilegedAction.java,
+	libraries/javalib/java/security/PrivilegedExceptionAction.java,
+	libraries/javalib/java/security/PublicKey.java,
+	libraries/javalib/java/security/cert/X509Extension.java
+	Merged in from GNU Classpath.
+
+	* developers/check-classpath-unmerged:
+	New file.
+	
 2004-03-12  Casey Marshall <rsdio at metastatic.org>
 
         * libraries/javalib/java/security/CodeSource.java
===================================================================
Checking out kaffe/developers/check-classpath-unmerged
RCS:  /home/cvs/kaffe/kaffe/developers/check-classpath-unmerged,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/developers/check-classpath-unmerged	Sat Mar 13 16:30:31 2004
@@ -0,0 +1,6 @@
+# Script to check which files haven't been merged with GNU Classpath
+# yet.
+#
+# Run from libraries/javalib directory.
+#
+find . -name "*.java" | xargs -n 1 grep -L "GNU Classpath is free software"
Index: kaffe/libraries/javalib/java/lang/Compiler.java
diff -u kaffe/libraries/javalib/java/lang/Compiler.java:1.3 kaffe/libraries/javalib/java/lang/Compiler.java:1.4
--- kaffe/libraries/javalib/java/lang/Compiler.java:1.3	Wed Mar  3 09:17:37 1999
+++ kaffe/libraries/javalib/java/lang/Compiler.java	Sat Mar 13 16:27:22 2004
@@ -1,36 +1,128 @@
-/*
- * Java core library component.
- *
- * Copyright (c) 1997, 1998
- *      Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- */
-
-package java.lang;
+/* Compiler.java -- placeholder for Java-to-native runtime compilers
+   Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
 
-public final class Compiler {
+This file is part of GNU Classpath.
 
-private Compiler() {
-}
-    
-public static boolean compileClass(Class aClass) {
-	return (false);
-}
-
-public static boolean compileClasses(String string) {
-	return (false);
-}
-
-public static Object command(Object any) {
-	return (null);
-}
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
 
-public static void enable() {
-}
 
-public static void disable() {
-}
+package java.lang;
 
+/**
+ * The <code>Compiler</code> class is a placeholder for a JIT compiler
+ * implementation, and does nothing unless there is such a compiler.
+ *
+ * <p>The system property <code>java.compiler</code> may contain the name
+ * of a library to load with <code>System.loadLibrary</code> when the
+ * virtual machine first starts.  If so, and loading the library succeeds,
+ * then a function by the name of <code>java_lang_Compiler_start()</code>
+ * in that library is called.
+ *
+ * <p>Note that a VM might not have implemented any of this.
+ *
+ * @author Tom Tromey <tromey at cygnus.com>
+ * @see System#getProperty(String)
+ * @see System#getProperty(String, String)
+ * @see System#loadLibrary(String)
+ * @since JDK 1.0
+ * @status updated to 1.4
+ */
+public final class Compiler
+{
+  /**
+   * Don't allow new `Compiler's to be made.
+   */
+  private Compiler()
+  {
+  }
+
+  /**
+   * Compile the class named by <code>oneClass</code>.
+   *
+   * @param oneClass the class to compile
+   * @return <code>false</code> if no compiler is available or
+   *         compilation failed, <code>true</code> if compilation succeeded
+   * @throws NullPointerException if oneClass is null
+   */
+  public static boolean compileClass(Class oneClass)
+  {
+    // Never succeed.
+    return false;
+  }
+
+  /**
+   * Compile the classes whose name matches <code>classNames/code>.
+   *
+   * @param classNames the name of classes to compile
+   * @return <code>false</code> if no compiler is available or
+   *         compilation failed, <code>true</code> if compilation succeeded
+   * @throws NullPointerException if classNames is null
+   */
+  public static boolean compileClasses(String classNames)
+  {
+    // Note the incredibly lame interface.  Always fail.
+    return false;
+  }
+
+  /**
+   * This method examines the argument and performs an operation
+   * according to the compilers documentation.  No specific operation
+   * is required.
+   *
+   * @param arg a compiler-specific argument
+   * @return a compiler-specific value, including null
+   * @throws NullPointerException if the compiler doesn't like a null arg
+   */
+  public static Object command(Object arg)
+  {
+    // Our implementation defines this to a no-op.
+    return null;
+  }
+
+  /**
+   * Calling <code>Compiler.enable()</code> will cause the compiler
+   * to resume operation if it was previously disabled; provided that a
+   * compiler even exists.
+   */
+  public static void enable()
+  {
+  }
+
+  /**
+   * Calling <code>Compiler.disable()</code> will cause the compiler
+   * to be suspended; provided that a compiler even exists.
+   */
+  public static void disable()
+  {
+  }
 }
Index: kaffe/libraries/javalib/java/lang/RuntimePermission.java
diff -u kaffe/libraries/javalib/java/lang/RuntimePermission.java:1.1 kaffe/libraries/javalib/java/lang/RuntimePermission.java:1.2
--- kaffe/libraries/javalib/java/lang/RuntimePermission.java:1.1	Thu Jul 22 02:12:20 1999
+++ kaffe/libraries/javalib/java/lang/RuntimePermission.java	Sat Mar 13 16:27:22 2004
@@ -1,33 +1,208 @@
+/* RuntimePermission.java -- permission for a secure runtime action
+   Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
 
-/*
- * Java core library component.
- *
- * Copyright (c) 1999
- *	Archie L. Cobbs.  All rights reserved.
- * Copyright (c) 1999
- *	Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- *
- * Author: Archie L. Cobbs <archie at whistle.com>
- */
 
 package java.lang;
 
 import java.security.BasicPermission;
 
-public final class RuntimePermission extends BasicPermission {
-
-	public RuntimePermission(String name) {
-		super(name);
-	}
-
-	public RuntimePermission(String name, String actions) {
-		super(name, actions);
-		if (actions != null) {
-			throw new IllegalArgumentException();
-		}
-	}
+/**
+ * A <code>RuntimePermission</code> contains a permission name, but no
+ * actions list.  This means you either have the permission or you don't.
+ *
+ * Permission names have the follow the hierarchial property naming
+ * convention.  In addition, an asterisk may appear at the end of a
+ * name if following a period or by itself.
+ *
+ * <table border=1>
+ * <tr><th>Valid names</th><th>Invalid names</th></tr>
+ * <tr><td>"accessClassInPackage.*","*"</td>
+ * <td>"**", "*x", "*.a"</td></tr>
+ * </table>
+ * <br>
+ *
+ * The following table provides a list of all the possible RuntimePermission
+ * permission names with a description of what that permission allows.<br>
+ * <table border=1>
+ * <tr><th>Permission Name</th><th>Permission Allows</th><th>Risks</th</tr>
+ * <tr>
+ *   <td><code>createClassLoader</code></td>
+ *   <td>creation of a class loader</td>
+ *   <td>a class loader can load rogue classes which bypass all security
+ *       permissions</td></tr>
+ * <tr>
+ *   <td><code>getClassLoader</code></td>
+ *   <td>retrieval of the class loader for the calling class</td>
+ *   <td>rogue code could load classes not otherwise available</td></tr>
+ * <tr>
+ *   <td><code>setContextClassLoader</code></td>
+ *   <td>allows the setting of the context class loader used by a thread</td>
+ *   <td>rogue code could change the context class loader needed by system
+ *       threads</td></tr>
+ * <tr>
+ *   <td><code>setSecurityManager</code></td>
+ *   <td>allows the application to replace the security manager</td>
+ *   <td>the new manager may be less restrictive, so that rogue code can
+ *       bypass existing security checks</td></tr>
+ * <tr>
+ *   <td><code>createSecurityManager</code></td>
+ *   <td>allows the application to create a new security manager</td>
+ *   <td>rogue code can use the new security manager to discover information
+ *       about the execution stack</td></tr>
+ * <tr>
+ *   <td><code>exitVM</code></td>
+ *   <td>allows the application to halt the virtual machine</td>
+ *   <td>rogue code can mount a denial-of-service attack by killing the
+ *       virtual machine</td></tr>
+ * <tr>
+ *   <td><code>shutdownHooks</code></td>
+ *   <td>allows registration and modification of shutdown hooks</td>
+ *   <td>rogue code can add a hook that interferes with clean
+ *       virtual machine shutdown</td></tr>
+ * <tr>
+ *   <td><code>setFactory</code></td>
+ *   <td>allows the application to set the socket factory for socket,
+ *       server socket, stream handler, or RMI socket factory.</td>
+ *   <td>rogue code can create a rogue network object which mangles or
+ *       intercepts data</td></tr>
+ * <tr>
+ *   <td><code>setIO</code></td>
+ *   <td>allows the application to set System.out, System.in, and
+ *       System.err</td>
+ *   <td>rogue code could sniff user input and intercept or mangle
+ *       output</td></tr>
+ * <tr>
+ *   <td><code>modifyThread</code></td>
+ *   <td>allows the application to modify any thread in the virtual machine
+ *       using any of the methods <code>stop</code>, <code>resume</code>,
+ *       <code>suspend</code>, <code>setPriority</code>, and
+ *       <code>setName</code> of classs <code>Thread</code></td>
+ *   <td>rogue code could adversely modify system or user threads</td></tr>
+ * <tr>
+ *   <td><code>stopThread</code></td>
+ *   <td>allows the application to <code>stop</code> any thread it has
+ *       access to in the system</td>
+ *   <td>rogue code can stop arbitrary threads</td></tr>
+ * <tr>
+ *   <td><code>modifyThreadGroup</td>
+ *   <td>allows the application to modify thread groups using any of the
+ *       methods <code>destroy</code>, <code>resume</code>,
+ *       <code>setDaemon</code>, <code>setMaxPriority</code>,
+ *       <code>stop</code>, and <code>suspend</code> of the class
+ *       <code>ThreadGroup</code></td>
+ *   <td>rogue code can mount a denial-of-service attack by changing run
+ *       priorities</td></tr>
+ * <tr>
+ *   <td><code>getProtectionDomain</code></td>
+ *   <td>retrieve a class's ProtectionDomain</td>
+ *   <td>rogue code can gain information about the security policy, to
+ *       prepare a better attack</td></tr>
+ * <tr>
+ *   <td><code>readFileDescriptor</code></td>
+ *   <td>read a file descriptor</td>
+ *   <td>rogue code can read sensitive information</td></tr>
+ * <tr>
+ *   <td><code>writeFileDescriptor</code></td>
+ *   <td>write a file descriptor</td>
+ *   <td>rogue code can write files, including viruses, and can modify the
+ *       virtual machine binary; if not just fill up the disk</td></tr>
+ * <tr>
+ *   <td><code>loadLibrary.<code><em>library name</em></td>
+ *   <td>dynamic linking of the named library</td>
+ *   <td>native code can bypass many security checks of pure Java</td></tr>
+ * <tr>
+ *   <td><code>accessClassInPackage.</code><em>package name</em></td>
+ *   <td>access to a package via a ClassLoader</td>
+ *   <td>rogue code can access classes not normally available</td></tr>
+ * <tr>
+ *   <td><code>defineClassInPackage.</code><em>package name</em></td>
+ *   <td>define a class inside a given package</td>
+ *   <td>rogue code can install rogue classes, including in trusted packages
+ *       like java.security or java.lang</td></tr>
+ * <tr>
+ *   <td><code>accessDeclaredMembers</code></td>
+ *   <td>access declared class members via reflection</td>
+ *   <td>rogue code can discover information, invoke methods, or modify fields
+ *       that are not otherwise available</td></tr>
+ * <tr>
+ *   <td><code>queuePrintJob</code></td>
+ *   <td>initiate a print job</td>
+ *   <td>rogue code could make a hard copy of sensitive information, or
+ *       simply waste paper</td></tr>
+ * </table>
+ *
+ * @author Brian Jones
+ * @author Eric Blake <ebb9 at email.byu.edu>
+ * @see BasicPermission
+ * @see Permission
+ * @see SecurityManager
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public final class RuntimePermission extends BasicPermission
+{
+  /**
+   * Compatible with JDK 1.2+.
+   */
+  private static final long serialVersionUID = 7399184964622342223L;
+
+  /**
+   * Create a new permission with the specified name.
+   *
+   * @param permissionName the name of the granted permission
+   * @throws NullPointerException if name is null
+   * @throws IllegalArgumentException thrown if name is empty or invalid
+   */
+  public RuntimePermission(String permissionName)
+    {
+      super(permissionName);
+    }
+
+  /**
+   * Create a new permission with the specified name. The actions argument
+   * is ignored, as runtime permissions have no actions.
+   *
+   * @param permissionName the name of the granted permission
+   * @param actions ignored
+   * @throws NullPointerException if name is null
+   * @throws IllegalArgumentException thrown if name is empty or invalid
+   */
+  public RuntimePermission(String permissionName, String actions)
+  {
+    super(permissionName);
+  }
 }
-
Index: kaffe/libraries/javalib/java/lang/reflect/AccessibleObject.java
diff -u kaffe/libraries/javalib/java/lang/reflect/AccessibleObject.java:1.3 kaffe/libraries/javalib/java/lang/reflect/AccessibleObject.java:1.4
--- kaffe/libraries/javalib/java/lang/reflect/AccessibleObject.java:1.3	Fri Jan  4 05:12:24 2002
+++ kaffe/libraries/javalib/java/lang/reflect/AccessibleObject.java	Sat Mar 13 16:27:22 2004
@@ -1,67 +1,159 @@
-/*
- * Java core library component.
- *
- * Copyright (c) 2001
- *      Andrew Taylor.  All rights reserved.
- * Copyright (c) 2001
- *      Edouard G. Parmelan.  All rights reserverd.
- * Copyright (c) 2001
- *      Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- *
- * Author: Andrew Taylor <andrew.taylor at montage.ca>
- * Modified by Edouard G. Parmelan to support jdk1.3 security behavior.
- * Checked Spec: JDK 1.3
- */
+/* java.lang.reflect.AccessibleObject
+   Copyright (C) 2001 Free Software Foundation, Inc.
 
-package java.lang.reflect;
+This file is part of GNU Classpath.
 
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
 
-public class AccessibleObject
-{
-    static final private java.security.Permission suppressAccessChecks =
-	new ReflectPermission("suppressAccessChecks");
 
-    private boolean accessible;
-
-    protected AccessibleObject() {
-    }
+package java.lang.reflect;
 
-    public boolean isAccessible() {
-	return accessible;
-    }
-
-    public void setAccessible(boolean accessible)
-	throws SecurityException
-    {
-	SecurityManager sm = System.getSecurityManager();
-	if (sm != null)
-	    sm.checkPermission (suppressAccessChecks);
-	setAccessible0 (this, accessible);
-    }
-
-    public static void setAccessible(AccessibleObject[] objs, boolean accessible)
-	throws SecurityException
-    {
-	SecurityManager sm = System.getSecurityManager();
-	if (sm != null)
-	    sm.checkPermission (suppressAccessChecks);
-	for (int i = 0; i < objs.length; i++)
-	    setAccessible0(objs[i], accessible);
-    }
-
-    private static void setAccessible0(AccessibleObject obj, boolean accessible)
-	throws SecurityException
-    {
-	if (accessible && obj instanceof Constructor) {
-	    // JKD1.3 enforce check to not changes java.lang.Class
-	    // constructors
-	    if (((Constructor)obj).getDeclaringClass() == Class.class) {
-		throw new SecurityException ("Can't change accessibility of java.lang.Class constructor");
-	    }
-	}
-	obj.accessible = accessible;
-    }
+/**
+ * This class is the superclass of various reflection classes, and
+ * allows sufficiently trusted code to bypass normal restrictions to
+ * do necessary things like invoke private methods outside of the
+ * class during Serialization.  If you don't have a good reason
+ * to mess with this, don't try. Fortunately, there are adequate
+ * security checks before you can set a reflection object as accessible.
+ *
+ * @author Tom Tromey <tromey at cygnus.com>
+ * @author Eric Blake <ebb9 at email.byu.edu>
+ * @see Field
+ * @see Constructor
+ * @see Method
+ * @see ReflectPermission
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class AccessibleObject
+{
+  /**
+   * True if this object is marked accessible, which means the reflected
+   * object bypasses normal security checks.
+   */
+  // default visibility for use by inherited classes
+  boolean flag = false;
+
+  /**
+   * Only the three reflection classes that extend this can create an
+   * accessible object.  This is not serializable for security reasons.
+   */
+  protected AccessibleObject()
+  {
+  }
+
+  /**
+   * Return the accessibility status of this object.
+   *
+   * @return true if this object bypasses security checks
+   */
+  public boolean isAccessible()
+  {
+    return flag;
+  }
+
+  /**
+   * Convenience method to set the flag on a number of objects with a single
+   * security check. If a security manager exists, it is checked for
+   * <code>ReflectPermission("suppressAccessChecks")</code>.<p>
+   *
+   * It is forbidden to set the accessibility flag to true on any constructor
+   * for java.lang.Class. This will result in a SecurityException. If the 
+   * SecurityException is thrown for any of the passed AccessibleObjects,
+   * the accessibility flag will be set on AccessibleObjects in the array prior 
+   * to the one which resulted in the exception.
+   *
+   * @param array the array of accessible objects
+   * @param flag the desired state of accessibility, true to bypass security
+   * @throws NullPointerException if array is null
+   * @throws SecurityException if the request is denied
+   * @see SecurityManager#checkPermission(java.security.Permission)
+   * @see RuntimePermission
+   */
+  public static void setAccessible(AccessibleObject[] array, boolean flag)
+  {
+    checkPermission();
+    for (int i = 0; i < array.length; i++)
+      array[i].secureSetAccessible(flag);
+  }
+
+  /**
+   * Sets the accessibility flag for this reflection object. If a security
+   * manager exists, it is checked for
+   * <code>ReflectPermission("suppressAccessChecks")</code>.<p>
+   *
+   * It is forbidden to set the accessibility flag to true on any constructor for 
+   * java.lang.Class. This will result in a SecurityException.
+   *
+   * @param flag the desired state of accessibility, true to bypass security
+   * @throws NullPointerException if array is null
+   * @throws SecurityException if the request is denied
+   * @see SecurityManager#checkPermission(java.security.Permission)
+   * @see RuntimePermission
+   */
+  public void setAccessible(boolean flag)
+  {
+    checkPermission();
+    secureSetAccessible(flag);
+  }
+
+  /**
+   * Performs the specified security check, for
+   * <code>ReflectPermission("suppressAccessChecks")</code>.
+   *
+   * @throws SecurityException if permission is denied
+   */
+  private static final void checkPermission()
+  {
+    SecurityManager sm = System.getSecurityManager();
+    if (sm != null)
+      sm.checkPermission(new ReflectPermission("suppressAccessChecks"));
+  }
+
+  /**
+   * Performs the actual accessibility change, this must always be invoked
+   * after calling checkPermission.
+   *
+   * @param flag the desired status
+   * @throws SecurityException if flag is true and this is a constructor
+   * for <code>java.lang.Class</code>.
+   */
+  private final void secureSetAccessible(boolean flag)
+  {
+    if (flag &&
+        (this instanceof Constructor
+          && ((Constructor) this).getDeclaringClass() == Class.class))
+      throw new SecurityException("Cannot make object accessible: " + this);
+    this.flag = flag;
+  }
 }
Index: kaffe/libraries/javalib/java/lang/reflect/InvocationHandler.java
diff -u kaffe/libraries/javalib/java/lang/reflect/InvocationHandler.java:1.2 kaffe/libraries/javalib/java/lang/reflect/InvocationHandler.java:1.3
--- kaffe/libraries/javalib/java/lang/reflect/InvocationHandler.java:1.2	Sat Nov 24 01:52:52 2001
+++ kaffe/libraries/javalib/java/lang/reflect/InvocationHandler.java	Sat Mar 13 16:27:22 2004
@@ -1,21 +1,136 @@
-/*
- * Java core library component.
+/* java.lang.reflect.InvocationHandler - dynamically executes methods in
+   proxy instances
+   Copyright (C) 2001 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang.reflect;
+
+/**
+ * This interface defines an invocation handler.  Suppose you are using
+ * reflection, and found a method that requires that its parameter
+ * be an object of a given interface.  You want to call this method,
+ * but have no idea what classes implement that interface.  So, you can
+ * create a {@link Proxy} instance, a convenient way to dynamically
+ * generate a class that meets all the necessary properties of that
+ * interface.  But in order for the proxy instance to do any good, it
+ * needs to know what to do when interface methods are invoked!  So,
+ * this interface is basically a cool wrapper that provides runtime
+ * code generation needed by proxy instances.<p>
+ *
+ * While this interface was designed for use by Proxy, it will also
+ * work on any object in general.<p>
+ *
+ * Hints for implementing this class:<br>
+ * <ul>
+ *  <li>Don't forget that Object.equals, Object.hashCode, and
+ *      Object.toString will call this handler.  In particular,
+ *      a naive call to proxy.equals, proxy.hashCode, or proxy.toString
+ *      will put you in an infinite loop.  And remember that string
+ *      concatenation also invokes toString.</li>
+ *  <li>Obey the contract of the Method object you are handling, or
+ *      the proxy instance will be forced to throw a
+ *      {@link NullPointerException}, {@link ClassCastException},
+ *      or {@link UndeclaredThrowableException}.</li>
+ *  <li>Be prepared to wrap/unwrap primitives as necessary.</li>
+ *  <li>The Method object may be owned by a different interface than
+ *      what was actually used as the qualifying type of the method
+ *      invocation in the Java source code. This means that it might
+ *      not always be safe to throw an exception listed as belonging
+ *      to the method's throws clause.</li>
+ * </ul>
  *
- * Copyright (c) 2001
- *      Edouard G. Parmelan.  All rights reserverd.
- * Copyright (c) 2001
- *      Transvirtual Technologies, Inc.  All rights reserved.
+ * <p><small>For a fun time, create an InvocationHandler that handles the
+ * methods of a proxy instance of the InvocationHandler interface!</small>
  *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
+ * @see Proxy
+ * @see UndeclaredThrowableException
  *
- * Author: Edouard G. Parmelan <egp at free.fr>
- * Checked Spec: JDK 1.3
+ * @author Eric Blake <ebb9 at email.byu.edu>
+ * @since 1.3
+ * @status updated to 1.4
  */
-
-package java.lang.reflect;
-
 public interface InvocationHandler
 {
-    Object invoke(Object proxy, Method method, Object[] args) throws Throwable;
+  /**
+   * When a method is invoked on a proxy instance, it is wrapped and
+   * this method is called instead, so that you may decide at runtime
+   * how the original method should behave.
+   *
+   * @param proxy the instance that the wrapped method should be
+   *        invoked on.  When this method is called by a Proxy object,
+   *        `proxy' will be an instance of {@link Proxy}, and oddly enough,
+   *        <code>Proxy.getInvocationHandler(proxy)</code> will return
+   *        <code>this</code>!
+   * @param method the reflected method to invoke on the proxy.
+   *        When this method is called by a Proxy object, 'method'
+   *        will be the reflection object owned by the declaring
+   *        class or interface, which may be a supertype of the
+   *        interfaces the proxy directly implements.
+   * @param args the arguments passed to the original method, or
+   *        <code>null</code> if the method takes no arguments.
+   *        (But also be prepared to handle a 0-length array).
+   *        Arguments of primitive type, such as <code>boolean</code>
+   *        or <code>int</code>, are wrapped in the appropriate
+   *        class such as {@link Boolean} or {@link Integer}.
+   * @return whatever is necessary to return from the wrapped method.
+   *         If the wrapped method is <code>void</code>, the proxy
+   *         instance will ignore it.  If the wrapped method returns
+   *         a primitive, this must be the correct wrapper type whose value
+   *         is exactly assignable to the appropriate type (no widening
+   *         will be performed); a null object in this case causes a
+   *         {@link NullPointerException}.  In all remaining cases, if
+   *         the returned object is not assignment compatible to the
+   *         declared type of the original method, the proxy instance
+   *         will generate a {@link ClassCastException}.
+   * @throws Throwable this interface is listed as throwing anything,
+   *         but the implementation should only throw unchecked
+   *         exceptions and exceptions listed in the throws clause of
+   *         all methods being overridden by the proxy instance.  If
+   *         something is thrown that is not compatible with the throws
+   *         clause of all overridden methods, the proxy instance will
+   *         wrap the exception in an UndeclaredThrowableException.
+   *         Note that an exception listed in the throws clause of the
+   *         `method' parameter might not be declared in additional
+   *         interfaces also implemented by the proxy object.
+   *
+   * @see Proxy
+   * @see UndeclaredThrowableException
+   */
+  Object invoke(Object proxy, Method method, Object[] args)
+    throws Throwable;
+
 }
Index: kaffe/libraries/javalib/java/lang/reflect/Member.java
diff -u kaffe/libraries/javalib/java/lang/reflect/Member.java:1.6 kaffe/libraries/javalib/java/lang/reflect/Member.java:1.7
--- kaffe/libraries/javalib/java/lang/reflect/Member.java:1.6	Sat Nov 24 01:52:52 2001
+++ kaffe/libraries/javalib/java/lang/reflect/Member.java	Sat Mar 13 16:27:22 2004
@@ -1,26 +1,100 @@
-/*
- * Java core library component.
- *
- * Copyright (c) 1997, 1998, 2001
- *      Transvirtual Technologies, Inc.  All rights reserved.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file.
- *
- * Checked Spec: JDK 1.3
- */
-
-package java.lang.reflect;
-
+/* java.lang.reflect.Member - common query methods in reflection
+   Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
 
-public interface Member {
+This file is part of GNU Classpath.
 
-int PUBLIC = 0;
-int DECLARED = 1;
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath 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 for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
 
-Class getDeclaringClass();
 
-int getModifiers();
+package java.lang.reflect;
 
-String getName();
+/**
+ * Member is an interface that represents any member of a class (field or
+ * method) or a constructor. You can get information about the declaring
+ * class, name or modifiers of the member with this interface.
+ *
+ * @author John Keiser
+ * @author Per Bothner <bothner at cygnus.com>
+ * @author Eric Blake <ebb9 at email.byu.edu>
+ * @see Class
+ * @see Field
+ * @see Method
+ * @see Constructor
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface Member
+{
+  /**
+   * Represents all members, whether public, private, protected or
+   * package-protected, but only which are declared in this class.
+   * Used in SecurityManager.checkMemberAccess() to determine the
+   * type of members to access.
+   * @see SecurityManager#checkMemberAccess()
+   */
+  int DECLARED = 1;
+
+  /**
+   * Represents public members only, but includes all inherited members.
+   *  Used in SecurityManager.checkMemberAccess() to determine the type of
+   * members to access.
+   * @see SecurityManager#checkMemberAccess()
+   */
+  int PUBLIC = 0;
+
+  /**
+   * Gets the class that declared this member. This is not the class where
+   * this method was called, or even the class where this Member object
+   * came to life, but the class that declares the member this represents.
+   *
+   * @return the class that declared this member
+   */
+  Class getDeclaringClass();
+
+  /**
+   * Gets the simple name of this member. This will be a valid Java
+   * identifier, with no qualification.
+   *
+   * @return the name of this member
+   */

*** Patch too long, truncated ***




More information about the kaffe mailing list