aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java
diff options
context:
space:
mode:
authorMatthias Klose <doko@gcc.gnu.org>2008-06-28 13:29:13 +0000
committerMatthias Klose <doko@gcc.gnu.org>2008-06-28 13:29:13 +0000
commite0441a5bfb29083a532307ba2b1fd6d6d13944ba (patch)
tree602cd7aa7c947386134690d8e0f6b53abcdeacb9 /libjava/classpath/java
parent15c151967dd1cde61b79d26374f608f63a29d411 (diff)
downloadgcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.zip
gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.gz
gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.bz2
Import GNU Classpath (classpath-0_97_2-release).
libjava/ 2008-06-28 Matthias Klose <doko@ubuntu.com> Import GNU Classpath (classpath-0_97_2-release). * Regenerate class and header files. * Regenerate auto* files. * gcj/javaprims.h: Define jobjectRefType. * jni.cc (_Jv_JNI_GetObjectRefType): New (stub only). (_Jv_JNIFunctions): Initialize GetObjectRefType. * gnu/classpath/jdwp/VMVirtualMachine.java, java/security/VMSecureRandom.java: Merge from classpath. * HACKING: Fix typo. * ChangeLog-2007: New file. * configure.ac: Set JAVAC, pass --disable-regen-headers to classpath. libjava/classpath/ 2008-06-28 Matthias Klose <doko@ubuntu.com> * m4/ac_prog_javac.m4: Disable check for JAVAC, when not configured with --enable-java-maintainer-mode. * aclocal.m4, configure: Regenerate. * native/jni/gstreamer-peer/Makefile.am: Do not link with libclasspathnative. * native/jni/gstreamer-peer/Makefile.in: Regenerate. * tools/Makefile.am, lib/Makefile.am: Use JAVAC for setting JCOMPILER, drop flags not understood by gcj. From-SVN: r137223
Diffstat (limited to 'libjava/classpath/java')
-rw-r--r--libjava/classpath/java/awt/AWTKeyStroke.java6
-rw-r--r--libjava/classpath/java/awt/Container.java6
-rw-r--r--libjava/classpath/java/awt/DefaultKeyboardFocusManager.java2
-rw-r--r--libjava/classpath/java/awt/Desktop.java4
-rw-r--r--libjava/classpath/java/awt/Font.java21
-rw-r--r--libjava/classpath/java/awt/GridBagLayout.java29
-rw-r--r--libjava/classpath/java/awt/LightweightDispatcher.java3
-rw-r--r--libjava/classpath/java/awt/MenuShortcut.java2
-rw-r--r--libjava/classpath/java/awt/color/ICC_Profile.java13
-rw-r--r--libjava/classpath/java/awt/dnd/DragGestureRecognizer.java2
-rw-r--r--libjava/classpath/java/awt/event/MouseEvent.java33
-rw-r--r--libjava/classpath/java/awt/font/LineBreakMeasurer.java2
-rw-r--r--libjava/classpath/java/awt/font/TextMeasurer.java1
-rw-r--r--libjava/classpath/java/awt/geom/Arc2D.java2
-rw-r--r--libjava/classpath/java/awt/geom/CubicCurve2D.java8
-rw-r--r--libjava/classpath/java/awt/geom/QuadCurve2D.java8
-rw-r--r--libjava/classpath/java/awt/im/InputContext.java5
-rw-r--r--libjava/classpath/java/awt/image/AffineTransformOp.java2
-rw-r--r--libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java4
-rw-r--r--libjava/classpath/java/awt/image/BufferedImage.java2
-rw-r--r--libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java29
-rw-r--r--libjava/classpath/java/awt/image/RGBImageFilter.java2
-rw-r--r--libjava/classpath/java/awt/image/Raster.java2
-rw-r--r--libjava/classpath/java/beans/Beans.java2
-rw-r--r--libjava/classpath/java/beans/DefaultPersistenceDelegate.java4
-rw-r--r--libjava/classpath/java/beans/Encoder.java2
-rw-r--r--libjava/classpath/java/beans/EventHandler.java14
-rw-r--r--libjava/classpath/java/beans/PropertyChangeSupport.java4
-rw-r--r--libjava/classpath/java/beans/VetoableChangeSupport.java4
-rw-r--r--libjava/classpath/java/beans/XMLDecoder.java2
-rw-r--r--libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java9
-rw-r--r--libjava/classpath/java/beans/beancontext/BeanContextSupport.java4
-rw-r--r--libjava/classpath/java/io/BufferedReader.java10
-rw-r--r--libjava/classpath/java/io/CharArrayWriter.java4
-rw-r--r--libjava/classpath/java/io/DataInputStream.java54
-rw-r--r--libjava/classpath/java/io/DataOutputStream.java84
-rw-r--r--libjava/classpath/java/io/File.java67
-rw-r--r--libjava/classpath/java/io/FileOutputStream.java2
-rw-r--r--libjava/classpath/java/io/ObjectInputStream.java15
-rw-r--r--libjava/classpath/java/io/ObjectOutputStream.java22
-rw-r--r--libjava/classpath/java/io/ObjectStreamClass.java6
-rw-r--r--libjava/classpath/java/io/OutputStreamWriter.java114
-rw-r--r--libjava/classpath/java/io/PipedInputStream.java38
-rw-r--r--libjava/classpath/java/io/PrintStream.java15
-rw-r--r--libjava/classpath/java/lang/Class.java8
-rw-r--r--libjava/classpath/java/lang/Double.java36
-rw-r--r--libjava/classpath/java/lang/Float.java36
-rw-r--r--libjava/classpath/java/lang/Integer.java13
-rw-r--r--libjava/classpath/java/lang/Long.java2
-rw-r--r--libjava/classpath/java/lang/StackTraceElement.java2
-rw-r--r--libjava/classpath/java/lang/String.java200
-rw-r--r--libjava/classpath/java/lang/System.java2
-rw-r--r--libjava/classpath/java/lang/Throwable.java4
-rw-r--r--libjava/classpath/java/lang/management/ThreadInfo.java128
-rw-r--r--libjava/classpath/java/lang/reflect/Array.java14
-rw-r--r--libjava/classpath/java/lang/reflect/Proxy.java14
-rw-r--r--libjava/classpath/java/math/BigInteger.java4
-rw-r--r--libjava/classpath/java/net/DatagramSocket.java8
-rw-r--r--libjava/classpath/java/net/ResolverCache.java6
-rw-r--r--libjava/classpath/java/net/ServerSocket.java4
-rw-r--r--libjava/classpath/java/net/Socket.java8
-rw-r--r--libjava/classpath/java/net/URI.java21
-rw-r--r--libjava/classpath/java/net/URLClassLoader.java4
-rw-r--r--libjava/classpath/java/net/URLEncoder.java2
-rw-r--r--libjava/classpath/java/nio/charset/Charset.java2
-rw-r--r--libjava/classpath/java/nio/charset/CoderResult.java2
-rw-r--r--libjava/classpath/java/security/SecureClassLoader.java7
-rw-r--r--libjava/classpath/java/security/Security.java2
-rw-r--r--libjava/classpath/java/security/cert/CertificateFactory.java1
-rw-r--r--libjava/classpath/java/security/spec/RSAKeyGenParameterSpec.java4
-rw-r--r--libjava/classpath/java/text/ChoiceFormat.java8
-rw-r--r--libjava/classpath/java/text/CollationElementIterator.java21
-rw-r--r--libjava/classpath/java/text/DecimalFormat.java18
-rw-r--r--libjava/classpath/java/text/MessageFormat.java4
-rw-r--r--libjava/classpath/java/text/RuleBasedCollator.java11
-rw-r--r--libjava/classpath/java/text/SimpleDateFormat.java16
-rw-r--r--libjava/classpath/java/util/AbstractMap.java2
-rw-r--r--libjava/classpath/java/util/Calendar.java8
-rw-r--r--libjava/classpath/java/util/Collections.java4
-rw-r--r--libjava/classpath/java/util/Date.java2
-rw-r--r--libjava/classpath/java/util/Formatter.java4
-rw-r--r--libjava/classpath/java/util/Hashtable.java10
-rw-r--r--libjava/classpath/java/util/LinkedHashSet.java4
-rw-r--r--libjava/classpath/java/util/Locale.java20
-rw-r--r--libjava/classpath/java/util/concurrent/CopyOnWriteArrayList.java1015
-rw-r--r--libjava/classpath/java/util/jar/Manifest.java2
-rw-r--r--libjava/classpath/java/util/logging/Logger.java1624
-rw-r--r--libjava/classpath/java/util/zip/ZipEntry.java2
88 files changed, 2582 insertions, 1391 deletions
diff --git a/libjava/classpath/java/awt/AWTKeyStroke.java b/libjava/classpath/java/awt/AWTKeyStroke.java
index 0fc4428..378e4eb 100644
--- a/libjava/classpath/java/awt/AWTKeyStroke.java
+++ b/libjava/classpath/java/awt/AWTKeyStroke.java
@@ -260,7 +260,7 @@ public class AWTKeyStroke implements Serializable
c.setAccessible(true);
// Create a new instance, to make sure that we can, and
// to cause any ClassCastException.
- AWTKeyStroke dummy = (AWTKeyStroke) c.newInstance(null);
+ AWTKeyStroke dummy = (AWTKeyStroke) c.newInstance();
return c;
}
});
@@ -632,7 +632,7 @@ public class AWTKeyStroke implements Serializable
else
try
{
- stroke = (AWTKeyStroke) c.newInstance(null);
+ stroke = (AWTKeyStroke) c.newInstance();
stroke.keyChar = keyChar;
stroke.keyCode = keyCode;
stroke.modifiers = modifiers;
@@ -643,7 +643,7 @@ public class AWTKeyStroke implements Serializable
throw (Error) new InternalError().initCause(e);
}
// Check level 1 cache.
- AWTKeyStroke cached = (AWTKeyStroke) cache.get(stroke);
+ AWTKeyStroke cached = cache.get(stroke);
if (cached == null)
cache.put(stroke, stroke);
else
diff --git a/libjava/classpath/java/awt/Container.java b/libjava/classpath/java/awt/Container.java
index e7622f2..1e50040 100644
--- a/libjava/classpath/java/awt/Container.java
+++ b/libjava/classpath/java/awt/Container.java
@@ -1322,10 +1322,10 @@ public class Container extends Component
while (true)
{
if (comp == null)
- return false;
- if (comp == this)
- return true;
+ return false;
comp = comp.getParent();
+ if (comp == this)
+ return true;
}
}
}
diff --git a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
index 9fea99b..325e3ac 100644
--- a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
+++ b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
@@ -350,7 +350,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
while (i.hasNext ())
{
KeyEventPostProcessor processor = (KeyEventPostProcessor) i.next ();
- if (processor.postProcessKeyEvent ((KeyEvent) e))
+ if (processor.postProcessKeyEvent (e))
return true;
}
diff --git a/libjava/classpath/java/awt/Desktop.java b/libjava/classpath/java/awt/Desktop.java
index 8010464..227b8b1 100644
--- a/libjava/classpath/java/awt/Desktop.java
+++ b/libjava/classpath/java/awt/Desktop.java
@@ -120,7 +120,7 @@ public class Desktop
}
/**
- * Returns an istance of the Desktop Class.
+ * Returns an instance of the Desktop Class.
*
* If this implementation does not support Desktop, an
* UnsupportedOperationException will be thrown.
@@ -155,7 +155,7 @@ public class Desktop
* @return true if this class is supported on the current platform;
* false otherwise
*/
- private static boolean isDesktopSupported()
+ public static boolean isDesktopSupported()
{
if (GraphicsEnvironment.isHeadless())
return false;
diff --git a/libjava/classpath/java/awt/Font.java b/libjava/classpath/java/awt/Font.java
index d6892a6..4e6e6bd 100644
--- a/libjava/classpath/java/awt/Font.java
+++ b/libjava/classpath/java/awt/Font.java
@@ -229,6 +229,11 @@ public class Font implements Serializable
// The ClasspathToolkit-provided peer which implements this font
private transient ClasspathFontPeer peer;
+ /**
+ * The cached hashcode. A value of 0 (default initialized) means that the
+ * hashcode is not computed yet.
+ */
+ private transient int hashCode;
/**
* Creates a <code>Font</code> object from the specified string, which
@@ -1318,7 +1323,21 @@ public class Font implements Serializable
*/
public int hashCode()
{
- return this.toString().hashCode();
+ // We cache the hashcode. This makes sense, because the font wouldn't
+ // change the relevant properties.
+ if (hashCode == 0)
+ {
+ hashCode = getName().hashCode() ^ getTransform().hashCode() ^ getSize()
+ ^ getStyle();
+ // In the rare case when the above yields 0, we set this to some other
+ // value to avoid recomputing over and over again. This is still
+ // conform to the specification of hashCode().
+ if (hashCode == 0)
+ {
+ hashCode = -1;
+ }
+ }
+ return hashCode;
}
diff --git a/libjava/classpath/java/awt/GridBagLayout.java b/libjava/classpath/java/awt/GridBagLayout.java
index 0415c7b..d016fd3 100644
--- a/libjava/classpath/java/awt/GridBagLayout.java
+++ b/libjava/classpath/java/awt/GridBagLayout.java
@@ -211,12 +211,12 @@ public class GridBagLayout
protected GridBagConstraints lookupConstraints (Component component)
{
- GridBagConstraints result = (GridBagConstraints) comptable.get (component);
+ GridBagConstraints result = comptable.get (component);
if (result == null)
{
setConstraints (component, defaultConstraints);
- result = (GridBagConstraints) comptable.get (component);
+ result = comptable.get (component);
}
return result;
@@ -224,8 +224,7 @@ public class GridBagLayout
private GridBagConstraints lookupInternalConstraints (Component component)
{
- GridBagConstraints result =
- (GridBagConstraints) internalcomptable.get (component);
+ GridBagConstraints result = internalcomptable.get (component);
if (result == null)
{
@@ -562,7 +561,7 @@ public class GridBagLayout
x = 0;
else
{
- Component lastComponent = (Component) lastInRow.get(new Integer(constraints.gridy));
+ Component lastComponent = lastInRow.get(new Integer(constraints.gridy));
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
x = lastConstraints.gridx + Math.max(1, lastConstraints.gridwidth);
}
@@ -573,7 +572,7 @@ public class GridBagLayout
{
if (lastInRow.containsKey(new Integer(y)))
{
- Component lastComponent = (Component) lastInRow.get(new Integer(y));
+ Component lastComponent = lastInRow.get(new Integer(y));
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
x = Math.max (x,
lastConstraints.gridx + Math.max(1, lastConstraints.gridwidth));
@@ -595,7 +594,7 @@ public class GridBagLayout
}
else
{
- Component lastComponent = (Component)lastInCol.get(new Integer(constraints.gridx));
+ Component lastComponent = lastInCol.get(new Integer(constraints.gridx));
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
y = lastConstraints.gridy + Math.max(1, lastConstraints.gridheight);
}
@@ -606,7 +605,7 @@ public class GridBagLayout
{
if (lastInCol.containsKey(new Integer(x)))
{
- Component lastComponent = (Component) lastInCol.get(new Integer(x));
+ Component lastComponent = lastInCol.get(new Integer(x));
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
y = Math.max (y,
lastConstraints.gridy + Math.max(1, lastConstraints.gridheight));
@@ -636,7 +635,7 @@ public class GridBagLayout
{
if(lastInRow.containsKey(new Integer(y)))
{
- Component lastComponent = (Component) lastInRow.get(new Integer(y));
+ Component lastComponent = lastInRow.get(new Integer(y));
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
if (constraints.gridx > lastConstraints.gridx)
{
@@ -653,7 +652,7 @@ public class GridBagLayout
{
if(lastInCol.containsKey(new Integer(x)))
{
- Component lastComponent = (Component) lastInCol.get(new Integer(x));
+ Component lastComponent = lastInCol.get(new Integer(x));
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
if (constraints.gridy > lastConstraints.gridy)
{
@@ -707,7 +706,7 @@ public class GridBagLayout
{
if (lastInRow.containsKey(new Integer(y)))
{
- Component lastComponent = (Component) lastInRow.get(new Integer(y));
+ Component lastComponent = lastInRow.get(new Integer(y));
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
if (lastConstraints.gridwidth == GridBagConstraints.RELATIVE)
@@ -742,7 +741,7 @@ public class GridBagLayout
{
if (lastInCol.containsKey(new Integer(x)))
{
- Component lastComponent = (Component) lastInRow.get(new Integer(x));
+ Component lastComponent = lastInRow.get(new Integer(x));
if (lastComponent != null)
{
GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
@@ -804,7 +803,7 @@ public class GridBagLayout
// STEP 4: Determine sizes and weights for rows.
for (int i = 0; i < sortedByHeight.size(); i++)
{
- Component component = (Component) sortedByHeight.get(i);
+ Component component = sortedByHeight.get(i);
// If component is not visible we dont have to care about it.
if (!component.isVisible())
@@ -904,7 +903,7 @@ public class GridBagLayout
int i = 0;
if (list.size() > 0)
{
- GridBagConstraints gbc = lookupInternalConstraints((Component) list.get(i));
+ GridBagConstraints gbc = lookupInternalConstraints(list.get(i));
int otherspan = sortByWidth ?
gbc.gridwidth :
gbc.gridheight;
@@ -915,7 +914,7 @@ public class GridBagLayout
i++;
if (i < list.size())
{
- gbc = lookupInternalConstraints((Component) list.get(i));
+ gbc = lookupInternalConstraints(list.get(i));
otherspan = sortByWidth ?
gbc.gridwidth :
gbc.gridheight;
diff --git a/libjava/classpath/java/awt/LightweightDispatcher.java b/libjava/classpath/java/awt/LightweightDispatcher.java
index 04196bd..39bdb88 100644
--- a/libjava/classpath/java/awt/LightweightDispatcher.java
+++ b/libjava/classpath/java/awt/LightweightDispatcher.java
@@ -286,7 +286,8 @@ final class LightweightDispatcher
private void redispatch(MouseEvent ev, Component target, int id)
{
Component source = ev.getComponent();
- if (target != null)
+ assert target != null;
+ if (target.isShowing())
{
// Translate coordinates.
int x = ev.getX();
diff --git a/libjava/classpath/java/awt/MenuShortcut.java b/libjava/classpath/java/awt/MenuShortcut.java
index 259cbf1..5216d34 100644
--- a/libjava/classpath/java/awt/MenuShortcut.java
+++ b/libjava/classpath/java/awt/MenuShortcut.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package java.awt;
-import java.awt.event.KeyEvent;
-
/**
* This class implements a keyboard accelerator for a menu item.
*
diff --git a/libjava/classpath/java/awt/color/ICC_Profile.java b/libjava/classpath/java/awt/color/ICC_Profile.java
index 1072cd6..e2efb3a 100644
--- a/libjava/classpath/java/awt/color/ICC_Profile.java
+++ b/libjava/classpath/java/awt/color/ICC_Profile.java
@@ -426,10 +426,15 @@ public class ICC_Profile implements Serializable
System.arraycopy(headerData, 0, data, 0, ProfileHeader.HEADERSIZE);
// read the rest
- if (in.read(data, ProfileHeader.HEADERSIZE,
- header.getSize() - ProfileHeader.HEADERSIZE) != header.getSize()
- - ProfileHeader.HEADERSIZE)
- throw new IOException("Incorrect profile size");
+ int totalBytes = header.getSize() - ProfileHeader.HEADERSIZE;
+ int bytesLeft = totalBytes;
+ while (bytesLeft > 0)
+ {
+ int read = in.read(data,
+ ProfileHeader.HEADERSIZE + (totalBytes - bytesLeft),
+ bytesLeft);
+ bytesLeft -= read;
+ }
return getInstance(data);
}
diff --git a/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java b/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
index 3973e52..fb37b4f 100644
--- a/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
+++ b/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
@@ -124,7 +124,7 @@ public abstract class DragGestureRecognizer implements Serializable
public InputEvent getTriggerEvent()
{
- return events.size() > 0 ? (InputEvent) events.get(0) : null;
+ return events.size() > 0 ? events.get(0) : null;
}
/**
diff --git a/libjava/classpath/java/awt/event/MouseEvent.java b/libjava/classpath/java/awt/event/MouseEvent.java
index ad777e8..0ca8336 100644
--- a/libjava/classpath/java/awt/event/MouseEvent.java
+++ b/libjava/classpath/java/awt/event/MouseEvent.java
@@ -221,37 +221,8 @@ public class MouseEvent extends InputEvent
int x, int y, int clickCount, boolean popupTrigger,
int button)
{
- super(source, id, when, modifiers);
-
- this.x = x;
- this.y = y;
- this.clickCount = clickCount;
- this.popupTrigger = popupTrigger;
- this.button = button;
- if (button < NOBUTTON || button > BUTTON3)
- throw new IllegalArgumentException();
- if ((modifiers & EventModifier.OLD_MASK) != 0)
- {
- if ((modifiers & BUTTON1_MASK) != 0)
- this.button = BUTTON1;
- else if ((modifiers & BUTTON2_MASK) != 0)
- this.button = BUTTON2;
- else if ((modifiers & BUTTON3_MASK) != 0)
- this.button = BUTTON3;
- }
- // clear the mouse button modifier masks if this is a button
- // release event.
- if (id == MOUSE_RELEASED)
- this.modifiersEx &= ~(BUTTON1_DOWN_MASK
- | BUTTON2_DOWN_MASK
- | BUTTON3_DOWN_MASK);
-
- if (source != null)
- {
- Point screenLoc = source.getLocationOnScreen();
- absX = screenLoc.x + x;
- absY = screenLoc.y + y;
- }
+ this(source, id, when, modifiers, x, y, 0, 0, clickCount, popupTrigger,
+ button);
}
/**
diff --git a/libjava/classpath/java/awt/font/LineBreakMeasurer.java b/libjava/classpath/java/awt/font/LineBreakMeasurer.java
index 816c774..278bc84 100644
--- a/libjava/classpath/java/awt/font/LineBreakMeasurer.java
+++ b/libjava/classpath/java/awt/font/LineBreakMeasurer.java
@@ -39,9 +39,7 @@ exception statement from your version. */
package java.awt.font;
import java.text.AttributedCharacterIterator;
-import java.text.AttributedString;
import java.text.BreakIterator;
-import java.awt.Shape;
public final class LineBreakMeasurer
{
diff --git a/libjava/classpath/java/awt/font/TextMeasurer.java b/libjava/classpath/java/awt/font/TextMeasurer.java
index 00cab8a..f4430bf 100644
--- a/libjava/classpath/java/awt/font/TextMeasurer.java
+++ b/libjava/classpath/java/awt/font/TextMeasurer.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package java.awt.font;
import java.text.AttributedCharacterIterator;
-import java.text.AttributedString;
import java.awt.Shape;
/**
diff --git a/libjava/classpath/java/awt/geom/Arc2D.java b/libjava/classpath/java/awt/geom/Arc2D.java
index 8d5b01c..eb9a160 100644
--- a/libjava/classpath/java/awt/geom/Arc2D.java
+++ b/libjava/classpath/java/awt/geom/Arc2D.java
@@ -1279,7 +1279,7 @@ public abstract class Arc2D extends RectangularShape
width = (float) r.getWidth();
height = (float) r.getHeight();
this.start = start;
- this.extent = (float) extent;
+ this.extent = extent;
}
/**
diff --git a/libjava/classpath/java/awt/geom/CubicCurve2D.java b/libjava/classpath/java/awt/geom/CubicCurve2D.java
index 50c3811..d0d5598 100644
--- a/libjava/classpath/java/awt/geom/CubicCurve2D.java
+++ b/libjava/classpath/java/awt/geom/CubicCurve2D.java
@@ -1714,10 +1714,10 @@ public abstract class CubicCurve2D implements Shape, Cloneable
*/
public Rectangle2D getBounds2D()
{
- float nx1 = (float) Math.min(Math.min(x1, ctrlx1), Math.min(ctrlx2, x2));
- float ny1 = (float) Math.min(Math.min(y1, ctrly1), Math.min(ctrly2, y2));
- float nx2 = (float) Math.max(Math.max(x1, ctrlx1), Math.max(ctrlx2, x2));
- float ny2 = (float) Math.max(Math.max(y1, ctrly1), Math.max(ctrly2, y2));
+ float nx1 = Math.min(Math.min(x1, ctrlx1), Math.min(ctrlx2, x2));
+ float ny1 = Math.min(Math.min(y1, ctrly1), Math.min(ctrly2, y2));
+ float nx2 = Math.max(Math.max(x1, ctrlx1), Math.max(ctrlx2, x2));
+ float ny2 = Math.max(Math.max(y1, ctrly1), Math.max(ctrly2, y2));
return new Rectangle2D.Float(nx1, ny1, nx2 - nx1, ny2 - ny1);
}
}
diff --git a/libjava/classpath/java/awt/geom/QuadCurve2D.java b/libjava/classpath/java/awt/geom/QuadCurve2D.java
index 41021db..d247c79 100644
--- a/libjava/classpath/java/awt/geom/QuadCurve2D.java
+++ b/libjava/classpath/java/awt/geom/QuadCurve2D.java
@@ -1457,10 +1457,10 @@ public abstract class QuadCurve2D implements Shape, Cloneable
*/
public Rectangle2D getBounds2D()
{
- float nx1 = (float) Math.min(Math.min(x1, ctrlx), x2);
- float ny1 = (float) Math.min(Math.min(y1, ctrly), y2);
- float nx2 = (float) Math.max(Math.max(x1, ctrlx), x2);
- float ny2 = (float) Math.max(Math.max(y1, ctrly), y2);
+ float nx1 = Math.min(Math.min(x1, ctrlx), x2);
+ float ny1 = Math.min(Math.min(y1, ctrly), y2);
+ float nx2 = Math.max(Math.max(x1, ctrlx), x2);
+ float ny2 = Math.max(Math.max(y1, ctrly), y2);
return new Rectangle2D.Float(nx1, ny1, nx2 - nx1, ny2 - ny1);
}
}
diff --git a/libjava/classpath/java/awt/im/InputContext.java b/libjava/classpath/java/awt/im/InputContext.java
index c819932..c2e09b6 100644
--- a/libjava/classpath/java/awt/im/InputContext.java
+++ b/libjava/classpath/java/awt/im/InputContext.java
@@ -216,12 +216,11 @@ public class InputContext
recent.put(locale, im);
return true;
}
- InputMethod next = (InputMethod) recent.get(locale);
- outer:
+ InputMethod next = recent.get(locale);
if (next != null)
for (int i = 0, limit = descriptors.size(); i < limit; i++)
{
- InputMethodDescriptor d = (InputMethodDescriptor) descriptors.get(i);
+ InputMethodDescriptor d = descriptors.get(i);
Locale[] list;
try
{
diff --git a/libjava/classpath/java/awt/image/AffineTransformOp.java b/libjava/classpath/java/awt/image/AffineTransformOp.java
index 849c5b0..df9db7d 100644
--- a/libjava/classpath/java/awt/image/AffineTransformOp.java
+++ b/libjava/classpath/java/awt/image/AffineTransformOp.java
@@ -188,7 +188,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
if (dst == null)
dst = createCompatibleDestImage(src, null);
- Graphics2D gr = (Graphics2D) dst.createGraphics();
+ Graphics2D gr = dst.createGraphics();
gr.setRenderingHints(hints);
gr.drawImage(src, transform, null);
return dst;
diff --git a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
index 44d5cec..491a2f5 100644
--- a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
+++ b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
@@ -158,7 +158,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
* @param srcOffset - Starting offset into the source pixel data array.
* @param srcScansize - Source array scanline size.
* @param rx,ry - Scaling factor.
- * @param dstScansize - Destination array scanline size.
+ * @param destScansize - Destination array scanline size.
*/
private byte[] averagePixels(int srcx, int srcy, int srcw, int srch,
ColorModel model, byte[] srcPixels,
@@ -218,7 +218,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
* @param srcOffset - Starting offset into the source pixel data array.
* @param srcScansize - Source array scanline size.
* @param rx,ry - Scaling factor.
- * @param dstScansize - Destination array scanline size.
+ * @param destScansize - Destination array scanline size.
*/
private int[] averagePixels(int srcx, int srcy, int srcw, int srch,
ColorModel model, int[] srcPixels,
diff --git a/libjava/classpath/java/awt/image/BufferedImage.java b/libjava/classpath/java/awt/image/BufferedImage.java
index c987946..78623cc 100644
--- a/libjava/classpath/java/awt/image/BufferedImage.java
+++ b/libjava/classpath/java/awt/image/BufferedImage.java
@@ -41,8 +41,6 @@ package java.awt.image;
import gnu.java.awt.Buffers;
import gnu.java.awt.ClasspathGraphicsEnvironment;
import gnu.java.awt.ComponentDataBlitOp;
-import gnu.java.awt.peer.gtk.CairoSurface;
-
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
diff --git a/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java b/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java
index 4c5c436..3a0d415 100644
--- a/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java
+++ b/libjava/classpath/java/awt/image/PixelInterleavedSampleModel.java
@@ -69,9 +69,34 @@ public class PixelInterleavedSampleModel
*/
public SampleModel createCompatibleSampleModel(int width, int height)
{
+ // Find minimum band offset.
+ int minBandoff = bandOffsets[0];
+ int numBands = bandOffsets.length;
+ for (int i = 1; i < numBands; i++)
+ {
+ if (bandOffsets[i] < minBandoff)
+ {
+ minBandoff = bandOffsets[i];
+ }
+ }
+ // Adjust band offsets so that minimum offset is at 0.
+ int[] bandOff;
+ if (minBandoff > 0)
+ {
+ bandOff = new int[numBands];
+ for (int i = 0; i < numBands; i++)
+ {
+ bandOff[i] = bandOffsets[i] - minBandoff;
+ }
+ }
+ else
+ {
+ bandOff = bandOffsets;
+ }
+ // Adjust scanline stride for new width.
return new PixelInterleavedSampleModel(dataType, width, height,
- pixelStride, scanlineStride,
- bandOffsets);
+ pixelStride, pixelStride * width,
+ bandOff);
}
diff --git a/libjava/classpath/java/awt/image/RGBImageFilter.java b/libjava/classpath/java/awt/image/RGBImageFilter.java
index c777fec..3cd1423 100644
--- a/libjava/classpath/java/awt/image/RGBImageFilter.java
+++ b/libjava/classpath/java/awt/image/RGBImageFilter.java
@@ -245,7 +245,7 @@ public abstract class RGBImageFilter extends ImageFilter
{
for (int xp = 0; xp < w; xp++)
{
- filtered[xp] = model.getRGB((pixels[index] & 0xff));
+ filtered[xp] = model.getRGB((pixels[index]));
index++;
}
index += scansize - w;
diff --git a/libjava/classpath/java/awt/image/Raster.java b/libjava/classpath/java/awt/image/Raster.java
index d63e156..fb0950d 100644
--- a/libjava/classpath/java/awt/image/Raster.java
+++ b/libjava/classpath/java/awt/image/Raster.java
@@ -302,7 +302,7 @@ public class Raster
Point location)
{
SampleModel sm = new ComponentSampleModel(dataBuffer.getDataType(),
- w, h, scanlineStride, pixelStride, bandOffsets);
+ w, h, pixelStride, scanlineStride, bandOffsets);
return createWritableRaster(sm, dataBuffer, location);
}
diff --git a/libjava/classpath/java/beans/Beans.java b/libjava/classpath/java/beans/Beans.java
index b3b0a42..2f6e0a9 100644
--- a/libjava/classpath/java/beans/Beans.java
+++ b/libjava/classpath/java/beans/Beans.java
@@ -309,7 +309,7 @@ public class Beans
* Objects.
*
* @param bean the Bean to cast.
- * @param newClass the Class to cast it to.
+ * @param newBeanClass the Class to cast it to.
*
* @return whether the Bean can be cast to the class type
* in question.
diff --git a/libjava/classpath/java/beans/DefaultPersistenceDelegate.java b/libjava/classpath/java/beans/DefaultPersistenceDelegate.java
index 08f6174..c4328e0 100644
--- a/libjava/classpath/java/beans/DefaultPersistenceDelegate.java
+++ b/libjava/classpath/java/beans/DefaultPersistenceDelegate.java
@@ -127,7 +127,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate
{
Method readMethod = propertyDescs[i].getReadMethod();
- args[i] = readMethod.invoke(oldInstance, null);
+ args[i] = readMethod.invoke(oldInstance);
}
}
}
@@ -186,7 +186,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate
if (readMethod != null && writeMethod != null)
{
- Object oldValue = readMethod.invoke(oldInstance, null);
+ Object oldValue = readMethod.invoke(oldInstance);
if (oldValue != null)
out.writeStatement(new Statement(oldInstance,
diff --git a/libjava/classpath/java/beans/Encoder.java b/libjava/classpath/java/beans/Encoder.java
index cde1735..6dc3627 100644
--- a/libjava/classpath/java/beans/Encoder.java
+++ b/libjava/classpath/java/beans/Encoder.java
@@ -195,7 +195,7 @@ public class Encoder
PersistenceDelegate pd = (PersistenceDelegate) delegates.get(type);
- return (pd != null) ? pd : (PersistenceDelegate) defaultPersistenceDelegate;
+ return (pd != null) ? pd : defaultPersistenceDelegate;
}
/**
diff --git a/libjava/classpath/java/beans/EventHandler.java b/libjava/classpath/java/beans/EventHandler.java
index 318b274..5efbc8d 100644
--- a/libjava/classpath/java/beans/EventHandler.java
+++ b/libjava/classpath/java/beans/EventHandler.java
@@ -173,19 +173,17 @@ public class EventHandler implements InvocationHandler
try
{
// Look for boolean property getter isProperty
- getter = o.getClass().getMethod("is" + capitalize(prop),
- null);
+ getter = o.getClass().getMethod("is" + capitalize(prop));
}
catch (NoSuchMethodException nsme1)
{
try {
// Look for regular property getter getProperty
- getter = o.getClass().getMethod("get" + capitalize(prop),
- null);
+ getter = o.getClass().getMethod("get" + capitalize(prop));
} catch(NoSuchMethodException nsme2) {
try {
// Finally look for a method of the name prop
- getter = o.getClass().getMethod(prop, null);
+ getter = o.getClass().getMethod(prop);
} catch(NoSuchMethodException nsme3) {
// Ok, give up with an intelligent hint for the user.
throw new RuntimeException("Method not called: Could not find a property or method '" + prop
@@ -194,7 +192,7 @@ public class EventHandler implements InvocationHandler
}
}
try {
- Object val = getter.invoke(o, null);
+ Object val = getter.invoke(o);
if (rest != null)
return getProperty(val, rest);
@@ -304,7 +302,7 @@ public class EventHandler implements InvocationHandler
// more specification compliant than the JDK itself because this one will fail in such a case.
try
{
- actionMethod = targetClass.getMethod(action, null);
+ actionMethod = targetClass.getMethod(action);
}
catch(NoSuchMethodException nsme)
{
@@ -342,7 +340,7 @@ public class EventHandler implements InvocationHandler
throw new ArrayIndexOutOfBoundsException(0);
// Invoke target.action(property)
- return actionMethod.invoke(target, null);
+ return actionMethod.invoke(target);
} catch(InvocationTargetException ite) {
throw new RuntimeException(ite.getCause());
} catch(IllegalAccessException iae) {
diff --git a/libjava/classpath/java/beans/PropertyChangeSupport.java b/libjava/classpath/java/beans/PropertyChangeSupport.java
index e944e15..ecadb14 100644
--- a/libjava/classpath/java/beans/PropertyChangeSupport.java
+++ b/libjava/classpath/java/beans/PropertyChangeSupport.java
@@ -346,8 +346,8 @@ public class PropertyChangeSupport implements Serializable
{
if (oldVal != newVal)
firePropertyChange(new PropertyChangeEvent(source, propertyName,
- new Integer(oldVal),
- new Integer(newVal)));
+ Integer.valueOf(oldVal),
+ Integer.valueOf(newVal)));
}
/**
diff --git a/libjava/classpath/java/beans/VetoableChangeSupport.java b/libjava/classpath/java/beans/VetoableChangeSupport.java
index 12051d2..f2b6a1d 100644
--- a/libjava/classpath/java/beans/VetoableChangeSupport.java
+++ b/libjava/classpath/java/beans/VetoableChangeSupport.java
@@ -349,8 +349,8 @@ public class VetoableChangeSupport implements Serializable
{
if (oldVal != newVal)
fireVetoableChange(new PropertyChangeEvent(source, propertyName,
- new Integer(oldVal),
- new Integer(newVal)));
+ Integer.valueOf(oldVal),
+ Integer.valueOf(newVal)));
}
/**
diff --git a/libjava/classpath/java/beans/XMLDecoder.java b/libjava/classpath/java/beans/XMLDecoder.java
index 7618bb8..131cf3b 100644
--- a/libjava/classpath/java/beans/XMLDecoder.java
+++ b/libjava/classpath/java/beans/XMLDecoder.java
@@ -164,7 +164,7 @@ public class XMLDecoder
*
* @param in InputStream to read XML data from.
* @param owner Owner object which can be accessed and modified while parsing.
- * @param exceptionListener ExceptionListener instance to which exception notifications are send.
+ * @param listener ExceptionListener instance to which exception notifications are send.
* @param cl ClassLoader instance that is used for calls to <code>Class.forName(String, boolean, ClassLoader)</code>
* @since 1.5
*/
diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java
index f354ff4..1c27f98 100644
--- a/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java
+++ b/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package java.beans.beancontext;
-import gnu.classpath.NotImplementedException;
-
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -88,11 +86,6 @@ public class BeanContextServicesSupport
private BeanContextServiceProvider provider;
- private BCSSProxyServiceProvider(BeanContextServiceProvider p)
- {
- provider = p;
- }
-
public Iterator getCurrentServiceSelectors (BeanContextServices bcs,
Class serviceClass)
{
@@ -427,7 +420,7 @@ public class BeanContextServicesSupport
* Subclasses may envelope its behaviour in order to read further
* serialized data to the stream.
*
- * @param oos the stream from which data is being deserialized.
+ * @param ois the stream from which data is being deserialized.
* @throws IOException if an I/O error occurs.
* @throws ClassNotFoundException if the class of a deserialized object
* can not be found.
diff --git a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
index d57f5f8..7572af3 100644
--- a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
+++ b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
@@ -794,12 +794,12 @@ public class BeanContextSupport extends BeanContextChildSupport
}
/**
- * Deerializes the children using the
+ * Deserializes the children using the
* {@link #deserialize(ObjectInputStream, Collection} method
* and then calls {@link childDeserializedHook(Object, BCSChild)}
* for each child deserialized.
*
- * @param oos the output stream.
+ * @param ois the input stream.
* @throws IOException if an I/O error occurs.
*/
public final void readChildren (ObjectInputStream ois)
diff --git a/libjava/classpath/java/io/BufferedReader.java b/libjava/classpath/java/io/BufferedReader.java
index 4849949..c52d15e 100644
--- a/libjava/classpath/java/io/BufferedReader.java
+++ b/libjava/classpath/java/io/BufferedReader.java
@@ -89,11 +89,6 @@ public class BufferedReader extends Reader
static final int DEFAULT_BUFFER_SIZE = 8192;
/**
- * The line buffer for <code>readLine</code>.
- */
- private StringBuffer sbuf = null;
-
- /**
* Create a new <code>BufferedReader</code> that will read from the
* specified subordinate stream with a default buffer size of 8192 chars.
*
@@ -455,10 +450,7 @@ public class BufferedReader extends Reader
pos++;
return str;
}
- if (sbuf == null)
- sbuf = new StringBuffer(200);
- else
- sbuf.setLength(0);
+ StringBuilder sbuf = new StringBuilder(200);
sbuf.append(buffer, pos, i - pos);
pos = i;
// We only want to return null when no characters were read before
diff --git a/libjava/classpath/java/io/CharArrayWriter.java b/libjava/classpath/java/io/CharArrayWriter.java
index 0eead3a..8cbc8ae 100644
--- a/libjava/classpath/java/io/CharArrayWriter.java
+++ b/libjava/classpath/java/io/CharArrayWriter.java
@@ -267,7 +267,7 @@ public class CharArrayWriter extends Writer
* sequence is wrapped around an input buffer, the results will
* depend on the current position and length of that buffer.
*
- * @param seq the character sequence to append. If seq is null,
+ * @param cs the character sequence to append. If seq is null,
* then the string "null" (the string representation of null)
* is appended.
* @return a reference to this object.
@@ -294,7 +294,7 @@ public class CharArrayWriter extends Writer
* <code>append(seq.subSequence(start,end))</code> when the sequence
* is not null.
*
- * @param seq the character sequence to append. If seq is null,
+ * @param cs the character sequence to append. If seq is null,
* then the string "null" (the string representation of null)
* is appended.
* @param start the index of the first Unicode character to use from
diff --git a/libjava/classpath/java/io/DataInputStream.java b/libjava/classpath/java/io/DataInputStream.java
index d2604b5..ad43498 100644
--- a/libjava/classpath/java/io/DataInputStream.java
+++ b/libjava/classpath/java/io/DataInputStream.java
@@ -1,5 +1,6 @@
/* DataInputStream.java -- FilteredInputStream that implements DataInput
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2008
+ Free Software Foundation
This file is part of GNU Classpath.
@@ -349,7 +350,7 @@ public class DataInputStream extends FilterInputStream implements DataInput
*/
public final String readLine() throws IOException
{
- StringBuffer strb = new StringBuffer();
+ StringBuilder strb = new StringBuilder();
while (true)
{
@@ -590,13 +591,56 @@ public class DataInputStream extends FilterInputStream implements DataInput
public static final String readUTF(DataInput in) throws IOException
{
final int UTFlen = in.readUnsignedShort ();
- byte[] buf = new byte [UTFlen];
+
+ return readUTF(in, UTFlen);
+ }
+
+ /**
+ * This method is similar to <code>readUTF</code>, but the
+ * UTF-8 byte length is in 64 bits.
+ * This method is not public. It is used by <code>ObjectInputStream</code>.
+ *
+ * @return The <code>String</code> read
+ *
+ * @exception EOFException If end of file is reached before reading
+ * the String
+ * @exception UTFDataFormatException If the data is not in UTF-8 format
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeUTFLong
+ */
+ final String readUTFLong () throws IOException
+ {
+ long l = readLong ();
+ if (l > Integer.MAX_VALUE)
+ throw new IOException("The string length > Integer.MAX_VALUE");
+ final int UTFlen = (int)l;
+ return readUTF (this, UTFlen);
+ }
+
+ /**
+ * This method performs the main task of <code>readUTF</code> and
+ * <code>readUTFLong</code>.
+ *
+ * @param in The <code>DataInput</code> source to read from
+ *
+ * @param len The UTF-8 byte length of the String to be read
+ *
+ * @return The String read from the source
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see DataInput#readUTF
+ */
+ private static final String readUTF(DataInput in, int len) throws IOException
+ {
+ byte[] buf = new byte [len];
// This blocks until the entire string is available rather than
// doing partial processing on the bytes that are available and then
// blocking. An advantage of the latter is that Exceptions
// could be thrown earlier. The former is a bit cleaner.
- in.readFully (buf, 0, UTFlen);
+ in.readFully (buf, 0, len);
return convertFromUTF (buf);
}
@@ -703,7 +747,7 @@ public class DataInputStream extends FilterInputStream implements DataInput
{
// Give StringBuffer an initial estimated size to avoid
// enlarge buffer frequently
- StringBuffer strbuf = new StringBuffer (buf.length / 2 + 2);
+ StringBuilder strbuf = new StringBuilder (buf.length / 2 + 2);
for (int i = 0; i < buf.length; )
{
diff --git a/libjava/classpath/java/io/DataOutputStream.java b/libjava/classpath/java/io/DataOutputStream.java
index 6670c2d..435ff76 100644
--- a/libjava/classpath/java/io/DataOutputStream.java
+++ b/libjava/classpath/java/io/DataOutputStream.java
@@ -1,5 +1,5 @@
/* DataOutputStream.java -- Writes primitive Java datatypes to streams
- Copyright (C) 1998, 2001, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2003, 2005, 2008 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -379,19 +379,20 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
/**
* Calculate the length, in bytes, of a <code>String</code> in Utf8 format.
+ * This method is package-private so that <code>ObjectOutputStream</code>
+ * may use it. The return type is long so that a long string whose
+ * Utf8 byte count is 64 bit long may be handled.
*
* @param value The <code>String</code> to measure
* @param start String index at which to begin count
* @param sum Starting Utf8 byte count
*
- * @throws UTFDataFormatException if result would exceed 65535
*/
- private int getUTFlength(String value, int start, int sum)
- throws IOException
+ long getUTFlength(String value, int start, long sum)
{
int len = value.length();
- for (int i = start; i < len && sum <= 65535; ++i)
+ for (int i = start; i < len; ++i)
{
char c = value.charAt(i);
if (c >= '\u0001' && c <= '\u007f')
@@ -402,9 +403,6 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
sum += 3;
}
- if (sum > 65535)
- throw new UTFDataFormatException ();
-
return sum;
}
@@ -442,10 +440,70 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
*/
public final synchronized void writeUTF(String value) throws IOException
{
+ long l = getUTFlength(value, 0, 0);
+ if (l > 65535)
+ throw new UTFDataFormatException ();
+ writeUTFShort(value, (int)l);
+ }
+
+ /**
+ * This method performs the main task of <code>writeUTF</code>.
+ * This method is package-private because ObjectOutputStream uses it.
+ *
+ * @param value The <code>String</code> to write to the output in UTF format
+ *
+ * @param bytelen The UTF-8 byte length of the <code>String</code>. When
+ * this method is called, the expected byte length must have been calculated
+ * by <code>getUTFlength</code>.
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see DataInput#readUTF
+ */
+ final synchronized void writeUTFShort(String value, int bytelen)
+ throws IOException
+ {
+ writeShort(bytelen);
+ writeUTFBytes(value);
+ }
+
+ /**
+ * This method is similar to <code>writeUTF</code>, but it writes the
+ * UTF-8 byte length in 64 bits.
+ * This method is not public but <code>ObjectOutputStream</code> uses it.
+ *
+ * @param value The <code>String</code> to write to the output in UTF format
+ *
+ * @param bytelen The UTF-8 byte length of the <code>String</code>. When
+ * this method is called, the expected byte length must have been calculated
+ * by <code>getUTFlength</code>.
+ *
+ * @exception IOException If an error occurs
+ *
+ */
+ final synchronized void writeUTFLong(String value, long bytelen)
+ throws IOException
+ {
+ writeLong(bytelen);
+ writeUTFBytes(value);
+ }
+
+ /**
+ * This method performes the main task of <code>writeUTF</code> and
+ * <code>WriteUTFLong</code>, which is to write the UTF-8 byte
+ * sequence to the output.
+ *
+ * @param value The <code>String</code> to write to the output in UTF format
+ *
+ * @exception IOException If an error occurs
+ *
+ */
+ private final synchronized void writeUTFBytes(String value)
+ throws IOException
+ {
int len = value.length();
int i = 0;
int pos = 0;
- boolean lengthWritten = false;
if (buf == null)
buf = new byte[512];
@@ -472,14 +530,6 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
buf[pos++] = (byte) (0x80 | (0x3f & c));
}
}
- if (! lengthWritten)
- {
- if (i == len)
- writeShort(pos);
- else
- writeShort(getUTFlength(value, i, pos));
- lengthWritten = true;
- }
write(buf, 0, pos);
pos = 0;
}
diff --git a/libjava/classpath/java/io/File.java b/libjava/classpath/java/io/File.java
index f34b4dd..cd11163 100644
--- a/libjava/classpath/java/io/File.java
+++ b/libjava/classpath/java/io/File.java
@@ -1293,6 +1293,73 @@ public class File implements Serializable, Comparable<File>
}
/**
+ * Get the total space for the partition pointed by this file path, in bytes.
+ *
+ * @return the total number of bytes in this partition.
+ * @since 1.6
+ */
+ public long getTotalSpace()
+ {
+ // check security manager.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkPermission(new RuntimePermission("getFileSystemAttributes"));
+ checkRead();
+
+ return VMFile.getTotalSpace(path);
+ }
+
+ /**
+ * Get the free space in the partition pointed by this file path, in bytes.
+ *
+ * @return the number of free bytes in this partition.
+ * @since 1.6
+ */
+ public long getFreeSpace()
+ {
+ // check security manager.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkPermission(new RuntimePermission("getFileSystemAttributes"));
+ checkRead();
+
+ return VMFile.getFreeSpace(path);
+ }
+
+ /**
+ * Get the usable space in the partition pointed by this file path, in bytes.
+ * This is not necessarily the same as the number returned by
+ * {@link #getFreeSpace()}.
+ *
+ * <strong>Implementation note</strong>: Unlike the RI, on Linux and UNIX
+ * like systems this methods take into account the reserved space for the
+ * "root" user. This means that the returned results will be a little
+ * different if a normal user or root perform the query.
+ *
+ * Also, the bytes returned should be interpreted as an hint, and may be
+ * different at each call of this method or even right after the method
+ * returns.
+ *
+ * @return the number of usable bytes in this partition.
+ * @since 1.6
+ */
+ public long getUsableSpace()
+ {
+ // check security manager.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkPermission(new RuntimePermission("getFileSystemAttributes"));
+ checkRead();
+
+ // root users can use the reserved extra space
+ String user = System.getProperty("user.name");
+ if (user != null && user.equals("root"))
+ return VMFile.getFreeSpace(path);
+
+ return VMFile.getUsableSpace(path);
+ }
+
+ /**
* This method sets the file represented by this object to be read only.
* A read only file or directory cannot be modified. Please note that
* GNU systems allow read only files to be deleted if the directory it
diff --git a/libjava/classpath/java/io/FileOutputStream.java b/libjava/classpath/java/io/FileOutputStream.java
index d7561a9..b012e60 100644
--- a/libjava/classpath/java/io/FileOutputStream.java
+++ b/libjava/classpath/java/io/FileOutputStream.java
@@ -59,7 +59,7 @@ public class FileOutputStream extends OutputStream
{
private FileDescriptor fd;
- private FileChannelImpl ch;
+ private final FileChannelImpl ch;
/**
* This method initializes a <code>FileOutputStream</code> object to write
diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java
index 37b2b64..6b2a651 100644
--- a/libjava/classpath/java/io/ObjectInputStream.java
+++ b/libjava/classpath/java/io/ObjectInputStream.java
@@ -1,5 +1,5 @@
/* ObjectInputStream.java -- Class used to read serialized objects
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -367,7 +367,6 @@ public class ObjectInputStream extends InputStream
}
case TC_STRING:
- case TC_LONGSTRING:
{
if(dump) dumpElement("STRING=");
String s = this.realInputStream.readUTF();
@@ -377,6 +376,16 @@ public class ObjectInputStream extends InputStream
break;
}
+ case TC_LONGSTRING:
+ {
+ if(dump) dumpElement("STRING=");
+ String s = this.realInputStream.readUTFLong();
+ if(dump) dumpElementln(s);
+ ret_val = processResolution(null, s, assignNewHandle(s,shared),
+ shared);
+ break;
+ }
+
case TC_ARRAY:
{
if(dump) dumpElementln("ARRAY");
@@ -926,7 +935,7 @@ public class ObjectInputStream extends InputStream
return null;
ObjectStreamClass oclazz;
- oclazz = (ObjectStreamClass)classLookupTable.get(clazz);
+ oclazz = classLookupTable.get(clazz);
if (oclazz == null)
return ObjectStreamClass.lookup(clazz);
else
diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java
index b1894b3..303aed4 100644
--- a/libjava/classpath/java/io/ObjectOutputStream.java
+++ b/libjava/classpath/java/io/ObjectOutputStream.java
@@ -1,5 +1,5 @@
/* ObjectOutputStream.java -- Class used to write serialized objects
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -363,10 +363,22 @@ public class ObjectOutputStream extends OutputStream
if (obj instanceof String)
{
- realOutput.writeByte(TC_STRING);
- if (shared)
- assignNewHandle(obj);
- realOutput.writeUTF((String)obj);
+ String s = (String)obj;
+ long l = realOutput.getUTFlength(s, 0, 0);
+ if (l <= 65535)
+ {
+ realOutput.writeByte(TC_STRING);
+ if (shared)
+ assignNewHandle(obj);
+ realOutput.writeUTFShort(s, (int)l);
+ }
+ else
+ {
+ realOutput.writeByte(TC_LONGSTRING);
+ if (shared)
+ assignNewHandle(obj);
+ realOutput.writeUTFLong(s, l);
+ }
break;
}
diff --git a/libjava/classpath/java/io/ObjectStreamClass.java b/libjava/classpath/java/io/ObjectStreamClass.java
index 1f3ba73..8ebf32c 100644
--- a/libjava/classpath/java/io/ObjectStreamClass.java
+++ b/libjava/classpath/java/io/ObjectStreamClass.java
@@ -106,7 +106,7 @@ public class ObjectStreamClass implements Serializable
if (cl == null)
return null;
- ObjectStreamClass osc = (ObjectStreamClass) classLookupTable.get(cl);
+ ObjectStreamClass osc = classLookupTable.get(cl);
if (osc != null)
return osc;
@@ -830,7 +830,7 @@ outer:
}
if (loadedByBootOrApplicationClassLoader(cl))
- uidCache.put(cl,new Long(result));
+ uidCache.put(cl,Long.valueOf(result));
}
return result;
}
@@ -1074,7 +1074,7 @@ outer:
try
{
- return (Externalizable)constructor.newInstance(null);
+ return (Externalizable)constructor.newInstance();
}
catch(Exception x)
{
diff --git a/libjava/classpath/java/io/OutputStreamWriter.java b/libjava/classpath/java/io/OutputStreamWriter.java
index 2636340..5ccceed 100644
--- a/libjava/classpath/java/io/OutputStreamWriter.java
+++ b/libjava/classpath/java/io/OutputStreamWriter.java
@@ -91,17 +91,17 @@ public class OutputStreamWriter extends Writer
/**
* The charset encoder.
*/
- private CharsetEncoder encoder;
+ private final CharsetEncoder encoder;
/**
* java.io canonical name of the encoding.
*/
- private String encodingName;
+ private final String encodingName;
/**
* Buffer output before character conversion as it has costly overhead.
*/
- private CharBuffer outputBuffer;
+ private final CharBuffer outputBuffer;
private final static int BUFFER_SIZE = 1024;
/**
@@ -120,7 +120,11 @@ public class OutputStreamWriter extends Writer
public OutputStreamWriter (OutputStream out, String encoding_scheme)
throws UnsupportedEncodingException
{
+ CharsetEncoder encoder;
+ String encodingName;
this.out = out;
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
+
try
{
// Don't use NIO if avoidable
@@ -128,44 +132,44 @@ public class OutputStreamWriter extends Writer
{
encodingName = "ISO8859_1";
encoder = null;
- return;
- }
-
- /*
- * Workraround for encodings with a byte-order-mark.
- * We only want to write it once per stream.
- */
- try
- {
- if(encoding_scheme.equalsIgnoreCase("UnicodeBig") ||
- encoding_scheme.equalsIgnoreCase("UTF-16") ||
- encoding_scheme.equalsIgnoreCase("UTF16"))
- {
- encoding_scheme = "UTF-16BE";
- out.write((byte)0xFE);
- out.write((byte)0xFF);
- }
- else if(encoding_scheme.equalsIgnoreCase("UnicodeLittle")){
- encoding_scheme = "UTF-16LE";
- out.write((byte)0xFF);
- out.write((byte)0xFE);
- }
- }
- catch(IOException ioe)
- {
}
-
- outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
-
- Charset cs = EncodingHelper.getCharset(encoding_scheme);
- if(cs == null)
- throw new UnsupportedEncodingException("Encoding "+encoding_scheme+
- " unknown");
- encoder = cs.newEncoder();
- encodingName = EncodingHelper.getOldCanonical(cs.name());
-
- encoder.onMalformedInput(CodingErrorAction.REPLACE);
- encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ else
+ {
+ /*
+ * Workaround for encodings with a byte-order-mark.
+ * We only want to write it once per stream.
+ */
+ try
+ {
+ if(encoding_scheme.equalsIgnoreCase("UnicodeBig") ||
+ encoding_scheme.equalsIgnoreCase("UTF-16") ||
+ encoding_scheme.equalsIgnoreCase("UTF16"))
+ {
+ encoding_scheme = "UTF-16BE";
+ out.write((byte)0xFE);
+ out.write((byte)0xFF);
+ }
+ else if(encoding_scheme.equalsIgnoreCase("UnicodeLittle"))
+ {
+ encoding_scheme = "UTF-16LE";
+ out.write((byte)0xFF);
+ out.write((byte)0xFE);
+ }
+ }
+ catch(IOException ioe)
+ {
+ }
+
+ Charset cs = EncodingHelper.getCharset(encoding_scheme);
+ if(cs == null)
+ throw new UnsupportedEncodingException("Encoding "+encoding_scheme+
+ " unknown");
+ encoder = cs.newEncoder();
+ encodingName = EncodingHelper.getOldCanonical(cs.name());
+
+ encoder.onMalformedInput(CodingErrorAction.REPLACE);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ }
}
catch(RuntimeException e)
{
@@ -174,6 +178,8 @@ public class OutputStreamWriter extends Writer
encoder = null;
encodingName = "ISO8859_1";
}
+ this.encoder = encoder;
+ this.encodingName = encodingName;
}
/**
@@ -184,8 +190,10 @@ public class OutputStreamWriter extends Writer
*/
public OutputStreamWriter (OutputStream out)
{
+ CharsetEncoder encoder;
+ String encodingName;
this.out = out;
- outputBuffer = null;
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
try
{
String encoding = System.getProperty("file.encoding");
@@ -203,8 +211,9 @@ public class OutputStreamWriter extends Writer
{
encoder.onMalformedInput(CodingErrorAction.REPLACE);
encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
}
+ this.encoder = encoder;
+ this.encodingName = encodingName;
}
/**
@@ -345,7 +354,7 @@ public class OutputStreamWriter extends Writer
{
byte[] b = new byte[count];
for(int i=0;i<count;i++)
- b[i] = (byte)((buf[offset+i] <= 0xFF)?buf[offset+i]:'?');
+ b[i] = nullConversion(buf[offset+i]);
out.write(b);
} else {
try {
@@ -369,6 +378,10 @@ public class OutputStreamWriter extends Writer
}
}
+ private byte nullConversion(char c) {
+ return (byte)((c <= 0xFF)?c:'?');
+ }
+
/**
* This method writes <code>count</code> bytes from the specified
* <code>String</code> starting at position <code>offset</code> into the
@@ -398,7 +411,20 @@ public class OutputStreamWriter extends Writer
*/
public void write (int ch) throws IOException
{
- write(new char[]{ (char)ch }, 0, 1);
+ // No buffering, no encoding ... just pass through
+ if (encoder == null && outputBuffer == null) {
+ out.write(nullConversion((char)ch));
+ } else {
+ if (outputBuffer != null) {
+ if (outputBuffer.remaining() == 0) {
+ writeConvert(outputBuffer.array(), 0, BUFFER_SIZE);
+ outputBuffer.clear();
+ }
+ outputBuffer.put((char)ch);
+ } else {
+ writeConvert(new char[]{ (char)ch }, 0, 1);
+ }
+ }
}
} // class OutputStreamWriter
diff --git a/libjava/classpath/java/io/PipedInputStream.java b/libjava/classpath/java/io/PipedInputStream.java
index c0396d2..924cc66 100644
--- a/libjava/classpath/java/io/PipedInputStream.java
+++ b/libjava/classpath/java/io/PipedInputStream.java
@@ -82,7 +82,7 @@ public class PipedInputStream extends InputStream
* This is the internal circular buffer used for storing bytes written
* to the pipe and from which bytes are read by this stream
*/
- protected byte[] buffer = new byte[PIPE_SIZE];
+ protected byte[] buffer = null;
/**
* The index into buffer where the next byte from the connected
@@ -107,9 +107,26 @@ public class PipedInputStream extends InputStream
*/
public PipedInputStream()
{
+ this(PIPE_SIZE);
}
/**
+ * Creates a new <code>PipedInputStream</code> of the given size that is not
+ * connected to a <code>PipedOutputStream</code>.
+ * It must be connected before bytes can be read from this stream.
+ *
+ * @since 1.6
+ * @since IllegalArgumentException If pipeSize <= 0.
+ */
+ public PipedInputStream(int pipeSize) throws IllegalArgumentException
+ {
+ if (pipeSize <= 0)
+ throw new IllegalArgumentException("pipeSize must be > 0");
+
+ this.buffer = new byte[pipeSize];
+ }
+
+ /**
* This constructor creates a new <code>PipedInputStream</code> and connects
* it to the passed in <code>PipedOutputStream</code>. The stream is then
* ready for reading.
@@ -121,10 +138,29 @@ public class PipedInputStream extends InputStream
*/
public PipedInputStream(PipedOutputStream source) throws IOException
{
+ this();
connect(source);
}
/**
+ * This constructor creates a new <code>PipedInputStream</code> of the given
+ * size and connects it to the passed in <code>PipedOutputStream</code>.
+ * The stream is then ready for reading.
+ *
+ * @param source The <code>PipedOutputStream</code> to connect this
+ * stream to
+ *
+ * @since 1.6
+ * @exception IOException If <code>source</code> is already connected.
+ */
+ public PipedInputStream(PipedOutputStream source, int pipeSize)
+ throws IOException
+ {
+ this(pipeSize);
+ connect(source);
+ }
+
+ /**
* This method connects this stream to the passed in
* <code>PipedOutputStream</code>.
* This stream is then ready for reading. If this stream is already
diff --git a/libjava/classpath/java/io/PrintStream.java b/libjava/classpath/java/io/PrintStream.java
index 2d747c8..9347ac3 100644
--- a/libjava/classpath/java/io/PrintStream.java
+++ b/libjava/classpath/java/io/PrintStream.java
@@ -76,7 +76,7 @@ public class PrintStream extends FilterOutputStream implements Appendable
/**
* Encoding name
*/
- private String encoding;
+ private final String encoding;
/**
* This boolean indicates whether or not an error has ever occurred
@@ -88,7 +88,7 @@ public class PrintStream extends FilterOutputStream implements Appendable
* This is <code>true</code> if auto-flush is enabled,
* <code>false</code> otherwise
*/
- private boolean auto_flush;
+ private final boolean auto_flush;
/**
* This method initializes a new <code>PrintStream</code> object to write
@@ -185,16 +185,17 @@ public class PrintStream extends FilterOutputStream implements Appendable
public PrintStream (OutputStream out, boolean auto_flush)
{
super (out);
-
+ String encoding;
try {
- this.encoding = SystemProperties.getProperty("file.encoding");
+ encoding = SystemProperties.getProperty("file.encoding");
} catch (SecurityException e){
- this.encoding = "ISO8859_1";
+ encoding = "ISO8859_1";
} catch (IllegalArgumentException e){
- this.encoding = "ISO8859_1";
+ encoding = "ISO8859_1";
} catch (NullPointerException e){
- this.encoding = "ISO8859_1";
+ encoding = "ISO8859_1";
}
+ this.encoding = encoding;
this.auto_flush = auto_flush;
}
diff --git a/libjava/classpath/java/lang/Class.java b/libjava/classpath/java/lang/Class.java
index d3df881..0aafe80 100644
--- a/libjava/classpath/java/lang/Class.java
+++ b/libjava/classpath/java/lang/Class.java
@@ -1,5 +1,5 @@
/* Class.java -- Representation of a Java class.
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation
This file is part of GNU Classpath.
@@ -66,7 +66,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
/**
@@ -596,7 +596,7 @@ public final class Class<T>
*/
private Field[] internalGetFields()
{
- HashSet<Field> set = new HashSet<Field>();
+ LinkedHashSet<Field> set = new LinkedHashSet<Field>();
set.addAll(Arrays.asList(getDeclaredFields(true)));
Class[] interfaces = getInterfaces();
for (int i = 0; i < interfaces.length; i++)
@@ -1151,7 +1151,7 @@ public final class Class<T>
}
try
{
- return constructor.newInstance(null);
+ return constructor.newInstance();
}
catch (InvocationTargetException e)
{
diff --git a/libjava/classpath/java/lang/Double.java b/libjava/classpath/java/lang/Double.java
index c716203..466d482 100644
--- a/libjava/classpath/java/lang/Double.java
+++ b/libjava/classpath/java/lang/Double.java
@@ -518,7 +518,10 @@ public final class Double extends Number implements Comparable<Double>
*/
public static long doubleToLongBits(double value)
{
- return VMDouble.doubleToLongBits(value);
+ if (isNaN(value))
+ return 0x7ff8000000000000L;
+ else
+ return VMDouble.doubleToRawLongBits(value);
}
/**
@@ -587,16 +590,25 @@ public final class Double extends Number implements Comparable<Double>
*/
public static int compare(double x, double y)
{
- if (isNaN(x))
- return isNaN(y) ? 0 : 1;
- if (isNaN(y))
- return -1;
- // recall that 0.0 == -0.0, so we convert to infinites and try again
- if (x == 0 && y == 0)
- return (int) (1 / x - 1 / y);
- if (x == y)
- return 0;
-
- return x > y ? 1 : -1;
+ // handle the easy cases:
+ if (x < y)
+ return -1;
+ if (x > y)
+ return 1;
+
+ // handle equality respecting that 0.0 != -0.0 (hence not using x == y):
+ long lx = doubleToRawLongBits(x);
+ long ly = doubleToRawLongBits(y);
+ if (lx == ly)
+ return 0;
+
+ // handle NaNs:
+ if (x != x)
+ return (y != y) ? 0 : 1;
+ else if (y != y)
+ return -1;
+
+ // handle +/- 0.0
+ return (lx < ly) ? -1 : 1;
}
}
diff --git a/libjava/classpath/java/lang/Float.java b/libjava/classpath/java/lang/Float.java
index dc39ec2..72f31b5 100644
--- a/libjava/classpath/java/lang/Float.java
+++ b/libjava/classpath/java/lang/Float.java
@@ -526,7 +526,10 @@ public final class Float extends Number implements Comparable<Float>
*/
public static int floatToIntBits(float value)
{
- return VMFloat.floatToIntBits(value);
+ if (isNaN(value))
+ return 0x7fc00000;
+ else
+ return VMFloat.floatToRawIntBits(value);
}
/**
@@ -594,16 +597,25 @@ public final class Float extends Number implements Comparable<Float>
*/
public static int compare(float x, float y)
{
- if (isNaN(x))
- return isNaN(y) ? 0 : 1;
- if (isNaN(y))
- return -1;
- // recall that 0.0 == -0.0, so we convert to infinities and try again
- if (x == 0 && y == 0)
- return (int) (1 / x - 1 / y);
- if (x == y)
- return 0;
-
- return x > y ? 1 : -1;
+ // handle the easy cases:
+ if (x < y)
+ return -1;
+ if (x > y)
+ return 1;
+
+ // handle equality respecting that 0.0 != -0.0 (hence not using x == y):
+ int ix = floatToRawIntBits(x);
+ int iy = floatToRawIntBits(y);
+ if (ix == iy)
+ return 0;
+
+ // handle NaNs:
+ if (x != x)
+ return (y != y) ? 0 : 1;
+ else if (y != y)
+ return -1;
+
+ // handle +/- 0.0
+ return (ix < iy) ? -1 : 1;
}
}
diff --git a/libjava/classpath/java/lang/Integer.java b/libjava/classpath/java/lang/Integer.java
index 62907ff..cbf5274 100644
--- a/libjava/classpath/java/lang/Integer.java
+++ b/libjava/classpath/java/lang/Integer.java
@@ -705,16 +705,19 @@ public final class Integer extends Number implements Comparable<Integer>
if (len == 0)
throw new NumberFormatException("string length is null");
int ch = str.charAt(index);
- if (ch == '-' || ch == '+')
+ if (ch == '-')
{
if (len == 1)
- if (ch == '-')
- throw new NumberFormatException("pure '-'");
- else if (ch == '+')
- throw new NumberFormatException("pure '+'");
+ throw new NumberFormatException("pure '-'");
isNeg = true;
ch = str.charAt(++index);
}
+ else if (ch == '+')
+ {
+ if (len == 1)
+ throw new NumberFormatException("pure '+'");
+ ch = str.charAt(++index);
+ }
if (decode)
{
if (ch == '0')
diff --git a/libjava/classpath/java/lang/Long.java b/libjava/classpath/java/lang/Long.java
index f0fbc90..08ac3976 100644
--- a/libjava/classpath/java/lang/Long.java
+++ b/libjava/classpath/java/lang/Long.java
@@ -296,7 +296,7 @@ public final class Long extends Number implements Comparable<Long>
* @return the <code>Long</code>
* @since 1.5
*/
- public static synchronized Long valueOf(long val)
+ public static Long valueOf(long val)
{
// We aren't required to cache here. We could, though perhaps we
// ought to consider that as an empirical question.
diff --git a/libjava/classpath/java/lang/StackTraceElement.java b/libjava/classpath/java/lang/StackTraceElement.java
index 746dd63..73e1a46 100644
--- a/libjava/classpath/java/lang/StackTraceElement.java
+++ b/libjava/classpath/java/lang/StackTraceElement.java
@@ -202,7 +202,7 @@ public final class StackTraceElement implements Serializable
*/
public String toString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
if (declaringClass != null)
{
sb.append(declaringClass);
diff --git a/libjava/classpath/java/lang/String.java b/libjava/classpath/java/lang/String.java
index ecb4688..0b56acc 100644
--- a/libjava/classpath/java/lang/String.java
+++ b/libjava/classpath/java/lang/String.java
@@ -1303,13 +1303,13 @@ public final class String
break;
if (i < 0)
return this;
- char[] newStr = (char[]) value.clone();
- newStr[x] = newChar;
+ char[] newStr = toCharArray();
+ newStr[x - offset] = newChar;
while (--i >= 0)
if (value[++x] == oldChar)
- newStr[x] = newChar;
+ newStr[x - offset] = newChar;
// Package constructor avoids an array copy.
- return new String(newStr, offset, count, true);
+ return new String(newStr, 0, count, true);
}
/**
@@ -1431,27 +1431,18 @@ public final class String
}
/**
- * Lowercases this String according to a particular locale. This uses
- * Unicode's special case mappings, as applied to the given Locale, so the
- * resulting string may be a different length.
- *
- * @param loc locale to use
- * @return new lowercased String, or this if no characters were lowercased
- * @throws NullPointerException if loc is null
- * @see #toUpperCase(Locale)
- * @since 1.1
+ * Convert string to lower case for a Turkish locale that requires special
+ * handling of '\u0049'
*/
- public String toLowerCase(Locale loc)
+ private String toLowerCaseTurkish()
{
// First, see if the current string is already lower case.
- boolean turkish = "tr".equals(loc.getLanguage());
int i = count;
int x = offset - 1;
while (--i >= 0)
{
char ch = value[++x];
- if ((turkish && ch == '\u0049')
- || ch != Character.toLowerCase(ch))
+ if ((ch == '\u0049') || ch != Character.toLowerCase(ch))
break;
}
if (i < 0)
@@ -1459,17 +1450,75 @@ public final class String
// Now we perform the conversion. Fortunately, there are no multi-character
// lowercase expansions in Unicode 3.0.0.
- char[] newStr = (char[]) value.clone();
+ char[] newStr = new char[count];
+ VMSystem.arraycopy(value, offset, newStr, 0, x - offset);
do
{
char ch = value[x];
// Hardcoded special case.
- newStr[x++] = (turkish && ch == '\u0049') ? '\u0131'
- : Character.toLowerCase(ch);
+ if (ch != '\u0049')
+ {
+ newStr[x - offset] = Character.toLowerCase(ch);
+ }
+ else
+ {
+ newStr[x - offset] = '\u0131';
+ }
+ x++;
}
while (--i >= 0);
// Package constructor avoids an array copy.
- return new String(newStr, offset, count, true);
+ return new String(newStr, 0, count, true);
+ }
+
+ /**
+ * Lowercases this String according to a particular locale. This uses
+ * Unicode's special case mappings, as applied to the given Locale, so the
+ * resulting string may be a different length.
+ *
+ * @param loc locale to use
+ * @return new lowercased String, or this if no characters were lowercased
+ * @throws NullPointerException if loc is null
+ * @see #toUpperCase(Locale)
+ * @since 1.1
+ */
+ public String toLowerCase(Locale loc)
+ {
+ // First, see if the current string is already lower case.
+
+ // Is loc turkish? String equality test is ok as Locale.language is interned
+ if ("tr" == loc.getLanguage())
+ {
+ return toLowerCaseTurkish();
+ }
+ else
+ {
+ int i = count;
+ int x = offset - 1;
+ while (--i >= 0)
+ {
+ char ch = value[++x];
+ if (ch != Character.toLowerCase(ch))
+ break;
+ }
+ if (i < 0)
+ return this;
+
+ // Now we perform the conversion. Fortunately, there are no
+ // multi-character lowercase expansions in Unicode 3.0.0.
+ char[] newStr = new char[count];
+ VMSystem.arraycopy(value, offset, newStr, 0, x - offset);
+ do
+ {
+ char ch = value[x];
+ // Hardcoded special case.
+ newStr[x - offset] = Character.toLowerCase(ch);
+ x++;
+ }
+ while (--i >= 0);
+ // Package constructor avoids an array copy.
+ return new String(newStr, 0, count, true);
+ }
}
/**
@@ -1487,21 +1536,12 @@ public final class String
}
/**
- * Uppercases this String according to a particular locale. This uses
- * Unicode's special case mappings, as applied to the given Locale, so the
- * resulting string may be a different length.
- *
- * @param loc locale to use
- * @return new uppercased String, or this if no characters were uppercased
- * @throws NullPointerException if loc is null
- * @see #toLowerCase(Locale)
- * @since 1.1
+ * Uppercase this string for a Turkish locale
*/
- public String toUpperCase(Locale loc)
+ private String toUpperCaseTurkish()
{
// First, see how many characters we have to grow by, as well as if the
// current string is already upper case.
- boolean turkish = "tr".equals(loc.getLanguage());
int expand = 0;
boolean unchanged = true;
int i = count;
@@ -1511,7 +1551,7 @@ public final class String
char ch = value[--x];
expand += upperCaseExpansion(ch);
unchanged = (unchanged && expand == 0
- && ! (turkish && ch == '\u0069')
+ && ch != '\u0069'
&& ch == Character.toUpperCase(ch));
}
if (unchanged)
@@ -1521,16 +1561,24 @@ public final class String
i = count;
if (expand == 0)
{
- char[] newStr = (char[]) value.clone();
+ char[] newStr = new char[count];
+ VMSystem.arraycopy(value, offset, newStr, 0, count - (x - offset));
while (--i >= 0)
{
char ch = value[x];
// Hardcoded special case.
- newStr[x++] = (turkish && ch == '\u0069') ? '\u0130'
- : Character.toUpperCase(ch);
+ if (ch != '\u0069')
+ {
+ newStr[x - offset] = Character.toUpperCase(ch);
+ }
+ else
+ {
+ newStr[x - offset] = '\u0130';
+ }
+ x++;
}
// Package constructor avoids an array copy.
- return new String(newStr, offset, count, true);
+ return new String(newStr, 0, count, true);
}
// Expansion is necessary.
@@ -1540,7 +1588,7 @@ public final class String
{
char ch = value[x++];
// Hardcoded special case.
- if (turkish && ch == '\u0069')
+ if (ch == '\u0069')
{
newStr[j++] = '\u0130';
continue;
@@ -1560,6 +1608,79 @@ public final class String
}
/**
+ * Uppercases this String according to a particular locale. This uses
+ * Unicode's special case mappings, as applied to the given Locale, so the
+ * resulting string may be a different length.
+ *
+ * @param loc locale to use
+ * @return new uppercased String, or this if no characters were uppercased
+ * @throws NullPointerException if loc is null
+ * @see #toLowerCase(Locale)
+ * @since 1.1
+ */
+ public String toUpperCase(Locale loc)
+ {
+ // First, see how many characters we have to grow by, as well as if the
+ // current string is already upper case.
+
+ // Is loc turkish? String equality test is ok as Locale.language is interned
+ if ("tr" == loc.getLanguage())
+ {
+ return toUpperCaseTurkish();
+ }
+ else
+ {
+ int expand = 0;
+ boolean unchanged = true;
+ int i = count;
+ int x = i + offset;
+ while (--i >= 0)
+ {
+ char ch = value[--x];
+ expand += upperCaseExpansion(ch);
+ unchanged = (unchanged && expand == 0
+ && ch == Character.toUpperCase(ch));
+ }
+ if (unchanged)
+ return this;
+
+ // Now we perform the conversion.
+ i = count;
+ if (expand == 0)
+ {
+ char[] newStr = new char[count];
+ VMSystem.arraycopy(value, offset, newStr, 0, count - (x - offset));
+ while (--i >= 0)
+ {
+ char ch = value[x];
+ newStr[x - offset] = Character.toUpperCase(ch);
+ x++;
+ }
+ // Package constructor avoids an array copy.
+ return new String(newStr, 0, count, true);
+ }
+
+ // Expansion is necessary.
+ char[] newStr = new char[count + expand];
+ int j = 0;
+ while (--i >= 0)
+ {
+ char ch = value[x++];
+ expand = upperCaseExpansion(ch);
+ if (expand > 0)
+ {
+ int index = upperCaseIndex(ch);
+ while (expand-- >= 0)
+ newStr[j++] = upperExpand[index++];
+ }
+ else
+ newStr[j++] = Character.toUpperCase(ch);
+ }
+ // Package constructor avoids an array copy.
+ return new String(newStr, 0, newStr.length, true);
+ }
+ }
+ /**
* Uppercases this String. This uses Unicode's special case mappings, as
* applied to the platform's default Locale, so the resulting string may
* be a different length.
@@ -1617,9 +1738,6 @@ public final class String
*/
public char[] toCharArray()
{
- if (count == value.length)
- return (char[]) value.clone();
-
char[] copy = new char[count];
VMSystem.arraycopy(value, offset, copy, 0, count);
return copy;
diff --git a/libjava/classpath/java/lang/System.java b/libjava/classpath/java/lang/System.java
index 68d76fc..9fd6bfe 100644
--- a/libjava/classpath/java/lang/System.java
+++ b/libjava/classpath/java/lang/System.java
@@ -832,7 +832,7 @@ public final class System
* Blocks the retention of all elements in the specified
* collection from the collection.
*
- * @param c the collection of elements to retain.
+ * @param coll the collection of elements to retain.
* @return true if the other elements were removed.
* @throws NullPointerException if the collection is null.
* @throws NullPointerException if any collection entry is null.
diff --git a/libjava/classpath/java/lang/Throwable.java b/libjava/classpath/java/lang/Throwable.java
index c47a14b..72f9e7f 100644
--- a/libjava/classpath/java/lang/Throwable.java
+++ b/libjava/classpath/java/lang/Throwable.java
@@ -411,7 +411,7 @@ public class Throwable implements Serializable
// different threads to get mixed up when written to the same PrintWriter.
private String stackTraceString()
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
// Main stacktrace
StackTraceElement[] stack = getStackTrace();
@@ -455,7 +455,7 @@ public class Throwable implements Serializable
// Adds to the given StringBuffer a line containing the name and
// all stacktrace elements minus the last equal ones.
- private static void stackTraceStringBuffer(StringBuffer sb, String name,
+ private static void stackTraceStringBuffer(StringBuilder sb, String name,
StackTraceElement[] stack, int equal)
{
String nl = StaticData.nl;
diff --git a/libjava/classpath/java/lang/management/ThreadInfo.java b/libjava/classpath/java/lang/management/ThreadInfo.java
index 884f5af..5b8856d 100644
--- a/libjava/classpath/java/lang/management/ThreadInfo.java
+++ b/libjava/classpath/java/lang/management/ThreadInfo.java
@@ -192,134 +192,6 @@ public class ThreadInfo
/**
* Constructs a new {@link ThreadInfo} corresponding
- * to the thread specified.
- *
- * @param thread the thread on which the new instance
- * will be based.
- * @param blockedCount the number of times the thread
- * has been blocked.
- * @param blockedTime the accumulated number of milliseconds
- * the specified thread has been blocked
- * (only used with contention monitoring enabled)
- * @param lock the monitor lock the thread is waiting for
- * (only used if blocked)
- * @param lockOwner the thread which owns the monitor lock, or
- * <code>null</code> if it doesn't have an owner
- * (only used if blocked)
- * @param waitedCount the number of times the thread has been in a
- * waiting state.
- * @param waitedTime the accumulated number of milliseconds the
- * specified thread has been waiting
- * (only used with contention monitoring enabled)
- * @param isInNative true if the thread is in a native method.
- * @param isSuspended true if the thread is suspended.
- * @param trace the stack trace of the thread to a pre-determined
- * depth (see VMThreadMXBeanImpl)
- */
- private ThreadInfo(Thread thread, long blockedCount, long blockedTime,
- Object lock, Thread lockOwner, long waitedCount,
- long waitedTime, boolean isInNative, boolean isSuspended,
- StackTraceElement[] trace)
- {
- this(thread, blockedCount, blockedTime, lock, lockOwner, waitedCount,
- waitedTime, isInNative, isSuspended, trace, new MonitorInfo[]{},
- new LockInfo[]{});
- }
-
- /**
- * Constructs a new {@link ThreadInfo} corresponding
- * to the thread specified.
- *
- * @param thread the thread on which the new instance
- * will be based.
- * @param blockedCount the number of times the thread
- * has been blocked.
- * @param blockedTime the accumulated number of milliseconds
- * the specified thread has been blocked
- * (only used with contention monitoring enabled)
- * @param lock the monitor lock the thread is waiting for
- * (only used if blocked)
- * @param lockOwner the thread which owns the monitor lock, or
- * <code>null</code> if it doesn't have an owner
- * (only used if blocked)
- * @param waitedCount the number of times the thread has been in a
- * waiting state.
- * @param waitedTime the accumulated number of milliseconds the
- * specified thread has been waiting
- * (only used with contention monitoring enabled)
- * @param isInNative true if the thread is in a native method.
- * @param isSuspended true if the thread is suspended.
- * @param trace the stack trace of the thread to a pre-determined
- * depth (see VMThreadMXBeanImpl)
- * @param lockedMonitors an array of {@link MonitorInfo} objects
- * representing locks held on object monitors
- * by the thread.
- * @param lockedSynchronizers an array of {@link LockInfo} objects
- * representing locks held on ownable
- * synchronizers by the thread.
- * @since 1.6
- */
- private ThreadInfo(Thread thread, long blockedCount, long blockedTime,
- Object lock, Thread lockOwner, long waitedCount,
- long waitedTime, boolean isInNative, boolean isSuspended,
- StackTraceElement[] trace, MonitorInfo[] lockedMonitors,
- LockInfo[] lockedSynchronizers)
- {
- this(thread.getId(), thread.getName(), thread.getState(), blockedCount, blockedTime,
- lock == null ? null : lock.getClass().getName() + "@" +
- Integer.toHexString(System.identityHashCode(lock)),
- lockOwner == null ? -1 : lockOwner.getId(),
- lockOwner == null ? null : lockOwner.getName(),
- waitedCount, waitedTime, isInNative, isSuspended,
- trace, lockedMonitors, lockedSynchronizers);
- }
-
- /**
- * Constructs a new {@link ThreadInfo} corresponding
- * to the thread details specified.
- *
- * @param threadId the id of the thread on which this
- * new instance will be based.
- * @param threadName the name of the thread on which
- * this new instance will be based.
- * @param threadState the state of the thread on which
- * this new instance will be based.
- * @param blockedCount the number of times the thread
- * has been blocked.
- * @param blockedTime the accumulated number of milliseconds
- * the specified thread has been blocked
- * (only used with contention monitoring enabled)
- * @param lockName the name of the monitor lock the thread is waiting for
- * (only used if blocked)
- * @param lockOwnerId the id of the thread which owns the monitor
- * lock, or <code>-1</code> if it doesn't have an owner
- * (only used if blocked)
- * @param lockOwnerName the name of the thread which owns the monitor
- * lock, or <code>null</code> if it doesn't have an
- * owner (only used if blocked)
- * @param waitedCount the number of times the thread has been in a
- * waiting state.
- * @param waitedTime the accumulated number of milliseconds the
- * specified thread has been waiting
- * (only used with contention monitoring enabled)
- * @param isInNative true if the thread is in a native method.
- * @param isSuspended true if the thread is suspended.
- * @param trace the stack trace of the thread to a pre-determined
- * depth (see VMThreadMXBeanImpl)
- */
- private ThreadInfo(long threadId, String threadName, Thread.State threadState,
- long blockedCount, long blockedTime, String lockName,
- long lockOwnerId, String lockOwnerName, long waitedCount,
- long waitedTime, boolean isInNative, boolean isSuspended,
- StackTraceElement[] trace)
- {
- this(threadId, threadName, threadState, blockedCount, blockedTime,
- lockName, lockOwnerId, lockOwnerName, waitedCount, waitedTime,
- isInNative, isSuspended, trace, new MonitorInfo[]{}, new LockInfo[]{});
- }
-
- /**
- * Constructs a new {@link ThreadInfo} corresponding
* to the thread details specified.
*
* @param threadId the id of the thread on which this
diff --git a/libjava/classpath/java/lang/reflect/Array.java b/libjava/classpath/java/lang/reflect/Array.java
index fee9f01..d64e36c 100644
--- a/libjava/classpath/java/lang/reflect/Array.java
+++ b/libjava/classpath/java/lang/reflect/Array.java
@@ -209,19 +209,19 @@ public final class Array
if (array instanceof boolean[])
return ((boolean[]) array)[index] ? Boolean.TRUE : Boolean.FALSE;
if (array instanceof byte[])
- return new Byte(((byte[]) array)[index]);
+ return Byte.valueOf(((byte[]) array)[index]);
if (array instanceof char[])
- return new Character(((char[]) array)[index]);
+ return Character.valueOf(((char[]) array)[index]);
if (array instanceof short[])
- return new Short(((short[]) array)[index]);
+ return Short.valueOf(((short[]) array)[index]);
if (array instanceof int[])
- return new Integer(((int[]) array)[index]);
+ return Integer.valueOf(((int[]) array)[index]);
if (array instanceof long[])
- return new Long(((long[]) array)[index]);
+ return Long.valueOf(((long[]) array)[index]);
if (array instanceof float[])
- return new Float(((float[]) array)[index]);
+ return Float.valueOf(((float[]) array)[index]);
if (array instanceof double[])
- return new Double(((double[]) array)[index]);
+ return Double.valueOf(((double[]) array)[index]);
if (array == null)
throw new NullPointerException();
throw new IllegalArgumentException();
diff --git a/libjava/classpath/java/lang/reflect/Proxy.java b/libjava/classpath/java/lang/reflect/Proxy.java
index ef743f6..6c1e975 100644
--- a/libjava/classpath/java/lang/reflect/Proxy.java
+++ b/libjava/classpath/java/lang/reflect/Proxy.java
@@ -471,9 +471,9 @@ public class Proxy implements Serializable
.getMethod("equals",
new Class[] {Object.class}));
coreMethods.put(sig, sig);
- sig = new ProxySignature(Object.class.getMethod("hashCode", null));
+ sig = new ProxySignature(Object.class.getMethod("hashCode"));
coreMethods.put(sig, sig);
- sig = new ProxySignature(Object.class.getMethod("toString", null));
+ sig = new ProxySignature(Object.class.getMethod("toString"));
coreMethods.put(sig, sig);
}
catch (Exception e)
@@ -1033,7 +1033,7 @@ public class Proxy implements Serializable
code_length += 9; // new, dup_x1, swap, invokespecial, athrow
}
int handler_pc = code_length - 1;
- StringBuffer signature = new StringBuffer("(");
+ StringBuilder signature = new StringBuilder("(");
for (int j = 0; j < paramtypes.length; j++)
signature.append(TypeSignature.getEncodingOfClass(paramtypes[j]));
signature.append(")").append(TypeSignature.getEncodingOfClass(ret_type));
@@ -1261,8 +1261,8 @@ public class Proxy implements Serializable
// we're in the same package.
m.flag = true;
- Object[] args = {loader, qualName, bytecode, new Integer(0),
- new Integer(bytecode.length),
+ Object[] args = {loader, qualName, bytecode, Integer.valueOf(0),
+ Integer.valueOf(bytecode.length),
Object.class.getProtectionDomain() };
Class clazz = (Class) m.invoke(null, args);
@@ -1492,7 +1492,7 @@ public class Proxy implements Serializable
if (i == len)
return str;
- final StringBuffer sb = new StringBuffer(str);
+ final StringBuilder sb = new StringBuilder(str);
sb.setLength(i);
for ( ; i < len; i++)
{
@@ -1533,7 +1533,7 @@ public class Proxy implements Serializable
int size = poolEntries.size() + 1;
if (size >= 65535)
throw new IllegalArgumentException("exceeds VM limitations");
- i = new Integer(size);
+ i = Integer.valueOf(size);
poolEntries.put(sequence, i);
pool.append(sequence);
}
diff --git a/libjava/classpath/java/math/BigInteger.java b/libjava/classpath/java/math/BigInteger.java
index 8d174d0..3fb75ff 100644
--- a/libjava/classpath/java/math/BigInteger.java
+++ b/libjava/classpath/java/math/BigInteger.java
@@ -1,5 +1,5 @@
/* java.math.BigInteger -- Arbitary precision integers
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -1313,7 +1313,7 @@ public class BigInteger extends Number implements Comparable<BigInteger>
int b = pMinus1.getLowestSetBit();
// Set m such that this = 1 + 2^b * m.
- BigInteger m = pMinus1.divide(valueOf(2L << b - 1));
+ BigInteger m = pMinus1.divide(valueOf(2L).pow(b));
// The HAC (Handbook of Applied Cryptography), Alfred Menezes & al. Note
// 4.49 (controlling the error probability) gives the number of trials
diff --git a/libjava/classpath/java/net/DatagramSocket.java b/libjava/classpath/java/net/DatagramSocket.java
index d7aad72..ea681a1 100644
--- a/libjava/classpath/java/net/DatagramSocket.java
+++ b/libjava/classpath/java/net/DatagramSocket.java
@@ -403,7 +403,7 @@ public class DatagramSocket
if (timeout < 0)
throw new IllegalArgumentException("Invalid timeout: " + timeout);
- getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
+ getImpl().setOption(SocketOptions.SO_TIMEOUT, Integer.valueOf(timeout));
}
/**
@@ -450,7 +450,7 @@ public class DatagramSocket
if (size < 0)
throw new IllegalArgumentException("Buffer size is less than 0");
- getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size));
+ getImpl().setOption(SocketOptions.SO_SNDBUF, Integer.valueOf(size));
}
/**
@@ -497,7 +497,7 @@ public class DatagramSocket
if (size < 0)
throw new IllegalArgumentException("Buffer size is less than 0");
- getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size));
+ getImpl().setOption(SocketOptions.SO_RCVBUF, Integer.valueOf(size));
}
/**
@@ -916,7 +916,7 @@ public class DatagramSocket
if (tc < 0 || tc > 255)
throw new IllegalArgumentException();
- getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc));
+ getImpl().setOption(SocketOptions.IP_TOS, Integer.valueOf(tc));
}
/**
diff --git a/libjava/classpath/java/net/ResolverCache.java b/libjava/classpath/java/net/ResolverCache.java
index d57df49..ad329b6 100644
--- a/libjava/classpath/java/net/ResolverCache.java
+++ b/libjava/classpath/java/net/ResolverCache.java
@@ -107,7 +107,7 @@ class ResolverCache
/**
* Return the hostname for the specified IP address.
*
- * @param ip The IP address as a byte array
+ * @param addr The IP address as a byte array
*
* @return The hostname
*
@@ -116,7 +116,7 @@ class ResolverCache
public static String getHostByAddr(byte[] addr) throws UnknownHostException
{
Object key = makeHashableAddress(addr);
- Entry entry = (Entry) get(key);
+ Entry entry = get(key);
if (entry != null)
{
if (entry.value == null)
@@ -149,7 +149,7 @@ class ResolverCache
public static byte[][] getHostByName(String hostname)
throws UnknownHostException
{
- Entry entry = (Entry) get(hostname);
+ Entry entry = get(hostname);
if (entry != null)
{
if (entry.value == null)
diff --git a/libjava/classpath/java/net/ServerSocket.java b/libjava/classpath/java/net/ServerSocket.java
index 9cefd29..fa1c51e 100644
--- a/libjava/classpath/java/net/ServerSocket.java
+++ b/libjava/classpath/java/net/ServerSocket.java
@@ -469,7 +469,7 @@ public class ServerSocket
if (timeout < 0)
throw new IllegalArgumentException("SO_TIMEOUT value must be >= 0");
- impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
+ impl.setOption(SocketOptions.SO_TIMEOUT, Integer.valueOf(timeout));
}
/**
@@ -556,7 +556,7 @@ public class ServerSocket
if (size <= 0)
throw new IllegalArgumentException("SO_RCVBUF value must be > 0");
- impl.setOption(SocketOptions.SO_RCVBUF, new Integer(size));
+ impl.setOption(SocketOptions.SO_RCVBUF, Integer.valueOf(size));
}
/**
diff --git a/libjava/classpath/java/net/Socket.java b/libjava/classpath/java/net/Socket.java
index 6480527..7541bdf 100644
--- a/libjava/classpath/java/net/Socket.java
+++ b/libjava/classpath/java/net/Socket.java
@@ -844,7 +844,7 @@ public class Socket
if (timeout < 0)
throw new IllegalArgumentException("SO_TIMEOUT value must be >= 0");
- getImpl().setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
+ getImpl().setOption(SocketOptions.SO_TIMEOUT, Integer.valueOf(timeout));
}
/**
@@ -896,7 +896,7 @@ public class Socket
if (size <= 0)
throw new IllegalArgumentException("SO_SNDBUF value must be > 0");
- getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size));
+ getImpl().setOption(SocketOptions.SO_SNDBUF, Integer.valueOf(size));
}
/**
@@ -943,7 +943,7 @@ public class Socket
if (size <= 0)
throw new IllegalArgumentException("SO_RCVBUF value must be > 0");
- getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size));
+ getImpl().setOption(SocketOptions.SO_RCVBUF, Integer.valueOf(size));
}
/**
@@ -1211,7 +1211,7 @@ public class Socket
if (tc < 0 || tc > 255)
throw new IllegalArgumentException();
- getImpl().setOption(SocketOptions.IP_TOS, new Integer(tc));
+ getImpl().setOption(SocketOptions.IP_TOS, Integer.valueOf(tc));
}
/**
diff --git a/libjava/classpath/java/net/URI.java b/libjava/classpath/java/net/URI.java
index 4bf4db9..85e0e04 100644
--- a/libjava/classpath/java/net/URI.java
+++ b/libjava/classpath/java/net/URI.java
@@ -483,7 +483,7 @@ public final class URI
*/
private static String quote(String str, String legalCharacters)
{
- StringBuffer sb = new StringBuffer(str.length());
+ StringBuilder sb = new StringBuilder(str.length());
for (int i = 0; i < str.length(); i++)
{
char c = str.charAt(i);
@@ -778,8 +778,8 @@ public final class URI
This follows the algorithm in section 5.2.4. of RFC3986,
but doesn't modify the input buffer.
*/
- StringBuffer input = new StringBuffer(relativePath);
- StringBuffer output = new StringBuffer();
+ StringBuilder input = new StringBuilder(relativePath);
+ StringBuilder output = new StringBuilder();
int start = 0;
while (start < input.length())
{
@@ -853,7 +853,7 @@ public final class URI
*
* @param buffer the buffer containing the path.
*/
- private void removeLastSegment(StringBuffer buffer)
+ private void removeLastSegment(StringBuilder buffer)
{
int lastSlash = buffer.lastIndexOf("/");
if (lastSlash == -1)
@@ -899,7 +899,7 @@ public final class URI
path = "";
if (! (path.startsWith("/")))
{
- StringBuffer basepath = new StringBuffer(this.path);
+ StringBuilder basepath = new StringBuilder(this.path);
int i = this.path.lastIndexOf('/');
if (i >= 0)
@@ -1321,7 +1321,8 @@ public final class URI
int hCompare = host.compareTo(uri.getHost());
if (hCompare != 0)
return hCompare;
- return new Integer(port).compareTo(new Integer(uri.getPort()));
+ int uriPort = uri.getPort();
+ return (uriPort == port) ? 0 : (uriPort > port) ? -1 : 1;
}
}
if (rawPath == null && uri.getRawPath() != null)
@@ -1387,8 +1388,8 @@ public final class URI
{
String strRep = toString();
boolean inNonAsciiBlock = false;
- StringBuffer buffer = new StringBuffer();
- StringBuffer encBuffer = null;
+ StringBuilder buffer = new StringBuilder();
+ StringBuilder encBuffer = null;
for (int i = 0; i < strRep.length(); i++)
{
char c = strRep.charAt(i);
@@ -1405,7 +1406,7 @@ public final class URI
{
if (!inNonAsciiBlock)
{
- encBuffer = new StringBuffer();
+ encBuffer = new StringBuilder();
inNonAsciiBlock = true;
}
encBuffer.append(c);
@@ -1427,7 +1428,7 @@ public final class URI
{
try
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
// this is far from optimal, but it works
byte[] utf8 = str.getBytes("utf-8");
for (int j = 0; j < utf8.length; j++)
diff --git a/libjava/classpath/java/net/URLClassLoader.java b/libjava/classpath/java/net/URLClassLoader.java
index 346f51c..e1db2a1 100644
--- a/libjava/classpath/java/net/URLClassLoader.java
+++ b/libjava/classpath/java/net/URLClassLoader.java
@@ -452,7 +452,7 @@ public class URLClassLoader extends SecureClassLoader
{
// Compute the name of the package as it may appear in the
// Manifest.
- StringBuffer xform = new StringBuffer(name);
+ StringBuilder xform = new StringBuilder(name);
for (int i = xform.length () - 1; i >= 0; --i)
if (xform.charAt(i) == '.')
xform.setCharAt(i, '/');
@@ -641,7 +641,7 @@ public class URLClassLoader extends SecureClassLoader
{
if (thisString == null)
{
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(this.getClass().getName());
sb.append("{urls=[" );
URL[] thisURLs = getURLs();
diff --git a/libjava/classpath/java/net/URLEncoder.java b/libjava/classpath/java/net/URLEncoder.java
index dacc384..2f11c50 100644
--- a/libjava/classpath/java/net/URLEncoder.java
+++ b/libjava/classpath/java/net/URLEncoder.java
@@ -113,7 +113,7 @@ public class URLEncoder
int start = 0;
int i = 0;
- StringBuffer result = new StringBuffer(length);
+ StringBuilder result = new StringBuilder(length);
while (true)
{
while (i < length && isSafe(s.charAt(i)))
diff --git a/libjava/classpath/java/nio/charset/Charset.java b/libjava/classpath/java/nio/charset/Charset.java
index 556e470..924e005 100644
--- a/libjava/classpath/java/nio/charset/Charset.java
+++ b/libjava/classpath/java/nio/charset/Charset.java
@@ -234,7 +234,7 @@ public abstract class Charset implements Comparable<Charset>
{
for (Iterator<Charset> i = providers[j].charsets(); i.hasNext(); )
{
- Charset cs = (Charset) i.next();
+ Charset cs = i.next();
charsets.put(cs.name(), cs);
}
}
diff --git a/libjava/classpath/java/nio/charset/CoderResult.java b/libjava/classpath/java/nio/charset/CoderResult.java
index 664215d..304d9d7 100644
--- a/libjava/classpath/java/nio/charset/CoderResult.java
+++ b/libjava/classpath/java/nio/charset/CoderResult.java
@@ -170,7 +170,7 @@ public class CoderResult
if (length <= 0)
throw new IllegalArgumentException ("Non-positive length");
- Integer len = new Integer (length);
+ Integer len = Integer.valueOf (length);
CoderResult cr = null;
Object o;
if ((o = cache.get (len)) != null)
diff --git a/libjava/classpath/java/security/SecureClassLoader.java b/libjava/classpath/java/security/SecureClassLoader.java
index f683f9a..6e17300 100644
--- a/libjava/classpath/java/security/SecureClassLoader.java
+++ b/libjava/classpath/java/security/SecureClassLoader.java
@@ -37,8 +37,6 @@ exception statement from your version. */
package java.security;
-import java.util.WeakHashMap;
-
import java.nio.ByteBuffer;
import java.util.HashMap;
@@ -113,7 +111,7 @@ public class SecureClassLoader extends ClassLoader
{
synchronized (protectionDomainCache)
{
- protectionDomain = (ProtectionDomain)protectionDomainCache.get(cs);
+ protectionDomain = protectionDomainCache.get(cs);
}
if (protectionDomain == null)
@@ -122,8 +120,7 @@ public class SecureClassLoader extends ClassLoader
= new ProtectionDomain(cs, getPermissions(cs), this, null);
synchronized (protectionDomainCache)
{
- ProtectionDomain domain
- = (ProtectionDomain)protectionDomainCache.get(cs);
+ ProtectionDomain domain = protectionDomainCache.get(cs);
if (domain == null)
protectionDomainCache.put(cs, protectionDomain);
else
diff --git a/libjava/classpath/java/security/Security.java b/libjava/classpath/java/security/Security.java
index d3d2c1e..6b7b664 100644
--- a/libjava/classpath/java/security/Security.java
+++ b/libjava/classpath/java/security/Security.java
@@ -702,7 +702,7 @@ public final class Security
return true;
// assume value is a number. cehck for greater-than-or-equal
- return (new Integer(val).intValue() >= new Integer(realVal).intValue());
+ return (Integer.parseInt(val) >= Integer.parseInt(realVal));
}
}
diff --git a/libjava/classpath/java/security/cert/CertificateFactory.java b/libjava/classpath/java/security/cert/CertificateFactory.java
index 8139c6e..d83b816 100644
--- a/libjava/classpath/java/security/cert/CertificateFactory.java
+++ b/libjava/classpath/java/security/cert/CertificateFactory.java
@@ -42,7 +42,6 @@ import gnu.java.security.Engine;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
-import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
diff --git a/libjava/classpath/java/security/spec/RSAKeyGenParameterSpec.java b/libjava/classpath/java/security/spec/RSAKeyGenParameterSpec.java
index 0df8dec..ad55111 100644
--- a/libjava/classpath/java/security/spec/RSAKeyGenParameterSpec.java
+++ b/libjava/classpath/java/security/spec/RSAKeyGenParameterSpec.java
@@ -55,12 +55,12 @@ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec
/**
Public Exponent F0 = 3
*/
- public static final BigInteger F0 = new BigInteger("3");
+ public static final BigInteger F0 = BigInteger.valueOf(3);
/**
Public Exponent F4 = 3
*/
- public static final BigInteger F4 = new BigInteger("65537");
+ public static final BigInteger F4 = BigInteger.valueOf(65537L);
/**
Create a new RSAKeyGenParameterSpec to store the RSA key's keysize
diff --git a/libjava/classpath/java/text/ChoiceFormat.java b/libjava/classpath/java/text/ChoiceFormat.java
index 94c13a2..629701c 100644
--- a/libjava/classpath/java/text/ChoiceFormat.java
+++ b/libjava/classpath/java/text/ChoiceFormat.java
@@ -114,10 +114,10 @@ public class ChoiceFormat extends NumberFormat
if (index == max)
throw new IllegalArgumentException ("unexpected end of text");
- Double d = new Double (newPattern.substring(dstart, index));
+ Double d = Double.valueOf (newPattern.substring(dstart, index));
if (newPattern.charAt(index) == '<')
- d = new Double (nextDouble (d.doubleValue()));
+ d = Double.valueOf (nextDouble (d.doubleValue()));
limitVec.addElement(d);
@@ -404,11 +404,11 @@ public class ChoiceFormat extends NumberFormat
if (sourceStr.startsWith(choiceFormats[i], index))
{
pos.setIndex(index + choiceFormats[i].length());
- return new Double (choiceLimits[i]);
+ return Double.valueOf (choiceLimits[i]);
}
}
pos.setErrorIndex(index);
- return new Double (Double.NaN);
+ return Double.valueOf (Double.NaN);
}
/**
diff --git a/libjava/classpath/java/text/CollationElementIterator.java b/libjava/classpath/java/text/CollationElementIterator.java
index 45c7914..08c5cb5 100644
--- a/libjava/classpath/java/text/CollationElementIterator.java
+++ b/libjava/classpath/java/text/CollationElementIterator.java
@@ -73,7 +73,7 @@ public final class CollationElementIterator
/**
* This is the String that is being iterated over.
*/
- String text;
+ CharacterIterator text;
/**
* This is the index into the collation decomposition where we are currently scanning.
@@ -111,6 +111,21 @@ public final class CollationElementIterator
setText (text);
}
+ /**
+ * This method initializes a new instance of <code>CollationElementIterator</code>
+ * to iterate over the specified <code>String</code> using the rules in the
+ * specified <code>RuleBasedCollator</code>.
+ *
+ * @param collator The <code>RuleBasedCollation</code> used for calculating collation values
+ * @param text The character iterator to iterate over.
+ */
+ CollationElementIterator(RuleBasedCollator collator, CharacterIterator text)
+ {
+ this.collator = collator;
+
+ setText (text);
+ }
+
RuleBasedCollator.CollationElement nextBlock()
{
if (index >= text_decomposition.length)
@@ -246,7 +261,7 @@ public final class CollationElementIterator
int alreadyExpanded = 0;
int idxToMove = 0;
- this.text = text;
+ this.text = new StringCharacterIterator(text);
this.index = 0;
String work_text = text.intern();
@@ -440,7 +455,7 @@ public final class CollationElementIterator
if (offset < 0)
throw new IllegalArgumentException("Negative offset: " + offset);
- if (offset > (text.length() - 1))
+ if (offset > (text.getEndIndex() - 1))
throw new IllegalArgumentException("Offset too large: " + offset);
for (index = 0; index < text_decomposition.length; index++)
diff --git a/libjava/classpath/java/text/DecimalFormat.java b/libjava/classpath/java/text/DecimalFormat.java
index 7febdeb..61732c1 100644
--- a/libjava/classpath/java/text/DecimalFormat.java
+++ b/libjava/classpath/java/text/DecimalFormat.java
@@ -716,15 +716,15 @@ public class DecimalFormat extends NumberFormat
if (this.parseBigDecimal)
{
if (isNegative)
- return new BigDecimal(Double.NEGATIVE_INFINITY);
+ return BigDecimal.valueOf(Double.NEGATIVE_INFINITY);
- return new BigDecimal(Double.POSITIVE_INFINITY);
+ return BigDecimal.valueOf(Double.POSITIVE_INFINITY);
}
if (isNegative)
- return new Double(Double.NEGATIVE_INFINITY);
+ return Double.valueOf(Double.NEGATIVE_INFINITY);
- return new Double(Double.POSITIVE_INFINITY);
+ return Double.valueOf(Double.POSITIVE_INFINITY);
}
// no number...
@@ -771,21 +771,21 @@ public class DecimalFormat extends NumberFormat
// want integer?
if (this.parseIntegerOnly)
- return new Long(bigDecimal.longValue());
+ return Long.valueOf(bigDecimal.longValue());
// 3th special case -0.0
if (isNegative && (bigDecimal.compareTo(BigDecimal.ZERO) == 0))
- return new Double(-0.0);
+ return Double.valueOf(-0.0);
try
{
BigDecimal integer
= bigDecimal.setScale(0, BigDecimal.ROUND_UNNECESSARY);
- return new Long(integer.longValue());
+ return Long.valueOf(integer.longValue());
}
catch (ArithmeticException e)
{
- return new Double(bigDecimal.doubleValue());
+ return Double.valueOf(bigDecimal.doubleValue());
}
}
@@ -1787,7 +1787,7 @@ public class DecimalFormat extends NumberFormat
int endIndexFract = 0;
// compute the multiplier to use with percent and similar
- number = number.multiply(new BigDecimal(_multiplier));
+ number = number.multiply(BigDecimal.valueOf(_multiplier));
// XXX: special case, not sure if it belongs here or if it is
// correct at all. There may be other special cases as well
diff --git a/libjava/classpath/java/text/MessageFormat.java b/libjava/classpath/java/text/MessageFormat.java
index ab71cec..5a595f5 100644
--- a/libjava/classpath/java/text/MessageFormat.java
+++ b/libjava/classpath/java/text/MessageFormat.java
@@ -498,7 +498,7 @@ public class MessageFormat extends Format
int position = output_iterator.getEndIndex();
hash_argument.put (MessageFormat.Field.ARGUMENT,
- new Integer(elements[i].argNumber));
+ Integer.valueOf(elements[i].argNumber));
if (iterator != null)
@@ -630,7 +630,7 @@ public class MessageFormat extends Format
// have recursive formatting.
ChoiceFormat cf = (ChoiceFormat) formatter;
String[] formats = (String[]) cf.getFormats();
- double[] limits = (double[]) cf.getLimits();
+ double[] limits = cf.getLimits();
MessageFormat subfmt = new MessageFormat ();
subfmt.setLocale(locale);
ParsePosition subpos = new ParsePosition (index);
diff --git a/libjava/classpath/java/text/RuleBasedCollator.java b/libjava/classpath/java/text/RuleBasedCollator.java
index 4bffcaf..7ec18dc 100644
--- a/libjava/classpath/java/text/RuleBasedCollator.java
+++ b/libjava/classpath/java/text/RuleBasedCollator.java
@@ -923,17 +923,8 @@ element_loop:
* @return A <code>CollationElementIterator</code> for the specified <code>String</code>.
*/
public CollationElementIterator getCollationElementIterator(CharacterIterator source)
- throws NotImplementedException // Because decomposeCharacter does not work
{
- StringBuffer expand = new StringBuffer("");
-
- // Right now we assume that we will read from the beginning of the string.
- for (char c = source.first();
- c != CharacterIterator.DONE;
- c = source.next())
- decomposeCharacter(c, expand);
-
- return getCollationElementIterator(expand.toString());
+ return new CollationElementIterator(this, source);
}
/**
diff --git a/libjava/classpath/java/text/SimpleDateFormat.java b/libjava/classpath/java/text/SimpleDateFormat.java
index f78fdcb..934fb42 100644
--- a/libjava/classpath/java/text/SimpleDateFormat.java
+++ b/libjava/classpath/java/text/SimpleDateFormat.java
@@ -139,9 +139,9 @@ public class SimpleDateFormat extends DateFormat
*/
public String toString()
{
- StringBuffer builder;
+ StringBuilder builder;
- builder = new StringBuffer(getClass().getName());
+ builder = new StringBuilder(getClass().getName());
builder.append("[field=");
builder.append(field);
builder.append(", size=");
@@ -322,7 +322,7 @@ public class SimpleDateFormat extends DateFormat
// Look for the terminating quote. However, if we
// see a '', that represents a literal quote and
// we must iterate.
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int oldPos = i + 1;
do
{
@@ -346,7 +346,7 @@ public class SimpleDateFormat extends DateFormat
else
{
// A special character
- tokens.add(new Character(thisChar));
+ tokens.add(Character.valueOf(thisChar));
}
}
else
@@ -372,7 +372,7 @@ public class SimpleDateFormat extends DateFormat
*/
public String toString()
{
- StringBuffer output = new StringBuffer(getClass().getName());
+ StringBuilder output = new StringBuilder(getClass().getName());
output.append("[tokens=");
output.append(tokens);
output.append(", formatData=");
@@ -554,7 +554,7 @@ public class SimpleDateFormat extends DateFormat
String oldChars, String newChars)
{
int len = pattern.length();
- StringBuffer buf = new StringBuffer(len);
+ StringBuilder buf = new StringBuilder(len);
boolean quoted = false;
for (int i = 0; i < len; i++)
{
@@ -1279,12 +1279,12 @@ public class SimpleDateFormat extends DateFormat
// advance the index
pos.setIndex(pos.getIndex() + matcher.end());
- return new Integer(offset);
+ return Integer.valueOf(offset);
}
else if (zoneString.startsWith("GMT"))
{
pos.setIndex(pos.getIndex() + 3);
- return new Integer(0);
+ return Integer.valueOf(0);
}
return null;
}
diff --git a/libjava/classpath/java/util/AbstractMap.java b/libjava/classpath/java/util/AbstractMap.java
index 2f58121..02a30a2 100644
--- a/libjava/classpath/java/util/AbstractMap.java
+++ b/libjava/classpath/java/util/AbstractMap.java
@@ -524,7 +524,7 @@ public abstract class AbstractMap<K, V> implements Map<K, V>
public String toString()
{
Iterator<Map.Entry<K, V>> entries = entrySet().iterator();
- StringBuffer r = new StringBuffer("{");
+ StringBuilder r = new StringBuilder("{");
for (int pos = size(); pos > 0; pos--)
{
Map.Entry<K, V> entry = entries.next();
diff --git a/libjava/classpath/java/util/Calendar.java b/libjava/classpath/java/util/Calendar.java
index 2b385b1..712296b 100644
--- a/libjava/classpath/java/util/Calendar.java
+++ b/libjava/classpath/java/util/Calendar.java
@@ -572,7 +572,7 @@ public abstract class Calendar
* Cache of locale->calendar-class mappings. This avoids having to do a ResourceBundle
* lookup for every getInstance call.
*/
- private static HashMap<Locale,Class> cache = new HashMap<Locale,Class>();
+ private static final HashMap<Locale,Class> cache = new HashMap<Locale,Class>();
/** Preset argument types for calendar-class constructor lookup. */
private static Class[] ctorArgTypes = new Class[]
@@ -1266,7 +1266,7 @@ public abstract class Calendar
/**
* Compares the time of two calendar instances.
- * @param calendar the calendar to which the time should be compared.
+ * @param cal the calendar to which the time should be compared.
* @return 0 if the two calendars are set to the same time,
* less than 0 if the time of this calendar is before that of
* <code>cal</code>, or more than 0 if the time of this calendar is after
@@ -1328,8 +1328,8 @@ public abstract class Calendar
*/
public String toString()
{
- StringBuffer sb = new StringBuffer();
- sb.append(getClass().getName()).append('[');
+ StringBuilder sb = new StringBuilder(getClass().getName());
+ sb.append('[');
sb.append("time=");
if (isTimeSet)
sb.append(time);
diff --git a/libjava/classpath/java/util/Collections.java b/libjava/classpath/java/util/Collections.java
index fd802fe..ae2010f 100644
--- a/libjava/classpath/java/util/Collections.java
+++ b/libjava/classpath/java/util/Collections.java
@@ -6167,7 +6167,7 @@ public class Collections
* correct type.
*
* @param index the index at which to place the new element.
- * @param c the collections of objects to add.
+ * @param coll the collections of objects to add.
* @throws ClassCastException if the type of any element in c is not a
* valid type for the underlying collection.
*/
@@ -6870,7 +6870,7 @@ public class Collections
* Adds all pairs within the supplied map to the underlying map,
* provided they are all have the correct key and value types.
*
- * @param m the map, the entries of which should be added
+ * @param map the map, the entries of which should be added
* to the underlying map.
* @throws ClassCastException if the type of a key or value is
* not a valid type for the underlying map.
diff --git a/libjava/classpath/java/util/Date.java b/libjava/classpath/java/util/Date.java
index 1ad128e..8646c19 100644
--- a/libjava/classpath/java/util/Date.java
+++ b/libjava/classpath/java/util/Date.java
@@ -722,7 +722,7 @@ public class Date
boolean localTimezone = true;
// Trim out any nested stuff in parentheses now to make parsing easier.
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
int parenNesting = 0;
int len = string.length();
for (int i = 0; i < len; i++)
diff --git a/libjava/classpath/java/util/Formatter.java b/libjava/classpath/java/util/Formatter.java
index 12b705b..8213078 100644
--- a/libjava/classpath/java/util/Formatter.java
+++ b/libjava/classpath/java/util/Formatter.java
@@ -291,7 +291,7 @@ public final class Formatter
* If the locale is <code>null</code>, then no localization is
* applied.
*
- * @param file the output stream.
+ * @param out the output stream.
* @param charset the character set to use for output.
* @param loc the locale to use.
* @throws UnsupportedEncodingException if the supplied character
@@ -1427,7 +1427,7 @@ public final class Formatter
* Outputs a formatted string based on the supplied specification,
* <code>fmt</code>, and its arguments using the formatter's locale.
*
- * @param fmt the format specification.
+ * @param format the format specification.
* @param args the arguments to apply to the specification.
* @throws IllegalFormatException if there is a problem with
* the syntax of the format
diff --git a/libjava/classpath/java/util/Hashtable.java b/libjava/classpath/java/util/Hashtable.java
index a8567463..07bd946 100644
--- a/libjava/classpath/java/util/Hashtable.java
+++ b/libjava/classpath/java/util/Hashtable.java
@@ -579,7 +579,7 @@ public class Hashtable<K, V> extends Dictionary<K, V>
// would repeatedly re-lock/release the monitor, we directly use the
// unsynchronized EntryIterator instead.
Iterator<Map.Entry<K, V>> entries = new EntryIterator();
- StringBuffer r = new StringBuffer("{");
+ StringBuilder r = new StringBuilder("{");
for (int pos = size; pos > 0; pos--)
{
r.append(entries.next());
@@ -1088,7 +1088,7 @@ public class Hashtable<K, V> extends Dictionary<K, V>
* <code>next()</code> gives a different result, by returning just
* the key rather than the whole element.
*/
- private EntryIterator iterator;
+ private final EntryIterator iterator;
/**
* Construct a new KeyIterator
@@ -1153,7 +1153,7 @@ public class Hashtable<K, V> extends Dictionary<K, V>
* <code>next()</code> gives a different result, by returning just
* the value rather than the whole element.
*/
- private EntryIterator iterator;
+ private final EntryIterator iterator;
/**
* Construct a new KeyIterator
@@ -1294,7 +1294,7 @@ public class Hashtable<K, V> extends Dictionary<K, V>
* <code>nextElement()</code> gives a different result, by returning just
* the key rather than the whole element.
*/
- private EntryEnumerator enumerator;
+ private final EntryEnumerator enumerator;
/**
* Construct a new KeyEnumerator
@@ -1355,7 +1355,7 @@ public class Hashtable<K, V> extends Dictionary<K, V>
* <code>nextElement()</code> gives a different result, by returning just
* the value rather than the whole element.
*/
- private EntryEnumerator enumerator;
+ private final EntryEnumerator enumerator;
/**
* Construct a new ValueEnumerator
diff --git a/libjava/classpath/java/util/LinkedHashSet.java b/libjava/classpath/java/util/LinkedHashSet.java
index a0b32f3..03b9556 100644
--- a/libjava/classpath/java/util/LinkedHashSet.java
+++ b/libjava/classpath/java/util/LinkedHashSet.java
@@ -1,6 +1,6 @@
/* LinkedHashSet.java -- a set backed by a LinkedHashMap, for linked
list traversal.
- Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -98,7 +98,7 @@ public class LinkedHashSet<T> extends HashSet<T>
/**
* Construct a new, empty HashSet whose backing HashMap has the default
- * capacity (11) and loadFacor (0.75).
+ * capacity (11) and loadFactor (0.75).
*/
public LinkedHashSet()
{
diff --git a/libjava/classpath/java/util/Locale.java b/libjava/classpath/java/util/Locale.java
index 846ae7b..cd372f2 100644
--- a/libjava/classpath/java/util/Locale.java
+++ b/libjava/classpath/java/util/Locale.java
@@ -178,21 +178,21 @@ public final class Locale implements Serializable, Cloneable
*
* @serial the languange, possibly ""
*/
- private String language;
+ private final String language;
/**
* The country code, as returned by getCountry().
*
* @serial the country, possibly ""
*/
- private String country;
+ private final String country;
/**
* The variant code, as returned by getVariant().
*
* @serial the variant, possibly ""
*/
- private String variant;
+ private final String variant;
/**
* This is the cached hashcode. When writing to stream, we write -1.
@@ -324,13 +324,12 @@ public final class Locale implements Serializable, Cloneable
// default locale.
if (defaultLocale != null)
{
- language = convertLanguage(language).intern();
- country = country.toUpperCase().intern();
- variant = variant.intern();
+ language = convertLanguage(language);
+ country = country.toUpperCase();
}
- this.language = language;
- this.country = country;
- this.variant = variant;
+ this.language = language.intern();
+ this.country = country.intern();
+ this.variant = variant.intern();
hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}
@@ -1022,9 +1021,6 @@ public final class Locale implements Serializable, Cloneable
throws IOException, ClassNotFoundException
{
s.defaultReadObject();
- language = language.intern();
- country = country.intern();
- variant = variant.intern();
hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}
} // class Locale
diff --git a/libjava/classpath/java/util/concurrent/CopyOnWriteArrayList.java b/libjava/classpath/java/util/concurrent/CopyOnWriteArrayList.java
index 48c017f..6e4fb9a 100644
--- a/libjava/classpath/java/util/concurrent/CopyOnWriteArrayList.java
+++ b/libjava/classpath/java/util/concurrent/CopyOnWriteArrayList.java
@@ -41,18 +41,71 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+
import java.lang.reflect.Array;
+
import java.util.AbstractList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
import java.util.RandomAccess;
-/** @since 1.5 */
-public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
- List<E>, RandomAccess, Cloneable, Serializable
+/**
+ * A thread-safe implementation of an ArrayList. A CopyOnWriteArrayList is
+ * as special ArrayList which performs copies of the underlying storage
+ * each time a write (<code>remove</code>, <code>add</code> etc..) operation
+ * is performed.<br />
+ * <br />
+ * The update operation in this class run usually in <code>O(n)</code> or worse,
+ * but traversal operations are fast and efficient, especially when running in
+ * a multi-thread environment without the need to design complex synchronize
+ * mechanisms.<br />
+ * <br />
+ * <code>Iterator</code>s in this class work on a snapshot of the backing store
+ * at the moment the iterator itself was created, hence the iterator will not
+ * reflect changes in the underlying storage. Thus, update operation on the
+ * <code>Iterator</code>s are not supported, but as interferences from other
+ * threads are impossible, no <code>ConcurrentModificationException</code>
+ * will be ever thrown from within the <code>Iterator</code>.
+ * <br /><br />
+ * This class is especially useful when used with event handling, like the
+ * following code demonstrates:<br />
+ * <code><pre>
+ *
+ * CopyOnWriteArrayList<EventListener> listeners =
+ * new CopyOnWriteArrayList<EventListener>();
+ *
+ * [...]
+ *
+ * for (final EventListener listener : listeners)
+ * {
+ * Runnable dispatcher = new Runnable() {
+ * public void run()
+ * {
+ * listener.preferenceChange(event);
+ * }
+ * };
+ *
+ * Executor executor = Executors.newSingleThreadExecutor();
+ * executor.execute(dispatcher);
+ * }
+ * </pre></code>
+ *
+ * @since 1.5
+ */
+public class CopyOnWriteArrayList<E>
+ implements List<E>, RandomAccess, Cloneable, Serializable
{
/**
+ *
+ */
+ private static final long serialVersionUID = 8673264195747942595L;
+
+ /**
* Where the data is stored.
*/
private transient E[] data;
@@ -118,7 +171,7 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
}
/**
- * Returns true iff element is in this ArrayList.
+ * Returns true if element is in this ArrayList.
*
* @param e
* the element whose inclusion in the List is being tested
@@ -130,6 +183,28 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
}
/**
+ * Tests whether this collection contains all the elements in a given
+ * collection. This implementation iterates over the given collection,
+ * testing whether each element is contained in this collection. If any one
+ * is not, false is returned. Otherwise true is returned.
+ *
+ * @param c the collection to test against
+ * @return true if this collection contains all the elements in the given
+ * collection
+ * @throws NullPointerException if the given collection is null
+ * @see #contains(Object)
+ */
+ public boolean containsAll(Collection<?> c)
+ {
+ Iterator<?> itr = c.iterator();
+ int pos = c.size();
+ while (--pos >= 0)
+ if (!contains(itr.next()))
+ return false;
+ return true;
+ }
+
+ /**
* Returns the lowest index at which element appears in this List, or -1 if it
* does not appear.
*
@@ -161,7 +236,7 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
for (int i = index; i < data.length; i++)
if (equals(e, data[i]))
- return i;
+ return i;
return -1;
}
@@ -197,7 +272,7 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
for (int i = index; i >= 0; i--)
if (equals(e, data[i]))
- return i;
+ return i;
return -1;
}
@@ -212,7 +287,6 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
try
{
clone = (CopyOnWriteArrayList<E>) super.clone();
- clone.data = (E[]) data.clone();
}
catch (CloneNotSupportedException e)
{
@@ -347,18 +421,154 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
*/
public synchronized E remove(int index)
{
- E[] data = this.data;
- E[] newData = (E[]) new Object[data.length - 1];
+ if (index < 0 || index >= this.size())
+ throw new IndexOutOfBoundsException("index = " + index);
+
+ E[] snapshot = this.data;
+ E[] newData = (E[]) new Object[snapshot.length - 1];
+
+ E result = snapshot[index];
+
if (index > 0)
- System.arraycopy(data, 0, newData, 0, index - 1);
- System.arraycopy(data, index + 1, newData, index,
- data.length - index - 1);
- E r = data[index];
+ System.arraycopy(snapshot, 0, newData, 0, index);
+
+ System.arraycopy(snapshot, index + 1, newData, index,
+ snapshot.length - index - 1);
+
this.data = newData;
- return r;
+
+ return result;
}
/**
+ * Remove the first occurrence, if any, of the given object from this list,
+ * returning <code>true</code> if the object was removed, <code>false</code>
+ * otherwise.
+ *
+ * @param element the object to be removed.
+ * @return true if element was removed, false otherwise. false means also that
+ * the underlying storage was unchanged after this operation concluded.
+ */
+ public synchronized boolean remove(Object element)
+ {
+ E[] snapshot = this.data;
+ E[] newData = (E[]) new Object[snapshot.length - 1];
+
+ // search the element to remove while filling the backup array
+ // this way we can run this method in O(n)
+ int elementIndex = -1;
+ for (int i = 0; i < snapshot.length; i++)
+ {
+ if (equals(element, snapshot[i]))
+ {
+ elementIndex = i;
+ break;
+ }
+
+ if (i < newData.length)
+ newData[i] = snapshot[i];
+ }
+
+ if (elementIndex < 0)
+ return false;
+
+ System.arraycopy(snapshot, elementIndex + 1, newData, elementIndex,
+ snapshot.length - elementIndex - 1);
+ this.data = newData;
+
+ return true;
+ }
+
+ /**
+ * Removes all the elements contained in the given collection.
+ * This method removes the elements that are contained in both
+ * this list and in the given collection.
+ *
+ * @param c the collection containing the elements to be removed from this
+ * list.
+ * @return true if at least one element was removed, indicating that
+ * the list internal storage changed as a result, false otherwise.
+ */
+ public synchronized boolean removeAll(Collection<?> c)
+ {
+ if (c.size() == 0)
+ return false;
+
+ E [] snapshot = this.data;
+ E [] storage = (E[]) new Object[this.data.length];
+ boolean changed = false;
+
+ int length = 0;
+ for (E element : snapshot)
+ {
+ // copy all the elements, including null values
+ // if the collection can hold it
+ // FIXME: slow operation
+ if (c.contains(element))
+ changed = true;
+ else
+ storage[length++] = element;
+ }
+
+ if (!changed)
+ return false;
+
+ E[] newData = (E[]) new Object[length];
+ System.arraycopy(storage, 0, newData, 0, length);
+
+ this.data = newData;
+
+ return true;
+ }
+
+ /**
+ * Removes all the elements that are not in the passed collection.
+ * If the collection is void, this method has the same effect of
+ * <code>clear()</code>.
+ * Please, note that this method is extremely slow (unless the argument has
+ * <code>size == 0</code>) and has bad performance is both space and time
+ * usage.
+ *
+ * @param c the collection containing the elements to be retained by this
+ * list.
+ * @return true the list internal storage changed as a result of this
+ * operation, false otherwise.
+ */
+ public synchronized boolean retainAll(Collection<?> c)
+ {
+ // if the given collection does not contain elements
+ // we remove all the elements from our storage
+ if (c.size() == 0)
+ {
+ this.clear();
+ return true;
+ }
+
+ E [] snapshot = this.data;
+ E [] storage = (E[]) new Object[this.data.length];
+
+ int length = 0;
+ for (E element : snapshot)
+ {
+ if (c.contains(element))
+ storage[length++] = element;
+ }
+
+ // means we retained all the elements previously in our storage
+ // we are running already slow here, but at least we avoid copying
+ // another array and changing the internal storage
+ if (length == snapshot.length)
+ return false;
+
+ E[] newData = (E[]) new Object[length];
+ System.arraycopy(storage, 0, newData, 0, length);
+
+ this.data = newData;
+
+ return true;
+ }
+
+ /**
* Removes all elements from this List
*/
public synchronized void clear()
@@ -399,21 +609,42 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
*/
public synchronized boolean addAll(int index, Collection< ? extends E> c)
{
- E[] data = this.data;
- Iterator<? extends E> itr = c.iterator();
+ if (index < 0 || index > this.size())
+ throw new IndexOutOfBoundsException("index = " + index);
+
int csize = c.size();
if (csize == 0)
return false;
-
+
+ E[] data = this.data;
+ Iterator<? extends E> itr = c.iterator();
+
E[] newData = (E[]) new Object[data.length + csize];
- System.arraycopy(data, 0, newData, 0, data.length);
- int end = data.length;
+
+ // avoid this call at all if we were asked to put the elements at the
+ // beginning of our storage
+ if (index != 0)
+ System.arraycopy(data, 0, newData, 0, index);
+
+ int itemsLeft = index;
+
for (E value : c)
- newData[end++] = value;
+ newData[index++] = value;
+
+ // now copy the remaining elements
+ System.arraycopy(data, itemsLeft, newData, 0, data.length - itemsLeft);
+
this.data = newData;
+
return true;
}
+ /**
+ * Adds an element if the list does not contains it already.
+ *
+ * @param val the element to add to the list.
+ * @return true if the element was added, false otherwise.
+ */
public synchronized boolean addIfAbsent(E val)
{
if (contains(val))
@@ -422,16 +653,752 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
return true;
}
+ /**
+ * Adds all the element from the given collection that are not already
+ * in this list.
+ *
+ * @param c the Collection containing the elements to be inserted
+ * @return true the list internal storage changed as a result of this
+ * operation, false otherwise.
+ */
public synchronized int addAllAbsent(Collection<? extends E> c)
{
- int result = 0;
+ int size = c.size();
+ if (size == 0)
+ return 0;
+
+ E [] snapshot = this.data;
+ E [] storage = (E[]) new Object[size];
+
+ size = 0;
for (E val : c)
{
- if (addIfAbsent(val))
- ++result;
+ if (!this.contains(val))
+ storage[size++] = val;
}
- return result;
+
+ if (size == 0)
+ return 0;
+
+ // append storage to data
+ E [] newData = (E[]) new Object[snapshot.length + size];
+
+ System.arraycopy(snapshot, 0, newData, 0, snapshot.length);
+ System.arraycopy(storage, 0, newData, snapshot.length, size);
+
+ this.data = newData;
+
+ return size;
+ }
+
+ public String toString()
+ {
+ return Arrays.toString(this.data);
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o == null)
+ return false;
+
+ if (this == o)
+ return true;
+
+ // let's see if 'o' is a list, if so, we need to compare the elements
+ // as returned by the iterator
+ if (o instanceof List)
+ {
+ List<?> source = (List<?>) o;
+
+ if (source.size() != this.size())
+ return false;
+
+ Iterator<?> sourceIterator = source.iterator();
+ for (E element : this)
+ {
+ if (!element.equals(sourceIterator.next()))
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public int hashCode()
+ {
+ // see http://java.sun.com/6/docs/api/java/util/List.html#hashcode()
+ int hashcode = 1;
+ for (E element : this)
+ {
+ hashcode = 31 * hashcode + (element == null ? 0 : element.hashCode());
+ }
+ return hashcode;
+ }
+
+ /**
+ * Return an Iterator containing the elements of this list.
+ * The Iterator uses a snapshot of the state of the internal storage
+ * at the moment this method is called and does <strong>not</strong> support
+ * update operations, so no synchronization is needed to traverse the
+ * iterator.
+ *
+ * @return an Iterator containing the elements of this list in sequence.
+ */
+ public Iterator<E> iterator()
+ {
+ return new Iterator<E>()
+ {
+ E [] iteratorData = CopyOnWriteArrayList.this.data;
+ int currentElement = 0;
+
+ public boolean hasNext()
+ {
+ return (currentElement < iteratorData.length);
+ }
+
+ public E next()
+ {
+ return iteratorData[currentElement++];
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("updating of elements in " +
+ "iterators is not supported " +
+ "by this class");
+ }
+ };
}
+
+ /**
+ * Return a ListIterator containing the elements of this list.
+ * The Iterator uses a snapshot of the state of the internal storage
+ * at the moment this method is called and does <strong>not</strong> support
+ * update operations, so no synchronization is needed to traverse the
+ * iterator.
+ *
+ * @return a ListIterator containing the elements of this list in sequence.
+ */
+ public ListIterator<E> listIterator()
+ {
+ return listIterator(0);
+ }
+
+ /**
+ * Return a ListIterator over the elements of this list starting at
+ * the specified index. An initial call to {@code next()} will thus
+ * return the element at {@code index}, while an initial call to
+ * {@code previous()} will return the element at {@code index-1}. The
+ * Iterator uses a snapshot of the state of the internal storage
+ * at the moment this method is called and does <strong>not</strong> support
+ * update operations, so no synchronization is needed to traverse the
+ * iterator.
+ *
+ * @param index the index at which to start iterating.
+ * @return a ListIterator containing the elements of this list in sequence.
+ */
+ public ListIterator<E> listIterator(final int index)
+ {
+ if (index < 0 || index > size())
+ throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
+ + size());
+
+ return new ListIterator<E>()
+ {
+ E [] iteratorData = CopyOnWriteArrayList.this.data;
+ int currentElement = index;
+
+ public void add(E o)
+ {
+ throw new UnsupportedOperationException("updating of elements in " +
+ "iterators is not supported " +
+ "by this class");
+ }
+
+ public boolean hasNext()
+ {
+ return (currentElement < iteratorData.length);
+ }
+
+ public boolean hasPrevious()
+ {
+ return (currentElement > 0);
+ }
+
+ public E next()
+ {
+ if (hasNext() == false)
+ throw new java.util.NoSuchElementException();
+
+ return iteratorData[currentElement++];
+ }
+
+ public int nextIndex()
+ {
+ return (currentElement + 1);
+ }
+
+ public E previous()
+ {
+ if (hasPrevious() == false)
+ throw new java.util.NoSuchElementException();
+
+ return iteratorData[--currentElement];
+ }
+
+ public int previousIndex()
+ {
+ return (currentElement - 1);
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("updating of elements in " +
+ "iterators is not supported " +
+ "by this class");
+ }
+
+ public void set(E o)
+ {
+ throw new UnsupportedOperationException("updating of elements in " +
+ "iterators is not supported " +
+ "by this class");
+ }
+
+ };
+ }
+
+ /**
+ * Obtain a List view of a subsection of this list, from fromIndex
+ * (inclusive) to toIndex (exclusive). If the two indices are equal, the
+ * sublist is empty. The returned list should be modifiable if and only
+ * if this list is modifiable. Changes to the returned list should be
+ * reflected in this list. If this list is structurally modified in
+ * any way other than through the returned list, the result of any subsequent
+ * operations on the returned list is undefined.
+ * <p>
+ *
+ * This implementation returns a subclass of AbstractList. It stores, in
+ * private fields, the offset and size of the sublist, and the expected
+ * modCount of the backing list. If the backing list implements RandomAccess,
+ * the sublist will also.
+ * <p>
+ *
+ * The subclass's <code>set(int, Object)</code>, <code>get(int)</code>,
+ * <code>add(int, Object)</code>, <code>remove(int)</code>,
+ * <code>addAll(int, Collection)</code> and
+ * <code>removeRange(int, int)</code> methods all delegate to the
+ * corresponding methods on the backing abstract list, after
+ * bounds-checking the index and adjusting for the offset. The
+ * <code>addAll(Collection c)</code> method merely returns addAll(size, c).
+ * The <code>listIterator(int)</code> method returns a "wrapper object"
+ * over a list iterator on the backing list, which is created with the
+ * corresponding method on the backing list. The <code>iterator()</code>
+ * method merely returns listIterator(), and the <code>size()</code> method
+ * merely returns the subclass's size field.
+ * <p>
+ *
+ * All methods first check to see if the actual modCount of the backing
+ * list is equal to its expected value, and throw a
+ * ConcurrentModificationException if it is not.
+ *
+ * @param fromIndex the index that the returned list should start from
+ * (inclusive)
+ * @param toIndex the index that the returned list should go to (exclusive)
+ * @return a List backed by a subsection of this list
+ * @throws IndexOutOfBoundsException if fromIndex &lt; 0
+ * || toIndex &gt; size()
+ * @throws IndexOutOfBoundsException if fromIndex &gt; toIndex
+ * @see ConcurrentModificationException
+ * @see RandomAccess
+ */
+ public synchronized List<E> subList(int fromIndex, int toIndex)
+ {
+ // This follows the specification of AbstractList, but is inconsistent
+ // with the one in List. Don't you love Sun's inconsistencies?
+ if (fromIndex > toIndex)
+ throw new IndexOutOfBoundsException(fromIndex + " > " + toIndex);
+ if (fromIndex < 0 || toIndex > size())
+ throw new IndexOutOfBoundsException();
+
+ if (this instanceof RandomAccess)
+ return new RandomAccessSubList<E>(this, fromIndex, toIndex);
+ return new SubList<E>(this, fromIndex, toIndex);
+ }
+
+ /**
+ * This class follows the implementation requirements set forth in
+ * {@link AbstractList#subList(int, int)}. It matches Sun's implementation
+ * by using a non-public top-level class in the same package.
+ *
+ * @author Original author unknown
+ * @author Eric Blake (ebb9@email.byu.edu)
+ */
+ private static class SubList<E>
+ extends AbstractList<E>
+ {
+ // Package visible, for use by iterator.
+ /** The original list. */
+ final CopyOnWriteArrayList<E> backingList;
+ /** The index of the first element of the sublist. */
+ final int offset;
+ /** The size of the sublist. */
+ int size;
+ /** The backing data */
+ E[] data;
+
+ /**
+ * Construct the sublist.
+ *
+ * @param backing the list this comes from
+ * @param fromIndex the lower bound, inclusive
+ * @param toIndex the upper bound, exclusive
+ */
+ SubList(CopyOnWriteArrayList<E> backing, int fromIndex, int toIndex)
+ {
+ backingList = backing;
+ data = backing.data;
+ offset = fromIndex;
+ size = toIndex - fromIndex;
+ }
+
+ /**
+ * This method checks the two modCount fields to ensure that there has
+ * not been a concurrent modification, returning if all is okay.
+ *
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ */
+ // This can be inlined. Package visible, for use by iterator.
+ void checkMod()
+ {
+ if (data != backingList.data)
+ throw new ConcurrentModificationException();
+ }
+
+ /**
+ * This method checks that a value is between 0 and size (inclusive). If
+ * it is not, an exception is thrown.
+ *
+ * @param index the value to check
+ * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+ */
+ // This will get inlined, since it is private.
+ private void checkBoundsInclusive(int index)
+ {
+ if (index < 0 || index > size)
+ throw new IndexOutOfBoundsException("Index: " + index +
+ ", Size:" + size);
+ }
+
+ /**
+ * This method checks that a value is between 0 (inclusive) and size
+ * (exclusive). If it is not, an exception is thrown.
+ *
+ * @param index the value to check
+ * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+ */
+ // This will get inlined, since it is private.
+ private void checkBoundsExclusive(int index)
+ {
+ if (index < 0 || index >= size)
+ throw new IndexOutOfBoundsException("Index: " + index +
+ ", Size:" + size);
+ }
+
+ /**
+ * Specified by AbstractList.subList to return the private field size.
+ *
+ * @return the sublist size
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ */
+ public int size()
+ {
+ synchronized (backingList)
+ {
+ checkMod();
+ return size;
+ }
+ }
+
+ public void clear()
+ {
+ synchronized (backingList)
+ {
+ E[] snapshot = backingList.data;
+ E[] newData = (E[]) new Object[snapshot.length - size];
+
+ int toIndex = size + offset;
+
+ System.arraycopy(snapshot, 0, newData, 0, offset);
+ System.arraycopy(snapshot, toIndex, newData, offset,
+ snapshot.length - toIndex);
+
+ backingList.data = newData;
+ this.data = backingList.data;
+ this.size = 0;
+ }
+ }
+
+ /**
+ * Specified by AbstractList.subList to delegate to the backing list.
+ *
+ * @param index the location to modify
+ * @param o the new value
+ * @return the old value
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ * @throws UnsupportedOperationException if the backing list does not
+ * support the set operation
+ * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+ * @throws ClassCastException if o cannot be added to the backing list due
+ * to its type
+ * @throws IllegalArgumentException if o cannot be added to the backing list
+ * for some other reason
+ */
+ public E set(int index, E o)
+ {
+ synchronized (backingList)
+ {
+ checkMod();
+ checkBoundsExclusive(index);
+
+ E el = backingList.set(index + offset, o);
+ this.data = backingList.data;
+
+ return el;
+ }
+ }
+
+ /**
+ * Specified by AbstractList.subList to delegate to the backing list.
+ *
+ * @param index the location to get from
+ * @return the object at that location
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+ */
+ public E get(int index)
+ {
+ synchronized (backingList)
+ {
+ checkMod();
+ checkBoundsExclusive(index);
+
+ return backingList.get(index + offset);
+ }
+ }
+
+ /**
+ * Specified by AbstractList.subList to delegate to the backing list.
+ *
+ * @param index the index to insert at
+ * @param o the object to add
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+ * @throws UnsupportedOperationException if the backing list does not
+ * support the add operation.
+ * @throws ClassCastException if o cannot be added to the backing list due
+ * to its type.
+ * @throws IllegalArgumentException if o cannot be added to the backing
+ * list for some other reason.
+ */
+ public void add(int index, E o)
+ {
+ synchronized (backingList)
+ {
+ checkMod();
+ checkBoundsInclusive(index);
+
+ backingList.add(index + offset, o);
+
+ this.data = backingList.data;
+ size++;
+ }
+ }
+
+ /**
+ * Specified by AbstractList.subList to delegate to the backing list.
+ *
+ * @param index the index to remove
+ * @return the removed object
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
+ * @throws UnsupportedOperationException if the backing list does not
+ * support the remove operation
+ */
+ public E remove(int index)
+ {
+ synchronized (backingList)
+ {
+ checkMod();
+ checkBoundsExclusive(index);
+ E o = backingList.remove(index + offset);
+
+ this.data = backingList.data;
+ size--;
+
+ return o;
+ }
+ }
+
+ /**
+ * Specified by AbstractList.subList to delegate to the backing list.
+ *
+ * @param index the location to insert at
+ * @param c the collection to insert
+ * @return true if this list was modified, in other words, c is non-empty
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
+ * @throws UnsupportedOperationException if this list does not support the
+ * addAll operation
+ * @throws ClassCastException if some element of c cannot be added to this
+ * list due to its type
+ * @throws IllegalArgumentException if some element of c cannot be added
+ * to this list for some other reason
+ * @throws NullPointerException if the specified collection is null
+ */
+ public boolean addAll(int index, Collection<? extends E> c)
+ {
+ synchronized (backingList)
+ {
+ checkMod();
+ checkBoundsInclusive(index);
+ int csize = c.size();
+ boolean result = backingList.addAll(offset + index, c);
+
+ this.data = backingList.data;
+ size += csize;
+
+ return result;
+ }
+ }
+
+ /**
+ * Specified by AbstractList.subList to return addAll(size, c).
+ *
+ * @param c the collection to insert
+ * @return true if this list was modified, in other words, c is non-empty
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ * @throws UnsupportedOperationException if this list does not support the
+ * addAll operation
+ * @throws ClassCastException if some element of c cannot be added to this
+ * list due to its type
+ * @throws IllegalArgumentException if some element of c cannot be added
+ * to this list for some other reason
+ * @throws NullPointerException if the specified collection is null
+ */
+ public boolean addAll(Collection<? extends E> c)
+ {
+ synchronized (backingList)
+ {
+ return addAll(size, c);
+ }
+ }
+
+ /**
+ * Specified by AbstractList.subList to return listIterator().
+ *
+ * @return an iterator over the sublist
+ */
+ public Iterator<E> iterator()
+ {
+ return listIterator();
+ }
+
+ /**
+ * Specified by AbstractList.subList to return a wrapper around the
+ * backing list's iterator.
+ *
+ * @param index the start location of the iterator
+ * @return a list iterator over the sublist
+ * @throws ConcurrentModificationException if the backing list has been
+ * modified externally to this sublist
+ * @throws IndexOutOfBoundsException if the value is out of range
+ */
+ public ListIterator<E> listIterator(final int index)
+ {
+ checkMod();
+ checkBoundsInclusive(index);
+
+ return new ListIterator<E>()
+ {
+ private final ListIterator<E> i =
+ backingList.listIterator(index + offset);
+ private int position = index;
+
+ /**
+ * Tests to see if there are any more objects to
+ * return.
+ *
+ * @return True if the end of the list has not yet been
+ * reached.
+ */
+ public boolean hasNext()
+ {
+ return position < size;
+ }
+
+ /**
+ * Tests to see if there are objects prior to the
+ * current position in the list.
+ *
+ * @return True if objects exist prior to the current
+ * position of the iterator.
+ */
+ public boolean hasPrevious()
+ {
+ return position > 0;
+ }
+
+ /**
+ * Retrieves the next object from the list.
+ *
+ * @return The next object.
+ * @throws NoSuchElementException if there are no
+ * more objects to retrieve.
+ * @throws ConcurrentModificationException if the
+ * list has been modified elsewhere.
+ */
+ public E next()
+ {
+ if (position == size)
+ throw new NoSuchElementException();
+ position++;
+ return i.next();
+ }
+
+ /**
+ * Retrieves the previous object from the list.
+ *
+ * @return The next object.
+ * @throws NoSuchElementException if there are no
+ * previous objects to retrieve.
+ * @throws ConcurrentModificationException if the
+ * list has been modified elsewhere.
+ */
+ public E previous()
+ {
+ if (position == 0)
+ throw new NoSuchElementException();
+ position--;
+ return i.previous();
+ }
+
+ /**
+ * Returns the index of the next element in the
+ * list, which will be retrieved by <code>next()</code>
+ *
+ * @return The index of the next element.
+ */
+ public int nextIndex()
+ {
+ return i.nextIndex() - offset;
+ }
+
+ /**
+ * Returns the index of the previous element in the
+ * list, which will be retrieved by <code>previous()</code>
+ *
+ * @return The index of the previous element.
+ */
+ public int previousIndex()
+ {
+ return i.previousIndex() - offset;
+ }
+
+ /**
+ * Removes the last object retrieved by <code>next()</code>
+ * from the list, if the list supports object removal.
+ *
+ * @throws IllegalStateException if the iterator is positioned
+ * before the start of the list or the last object has already
+ * been removed.
+ * @throws UnsupportedOperationException if the list does
+ * not support removing elements.
+ */
+ public void remove()
+ {
+ throw new UnsupportedOperationException("Modification not supported " +
+ "on CopyOnWriteArrayList iterators");
+ }
+
+ /**
+ * Replaces the last object retrieved by <code>next()</code>
+ * or <code>previous</code> with o, if the list supports object
+ * replacement and an add or remove operation has not already
+ * been performed.
+ *
+ * @throws IllegalStateException if the iterator is positioned
+ * before the start of the list or the last object has already
+ * been removed.
+ * @throws UnsupportedOperationException if the list doesn't support
+ * the addition or removal of elements.
+ * @throws ClassCastException if the type of o is not a valid type
+ * for this list.
+ * @throws IllegalArgumentException if something else related to o
+ * prevents its addition.
+ * @throws ConcurrentModificationException if the list
+ * has been modified elsewhere.
+ */
+ public void set(E o)
+ {
+ throw new UnsupportedOperationException("Modification not supported " +
+ "on CopyOnWriteArrayList iterators");
+ }
+
+ /**
+ * Adds the supplied object before the element that would be returned
+ * by a call to <code>next()</code>, if the list supports addition.
+ *
+ * @param o The object to add to the list.
+ * @throws UnsupportedOperationException if the list doesn't support
+ * the addition of new elements.
+ * @throws ClassCastException if the type of o is not a valid type
+ * for this list.
+ * @throws IllegalArgumentException if something else related to o
+ * prevents its addition.
+ * @throws ConcurrentModificationException if the list
+ * has been modified elsewhere.
+ */
+ public void add(E o)
+ {
+ throw new UnsupportedOperationException("Modification not supported " +
+ "on CopyOnWriteArrayList iterators");
+ }
+ };
+ }
+ } // class SubList
+
+ /**
+ * This class is a RandomAccess version of SubList, as required by
+ * {@link AbstractList#subList(int, int)}.
+ *
+ * @author Eric Blake (ebb9@email.byu.edu)
+ */
+ private static final class RandomAccessSubList<E> extends SubList<E>
+ implements RandomAccess
+ {
+ /**
+ * Construct the sublist.
+ *
+ * @param backing the list this comes from
+ * @param fromIndex the lower bound, inclusive
+ * @param toIndex the upper bound, exclusive
+ */
+ RandomAccessSubList(CopyOnWriteArrayList<E> backing, int fromIndex, int toIndex)
+ {
+ super(backing, fromIndex, toIndex);
+ }
+ } // class RandomAccessSubList
/**
* Serializes this object to the given stream.
diff --git a/libjava/classpath/java/util/jar/Manifest.java b/libjava/classpath/java/util/jar/Manifest.java
index 8effc28..980cfc6 100644
--- a/libjava/classpath/java/util/jar/Manifest.java
+++ b/libjava/classpath/java/util/jar/Manifest.java
@@ -138,7 +138,7 @@ public class Manifest implements Cloneable
*/
public Attributes getAttributes(String entryName)
{
- return (Attributes) getEntries().get(entryName);
+ return getEntries().get(entryName);
}
/**
diff --git a/libjava/classpath/java/util/logging/Logger.java b/libjava/classpath/java/util/logging/Logger.java
index 01ef8f5..f7157c1 100644
--- a/libjava/classpath/java/util/logging/Logger.java
+++ b/libjava/classpath/java/util/logging/Logger.java
@@ -45,110 +45,105 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
/**
- * A Logger is used for logging information about events. Usually, there
- * is a seprate logger for each subsystem or component, although there
- * is a shared instance for components that make only occasional use of
- * the logging framework.
- *
- * <p>It is common to name a logger after the name of a corresponding
- * Java package. Loggers are organized into a hierarchical namespace;
- * for example, the logger <code>"org.gnu.foo"</code> is the
- * <em>parent</em> of logger <code>"org.gnu.foo.bar"</code>.
- *
- * <p>A logger for a named subsystem can be obtained through {@link
- * java.util.logging.Logger#getLogger(java.lang.String)}. However,
- * only code which has been granted the permission to control the
- * logging infrastructure will be allowed to customize that logger.
- * Untrusted code can obtain a private, anonymous logger through
- * {@link #getAnonymousLogger()} if it wants to perform any
- * modifications to the logger.
- *
- * <p>FIXME: Write more documentation.
- *
+ * A Logger is used for logging information about events. Usually, there is a
+ * seprate logger for each subsystem or component, although there is a shared
+ * instance for components that make only occasional use of the logging
+ * framework.
+ * <p>
+ * It is common to name a logger after the name of a corresponding Java package.
+ * Loggers are organized into a hierarchical namespace; for example, the logger
+ * <code>"org.gnu.foo"</code> is the <em>parent</em> of logger
+ * <code>"org.gnu.foo.bar"</code>.
+ * <p>
+ * A logger for a named subsystem can be obtained through {@link
+ * java.util.logging.Logger#getLogger(java.lang.String)}. However, only code
+ * which has been granted the permission to control the logging infrastructure
+ * will be allowed to customize that logger. Untrusted code can obtain a
+ * private, anonymous logger through {@link #getAnonymousLogger()} if it wants
+ * to perform any modifications to the logger.
+ * <p>
+ * FIXME: Write more documentation.
+ *
* @author Sascha Brawer (brawer@acm.org)
*/
public class Logger
{
-
static final Logger root = new Logger("", null);
/**
- * A logger provided to applications that make only occasional use
- * of the logging framework, typically early prototypes. Serious
- * products are supposed to create and use their own Loggers, so
- * they can be controlled individually.
+ * A logger provided to applications that make only occasional use of the
+ * logging framework, typically early prototypes. Serious products are
+ * supposed to create and use their own Loggers, so they can be controlled
+ * individually.
*/
public static final Logger global;
+ /**
+ * Use to lock methods on this class instead of calling synchronize on methods
+ * to avoid deadlocks. Yeah, no kidding, we got them :)
+ */
+ private static final Object[] lock = new Object[0];
+
static
{
// Our class might be initialized from an unprivileged context
- global = (Logger) AccessController.doPrivileged
- (new PrivilegedAction()
- {
- public Object run()
- {
- return getLogger("global");
- }
- });
+ global = (Logger) AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return getLogger("global");
+ }
+ });
}
-
/**
- * The name of the Logger, or <code>null</code> if the logger is
- * anonymous.
- *
- * <p>A previous version of the GNU Classpath implementation granted
- * untrusted code the permission to control any logger whose name
- * was null. However, test code revealed that the Sun J2SE 1.4
- * reference implementation enforces the security control for any
- * logger that was not created through getAnonymousLogger, even if
- * it has a null name. Therefore, a separate flag {@link
- * Logger#anonymous} was introduced.
+ * The name of the Logger, or <code>null</code> if the logger is anonymous.
+ * <p>
+ * A previous version of the GNU Classpath implementation granted untrusted
+ * code the permission to control any logger whose name was null. However,
+ * test code revealed that the Sun J2SE 1.4 reference implementation enforces
+ * the security control for any logger that was not created through
+ * getAnonymousLogger, even if it has a null name. Therefore, a separate flag
+ * {@link Logger#anonymous} was introduced.
*/
private final String name;
-
/**
* The name of the resource bundle used for localization.
- *
- * <p>This variable cannot be declared as <code>final</code>
- * because its value can change as a result of calling
- * getLogger(String,String).
+ * <p>
+ * This variable cannot be declared as <code>final</code> because its value
+ * can change as a result of calling getLogger(String,String).
*/
private String resourceBundleName;
-
/**
* The resource bundle used for localization.
- *
- * <p>This variable cannot be declared as <code>final</code>
- * because its value can change as a result of calling
- * getLogger(String,String).
+ * <p>
+ * This variable cannot be declared as <code>final</code> because its value
+ * can change as a result of calling getLogger(String,String).
*/
private ResourceBundle resourceBundle;
private Filter filter;
private final List handlerList = new java.util.ArrayList(4);
+
private Handler[] handlers = new Handler[0];
/**
- * Indicates whether or not this logger is anonymous. While
- * a LoggingPermission is required for any modifications to
- * a normal logger, untrusted code can obtain an anonymous logger
- * and modify it according to its needs.
- *
- * <p>A previous version of the GNU Classpath implementation
- * granted access to every logger whose name was null.
- * However, test code revealed that the Sun J2SE 1.4 reference
- * implementation enforces the security control for any logger
- * that was not created through getAnonymousLogger, even
- * if it has a null name.
+ * Indicates whether or not this logger is anonymous. While a
+ * LoggingPermission is required for any modifications to a normal logger,
+ * untrusted code can obtain an anonymous logger and modify it according to
+ * its needs.
+ * <p>
+ * A previous version of the GNU Classpath implementation granted access to
+ * every logger whose name was null. However, test code revealed that the Sun
+ * J2SE 1.4 reference implementation enforces the security control for any
+ * logger that was not created through getAnonymousLogger, even if it has a
+ * null name.
*/
private boolean anonymous;
-
private boolean useParentHandlers;
private Level level;
@@ -156,29 +151,26 @@ public class Logger
private Logger parent;
/**
- * Constructs a Logger for a subsystem. Most applications do not
- * need to create new Loggers explicitly; instead, they should call
- * the static factory methods
- * {@link #getLogger(java.lang.String,java.lang.String) getLogger}
+ * Constructs a Logger for a subsystem. Most applications do not need to
+ * create new Loggers explicitly; instead, they should call the static factory
+ * methods {@link #getLogger(java.lang.String,java.lang.String) getLogger}
* (with ResourceBundle for localization) or
- * {@link #getLogger(java.lang.String) getLogger} (without
- * ResourceBundle), respectively.
- *
- * @param name the name for the logger, for example "java.awt"
- * or "com.foo.bar". The name should be based on
- * the name of the package issuing log records
- * and consist of dot-separated Java identifiers.
- *
- * @param resourceBundleName the name of a resource bundle
- * for localizing messages, or <code>null</code>
- * to indicate that messages do not need to be localized.
- *
+ * {@link #getLogger(java.lang.String) getLogger} (without ResourceBundle),
+ * respectively.
+ *
+ * @param name the name for the logger, for example "java.awt" or
+ * "com.foo.bar". The name should be based on the name of the
+ * package issuing log records and consist of dot-separated Java
+ * identifiers.
+ * @param resourceBundleName the name of a resource bundle for localizing
+ * messages, or <code>null</code> to indicate that messages do
+ * not need to be localized.
* @throws java.util.MissingResourceException if
- * <code>resourceBundleName</code> is not <code>null</code>
- * and no such bundle could be located.
+ * <code>resourceBundleName</code> is not <code>null</code>
+ * and no such bundle could be located.
*/
protected Logger(String name, String resourceBundleName)
- throws MissingResourceException
+ throws MissingResourceException
{
this.name = name;
this.resourceBundleName = resourceBundleName;
@@ -190,1002 +182,978 @@ public class Logger
level = null;
- /* This is null when the root logger is being constructed,
- * and the root logger afterwards.
+ /*
+ * This is null when the root logger is being constructed, and the root
+ * logger afterwards.
*/
parent = root;
useParentHandlers = (parent != null);
}
-
-
/**
- * Finds a registered logger for a subsystem, or creates one in
- * case no logger has been registered yet.
- *
- * @param name the name for the logger, for example "java.awt"
- * or "com.foo.bar". The name should be based on
- * the name of the package issuing log records
- * and consist of dot-separated Java identifiers.
- *
- * @throws IllegalArgumentException if a logger for the subsystem
- * identified by <code>name</code> has already been created,
- * but uses a a resource bundle for localizing messages.
- *
- * @throws NullPointerException if <code>name</code> is
- * <code>null</code>.
- *
- * @return a logger for the subsystem specified by <code>name</code>
- * that does not localize messages.
+ * Finds a registered logger for a subsystem, or creates one in case no logger
+ * has been registered yet.
+ *
+ * @param name the name for the logger, for example "java.awt" or
+ * "com.foo.bar". The name should be based on the name of the
+ * package issuing log records and consist of dot-separated Java
+ * identifiers.
+ * @throws IllegalArgumentException if a logger for the subsystem identified
+ * by <code>name</code> has already been created, but uses a a
+ * resource bundle for localizing messages.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ * @return a logger for the subsystem specified by <code>name</code> that
+ * does not localize messages.
*/
public static Logger getLogger(String name)
{
return getLogger(name, null);
}
-
/**
- * Finds a registered logger for a subsystem, or creates one in case
- * no logger has been registered yet.
- *
- * <p>If a logger with the specified name has already been
- * registered, the behavior depends on the resource bundle that is
- * currently associated with the existing logger.
- *
- * <ul><li>If the existing logger uses the same resource bundle as
- * specified by <code>resourceBundleName</code>, the existing logger
- * is returned.</li>
- *
- * <li>If the existing logger currently does not localize messages,
- * the existing logger is modified to use the bundle specified by
- * <code>resourceBundleName</code>. The existing logger is then
- * returned. Therefore, all subsystems currently using this logger
- * will produce localized messages from now on.</li>
- *
- * <li>If the existing logger already has an associated resource
- * bundle, but a different one than specified by
- * <code>resourceBundleName</code>, an
- * <code>IllegalArgumentException</code> is thrown.</li></ul>
- *
- * @param name the name for the logger, for example "java.awt"
- * or "org.gnu.foo". The name should be based on
- * the name of the package issuing log records
- * and consist of dot-separated Java identifiers.
- *
- * @param resourceBundleName the name of a resource bundle
- * for localizing messages, or <code>null</code>
- * to indicate that messages do not need to be localized.
- *
+ * Finds a registered logger for a subsystem, or creates one in case no logger
+ * has been registered yet.
+ * <p>
+ * If a logger with the specified name has already been registered, the
+ * behavior depends on the resource bundle that is currently associated with
+ * the existing logger.
+ * <ul>
+ * <li>If the existing logger uses the same resource bundle as specified by
+ * <code>resourceBundleName</code>, the existing logger is returned.</li>
+ * <li>If the existing logger currently does not localize messages, the
+ * existing logger is modified to use the bundle specified by
+ * <code>resourceBundleName</code>. The existing logger is then returned.
+ * Therefore, all subsystems currently using this logger will produce
+ * localized messages from now on.</li>
+ * <li>If the existing logger already has an associated resource bundle, but
+ * a different one than specified by <code>resourceBundleName</code>, an
+ * <code>IllegalArgumentException</code> is thrown.</li>
+ * </ul>
+ *
+ * @param name the name for the logger, for example "java.awt" or
+ * "org.gnu.foo". The name should be based on the name of the
+ * package issuing log records and consist of dot-separated Java
+ * identifiers.
+ * @param resourceBundleName the name of a resource bundle for localizing
+ * messages, or <code>null</code> to indicate that messages do
+ * not need to be localized.
* @return a logger for the subsystem specified by <code>name</code>.
- *
* @throws java.util.MissingResourceException if
- * <code>resourceBundleName</code> is not <code>null</code>
- * and no such bundle could be located.
- *
- * @throws IllegalArgumentException if a logger for the subsystem
- * identified by <code>name</code> has already been created,
- * but uses a different resource bundle for localizing
- * messages.
- *
- * @throws NullPointerException if <code>name</code> is
- * <code>null</code>.
+ * <code>resourceBundleName</code> is not <code>null</code>
+ * and no such bundle could be located.
+ * @throws IllegalArgumentException if a logger for the subsystem identified
+ * by <code>name</code> has already been created, but uses a
+ * different resource bundle for localizing messages.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
*/
public static Logger getLogger(String name, String resourceBundleName)
{
LogManager lm = LogManager.getLogManager();
- Logger result;
+ Logger result;
if (name == null)
throw new NullPointerException();
- /* Without synchronized(lm), it could happen that another thread
- * would create a logger between our calls to getLogger and
- * addLogger. While addLogger would indicate this by returning
- * false, we could not be sure that this other logger was still
- * existing when we called getLogger a second time in order
- * to retrieve it -- note that LogManager is only allowed to
- * keep weak references to registered loggers, so Loggers
- * can be garbage collected at any time in general, and between
- * our call to addLogger and our second call go getLogger
- * in particular.
- *
- * Of course, we assume here that LogManager.addLogger etc.
- * are synchronizing on the global LogManager object. There
- * is a comment in the implementation of LogManager.addLogger
- * referring to this comment here, so that any change in
- * the synchronization of LogManager will be reflected here.
+ /*
+ * Without synchronized(lm), it could happen that another thread would
+ * create a logger between our calls to getLogger and addLogger. While
+ * addLogger would indicate this by returning false, we could not be sure
+ * that this other logger was still existing when we called getLogger a
+ * second time in order to retrieve it -- note that LogManager is only
+ * allowed to keep weak references to registered loggers, so Loggers can be
+ * garbage collected at any time in general, and between our call to
+ * addLogger and our second call go getLogger in particular. Of course, we
+ * assume here that LogManager.addLogger etc. are synchronizing on the
+ * global LogManager object. There is a comment in the implementation of
+ * LogManager.addLogger referring to this comment here, so that any change
+ * in the synchronization of LogManager will be reflected here.
*/
- synchronized (lm)
- {
- result = lm.getLogger(name);
- if (result == null)
- {
- boolean couldBeAdded;
-
- result = new Logger(name, resourceBundleName);
- couldBeAdded = lm.addLogger(result);
- if (!couldBeAdded)
- throw new IllegalStateException("cannot register new logger");
- }
- else
+ synchronized (lock)
{
- /* The logger already exists. Make sure it uses
- * the same resource bundle for localizing messages.
- */
- String existingBundleName = result.getResourceBundleName();
-
- /* The Sun J2SE 1.4 reference implementation will return the
- * registered logger object, even if it does not have a resource
- * bundle associated with it. However, it seems to change the
- * resourceBundle of the registered logger to the bundle
- * whose name was passed to getLogger.
- */
- if ((existingBundleName == null) && (resourceBundleName != null))
- {
- /* If ResourceBundle.getBundle throws an exception, the
- * existing logger will be unchanged. This would be
- * different if the assignment to resourceBundleName
- * came first.
- */
- result.resourceBundle = ResourceBundle.getBundle(resourceBundleName);
- result.resourceBundleName = resourceBundleName;
- return result;
- }
-
- if ((existingBundleName != resourceBundleName)
- && ((existingBundleName == null)
- || !existingBundleName.equals(resourceBundleName)))
- {
- throw new IllegalArgumentException();
- }
+ synchronized (lm)
+ {
+ result = lm.getLogger(name);
+ if (result == null)
+ {
+ boolean couldBeAdded;
+
+ result = new Logger(name, resourceBundleName);
+ couldBeAdded = lm.addLogger(result);
+ if (! couldBeAdded)
+ throw new IllegalStateException("cannot register new logger");
+ }
+ else
+ {
+ /*
+ * The logger already exists. Make sure it uses the same
+ * resource bundle for localizing messages.
+ */
+ String existingBundleName = result.getResourceBundleName();
+
+ /*
+ * The Sun J2SE 1.4 reference implementation will return the
+ * registered logger object, even if it does not have a resource
+ * bundle associated with it. However, it seems to change the
+ * resourceBundle of the registered logger to the bundle whose
+ * name was passed to getLogger.
+ */
+ if ((existingBundleName == null) &&
+ (resourceBundleName != null))
+ {
+ /*
+ * If ResourceBundle.getBundle throws an exception, the
+ * existing logger will be unchanged. This would be
+ * different if the assignment to resourceBundleName came
+ * first.
+ */
+ result.resourceBundle =
+ ResourceBundle.getBundle(resourceBundleName);
+
+ result.resourceBundleName = resourceBundleName;
+ return result;
+ }
+
+ if ((existingBundleName != resourceBundleName)
+ && ((existingBundleName == null)
+ || !existingBundleName.equals(resourceBundleName)))
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
}
- }
return result;
}
-
/**
- * Creates a new, unnamed logger. Unnamed loggers are not
- * registered in the namespace of the LogManager, and no special
- * security permission is required for changing their state.
- * Therefore, untrusted applets are able to modify their private
- * logger instance obtained through this method.
- *
- * <p>The parent of the newly created logger will the the root
- * logger, from which the level threshold and the handlers are
- * inherited.
+ * Creates a new, unnamed logger. Unnamed loggers are not registered in the
+ * namespace of the LogManager, and no special security permission is required
+ * for changing their state. Therefore, untrusted applets are able to modify
+ * their private logger instance obtained through this method.
+ * <p>
+ * The parent of the newly created logger will the the root logger, from which
+ * the level threshold and the handlers are inherited.
*/
public static Logger getAnonymousLogger()
{
return getAnonymousLogger(null);
}
-
/**
- * Creates a new, unnamed logger. Unnamed loggers are not
- * registered in the namespace of the LogManager, and no special
- * security permission is required for changing their state.
- * Therefore, untrusted applets are able to modify their private
- * logger instance obtained through this method.
- *
- * <p>The parent of the newly created logger will the the root
- * logger, from which the level threshold and the handlers are
- * inherited.
- *
- * @param resourceBundleName the name of a resource bundle
- * for localizing messages, or <code>null</code>
- * to indicate that messages do not need to be localized.
- *
+ * Creates a new, unnamed logger. Unnamed loggers are not registered in the
+ * namespace of the LogManager, and no special security permission is required
+ * for changing their state. Therefore, untrusted applets are able to modify
+ * their private logger instance obtained through this method.
+ * <p>
+ * The parent of the newly created logger will the the root logger, from which
+ * the level threshold and the handlers are inherited.
+ *
+ * @param resourceBundleName the name of a resource bundle for localizing
+ * messages, or <code>null</code> to indicate that messages do
+ * not need to be localized.
* @throws java.util.MissingResourceException if
- * <code>resourceBundleName</code> is not <code>null</code>
- * and no such bundle could be located.
+ * <code>resourceBundleName</code> is not <code>null</code>
+ * and no such bundle could be located.
*/
public static Logger getAnonymousLogger(String resourceBundleName)
- throws MissingResourceException
+ throws MissingResourceException
{
- Logger result;
+ Logger result;
result = new Logger(null, resourceBundleName);
result.anonymous = true;
return result;
}
-
/**
- * Returns the name of the resource bundle that is being used for
- * localizing messages.
- *
- * @return the name of the resource bundle used for localizing messages,
- * or <code>null</code> if the parent's resource bundle
- * is used for this purpose.
+ * Returns the name of the resource bundle that is being used for localizing
+ * messages.
+ *
+ * @return the name of the resource bundle used for localizing messages, or
+ * <code>null</code> if the parent's resource bundle is used for
+ * this purpose.
*/
- public synchronized String getResourceBundleName()
+ public String getResourceBundleName()
{
- return resourceBundleName;
+ synchronized (lock)
+ {
+ return resourceBundleName;
+ }
}
-
/**
- * Returns the resource bundle that is being used for localizing
- * messages.
- *
- * @return the resource bundle used for localizing messages,
- * or <code>null</code> if the parent's resource bundle
- * is used for this purpose.
+ * Returns the resource bundle that is being used for localizing messages.
+ *
+ * @return the resource bundle used for localizing messages, or
+ * <code>null</code> if the parent's resource bundle is used for
+ * this purpose.
*/
- public synchronized ResourceBundle getResourceBundle()
+ public ResourceBundle getResourceBundle()
{
- return resourceBundle;
+ synchronized (lock)
+ {
+ return resourceBundle;
+ }
}
-
/**
- * Returns the severity level threshold for this <code>Handler</code>.
- * All log records with a lower severity level will be discarded;
- * a log record of the same or a higher level will be published
- * unless an installed <code>Filter</code> decides to discard it.
- *
- * @return the severity level below which all log messages will be
- * discarded, or <code>null</code> if the logger inherits
- * the threshold from its parent.
+ * Returns the severity level threshold for this <code>Handler</code>. All
+ * log records with a lower severity level will be discarded; a log record of
+ * the same or a higher level will be published unless an installed
+ * <code>Filter</code> decides to discard it.
+ *
+ * @return the severity level below which all log messages will be discarded,
+ * or <code>null</code> if the logger inherits the threshold from
+ * its parent.
*/
- public synchronized Level getLevel()
+ public Level getLevel()
{
- return level;
+ synchronized (lock)
+ {
+ return level;
+ }
}
-
/**
- * Returns whether or not a message of the specified level
- * would be logged by this logger.
- *
- * @throws NullPointerException if <code>level</code>
- * is <code>null</code>.
+ * Returns whether or not a message of the specified level would be logged by
+ * this logger.
+ *
+ * @throws NullPointerException if <code>level</code> is <code>null</code>.
*/
- public synchronized boolean isLoggable(Level level)
+ public boolean isLoggable(Level level)
{
- if (this.level != null)
- return this.level.intValue() <= level.intValue();
+ synchronized (lock)
+ {
+ if (this.level != null)
+ return this.level.intValue() <= level.intValue();
- if (parent != null)
- return parent.isLoggable(level);
- else
- return false;
+ if (parent != null)
+ return parent.isLoggable(level);
+ else
+ return false;
+ }
}
-
/**
- * Sets the severity level threshold for this <code>Handler</code>.
- * All log records with a lower severity level will be discarded
- * immediately. A log record of the same or a higher level will be
- * published unless an installed <code>Filter</code> decides to
- * discard it.
- *
- * @param level the severity level below which all log messages
- * will be discarded, or <code>null</code> to
- * indicate that the logger should inherit the
- * threshold from its parent.
- *
- * @throws SecurityException if this logger is not anonymous, a
- * security manager exists, and the caller is not granted
- * the permission to control the logging infrastructure by
- * having LoggingPermission("control"). Untrusted code can
- * obtain an anonymous logger through the static factory method
- * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+ * Sets the severity level threshold for this <code>Handler</code>. All log
+ * records with a lower severity level will be discarded immediately. A log
+ * record of the same or a higher level will be published unless an installed
+ * <code>Filter</code> decides to discard it.
+ *
+ * @param level the severity level below which all log messages will be
+ * discarded, or <code>null</code> to indicate that the logger
+ * should inherit the threshold from its parent.
+ * @throws SecurityException if this logger is not anonymous, a security
+ * manager exists, and the caller is not granted the permission to
+ * control the logging infrastructure by having
+ * LoggingPermission("control"). Untrusted code can obtain an
+ * anonymous logger through the static factory method
+ * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
*/
- public synchronized void setLevel(Level level)
+ public void setLevel(Level level)
{
- /* An application is allowed to control an anonymous logger
- * without having the permission to control the logging
- * infrastructure.
- */
- if (!anonymous)
- LogManager.getLogManager().checkAccess();
-
- this.level = level;
+ synchronized (lock)
+ {
+ /*
+ * An application is allowed to control an anonymous logger without
+ * having the permission to control the logging infrastructure.
+ */
+ if (! anonymous)
+ LogManager.getLogManager().checkAccess();
+
+ this.level = level;
+ }
}
-
- public synchronized Filter getFilter()
+ public Filter getFilter()
{
- return filter;
+ synchronized (lock)
+ {
+ return filter;
+ }
}
-
/**
- * @throws SecurityException if this logger is not anonymous, a
- * security manager exists, and the caller is not granted
- * the permission to control the logging infrastructure by
- * having LoggingPermission("control"). Untrusted code can
- * obtain an anonymous logger through the static factory method
- * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+ * @throws SecurityException if this logger is not anonymous, a security
+ * manager exists, and the caller is not granted the permission to
+ * control the logging infrastructure by having
+ * LoggingPermission("control"). Untrusted code can obtain an
+ * anonymous logger through the static factory method
+ * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
*/
- public synchronized void setFilter(Filter filter)
- throws SecurityException
+ public void setFilter(Filter filter) throws SecurityException
{
- /* An application is allowed to control an anonymous logger
- * without having the permission to control the logging
- * infrastructure.
- */
- if (!anonymous)
- LogManager.getLogManager().checkAccess();
-
- this.filter = filter;
+ synchronized (lock)
+ {
+ /*
+ * An application is allowed to control an anonymous logger without
+ * having the permission to control the logging infrastructure.
+ */
+ if (! anonymous)
+ LogManager.getLogManager().checkAccess();
+
+ this.filter = filter;
+ }
}
-
-
-
/**
* Returns the name of this logger.
- *
- * @return the name of this logger, or <code>null</code> if
- * the logger is anonymous.
+ *
+ * @return the name of this logger, or <code>null</code> if the logger is
+ * anonymous.
*/
public String getName()
{
- /* Note that the name of a logger cannot be changed during
- * its lifetime, so no synchronization is needed.
+ /*
+ * Note that the name of a logger cannot be changed during its lifetime, so
+ * no synchronization is needed.
*/
return name;
}
-
/**
- * Passes a record to registered handlers, provided the record
- * is considered as loggable both by {@link #isLoggable(Level)}
- * and a possibly installed custom {@link #setFilter(Filter) filter}.
- *
- * <p>If the logger has been configured to use parent handlers,
- * the record will be forwarded to the parent of this logger
- * in addition to being processed by the handlers registered with
- * this logger.
- *
- * <p>The other logging methods in this class are convenience methods
- * that merely create a new LogRecord and pass it to this method.
- * Therefore, subclasses usually just need to override this single
- * method for customizing the logging behavior.
- *
+ * Passes a record to registered handlers, provided the record is considered
+ * as loggable both by {@link #isLoggable(Level)} and a possibly installed
+ * custom {@link #setFilter(Filter) filter}.
+ * <p>
+ * If the logger has been configured to use parent handlers, the record will
+ * be forwarded to the parent of this logger in addition to being processed by
+ * the handlers registered with this logger.
+ * <p>
+ * The other logging methods in this class are convenience methods that merely
+ * create a new LogRecord and pass it to this method. Therefore, subclasses
+ * usually just need to override this single method for customizing the
+ * logging behavior.
+ *
* @param record the log record to be inspected and possibly forwarded.
*/
- public synchronized void log(LogRecord record)
+ public void log(LogRecord record)
{
- if (!isLoggable(record.getLevel()))
- return;
-
- if ((filter != null) && !filter.isLoggable(record))
- return;
-
- /* If no logger name has been set for the log record,
- * use the name of this logger.
- */
- if (record.getLoggerName() == null)
- record.setLoggerName(name);
-
- /* Avoid that some other thread is changing the logger hierarchy
- * while we are traversing it.
- */
- synchronized (LogManager.getLogManager())
- {
- Logger curLogger = this;
-
- do
+ synchronized (lock)
{
- /* The Sun J2SE 1.4 reference implementation seems to call the
- * filter only for the logger whose log method is called,
- * never for any of its parents. Also, parent loggers publish
- * log record whatever their level might be. This is pretty
- * weird, but GNU Classpath tries to be as compatible as
- * possible to the reference implementation.
- */
- for (int i = 0; i < curLogger.handlers.length; i++)
- curLogger.handlers[i].publish(record);
-
- if (curLogger.getUseParentHandlers() == false)
- break;
-
- curLogger = curLogger.getParent();
+ if (!isLoggable(record.getLevel()))
+ return;
+
+ if ((filter != null) && ! filter.isLoggable(record))
+ return;
+
+ /*
+ * If no logger name has been set for the log record, use the name of
+ * this logger.
+ */
+ if (record.getLoggerName() == null)
+ record.setLoggerName(name);
+
+ /*
+ * Avoid that some other thread is changing the logger hierarchy while
+ * we are traversing it.
+ */
+ synchronized (LogManager.getLogManager())
+ {
+ Logger curLogger = this;
+
+ do
+ {
+ /*
+ * The Sun J2SE 1.4 reference implementation seems to call the
+ * filter only for the logger whose log method is called, never
+ * for any of its parents. Also, parent loggers publish log
+ * record whatever their level might be. This is pretty weird,
+ * but GNU Classpath tries to be as compatible as possible to
+ * the reference implementation.
+ */
+ for (int i = 0; i < curLogger.handlers.length; i++)
+ curLogger.handlers[i].publish(record);
+
+ if (curLogger.getUseParentHandlers() == false)
+ break;
+
+ curLogger = curLogger.getParent();
+ }
+ while (parent != null);
+ }
}
- while (parent != null);
- }
}
-
public void log(Level level, String message)
{
if (isLoggable(level))
log(level, message, (Object[]) null);
}
-
- public synchronized void log(Level level,
- String message,
- Object param)
+ public void log(Level level, String message, Object param)
{
- if (isLoggable(level))
+ synchronized (lock)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- param);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level, caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message, param);
+ }
}
}
-
- public synchronized void log(Level level,
- String message,
- Object[] params)
+ public void log(Level level, String message, Object[] params)
{
- if (isLoggable(level))
+ synchronized (lock)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- params);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level, caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message, params);
+
+ }
}
}
-
- public synchronized void log(Level level,
- String message,
- Throwable thrown)
+ public void log(Level level, String message, Throwable thrown)
{
- if (isLoggable(level))
+ synchronized (lock)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- thrown);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level, caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message, thrown);
+ }
}
}
-
- public synchronized void logp(Level level,
- String sourceClass,
- String sourceMethod,
- String message)
+ public void logp(Level level, String sourceClass, String sourceMethod,
+ String message)
{
- logp(level, sourceClass, sourceMethod, message,
- (Object[]) null);
+ synchronized (lock)
+ {
+ logp(level, sourceClass, sourceMethod, message, (Object[]) null);
+ }
}
-
- public synchronized void logp(Level level,
- String sourceClass,
- String sourceMethod,
- String message,
- Object param)
+ public void logp(Level level, String sourceClass, String sourceMethod,
+ String message, Object param)
{
- logp(level, sourceClass, sourceMethod, message,
- new Object[] { param });
- }
+ synchronized (lock)
+ {
+ logp(level, sourceClass, sourceMethod, message, new Object[] { param });
+ }
+ }
- private synchronized ResourceBundle findResourceBundle()
+ private ResourceBundle findResourceBundle()
{
- if (resourceBundle != null)
- return resourceBundle;
+ synchronized (lock)
+ {
+ if (resourceBundle != null)
+ return resourceBundle;
- if (parent != null)
- return parent.findResourceBundle();
+ if (parent != null)
+ return parent.findResourceBundle();
- return null;
+ return null;
+ }
}
-
- private synchronized void logImpl(Level level,
- String sourceClass,
- String sourceMethod,
- String message,
- Object[] params)
+ private void logImpl(Level level, String sourceClass, String sourceMethod,
+ String message, Object[] params)
{
- LogRecord rec = new LogRecord(level, message);
+ synchronized (lock)
+ {
+ LogRecord rec = new LogRecord(level, message);
- rec.setResourceBundle(findResourceBundle());
- rec.setSourceClassName(sourceClass);
- rec.setSourceMethodName(sourceMethod);
- rec.setParameters(params);
+ rec.setResourceBundle(findResourceBundle());
+ rec.setSourceClassName(sourceClass);
+ rec.setSourceMethodName(sourceMethod);
+ rec.setParameters(params);
- log(rec);
+ log(rec);
+ }
}
-
- public synchronized void logp(Level level,
- String sourceClass,
- String sourceMethod,
- String message,
- Object[] params)
+ public void logp(Level level, String sourceClass, String sourceMethod,
+ String message, Object[] params)
{
- logImpl(level, sourceClass, sourceMethod, message, params);
+ synchronized (lock)
+ {
+ logImpl(level, sourceClass, sourceMethod, message, params);
+ }
}
-
- public synchronized void logp(Level level,
- String sourceClass,
- String sourceMethod,
- String message,
- Throwable thrown)
+ public void logp(Level level, String sourceClass, String sourceMethod,
+ String message, Throwable thrown)
{
- LogRecord rec = new LogRecord(level, message);
+ synchronized (lock)
+ {
+ LogRecord rec = new LogRecord(level, message);
- rec.setResourceBundle(resourceBundle);
- rec.setSourceClassName(sourceClass);
- rec.setSourceMethodName(sourceMethod);
- rec.setThrown(thrown);
+ rec.setResourceBundle(resourceBundle);
+ rec.setSourceClassName(sourceClass);
+ rec.setSourceMethodName(sourceMethod);
+ rec.setThrown(thrown);
- log(rec);
+ log(rec);
+ }
}
-
- public synchronized void logrb(Level level,
- String sourceClass,
- String sourceMethod,
- String bundleName,
- String message)
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String message)
{
- logrb(level, sourceClass, sourceMethod, bundleName,
- message, (Object[]) null);
+ synchronized (lock)
+ {
+ logrb(level, sourceClass, sourceMethod, bundleName, message,
+ (Object[]) null);
+ }
}
-
- public synchronized void logrb(Level level,
- String sourceClass,
- String sourceMethod,
- String bundleName,
- String message,
- Object param)
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String message, Object param)
{
- logrb(level, sourceClass, sourceMethod, bundleName,
- message, new Object[] { param });
+ synchronized (lock)
+ {
+ logrb(level, sourceClass, sourceMethod, bundleName, message,
+ new Object[] { param });
+ }
}
-
- public synchronized void logrb(Level level,
- String sourceClass,
- String sourceMethod,
- String bundleName,
- String message,
- Object[] params)
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String message, Object[] params)
{
- LogRecord rec = new LogRecord(level, message);
+ synchronized (lock)
+ {
+ LogRecord rec = new LogRecord(level, message);
- rec.setResourceBundleName(bundleName);
- rec.setSourceClassName(sourceClass);
- rec.setSourceMethodName(sourceMethod);
- rec.setParameters(params);
+ rec.setResourceBundleName(bundleName);
+ rec.setSourceClassName(sourceClass);
+ rec.setSourceMethodName(sourceMethod);
+ rec.setParameters(params);
- log(rec);
+ log(rec);
+ }
}
-
- public synchronized void logrb(Level level,
- String sourceClass,
- String sourceMethod,
- String bundleName,
- String message,
- Throwable thrown)
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String message, Throwable thrown)
{
- LogRecord rec = new LogRecord(level, message);
+ synchronized (lock)
+ {
+ LogRecord rec = new LogRecord(level, message);
- rec.setResourceBundleName(bundleName);
- rec.setSourceClassName(sourceClass);
- rec.setSourceMethodName(sourceMethod);
- rec.setThrown(thrown);
+ rec.setResourceBundleName(bundleName);
+ rec.setSourceClassName(sourceClass);
+ rec.setSourceMethodName(sourceMethod);
+ rec.setThrown(thrown);
- log(rec);
+ log(rec);
+ }
}
-
- public synchronized void entering(String sourceClass,
- String sourceMethod)
+ public void entering(String sourceClass, String sourceMethod)
{
- if (isLoggable(Level.FINER))
- logp(Level.FINER, sourceClass, sourceMethod, "ENTRY");
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINER))
+ logp(Level.FINER, sourceClass, sourceMethod, "ENTRY");
+ }
}
-
- public synchronized void entering(String sourceClass,
- String sourceMethod,
- Object param)
+ public void entering(String sourceClass, String sourceMethod, Object param)
{
- if (isLoggable(Level.FINER))
- logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", param);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINER))
+ logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", param);
+ }
}
-
- public synchronized void entering(String sourceClass,
- String sourceMethod,
- Object[] params)
+ public void entering(String sourceClass, String sourceMethod, Object[] params)
{
- if (isLoggable(Level.FINER))
- {
- StringBuffer buf = new StringBuffer(80);
- buf.append("ENTRY");
- for (int i = 0; i < params.length; i++)
+ synchronized (lock)
{
- buf.append(" {");
- buf.append(i);
- buf.append('}');
+ if (isLoggable(Level.FINER))
+ {
+ StringBuffer buf = new StringBuffer(80);
+ buf.append("ENTRY");
+ for (int i = 0; i < params.length; i++)
+ {
+ buf.append(" {");
+ buf.append(i);
+ buf.append('}');
+ }
+
+ logp(Level.FINER, sourceClass, sourceMethod, buf.toString(), params);
+ }
}
-
- logp(Level.FINER, sourceClass, sourceMethod, buf.toString(), params);
- }
}
-
- public synchronized void exiting(String sourceClass,
- String sourceMethod)
+ public void exiting(String sourceClass, String sourceMethod)
{
- if (isLoggable(Level.FINER))
- logp(Level.FINER, sourceClass, sourceMethod, "RETURN");
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINER))
+ logp(Level.FINER, sourceClass, sourceMethod, "RETURN");
+ }
}
-
- public synchronized void exiting(String sourceClass,
- String sourceMethod,
- Object result)
+ public void exiting(String sourceClass, String sourceMethod, Object result)
{
- if (isLoggable(Level.FINER))
- logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINER))
+ logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", result);
+ }
}
-
- public synchronized void throwing(String sourceClass,
- String sourceMethod,
- Throwable thrown)
+ public void throwing(String sourceClass, String sourceMethod, Throwable thrown)
{
- if (isLoggable(Level.FINER))
- logp(Level.FINER, sourceClass, sourceMethod, "THROW", thrown);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINER))
+ logp(Level.FINER, sourceClass, sourceMethod, "THROW", thrown);
+ }
}
-
/**
- * Logs a message with severity level SEVERE, indicating a serious
- * failure that prevents normal program execution. Messages at this
- * level should be understandable to an inexperienced, non-technical
- * end user. Ideally, they explain in simple words what actions the
- * user can take in order to resolve the problem.
- *
+ * Logs a message with severity level SEVERE, indicating a serious failure
+ * that prevents normal program execution. Messages at this level should be
+ * understandable to an inexperienced, non-technical end user. Ideally, they
+ * explain in simple words what actions the user can take in order to resolve
+ * the problem.
+ *
* @see Level#SEVERE
- *
- * @param message the message text, also used as look-up key if the
- * logger is localizing messages with a resource
- * bundle. While it is possible to pass
- * <code>null</code>, this is not recommended, since
- * a logging message without text is unlikely to be
- * helpful.
+ * @param message the message text, also used as look-up key if the logger is
+ * localizing messages with a resource bundle. While it is possible
+ * to pass <code>null</code>, this is not recommended, since a
+ * logging message without text is unlikely to be helpful.
*/
- public synchronized void severe(String message)
+ public void severe(String message)
{
- if (isLoggable(Level.SEVERE))
- log(Level.SEVERE, message);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.SEVERE))
+ log(Level.SEVERE, message);
+ }
}
-
/**
- * Logs a message with severity level WARNING, indicating a
- * potential problem that does not prevent normal program execution.
- * Messages at this level should be understandable to an
- * inexperienced, non-technical end user. Ideally, they explain in
- * simple words what actions the user can take in order to resolve
- * the problem.
- *
+ * Logs a message with severity level WARNING, indicating a potential problem
+ * that does not prevent normal program execution. Messages at this level
+ * should be understandable to an inexperienced, non-technical end user.
+ * Ideally, they explain in simple words what actions the user can take in
+ * order to resolve the problem.
+ *
* @see Level#WARNING
- *
- * @param message the message text, also used as look-up key if the
- * logger is localizing messages with a resource
- * bundle. While it is possible to pass
- * <code>null</code>, this is not recommended, since
- * a logging message without text is unlikely to be
- * helpful.
+ * @param message the message text, also used as look-up key if the logger is
+ * localizing messages with a resource bundle. While it is possible
+ * to pass <code>null</code>, this is not recommended, since a
+ * logging message without text is unlikely to be helpful.
*/
- public synchronized void warning(String message)
+ public void warning(String message)
{
- if (isLoggable(Level.WARNING))
- log(Level.WARNING, message);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.WARNING))
+ log(Level.WARNING, message);
+ }
}
-
/**
- * Logs a message with severity level INFO. {@link Level#INFO} is
- * intended for purely informational messages that do not indicate
- * error or warning situations. In the default logging
- * configuration, INFO messages will be written to the system
- * console. For this reason, the INFO level should be used only for
- * messages that are important to end users and system
- * administrators. Messages at this level should be understandable
- * to an inexperienced, non-technical user.
- *
- * @param message the message text, also used as look-up key if the
- * logger is localizing messages with a resource
- * bundle. While it is possible to pass
- * <code>null</code>, this is not recommended, since
- * a logging message without text is unlikely to be
- * helpful.
+ * Logs a message with severity level INFO. {@link Level#INFO} is intended for
+ * purely informational messages that do not indicate error or warning
+ * situations. In the default logging configuration, INFO messages will be
+ * written to the system console. For this reason, the INFO level should be
+ * used only for messages that are important to end users and system
+ * administrators. Messages at this level should be understandable to an
+ * inexperienced, non-technical user.
+ *
+ * @param message the message text, also used as look-up key if the logger is
+ * localizing messages with a resource bundle. While it is possible
+ * to pass <code>null</code>, this is not recommended, since a
+ * logging message without text is unlikely to be helpful.
*/
- public synchronized void info(String message)
+ public void info(String message)
{
- if (isLoggable(Level.INFO))
- log(Level.INFO, message);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.INFO))
+ log(Level.INFO, message);
+ }
}
-
/**
- * Logs a message with severity level CONFIG. {@link Level#CONFIG} is
- * intended for static configuration messages, for example about the
- * windowing environment, the operating system version, etc.
- *
- * @param message the message text, also used as look-up key if the
- * logger is localizing messages with a resource bundle. While
- * it is possible to pass <code>null</code>, this is not
- * recommended, since a logging message without text is unlikely
- * to be helpful.
+ * Logs a message with severity level CONFIG. {@link Level#CONFIG} is intended
+ * for static configuration messages, for example about the windowing
+ * environment, the operating system version, etc.
+ *
+ * @param message the message text, also used as look-up key if the logger is
+ * localizing messages with a resource bundle. While it is possible
+ * to pass <code>null</code>, this is not recommended, since a
+ * logging message without text is unlikely to be helpful.
*/
- public synchronized void config(String message)
+ public void config(String message)
{
- if (isLoggable(Level.CONFIG))
- log(Level.CONFIG, message);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.CONFIG))
+ log(Level.CONFIG, message);
+ }
}
-
/**
- * Logs a message with severity level FINE. {@link Level#FINE} is
- * intended for messages that are relevant for developers using
- * the component generating log messages. Examples include minor,
- * recoverable failures, or possible inefficiencies.
- *
- * @param message the message text, also used as look-up key if the
- * logger is localizing messages with a resource
- * bundle. While it is possible to pass
- * <code>null</code>, this is not recommended, since
- * a logging message without text is unlikely to be
- * helpful.
+ * Logs a message with severity level FINE. {@link Level#FINE} is intended for
+ * messages that are relevant for developers using the component generating
+ * log messages. Examples include minor, recoverable failures, or possible
+ * inefficiencies.
+ *
+ * @param message the message text, also used as look-up key if the logger is
+ * localizing messages with a resource bundle. While it is possible
+ * to pass <code>null</code>, this is not recommended, since a
+ * logging message without text is unlikely to be helpful.
*/
- public synchronized void fine(String message)
+ public void fine(String message)
{
- if (isLoggable(Level.FINE))
- log(Level.FINE, message);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINE))
+ log(Level.FINE, message);
+ }
}
-
/**
- * Logs a message with severity level FINER. {@link Level#FINER} is
- * intended for rather detailed tracing, for example entering a
- * method, returning from a method, or throwing an exception.
- *
- * @param message the message text, also used as look-up key if the
- * logger is localizing messages with a resource
- * bundle. While it is possible to pass
- * <code>null</code>, this is not recommended, since
- * a logging message without text is unlikely to be
- * helpful.
+ * Logs a message with severity level FINER. {@link Level#FINER} is intended
+ * for rather detailed tracing, for example entering a method, returning from
+ * a method, or throwing an exception.
+ *
+ * @param message the message text, also used as look-up key if the logger is
+ * localizing messages with a resource bundle. While it is possible
+ * to pass <code>null</code>, this is not recommended, since a
+ * logging message without text is unlikely to be helpful.
*/
- public synchronized void finer(String message)
+ public void finer(String message)
{
- if (isLoggable(Level.FINER))
- log(Level.FINER, message);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINER))
+ log(Level.FINER, message);
+ }
}
-
/**
- * Logs a message with severity level FINEST. {@link Level#FINEST}
- * is intended for highly detailed tracing, for example reaching a
- * certain point inside the body of a method.
- *
- * @param message the message text, also used as look-up key if the
- * logger is localizing messages with a resource
- * bundle. While it is possible to pass
- * <code>null</code>, this is not recommended, since
- * a logging message without text is unlikely to be
- * helpful.
+ * Logs a message with severity level FINEST. {@link Level#FINEST} is intended
+ * for highly detailed tracing, for example reaching a certain point inside
+ * the body of a method.
+ *
+ * @param message the message text, also used as look-up key if the logger is
+ * localizing messages with a resource bundle. While it is possible
+ * to pass <code>null</code>, this is not recommended, since a
+ * logging message without text is unlikely to be helpful.
*/
- public synchronized void finest(String message)
+ public void finest(String message)
{
- if (isLoggable(Level.FINEST))
- log(Level.FINEST, message);
+ synchronized (lock)
+ {
+ if (isLoggable(Level.FINEST))
+ log(Level.FINEST, message);
+ }
}
-
/**
- * Adds a handler to the set of handlers that get notified
- * when a log record is to be published.
- *
+ * Adds a handler to the set of handlers that get notified when a log record
+ * is to be published.
+ *
* @param handler the handler to be added.
- *
- * @throws NullPointerException if <code>handler</code>
- * is <code>null</code>.
- *
- * @throws SecurityException if this logger is not anonymous, a
- * security manager exists, and the caller is not granted
- * the permission to control the logging infrastructure by
- * having LoggingPermission("control"). Untrusted code can
- * obtain an anonymous logger through the static factory method
- * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+ * @throws NullPointerException if <code>handler</code> is <code>null</code>.
+ * @throws SecurityException if this logger is not anonymous, a security
+ * manager exists, and the caller is not granted the permission to
+ * control the logging infrastructure by having
+ * LoggingPermission("control"). Untrusted code can obtain an
+ * anonymous logger through the static factory method
+ * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
*/
- public synchronized void addHandler(Handler handler)
- throws SecurityException
+ public void addHandler(Handler handler) throws SecurityException
{
- if (handler == null)
- throw new NullPointerException();
-
- /* An application is allowed to control an anonymous logger
- * without having the permission to control the logging
- * infrastructure.
- */
- if (!anonymous)
- LogManager.getLogManager().checkAccess();
-
- if (!handlerList.contains(handler))
- {
- handlerList.add(handler);
- handlers = getHandlers();
- }
+ synchronized (lock)
+ {
+ if (handler == null)
+ throw new NullPointerException();
+
+ /*
+ * An application is allowed to control an anonymous logger without
+ * having the permission to control the logging infrastructure.
+ */
+ if (! anonymous)
+ LogManager.getLogManager().checkAccess();
+
+ if (! handlerList.contains(handler))
+ {
+ handlerList.add(handler);
+ handlers = getHandlers();
+ }
+ }
}
-
/**
- * Removes a handler from the set of handlers that get notified
- * when a log record is to be published.
- *
+ * Removes a handler from the set of handlers that get notified when a log
+ * record is to be published.
+ *
* @param handler the handler to be removed.
- *
- * @throws SecurityException if this logger is not anonymous, a
- * security manager exists, and the caller is not granted the
- * permission to control the logging infrastructure by having
- * LoggingPermission("control"). Untrusted code can obtain an
- * anonymous logger through the static factory method {@link
- * #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
- *
- * @throws NullPointerException if <code>handler</code>
- * is <code>null</code>.
+ * @throws SecurityException if this logger is not anonymous, a security
+ * manager exists, and the caller is not granted the permission to
+ * control the logging infrastructure by having
+ * LoggingPermission("control"). Untrusted code can obtain an
+ * anonymous logger through the static factory method {@link
+ * #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+ * @throws NullPointerException if <code>handler</code> is <code>null</code>.
*/
- public synchronized void removeHandler(Handler handler)
- throws SecurityException
+ public void removeHandler(Handler handler) throws SecurityException
{
- /* An application is allowed to control an anonymous logger
- * without having the permission to control the logging
- * infrastructure.
- */
- if (!anonymous)
- LogManager.getLogManager().checkAccess();
-
- if (handler == null)
- throw new NullPointerException();
-
- handlerList.remove(handler);
- handlers = getHandlers();
+ synchronized (lock)
+ {
+ /*
+ * An application is allowed to control an anonymous logger without
+ * having the permission to control the logging infrastructure.
+ */
+ if (! anonymous)
+ LogManager.getLogManager().checkAccess();
+
+ if (handler == null)
+ throw new NullPointerException();
+
+ handlerList.remove(handler);
+ handlers = getHandlers();
+ }
}
-
/**
- * Returns the handlers currently registered for this Logger.
- * When a log record has been deemed as being loggable,
- * it will be passed to all registered handlers for
- * publication. In addition, if the logger uses parent handlers
- * (see {@link #getUseParentHandlers() getUseParentHandlers}
- * and {@link #setUseParentHandlers(boolean) setUseParentHandlers},
- * the log record will be passed to the parent's handlers.
+ * Returns the handlers currently registered for this Logger. When a log
+ * record has been deemed as being loggable, it will be passed to all
+ * registered handlers for publication. In addition, if the logger uses parent
+ * handlers (see {@link #getUseParentHandlers() getUseParentHandlers} and
+ * {@link #setUseParentHandlers(boolean) setUseParentHandlers}, the log
+ * record will be passed to the parent's handlers.
*/
- public synchronized Handler[] getHandlers()
+ public Handler[] getHandlers()
{
- /* We cannot return our internal handlers array
- * because we do not have any guarantee that the
- * caller would not change the array entries.
- */
- return (Handler[]) handlerList.toArray(new Handler[handlerList.size()]);
+ synchronized (lock)
+ {
+ /*
+ * We cannot return our internal handlers array because we do not have
+ * any guarantee that the caller would not change the array entries.
+ */
+ return (Handler[]) handlerList.toArray(new Handler[handlerList.size()]);
+ }
}
-
/**
- * Returns whether or not this Logger forwards log records to
- * handlers registered for its parent loggers.
- *
- * @return <code>false</code> if this Logger sends log records
- * merely to Handlers registered with itself;
- * <code>true</code> if this Logger sends log records
- * not only to Handlers registered with itself, but also
- * to those Handlers registered with parent loggers.
+ * Returns whether or not this Logger forwards log records to handlers
+ * registered for its parent loggers.
+ *
+ * @return <code>false</code> if this Logger sends log records merely to
+ * Handlers registered with itself; <code>true</code> if this Logger
+ * sends log records not only to Handlers registered with itself, but
+ * also to those Handlers registered with parent loggers.
*/
- public synchronized boolean getUseParentHandlers()
+ public boolean getUseParentHandlers()
{
- return useParentHandlers;
+ synchronized (lock)
+ {
+ return useParentHandlers;
+ }
}
-
/**
- * Sets whether or not this Logger forwards log records to
- * handlers registered for its parent loggers.
- *
- * @param useParentHandlers <code>false</code> to let this
- * Logger send log records merely to Handlers registered
- * with itself; <code>true</code> to let this Logger
- * send log records not only to Handlers registered
- * with itself, but also to those Handlers registered with
- * parent loggers.
- *
- * @throws SecurityException if this logger is not anonymous, a
- * security manager exists, and the caller is not granted
- * the permission to control the logging infrastructure by
- * having LoggingPermission("control"). Untrusted code can
- * obtain an anonymous logger through the static factory method
- * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
- *
+ * Sets whether or not this Logger forwards log records to handlers registered
+ * for its parent loggers.
+ *
+ * @param useParentHandlers <code>false</code> to let this Logger send log
+ * records merely to Handlers registered with itself;
+ * <code>true</code> to let this Logger send log records not only
+ * to Handlers registered with itself, but also to those Handlers
+ * registered with parent loggers.
+ * @throws SecurityException if this logger is not anonymous, a security
+ * manager exists, and the caller is not granted the permission to
+ * control the logging infrastructure by having
+ * LoggingPermission("control"). Untrusted code can obtain an
+ * anonymous logger through the static factory method
+ * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
*/
- public synchronized void setUseParentHandlers(boolean useParentHandlers)
+ public void setUseParentHandlers(boolean useParentHandlers)
{
- /* An application is allowed to control an anonymous logger
- * without having the permission to control the logging
- * infrastructure.
- */
- if (!anonymous)
- LogManager.getLogManager().checkAccess();
-
- this.useParentHandlers = useParentHandlers;
+ synchronized (lock)
+ {
+ /*
+ * An application is allowed to control an anonymous logger without
+ * having the permission to control the logging infrastructure.
+ */
+ if (! anonymous)
+ LogManager.getLogManager().checkAccess();
+
+ this.useParentHandlers = useParentHandlers;
+ }
}
-
/**
- * Returns the parent of this logger. By default, the parent is
- * assigned by the LogManager by inspecting the logger's name.
- *
- * @return the parent of this logger (as detemined by the LogManager
- * by inspecting logger names), the root logger if no other
- * logger has a name which is a prefix of this logger's name, or
- * <code>null</code> for the root logger.
+ * Returns the parent of this logger. By default, the parent is assigned by
+ * the LogManager by inspecting the logger's name.
+ *
+ * @return the parent of this logger (as detemined by the LogManager by
+ * inspecting logger names), the root logger if no other logger has a
+ * name which is a prefix of this logger's name, or <code>null</code>
+ * for the root logger.
*/
- public synchronized Logger getParent()
+ public Logger getParent()
{
- return parent;
+ synchronized (lock)
+ {
+ return parent;
+ }
}
-
/**
- * Sets the parent of this logger. Usually, applications do not
- * call this method directly. Instead, the LogManager will ensure
- * that the tree of loggers reflects the hierarchical logger
- * namespace. Basically, this method should not be public at all,
- * but the GNU implementation follows the API specification.
- *
- * @throws NullPointerException if <code>parent</code> is
- * <code>null</code>.
- *
- * @throws SecurityException if this logger is not anonymous, a
- * security manager exists, and the caller is not granted
- * the permission to control the logging infrastructure by
- * having LoggingPermission("control"). Untrusted code can
- * obtain an anonymous logger through the static factory method
- * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
+ * Sets the parent of this logger. Usually, applications do not call this
+ * method directly. Instead, the LogManager will ensure that the tree of
+ * loggers reflects the hierarchical logger namespace. Basically, this method
+ * should not be public at all, but the GNU implementation follows the API
+ * specification.
+ *
+ * @throws NullPointerException if <code>parent</code> is <code>null</code>.
+ * @throws SecurityException if this logger is not anonymous, a security
+ * manager exists, and the caller is not granted the permission to
+ * control the logging infrastructure by having
+ * LoggingPermission("control"). Untrusted code can obtain an
+ * anonymous logger through the static factory method
+ * {@link #getAnonymousLogger(java.lang.String) getAnonymousLogger}.
*/
- public synchronized void setParent(Logger parent)
+ public void setParent(Logger parent)
{
- if (parent == null)
- throw new NullPointerException();
+ synchronized (lock)
+ {
+ if (parent == null)
+ throw new NullPointerException();
- if (this == root)
- throw new IllegalArgumentException(
- "the root logger can only have a null parent");
+ if (this == root)
+ throw new IllegalArgumentException(
+ "the root logger can only have a null parent");
- /* An application is allowed to control an anonymous logger
- * without having the permission to control the logging
- * infrastructure.
- */
- if (!anonymous)
- LogManager.getLogManager().checkAccess();
+ /*
+ * An application is allowed to control an anonymous logger without
+ * having the permission to control the logging infrastructure.
+ */
+ if (! anonymous)
+ LogManager.getLogManager().checkAccess();
- this.parent = parent;
+ this.parent = parent;
+ }
}
-
+
/**
- * Gets the StackTraceElement of the first class that is not this class.
- * That should be the initial caller of a logging method.
+ * Gets the StackTraceElement of the first class that is not this class. That
+ * should be the initial caller of a logging method.
+ *
* @return caller of the initial logging method or null if unknown.
*/
private StackTraceElement getCallerStackFrame()
@@ -1195,18 +1163,18 @@ public class Logger
int index = 0;
// skip to stackentries until this class
- while(index < stackTrace.length
- && !stackTrace[index].getClassName().equals(getClass().getName()))
+ while (index < stackTrace.length
+ && ! stackTrace[index].getClassName().equals(getClass().getName()))
index++;
// skip the stackentries of this class
- while(index < stackTrace.length
- && stackTrace[index].getClassName().equals(getClass().getName()))
+ while (index < stackTrace.length
+ && stackTrace[index].getClassName().equals(getClass().getName()))
index++;
return index < stackTrace.length ? stackTrace[index] : null;
}
-
+
/**
* Reset and close handlers attached to this logger. This function is package
* private because it must only be available to the LogManager.
diff --git a/libjava/classpath/java/util/zip/ZipEntry.java b/libjava/classpath/java/util/zip/ZipEntry.java
index 9b7afa0..893f043 100644
--- a/libjava/classpath/java/util/zip/ZipEntry.java
+++ b/libjava/classpath/java/util/zip/ZipEntry.java
@@ -357,7 +357,7 @@ public class ZipEntry implements ZipConstants, Cloneable
| (extra[pos+2] & 0xff) << 8
| (extra[pos+3] & 0xff) << 16
| (extra[pos+4] & 0xff) << 24);
- setTime(time);
+ setTime(time*1000);
}
}
pos += len;