Commit 4d2446d9 by Tom Tromey Committed by Tom Tromey

LogManager.java (loggers): Genericized.

	* java/util/logging/LogManager.java (loggers): Genericized.
	(addLogger): Merged.
	(findAncestor): Likewise.
	(getLogger): Likewise.
	(getLoggerNames): Genericized.
	(reset): Merged.
	(getLevelProperty): Likewise.
	* java/lang/reflect/Method.java (getDeclaringClass): Genericized.
	* java/lang/reflect/Constructor.java (getParameterTypes):
	Genericized.
	(getExceptionTypes): Likewise.
	(newInstance): Likewise.
	* java/lang/reflect/Array.java (newInstance): Genericized.
	* java/lang/Object.java (getClass): Genericized.
	* java/nio/charset/spi/CharsetProvider.java (charsets):
	Genericized.
	* java/text/Collator.java: Implement Comparable<Object>.

From-SVN: r121473
parent 0a32f469
2007-02-01 Tom Tromey <tromey@redhat.com> 2007-02-01 Tom Tromey <tromey@redhat.com>
* java/util/logging/LogManager.java (loggers): Genericized.
(addLogger): Merged.
(findAncestor): Likewise.
(getLogger): Likewise.
(getLoggerNames): Genericized.
(reset): Merged.
(getLevelProperty): Likewise.
* java/lang/reflect/Method.java (getDeclaringClass): Genericized.
* java/lang/reflect/Constructor.java (getParameterTypes):
Genericized.
(getExceptionTypes): Likewise.
(newInstance): Likewise.
* java/lang/reflect/Array.java (newInstance): Genericized.
* java/lang/Object.java (getClass): Genericized.
* java/nio/charset/spi/CharsetProvider.java (charsets):
Genericized.
* java/text/Collator.java: Implement Comparable<Object>.
2007-02-01 Tom Tromey <tromey@redhat.com>
* java/util/Calendar.java: Implement Comparable<Calendar>. Update * java/util/Calendar.java: Implement Comparable<Calendar>. Update
comments. comments.
(clear): Call complete. (clear): Call complete.
......
/* java.lang.Object - The universal superclass in Java /* java.lang.Object - The universal superclass in Java
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2007
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -129,7 +129,7 @@ public class Object ...@@ -129,7 +129,7 @@ public class Object
* *
* @return the class of this Object * @return the class of this Object
*/ */
public final native Class getClass(); public final native Class<? extends Object> getClass();
/** /**
* Get a value that represents this Object, as uniquely as * Get a value that represents this Object, as uniquely as
......
/* java.lang.reflect.Array - manipulate arrays by reflection /* java.lang.reflect.Array - manipulate arrays by reflection
Copyright (C) 1998, 1999, 2001, 2003, 2005 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2001, 2003, 2005, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -104,7 +104,7 @@ public final class Array ...@@ -104,7 +104,7 @@ public final class Array
* @throws NegativeArraySizeException when length is less than 0 * @throws NegativeArraySizeException when length is less than 0
* @throws OutOfMemoryError if memory allocation fails * @throws OutOfMemoryError if memory allocation fails
*/ */
public static native Object newInstance(Class componentType, int length); public static native Object newInstance(Class<?> componentType, int length);
/** /**
* Creates a new multi-dimensioned array. The new array has the same * Creates a new multi-dimensioned array. The new array has the same
...@@ -130,7 +130,7 @@ public final class Array ...@@ -130,7 +130,7 @@ public final class Array
* than 0 * than 0
* @throws OutOfMemoryError if memory allocation fails * @throws OutOfMemoryError if memory allocation fails
*/ */
public static native Object newInstance(Class elementType, int[] dimensions); public static native Object newInstance(Class<?> elementType, int[] dimensions);
/** /**
* Gets the array length. * Gets the array length.
......
/* java.lang.reflect.Constructor - reflection of Java constructors /* java.lang.reflect.Constructor - reflection of Java constructors
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -155,11 +155,11 @@ public final class Constructor<T> extends AccessibleObject ...@@ -155,11 +155,11 @@ public final class Constructor<T> extends AccessibleObject
* *
* @return a list of the types of the constructor's parameters * @return a list of the types of the constructor's parameters
*/ */
public Class[] getParameterTypes () public Class<?>[] getParameterTypes ()
{ {
if (parameter_types == null) if (parameter_types == null)
getType (); getType ();
return (Class[]) parameter_types.clone(); return (Class<?>[]) parameter_types.clone();
} }
/** /**
...@@ -169,11 +169,11 @@ public final class Constructor<T> extends AccessibleObject ...@@ -169,11 +169,11 @@ public final class Constructor<T> extends AccessibleObject
* *
* @return a list of the types in the constructor's throws clause * @return a list of the types in the constructor's throws clause
*/ */
public Class[] getExceptionTypes () public Class<?>[] getExceptionTypes ()
{ {
if (exception_types == null) if (exception_types == null)
getType(); getType();
return (Class[]) exception_types.clone(); return (Class<?>[]) exception_types.clone();
} }
/** /**
...@@ -305,7 +305,7 @@ public final class Constructor<T> extends AccessibleObject ...@@ -305,7 +305,7 @@ public final class Constructor<T> extends AccessibleObject
* @throws ExceptionInInitializerError if construction triggered class * @throws ExceptionInInitializerError if construction triggered class
* initialization, which then failed * initialization, which then failed
*/ */
public native Object newInstance (Object[] args) public native T newInstance (Object... args)
throws InstantiationException, IllegalAccessException, throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException; IllegalArgumentException, InvocationTargetException;
......
// Method.java - Represent method of class or interface. // Method.java - Represent method of class or interface.
/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006 Free Software Foundation /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007 Free Software Foundation
This file is part of libgcj. This file is part of libgcj.
...@@ -68,7 +68,7 @@ public final class Method ...@@ -68,7 +68,7 @@ public final class Method
* is a non-inherited member. * is a non-inherited member.
* @return the class that declared this member * @return the class that declared this member
*/ */
public Class getDeclaringClass() public Class<?> getDeclaringClass()
{ {
return declaringClass; return declaringClass;
} }
......
/* CharsetProvider.java -- charset service provider interface /* CharsetProvider.java -- charset service provider interface
Copyright (C) 2002, 2006 Free Software Foundation Copyright (C) 2002, 2006, 2007 Free Software Foundation
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -83,7 +83,7 @@ public abstract class CharsetProvider ...@@ -83,7 +83,7 @@ public abstract class CharsetProvider
* @return the iterator * @return the iterator
* @see Charset#availableCharsets() * @see Charset#availableCharsets()
*/ */
public abstract Iterator charsets(); public abstract Iterator<Charset> charsets();
/** /**
* Returns the named charset, by canonical name or alias. * Returns the named charset, by canonical name or alias.
......
/* Collator.java -- Perform locale dependent String comparisons. /* Collator.java -- Perform locale dependent String comparisons.
Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -68,11 +68,7 @@ import java.util.ResourceBundle; ...@@ -68,11 +68,7 @@ import java.util.ResourceBundle;
* @author Aaron M. Renn (arenn@urbanophile.com) * @author Aaron M. Renn (arenn@urbanophile.com)
* @date March 18, 1999 * @date March 18, 1999
*/ */
/* Written using "Java Class Libraries", 2nd edition, plus online public abstract class Collator implements Comparator<Object>, Cloneable
* API docs for JDK 1.2 from http://www.javasoft.com.
* Status: Mostly complete, but parts stubbed out. Look for FIXME.
*/
public abstract class Collator implements Comparator, Cloneable
{ {
/** /**
* This constant is a strength value which indicates that only primary * This constant is a strength value which indicates that only primary
...@@ -292,7 +288,7 @@ public abstract class Collator implements Comparator, Cloneable ...@@ -292,7 +288,7 @@ public abstract class Collator implements Comparator, Cloneable
* specified locale. If no <code>Collator</code> exists for the desired * specified locale. If no <code>Collator</code> exists for the desired
* locale, a <code>Collator</code> for the default locale will be returned. * locale, a <code>Collator</code> for the default locale will be returned.
* *
* @param loc The desired localed to load a <code>Collator</code> for. * @param loc The desired locale to load a <code>Collator</code> for.
* *
* @return A <code>Collator</code> for the requested locale * @return A <code>Collator</code> for the requested locale
*/ */
......
/* LogManager.java -- a class for maintaining Loggers and managing /* LogManager.java -- a class for maintaining Loggers and managing
configuration properties configuration properties
Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc. Copyright (C) 2002, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -129,7 +129,7 @@ public class LogManager ...@@ -129,7 +129,7 @@ public class LogManager
* The registered named loggers; maps the name of a Logger to * The registered named loggers; maps the name of a Logger to
* a WeakReference to it. * a WeakReference to it.
*/ */
private Map loggers; private Map<String, WeakReference<Logger>> loggers;
/** /**
* The properties for the logging framework which have been * The properties for the logging framework which have been
...@@ -269,7 +269,7 @@ public class LogManager ...@@ -269,7 +269,7 @@ public class LogManager
*/ */
name = logger.getName(); name = logger.getName();
ref = (WeakReference) loggers.get(name); ref = loggers.get(name);
if (ref != null) if (ref != null)
{ {
if (ref.get() != null) if (ref.get() != null)
...@@ -286,7 +286,7 @@ public class LogManager ...@@ -286,7 +286,7 @@ public class LogManager
checkAccess(); checkAccess();
Logger parent = findAncestor(logger); Logger parent = findAncestor(logger);
loggers.put(name, new WeakReference(logger)); loggers.put(name, new WeakReference<Logger>(logger));
if (parent != logger.getParent()) if (parent != logger.getParent())
logger.setParent(parent); logger.setParent(parent);
...@@ -362,15 +362,13 @@ public class LogManager ...@@ -362,15 +362,13 @@ public class LogManager
int bestNameLength = 0; int bestNameLength = 0;
Logger cand; Logger cand;
String candName;
int candNameLength; int candNameLength;
if (child == Logger.root) if (child == Logger.root)
return null; return null;
for (Iterator iter = loggers.keySet().iterator(); iter.hasNext();) for (String candName : loggers.keySet())
{ {
candName = (String) iter.next();
candNameLength = candName.length(); candNameLength = candName.length();
if (candNameLength > bestNameLength if (candNameLength > bestNameLength
...@@ -378,7 +376,7 @@ public class LogManager ...@@ -378,7 +376,7 @@ public class LogManager
&& childName.startsWith(candName) && childName.startsWith(candName)
&& childName.charAt(candNameLength) == '.') && childName.charAt(candNameLength) == '.')
{ {
cand = (Logger) ((WeakReference) loggers.get(candName)).get(); cand = loggers.get(candName).get();
if ((cand == null) || (cand == child)) if ((cand == null) || (cand == child))
continue; continue;
...@@ -403,14 +401,14 @@ public class LogManager ...@@ -403,14 +401,14 @@ public class LogManager
*/ */
public synchronized Logger getLogger(String name) public synchronized Logger getLogger(String name)
{ {
WeakReference ref; WeakReference<Logger> ref;
/* Throw a NullPointerException if name is null. */ /* Throw a NullPointerException if name is null. */
name.getClass(); name.getClass();
ref = (WeakReference) loggers.get(name); ref = loggers.get(name);
if (ref != null) if (ref != null)
return (Logger) ref.get(); return ref.get();
else else
return null; return null;
} }
...@@ -423,7 +421,7 @@ public class LogManager ...@@ -423,7 +421,7 @@ public class LogManager
* @return an Enumeration with the names of the currently * @return an Enumeration with the names of the currently
* registered Loggers. * registered Loggers.
*/ */
public synchronized Enumeration getLoggerNames() public synchronized Enumeration<String> getLoggerNames()
{ {
return Collections.enumeration(loggers.keySet()); return Collections.enumeration(loggers.keySet());
} }
...@@ -446,16 +444,16 @@ public class LogManager ...@@ -446,16 +444,16 @@ public class LogManager
properties = new Properties(); properties = new Properties();
Iterator iter = loggers.values().iterator(); Iterator<WeakReference<Logger>> iter = loggers.values().iterator();
while (iter.hasNext()) while (iter.hasNext())
{ {
WeakReference ref; WeakReference<Logger> ref;
Logger logger; Logger logger;
ref = (WeakReference) iter.next(); ref = iter.next();
if (ref != null) if (ref != null)
{ {
logger = (Logger) ref.get(); logger = ref.get();
if (logger == null) if (logger == null)
iter.remove(); iter.remove();
...@@ -710,7 +708,11 @@ public class LogManager ...@@ -710,7 +708,11 @@ public class LogManager
{ {
try try
{ {
String value = getLogManager().getProperty(propertyName);
if (value != null)
return Level.parse(getLogManager().getProperty(propertyName)); return Level.parse(getLogManager().getProperty(propertyName));
else
return defaultValue;
} }
catch (Exception ex) catch (Exception ex)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment