classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Patch: FYI: more 1.5 stuff


From: Tom Tromey
Subject: [cp-patches] [generics] Patch: FYI: more 1.5 stuff
Date: 06 Aug 2004 18:09:54 -0600

I'm checking this in on the generics branch.
This is just a little more work I did earlier.

Some things are still missing javadocs.  I'm not too concerned about
that, I'll write them later.  In particular I think before the
eventual merge back to the trunk we will ensure that there are no
regressions in documented-ness.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>

        * vm/reference/java/lang/VMClass.java (cast): Declare.
        * java/io/SequenceInputStream.java (SequenceInputStream):
        Constructor now generic.
        (e): Updated.
        (getNextStream): Likewise.
        * java/lang/Thread.java (UncaughtExceptionHandler): New
        interface.
        (State): New enum.
        * java/lang/Readable.java: New file.
        * java/lang/Appendable.java: New file.
        * java/lang/Iterable.java: Documented.
        * java/lang/Class.java (asSubClass): New method.
        (Class): Now generic.
        * java/lang/Boolean.java (parseBoolean): New methods.
        (compareTo): Likewise.
        (Boolean): Now implements Comparable.
        * java/lang/ThreadLocal.java: Now generic.
        * java/lang/InheritableThreadLocal.java: Now generic.
        * java/lang/Deprecated.java: New file.
        * java/lang/Override.java: New file.
        * java/lang/SuppressWarnings.java: New file.

Index: java/io/SequenceInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/SequenceInputStream.java,v
retrieving revision 1.7
diff -u -r1.7 SequenceInputStream.java
--- java/io/SequenceInputStream.java 21 May 2004 07:54:33 -0000 1.7
+++ java/io/SequenceInputStream.java 7 Aug 2004 00:24:35 -0000
@@ -1,5 +1,5 @@
 /* SequenceInputStream.java -- Reads multiple input streams in sequence
-   Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -71,8 +71,11 @@
   /** Secondary input stream; not used if constructed w/ enumeration. */
   private InputStream in2;
 
-  /** The enumeration handle; not used if constructed w/ 2 explicit input 
streams. */
-  private Enumeration e;
+  /**
+   * The enumeration handle; not used if constructed w/ 2 explicit
+   * input streams.
+   */
+  private Enumeration<? extends InputStream> e;
 
  /**
   * This method creates a new <code>SequenceInputStream</code> that obtains
@@ -82,10 +85,10 @@
   * @param e An <code>Enumeration</code> that will return a list of
   * <code>InputStream</code>s to read in sequence
   */
-  public SequenceInputStream(Enumeration e)
+  public SequenceInputStream(Enumeration<? extends InputStream> e)
   {
     this.e = e;
-    in = (InputStream) e.nextElement();
+    in = e.nextElement();
     in2 = null;
   }
 
@@ -207,14 +210,13 @@
     if (e != null)
       {
         if (e.hasMoreElements())
-         nextIn = (InputStream) e.nextElement();
+         nextIn = e.nextElement();
+      }
+    else if (in2 != null)
+      {
+       nextIn = in2;
+       in2 = null;
       }
-    else
-      if (in2 != null)
-       {
-         nextIn = in2;
-         in2 = null;
-       }
 
     return nextIn;
   }
Index: java/lang/Appendable.java
===================================================================
RCS file: java/lang/Appendable.java
diff -N java/lang/Appendable.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/Appendable.java 7 Aug 2004 00:24:35 -0000
@@ -0,0 +1,44 @@
+/* Appendable.java -- Something to which characters can be appended
+   Copyright (C) 2004 Free Software Foundation
+
+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;
+
+public interface Appendable
+{
+  Appendable append(char c);
+  Appendable append(CharSequence seq);
+}
Index: java/lang/Boolean.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Boolean.java,v
retrieving revision 1.20
diff -u -r1.20 Boolean.java
--- java/lang/Boolean.java 25 Feb 2002 20:02:58 -0000 1.20
+++ java/lang/Boolean.java 7 Aug 2004 00:24:35 -0000
@@ -1,5 +1,5 @@
 /* Boolean.java -- object wrapper for boolean
-   Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -49,7 +49,7 @@
  * @since 1.0
  * @status updated to 1.4
  */
-public final class Boolean implements Serializable
+public final class Boolean implements Serializable, Comparable<Boolean>
 {
   /**
    * Compatible with JDK 1.0.2+.
@@ -221,4 +221,26 @@
       return false;
     return "true".equalsIgnoreCase(System.getProperty(name));
   }
+
+  /**
+   * If the String argument is "true", ignoring case, return true.
+   * Otherwise, return false.
+   *
+   * @param b String to parse
+   * @since 1.5
+   */
+  public static boolean parseBoolean(String b)
+  {
+    return "true".equalsIgnoreCase(b) ? true : false;
+  }
+
+  /**
+   * This implements the comparison contract specified by Comparable.
+   * @see Comparable
+   * @since 1.5
+   */
+  public int compareTo(Boolean other)
+  {
+    return value == other.value ? 0 : (value ? 1 : -1);
+  }
 }
Index: java/lang/Class.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Class.java,v
retrieving revision 1.22
diff -u -r1.22 Class.java
--- java/lang/Class.java 27 Jul 2004 07:28:01 -0000 1.22
+++ java/lang/Class.java 7 Aug 2004 00:24:36 -0000
@@ -86,7 +86,7 @@
  * @since 1.0
  * @see ClassLoader
  */
-public final class Class implements Serializable
+public final class Class<K> implements Serializable
 {
   /**
    * Compatible with JDK 1.0+.
@@ -144,9 +144,9 @@
    * @throws ExceptionInInitializerError if the class loads, but an exception
    *         occurs during initialization
    */
-  public static Class forName(String name) throws ClassNotFoundException
+  public static Class<?> forName(String name) throws ClassNotFoundException
   {
-    Class result = VMClass.forName (name);
+    Class<?> result = VMClass.forName (name);
     if (result == null)
       result = Class.forName(name, true,
                             
VMSecurityManager.getClassContext()[1].getClassLoader());
@@ -180,8 +180,8 @@
    * @see ClassLoader
    * @since 1.2
    */
-  public static Class forName(String name, boolean initialize,
-                              ClassLoader classloader)
+  public static Class<?> forName(String name, boolean initialize,
+                                ClassLoader classloader)
     throws ClassNotFoundException
   {
     if (classloader == null)
@@ -191,14 +191,14 @@
         if (sm != null)
           {
             // Get the calling class and classloader
-            Class c = VMSecurityManager.getClassContext()[1];
+            Class<?> c = VMSecurityManager.getClassContext()[1];
             ClassLoader cl = c.getClassLoader();
             if (cl != null)
               sm.checkPermission(new RuntimePermission("getClassLoader"));
           }
        if (name.startsWith("["))
          return VMClass.loadArrayClass(name, null);
-       Class c = VMClassLoader.loadClass(name, true);
+       Class<?> c = VMClassLoader.loadClass(name, true);
        if (c != null)
          {
            if (initialize)
@@ -209,7 +209,7 @@
       }
     if (name.startsWith("["))
       return VMClass.loadArrayClass(name, classloader);
-    Class c = classloader.loadClass(name);
+    Class<?> c = classloader.loadClass(name);
     classloader.resolveClass(c);
     if (initialize)
       VMClass.initialize(c);
@@ -289,7 +289,7 @@
    * @see Array
    * @since 1.1
    */
-  public Class getComponentType()
+  public Class<?> getComponentType()
   {
     return VMClass.getComponentType (this);
   }
@@ -308,7 +308,8 @@
    * @see #getConstructors()
    * @since 1.1
    */
-  public Constructor getConstructor(Class[] types) throws NoSuchMethodException
+  public Constructor<K> getConstructor(Class... types)
+    throws NoSuchMethodException
   {
     memberAccessCheck(Member.PUBLIC);
     Constructor[] constructors = getDeclaredConstructors(true);
@@ -353,7 +354,7 @@
    * @see #getDeclaredConstructors()
    * @since 1.1
    */
-  public Constructor getDeclaredConstructor(Class[] types)
+  public Constructor<K> getDeclaredConstructor(Class... types)
     throws NoSuchMethodException
   {
     memberAccessCheck(Member.DECLARED);
@@ -482,7 +483,7 @@
    * @see #getDeclaredMethods()
    * @since 1.1
    */
-  public Method getDeclaredMethod(String methodName, Class[] types)
+  public Method getDeclaredMethod(String methodName, Class... types)
     throws NoSuchMethodException
   {
     memberAccessCheck(Member.DECLARED);
@@ -641,17 +642,16 @@
     
     public boolean equals(Object o)
     {
-      if(o instanceof MethodKey)
+      if (o instanceof MethodKey)
        {
-         MethodKey m = (MethodKey)o;
-         if(m.name.equals(name) && m.params.length == params.length && 
m.returnType == returnType)
+         MethodKey m = (MethodKey) o;
+         if (m.name.equals(name) && m.params.length == params.length
+             && m.returnType == returnType)
            {
-             for(int i = 0; i < params.length; i++)
+             for (int i = 0; i < params.length; i++)
                {
-                 if(m.params[i] != params[i])
-                   {
-                     return false;
-                   }
+                 if (m.params[i] != params[i])
+                   return false;
                }
              return true;
            }
@@ -687,7 +687,7 @@
    * @see #getMethods()
    * @since 1.1
    */
-  public Method getMethod(String methodName, Class[] types)
+  public Method getMethod(String methodName, Class... types)
     throws NoSuchMethodException
   {
     memberAccessCheck(Member.PUBLIC);
@@ -1006,7 +1006,7 @@
    * @throws NullPointerException if c is null
    * @since 1.1
    */
-  public boolean isAssignableFrom(Class c)
+  public boolean isAssignableFrom(Class<?> c)
   {
     return VMClass.isAssignableFrom (this, c);
   }
@@ -1244,6 +1244,29 @@
   }
 
   /**
+   * FIXME
+   * @since 1.5
+   */
+  <T> public Class<? extends T> asSubclass(Class<T> klass)
+  {
+    if (! klass.isAssignableFrom(this))
+      throw new ClassCastException();
+    return (Class<? extends T>) klass;
+  }
+
+  /**
+   * Return object, cast to this Class' type.
+   *
+   * @param obj the object to cast
+   * @throws ClassCastException  if obj is not an instance of this class
+   * @since 1.5
+   */
+  public K cast(Object obj)
+  {
+    return VMClassLoader.cast(obj, this);
+  }
+
+  /**
    * Like <code>getField(String)</code> but without the security checks and 
returns null
    * instead of throwing NoSuchFieldException.
    */
Index: java/lang/Deprecated.java
===================================================================
RCS file: java/lang/Deprecated.java
diff -N java/lang/Deprecated.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/Deprecated.java 7 Aug 2004 00:24:36 -0000
@@ -0,0 +1,43 @@
+/* Deprecated - Annotation to mark elements as deprecated
+   Copyright (C) 2004 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;
+
address@hidden(SOURCE)
+public @interface Deprecated
+{
+}
Index: java/lang/InheritableThreadLocal.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/InheritableThreadLocal.java,v
retrieving revision 1.7
diff -u -r1.7 InheritableThreadLocal.java
--- java/lang/InheritableThreadLocal.java 9 Aug 2003 18:47:04 -0000 1.7
+++ java/lang/InheritableThreadLocal.java 7 Aug 2004 00:24:36 -0000
@@ -1,5 +1,5 @@
 /* InheritableThreadLocal -- a ThreadLocal which inherits values across threads
-   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -61,7 +61,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public class InheritableThreadLocal extends ThreadLocal
+public class InheritableThreadLocal<T> extends ThreadLocal<T>
 {
   /**
    * Maps Threads to a List of InheritableThreadLocals (the heritage of that
@@ -69,8 +69,8 @@
    * List can be collected, too. Maps to a list in case the user overrides
    * equals.
    */
-  private static final Map threadMap
-         = Collections.synchronizedMap(new WeakHashMap());
+  private static final Map threadMap<Thread, 
ArrayList<InheritableThreadLocals<T>>>
+    = Collections.synchronizedMap(new WeakHashMap<Thread, 
ArrayList<InheritableThreadLocals<T>>>());
 
   /**
    * Creates a new InheritableThreadLocal that has no values associated
@@ -81,10 +81,10 @@
     Thread currentThread = Thread.currentThread();
     // Note that we don't have to synchronize, as only this thread will
     // ever modify the returned heritage and threadMap is a synchronizedMap.
-    List heritage = (List) threadMap.get(currentThread);
+    List<InheritableThreadLocal<T>> heritage = threadMap.get(currentThread);
     if (heritage == null)
       {
-        heritage = new ArrayList();
+        heritage = new ArrayList<InheritableThreadLocal<T>>();
         threadMap.put(currentThread, heritage);
       }
     heritage.add(this);
@@ -99,7 +99,7 @@
    *        the moment of creation of the child
    * @return the initial value for the child thread
    */
-  protected Object childValue(Object parentValue)
+  protected T childValue(T parentValue)
   {
     return parentValue;
   }
@@ -118,23 +118,25 @@
     Thread parentThread = Thread.currentThread();
     // Note that we don't have to synchronize, as only this thread will
     // ever modify the returned heritage and threadMap is a synchronizedMap. 
-    ArrayList heritage = (ArrayList) threadMap.get(parentThread);
+    ArrayList<InheritableThreadLocal<T>> heritage
+      = threadMap.get(parentThread);
     if (heritage != null)
       {
-        threadMap.put(childThread, heritage.clone());
+        threadMap.put(childThread,
+                     (ArrayList<InheritableThreadLocal<T>>) heritage.clone());
         // Perform the inheritance.
-        Iterator it = heritage.iterator();
+        Iterator<InheritableThreadLocal<T>> it = heritage.iterator();
         int i = heritage.size();
         while (--i >= 0)
           {
-            InheritableThreadLocal local = (InheritableThreadLocal) it.next();
-            Object parentValue = local.valueMap.get(parentThread);
+            InheritableThreadLocal<T> local = it.next();
+           T parentValue = local.valueMap.get(parentThread);
             if (parentValue != null)
               {
-                Object childValue = local.childValue(parentValue == NULL
-                                                     ? null : parentValue);
+               T childValue = local.childValue(parentValue == (T) NULL
+                                               ? null : parentValue);
                 local.valueMap.put(childThread, (childValue == null
-                                                 ? NULL : parentValue));
+                                                 ? (T) NULL : parentValue));
               }
           }
       }
Index: java/lang/Iterable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Attic/Iterable.java,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 Iterable.java
--- java/lang/Iterable.java 5 Aug 2004 21:09:36 -0000 1.1.2.1
+++ java/lang/Iterable.java 7 Aug 2004 00:24:36 -0000
@@ -40,7 +40,17 @@
 
 import java.util.Iterator;
 
+/**
+ * This interface is used to indicate that a given class can be
+ * iterated over.  The compiler uses this interface to determine which
+ * classes are suitable targets of the <code>foreach</code> construct.
+ *
+ * @since 1.5
+ */
 public interface Iterable<E>
 {
+  /**
+   * Returns an iterator for the collection.
+   */
   Iterator<E> iterator ();
 }
Index: java/lang/Override.java
===================================================================
RCS file: java/lang/Override.java
diff -N java/lang/Override.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/Override.java 7 Aug 2004 00:24:36 -0000
@@ -0,0 +1,44 @@
+/* Override - Annotation to indicate that a method should be an override
+   Copyright (C) 2004 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;
+
address@hidden(SOURCE)
address@hidden(METHOD)
+public @interface Override
+{
+}
Index: java/lang/Readable.java
===================================================================
RCS file: java/lang/Readable.java
diff -N java/lang/Readable.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/Readable.java 7 Aug 2004 00:24:36 -0000
@@ -0,0 +1,46 @@
+/* Readable.java -- A character source
+   Copyright (C) 2004 Free Software Foundation
+
+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;
+
+import java.io.IOException;
+import java.nio.CharBuffer;
+
+public interface Readable
+{
+  int read(CharBuffer buf) throws IOException;
+}
Index: java/lang/SuppressWarnings.java
===================================================================
RCS file: java/lang/SuppressWarnings.java
diff -N java/lang/SuppressWarnings.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/SuppressWarnings.java 7 Aug 2004 00:24:36 -0000
@@ -0,0 +1,45 @@
+/* SuppressWarnings - Annotation to avoid compiler warnings
+   Copyright (C) 2004 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;
+
address@hidden(SOURCE)
address@hidden({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})
+public @interface SuppressWarnings
+{
+  String[] value ();
+}
Index: java/lang/Thread.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Thread.java,v
retrieving revision 1.8
diff -u -r1.8 Thread.java
--- java/lang/Thread.java 29 Jun 2004 10:04:41 -0000 1.8
+++ java/lang/Thread.java 7 Aug 2004 00:24:36 -0000
@@ -969,4 +969,14 @@
     group.removeThread(this);
     vmThread = null;
   }
+
+  interface UncaughtExceptionHandler
+  {
+    void uncaughtException(Thread thr, Throwable exc);
+  }
+
+  public enum State
+  {
+    BLOCKED, NEW, RUNNABLE, TERMINATED, TIMED_WAITING, WAITING
+  }
 }
Index: java/lang/ThreadLocal.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/ThreadLocal.java,v
retrieving revision 1.4
diff -u -r1.4 ThreadLocal.java
--- java/lang/ThreadLocal.java 9 Aug 2003 18:47:04 -0000 1.4
+++ java/lang/ThreadLocal.java 7 Aug 2004 00:24:36 -0000
@@ -1,5 +1,5 @@
 /* ThreadLocal -- a variable with a unique value per thread
-   Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -82,7 +82,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public class ThreadLocal
+public class ThreadLocal<T>
 {
   /**
    * Placeholder to distinguish between uninitialized and null set by the
@@ -93,8 +93,8 @@
 
   /**
    * The stored value. Package visible for use by InheritableThreadLocal. */
-  Object value;
-       
+  T value;
+
   /**
    * Maps Threads to values. Uses a WeakHashMap so if a Thread is garbage
    * collected the reference to the Value will disappear. A null value means
@@ -102,8 +102,9 @@
    * <code>set(Thread, Object)</code> and <code>get(Thread)</code> methods
    * access it. Package visible for use by InheritableThreadLocal.
    */
-  final Map valueMap = Collections.synchronizedMap(new WeakHashMap());
-       
+  final Map<Thread, T> valueMap
+    = Collections.synchronizedMap(new WeakHashMap<Thread, T>());
+
   /**
    * Creates a ThreadLocal object without associating any value to it yet.
    */
@@ -119,7 +120,7 @@
    *
    * @return the initial value of the variable in this thread
    */
-  protected Object initialValue()
+  protected T initialValue()
   {
     return null;
   }
@@ -132,18 +133,18 @@
    *
    * @return the value of the variable in this thread
    */
-  public Object get()
+  public T get()
   {
     Thread currentThread = Thread.currentThread();
     // Note that we don't have to synchronize, as only this thread will
     // ever modify the returned value and valueMap is a synchronizedMap.
-    Object value = valueMap.get(currentThread);
+    T value = valueMap.get(currentThread);
     if (value == null)
       {
         value = initialValue();
-        valueMap.put(currentThread, value == null ? NULL : value);
+        valueMap.put(currentThread, value == null ? (T) NULL : value);
       }
-    return value == NULL ? null : value;
+    return value == (T) NULL ? null : value;
   }
 
   /**
@@ -154,10 +155,10 @@
    *
    * @param value the value to set this thread's view of the variable to
    */
-  public void set(Object value)
+  public void set(T value)
   {
     // Note that we don't have to synchronize, as only this thread will
     // ever modify the returned value and valueMap is a synchronizedMap.
-    valueMap.put(Thread.currentThread(), value == null ? NULL : value);
+    valueMap.put(Thread.currentThread(), value == null ? (T) NULL : value);
   }
 }
Index: vm/reference/java/lang/VMClass.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/java/lang/VMClass.java,v
retrieving revision 1.10
diff -u -r1.10 VMClass.java
--- vm/reference/java/lang/VMClass.java 25 Apr 2004 12:03:01 -0000 1.10
+++ vm/reference/java/lang/VMClass.java 7 Aug 2004 00:24:37 -0000
@@ -290,4 +290,8 @@
    */
   static native void throwException(Throwable t);
 
+  /**
+   * Downcast object to the class' type.
+   */
+  static native Object cast(Object obj, Class k);
 } // class VMClass




reply via email to

[Prev in Thread] Current Thread [Next in Thread]