summaryrefslogtreecommitdiff
path: root/libjava/classpath/java
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-15 23:20:01 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-15 23:20:01 +0000
commit3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 (patch)
treea5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/java
parent7e55c49d7d91ef9f09e93c1100119b1ab3652446 (diff)
downloadgcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.tar.gz
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java')
-rw-r--r--libjava/classpath/java/applet/Applet.java76
-rw-r--r--libjava/classpath/java/awt/BorderLayout.java130
-rw-r--r--libjava/classpath/java/awt/Button.java2
-rw-r--r--libjava/classpath/java/awt/Canvas.java14
-rw-r--r--libjava/classpath/java/awt/Checkbox.java11
-rw-r--r--libjava/classpath/java/awt/CheckboxMenuItem.java2
-rw-r--r--libjava/classpath/java/awt/Choice.java4
-rw-r--r--libjava/classpath/java/awt/Color.java2
-rw-r--r--libjava/classpath/java/awt/ColorPaintContext.java4
-rw-r--r--libjava/classpath/java/awt/Component.java89
-rw-r--r--libjava/classpath/java/awt/Container.java132
-rw-r--r--libjava/classpath/java/awt/DefaultKeyboardFocusManager.java4
-rw-r--r--libjava/classpath/java/awt/Dialog.java2
-rw-r--r--libjava/classpath/java/awt/EventQueue.java1
-rw-r--r--libjava/classpath/java/awt/Font.java2070
-rw-r--r--libjava/classpath/java/awt/FontMetrics.java21
-rw-r--r--libjava/classpath/java/awt/Frame.java2
-rw-r--r--libjava/classpath/java/awt/Graphics.java1291
-rw-r--r--libjava/classpath/java/awt/GraphicsConfiguration.java5
-rw-r--r--libjava/classpath/java/awt/GridBagLayout.java23
-rw-r--r--libjava/classpath/java/awt/Image.java20
-rw-r--r--libjava/classpath/java/awt/KeyboardFocusManager.java75
-rw-r--r--libjava/classpath/java/awt/List.java15
-rw-r--r--libjava/classpath/java/awt/Menu.java2
-rw-r--r--libjava/classpath/java/awt/MenuComponent.java4
-rw-r--r--libjava/classpath/java/awt/MenuItem.java2
-rw-r--r--libjava/classpath/java/awt/Point.java4
-rw-r--r--libjava/classpath/java/awt/Polygon.java1
-rw-r--r--libjava/classpath/java/awt/PopupMenu.java2
-rw-r--r--libjava/classpath/java/awt/Rectangle.java4
-rw-r--r--libjava/classpath/java/awt/ScrollPane.java4
-rw-r--r--libjava/classpath/java/awt/ScrollPaneAdjustable.java8
-rw-r--r--libjava/classpath/java/awt/TextArea.java2
-rw-r--r--libjava/classpath/java/awt/TextComponent.java2
-rw-r--r--libjava/classpath/java/awt/TextField.java2
-rw-r--r--libjava/classpath/java/awt/Window.java110
-rw-r--r--libjava/classpath/java/awt/color/ICC_Profile.java18
-rw-r--r--libjava/classpath/java/awt/event/InputEvent.java41
-rw-r--r--libjava/classpath/java/awt/event/InvocationEvent.java25
-rw-r--r--libjava/classpath/java/awt/event/KeyEvent.java2
-rw-r--r--libjava/classpath/java/awt/event/MouseEvent.java23
-rw-r--r--libjava/classpath/java/awt/geom/Area.java2
-rw-r--r--libjava/classpath/java/awt/geom/GeneralPath.java3
-rw-r--r--libjava/classpath/java/awt/im/InputContext.java3
-rw-r--r--libjava/classpath/java/awt/im/InputMethodHighlight.java5
-rw-r--r--libjava/classpath/java/awt/im/InputMethodRequests.java2
-rw-r--r--libjava/classpath/java/awt/im/spi/InputMethod.java10
-rw-r--r--libjava/classpath/java/awt/im/spi/InputMethodContext.java4
-rw-r--r--libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java3
-rw-r--r--libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java2
-rw-r--r--libjava/classpath/java/awt/image/BufferedImage.java18
-rw-r--r--libjava/classpath/java/awt/image/ColorModel.java2
-rw-r--r--libjava/classpath/java/awt/image/ComponentSampleModel.java8
-rw-r--r--libjava/classpath/java/awt/image/ImageConsumer.java2
-rw-r--r--libjava/classpath/java/awt/image/PackedColorModel.java6
-rw-r--r--libjava/classpath/java/awt/image/SampleModel.java3
-rw-r--r--libjava/classpath/java/awt/print/PrinterJob.java7
-rw-r--r--libjava/classpath/java/beans/IndexedPropertyDescriptor.java610
-rw-r--r--libjava/classpath/java/beans/PropertyDescriptor.java17
-rw-r--r--libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java2
-rw-r--r--libjava/classpath/java/beans/beancontext/BeanContextSupport.java2
-rw-r--r--libjava/classpath/java/io/ByteArrayOutputStream.java5
-rw-r--r--libjava/classpath/java/io/DataOutputStream.java6
-rw-r--r--libjava/classpath/java/io/File.java39
-rw-r--r--libjava/classpath/java/io/FileWriter.java2
-rw-r--r--libjava/classpath/java/io/FilterReader.java2
-rw-r--r--libjava/classpath/java/io/InputStreamReader.java25
-rw-r--r--libjava/classpath/java/io/LineNumberReader.java6
-rw-r--r--libjava/classpath/java/io/ObjectInputStream.java588
-rw-r--r--libjava/classpath/java/io/ObjectOutputStream.java79
-rw-r--r--libjava/classpath/java/io/ObjectStreamField.java2
-rw-r--r--libjava/classpath/java/io/OutputStreamWriter.java160
-rw-r--r--libjava/classpath/java/io/PipedInputStream.java2
-rw-r--r--libjava/classpath/java/io/PrintWriter.java75
-rw-r--r--libjava/classpath/java/io/PushbackInputStream.java9
-rw-r--r--libjava/classpath/java/lang/Boolean.java32
-rw-r--r--libjava/classpath/java/lang/Byte.java32
-rw-r--r--libjava/classpath/java/lang/Character.java275
-rw-r--r--libjava/classpath/java/lang/Class.java11
-rw-r--r--libjava/classpath/java/lang/ClassLoader.java36
-rw-r--r--libjava/classpath/java/lang/Double.java23
-rw-r--r--libjava/classpath/java/lang/EnumConstantNotPresentException.java93
-rw-r--r--libjava/classpath/java/lang/Float.java22
-rw-r--r--libjava/classpath/java/lang/Integer.java4
-rw-r--r--libjava/classpath/java/lang/Long.java153
-rw-r--r--libjava/classpath/java/lang/Object.java4
-rw-r--r--libjava/classpath/java/lang/Process.java1
-rw-r--r--libjava/classpath/java/lang/Readable.java1
-rw-r--r--libjava/classpath/java/lang/RuntimePermission.java1
-rw-r--r--libjava/classpath/java/lang/SecurityManager.java30
-rw-r--r--libjava/classpath/java/lang/Short.java44
-rw-r--r--libjava/classpath/java/lang/StrictMath.java10
-rw-r--r--libjava/classpath/java/lang/String.java207
-rw-r--r--libjava/classpath/java/lang/StringBuffer.java259
-rw-r--r--libjava/classpath/java/lang/StringBuilder.java65
-rw-r--r--libjava/classpath/java/lang/System.java2
-rw-r--r--libjava/classpath/java/lang/Thread.java12
-rw-r--r--libjava/classpath/java/lang/ThreadLocal.java1
-rw-r--r--libjava/classpath/java/lang/ref/Reference.java6
-rw-r--r--libjava/classpath/java/lang/ref/WeakReference.java2
-rw-r--r--libjava/classpath/java/lang/reflect/Member.java4
-rw-r--r--libjava/classpath/java/lang/reflect/Proxy.java19
-rw-r--r--libjava/classpath/java/lang/reflect/UndeclaredThrowableException.java2
-rw-r--r--libjava/classpath/java/math/BigDecimal.java19
-rw-r--r--libjava/classpath/java/math/BigInteger.java19
-rw-r--r--libjava/classpath/java/net/DatagramSocket.java1
-rw-r--r--libjava/classpath/java/net/Inet4Address.java2
-rw-r--r--libjava/classpath/java/net/InetSocketAddress.java2
-rw-r--r--libjava/classpath/java/net/ServerSocket.java4
-rw-r--r--libjava/classpath/java/net/Socket.java9
-rw-r--r--libjava/classpath/java/net/URLClassLoader.java110
-rw-r--r--libjava/classpath/java/net/URLConnection.java8
-rw-r--r--libjava/classpath/java/net/URLStreamHandler.java22
-rw-r--r--libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java6
-rw-r--r--libjava/classpath/java/nio/charset/Charset.java27
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java110
-rw-r--r--libjava/classpath/java/rmi/server/LoaderHandler.java6
-rw-r--r--libjava/classpath/java/rmi/server/RMIClassLoader.java312
-rw-r--r--libjava/classpath/java/rmi/server/RemoteObject.java4
-rw-r--r--libjava/classpath/java/rmi/server/RemoteRef.java6
-rw-r--r--libjava/classpath/java/security/AccessControlContext.java34
-rw-r--r--libjava/classpath/java/security/AccessController.java16
-rw-r--r--libjava/classpath/java/security/Identity.java8
-rw-r--r--libjava/classpath/java/security/Security.java4
-rw-r--r--libjava/classpath/java/text/AttributedString.java48
-rw-r--r--libjava/classpath/java/text/AttributedStringIterator.java183
-rw-r--r--libjava/classpath/java/text/CharacterIterator.java2
-rw-r--r--libjava/classpath/java/text/DateFormat.java3
-rw-r--r--libjava/classpath/java/text/ParsePosition.java9
-rw-r--r--libjava/classpath/java/text/RuleBasedCollator.java2
-rw-r--r--libjava/classpath/java/text/StringCharacterIterator.java12
-rw-r--r--libjava/classpath/java/util/ArrayList.java4
-rw-r--r--libjava/classpath/java/util/Arrays.java180
-rw-r--r--libjava/classpath/java/util/Calendar.java23
-rw-r--r--libjava/classpath/java/util/Collections.java17
-rw-r--r--libjava/classpath/java/util/GregorianCalendar.java14
-rw-r--r--libjava/classpath/java/util/HashMap.java2
-rw-r--r--libjava/classpath/java/util/InvalidPropertiesFormatException.java57
-rw-r--r--libjava/classpath/java/util/Locale.java4
-rw-r--r--libjava/classpath/java/util/Map.java8
-rw-r--r--libjava/classpath/java/util/Properties.java348
-rw-r--r--libjava/classpath/java/util/Random.java2
-rw-r--r--libjava/classpath/java/util/ResourceBundle.java9
-rw-r--r--libjava/classpath/java/util/SimpleTimeZone.java3
-rw-r--r--libjava/classpath/java/util/Timer.java93
-rw-r--r--libjava/classpath/java/util/TreeMap.java2
-rw-r--r--libjava/classpath/java/util/WeakHashMap.java28
-rw-r--r--libjava/classpath/java/util/jar/Manifest.java8
-rw-r--r--libjava/classpath/java/util/logging/FileHandler.java4
-rw-r--r--libjava/classpath/java/util/logging/Handler.java6
-rw-r--r--libjava/classpath/java/util/logging/LogManager.java4
-rw-r--r--libjava/classpath/java/util/logging/LoggingPermission.java2
-rw-r--r--libjava/classpath/java/util/logging/SimpleFormatter.java2
-rw-r--r--libjava/classpath/java/util/logging/XMLFormatter.java2
-rw-r--r--libjava/classpath/java/util/prefs/Preferences.java28
-rw-r--r--libjava/classpath/java/util/regex/Matcher.java8
-rw-r--r--libjava/classpath/java/util/zip/PendingBuffer.java2
-rw-r--r--libjava/classpath/java/util/zip/ZipFile.java17
158 files changed, 5927 insertions, 3251 deletions
diff --git a/libjava/classpath/java/applet/Applet.java b/libjava/classpath/java/applet/Applet.java
index d0610ba0ea1..bb855351b8d 100644
--- a/libjava/classpath/java/applet/Applet.java
+++ b/libjava/classpath/java/applet/Applet.java
@@ -54,6 +54,10 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.UnsupportedAudioFileException;
/**
* This is the base applet class. An applet is a Java program that
@@ -257,8 +261,6 @@ public class Applet extends Panel
* Returns an audio clip from the specified URL. This clip is not tied to
* any particular applet.
*
- * XXX Classpath does not yet implement this.
- *
* @param url the URL of the audio clip
* @return the retrieved audio clip
* @throws NullPointerException if url is null
@@ -267,8 +269,7 @@ public class Applet extends Panel
*/
public static final AudioClip newAudioClip(URL url)
{
- // This requires an implementation of AudioClip in gnu.java.applet.
- throw new Error("Not implemented");
+ return new URLAudioClip(url);
}
/**
@@ -521,4 +522,71 @@ public class Applet extends Panel
return s;
}
} // class AccessibleApplet
+
+ private static class URLAudioClip implements AudioClip
+ {
+ // The URL we will try to play.
+ // This is null if we have already tried to create an
+ // audio input stream from this URL.
+ private URL url;
+
+ // The real audio clip. This is null before the URL is read,
+ // and might be null afterward if we were unable to read the URL
+ // for some reason.
+ private Clip clip;
+
+ public URLAudioClip(URL url)
+ {
+ this.url = url;
+ }
+
+ private synchronized Clip getClip()
+ {
+ if (url == null)
+ return clip;
+ try
+ {
+ clip = AudioSystem.getClip();
+ clip.open(AudioSystem.getAudioInputStream(url));
+ }
+ catch (LineUnavailableException _)
+ {
+ // Ignore.
+ }
+ catch (IOException _)
+ {
+ // Ignore.
+ }
+ catch (UnsupportedAudioFileException _)
+ {
+ // Ignore.
+ }
+ url = null;
+ return clip;
+ }
+
+ public void loop()
+ {
+ Clip myclip = getClip();
+ if (myclip != null)
+ myclip.loop(Clip.LOOP_CONTINUOUSLY);
+ }
+
+ public void play()
+ {
+ Clip myclip = getClip();
+ if (myclip != null)
+ myclip.start();
+ }
+
+ public void stop()
+ {
+ Clip myclip = getClip();
+ if (myclip != null)
+ {
+ myclip.stop();
+ myclip.setFramePosition(0);
+ }
+ }
+ }
} // class Applet
diff --git a/libjava/classpath/java/awt/BorderLayout.java b/libjava/classpath/java/awt/BorderLayout.java
index adf2ebf65f6..1b67c01cfcb 100644
--- a/libjava/classpath/java/awt/BorderLayout.java
+++ b/libjava/classpath/java/awt/BorderLayout.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt;
+
/**
* This class implements a layout manager that positions components
* in certain sectors of the parent container.
@@ -229,6 +230,12 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
private int vgap;
+ // Some constants for use with calcSize().
+ private static final int MIN = 0;
+ private static final int MAX = 1;
+ private static final int PREF = 2;
+
+
/**
* Initializes a new instance of <code>BorderLayout</code> with no
* horiztonal or vertical gaps between components.
@@ -423,7 +430,7 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
*/
public float getLayoutAlignmentX(Container parent)
{
- return(parent.getAlignmentX());
+ return 0.5F;
}
/**
@@ -438,7 +445,7 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
*/
public float getLayoutAlignmentY(Container parent)
{
- return(parent.getAlignmentY());
+ return 0.5F;
}
/**
@@ -449,7 +456,7 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
*/
public void invalidateLayout(Container parent)
{
- // FIXME: Implement this properly!
+ // Nothing to do here.
}
/**
@@ -560,7 +567,8 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
}
/**
- * FIXME: Document me!
+ * This is a convenience method to set the bounds on a component.
+ * If the indicated component is null, nothing is done.
*/
private void setBounds(Component comp, int x, int y, int w, int h)
{
@@ -569,12 +577,6 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
comp.setBounds(x, y, w, h);
}
- // FIXME: Maybe move to top of file.
- // Some constants for use with calcSize().
- private static final int MIN = 0;
- private static final int MAX = 1;
- private static final int PREF = 2;
-
private Dimension calcCompSize(Component comp, int what)
{
if (comp == null || !comp.isVisible())
@@ -660,4 +662,112 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
return(new Dimension(width, height));
}
}
+
+ /**
+ * Return the component at the indicated location, or null if no component
+ * is at that location. The constraints argument must be one of the
+ * location constants specified by this class.
+ * @param constraints the location
+ * @return the component at that location, or null
+ * @throws IllegalArgumentException if the constraints argument is not
+ * recognized
+ * @since 1.5
+ */
+ public Component getLayoutComponent(Object constraints)
+ {
+ if (constraints == CENTER)
+ return center;
+ if (constraints == NORTH)
+ return north;
+ if (constraints == EAST)
+ return east;
+ if (constraints == SOUTH)
+ return south;
+ if (constraints == WEST)
+ return west;
+ if (constraints == PAGE_START)
+ return firstLine;
+ if (constraints == PAGE_END)
+ return lastLine;
+ if (constraints == LINE_START)
+ return firstItem;
+ if (constraints == LINE_END)
+ return lastItem;
+ throw new IllegalArgumentException("constraint " + constraints
+ + " is not recognized");
+ }
+
+ /**
+ * Return the component at the specified location, which must be one
+ * of the absolute constants such as CENTER or SOUTH. The container's
+ * orientation is used to map this location to the correct corresponding
+ * component, so for instance in a right-to-left container, a request
+ * for the EAST component could return the LINE_END component. This will
+ * return null if no component is available at the given location.
+ * @param container the container whose orientation is used
+ * @param constraints the absolute location of the component
+ * @return the component at the location, or null
+ * @throws IllegalArgumentException if the constraint is not recognized
+ */
+ public Component getLayoutComponent(Container container, Object constraints)
+ {
+ ComponentOrientation orient = container.getComponentOrientation();
+ if (constraints == CENTER)
+ return center;
+ // Note that we don't support vertical layouts.
+ if (constraints == NORTH)
+ return north;
+ if (constraints == SOUTH)
+ return south;
+ if (constraints == WEST)
+ {
+ // Note that relative layout takes precedence.
+ if (orient.isLeftToRight())
+ return firstItem == null ? west : firstItem;
+ return lastItem == null ? west : lastItem;
+ }
+ if (constraints == EAST)
+ {
+ // Note that relative layout takes precedence.
+ if (orient.isLeftToRight())
+ return lastItem == null ? east : lastItem;
+ return firstItem == null ? east : firstItem;
+ }
+ throw new IllegalArgumentException("constraint " + constraints
+ + " is not recognized");
+ }
+
+ /**
+ * Return the constraint corresponding to a component in this layout.
+ * If the component is null, or is not in this layout, returns null.
+ * Otherwise, this will return one of the constraint constants defined
+ * in this class.
+ * @param c the component
+ * @return the constraint, or null
+ * @since 1.5
+ */
+ public Object getConstraints(Component c)
+ {
+ if (c == null)
+ return null;
+ if (c == center)
+ return CENTER;
+ if (c == north)
+ return NORTH;
+ if (c == east)
+ return EAST;
+ if (c == south)
+ return SOUTH;
+ if (c == west)
+ return WEST;
+ if (c == firstLine)
+ return PAGE_START;
+ if (c == lastLine)
+ return PAGE_END;
+ if (c == firstItem)
+ return LINE_START;
+ if (c == lastItem)
+ return LINE_END;
+ return null;
+ }
}
diff --git a/libjava/classpath/java/awt/Button.java b/libjava/classpath/java/awt/Button.java
index 90be1e5b111..e788d824ee1 100644
--- a/libjava/classpath/java/awt/Button.java
+++ b/libjava/classpath/java/awt/Button.java
@@ -98,6 +98,8 @@ private transient ActionListener action_listeners;
protected class AccessibleAWTButton extends AccessibleAWTComponent
implements AccessibleAction, AccessibleValue
{
+ public static final long serialVersionUID = -5932203980244017102L;
+
protected AccessibleAWTButton()
{
// Do nothing here.
diff --git a/libjava/classpath/java/awt/Canvas.java b/libjava/classpath/java/awt/Canvas.java
index fe2f854847a..b599582ba93 100644
--- a/libjava/classpath/java/awt/Canvas.java
+++ b/libjava/classpath/java/awt/Canvas.java
@@ -292,8 +292,8 @@ public class Canvas
*
* @since 1.4
*/
- public void createBufferStrategy(int numBuffers,
- BufferCapabilities caps)
+ public void createBufferStrategy(int numBuffers, BufferCapabilities caps)
+ throws AWTException
{
if (numBuffers < 1)
throw new IllegalArgumentException("Canvas.createBufferStrategy: number"
@@ -305,15 +305,7 @@ public class Canvas
// a flipping strategy was requested
if (caps.isPageFlipping())
- {
- try
- {
- bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
- }
- catch (AWTException e)
- {
- }
- }
+ bufferStrategy = new CanvasFlipBufferStrategy(numBuffers);
else
bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true);
}
diff --git a/libjava/classpath/java/awt/Checkbox.java b/libjava/classpath/java/awt/Checkbox.java
index cd39ad43617..93f60924723 100644
--- a/libjava/classpath/java/awt/Checkbox.java
+++ b/libjava/classpath/java/awt/Checkbox.java
@@ -392,6 +392,11 @@ Checkbox(String label, boolean state, CheckboxGroup group)
this.label = label;
this.state = state;
this.group = group;
+
+ if ( state && group != null )
+ {
+ group.setSelectedCheckbox(this);
+ }
}
/*************************************************************************/
@@ -610,8 +615,10 @@ dispatchEventImpl(AWTEvent e)
protected String
paramString()
{
- return ("label=" + label + ",state=" + state + ",group=" + group
- + "," + super.paramString());
+ // Note: We cannot add the checkbox group information here because this
+ // would trigger infinite recursion when CheckboxGroup.toString() is
+ // called and the box is in its selected state.
+ return ("label=" + label + ",state=" + state + "," + super.paramString());
}
/**
diff --git a/libjava/classpath/java/awt/CheckboxMenuItem.java b/libjava/classpath/java/awt/CheckboxMenuItem.java
index 5e446b84c8b..197065f6535 100644
--- a/libjava/classpath/java/awt/CheckboxMenuItem.java
+++ b/libjava/classpath/java/awt/CheckboxMenuItem.java
@@ -335,6 +335,8 @@ paramString()
implements AccessibleAction, AccessibleValue
{
// I think the base class provides the necessary implementation
+
+ private static final long serialVersionUID = -1122642964303476L;
}
/**
diff --git a/libjava/classpath/java/awt/Choice.java b/libjava/classpath/java/awt/Choice.java
index 5075ea92d83..df93c5b0742 100644
--- a/libjava/classpath/java/awt/Choice.java
+++ b/libjava/classpath/java/awt/Choice.java
@@ -565,6 +565,10 @@ processEvent(AWTEvent event)
protected void
processItemEvent(ItemEvent event)
{
+ int index = pItems.indexOf((String) event.getItem());
+ // Don't call back into the peers when selecting index here
+ if (event.getStateChange() == ItemEvent.SELECTED)
+ this.selectedIndex = index;
if (item_listeners != null)
item_listeners.itemStateChanged(event);
}
diff --git a/libjava/classpath/java/awt/Color.java b/libjava/classpath/java/awt/Color.java
index 4ad46d0c07c..b0312924170 100644
--- a/libjava/classpath/java/awt/Color.java
+++ b/libjava/classpath/java/awt/Color.java
@@ -762,7 +762,7 @@ public class Color implements Paint, Serializable
if (max == 0)
array[1] = 0;
else
- array[1] = (max - min) / max;
+ array[1] = ((float) (max - min)) / ((float) max);
// Calculate hue.
if (array[1] == 0)
array[0] = 0;
diff --git a/libjava/classpath/java/awt/ColorPaintContext.java b/libjava/classpath/java/awt/ColorPaintContext.java
index 759ba9d8734..82a78f63fb5 100644
--- a/libjava/classpath/java/awt/ColorPaintContext.java
+++ b/libjava/classpath/java/awt/ColorPaintContext.java
@@ -63,7 +63,7 @@ class ColorPaintContext implements PaintContext
/**
* Create the context for a given color.
*
- * @param c The solid color to use.
+ * @param colorRGB The solid color to use.
*/
ColorPaintContext(int colorRGB)
{
@@ -74,7 +74,7 @@ class ColorPaintContext implements PaintContext
* Create the context for a given color.
*
* @param cm The color model of this context.
- * @param c The solid color to use.
+ * @param colorRGB The solid color to use.
*/
ColorPaintContext(ColorModel cm,int colorRGB)
{
diff --git a/libjava/classpath/java/awt/Component.java b/libjava/classpath/java/awt/Component.java
index 0ae1ffa7d0b..9b389e21ed4 100644
--- a/libjava/classpath/java/awt/Component.java
+++ b/libjava/classpath/java/awt/Component.java
@@ -587,6 +587,7 @@ public abstract class Component
*/
protected Component()
{
+ // Nothing to do here.
}
/**
@@ -720,8 +721,9 @@ public abstract class Component
/**
* Tests if the component is displayable. It must be connected to a native
- * screen resource, and all its ancestors must be displayable. A containment
- * hierarchy is made displayable when a window is packed or made visible.
+ * screen resource. This reduces to checking that peer is not null. A
+ * containment hierarchy is made displayable when a window is packed or
+ * made visible.
*
* @return true if the component is displayable
* @see Container#add(Component)
@@ -733,9 +735,7 @@ public abstract class Component
*/
public boolean isDisplayable()
{
- if (parent != null)
- return parent.isDisplayable();
- return false;
+ return peer != null;
}
/**
@@ -763,7 +763,7 @@ public abstract class Component
if (! visible || peer == null)
return false;
- return parent == null ? true : parent.isShowing();
+ return parent == null ? false : parent.isShowing();
}
/**
@@ -902,15 +902,16 @@ public abstract class Component
if (currentPeer != null)
currentPeer.setVisible(true);
+ // The JDK repaints the component before invalidating the parent.
+ // So do we.
+ if (isShowing())
+ repaint();
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
- {
- currentParent.invalidate();
- currentParent.repaint();
- }
+ currentParent.invalidate();
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
@@ -946,18 +947,19 @@ public abstract class Component
ComponentPeer currentPeer=peer;
if (currentPeer != null)
currentPeer.setVisible(false);
-
+ boolean wasShowing = isShowing();
this.visible = false;
-
+
+ // The JDK repaints the component before invalidating the parent.
+ // So do we.
+ if (wasShowing)
+ repaint();
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
- {
- currentParent.invalidate();
- currentParent.repaint();
- }
+ currentParent.invalidate();
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
@@ -976,7 +978,7 @@ public abstract class Component
{
if (foreground != null)
return foreground;
- return parent == null ? SystemColor.windowText : parent.getForeground();
+ return parent == null ? null : parent.getForeground();
}
/**
@@ -1075,8 +1077,9 @@ public abstract class Component
Component p = parent;
if (p != null)
return p.getFont();
- else
- return new Font("Dialog", Font.PLAIN, 12);
+ if (peer != null)
+ return peer.getGraphics().getFont();
+ return null;
}
/**
@@ -1402,17 +1405,14 @@ public abstract class Component
peer.setBounds (x, y, width, height);
// Erase old bounds and repaint new bounds for lightweights.
- if (isLightweight() && isShowing ())
+ if (isLightweight() && isShowing())
{
if (parent != null)
{
Rectangle parentBounds = parent.getBounds();
- Rectangle oldBounds = new Rectangle(parent.getX() + oldx,
- parent.getY() + oldy,
- oldwidth, oldheight);
- Rectangle newBounds = new Rectangle(parent.getX() + x,
- parent.getY() + y,
- width, height);
+ Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth,
+ oldheight);
+ Rectangle newBounds = new Rectangle(x, y, width, height);
Rectangle destroyed = oldBounds.union(newBounds);
if (!destroyed.isEmpty())
parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
@@ -1646,7 +1646,7 @@ public abstract class Component
*/
public Dimension getMaximumSize()
{
- return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
}
/**
@@ -1720,7 +1720,7 @@ public abstract class Component
valid = false;
prefSize = null;
minSize = null;
- if (parent != null && parent.valid)
+ if (parent != null && parent.isValid())
parent.invalidate();
}
@@ -1736,11 +1736,8 @@ public abstract class Component
if (peer != null)
{
Graphics gfx = peer.getGraphics();
- if (gfx != null)
- return gfx;
- // create graphics for lightweight:
- Container parent = getParent();
- if (parent != null)
+ // Create peer for lightweights.
+ if (gfx == null && parent != null)
{
gfx = parent.getGraphics();
Rectangle bounds = getBounds();
@@ -1748,6 +1745,8 @@ public abstract class Component
gfx.translate(bounds.x, bounds.y);
return gfx;
}
+ gfx.setFont(font);
+ return gfx;
}
return null;
}
@@ -1887,7 +1886,7 @@ public abstract class Component
* @see #repaint(long, int, int, int, int)
*/
public void repaint()
- {
+ {
if(!isShowing())
{
Component p = parent;
@@ -3481,7 +3480,10 @@ public abstract class Component
ComponentPeer tmp = peer;
peer = null;
if (tmp != null)
- tmp.dispose();
+ {
+ tmp.hide();
+ tmp.dispose();
+ }
}
/**
@@ -3807,13 +3809,16 @@ public abstract class Component
{
synchronized (getTreeLock ())
{
- // Find this Component's top-level ancestor.
- Container parent = getParent ();
-
+ // Find this Component's top-level ancestor.
+ Container parent = (this instanceof Container) ? (Container) this
+ : getParent();
while (parent != null
&& !(parent instanceof Window))
parent = parent.getParent ();
+ if (parent == null)
+ return;
+
Window toplevel = (Window) parent;
if (toplevel.isFocusableWindow ())
{
@@ -4241,9 +4246,9 @@ public abstract class Component
if (isDoubleBuffered())
param.append(",doublebuffered");
if (parent == null)
- param.append(",parent==null");
+ param.append(",parent=null");
else
- param.append(",parent==").append(parent.getName());
+ param.append(",parent=").append(parent.getName());
return param.toString();
}
@@ -5567,6 +5572,7 @@ p * <li>the set of backward traversal keys
*/
protected AccessibleAWTComponentHandler()
{
+ // Nothing to do here.
}
/**
@@ -5598,6 +5604,7 @@ p * <li>the set of backward traversal keys
*/
public void componentMoved(ComponentEvent e)
{
+ // Nothing to do here.
}
/**
@@ -5607,6 +5614,7 @@ p * <li>the set of backward traversal keys
*/
public void componentResized(ComponentEvent e)
{
+ // Nothing to do here.
}
} // class AccessibleAWTComponentHandler
@@ -5624,6 +5632,7 @@ p * <li>the set of backward traversal keys
*/
protected AccessibleAWTFocusHandler()
{
+ // Nothing to do here.
}
/**
diff --git a/libjava/classpath/java/awt/Container.java b/libjava/classpath/java/awt/Container.java
index 13d32f87f39..4676895bf64 100644
--- a/libjava/classpath/java/awt/Container.java
+++ b/libjava/classpath/java/awt/Container.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt;
+import java.awt.event.ComponentListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.KeyEvent;
@@ -394,17 +395,20 @@ public class Container extends Component
layoutMgr.addLayoutComponent(null, comp);
}
- if (isShowing ())
- {
- // Post event to notify of adding the component.
- ContainerEvent ce = new ContainerEvent(this,
- ContainerEvent.COMPONENT_ADDED,
- comp);
- getToolkit().getSystemEventQueue().postEvent(ce);
-
- // Repaint this container.
- repaint();
- }
+ // We previously only sent an event when this container is showing.
+ // Also, the event was posted to the event queue. A Mauve test shows
+ // that this event is not delivered using the event queue and it is
+ // also sent when the container is not showing.
+ ContainerEvent ce = new ContainerEvent(this,
+ ContainerEvent.COMPONENT_ADDED,
+ comp);
+ ContainerListener[] listeners = getContainerListeners();
+ for (int i = 0; i < listeners.length; i++)
+ listeners[i].componentAdded(ce);
+
+ // Repaint this container.
+ repaint(comp.getX(), comp.getY(), comp.getWidth(),
+ comp.getHeight());
}
}
@@ -419,6 +423,10 @@ public class Container extends Component
{
Component r = component[index];
+ ComponentListener[] list = r.getComponentListeners();
+ for (int j = 0; j < list.length; j++)
+ r.removeComponentListener(list[j]);
+
r.removeNotify();
System.arraycopy(component, index + 1, component, index,
@@ -730,7 +738,16 @@ public class Container extends Component
*/
public float getAlignmentX()
{
- return super.getAlignmentX();
+ LayoutManager layout = getLayout();
+ float alignmentX = 0.0F;
+ if (layout != null && layout instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layout;
+ alignmentX = lm2.getLayoutAlignmentX(this);
+ }
+ else
+ alignmentX = super.getAlignmentX();
+ return alignmentX;
}
/**
@@ -742,7 +759,16 @@ public class Container extends Component
*/
public float getAlignmentY()
{
- return super.getAlignmentY();
+ LayoutManager layout = getLayout();
+ float alignmentY = 0.0F;
+ if (layout != null && layout instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layout;
+ alignmentY = lm2.getLayoutAlignmentY(this);
+ }
+ else
+ alignmentY = super.getAlignmentY();
+ return alignmentY;
}
/**
@@ -1047,6 +1073,53 @@ public class Container extends Component
return this;
}
}
+
+ /**
+ * Finds the visible child component that contains the specified position.
+ * The top-most child is returned in the case where there is overlap.
+ * If the top-most child is transparent and has no MouseListeners attached,
+ * we discard it and return the next top-most component containing the
+ * specified position.
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return null if the <code>this</code> does not contain the position,
+ * otherwise the top-most component (out of this container itself and
+ * its descendants) meeting the criteria above.
+ */
+ Component findComponentForMouseEventAt(int x, int y)
+ {
+ synchronized (getTreeLock())
+ {
+ if (!contains(x, y))
+ return null;
+
+ for (int i = 0; i < ncomponents; ++i)
+ {
+ // Ignore invisible children...
+ if (!component[i].isVisible())
+ continue;
+
+ int x2 = x - component[i].x;
+ int y2 = y - component[i].y;
+ // We don't do the contains() check right away because
+ // findComponentAt would redundantly do it first thing.
+ if (component[i] instanceof Container)
+ {
+ Container k = (Container) component[i];
+ Component r = k.findComponentForMouseEventAt(x2, y2);
+ if (r != null)
+ return r;
+ }
+ else if (component[i].contains(x2, y2))
+ return component[i];
+ }
+
+ //don't return transparent components with no MouseListeners
+ if (this.getMouseListeners().length == 0)
+ return null;
+ return this;
+ }
+ }
public Component findComponentAt(Point p)
{
@@ -1955,6 +2028,30 @@ class LightweightDispatcher implements Serializable
eventMask |= l;
}
+ /**
+ * Returns the deepest visible descendent of parent that contains the
+ * specified location and that is not transparent and MouseListener-less.
+ * @param parent the root component to begin the search
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return null if <code>parent</code> doesn't contain the location,
+ * parent if parent is not a container or has no child that contains the
+ * location, otherwise the appropriate component from the conditions
+ * above.
+ */
+ Component getDeepestComponentForMouseEventAt (
+ Component parent, int x, int y)
+ {
+ if (parent == null || (! parent.contains(x, y)))
+ return null;
+
+ if (! (parent instanceof Container))
+ return parent;
+
+ Container c = (Container) parent;
+ return c.findComponentForMouseEventAt(x, y);
+ }
+
Component acquireComponentForMouseEvent(MouseEvent me)
{
int x = me.getX ();
@@ -1968,7 +2065,7 @@ class LightweightDispatcher implements Serializable
while (candidate == null && parent != null)
{
candidate =
- AWTUtilities.getDeepestComponentAt(parent, p.x, p.y);
+ getDeepestComponentForMouseEventAt(parent, p.x, p.y);
if (candidate == null || (candidate.eventMask & me.getID()) == 0)
{
candidate = null;
@@ -2069,7 +2166,10 @@ class LightweightDispatcher implements Serializable
// Don't dispatch CLICKED events whose target is not the same as the
// target for the original PRESSED event.
if (candidate != pressedComponent)
- mouseEventTarget = null;
+ {
+ mouseEventTarget = null;
+ pressCount = 0;
+ }
else if (pressCount == 0)
pressedComponent = null;
}
@@ -2107,7 +2207,7 @@ class LightweightDispatcher implements Serializable
pressedComponent = null;
break;
}
-
+
MouseEvent newEvt =
AWTUtilities.convertMouseEvent(nativeContainer, me,
mouseEventTarget);
diff --git a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
index f53cc5ef04d..bce6352a900 100644
--- a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
+++ b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
@@ -146,8 +146,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
*/
private AWTKeyStroke waitForKeyStroke = null;
- /** The {@link java.util.SortedSet} of current {@link
- #EventDelayRequest}s. */
+ /** The {@link java.util.SortedSet} of current
+ * {@link EventDelayRequest}s. */
private SortedSet delayRequests = new TreeSet ();
public DefaultKeyboardFocusManager ()
diff --git a/libjava/classpath/java/awt/Dialog.java b/libjava/classpath/java/awt/Dialog.java
index d3eb975a86d..7e5e7215aac 100644
--- a/libjava/classpath/java/awt/Dialog.java
+++ b/libjava/classpath/java/awt/Dialog.java
@@ -519,6 +519,8 @@ paramString()
protected class AccessibleAWTDialog extends AccessibleAWTWindow
{
+ private static final long serialVersionUID = 4837230331833941201L;
+
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.DIALOG;
diff --git a/libjava/classpath/java/awt/EventQueue.java b/libjava/classpath/java/awt/EventQueue.java
index 15b6e1e7afd..235ad2ac17c 100644
--- a/libjava/classpath/java/awt/EventQueue.java
+++ b/libjava/classpath/java/awt/EventQueue.java
@@ -42,7 +42,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.InputMethodEvent;
import java.awt.event.InvocationEvent;
-import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import java.util.EmptyStackException;
diff --git a/libjava/classpath/java/awt/Font.java b/libjava/classpath/java/awt/Font.java
index 5de94586e2c..2e4c9f61c68 100644
--- a/libjava/classpath/java/awt/Font.java
+++ b/libjava/classpath/java/awt/Font.java
@@ -50,6 +50,7 @@ import java.awt.geom.Rectangle2D;
import java.awt.peer.FontPeer;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.text.AttributedCharacterIterator;
import java.text.CharacterIterator;
@@ -69,39 +70,35 @@ import java.util.StringTokenizer;
public class Font implements Serializable
{
-/*
- * Static Variables
- */
-
-/**
- * Constant indicating a "plain" font.
- */
-public static final int PLAIN = 0;
+ /**
+ * Constant indicating a "plain" font.
+ */
+ public static final int PLAIN = 0;
-/**
- * Constant indicating a "bold" font.
- */
-public static final int BOLD = 1;
+ /**
+ * Constant indicating a "bold" font.
+ */
+ public static final int BOLD = 1;
-/**
- * Constant indicating an "italic" font.
- */
-public static final int ITALIC = 2;
+ /**
+ * Constant indicating an "italic" font.
+ */
+ public static final int ITALIC = 2;
-/**
- * Constant indicating the baseline mode characteristic of Roman.
- */
-public static final int ROMAN_BASELINE = 0;
+ /**
+ * Constant indicating the baseline mode characteristic of Roman.
+ */
+ public static final int ROMAN_BASELINE = 0;
-/**
- * Constant indicating the baseline mode characteristic of Chinese.
- */
-public static final int CENTER_BASELINE = 1;
+ /**
+ * Constant indicating the baseline mode characteristic of Chinese.
+ */
+ public static final int CENTER_BASELINE = 1;
-/**
- * Constant indicating the baseline mode characteristic of Devanigri.
- */
-public static final int HANGING_BASELINE = 2;
+ /**
+ * Constant indicating the baseline mode characteristic of Devanigri.
+ */
+ public static final int HANGING_BASELINE = 2;
/**
@@ -170,1145 +167,1138 @@ public static final int HANGING_BASELINE = 2;
protected String name;
/**
- * The size of this font in pixels.
+ * The size of this font in points, rounded.
*
* @since 1.0
*/
protected int size;
/**
+ * The size of this font in points.
+ *
+ * @since 1.0
+ */
+ protected float pointSize;
+
+ /**
* The style of this font -- PLAIN, BOLD, ITALIC or BOLD+ITALIC.
*
* @since 1.0
*/
protected int style;
-// Serialization constant
-private static final long serialVersionUID = -4206021311591459213L;
+//Serialization constant
+ private static final long serialVersionUID = -4206021311591459213L;
// The ClasspathToolkit-provided peer which implements this font
- private ClasspathFontPeer peer;
-
-/*************************************************************************/
+ private transient ClasspathFontPeer peer;
-/*
- * Static Methods
- */
-/**
- * Creates a <code>Font</code> object from the specified string, which
- * is in one of the following formats:
- * <p>
- * <ul>
- * <li>fontname-style-pointsize
- * <li>fontname-style
- * <li>fontname-pointsize
- * <li>fontname
- * </ul>
- * <p>
- * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default
- * style if none is specified is PLAIN. The default size if none
- * is specified is 12.
- *
- * @param fontspec a string specifying the required font (<code>null</code>
- * permitted, interpreted as 'Dialog-PLAIN-12').
- *
- * @return A font.
- */
- public static Font decode (String fontspec)
-{
- if (fontspec == null)
- fontspec = "Dialog-PLAIN-12";
- String name = null;
- int style = PLAIN;
- int size = 12;
-
- StringTokenizer st = new StringTokenizer(fontspec, "- ");
- while (st.hasMoreTokens())
- {
- String token = st.nextToken();
- if (name == null)
- {
- name = token;
- continue;
- }
-
- if (token.toUpperCase().equals("BOLD"))
- {
- style = BOLD;
- continue;
- }
- if (token.toUpperCase().equals("ITALIC"))
- {
- style = ITALIC;
- continue;
- }
- if (token.toUpperCase().equals("BOLDITALIC"))
- {
+ /**
+ * Creates a <code>Font</code> object from the specified string, which
+ * is in one of the following formats:
+ * <p>
+ * <ul>
+ * <li>fontname-style-pointsize
+ * <li>fontname-style
+ * <li>fontname-pointsize
+ * <li>fontname
+ * </ul>
+ * <p>
+ * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default
+ * style if none is specified is PLAIN. The default size if none
+ * is specified is 12.
+ *
+ * @param fontspec a string specifying the required font (<code>null</code>
+ * permitted, interpreted as 'Dialog-PLAIN-12').
+ *
+ * @return A font.
+ */
+ public static Font decode(String fontspec)
+ {
+ if (fontspec == null)
+ fontspec = "Dialog-PLAIN-12";
+ String name = null;
+ int style = PLAIN;
+ int size = 12;
+
+ StringTokenizer st = new StringTokenizer(fontspec, "- ");
+ while (st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ if (name == null)
+ {
+ name = token;
+ continue;
+ }
+
+ if (token.toUpperCase().equals("BOLD"))
+ {
+ style = BOLD;
+ continue;
+ }
+ if (token.toUpperCase().equals("ITALIC"))
+ {
+ style = ITALIC;
+ continue;
+ }
+ if (token.toUpperCase().equals("BOLDITALIC"))
+ {
style = BOLD | ITALIC;
- continue;
- }
-
- int tokenval = 0;
- try
- {
- tokenval = Integer.parseInt(token);
- }
- catch(NumberFormatException e)
- {
- // Ignored.
- }
+ continue;
+ }
+
+ int tokenval = 0;
+ try
+ {
+ tokenval = Integer.parseInt(token);
+ }
+ catch (NumberFormatException e)
+ {
+ // Ignored.
+ }
if (tokenval != 0)
size = tokenval;
}
HashMap attrs = new HashMap();
- ClasspathFontPeer.copyStyleToAttrs (style, attrs);
- ClasspathFontPeer.copySizeToAttrs (size, attrs);
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
- return getFontFromToolkit (name, attrs);
-}
+ return getFontFromToolkit(name, attrs);
+ }
/* These methods delegate to the toolkit. */
- protected static ClasspathToolkit tk ()
+ static ClasspathToolkit tk()
{
- return (ClasspathToolkit)(Toolkit.getDefaultToolkit ());
+ return (ClasspathToolkit) Toolkit.getDefaultToolkit();
}
/* Every factory method in Font should eventually call this. */
- protected static Font getFontFromToolkit (String name, Map attribs)
+ static Font getFontFromToolkit(String name, Map attribs)
{
- return tk ().getFont (name, attribs);
+ return tk().getFont(name, attribs);
}
/* Every Font constructor should eventually call this. */
- protected static ClasspathFontPeer getPeerFromToolkit (String name, Map attrs)
+ static ClasspathFontPeer getPeerFromToolkit(String name, Map attrs)
{
- return tk ().getClasspathFontPeer (name, attrs);
+ return tk().getClasspathFontPeer(name, attrs);
}
-/*************************************************************************/
-
-/**
- * Returns a <code>Font</code> object from the passed property name.
- *
- * @param propname The name of the system property.
- * @param defval Value to use if the property is not found.
- *
- * @return The requested font, or <code>default</code> if the property
- * not exist or is malformed.
- */
- public static Font getFont (String propname, Font defval)
-{
- String propval = System.getProperty(propname);
- if (propval != null)
- return decode (propval);
+ /**
+ * Returns a <code>Font</code> object from the passed property name.
+ *
+ * @param propname The name of the system property.
+ * @param defval Value to use if the property is not found.
+ *
+ * @return The requested font, or <code>default</code> if the property
+ * not exist or is malformed.
+ */
+ public static Font getFont(String propname, Font defval)
+ {
+ String propval = System.getProperty(propname);
+ if (propval != null)
+ return decode(propval);
return defval;
-}
-
-/*************************************************************************/
-
-/**
- * Returns a <code>Font</code> object from the passed property name.
- *
- * @param propname The name of the system property.
- *
- * @return The requested font, or <code>null</code> if the property
- * not exist or is malformed.
- */
- public static Font getFont (String propname)
-{
- return getFont (propname, (Font)null);
-}
-
-/*************************************************************************/
+ }
-/*
- * Constructors
- */
+ /**
+ * Returns a <code>Font</code> object from the passed property name.
+ *
+ * @param propname The name of the system property.
+ *
+ * @return The requested font, or <code>null</code> if the property
+ * not exist or is malformed.
+ */
+ public static Font getFont(String propname)
+ {
+ return getFont(propname, (Font) null);
+ }
-/**
- * Initializes a new instance of <code>Font</code> with the specified
- * attributes.
- *
- * @param name The name of the font.
- * @param style The font style.
- * @param size The font point size.
- */
-
- public Font (String name, int style, int size)
+ /**
+ * Initializes a new instance of <code>Font</code> with the specified
+ * attributes.
+ *
+ * @param name The name of the font.
+ * @param style The font style.
+ * @param size The font point size.
+ */
+ public Font(String name, int style, int size)
{
HashMap attrs = new HashMap();
- ClasspathFontPeer.copyStyleToAttrs (style, attrs);
- ClasspathFontPeer.copySizeToAttrs (size, attrs);
- this.peer = getPeerFromToolkit (name, attrs);
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
+ this.peer = getPeerFromToolkit(name, attrs);
+ this.size = size;
+ this.pointSize = (float) size;
+ if (name != null)
+ this.name = name;
+ else
+ this.name = peer.getName(this);
}
- public Font (Map attrs)
+ public Font(Map attrs)
{
this(null, attrs);
}
/* This extra constructor is here to permit ClasspathToolkit and to
- build a font with a "logical name" as well as attrs.
- ClasspathToolkit.getFont(String,Map) uses reflection to call this
- package-private constructor. */
- Font (String name, Map attrs)
+ build a font with a "logical name" as well as attrs.
+ ClasspathToolkit.getFont(String,Map) uses reflection to call this
+ package-private constructor. */
+ Font(String name, Map attrs)
{
// If attrs is null, setting it to an empty HashMap will give this
// Font default attributes.
if (attrs == null)
attrs = new HashMap();
- this.peer = getPeerFromToolkit (name, attrs);
+ peer = getPeerFromToolkit(name, attrs);
+ size = (int) peer.getSize(this);
+ pointSize = peer.getSize(this);
+ if (name != null)
+ this.name = name;
+ else
+ this.name = peer.getName(this);
}
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
+ /**
* Returns the logical name of the font. A logical name is the name the
* font was constructed with. It may be the name of a logical font (one
* of 6 required names in all java environments) or it may be a face
* name.
- *
- * @return The logical name of the font.
- *
- * @see #getFamily()
- * @see #getFontName()
- */
+ *
+ * @return The logical name of the font.
+ *
+ * @see #getFamily()
+ * @see #getFontName()
+ */
public String getName ()
-{
- return peer.getName (this);
-}
-
-/*************************************************************************/
-
-/**
- * Returns the style of the font.
- *
- * @return The font style.
- */
- public int getSize ()
-{
- return (int) peer.getSize (this);
-}
-
- public float getSize2D ()
-{
- return peer.getSize (this);
-}
-
-/*************************************************************************/
-
-/**
- * Tests whether or not this is a plain font. This will be true if
- * and only if neither the bold nor the italics style is set.
- *
- * @return <code>true</code> if this is a plain font, <code>false</code>
- * otherwise.
- */
- public boolean isPlain ()
-{
- return peer.isPlain (this);
-}
+ {
+ return peer.getName(this);
+ }
-/*************************************************************************/
+ /**
+ * Returns the size of the font, in typographics points (1/72 of an inch),
+ * rounded to an integer.
+ *
+ * @return The font size
+ */
+ public int getSize()
+ {
+ return size;
+ }
-/**
- * Tests whether or not this font is bold.
- *
- * @return <code>true</code> if this font is bold, <code>false</code>
- * otherwise.
- */
- public boolean isBold ()
-{
- return peer.isBold (this);
-}
+ /**
+ * Returns the size of the font, in typographics points (1/72 of an inch).
+ *
+ * @return The font size
+ */
+ public float getSize2D()
+ {
+ return pointSize;
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not this is a plain font. This will be true if
+ * and only if neither the bold nor the italics style is set.
+ *
+ * @return <code>true</code> if this is a plain font, <code>false</code>
+ * otherwise.
+ */
+ public boolean isPlain()
+ {
+ return peer.isPlain(this);
+ }
-/**
- * Tests whether or not this font is italic.
- *
- * @return <code>true</code> if this font is italic, <code>false</code>
- * otherwise.
- */
- public boolean isItalic ()
-{
- return peer.isItalic (this);
-}
+ /**
+ * Tests whether or not this font is bold.
+ *
+ * @return <code>true</code> if this font is bold, <code>false</code>
+ * otherwise.
+ */
+ public boolean isBold()
+ {
+ return peer.isBold(this);
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not this font is italic.
+ *
+ * @return <code>true</code> if this font is italic, <code>false</code>
+ * otherwise.
+ */
+ public boolean isItalic()
+ {
+ return peer.isItalic(this);
+ }
-/**
+ /**
* Returns the family name of this font. A family name describes a design
* or "brand name" (such as Helvetica or Palatino). It is less specific
* than a font face name (such as Helvetica Bold).
- *
- * @return A string containing the font family name.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFontName()
- * @see GraphicsEnvironment#getAvailableFontFamilyNames()
- */
- public String getFamily ()
-{
- return peer.getFamily (this);
-}
+ *
+ * @return A string containing the font family name.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFontName()
+ * @see GraphicsEnvironment#getAvailableFontFamilyNames()
+ */
+ public String getFamily()
+ {
+ return peer.getFamily(this);
+ }
-/**
- * Returns integer code representing the sum of style flags of this font, a
- * combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}.
- *
- * @return code representing the style of this font.
- *
- * @see #isPlain()
- * @see #isBold()
- * @see #isItalic()
- */
- public int getStyle ()
-{
- return peer.getStyle (this);
-}
+ /**
+ * Returns integer code representing the sum of style flags of this font, a
+ * combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}.
+ *
+ * @return code representing the style of this font.
+ *
+ * @see #isPlain()
+ * @see #isBold()
+ * @see #isItalic()
+ */
+ public int getStyle()
+ {
+ return peer.getStyle(this);
+ }
-/**
- * Checks if specified character maps to a glyph in this font.
- *
- * @param c The character to check.
- *
- * @return Whether the character has a corresponding glyph in this font.
- *
- * @since 1.2
- */
- public boolean canDisplay (char c)
-{
- return peer.canDisplay (this, c);
-}
+ /**
+ * Checks if specified character maps to a glyph in this font.
+ *
+ * @param c The character to check.
+ *
+ * @return Whether the character has a corresponding glyph in this font.
+ *
+ * @since 1.2
+ */
+ public boolean canDisplay(char c)
+ {
+ return peer.canDisplay(this, c);
+ }
-/**
- * Checks how much of a given string can be mapped to glyphs in
- * this font.
- *
- * @param s The string to check.
- *
- * @return The index of the first character in <code>s</code> which cannot
- * be converted to a glyph by this font, or <code>-1</code> if all
- * characters can be mapped to glyphs.
- *
- * @since 1.2
- */
- public int canDisplayUpTo (String s)
-{
- return peer.canDisplayUpTo (this, new StringCharacterIterator (s),
- 0, s.length () - 1);
-}
+ /**
+ * Checks how much of a given string can be mapped to glyphs in
+ * this font.
+ *
+ * @param s The string to check.
+ *
+ * @return The index of the first character in <code>s</code> which cannot
+ * be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ */
+ public int canDisplayUpTo(String s)
+ {
+ return peer.canDisplayUpTo(this, new StringCharacterIterator(s),
+ 0, s.length() - 1);
+ }
-/**
- * Checks how much of a given sequence of text can be mapped to glyphs in
- * this font.
- *
- * @param text Array containing the text to check.
- * @param start Position of first character to check in <code>text</code>.
- * @param limit Position of last character to check in <code>text</code>.
- *
- * @return The index of the first character in the indicated range which
- * cannot be converted to a glyph by this font, or <code>-1</code> if all
- * characters can be mapped to glyphs.
- *
- * @since 1.2
- *
- * @throws IndexOutOfBoundsException if the range [start, limit] is
- * invalid in <code>text</code>.
- */
+ /**
+ * Checks how much of a given sequence of text can be mapped to glyphs in
+ * this font.
+ *
+ * @param text Array containing the text to check.
+ * @param start Position of first character to check in <code>text</code>.
+ * @param limit Position of last character to check in <code>text</code>.
+ *
+ * @return The index of the first character in the indicated range which
+ * cannot be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ *
+ * @throws IndexOutOfBoundsException if the range [start, limit] is
+ * invalid in <code>text</code>.
+ */
public int canDisplayUpTo (char[] text, int start, int limit)
-{
- return peer.canDisplayUpTo
- (this, new StringCharacterIterator (new String (text)), start, limit);
-}
+ {
+ return peer.canDisplayUpTo(this,
+ new StringCharacterIterator(new String (text)),
+ start, limit);
+ }
-/**
- * Checks how much of a given sequence of text can be mapped to glyphs in
- * this font.
- *
- * @param i Iterator over the text to check.
- * @param start Position of first character to check in <code>i</code>.
- * @param limit Position of last character to check in <code>i</code>.
- *
- * @return The index of the first character in the indicated range which
- * cannot be converted to a glyph by this font, or <code>-1</code> if all
- * characters can be mapped to glyphs.
- *
- * @since 1.2
- *
- * @throws IndexOutOfBoundsException if the range [start, limit] is
- * invalid in <code>i</code>.
- */
- public int canDisplayUpTo (CharacterIterator i, int start, int limit)
-{
- return peer.canDisplayUpTo (this, i, start, limit);
-}
+ /**
+ * Checks how much of a given sequence of text can be mapped to glyphs in
+ * this font.
+ *
+ * @param i Iterator over the text to check.
+ * @param start Position of first character to check in <code>i</code>.
+ * @param limit Position of last character to check in <code>i</code>.
+ *
+ * @return The index of the first character in the indicated range which
+ * cannot be converted to a glyph by this font, or <code>-1</code> if all
+ * characters can be mapped to glyphs.
+ *
+ * @since 1.2
+ *
+ * @throws IndexOutOfBoundsException if the range [start, limit] is
+ * invalid in <code>i</code>.
+ */
+ public int canDisplayUpTo(CharacterIterator i, int start, int limit)
+ {
+ return peer.canDisplayUpTo(this, i, start, limit);
+ }
-/**
- * Creates a new font with point size 1 and {@link #PLAIN} style,
- * reading font data from the provided input stream. The resulting font
- * can have further fonts derived from it using its
- * <code>deriveFont</code> method.
- *
- * @param fontFormat Integer code indicating the format the font data is
- * in.Currently this can only be {@link #TRUETYPE_FONT}.
- * @param is {@link InputStream} from which font data will be read. This
- * stream is not closed after font data is extracted.
- *
- * @return A new {@link Font} of the format indicated.
- *
- * @throws IllegalArgumentException if <code>fontType</code> is not
- * recognized.
- * @throws FontFormatException if data in InputStream is not of format
- * indicated.
- * @throws IOException if insufficient data is present on InputStream.
- *
- * @since 1.3
- */
- public static Font createFont (int fontFormat, InputStream is)
- throws FontFormatException, IOException
-{
- return tk().createFont (fontFormat, is);
-}
+ /**
+ * Creates a new font with point size 1 and {@link #PLAIN} style,
+ * reading font data from the provided input stream. The resulting font
+ * can have further fonts derived from it using its
+ * <code>deriveFont</code> method.
+ *
+ * @param fontFormat Integer code indicating the format the font data is
+ * in.Currently this can only be {@link #TRUETYPE_FONT}.
+ * @param is {@link InputStream} from which font data will be read. This
+ * stream is not closed after font data is extracted.
+ *
+ * @return A new {@link Font} of the format indicated.
+ *
+ * @throws IllegalArgumentException if <code>fontType</code> is not
+ * recognized.
+ * @throws FontFormatException if data in InputStream is not of format
+ * indicated.
+ * @throws IOException if insufficient data is present on InputStream.
+ *
+ * @since 1.3
+ */
+ public static Font createFont (int fontFormat, InputStream is)
+ throws FontFormatException, IOException
+ {
+ return tk().createFont(fontFormat, is);
+ }
-/**
- * Maps characters to glyphs in a one-to-one relationship, returning a new
- * {@link GlyphVector} with a mapped glyph for each input character. This
- * sort of mapping is often sufficient for some scripts such as Roman, but
- * is inappropriate for scripts with special shaping or contextual layout
- * requirements such as Arabic, Indic, Hebrew or Thai.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param str The string to convert to Glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- */
- public GlyphVector createGlyphVector (FontRenderContext ctx, String str)
-{
- return peer.createGlyphVector (this, ctx, new StringCharacterIterator (str));
-}
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param str The string to convert to Glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, String str)
+ {
+ return peer.createGlyphVector(this, ctx, new StringCharacterIterator(str));
+ }
-/**
- * Maps characters to glyphs in a one-to-one relationship, returning a new
- * {@link GlyphVector} with a mapped glyph for each input character. This
- * sort of mapping is often sufficient for some scripts such as Roman, but
- * is inappropriate for scripts with special shaping or contextual layout
- * requirements such as Arabic, Indic, Hebrew or Thai.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param i Iterator over the text to convert to glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- */
- public GlyphVector createGlyphVector (FontRenderContext ctx, CharacterIterator i)
-{
- return peer.createGlyphVector (this, ctx, i);
-}
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param i Iterator over the text to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx,
+ CharacterIterator i)
+ {
+ return peer.createGlyphVector(this, ctx, i);
+ }
-/**
- * Maps characters to glyphs in a one-to-one relationship, returning a new
- * {@link GlyphVector} with a mapped glyph for each input character. This
- * sort of mapping is often sufficient for some scripts such as Roman, but
- * is inappropriate for scripts with special shaping or contextual layout
- * requirements such as Arabic, Indic, Hebrew or Thai.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param chars Array of characters to convert to glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- */
- public GlyphVector createGlyphVector (FontRenderContext ctx, char[] chars)
-{
- return peer.createGlyphVector
- (this, ctx, new StringCharacterIterator (new String (chars)));
-}
+ /**
+ * Maps characters to glyphs in a one-to-one relationship, returning a new
+ * {@link GlyphVector} with a mapped glyph for each input character. This
+ * sort of mapping is often sufficient for some scripts such as Roman, but
+ * is inappropriate for scripts with special shaping or contextual layout
+ * requirements such as Arabic, Indic, Hebrew or Thai.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param chars Array of characters to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, char[] chars)
+ {
+ return peer.createGlyphVector(this, ctx,
+ new StringCharacterIterator(new String(chars)));
+ }
-/**
- * Extracts a sequence of glyphs from a font, returning a new {@link
- * GlyphVector} with a mapped glyph for each input glyph code.
- *
- * @param ctx The rendering context used for precise glyph placement.
- * @param glyphCodes Array of characters to convert to glyphs.
- *
- * @return A new {@link GlyphVector} containing glyphs mapped from str,
- * through the font's cmap table.
- *
- * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
- *
- * @specnote This method is documented to perform character-to-glyph
- * conversions, in the Sun documentation, but its second parameter name is
- * "glyphCodes" and it is not clear to me why it would exist if its
- * purpose was to transport character codes inside integers. I assume it
- * is mis-documented in the Sun documentation.
- */
-
- public GlyphVector createGlyphVector (FontRenderContext ctx, int[] glyphCodes)
-{
- return peer.createGlyphVector (this, ctx, glyphCodes);
-}
+ /**
+ * Extracts a sequence of glyphs from a font, returning a new {@link
+ * GlyphVector} with a mapped glyph for each input glyph code.
+ *
+ * @param ctx The rendering context used for precise glyph placement.
+ * @param glyphCodes Array of characters to convert to glyphs.
+ *
+ * @return A new {@link GlyphVector} containing glyphs mapped from str,
+ * through the font's cmap table.
+ *
+ * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+ *
+ * @specnote This method is documented to perform character-to-glyph
+ * conversions, in the Sun documentation, but its second parameter name is
+ * "glyphCodes" and it is not clear to me why it would exist if its
+ * purpose was to transport character codes inside integers. I assume it
+ * is mis-documented in the Sun documentation.
+ */
+ public GlyphVector createGlyphVector(FontRenderContext ctx, int[] glyphCodes)
+ {
+ return peer.createGlyphVector(this, ctx, glyphCodes);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new size and style.
- *
- * @param style The style of the newly created font.
- * @param size The size of the newly created font.
- *
- * @return A clone of the current font, with the specified size and style.
- *
- * @since 1.2
- */
- public Font deriveFont (int style, float size)
-{
- return peer.deriveFont (this, style, size);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new size and style.
+ *
+ * @param style The style of the newly created font.
+ * @param size The size of the newly created font.
+ *
+ * @return A clone of the current font, with the specified size and style.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style, float size)
+ {
+ return peer.deriveFont(this, style, size);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new size.
- *
- * @param size The size of the newly created font.
- *
- * @return A clone of the current font, with the specified size.
- *
- * @since 1.2
- */
- public Font deriveFont (float size)
-{
- return peer.deriveFont (this, size);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new size.
+ *
+ * @param size The size of the newly created font.
+ *
+ * @return A clone of the current font, with the specified size.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(float size)
+ {
+ return peer.deriveFont(this, size);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new style.
- *
- * @param style The style of the newly created font.
- *
- * @return A clone of the current font, with the specified style.
- *
- * @since 1.2
- */
- public Font deriveFont (int style)
-{
- return peer.deriveFont (this, style);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new style.
+ *
+ * @param style The style of the newly created font.
+ *
+ * @return A clone of the current font, with the specified style.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style)
+ {
+ return peer.deriveFont(this, style);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new style and subjected to a new affine transformation.
- *
- * @param style The style of the newly created font.
- * @param a The transformation to apply.
- *
- * @return A clone of the current font, with the specified style and
- * transform.
- *
- * @throws IllegalArgumentException If transformation is
- * <code>null</code>.
- *
- * @since 1.2
- */
- public Font deriveFont (int style, AffineTransform a)
-{
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new style and subjected to a new affine transformation.
+ *
+ * @param style The style of the newly created font.
+ * @param a The transformation to apply.
+ *
+ * @return A clone of the current font, with the specified style and
+ * transform.
+ *
+ * @throws IllegalArgumentException If transformation is
+ * <code>null</code>.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(int style, AffineTransform a)
+ {
if (a == null)
- throw new IllegalArgumentException ("Affine transformation is null");
+ throw new IllegalArgumentException("Affine transformation is null");
- return peer.deriveFont (this, style, a);
-}
+ return peer.deriveFont(this, style, a);
+ }
-/**
- * Produces a new {@link Font} based on the current font, subjected
- * to a new affine transformation.
- *
- * @param a The transformation to apply.
- *
- * @return A clone of the current font, with the specified transform.
- *
- * @throws IllegalArgumentException If transformation is
- * <code>null</code>.
- *
- * @since 1.2
- */
- public Font deriveFont (AffineTransform a)
-{
+ /**
+ * Produces a new {@link Font} based on the current font, subjected
+ * to a new affine transformation.
+ *
+ * @param a The transformation to apply.
+ *
+ * @return A clone of the current font, with the specified transform.
+ *
+ * @throws IllegalArgumentException If transformation is
+ * <code>null</code>.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(AffineTransform a)
+ {
if (a == null)
- throw new IllegalArgumentException ("Affine transformation is null");
+ throw new IllegalArgumentException("Affine transformation is null");
- return peer.deriveFont (this, a);
-}
+ return peer.deriveFont(this, a);
+ }
-/**
- * Produces a new {@link Font} based on the current font, adjusted to a
- * new set of attributes.
- *
- * @param attributes Attributes of the newly created font.
- *
- * @return A clone of the current font, with the specified attributes.
- *
- * @since 1.2
- */
- public Font deriveFont (Map attributes)
-{
- return peer.deriveFont (this, attributes);
-}
+ /**
+ * Produces a new {@link Font} based on the current font, adjusted to a
+ * new set of attributes.
+ *
+ * @param attributes Attributes of the newly created font.
+ *
+ * @return A clone of the current font, with the specified attributes.
+ *
+ * @since 1.2
+ */
+ public Font deriveFont(Map attributes)
+ {
+ return peer.deriveFont(this, attributes);
+ }
-/**
- * Returns a map of chracter attributes which this font currently has set.
- *
- * @return A map of chracter attributes which this font currently has set.
- *
- * @see #getAvailableAttributes()
- * @see java.text.AttributedCharacterIterator.Attribute
- * @see java.awt.font.TextAttribute
- */
- public Map getAttributes ()
-{
- return peer.getAttributes (this);
-}
+ /**
+ * Returns a map of chracter attributes which this font currently has set.
+ *
+ * @return A map of chracter attributes which this font currently has set.
+ *
+ * @see #getAvailableAttributes()
+ * @see java.text.AttributedCharacterIterator.Attribute
+ * @see java.awt.font.TextAttribute
+ */
+ public Map getAttributes()
+ {
+ return peer.getAttributes(this);
+ }
-/**
- * Returns an array of chracter attribute keys which this font understands.
- *
- * @return An array of chracter attribute keys which this font understands.
- *
- * @see #getAttributes()
- * @see java.text.AttributedCharacterIterator.Attribute
- * @see java.awt.font.TextAttribute
- */
+ /**
+ * Returns an array of chracter attribute keys which this font understands.
+ *
+ * @return An array of chracter attribute keys which this font understands.
+ *
+ * @see #getAttributes()
+ * @see java.text.AttributedCharacterIterator.Attribute
+ * @see java.awt.font.TextAttribute
+ */
public AttributedCharacterIterator.Attribute[] getAvailableAttributes()
-{
- return peer.getAvailableAttributes (this);
-}
+ {
+ return peer.getAvailableAttributes(this);
+ }
-/**
- * Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link
- * #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline
- * this font will measure baseline offsets for, when presenting glyph
- * metrics for a given character.
- *
- * Baseline offsets describe the position of a glyph relative to an
- * invisible line drawn under, through the center of, or over a line of
- * rendered text, respectively. Different scripts use different baseline
- * modes, so clients should not assume all baseline offsets in a glyph
- * vector are from a common baseline.
- *
- * @param c The character code to select a baseline mode for.
- *
- * @return The baseline mode which would be used in a glyph associated
- * with the provided character.
- *
- * @since 1.2
- *
- * @see LineMetrics#getBaselineOffsets()
- */
- public byte getBaselineFor (char c)
-{
- return peer.getBaselineFor (this, c);
-}
+ /**
+ * Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link
+ * #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline
+ * this font will measure baseline offsets for, when presenting glyph
+ * metrics for a given character.
+ *
+ * Baseline offsets describe the position of a glyph relative to an
+ * invisible line drawn under, through the center of, or over a line of
+ * rendered text, respectively. Different scripts use different baseline
+ * modes, so clients should not assume all baseline offsets in a glyph
+ * vector are from a common baseline.
+ *
+ * @param c The character code to select a baseline mode for.
+ *
+ * @return The baseline mode which would be used in a glyph associated
+ * with the provided character.
+ *
+ * @since 1.2
+ *
+ * @see LineMetrics#getBaselineOffsets()
+ */
+ public byte getBaselineFor(char c)
+ {
+ return peer.getBaselineFor(this, c);
+ }
-/**
- * Returns the family name of this font. A family name describes a
- * typographic style (such as Helvetica or Palatino). It is more specific
- * than a logical font name (such as Sans Serif) but less specific than a
- * font face name (such as Helvetica Bold).
- *
- * @param lc The locale in which to describe the name of the font family.
- *
- * @return A string containing the font family name, localized for the
- * provided locale.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFontName()
- * @see GraphicsEnvironment#getAvailableFontFamilyNames()
- * @see Locale
- */
- public String getFamily (Locale lc)
-{
- return peer.getFamily (this, lc);
-}
+ /**
+ * Returns the family name of this font. A family name describes a
+ * typographic style (such as Helvetica or Palatino). It is more specific
+ * than a logical font name (such as Sans Serif) but less specific than a
+ * font face name (such as Helvetica Bold).
+ *
+ * @param lc The locale in which to describe the name of the font family.
+ *
+ * @return A string containing the font family name, localized for the
+ * provided locale.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFontName()
+ * @see GraphicsEnvironment#getAvailableFontFamilyNames()
+ * @see Locale
+ */
+ public String getFamily(Locale lc)
+ {
+ return peer.getFamily(this, lc);
+ }
-/**
- * Returns a font appropriate for the given attribute set.
- *
- * @param attributes The attributes required for the new font.
- *
- * @return A new Font with the given attributes.
- *
- * @since 1.2
- *
- * @see java.awt.font.TextAttribute
- */
- public static Font getFont (Map attributes)
-{
- return getFontFromToolkit (null, attributes);
-}
+ /**
+ * Returns a font appropriate for the given attribute set.
+ *
+ * @param attributes The attributes required for the new font.
+ *
+ * @return A new Font with the given attributes.
+ *
+ * @since 1.2
+ *
+ * @see java.awt.font.TextAttribute
+ */
+ public static Font getFont(Map attributes)
+ {
+ return getFontFromToolkit(null, attributes);
+ }
-/**
- * Returns the font face name of the font. A font face name describes a
- * specific variant of a font family (such as Helvetica Bold). It is more
- * specific than both a font family name (such as Helvetica) and a logical
- * font name (such as Sans Serif).
- *
- * @return The font face name of the font.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFamily()
- */
- public String getFontName ()
-{
- return peer.getFontName (this);
-}
+ /**
+ * Returns the font face name of the font. A font face name describes a
+ * specific variant of a font family (such as Helvetica Bold). It is more
+ * specific than both a font family name (such as Helvetica) and a logical
+ * font name (such as Sans Serif).
+ *
+ * @return The font face name of the font.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ */
+ public String getFontName()
+ {
+ return peer.getFontName(this);
+ }
-/**
- * Returns the font face name of the font. A font face name describes a
- * specific variant of a font family (such as Helvetica Bold). It is more
+ /**
+ * Returns the font face name of the font. A font face name describes a
+ * specific variant of a font family (such as Helvetica Bold). It is more
* specific than both a font family name (such as Helvetica).
- *
- * @param lc The locale in which to describe the name of the font face.
- *
- * @return A string containing the font face name, localized for the
- * provided locale.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFamily()
- */
- public String getFontName (Locale lc)
-{
- return peer.getFontName (this, lc);
-}
+ *
+ * @param lc The locale in which to describe the name of the font face.
+ *
+ * @return A string containing the font face name, localized for the
+ * provided locale.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ */
+ public String getFontName(Locale lc)
+ {
+ return peer.getFontName(this, lc);
+ }
-/**
- * Returns the italic angle of this font, a measurement of its slant when
- * style is {@link #ITALIC}. The precise meaning is the inverse slope of a
- * caret line which "best measures" the font's italic posture.
- *
- * @return The italic angle.
- *
- * @see java.awt.font.TextAttribute#POSTURE
- */
- public float getItalicAngle ()
-{
- return peer.getItalicAngle (this);
-}
+ /**
+ * Returns the italic angle of this font, a measurement of its slant when
+ * style is {@link #ITALIC}. The precise meaning is the inverse slope of a
+ * caret line which "best measures" the font's italic posture.
+ *
+ * @return The italic angle.
+ *
+ * @see java.awt.font.TextAttribute#POSTURE
+ */
+ public float getItalicAngle()
+ {
+ return peer.getItalicAngle(this);
+ }
-/**
- * Returns a {@link LineMetrics} object constructed with the specified
- * text and {@link FontRenderContext}.
- *
- * @param text The string to calculate metrics from.
- * @param begin Index of first character in <code>text</code> to measure.
- * @param limit Index of last character in <code>text</code> to measure.
- * @param rc Context for calculating precise glyph placement and hints.
- *
- * @return A new {@link LineMetrics} object.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>text</code>.
- */
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param text The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>text</code>.
+ */
public LineMetrics getLineMetrics(String text, int begin,
int limit, FontRenderContext rc)
-{
- return peer.getLineMetrics (this, new StringCharacterIterator (text),
- begin, limit, rc);
-}
+ {
+ return peer.getLineMetrics(this, new StringCharacterIterator(text),
+ begin, limit, rc);
+ }
-/**
- * Returns a {@link LineMetrics} object constructed with the specified
- * text and {@link FontRenderContext}.
- *
- * @param chars The string to calculate metrics from.
- * @param begin Index of first character in <code>text</code> to measure.
- * @param limit Index of last character in <code>text</code> to measure.
- * @param rc Context for calculating precise glyph placement and hints.
- *
- * @return A new {@link LineMetrics} object.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>chars</code>.
- */
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param chars The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ */
public LineMetrics getLineMetrics(char[] chars, int begin,
int limit, FontRenderContext rc)
-{
- return peer.getLineMetrics (this, new StringCharacterIterator (new String(chars)),
- begin, limit, rc);
-}
+ {
+ return peer.getLineMetrics(this,
+ new StringCharacterIterator(new String(chars)),
+ begin, limit, rc);
+ }
-/**
- * Returns a {@link LineMetrics} object constructed with the specified
- * text and {@link FontRenderContext}.
- *
- * @param ci The string to calculate metrics from.
- * @param begin Index of first character in <code>text</code> to measure.
- * @param limit Index of last character in <code>text</code> to measure.
- * @param rc Context for calculating precise glyph placement and hints.
- *
- * @return A new {@link LineMetrics} object.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>ci</code>.
- */
- public LineMetrics getLineMetrics (CharacterIterator ci, int begin,
- int limit, FontRenderContext rc)
-{
- return peer.getLineMetrics (this, ci, begin, limit, rc);
-}
+ /**
+ * Returns a {@link LineMetrics} object constructed with the specified
+ * text and {@link FontRenderContext}.
+ *
+ * @param ci The string to calculate metrics from.
+ * @param begin Index of first character in <code>text</code> to measure.
+ * @param limit Index of last character in <code>text</code> to measure.
+ * @param rc Context for calculating precise glyph placement and hints.
+ *
+ * @return A new {@link LineMetrics} object.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>ci</code>.
+ */
+ public LineMetrics getLineMetrics(CharacterIterator ci, int begin,
+ int limit, FontRenderContext rc)
+ {
+ return peer.getLineMetrics(this, ci, begin, limit, rc);
+ }
-/**
- * Returns the maximal bounding box of all the bounding boxes in this
- * font, when the font's bounding boxes are evaluated in a given {@link
- * FontRenderContext}
- *
- * @param rc Context in which to evaluate bounding boxes.
- *
- * @return The maximal bounding box.
- */
- public Rectangle2D getMaxCharBounds (FontRenderContext rc)
-{
- return peer.getMaxCharBounds (this, rc);
-}
+ /**
+ * Returns the maximal bounding box of all the bounding boxes in this
+ * font, when the font's bounding boxes are evaluated in a given {@link
+ * FontRenderContext}
+ *
+ * @param rc Context in which to evaluate bounding boxes.
+ *
+ * @return The maximal bounding box.
+ */
+ public Rectangle2D getMaxCharBounds(FontRenderContext rc)
+ {
+ return peer.getMaxCharBounds(this, rc);
+ }
-/**
- * Returns the glyph code this font uses to represent missing glyphs. This
- * code will be present in glyph vectors when the font was unable to
- * locate a glyph to represent a particular character code.
- *
- * @return The missing glyph code.
- *
- * @since 1.2
- */
- public int getMissingGlyphCode ()
-{
- return peer.getMissingGlyphCode (this);
-}
+ /**
+ * Returns the glyph code this font uses to represent missing glyphs. This
+ * code will be present in glyph vectors when the font was unable to
+ * locate a glyph to represent a particular character code.
+ *
+ * @return The missing glyph code.
+ *
+ * @since 1.2
+ */
+ public int getMissingGlyphCode()
+ {
+ return peer.getMissingGlyphCode(this);
+ }
-/**
- * Returns the overall number of glyphs in this font. This number is one
- * more than the greatest glyph code used in any glyph vectors this font
- * produces. In other words, glyph codes are taken from the range
- * <code>[ 0, getNumGlyphs() - 1 ]</code>.
- *
- * @return The number of glyphs in this font.
- *
- * @since 1.2
- */
- public int getNumGlyphs ()
-{
- return peer.getMissingGlyphCode (this);
-}
+ /**
+ * Returns the overall number of glyphs in this font. This number is one
+ * more than the greatest glyph code used in any glyph vectors this font
+ * produces. In other words, glyph codes are taken from the range
+ * <code>[ 0, getNumGlyphs() - 1 ]</code>.
+ *
+ * @return The number of glyphs in this font.
+ *
+ * @since 1.2
+ */
+ public int getNumGlyphs()
+ {
+ return peer.getMissingGlyphCode(this);
+ }
-/**
- * Returns the PostScript Name of this font.
- *
- * @return The PostScript Name of this font.
- *
- * @since 1.2
- *
- * @see #getName()
- * @see #getFamily()
- * @see #getFontName()
- */
- public String getPSName ()
-{
- return peer.getPostScriptName (this);
-}
+ /**
+ * Returns the PostScript Name of this font.
+ *
+ * @return The PostScript Name of this font.
+ *
+ * @since 1.2
+ *
+ * @see #getName()
+ * @see #getFamily()
+ * @see #getFontName()
+ */
+ public String getPSName()
+ {
+ return peer.getPostScriptName(this);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param str The string to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @see #createGlyphVector(FontRenderContext, String)
- */
- public Rectangle2D getStringBounds (String str, FontRenderContext frc)
-{
- return getStringBounds (str, 0, str.length () - 1, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param str The string to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @see #createGlyphVector(FontRenderContext, String)
+ */
+ public Rectangle2D getStringBounds(String str, FontRenderContext frc)
+ {
+ return getStringBounds(str, 0, str.length() - 1, frc);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param str The string to measure.
- * @param begin Index of the first character in <code>str</code> to measure.
- * @param limit Index of the last character in <code>str</code> to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>str</code>.
- *
- * @since 1.2
- *
- * @see #createGlyphVector(FontRenderContext, String)
- */
- public Rectangle2D getStringBounds (String str, int begin,
- int limit, FontRenderContext frc)
-{
- return peer.getStringBounds (this, new StringCharacterIterator(str), begin, limit, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param str The string to measure.
+ * @param begin Index of the first character in <code>str</code> to measure.
+ * @param limit Index of the last character in <code>str</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>str</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, String)
+ */
+ public Rectangle2D getStringBounds(String str, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this, new StringCharacterIterator(str), begin,
+ limit, frc);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param ci The text to measure.
- * @param begin Index of the first character in <code>ci</code> to measure.
- * @param limit Index of the last character in <code>ci</code> to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>ci</code>.
- *
- * @since 1.2
- *
- * @see #createGlyphVector(FontRenderContext, CharacterIterator)
- */
- public Rectangle2D getStringBounds (CharacterIterator ci, int begin,
- int limit, FontRenderContext frc)
-{
- return peer.getStringBounds (this, ci, begin, limit, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param ci The text to measure.
+ * @param begin Index of the first character in <code>ci</code> to measure.
+ * @param limit Index of the last character in <code>ci</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>ci</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, CharacterIterator)
+ */
+ public Rectangle2D getStringBounds(CharacterIterator ci, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this, ci, begin, limit, frc);
+ }
-/**
- * Returns the logical bounds of the specified string when rendered with this
- * font in the specified {@link FontRenderContext}. This box will include the
- * glyph origin, ascent, advance, height, and leading, but may not include all
- * diacritics or accents. To get the complete visual bounding box of all the
- * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
- * {@link TextLayout}.
- *
- * @param chars The text to measure.
- * @param begin Index of the first character in <code>ci</code> to measure.
- * @param limit Index of the last character in <code>ci</code> to measure.
- * @param frc The context in which to make the precise glyph measurements.
- *
- * @return A bounding box covering the logical bounds of the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>chars</code>.
- *
- * @since 1.2
- *
- * @see #createGlyphVector(FontRenderContext, char[])
- */
- public Rectangle2D getStringBounds (char[] chars, int begin,
- int limit, FontRenderContext frc)
-{
- return peer.getStringBounds (this, new StringCharacterIterator (new String (chars)),
- begin, limit, frc);
-}
+ /**
+ * Returns the logical bounds of the specified string when rendered with this
+ * font in the specified {@link FontRenderContext}. This box will include the
+ * glyph origin, ascent, advance, height, and leading, but may not include all
+ * diacritics or accents. To get the complete visual bounding box of all the
+ * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
+ * {@link TextLayout}.
+ *
+ * @param chars The text to measure.
+ * @param begin Index of the first character in <code>ci</code> to measure.
+ * @param limit Index of the last character in <code>ci</code> to measure.
+ * @param frc The context in which to make the precise glyph measurements.
+ *
+ * @return A bounding box covering the logical bounds of the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ *
+ * @since 1.2
+ *
+ * @see #createGlyphVector(FontRenderContext, char[])
+ */
+ public Rectangle2D getStringBounds(char[] chars, int begin,
+ int limit, FontRenderContext frc)
+ {
+ return peer.getStringBounds(this,
+ new StringCharacterIterator(new String(chars)),
+ begin, limit, frc);
+ }
-/**
- * Returns a copy of the affine transformation this font is currently
- * subject to, if any.
- *
- * @return The current transformation.
- */
- public AffineTransform getTransform ()
-{
- return peer.getTransform (this);
-}
+ /**
+ * Returns a copy of the affine transformation this font is currently
+ * subject to, if any.
+ *
+ * @return The current transformation.
+ */
+ public AffineTransform getTransform()
+ {
+ return peer.getTransform(this);
+ }
-/**
- * Indicates whether this font's line metrics are uniform. A font may be
- * composed of several "subfonts", each covering a different code range,
- * and each with their own line metrics. A font with no subfonts, or
- * subfonts with identical line metrics, is said to have "uniform" line
- * metrics.
- *
- * @return Whether this font has uniform line metrics.
- *
- * @see LineMetrics
- * @see #getLineMetrics(String, FontRenderContext)
- */
- public boolean hasUniformLineMetrics ()
-{
- return peer.hasUniformLineMetrics (this);
-}
+ /**
+ * Indicates whether this font's line metrics are uniform. A font may be
+ * composed of several "subfonts", each covering a different code range,
+ * and each with their own line metrics. A font with no subfonts, or
+ * subfonts with identical line metrics, is said to have "uniform" line
+ * metrics.
+ *
+ * @return Whether this font has uniform line metrics.
+ *
+ * @see LineMetrics
+ * @see #getLineMetrics(String, FontRenderContext)
+ */
+ public boolean hasUniformLineMetrics()
+ {
+ return peer.hasUniformLineMetrics(this);
+ }
-/**
- * Indicates whether this font is subject to a non-identity affine
- * transformation.
- *
- * @return <code>true</code> iff the font has a non-identity affine
- * transformation applied to it.
- */
- public boolean isTransformed ()
-{
- return peer.isTransformed (this);
-}
+ /**
+ * Indicates whether this font is subject to a non-identity affine
+ * transformation.
+ *
+ * @return <code>true</code> iff the font has a non-identity affine
+ * transformation applied to it.
+ */
+ public boolean isTransformed()
+ {
+ return peer.isTransformed(this);
+ }
-/**
- * Produces a glyph vector representing a full layout fo the specified
- * text in this font. Full layouts may include complex shaping and
- * reordering operations, for scripts such as Arabic or Hindi.
- *
- * Bidirectional (bidi) layout is not performed in this method; text
- * should have its bidi direction specified with one of the flags {@link
- * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}.
- *
- * Some types of layout (notably Arabic glyph shaping) may examine context
- * characters beyond the bounds of the indicated range, in order to select
- * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and
- * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra
- * context areas from being examined, for instance if they contain invalid
- * characters.
- *
- * @param frc Context in which to perform the layout.
- * @param chars Text to perform layout on.
- * @param start Index of first character to perform layout on.
- * @param limit Index of last character to perform layout on.
- * @param flags Combination of flags controlling layout.
- *
- * @return A new {@link GlyphVector} representing the specified text.
- *
- * @throws IndexOutOfBoundsException if the range [begin, limit] is
- * invalid in <code>chars</code>.
- */
- public GlyphVector layoutGlyphVector (FontRenderContext frc,
- char[] chars, int start,
- int limit, int flags)
-{
- return peer.layoutGlyphVector (this, frc, chars, start, limit, flags);
-}
+ /**
+ * Produces a glyph vector representing a full layout fo the specified
+ * text in this font. Full layouts may include complex shaping and
+ * reordering operations, for scripts such as Arabic or Hindi.
+ *
+ * Bidirectional (bidi) layout is not performed in this method; text
+ * should have its bidi direction specified with one of the flags {@link
+ * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}.
+ *
+ * Some types of layout (notably Arabic glyph shaping) may examine context
+ * characters beyond the bounds of the indicated range, in order to select
+ * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and
+ * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra
+ * context areas from being examined, for instance if they contain invalid
+ * characters.
+ *
+ * @param frc Context in which to perform the layout.
+ * @param chars Text to perform layout on.
+ * @param start Index of first character to perform layout on.
+ * @param limit Index of last character to perform layout on.
+ * @param flags Combination of flags controlling layout.
+ *
+ * @return A new {@link GlyphVector} representing the specified text.
+ *
+ * @throws IndexOutOfBoundsException if the range [begin, limit] is
+ * invalid in <code>chars</code>.
+ */
+ public GlyphVector layoutGlyphVector(FontRenderContext frc,
+ char[] chars, int start,
+ int limit, int flags)
+ {
+ return peer.layoutGlyphVector(this, frc, chars, start, limit, flags);
+ }
-/**
- * Returns a native peer object for this font.
- *
- * @return A native peer object for this font.
- *
- * @deprecated
- */
- public FontPeer getPeer ()
-{
+ /**
+ * Returns a native peer object for this font.
+ *
+ * @return A native peer object for this font.
+ *
+ * @deprecated
+ */
+ public FontPeer getPeer()
+ {
return peer;
-}
+ }
-/**
- * Returns a hash value for this font.
- *
- * @return A hash for this font.
- */
+ /**
+ * Returns a hash value for this font.
+ *
+ * @return A hash for this font.
+ */
public int hashCode()
-{
+ {
return this.toString().hashCode();
-}
-
-
-/**
- * Tests whether or not the specified object is equal to this font. This
- * will be true if and only if:
- * <P>
- * <ul>
- * <li>The object is not <code>null</code>.
- * <li>The object is an instance of <code>Font</code>.
- * <li>The object has the same names, style, size, and transform as this object.
- * </ul>
- *
- * @return <code>true</code> if the specified object is equal to this
- * object, <code>false</code> otherwise.
- */
-public boolean
-equals(Object obj)
-{
- if (obj == null)
- return(false);
+ }
- if (!(obj instanceof Font))
- return(false);
- Font f = (Font)obj;
+ /**
+ * Tests whether or not the specified object is equal to this font. This
+ * will be true if and only if:
+ * <P>
+ * <ul>
+ * <li>The object is not <code>null</code>.
+ * <li>The object is an instance of <code>Font</code>.
+ * <li>The object has the same names, style, size, and transform as this object.
+ * </ul>
+ *
+ * @return <code>true</code> if the specified object is equal to this
+ * object, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ return false;
- return (f.getName ().equals (this.getName ()) &&
- f.getFamily ().equals (this.getFamily ()) &&
- f.getFontName ().equals (this.getFontName ()) &&
- f.getTransform ().equals (this.getTransform ()) &&
- f.getSize() == this.getSize() &&
- f.getStyle() == this.getStyle());
-}
+ if (! (obj instanceof Font))
+ return false;
-/*************************************************************************/
+ Font f = (Font) obj;
-/**
- * Returns a string representation of this font.
- *
- * @return A string representation of this font.
- */
-public String
-toString()
-{
- String styleString = "";
-
- switch (getStyle ())
- {
- case 0:
- styleString = "plain";
- break;
- case 1:
- styleString = "bold";
- break;
- case 2:
- styleString = "italic";
- break;
- default:
- styleString = "unknown";
- }
+ return (f.getName().equals(this.getName())
+ && f.getFamily().equals(this.getFamily())
+ && f.getFontName().equals(this.getFontName())
+ && f.getTransform().equals(this.getTransform ())
+ && f.getSize() == this.getSize()
+ && f.getStyle() == this.getStyle());
+ }
- return getClass ().getName ()
- + "[family=" + getFamily ()
- + ",name=" + getFontName ()
- + ",style=" + styleString
- + ",size=" + getSize () + "]";
-}
+ /**
+ * Returns a string representation of this font.
+ *
+ * @return A string representation of this font.
+ */
+ public String toString()
+ {
+ String styleString = "";
+
+ switch (getStyle())
+ {
+ case 0:
+ styleString = "plain";
+ break;
+ case 1:
+ styleString = "bold";
+ break;
+ case 2:
+ styleString = "italic";
+ break;
+ default:
+ styleString = "unknown";
+ }
+
+ return getClass().getName()
+ + "[family=" + getFamily ()
+ + ",name=" + getFontName ()
+ + ",style=" + styleString
+ + ",size=" + getSize () + "]";
+ }
/**
@@ -1331,8 +1321,22 @@ toString()
*/
public LineMetrics getLineMetrics(String str, FontRenderContext frc)
{
- return getLineMetrics (str, 0, str.length () - 1, frc);
+ return getLineMetrics(str, 0, str.length() - 1, frc);
}
-} // class Font
+ /**
+ * Reads the normal fields from the stream and then constructs the
+ * peer from the style and size through getPeerFromToolkit().
+ */
+ private void readObject(ObjectInputStream ois)
+ throws IOException, ClassNotFoundException
+ {
+ ois.defaultReadObject();
+
+ HashMap attrs = new HashMap();
+ ClasspathFontPeer.copyStyleToAttrs(style, attrs);
+ ClasspathFontPeer.copySizeToAttrs(size, attrs);
+ peer = getPeerFromToolkit(name, attrs);
+ }
+}
diff --git a/libjava/classpath/java/awt/FontMetrics.java b/libjava/classpath/java/awt/FontMetrics.java
index 6dd73ec2560..91866462fee 100644
--- a/libjava/classpath/java/awt/FontMetrics.java
+++ b/libjava/classpath/java/awt/FontMetrics.java
@@ -362,6 +362,18 @@ public abstract class FontMetrics implements java.io.Serializable
rc = gRC;
return font.getLineMetrics(chars, begin, limit, rc);
}
+
+ /**
+ * Returns the bounds of the largest character in a Graphics context.
+ * @param context the Graphics context object.
+ * @return a <code>Rectangle2D</code> representing the bounds
+ */
+ public Rectangle2D getMaxCharBounds(Graphics context)
+ {
+ if( context instanceof Graphics2D )
+ return font.getMaxCharBounds(((Graphics2D)context).getFontRenderContext());
+ return font.getMaxCharBounds( gRC );
+ }
/**
* Returns a {@link LineMetrics} object constructed with the
@@ -424,4 +436,13 @@ public abstract class FontMetrics implements java.io.Serializable
return gRC;
}
+
+ /**
+ * Returns if the font has uniform line metrics.
+ * @see Font#hasUniformLineMetrics()
+ */
+ public boolean hasUniformLineMetrics()
+ {
+ return font.hasUniformLineMetrics();
+ }
}
diff --git a/libjava/classpath/java/awt/Frame.java b/libjava/classpath/java/awt/Frame.java
index 05c938496e0..d6651f83e40 100644
--- a/libjava/classpath/java/awt/Frame.java
+++ b/libjava/classpath/java/awt/Frame.java
@@ -591,6 +591,8 @@ public static Frame[] getFrames()
protected class AccessibleAWTFrame extends AccessibleAWTWindow
{
+ private static final long serialVersionUID = -6172960752956030250L;
+
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.FRAME;
diff --git a/libjava/classpath/java/awt/Graphics.java b/libjava/classpath/java/awt/Graphics.java
index ff26190e5f0..a28ca7e428c 100644
--- a/libjava/classpath/java/awt/Graphics.java
+++ b/libjava/classpath/java/awt/Graphics.java
@@ -42,726 +42,595 @@ import java.awt.image.ImageObserver;
import java.text.AttributedCharacterIterator;
/**
- * This is the abstract superclass of classes for drawing to graphics
- * devices such as the screen or printers.
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- * @author Warren Levy (warrenl@cygnus.com)
- */
-public abstract class Graphics
-{
-
-/*
- * Instance Variables
- */
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * Default constructor for subclasses.
- */
-protected
-Graphics()
-{
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
+ * This is the abstract superclass of classes for drawing to graphics
+ * devices such as the screen or printers.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Warren Levy (warrenl@cygnus.com)
*/
-
-/**
- * Returns a copy of this <code>Graphics</code> object.
- *
- * @return A copy of this object.
- */
-public abstract Graphics
-create();
-
-/*************************************************************************/
-
-/**
- * Returns a copy of this <code>Graphics</code> object. The origin point
- * will be translated to the point (x, y) and the cliping rectangle set
- * to the intersection of the clipping rectangle in this object and the
- * rectangle specified by the parameters to this method.
- *
- * @param x The new X coordinate of the clipping region rect.
- * @param y The new Y coordinate of the clipping region rect.
- * @param width The width of the clipping region intersect rectangle.
- * @param height The height of the clipping region intersect rectangle.
- *
- * @return A copy of this object, modified as specified.
- */
-public Graphics
-create(int x, int y, int width, int height)
+public abstract class Graphics
{
- Graphics g = create();
-
- g.translate(x, y);
- // FIXME: I'm not sure if this will work. Are the old clip rect bounds
- // translated above?
- g.clipRect(0, 0, width, height);
- return(g);
-}
-
-/*************************************************************************/
-
-/**
- * Translates this context so that its new origin point is the point
- * (x, y).
- *
- * @param x The new X coordinate of the origin.
- * @param y The new Y coordinate of the origin.
- */
-public abstract void
-translate(int x, int y);
-
-/*************************************************************************/
-
-/**
- * Returns the current color for this object.
- *
- * @return The color for this object.
- */
-public abstract Color
-getColor();
-
-/*************************************************************************/
-
-/**
- * Sets the current color for this object.
- *
- * @param color The new color.
- */
-public abstract void
-setColor(Color color);
-
-/*************************************************************************/
-
-/**
- * Sets this context into "paint" mode, where the target pixels are
- * completely overwritten when drawn on.
- */
-public abstract void
-setPaintMode();
-
-/*************************************************************************/
-
-/**
- * Sets this context info "XOR" mode, where the targe pixles are
- * XOR-ed when drawn on.
- *
- * @param color The color to XOR against.
- */
-public abstract void
-setXORMode(Color color);
+ /**
+ * Default constructor for subclasses.
+ */
+ protected
+ Graphics()
+ {
+ }
+
+ /**
+ * Returns a copy of this <code>Graphics</code> object.
+ *
+ * @return A copy of this object.
+ */
+ public abstract Graphics create();
+
+ /**
+ * Returns a copy of this <code>Graphics</code> object. The origin point
+ * will be translated to the point (x, y) and the cliping rectangle set
+ * to the intersection of the clipping rectangle in this object and the
+ * rectangle specified by the parameters to this method.
+ *
+ * @param x The new X coordinate of the clipping region rect.
+ * @param y The new Y coordinate of the clipping region rect.
+ * @param width The width of the clipping region intersect rectangle.
+ * @param height The height of the clipping region intersect rectangle.
+ *
+ * @return A copy of this object, modified as specified.
+ */
+ public Graphics create(int x, int y, int width, int height)
+ {
+ Graphics g = create();
+
+ g.translate(x, y);
+ // FIXME: I'm not sure if this will work. Are the old clip rect bounds
+ // translated above?
+ g.clipRect(0, 0, width, height);
+
+ return(g);
+ }
+
+ /**
+ * Translates this context so that its new origin point is the point
+ * (x, y).
+ *
+ * @param x The new X coordinate of the origin.
+ * @param y The new Y coordinate of the origin.
+ */
+ public abstract void translate(int x, int y);
+
+ /**
+ * Returns the current color for this object.
+ *
+ * @return The color for this object.
+ */
+ public abstract Color getColor();
+
+ /**
+ * Sets the current color for this object.
+ *
+ * @param color The new color.
+ */
+ public abstract void setColor(Color color);
+
+ /**
+ * Sets this context into "paint" mode, where the target pixels are
+ * completely overwritten when drawn on.
+ */
+ public abstract void setPaintMode();
+
+ /**
+ * Sets this context info "XOR" mode, where the targe pixles are
+ * XOR-ed when drawn on.
+ *
+ * @param color The color to XOR against.
+ */
+ public abstract void setXORMode(Color color);
-/*************************************************************************/
-
-/**
- * Returns the current font for this graphics context.
- *
- * @return The current font.
- */
-public abstract Font
-getFont();
-
-/*************************************************************************/
-
-/**
- * Sets the font for this graphics context to the specified value.
- *
- * @param font The new font.
- */
-public abstract void
-setFont(Font font);
-
-/*************************************************************************/
-
-/**
- * Returns the font metrics for the current font.
- *
- * @return The font metrics for the current font.
- */
-public FontMetrics
-getFontMetrics()
-{
- return(getFontMetrics(getFont()));
-}
-
-/*************************************************************************/
-
-/**
- * Returns the font metrics for the specified font.
- *
- * @param font The font to return metrics for.
- *
- * @return The requested font metrics.
- */
-public abstract FontMetrics
-getFontMetrics(Font font);
-
-/*************************************************************************/
-
-/**
- * Returns the bounding rectangle of the clipping region for this
- * graphics context.
- *
- * @return The bounding rectangle for the clipping region.
- */
-public abstract Rectangle
-getClipBounds();
-
-/*************************************************************************/
-
-/**
- * Returns the bounding rectangle of the clipping region for this
- * graphics context.
- *
- * @return The bounding rectangle for the clipping region.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getClipBounds()</code>.
- */
-public Rectangle
-getClipRect()
-{
- return(getClipBounds());
-}
-
-/*************************************************************************/
-
-/**
- * Sets the clipping region to the intersection of the current clipping
- * region and the rectangle determined by the specified parameters.
- *
- * @param x The X coordinate of the upper left corner of the intersect rect.
- * @param y The Y coordinate of the upper left corner of the intersect rect.
- * @param width The width of the intersect rect.
- * @param height The height of the intersect rect.
- */
-public abstract void
-clipRect(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Sets the clipping region to the rectangle determined by the specified
- * parameters.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- */
-public abstract void
-setClip(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Returns the current clipping region as a <code>Shape</code> object.
- *
- * @return The clipping region as a <code>Shape</code>.
- */
-public abstract Shape
-getClip();
-
-/*************************************************************************/
-
-/**
- * Sets the clipping region to the specified <code>Shape</code>.
- *
- * @param clip The new clipping region.
- */
-public abstract void
-setClip(Shape clip);
-
-/*************************************************************************/
-
-/**
- * Copies the specified rectangle to the specified offset location.
- *
- * @param x The X coordinate of the upper left corner of the copy rect.
- * @param y The Y coordinate of the upper left corner of the copy rect.
- * @param width The width of the copy rect.
- * @param height The height of the copy rect.
- * @param dx The offset from the X value to start drawing.
- * @param dy The offset from the Y value to start drawing.
- */
-public abstract void
-copyArea(int x, int y, int width, int height, int dx, int dy);
-
-/*************************************************************************/
-
-/**
- * Draws a line between the two specified points.
- *
- * @param x1 The X coordinate of the first point.
- * @param y1 The Y coordinate of the first point.
- * @param x2 The X coordinate of the second point.
- * @param y2 The Y coordinate of the second point.
- */
-public abstract void
-drawLine(int x1, int y1, int x2, int y2);
-
-/*************************************************************************/
-
-/**
- * Fills the area bounded by the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the fill rect.
- * @param y The Y coordinate of the upper left corner of the fill rect.
- * @param width The width of the fill rect.
- * @param height The height of the fill rect.
- */
-public abstract void
-fillRect(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Draws the outline of the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the draw rect.
- * @param y The Y coordinate of the upper left corner of the draw rect.
- * @param width The width of the draw rect.
- * @param height The height of the draw rect.
- */
-public void
-drawRect(int x, int y, int width, int height)
-{
- int x1 = x;
- int y1 = y;
- int x2 = x + width;
- int y2 = y + height;
- drawLine(x1, y1, x2, y1);
- drawLine(x2, y1, x2, y2);
- drawLine(x2, y2, x1, y2);
- drawLine(x1, y2, x1, y1);
-}
-
-/*************************************************************************/
-
-/**
- * Clears the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the clear rect.
- * @param y The Y coordinate of the upper left corner of the clear rect.
- * @param width The width of the clear rect.
- * @param height The height of the clear rect.
- */
-public abstract void
-clearRect(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Draws the outline of the specified rectangle with rounded cornders.
- *
- * @param x The X coordinate of the upper left corner of the draw rect.
- * @param y The Y coordinate of the upper left corner of the draw rect.
- * @param width The width of the draw rect.
- * @param height The height of the draw rect.
- * @param arcWidth The width of the corner arcs.
- * @param arcHeight The height of the corner arcs.
- */
-public abstract void
-drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);
-
-/*************************************************************************/
-
-/**
- * Fills the specified rectangle with rounded cornders.
- *
- * @param x The X coordinate of the upper left corner of the fill rect.
- * @param y The Y coordinate of the upper left corner of the fill rect.
- * @param width The width of the fill rect.
- * @param height The height of the fill rect.
- * @param arcWidth The width of the corner arcs.
- * @param arcHeight The height of the corner arcs.
- */
-public abstract void
-fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);
-
-/*************************************************************************/
-
-public void
-draw3DRect(int x, int y, int width, int height, boolean raised)
-{
- Color color = getColor();
- Color tl = color.brighter();
- Color br = color.darker();
+ /**
+ * Returns the current font for this graphics context.
+ *
+ * @return The current font.
+ */
+ public abstract Font getFont();
+
+ /**
+ * Sets the font for this graphics context to the specified value.
+ *
+ * @param font The new font.
+ */
+ public abstract void setFont(Font font);
+
+ /**
+ * Returns the font metrics for the current font.
+ *
+ * @return The font metrics for the current font.
+ */
+ public FontMetrics getFontMetrics()
+ {
+ return getFontMetrics(getFont());
+ }
+
+ /**
+ * Returns the font metrics for the specified font.
+ *
+ * @param font The font to return metrics for.
+ *
+ * @return The requested font metrics.
+ */
+ public abstract FontMetrics getFontMetrics(Font font);
+
+ /**
+ * Returns the bounding rectangle of the clipping region for this
+ * graphics context.
+ *
+ * @return The bounding rectangle for the clipping region.
+ */
+ public abstract Rectangle getClipBounds();
+
+ /**
+ * Returns the bounding rectangle of the clipping region for this
+ * graphics context.
+ *
+ * @return The bounding rectangle for the clipping region.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getClipBounds()</code>.
+ */
+ public Rectangle getClipRect()
+ {
+ return getClipBounds();
+ }
+
+ /**
+ * Sets the clipping region to the intersection of the current clipping
+ * region and the rectangle determined by the specified parameters.
+ *
+ * @param x The X coordinate of the upper left corner of the intersect rect.
+ * @param y The Y coordinate of the upper left corner of the intersect rect.
+ * @param width The width of the intersect rect.
+ * @param height The height of the intersect rect.
+ */
+ public abstract void clipRect(int x, int y, int width, int height);
+
+ /**
+ * Sets the clipping region to the rectangle determined by the specified
+ * parameters.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void setClip(int x, int y, int width, int height);
+
+ /**
+ * Returns the current clipping region as a <code>Shape</code> object.
+ *
+ * @return The clipping region as a <code>Shape</code>.
+ */
+ public abstract Shape getClip();
+
+ /**
+ * Sets the clipping region to the specified <code>Shape</code>.
+ *
+ * @param clip The new clipping region.
+ */
+ public abstract void setClip(Shape clip);
+
+ /**
+ * Copies the specified rectangle to the specified offset location.
+ *
+ * @param x The X coordinate of the upper left corner of the copy rect.
+ * @param y The Y coordinate of the upper left corner of the copy rect.
+ * @param width The width of the copy rect.
+ * @param height The height of the copy rect.
+ * @param dx The offset from the X value to start drawing.
+ * @param dy The offset from the Y value to start drawing.
+ */
+ public abstract void copyArea(int x, int y, int width, int height, int dx,
+ int dy);
+
+ /**
+ * Draws a line between the two specified points.
+ *
+ * @param x1 The X coordinate of the first point.
+ * @param y1 The Y coordinate of the first point.
+ * @param x2 The X coordinate of the second point.
+ * @param y2 The Y coordinate of the second point.
+ */
+ public abstract void drawLine(int x1, int y1, int x2, int y2);
+
+ /**
+ * Fills the area bounded by the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ */
+ public abstract void fillRect(int x, int y, int width, int height);
+
+ /**
+ * Draws the outline of the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the draw rect.
+ * @param y The Y coordinate of the upper left corner of the draw rect.
+ * @param width The width of the draw rect.
+ * @param height The height of the draw rect.
+ */
+ public void drawRect(int x, int y, int width, int height)
+ {
+ int x1 = x;
+ int y1 = y;
+ int x2 = x + width;
+ int y2 = y + height;
+ drawLine(x1, y1, x2, y1);
+ drawLine(x2, y1, x2, y2);
+ drawLine(x2, y2, x1, y2);
+ drawLine(x1, y2, x1, y1);
+ }
+
+ /**
+ * Clears the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the clear rect.
+ * @param y The Y coordinate of the upper left corner of the clear rect.
+ * @param width The width of the clear rect.
+ * @param height The height of the clear rect.
+ */
+ public abstract void clearRect(int x, int y, int width, int height);
+
+ /**
+ * Draws the outline of the specified rectangle with rounded cornders.
+ *
+ * @param x The X coordinate of the upper left corner of the draw rect.
+ * @param y The Y coordinate of the upper left corner of the draw rect.
+ * @param width The width of the draw rect.
+ * @param height The height of the draw rect.
+ * @param arcWidth The width of the corner arcs.
+ * @param arcHeight The height of the corner arcs.
+ */
+ public abstract void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight);
+
+ /**
+ * Fills the specified rectangle with rounded cornders.
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ * @param arcWidth The width of the corner arcs.
+ * @param arcHeight The height of the corner arcs.
+ */
+ public abstract void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight);
+
+ public void draw3DRect(int x, int y, int width, int height, boolean raised)
+ {
+ Color color = getColor();
+ Color tl = color.brighter();
+ Color br = color.darker();
- if (!raised)
- {
- Color tmp = tl;
- tl = br;
- br = tmp;
- }
+ if (!raised)
+ {
+ Color tmp = tl;
+ tl = br;
+ br = tmp;
+ }
- int x1 = x;
- int y1 = y;
- int x2 = x + width;
- int y2 = y + height;
+ int x1 = x;
+ int y1 = y;
+ int x2 = x + width;
+ int y2 = y + height;
- setColor(tl);
- drawLine(x1, y1, x2, y1);
- drawLine(x1, y2, x1, y1);
- setColor(br);
- drawLine(x2, y1, x2, y2);
- drawLine(x2, y2, x1, y2);
- setColor(color);
-}
-
-/**
- * Fills the specified rectangle with a 3D effect
- *
- * @param x The X coordinate of the upper left corner of the fill rect.
- * @param y The Y coordinate of the upper left corner of the fill rect.
- * @param width The width of the fill rect.
- * @param height The height of the fill rect.
- * @param raised <code>true</code> if the rectangle appears raised,
- * <code>false</code> if it should appear etched.
- */
-public void
-fill3DRect(int x, int y, int width, int height, boolean raised)
-{
- fillRect(x, y, width, height);
- draw3DRect(x, y, width-1, height-1, raised);
-}
-
-/*************************************************************************/
-
-/**
- * Draws an oval that just fits within the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- */
-public abstract void
-drawOval(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Fills an oval that just fits within the specified rectangle.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- */
-public abstract void
-fillOval(int x, int y, int width, int height);
-
-/*************************************************************************/
-
-/**
- * Draws an arc using the specified bounding rectangle and the specified
- * angle parameter. The arc is centered at the center of the rectangle.
- * The arc starts at the arcAngle position and extend for arcAngle
- * degrees. The degree origin is at the 3 o'clock position.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- * @param arcStart The beginning angle of the arc.
- * @param arcAngle The extent of the arc.
- */
-public abstract void
-drawArc(int x, int y, int width, int height, int arcStart, int arcAngle);
-
-/*************************************************************************/
-
-/**
- * Fills the arc define by the specified bounding rectangle and the specified
- * angle parameter. The arc is centered at the center of the rectangle.
- * The arc starts at the arcAngle position and extend for arcAngle
- * degrees. The degree origin is at the 3 o'clock position.
- *
- * @param x The X coordinate of the upper left corner of the rect.
- * @param y The Y coordinate of the upper left corner of the rect.
- * @param width The width of the rect.
- * @param height The height of the rect.
- * @param arcStart The beginning angle of the arc.
- * @param arcAngle The extent of the arc.
- */
-public abstract void
-fillArc(int x, int y, int width, int height, int arcStart, int arcAngle);
-
-/*************************************************************************/
-
-/**
- * Draws a series of interconnected lines determined by the arrays
- * of corresponding x and y coordinates.
- *
- * @param xPoints The X coordinate array.
- * @param yPoints The Y coordinate array.
- * @param npoints The number of points to draw.
- */
-public abstract void
-drawPolyline(int xPoints[], int yPoints[], int npoints);
-
-/*************************************************************************/
-
-/**
- * Draws a series of interconnected lines determined by the arrays
- * of corresponding x and y coordinates. The figure is closed if necessary
- * by connecting the first and last points.
- *
- * @param xPoints The X coordinate array.
- * @param yPoints The Y coordinate array.
- * @param npoints The number of points to draw.
- */
-public abstract void
-drawPolygon(int xPoints[], int yPoints[], int npoints);
-
-/*************************************************************************/
-
-/**
- * Draws the specified polygon.
- *
- * @param polygon The polygon to draw.
- */
-public void
-drawPolygon(Polygon polygon)
-{
- drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
-}
-
-/*************************************************************************/
-
-/**
- * Fills the polygon determined by the arrays
- * of corresponding x and y coordinates.
- *
- * @param xPoints The X coordinate array.
- * @param yPoints The Y coordinate array.
- * @param npoints The number of points to draw.
- */
-public abstract void
-fillPolygon(int xPoints[], int yPoints[], int npoints);
-
-/*************************************************************************/
-
-/**
- * Fills the specified polygon
- *
- * @param polygon The polygon to fill.
- */
-public void
-fillPolygon(Polygon polygon)
-{
- fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
-}
-
-/*************************************************************************/
-
-/**
- * Draws the specified string starting at the specified point.
- *
- * @param string The string to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- */
-public abstract void
-drawString(String string, int x, int y);
-
-public abstract void drawString (AttributedCharacterIterator ci, int x, int y);
-
-/*************************************************************************/
-
-/**
- * Draws the specified characters starting at the specified point.
- *
- * @param data The array of characters to draw.
- * @param offset The offset into the array to start drawing characters from.
- * @param length The number of characters to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- */
-public void
-drawChars(char data[], int offset, int length, int x, int y)
-{
- drawString(new String(data, offset, length), x, y);
-}
-
-public void
-drawBytes(byte[] data, int offset, int length, int x, int y)
-{
- String str = new String(data, offset, length);
- drawString(str, x, y);
-}
-
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, ImageObserver observer);
+ setColor(tl);
+ drawLine(x1, y1, x2, y1);
+ drawLine(x1, y2, x1, y1);
+ setColor(br);
+ drawLine(x2, y1, x2, y2);
+ drawLine(x2, y2, x1, y2);
+ setColor(color);
+ }
+
+ /**
+ * Fills the specified rectangle with a 3D effect
+ *
+ * @param x The X coordinate of the upper left corner of the fill rect.
+ * @param y The Y coordinate of the upper left corner of the fill rect.
+ * @param width The width of the fill rect.
+ * @param height The height of the fill rect.
+ * @param raised <code>true</code> if the rectangle appears raised,
+ * <code>false</code> if it should appear etched.
+ */
+ public void fill3DRect(int x, int y, int width, int height, boolean raised)
+ {
+ fillRect(x, y, width, height);
+ draw3DRect(x, y, width-1, height-1, raised);
+ }
+
+ /**
+ * Draws an oval that just fits within the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void drawOval(int x, int y, int width, int height);
+
+ /**
+ * Fills an oval that just fits within the specified rectangle.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ */
+ public abstract void fillOval(int x, int y, int width, int height);
+
+ /**
+ * Draws an arc using the specified bounding rectangle and the specified
+ * angle parameter. The arc is centered at the center of the rectangle.
+ * The arc starts at the arcAngle position and extend for arcAngle
+ * degrees. The degree origin is at the 3 o'clock position.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ * @param arcStart The beginning angle of the arc.
+ * @param arcAngle The extent of the arc.
+ */
+ public abstract void drawArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle);
+
+ /**
+ * Fills the arc define by the specified bounding rectangle and the specified
+ * angle parameter. The arc is centered at the center of the rectangle.
+ * The arc starts at the arcAngle position and extend for arcAngle
+ * degrees. The degree origin is at the 3 o'clock position.
+ *
+ * @param x The X coordinate of the upper left corner of the rect.
+ * @param y The Y coordinate of the upper left corner of the rect.
+ * @param width The width of the rect.
+ * @param height The height of the rect.
+ * @param arcStart The beginning angle of the arc.
+ * @param arcAngle The extent of the arc.
+ */
+ public abstract void fillArc(int x, int y, int width, int height,
+ int arcStart, int arcAngle);
+
+ /**
+ * Draws a series of interconnected lines determined by the arrays
+ * of corresponding x and y coordinates.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void drawPolyline(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Draws a series of interconnected lines determined by the arrays
+ * of corresponding x and y coordinates. The figure is closed if necessary
+ * by connecting the first and last points.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void drawPolygon(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Draws the specified polygon.
+ *
+ * @param polygon The polygon to draw.
+ */
+ public void drawPolygon(Polygon polygon)
+ {
+ drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
+ }
+
+ /**
+ * Fills the polygon determined by the arrays
+ * of corresponding x and y coordinates.
+ *
+ * @param xPoints The X coordinate array.
+ * @param yPoints The Y coordinate array.
+ * @param npoints The number of points to draw.
+ */
+ public abstract void fillPolygon(int xPoints[], int yPoints[], int npoints);
+
+ /**
+ * Fills the specified polygon
+ *
+ * @param polygon The polygon to fill.
+ */
+ public void fillPolygon(Polygon polygon)
+ {
+ fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
+ }
+
+ /**
+ * Draws the specified string starting at the specified point.
+ *
+ * @param string The string to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ */
+ public abstract void drawString(String string, int x, int y);
+
+ public abstract void drawString (AttributedCharacterIterator ci, int x,
+ int y);
+
+ /**
+ * Draws the specified characters starting at the specified point.
+ *
+ * @param data The array of characters to draw.
+ * @param offset The offset into the array to start drawing characters from.
+ * @param length The number of characters to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ */
+ public void drawChars(char data[], int offset, int length, int x, int y)
+ {
+ drawString(new String(data, offset, length), x, y);
+ }
+
+ public void drawBytes(byte[] data, int offset, int length, int x, int y)
+ {
+ String str = new String(data, offset, length);
+ drawString(str, x, y);
+ }
+
+ /**
+ * Draws all of the image that is available and returns. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y,
+ ImageObserver observer);
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. The image
- * is scaled to fit in the specified rectangle. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param width The width of the rectangle to draw in.
- * @param height The height of the rectangle to draw in.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, int width, int height,
- ImageObserver observer);
+ /**
+ * Draws all of the image that is available and returns. The image
+ * is scaled to fit in the specified rectangle. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param width The width of the rectangle to draw in.
+ * @param height The height of the rectangle to draw in.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, int width,
+ int height, ImageObserver observer);
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param bgcolor The background color to use for the image.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer);
+ /**
+ * Draws all of the image that is available and returns. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param bgcolor The background color to use for the image.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, Color bgcolor,
+ ImageObserver observer);
-/*************************************************************************/
-
-/**
- * Draws all of the image that is available and returns. The image
- * is scaled to fit in the specified rectangle. If the image
- * is not completely loaded, <code>false</code> is returned and
- * the specified iamge observer is notified as more data becomes
- * available.
- *
- * @param image The image to draw.
- * @param x The X coordinate of the point to draw at.
- * @param y The Y coordinate of the point to draw at.
- * @param width The width of the rectangle to draw in.
- * @param height The height of the rectangle to draw in.
- * @param bgcolor The background color to use for the image.
- * @param observer The image observer to notify as data becomes available.
- *
- * @return <code>true</code> if all the image data is available,
- * <code>false</code> otherwise.
- */
-public abstract boolean
-drawImage(Image image, int x, int y, int width, int height, Color bgcolor,
- ImageObserver observer);
-
-/*************************************************************************/
-
-/**
- * FIXME: Write Javadocs for this when you understand it.
- */
-public abstract boolean
-drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
- int sx2, int sy2, ImageObserver observer);
-
-/*************************************************************************/
-
-/**
- * FIXME: Write Javadocs for this when you understand it.
- */
-public abstract boolean
-drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
- int sx2, int sy2, Color bgcolor, ImageObserver observer);
-
-/*************************************************************************/
-
-/**
- * Free any resources held by this graphics context immediately instead
- * of waiting for the object to be garbage collected and finalized.
- */
-public abstract void
-dispose();
-
-/*************************************************************************/
-
-/**
- * Frees the resources held by this graphics context when it is
- * garbage collected.
- */
-public void
-finalize()
-{
- dispose();
-}
-
-/*************************************************************************/
-
-/**
- * Returns a string representation of this object.
- *
- * @return A string representation of this object.
- */
-public String
-toString()
-{
- return getClass ().getName () + "[font=" + getFont () + ",color=" + getColor () + "]";
-}
-
-public boolean
-hitClip(int x, int y, int width, int height)
-{
- throw new UnsupportedOperationException("not implemented yet");
-}
-
-public Rectangle
-getClipBounds(Rectangle r)
-{
- Rectangle clipBounds = getClipBounds();
+ /**
+ * Draws all of the image that is available and returns. The image
+ * is scaled to fit in the specified rectangle. If the image
+ * is not completely loaded, <code>false</code> is returned and
+ * the specified iamge observer is notified as more data becomes
+ * available.
+ *
+ * @param image The image to draw.
+ * @param x The X coordinate of the point to draw at.
+ * @param y The Y coordinate of the point to draw at.
+ * @param width The width of the rectangle to draw in.
+ * @param height The height of the rectangle to draw in.
+ * @param bgcolor The background color to use for the image.
+ * @param observer The image observer to notify as data becomes available.
+ *
+ * @return <code>true</code> if all the image data is available,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean drawImage(Image image, int x, int y, int width,
+ int height, Color bgcolor,
+ ImageObserver observer);
+
+ /**
+ * FIXME: Write Javadocs for this when you understand it.
+ */
+ public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
+ int dy2, int sx1, int sy1, int sx2,
+ int sy2, ImageObserver observer);
+
+ /**
+ * FIXME: Write Javadocs for this when you understand it.
+ */
+ public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2,
+ int dy2, int sx1, int sy1, int sx2,
+ int sy2, Color bgcolor,
+ ImageObserver observer);
+
+ /**
+ * Free any resources held by this graphics context immediately instead
+ * of waiting for the object to be garbage collected and finalized.
+ */
+ public abstract void dispose();
+
+ /**
+ * Frees the resources held by this graphics context when it is
+ * garbage collected.
+ */
+ public void finalize()
+ {
+ dispose();
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString()
+ {
+ return getClass ().getName () + "[font=" + getFont () + ",color="
+ + getColor () + "]";
+ }
+
+ /**
+ * Returns <code>true</code> if the specified rectangle intersects with the
+ * current clip, <code>false</code> otherwise.
+ *
+ * @param x the X coordinate of the upper left corner of the test rectangle
+ * @param y the Y coordinate of the upper left corner of the test rectangle
+ * @param width the width of the upper left corner of the test rectangle
+ * @param height the height of the upper left corner of the test rectangle
+ * @return <code>true</code> if the specified rectangle intersects with the
+ * current clip, <code>false</code> otherwise
+ */
+ public boolean hitClip(int x, int y, int width, int height)
+ {
+ return getClip().intersects(x, y, width, height);
+ }
+
+ public Rectangle getClipBounds(Rectangle r)
+ {
+ Rectangle clipBounds = getClipBounds();
- if (r == null)
- return clipBounds;
-
- r.x = clipBounds.x;
- r.y = clipBounds.y;
- r.width = clipBounds.width;
- r.height = clipBounds.height;
- return r;
+ if (r == null)
+ return clipBounds;
+
+ r.x = clipBounds.x;
+ r.y = clipBounds.y;
+ r.width = clipBounds.width;
+ r.height = clipBounds.height;
+ return r;
+ }
}
-
-} // class Graphics
-
diff --git a/libjava/classpath/java/awt/GraphicsConfiguration.java b/libjava/classpath/java/awt/GraphicsConfiguration.java
index 069d7414b3d..1526ad3cfc0 100644
--- a/libjava/classpath/java/awt/GraphicsConfiguration.java
+++ b/libjava/classpath/java/awt/GraphicsConfiguration.java
@@ -130,11 +130,10 @@ public abstract class GraphicsConfiguration
* with the given transparency. Because the buffer is volatile, it
* can be optimized by native graphics accelerators.
*
- * @param w the width of the buffer
- * @param h the height of the buffer
+ * @param width the width of the buffer
+ * @param height the height of the buffer
* @param transparency the transparency value for the buffer
* @return the buffered image, or null if none is supported
- * @throws AWTException if the capabilities cannot be met
* @since 1.5
*/
public abstract VolatileImage createCompatibleVolatileImage(int width,
diff --git a/libjava/classpath/java/awt/GridBagLayout.java b/libjava/classpath/java/awt/GridBagLayout.java
index 7f9ab249b6d..083c0b7a7a3 100644
--- a/libjava/classpath/java/awt/GridBagLayout.java
+++ b/libjava/classpath/java/awt/GridBagLayout.java
@@ -705,17 +705,20 @@ public class GridBagLayout
if (lastInCol.containsKey(new Integer(x)))
{
Component lastComponent = (Component) lastInRow.get(new Integer(x));
- GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
-
- if (lastConstraints.gridheight == GridBagConstraints.RELATIVE)
+ if (lastComponent != null)
{
- constraints.gridy = max_y - 1;
- break;
- }
- else
- {
- constraints.gridy = Math.max (constraints.gridy,
- lastConstraints.gridy + Math.max (1, lastConstraints.gridheight));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+
+ if (lastConstraints.gridheight == GridBagConstraints.RELATIVE)
+ {
+ constraints.gridy = max_y - 1;
+ break;
+ }
+ else
+ {
+ constraints.gridy = Math.max (constraints.gridy,
+ lastConstraints.gridy + Math.max (1, lastConstraints.gridheight));
+ }
}
}
}
diff --git a/libjava/classpath/java/awt/Image.java b/libjava/classpath/java/awt/Image.java
index b657ad007d9..93c2c479024 100644
--- a/libjava/classpath/java/awt/Image.java
+++ b/libjava/classpath/java/awt/Image.java
@@ -38,7 +38,9 @@ exception statement from your version. */
package java.awt;
+import java.awt.image.AreaAveragingScaleFilter;
import java.awt.image.FilteredImageSource;
+import java.awt.image.ImageFilter;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.ReplicateScaleFilter;
@@ -141,7 +143,6 @@ public abstract class Image
* This method is only valid for off-screen objects.
*
* @return a graphics context object for an off-screen object
- * @see Graphics#getcreateImage(int, int)
*/
public abstract Graphics getGraphics();
@@ -179,20 +180,25 @@ public abstract class Image
*/
public Image getScaledInstance(int width, int height, int flags)
{
+ ImageFilter filter;
switch (flags)
{
case SCALE_DEFAULT:
case SCALE_FAST:
case SCALE_REPLICATE:
- ImageProducer producer =
- new FilteredImageSource(this.getSource(),
- new ReplicateScaleFilter(width, height));
- return Toolkit.getDefaultToolkit().createImage(producer);
- case SCALE_SMOOTH:
+ filter = new ReplicateScaleFilter(width, height);
+ break;
case SCALE_AREA_AVERAGING:
+ filter = new AreaAveragingScaleFilter(width, height);
+ break;
+ case SCALE_SMOOTH:
+ throw new Error("SCALE_SMOOTH: not implemented");
default:
- throw new Error("not implemented");
+ throw new Error("Unknown flag or not implemented: " + flags);
}
+
+ ImageProducer producer = new FilteredImageSource(getSource(), filter);
+ return Toolkit.getDefaultToolkit().createImage(producer);
}
/**
diff --git a/libjava/classpath/java/awt/KeyboardFocusManager.java b/libjava/classpath/java/awt/KeyboardFocusManager.java
index f64618477bd..371ea9bdf8a 100644
--- a/libjava/classpath/java/awt/KeyboardFocusManager.java
+++ b/libjava/classpath/java/awt/KeyboardFocusManager.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt;
import java.applet.Applet;
+import java.awt.FocusTraversalPolicy;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
@@ -213,7 +214,7 @@ public abstract class KeyboardFocusManager
currentFocusOwners */
private static Map currentFocusCycleRoots = new HashMap ();
- /** The default {@link FocusTraveralPolicy} that focus-managing
+ /** The default {@link FocusTraversalPolicy} that focus-managing
{@link Container}s will use to define their initial focus
traversal policy. */
private FocusTraversalPolicy defaultPolicy;
@@ -287,7 +288,7 @@ public abstract class KeyboardFocusManager
KeyboardFocusManager manager;
if (m == null)
- manager = createFocusManager();
+ manager = new DefaultKeyboardFocusManager();
else
manager = m;
@@ -295,46 +296,6 @@ public abstract class KeyboardFocusManager
}
/**
- * Creates a KeyboardFocusManager. The exact class is determined by the
- * system property 'gnu.java.awt.FocusManager'. If this is not set,
- * we default to DefaultKeyboardFocusManager.
- */
- private static KeyboardFocusManager createFocusManager()
- {
- String fmClassName = System.getProperty("gnu.java.awt.FocusManager",
- "java.awt.DefaultKeyboardFocusManager");
- try
- {
- Class fmClass = Class.forName(fmClassName);
- KeyboardFocusManager fm = (KeyboardFocusManager) fmClass.newInstance();
- return fm;
- }
- catch (ClassNotFoundException ex)
- {
- System.err.println("The class " + fmClassName + " cannot be found.");
- System.err.println("Check the setting of the system property");
- System.err.println("gnu.java.awt.FocusManager");
- return null;
- }
- catch (InstantiationException ex)
- {
- System.err.println("The class " + fmClassName + " cannot be");
- System.err.println("instantiated.");
- System.err.println("Check the setting of the system property");
- System.err.println("gnu.java.awt.FocusManager");
- return null;
- }
- catch (IllegalAccessException ex)
- {
- System.err.println("The class " + fmClassName + " cannot be");
- System.err.println("accessed.");
- System.err.println("Check the setting of the system property");
- System.err.println("gnu.java.awt.FocusManager");
- return null;
- }
- }
-
- /**
* Retrieve the {@link Component} that has the keyboard focus, or
* null if the focus owner was not set by a thread in the current
* {@link java.lang.ThreadGroup}.
@@ -1364,11 +1325,11 @@ public abstract class KeyboardFocusManager
*
* @return a global object set by the current ThreadGroup, or null
*
- * @see getFocusOwner
- * @see getPermanentFocusOwner
- * @see getFocusedWindow
- * @see getActiveWindow
- * @see getCurrentFocusCycleRoot
+ * @see #getFocusOwner()
+ * @see #getPermanentFocusOwner()
+ * @see #getFocusedWindow()
+ * @see #getActiveWindow()
+ * @see #getCurrentFocusCycleRoot()
*/
private Object getObject (Map globalMap)
{
@@ -1388,11 +1349,11 @@ public abstract class KeyboardFocusManager
* @throws SecurityException if this is not the keyboard focus
* manager associated with the current {@link java.lang.ThreadGroup}
*
- * @see getGlobalFocusOwner
- * @see getGlobalPermanentFocusOwner
- * @see getGlobalFocusedWindow
- * @see getGlobalActiveWindow
- * @see getGlobalCurrentFocusCycleRoot
+ * @see #getGlobalFocusOwner()
+ * @see #getGlobalPermanentFocusOwner()
+ * @see #getGlobalFocusedWindow()
+ * @see #getGlobalActiveWindow()
+ * @see #getGlobalCurrentFocusCycleRoot()
*/
private Object getGlobalObject (Map globalMap)
{
@@ -1432,11 +1393,11 @@ public abstract class KeyboardFocusManager
* @param newObject the object to set
* @param property the property that will change
*
- * @see setGlobalFocusOwner
- * @see setGlobalPermanentFocusOwner
- * @see setGlobalFocusedWindow
- * @see setGlobalActiveWindow
- * @see setGlobalCurrentFocusCycleRoot
+ * @see #setGlobalFocusOwner(Component)
+ * @see #setGlobalPermanentFocusOwner(Component)
+ * @see #setGlobalFocusedWindow(Window)
+ * @see #setGlobalActiveWindow(Window)
+ * @see #setGlobalCurrentFocusCycleRoot(Container)
*/
private void setGlobalObject (Map globalMap,
Object newObject,
diff --git a/libjava/classpath/java/awt/List.java b/libjava/classpath/java/awt/List.java
index ab7d359633e..00636a0224f 100644
--- a/libjava/classpath/java/awt/List.java
+++ b/libjava/classpath/java/awt/List.java
@@ -1088,18 +1088,23 @@ paramString()
protected class AccessibleAWTList extends AccessibleAWTComponent
implements AccessibleSelection, ItemListener, ActionListener
{
+ private static final long serialVersionUID = 7924617370136012829L;
+
protected class AccessibleAWTListChild extends AccessibleAWTComponent
implements Accessible
{
- private int index;
+ private static final long serialVersionUID = 4412022926028300317L;
+
+ // Field names are fixed by serialization spec.
private List parent;
+ private int indexInParent;
public AccessibleAWTListChild(List parent, int indexInParent)
{
this.parent = parent;
- index = indexInParent;
+ this.indexInParent = indexInParent;
if (parent == null)
- index = -1;
+ this.indexInParent = -1;
}
/* (non-Javadoc)
@@ -1118,14 +1123,14 @@ paramString()
public AccessibleStateSet getAccessibleStateSet()
{
AccessibleStateSet states = super.getAccessibleStateSet();
- if (parent.isIndexSelected(index))
+ if (parent.isIndexSelected(indexInParent))
states.add(AccessibleState.SELECTED);
return states;
}
public int getAccessibleIndexInParent()
{
- return index;
+ return indexInParent;
}
}
diff --git a/libjava/classpath/java/awt/Menu.java b/libjava/classpath/java/awt/Menu.java
index 56ceccfc542..13ebb5211be 100644
--- a/libjava/classpath/java/awt/Menu.java
+++ b/libjava/classpath/java/awt/Menu.java
@@ -441,6 +441,8 @@ paramString()
*/
protected class AccessibleAWTMenu extends AccessibleAWTMenuItem
{
+ private static final long serialVersionUID = 5228160894980069094L;
+
protected AccessibleAWTMenu()
{
}
diff --git a/libjava/classpath/java/awt/MenuComponent.java b/libjava/classpath/java/awt/MenuComponent.java
index ec6980e10ca..375d08436e0 100644
--- a/libjava/classpath/java/awt/MenuComponent.java
+++ b/libjava/classpath/java/awt/MenuComponent.java
@@ -1157,7 +1157,7 @@ protected abstract class AccessibleAWTMenuComponent
* the appropriate information.
*
* @param color the new color to use for the background.
- * @see getBackground()
+ * @see #getBackground()
*/
public void setBackground(Color color)
{
@@ -1217,7 +1217,7 @@ protected abstract class AccessibleAWTMenuComponent
*
* @param enabled true if the component should be enabled,
* false otherwise.
- * @see #getEnabled()
+ * @see #isEnabled()
*/
public void setEnabled(boolean enabled)
{
diff --git a/libjava/classpath/java/awt/MenuItem.java b/libjava/classpath/java/awt/MenuItem.java
index 58dcb674146..3e39d118a05 100644
--- a/libjava/classpath/java/awt/MenuItem.java
+++ b/libjava/classpath/java/awt/MenuItem.java
@@ -108,6 +108,8 @@ private transient ActionListener action_listeners;
extends MenuComponent.AccessibleAWTMenuComponent
implements AccessibleAction, AccessibleValue
{
+ private static final long serialVersionUID = -217847831945965825L;
+
/** Constructor */
public AccessibleAWTMenuItem()
{
diff --git a/libjava/classpath/java/awt/Point.java b/libjava/classpath/java/awt/Point.java
index 492749b8dc3..31b72e2cc75 100644
--- a/libjava/classpath/java/awt/Point.java
+++ b/libjava/classpath/java/awt/Point.java
@@ -226,6 +226,10 @@ public class Point extends Point2D implements Serializable
*/
public boolean equals(Object obj)
{
+ // NOTE: No special hashCode() method is required for this class,
+ // as this equals() implementation is functionally equivalent to
+ // super.equals(), which does define a proper hashCode().
+
if (! (obj instanceof Point2D))
return false;
Point2D p = (Point2D) obj;
diff --git a/libjava/classpath/java/awt/Polygon.java b/libjava/classpath/java/awt/Polygon.java
index a72522cb089..403c336cde5 100644
--- a/libjava/classpath/java/awt/Polygon.java
+++ b/libjava/classpath/java/awt/Polygon.java
@@ -544,7 +544,6 @@ public class Polygon implements Shape, Serializable
* the positive X, or Y axis, within a given interval.
*
* @return the winding number.
- * @see #condensed
* @see #contains(double, double)
*/
private int evaluateCrossings(double x, double y, boolean useYaxis,
diff --git a/libjava/classpath/java/awt/PopupMenu.java b/libjava/classpath/java/awt/PopupMenu.java
index 90d48d903b9..540fffda718 100644
--- a/libjava/classpath/java/awt/PopupMenu.java
+++ b/libjava/classpath/java/awt/PopupMenu.java
@@ -140,6 +140,8 @@ show(Component component, int x, int y)
protected class AccessibleAWTPopupMenu extends AccessibleAWTMenu
{
+ private static final long serialVersionUID = -4282044795947239955L;
+
protected AccessibleAWTPopupMenu()
{
}
diff --git a/libjava/classpath/java/awt/Rectangle.java b/libjava/classpath/java/awt/Rectangle.java
index 0f21d495cd8..c4ba6ba1488 100644
--- a/libjava/classpath/java/awt/Rectangle.java
+++ b/libjava/classpath/java/awt/Rectangle.java
@@ -727,6 +727,10 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public boolean equals(Object obj)
{
+ // NOTE: No special hashCode() method is required for this class,
+ // as this equals() implementation is functionally equivalent to
+ // super.equals(), which does define a proper hashCode().
+
if (! (obj instanceof Rectangle2D))
return false;
Rectangle2D r = (Rectangle2D) obj;
diff --git a/libjava/classpath/java/awt/ScrollPane.java b/libjava/classpath/java/awt/ScrollPane.java
index b3ecc59fcd5..525d9d3e7da 100644
--- a/libjava/classpath/java/awt/ScrollPane.java
+++ b/libjava/classpath/java/awt/ScrollPane.java
@@ -401,7 +401,7 @@ setScrollPosition(int x, int y)
public void
addNotify()
{
- if (!isDisplayable ())
+ if (peer != null)
return;
setPeer((ComponentPeer)getToolkit().createScrollPane(this));
@@ -592,6 +592,8 @@ paramString()
protected class AccessibleAWTScrollPane extends AccessibleAWTContainer
{
+ private static final long serialVersionUID = 6100703663886637L;
+
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.SCROLL_PANE;
diff --git a/libjava/classpath/java/awt/ScrollPaneAdjustable.java b/libjava/classpath/java/awt/ScrollPaneAdjustable.java
index cfca19b4423..bec5b5106de 100644
--- a/libjava/classpath/java/awt/ScrollPaneAdjustable.java
+++ b/libjava/classpath/java/awt/ScrollPaneAdjustable.java
@@ -87,12 +87,16 @@ public class ScrollPaneAdjustable
public void addAdjustmentListener (AdjustmentListener listener)
{
- AWTEventMulticaster.add (adjustmentListener, listener);
+ if (listener == null)
+ return;
+ adjustmentListener = AWTEventMulticaster.add (adjustmentListener, listener);
}
public void removeAdjustmentListener (AdjustmentListener listener)
{
- AWTEventMulticaster.remove (adjustmentListener, listener);
+ if (listener == null)
+ return;
+ adjustmentListener = AWTEventMulticaster.remove (adjustmentListener, listener);
}
public AdjustmentListener[] getAdjustmentListeners ()
diff --git a/libjava/classpath/java/awt/TextArea.java b/libjava/classpath/java/awt/TextArea.java
index d422d3306d2..b04cdc89204 100644
--- a/libjava/classpath/java/awt/TextArea.java
+++ b/libjava/classpath/java/awt/TextArea.java
@@ -603,6 +603,8 @@ public class TextArea extends TextComponent implements java.io.Serializable
protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent
{
+ private static final long serialVersionUID = 3472827823632144419L;
+
protected AccessibleAWTTextArea()
{
}
diff --git a/libjava/classpath/java/awt/TextComponent.java b/libjava/classpath/java/awt/TextComponent.java
index 60e72fcb5cb..f08e59c9fc9 100644
--- a/libjava/classpath/java/awt/TextComponent.java
+++ b/libjava/classpath/java/awt/TextComponent.java
@@ -107,6 +107,8 @@ protected transient TextListener textListener;
extends AccessibleAWTComponent
implements AccessibleText, TextListener
{
+ private static final long serialVersionUID = 3631432373506317811L;
+
// Constructor
// Adds a listener for tracking caret changes
public AccessibleAWTTextComponent()
diff --git a/libjava/classpath/java/awt/TextField.java b/libjava/classpath/java/awt/TextField.java
index 4d62d024aad..3302a2eff89 100644
--- a/libjava/classpath/java/awt/TextField.java
+++ b/libjava/classpath/java/awt/TextField.java
@@ -523,6 +523,8 @@ paramString()
protected class AccessibleAWTTextField extends AccessibleAWTTextComponent
{
+ private static final long serialVersionUID = 6219164359235943158L;
+
protected AccessibleAWTTextField()
{
}
diff --git a/libjava/classpath/java/awt/Window.java b/libjava/classpath/java/awt/Window.java
index 1689d03706b..f8a620daebd 100644
--- a/libjava/classpath/java/awt/Window.java
+++ b/libjava/classpath/java/awt/Window.java
@@ -101,6 +101,8 @@ public class Window extends Container implements Accessible
protected class AccessibleAWTWindow extends AccessibleAWTContainer
{
+ private static final long serialVersionUID = 4215068635060671780L;
+
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.WINDOW;
@@ -278,14 +280,14 @@ public class Window extends Container implements Accessible
*/
public void show()
{
+ synchronized (getTreeLock())
+ {
if (parent != null && !parent.isDisplayable())
parent.addNotify();
if (peer == null)
addNotify();
// Show visible owned windows.
- synchronized (getTreeLock())
- {
Iterator e = ownedWindows.iterator();
while(e.hasNext())
{
@@ -302,14 +304,13 @@ public class Window extends Container implements Accessible
// synchronous access to ownedWindows there.
e.remove();
}
- }
validate();
super.show();
toFront();
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.setGlobalFocusedWindow (this);
-
+
if (!shown)
{
FocusTraversalPolicy policy = getFocusTraversalPolicy ();
@@ -323,6 +324,7 @@ public class Window extends Container implements Accessible
shown = true;
}
+ }
}
public void hide()
@@ -346,13 +348,6 @@ public class Window extends Container implements Accessible
super.hide();
}
- public boolean isDisplayable()
- {
- if (super.isDisplayable())
- return true;
- return peer != null;
- }
-
/**
* Destroys any resources associated with this window. This includes
* all components in the window and all owned top-level windows.
@@ -808,20 +803,81 @@ public class Window extends Container implements Accessible
return isVisible();
}
- public void setLocationRelativeTo (Component c)
+ public void setLocationRelativeTo(Component c)
{
- if (c == null || !c.isShowing ())
+ int x = 0;
+ int y = 0;
+
+ if (c == null || !c.isShowing())
{
- int x = 0;
- int y = 0;
-
- GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment ();
- Point center = ge.getCenterPoint ();
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Point center = ge.getCenterPoint();
x = center.x - (width / 2);
y = center.y - (height / 2);
- setLocation (x, y);
}
- // FIXME: handle case where component is non-null.
+ else
+ {
+ int cWidth = c.getWidth();
+ int cHeight = c.getHeight();
+ Dimension screenSize = getToolkit().getScreenSize();
+
+ x = c.getLocationOnScreen().x;
+ y = c.getLocationOnScreen().y;
+
+ // If bottom of component is cut off, window placed
+ // on the left or the right side of component
+ if ((y + cHeight) > screenSize.height)
+ {
+ // If the right side of the component is closer to the center
+ if ((screenSize.width / 2 - x) <= 0)
+ {
+ if ((x - width) >= 0)
+ x -= width;
+ else
+ x = 0;
+ }
+ else
+ {
+ if ((x + cWidth + width) <= screenSize.width)
+ x += cWidth;
+ else
+ x = screenSize.width - width;
+ }
+
+ y = screenSize.height - height;
+ }
+ else if (cWidth > width || cHeight > height)
+ {
+ // If right side of component is cut off
+ if ((x + width) > screenSize.width)
+ x = screenSize.width - width;
+ // If left side of component is cut off
+ else if (x < 0)
+ x = 0;
+ else
+ x += (cWidth - width) / 2;
+
+ y += (cHeight - height) / 2;
+ }
+ else
+ {
+ // If right side of component is cut off
+ if ((x + width) > screenSize.width)
+ x = screenSize.width - width;
+ // If left side of component is cut off
+ else if (x < 0 || (x - (width - cWidth) / 2) < 0)
+ x = 0;
+ else
+ x -= (width - cWidth) / 2;
+
+ if ((y - (height - cHeight) / 2) > 0)
+ y -= (height - cHeight) / 2;
+ else
+ y = 0;
+ }
+ }
+
+ setLocation(x, y);
}
/**
@@ -938,8 +994,8 @@ public class Window extends Container implements Accessible
*
* @since 1.4
*/
- public void createBufferStrategy(int numBuffers,
- BufferCapabilities caps)
+ public void createBufferStrategy(int numBuffers, BufferCapabilities caps)
+ throws AWTException
{
if (numBuffers < 1)
throw new IllegalArgumentException("Window.createBufferStrategy: number"
@@ -951,15 +1007,7 @@ public class Window extends Container implements Accessible
// a flipping strategy was requested
if (caps.isPageFlipping())
- {
- try
- {
- bufferStrategy = new WindowFlipBufferStrategy(numBuffers);
- }
- catch (AWTException e)
- {
- }
- }
+ bufferStrategy = new WindowFlipBufferStrategy(numBuffers);
else
bufferStrategy = new WindowBltBufferStrategy(numBuffers, true);
}
diff --git a/libjava/classpath/java/awt/color/ICC_Profile.java b/libjava/classpath/java/awt/color/ICC_Profile.java
index 75f55a1dacb..1072cd694db 100644
--- a/libjava/classpath/java/awt/color/ICC_Profile.java
+++ b/libjava/classpath/java/awt/color/ICC_Profile.java
@@ -324,11 +324,11 @@ public class ICC_Profile implements Serializable
* An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
* may be returned if appropriate.
*
- * @throws IllegalArgumentException if the profile data is an invalid
- * v2 profile.
- *
* @param data - the profile data
* @return An ICC_Profile object
+ *
+ * @throws IllegalArgumentException if the profile data is an invalid
+ * v2 profile.
*/
public static ICC_Profile getInstance(byte[] data)
{
@@ -373,12 +373,12 @@ public class ICC_Profile implements Serializable
* An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
* may be returned if appropriate.
*
+ * @param filename - the file name of the profile file.
+ * @return An ICC_Profile object
+ *
* @throws IllegalArgumentException if the profile data is an invalid
* v2 profile.
* @throws IOException if the file could not be read.
- *
- * @param filename - the file name of the profile file.
- * @return An ICC_Profile object
*/
public static ICC_Profile getInstance(String filename)
throws IOException
@@ -400,12 +400,12 @@ public class ICC_Profile implements Serializable
* An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
* may be returned if appropriate.
*
+ * @param in - the input stream to read the profile from.
+ * @return An ICC_Profile object
+ *
* @throws IllegalArgumentException if the profile data is an invalid
* v2 profile.
* @throws IOException if the stream could not be read.
- *
- * @param in - the input stream to read the profile from.
- * @return An ICC_Profile object
*/
public static ICC_Profile getInstance(InputStream in)
throws IOException
diff --git a/libjava/classpath/java/awt/event/InputEvent.java b/libjava/classpath/java/awt/event/InputEvent.java
index 8f9aed611f8..28cd9018599 100644
--- a/libjava/classpath/java/awt/event/InputEvent.java
+++ b/libjava/classpath/java/awt/event/InputEvent.java
@@ -197,17 +197,28 @@ public abstract class InputEvent extends ComponentEvent
private final long when;
/**
- * The modifiers in effect for this event. Package visible for use by
- * subclasses. The old style (bitmask 0x3f) should not be mixed with the
- * new style (bitmasks 0xffffffc0).
+ * The old-style modifiers in effect for this event. Package visible
+ * for use by subclasses. The old style (bitmask 0x3f) should not be
+ * mixed with the new style (bitmasks 0xffffffc0).
*
* @see #getModifiers()
* @see MouseEvent
- * @serial the modifier state, stored in the new style
+ * @serial the modifier state, stored in the old style
*/
int modifiers;
/**
+ * The new-style modifiers in effect for this event. Package visible
+ * for use by subclasses. The old style (bitmask 0x3f) should not be
+ * mixed with the new style (bitmasks 0xffffffc0).
+ *
+ * @see #getModifiersEx()
+ * @see MouseEvent
+ * @serial the modifier state, stored in the new style
+ */
+ int modifiersEx;
+
+ /**
* Initializes a new instance of <code>InputEvent</code> with the specified
* source, id, timestamp, and modifiers. Note that an invalid id leads to
* unspecified results.
@@ -222,7 +233,8 @@ public abstract class InputEvent extends ComponentEvent
{
super(source, id);
this.when = when;
- this.modifiers = EventModifier.extend(modifiers);
+ this.modifiers = modifiers & EventModifier.OLD_MASK;
+ this.modifiersEx = modifiers & EventModifier.NEW_MASK;
}
/**
@@ -232,7 +244,8 @@ public abstract class InputEvent extends ComponentEvent
*/
public boolean isShiftDown()
{
- return (modifiers & SHIFT_DOWN_MASK) != 0;
+ return ((modifiers & SHIFT_MASK) != 0)
+ || ((modifiersEx & SHIFT_DOWN_MASK) != 0);
}
/**
@@ -243,7 +256,8 @@ public abstract class InputEvent extends ComponentEvent
*/
public boolean isControlDown()
{
- return (modifiers & CTRL_DOWN_MASK) != 0;
+ return ((modifiers & CTRL_MASK) != 0)
+ || ((modifiersEx & CTRL_DOWN_MASK) != 0);
}
/**
@@ -253,7 +267,8 @@ public abstract class InputEvent extends ComponentEvent
*/
public boolean isMetaDown()
{
- return (modifiers & META_DOWN_MASK) != 0;
+ return ((modifiers & META_MASK) != 0)
+ || ((modifiersEx & META_DOWN_MASK) != 0);
}
/**
@@ -263,7 +278,8 @@ public abstract class InputEvent extends ComponentEvent
*/
public boolean isAltDown()
{
- return (modifiers & ALT_DOWN_MASK) != 0;
+ return ((modifiers & ALT_MASK) != 0)
+ || ((modifiersEx & ALT_DOWN_MASK) != 0);
}
/**
@@ -274,7 +290,8 @@ public abstract class InputEvent extends ComponentEvent
*/
public boolean isAltGraphDown()
{
- return (modifiers & ALT_GRAPH_DOWN_MASK) != 0;
+ return ((modifiers & ALT_GRAPH_MASK) != 0)
+ || ((modifiersEx & ALT_GRAPH_DOWN_MASK) != 0);
}
/**
@@ -300,7 +317,7 @@ public abstract class InputEvent extends ComponentEvent
*/
public int getModifiers()
{
- return EventModifier.revert(modifiers);
+ return modifiers;
}
/**
@@ -321,7 +338,7 @@ public abstract class InputEvent extends ComponentEvent
*/
public int getModifiersEx()
{
- return modifiers;
+ return modifiersEx;
}
/**
diff --git a/libjava/classpath/java/awt/event/InvocationEvent.java b/libjava/classpath/java/awt/event/InvocationEvent.java
index 75feb62bd94..6f39d6b9130 100644
--- a/libjava/classpath/java/awt/event/InvocationEvent.java
+++ b/libjava/classpath/java/awt/event/InvocationEvent.java
@@ -107,6 +107,13 @@ public class InvocationEvent extends AWTEvent implements ActiveEvent
private Exception exception;
/**
+ * This is the caught Throwable thrown in the <code>run()</code> method.
+ * It is null if throwables are ignored, the run method hasn't completed,
+ * or there were no throwables thrown.
+ */
+ private Throwable throwable;
+
+ /**
* The timestamp when this event was created.
*
* @see #getWhen()
@@ -183,9 +190,11 @@ public class InvocationEvent extends AWTEvent implements ActiveEvent
{
runnable.run();
}
- catch (Exception e)
+ catch (Throwable t)
{
- exception = e;
+ throwable = t;
+ if (t instanceof Exception)
+ exception = (Exception)t;
}
else
runnable.run();
@@ -211,6 +220,18 @@ public class InvocationEvent extends AWTEvent implements ActiveEvent
}
/**
+ * Returns a throwable caught while executing the Runnable's run() method.
+ * Null if none was thrown or if this InvocationEvent doesn't catch
+ * throwables.
+ * @return the caught Throwable
+ * @since 1.5
+ */
+ public Throwable getThrowable()
+ {
+ return throwable;
+ }
+
+ /**
* Gets the timestamp of when this event was created.
*
* @return the timestamp of this event
diff --git a/libjava/classpath/java/awt/event/KeyEvent.java b/libjava/classpath/java/awt/event/KeyEvent.java
index a40a8e15c04..d4b93ba3e0b 100644
--- a/libjava/classpath/java/awt/event/KeyEvent.java
+++ b/libjava/classpath/java/awt/event/KeyEvent.java
@@ -1735,6 +1735,6 @@ public class KeyEvent extends InputEvent
throws IOException, ClassNotFoundException
{
s.defaultReadObject();
- modifiers = EventModifier.extend(modifiers);
+ modifiersEx = EventModifier.extend(modifiers) & EventModifier.NEW_MASK;
}
} // class KeyEvent
diff --git a/libjava/classpath/java/awt/event/MouseEvent.java b/libjava/classpath/java/awt/event/MouseEvent.java
index 249c3d112e4..3e0fecacf94 100644
--- a/libjava/classpath/java/awt/event/MouseEvent.java
+++ b/libjava/classpath/java/awt/event/MouseEvent.java
@@ -42,6 +42,7 @@ import gnu.java.awt.EventModifier;
import java.awt.Component;
import java.awt.Point;
+import java.awt.PopupMenu;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -227,6 +228,12 @@ public class MouseEvent extends InputEvent
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);
}
/**
@@ -392,17 +399,9 @@ public class MouseEvent extends InputEvent
s.append("unknown type,(");
}
s.append(x).append(',').append(y).append("),button=").append(button);
- if ((modifiers & EventModifier.NEW_MASK) != 0)
- {
- int mod = modifiers;
- if ((mod & (ALT_DOWN_MASK | BUTTON2_DOWN_MASK)) != 0)
- mod |= ALT_DOWN_MASK | BUTTON2_DOWN_MASK;
- if ((mod & (META_DOWN_MASK | BUTTON3_DOWN_MASK)) != 0)
- mod |= META_DOWN_MASK | BUTTON3_DOWN_MASK;
- s.append(",modifiers=").append(getModifiersExText(mod));
- }
- if (modifiers != 0)
- s.append(",extModifiers=").append(getModifiersExText(modifiers));
+ // FIXME: need a mauve test for this method
+ if (modifiersEx != 0)
+ s.append(",extModifiers=").append(getModifiersExText(modifiersEx));
return s.append(",clickCount=").append(clickCount).toString();
}
@@ -426,7 +425,7 @@ public class MouseEvent extends InputEvent
button = BUTTON2;
else if ((modifiers & BUTTON3_MASK) != 0)
button = BUTTON3;
- modifiers = EventModifier.extend(modifiers);
+ modifiersEx = EventModifier.extend(modifiers) & EventModifier.NEW_MASK;
}
}
} // class MouseEvent
diff --git a/libjava/classpath/java/awt/geom/Area.java b/libjava/classpath/java/awt/geom/Area.java
index 7a0fac43a34..ad20b535f68 100644
--- a/libjava/classpath/java/awt/geom/Area.java
+++ b/libjava/classpath/java/awt/geom/Area.java
@@ -1215,7 +1215,7 @@ public class Area implements Shape, Cloneable
* @param t1 - global parametric value of the first curve's starting point
* @param t2 - global parametric value of the second curve's starting point
* @param w1 - global parametric length of curve 1
- * @param c1 - global parametric length of curve 2
+ * @param w2 - global parametric length of curve 2
*
* The final four parameters are for keeping track of the parametric
* value of the curve. For a full curve t = 0, w = 1, w is halved with
diff --git a/libjava/classpath/java/awt/geom/GeneralPath.java b/libjava/classpath/java/awt/geom/GeneralPath.java
index f54855874dc..15fb8aba811 100644
--- a/libjava/classpath/java/awt/geom/GeneralPath.java
+++ b/libjava/classpath/java/awt/geom/GeneralPath.java
@@ -558,7 +558,8 @@ public final class GeneralPath implements Shape, Cloneable
* Constructs a new iterator for enumerating the segments of a
* GeneralPath.
*
- * @param at an affine transformation for projecting the returned
+ * @param path the path to enumerate
+ * @param transform an affine transformation for projecting the returned
* points, or <code>null</code> to return the original points
* without any mapping.
*/
diff --git a/libjava/classpath/java/awt/im/InputContext.java b/libjava/classpath/java/awt/im/InputContext.java
index c0505e7e98b..0bb107e36d1 100644
--- a/libjava/classpath/java/awt/im/InputContext.java
+++ b/libjava/classpath/java/awt/im/InputContext.java
@@ -49,6 +49,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
+import java.text.AttributedCharacterIterator.Attribute;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -334,7 +335,7 @@ public class InputContext
/**
* Starts a reconversion operation in the current input method. The input
- * method gets theh text to reconvert from the client component, using
+ * method gets the text to reconvert from the client component, using
* {@link InputMethodRequests#getSelectedText(Attribute[])}. Then the
* composed and committed text produced by the operation is sent back to
* the client using a sequence of InputMethodRequests.
diff --git a/libjava/classpath/java/awt/im/InputMethodHighlight.java b/libjava/classpath/java/awt/im/InputMethodHighlight.java
index 0d664b19366..6fbe42fe549 100644
--- a/libjava/classpath/java/awt/im/InputMethodHighlight.java
+++ b/libjava/classpath/java/awt/im/InputMethodHighlight.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package java.awt.im;
+import java.awt.Toolkit;
+import java.text.Annotation;
+import java.text.AttributedCharacterIterator;
import java.util.Map;
/**
@@ -53,7 +56,7 @@ import java.util.Map;
* text segments.
*
* @author Eric Blake (ebb9@email.byu.edu)
- * @see AttributedCharacterIterators
+ * @see AttributedCharacterIterator
* @see Annotation
* @since 1.2
* @status updated to 1.4
diff --git a/libjava/classpath/java/awt/im/InputMethodRequests.java b/libjava/classpath/java/awt/im/InputMethodRequests.java
index d50ec33c5c8..0423358cc53 100644
--- a/libjava/classpath/java/awt/im/InputMethodRequests.java
+++ b/libjava/classpath/java/awt/im/InputMethodRequests.java
@@ -37,8 +37,10 @@ exception statement from your version. */
package java.awt.im;
+import java.awt.Component;
import java.awt.Rectangle;
import java.awt.font.TextHitInfo;
+import java.awt.event.InputMethodListener;
import java.text.AttributedCharacterIterator;
import java.text.AttributedCharacterIterator.Attribute;
diff --git a/libjava/classpath/java/awt/im/spi/InputMethod.java b/libjava/classpath/java/awt/im/spi/InputMethod.java
index 840d193a8d8..ebe4508418e 100644
--- a/libjava/classpath/java/awt/im/spi/InputMethod.java
+++ b/libjava/classpath/java/awt/im/spi/InputMethod.java
@@ -38,7 +38,11 @@ exception statement from your version. */
package java.awt.im.spi;
import java.awt.AWTEvent;
+import java.awt.Component;
import java.awt.Rectangle;
+import java.awt.im.InputContext;
+import java.awt.im.InputMethodRequests;
+import java.text.AttributedCharacterIterator.Attribute;
import java.util.Locale;
/**
@@ -152,8 +156,8 @@ public interface InputMethod
* Notify this input method of changes in the client window. This is called
* when notifications are enabled (see {@link
* InputMethodContext#enableClientWindowNotification(InputMethod, boolean)},
- * if {@link #removeNotify(Component)} has not been called. The following
- * situations trigger a notification:<ul>
+ * if {@link InputContext#removeNotify(Component)} has not been called.
+ * The following situations trigger a notification:<ul>
* <li>The client window changes in location, size, visibility,
* iconification, or is closed.</li>
* <li>When enabling client notification (or on the first activation after
@@ -202,7 +206,7 @@ public interface InputMethod
/**
* Notify the input method that a client component has been removed from its
* hierarchy, or that input method support has been disabled. This is
- * called by {@link InputContext#removeNotify()}, and only when the input
+ * called by {@link InputContext#removeNotify(Component)}, and only when the input
* method is inactive.
*/
void removeNotify();
diff --git a/libjava/classpath/java/awt/im/spi/InputMethodContext.java b/libjava/classpath/java/awt/im/spi/InputMethodContext.java
index 43bee8d8617..17ec4f8f7ee 100644
--- a/libjava/classpath/java/awt/im/spi/InputMethodContext.java
+++ b/libjava/classpath/java/awt/im/spi/InputMethodContext.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.im.spi;
+import java.awt.HeadlessException;
+import java.awt.Rectangle;
import java.awt.Window;
import java.awt.font.TextHitInfo;
import java.awt.im.InputMethodRequests;
@@ -113,7 +115,7 @@ public interface InputMethodContext extends InputMethodRequests
/**
* Sets whether notification of the client window's location and state should
* be enabled for the input method. When enabled, the input method's
- * {@link #notifyClientWindowChange(Rectangle)} method is called.
+ * {@link InputMethod#notifyClientWindowChange(Rectangle)} method is called.
* Notification is automatically disabled when the input method is disposed.
*
* @param inputMethod the method to change status of
diff --git a/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java b/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java
index 093d7319217..d234e5c57f3 100644
--- a/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java
+++ b/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java
@@ -39,6 +39,7 @@ package java.awt.im.spi;
import java.awt.AWTException;
import java.awt.Image;
+import java.awt.im.InputContext;
import java.util.Locale;
/**
@@ -57,7 +58,7 @@ public interface InputMethodDescriptor
* also by country and variant), via
* {@link InputContext#selectInputMethod(Locale)}. The returned list should
* ignore pass-through locales, so it is usually a subset of locales for
- * which {@link InputMethod#setContext(Locale)} returns true. If
+ * which {@link InputMethod#setLocale(Locale)} returns true. If
* {@link #hasDynamicLocaleList()} returns true, this is called each time
* information is needed, allowing dynamic addition or removal of supported
* locales.
diff --git a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
index 194d483d962..6333ce9e7f9 100644
--- a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
+++ b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
@@ -45,7 +45,7 @@ package java.awt.image;
* points should give the desired results although Sun does not
* specify what the exact algorithm should be.
* <br>
- * Currently this filter does nothing and needs to be implemented.
+ * FIXME: Currently this filter does nothing and needs to be implemented.
*
* @author C. Brian Jones (cbj@gnu.org)
*/
diff --git a/libjava/classpath/java/awt/image/BufferedImage.java b/libjava/classpath/java/awt/image/BufferedImage.java
index 124b81368e2..3cabfbde692 100644
--- a/libjava/classpath/java/awt/image/BufferedImage.java
+++ b/libjava/classpath/java/awt/image/BufferedImage.java
@@ -1,5 +1,5 @@
/* BufferedImage.java --
- Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation
+ Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation
This file is part of GNU Classpath.
@@ -48,9 +48,7 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
-import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.Vector;
/**
@@ -64,7 +62,7 @@ import java.util.Vector;
* @author Rolf W. Rasmussen (rolfwr@ii.uib.no)
*/
public class BufferedImage extends Image
- implements WritableRenderedImage
+ implements WritableRenderedImage, Transparency
{
public static final int TYPE_CUSTOM = 0,
TYPE_INT_RGB = 1,
@@ -690,4 +688,16 @@ public class BufferedImage extends Image
observers.remove (to);
}
+
+ /**
+ * Return the transparency type.
+ *
+ * @return One of {@link #OPAQUE}, {@link #BITMASK}, or {@link #TRANSLUCENT}.
+ * @see Transparency#getTransparency()
+ * @since 1.5
+ */
+ public int getTransparency()
+ {
+ return colorModel.getTransparency();
+ }
}
diff --git a/libjava/classpath/java/awt/image/ColorModel.java b/libjava/classpath/java/awt/image/ColorModel.java
index 1ebcb98a76b..1ced2a04366 100644
--- a/libjava/classpath/java/awt/image/ColorModel.java
+++ b/libjava/classpath/java/awt/image/ColorModel.java
@@ -609,7 +609,7 @@ public abstract class ColorModel implements Transparency
* @param obj Array of TransferType or null.
*
* @return pixel value encoded according to the color model.
- * @throws ArrayIndexOutOfBounds
+ * @throws ArrayIndexOutOfBoundsException
* @throws ClassCastException
* @since 1.4
*/
diff --git a/libjava/classpath/java/awt/image/ComponentSampleModel.java b/libjava/classpath/java/awt/image/ComponentSampleModel.java
index 953f63c1ea1..5cf06e4a17f 100644
--- a/libjava/classpath/java/awt/image/ComponentSampleModel.java
+++ b/libjava/classpath/java/awt/image/ComponentSampleModel.java
@@ -63,8 +63,11 @@ public class ComponentSampleModel extends SampleModel
protected int[] bandOffsets;
protected int[] bankIndices;
- // FIXME: Should we really shadow the numBands in the superclass?
- //protected int numBands;
+ /**
+ * Number of bands in the image described.
+ * @specnote This field shadows the protected numBands in SampleModel.
+ */
+ protected int numBands;
/** Used when creating data buffers. */
protected int numBanks;
@@ -100,6 +103,7 @@ public class ComponentSampleModel extends SampleModel
this.bandOffsets = bandOffsets;
this.bankIndices = bankIndices;
+ this.numBands = bandOffsets.length;
this.numBanks = 0;
for (int b=0; b<bankIndices.length; b++)
diff --git a/libjava/classpath/java/awt/image/ImageConsumer.java b/libjava/classpath/java/awt/image/ImageConsumer.java
index e1834c3978f..fc5ed11e5ca 100644
--- a/libjava/classpath/java/awt/image/ImageConsumer.java
+++ b/libjava/classpath/java/awt/image/ImageConsumer.java
@@ -75,7 +75,7 @@ public interface ImageConsumer
* most one call to <code>setPixels</code> for any single pixel.
*
* @see #setHints
- * @see #setPixels
+ * @see #setPixels(int, int, int, int, ColorModel, int[], int, int)
*/
int SINGLEPASS = 8;
diff --git a/libjava/classpath/java/awt/image/PackedColorModel.java b/libjava/classpath/java/awt/image/PackedColorModel.java
index 894e6e66fda..b60230fa70d 100644
--- a/libjava/classpath/java/awt/image/PackedColorModel.java
+++ b/libjava/classpath/java/awt/image/PackedColorModel.java
@@ -90,11 +90,7 @@ public abstract class PackedColorModel extends ColorModel
return bitsPerComponent;
}
- /** Initializes the masks.
- *
- * @return an array containing the number of bits per color
- * component.
- */
+ /** Initializes the masks. */
private void initMasks(int[] colorMaskArray, int alphaMask)
{
int numComponents = colorMaskArray.length;
diff --git a/libjava/classpath/java/awt/image/SampleModel.java b/libjava/classpath/java/awt/image/SampleModel.java
index 257e30a5bd5..1159662223c 100644
--- a/libjava/classpath/java/awt/image/SampleModel.java
+++ b/libjava/classpath/java/awt/image/SampleModel.java
@@ -47,7 +47,8 @@ public abstract class SampleModel
/** Height of image described. */
protected int height;
- /** Number of bands in the image described. */
+ /** Number of bands in the image described. Package-private here,
+ shadowed by ComponentSampleModel. */
protected int numBands;
/**
diff --git a/libjava/classpath/java/awt/print/PrinterJob.java b/libjava/classpath/java/awt/print/PrinterJob.java
index e61ab61bc77..e1aeabc3e62 100644
--- a/libjava/classpath/java/awt/print/PrinterJob.java
+++ b/libjava/classpath/java/awt/print/PrinterJob.java
@@ -169,8 +169,11 @@ public abstract class PrinterJob
/**
* Prints the page with given attributes.
*/
- public abstract void print (PrintRequestAttributeSet attributes)
- throws PrinterException;
+ public void print (PrintRequestAttributeSet attributes)
+ throws PrinterException
+ {
+ print ();
+ }
/**
* Displays a dialog box to the user which allows the print job
diff --git a/libjava/classpath/java/beans/IndexedPropertyDescriptor.java b/libjava/classpath/java/beans/IndexedPropertyDescriptor.java
index efdc7b40238..0ba2ed4f493 100644
--- a/libjava/classpath/java/beans/IndexedPropertyDescriptor.java
+++ b/libjava/classpath/java/beans/IndexedPropertyDescriptor.java
@@ -1,4 +1,4 @@
-/* java.beans.IndexedPropertyDescriptor
+/* IndexedPropertyDescriptor.java --
Copyright (C) 1998, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,266 +42,380 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method;
/**
- ** IndexedPropertyDescriptor describes information about a JavaBean
- ** indexed property, by which we mean an array-like property that
- ** has been exposed via a pair of get and set methods and another
- ** pair that allows you to get to the property by an index.<P>
- **
- ** An example property would have four methods like this:<P>
- ** <CODE>FooBar[] getFoo()</CODE><BR>
- ** <CODE>void setFoo(FooBar[])</CODE><BR>
- ** <CODE>FooBar getFoo(int)</CODE><BR>
- ** <CODE>void setFoo(int,FooBar)</CODE><P>
- **
- ** The constraints put on get and set methods are:<P>
- ** <OL>
- ** <LI>There must be at least a get(int) or a set(int,...) method.
- ** Nothing else is required. <B>Spec note:</B>One nice restriction
- ** would be that if there is a get() there must be a get(int), same
- ** with set, but that is not in the spec and is fairly harmless.)</LI>
- ** <LI>A get array method must have signature
- ** <CODE>&lt;propertyType&gt;[] &lt;getMethodName&gt;()</CODE></LI>
- ** <LI>A set array method must have signature
- ** <CODE>void &lt;setMethodName&gt;(&lt;propertyType&gt;[])</CODE></LI>
- ** <LI>A get index method must have signature
- ** <CODE>&lt;propertyType&gt; &lt;getMethodName&gt;(int)</CODE></LI>
- ** <LI>A set index method must have signature
- ** <CODE>void &lt;setMethodName&gt;(int,&lt;propertyType&gt;)</CODE></LI>
- ** <LI>All these methods may throw any exception.</LI>
- ** <LI>All these methods must be public.</LI>
- ** </OL>
- **
- ** @author John Keiser
- ** @since JDK1.1
- ** @version 1.1.0, 26 Jul 1998
- **/
+ * IndexedPropertyDescriptor describes information about a JavaBean
+ * indexed property, by which we mean an array-like property that
+ * has been exposed via a pair of get and set methods and another
+ * pair that allows you to get to the property by an index.<P>
+ *
+ * An example property would have four methods like this:<P>
+ * <CODE>FooBar[] getFoo()</CODE><BR>
+ * <CODE>void setFoo(FooBar[])</CODE><BR>
+ * <CODE>FooBar getFoo(int)</CODE><BR>
+ * <CODE>void setFoo(int,FooBar)</CODE><P>
+ *
+ * The constraints put on get and set methods are:<P>
+ * <OL>
+ * <LI>There must be at least a get(int) or a set(int,...) method.
+ * Nothing else is required. <B>Spec note:</B>One nice restriction
+ * would be that if there is a get() there must be a get(int), same
+ * with set, but that is not in the spec and is fairly harmless.)</LI>
+ * <LI>A get array method must have signature
+ * <CODE>&lt;propertyType&gt;[] &lt;getMethodName&gt;()</CODE></LI>
+ * <LI>A set array method must have signature
+ * <CODE>void &lt;setMethodName&gt;(&lt;propertyType&gt;[])</CODE></LI>
+ * <LI>A get index method must have signature
+ * <CODE>&lt;propertyType&gt; &lt;getMethodName&gt;(int)</CODE></LI>
+ * <LI>A set index method must have signature
+ * <CODE>void &lt;setMethodName&gt;(int,&lt;propertyType&gt;)</CODE></LI>
+ * <LI>All these methods may throw any exception.</LI>
+ * <LI>All these methods must be public.</LI>
+ * </OL>
+ *
+ * @author John Keiser
+ * @since JDK1.1
+ */
+public class IndexedPropertyDescriptor extends PropertyDescriptor
+{
+ private Class indexedPropertyType;
+ private Method setIndex;
+ private Method getIndex;
-public class IndexedPropertyDescriptor extends PropertyDescriptor {
- private Class indexedPropertyType;
- private Method setIndex;
- private Method getIndex;
+ /**
+ * Create a new IndexedPropertyDescriptor by introspection.
+ * This form of constructor creates the PropertyDescriptor by
+ * looking for getter methods named <CODE>get&lt;name&gt;()</CODE>
+ * and setter methods named
+ * <CODE>set&lt;name&gt;()</CODE> in class
+ * <CODE>&lt;beanClass&gt;</CODE>, where &lt;name&gt; has its
+ * first letter capitalized by the constructor.<P>
+ *
+ * <B>Implementation note:</B> If there is a get(int) method,
+ * then the return type of that method is used to find the
+ * remaining methods. If there is no get method, then the
+ * set(int) method is searched for exhaustively and that type
+ * is used to find the others.<P>
+ *
+ * <B>Spec note:</B>
+ * If there is no get(int) method and multiple set(int) methods with
+ * the same name and the correct parameters (different type of course),
+ * then an IntrospectionException is thrown. While Sun's spec
+ * does not state this, it can make Bean behavior different on
+ * different systems (since method order is not guaranteed) and as
+ * such, can be treated as a bug in the spec. I am not aware of
+ * whether Sun's implementation catches this.
+ *
+ * @param name the programmatic name of the property, usually
+ * starting with a lowercase letter (e.g. fooManChu
+ * instead of FooManChu).
+ * @param beanClass the class the get and set methods live in.
+ *
+ * @exception IntrospectionException if the methods are not found or
+ * invalid.
+ */
+ public IndexedPropertyDescriptor(String name, Class beanClass)
+ throws IntrospectionException
+ {
+ super(name);
+ String capitalized;
+ try
+ {
+ capitalized = Character.toUpperCase(name.charAt(0))
+ + name.substring(1);
+ }
+ catch(StringIndexOutOfBoundsException e)
+ {
+ capitalized = "";
+ }
+ findMethods(beanClass, "get" + capitalized, "set" + capitalized,
+ "get" + capitalized, "set" + capitalized);
+ }
- /** Create a new IndexedPropertyDescriptor by introspection.
- ** This form of constructor creates the PropertyDescriptor by
- ** looking for getter methods named <CODE>get&lt;name&gt;()</CODE>
- ** and setter methods named
- ** <CODE>set&lt;name&gt;()</CODE> in class
- ** <CODE>&lt;beanClass&gt;</CODE>, where &lt;name&gt; has its
- ** first letter capitalized by the constructor.<P>
- **
- ** <B>Implementation note:</B> If there is a get(int) method,
- ** then the return type of that method is used to find the
- ** remaining methods. If there is no get method, then the
- ** set(int) method is searched for exhaustively and that type
- ** is used to find the others.<P>
- **
- ** <B>Spec note:</B>
- ** If there is no get(int) method and multiple set(int) methods with
- ** the same name and the correct parameters (different type of course),
- ** then an IntrospectionException is thrown. While Sun's spec
- ** does not state this, it can make Bean behavior different on
- ** different systems (since method order is not guaranteed) and as
- ** such, can be treated as a bug in the spec. I am not aware of
- ** whether Sun's implementation catches this.
- **
- ** @param name the programmatic name of the property, usually
- ** starting with a lowercase letter (e.g. fooManChu
- ** instead of FooManChu).
- ** @param beanClass the class the get and set methods live in.
- ** @exception IntrospectionException if the methods are not found or invalid.
- **/
- public IndexedPropertyDescriptor(String name, Class beanClass) throws IntrospectionException {
- super(name);
- String capitalized;
- try {
- capitalized = Character.toUpperCase(name.charAt(0)) + name.substring(1);
- } catch(StringIndexOutOfBoundsException e) {
- capitalized = "";
- }
- findMethods(beanClass, "get" + capitalized, "set" + capitalized, "get" + capitalized, "set" + capitalized);
- }
+ /**
+ * Create a new IndexedPropertyDescriptor by introspection.
+ * This form of constructor allows you to specify the
+ * names of the get and set methods to search for.<P>
+ *
+ * <B>Implementation note:</B> If there is a get(int) method,
+ * then the return type of that method is used to find the
+ * remaining methods. If there is no get method, then the
+ * set(int) method is searched for exhaustively and that type
+ * is used to find the others.<P>
+ *
+ * <B>Spec note:</B>
+ * If there is no get(int) method and multiple set(int) methods with
+ * the same name and the correct parameters (different type of course),
+ * then an IntrospectionException is thrown. While Sun's spec
+ * does not state this, it can make Bean behavior different on
+ * different systems (since method order is not guaranteed) and as
+ * such, can be treated as a bug in the spec. I am not aware of
+ * whether Sun's implementation catches this.
+ *
+ * @param name the programmatic name of the property, usually
+ * starting with a lowercase letter (e.g. fooManChu
+ * instead of FooManChu).
+ * @param beanClass the class the get and set methods live in.
+ * @param getMethodName the name of the get array method.
+ * @param setMethodName the name of the set array method.
+ * @param getIndexName the name of the get index method.
+ * @param setIndexName the name of the set index method.
+ *
+ * @exception IntrospectionException if the methods are not found or invalid.
+ */
+ public IndexedPropertyDescriptor(String name, Class beanClass,
+ String getMethodName, String setMethodName,
+ String getIndexName, String setIndexName)
+ throws IntrospectionException
+ {
+ super(name);
+ findMethods(beanClass, getMethodName, setMethodName, getIndexName,
+ setIndexName);
+ }
- /** Create a new IndexedPropertyDescriptor by introspection.
- ** This form of constructor allows you to specify the
- ** names of the get and set methods to search for.<P>
- **
- ** <B>Implementation note:</B> If there is a get(int) method,
- ** then the return type of that method is used to find the
- ** remaining methods. If there is no get method, then the
- ** set(int) method is searched for exhaustively and that type
- ** is used to find the others.<P>
- **
- ** <B>Spec note:</B>
- ** If there is no get(int) method and multiple set(int) methods with
- ** the same name and the correct parameters (different type of course),
- ** then an IntrospectionException is thrown. While Sun's spec
- ** does not state this, it can make Bean behavior different on
- ** different systems (since method order is not guaranteed) and as
- ** such, can be treated as a bug in the spec. I am not aware of
- ** whether Sun's implementation catches this.
- **
- ** @param name the programmatic name of the property, usually
- ** starting with a lowercase letter (e.g. fooManChu
- ** instead of FooManChu).
- ** @param beanClass the class the get and set methods live in.
- ** @param getMethodName the name of the get array method.
- ** @param setMethodName the name of the set array method.
- ** @param getIndexName the name of the get index method.
- ** @param setIndexName the name of the set index method.
- ** @exception IntrospectionException if the methods are not found or invalid.
- **/
- public IndexedPropertyDescriptor(String name, Class beanClass, String getMethodName, String setMethodName, String getIndexName, String setIndexName) throws IntrospectionException {
- super(name);
- findMethods(beanClass, getMethodName, setMethodName, getIndexName, setIndexName);
- }
+ /**
+ * Create a new PropertyDescriptor using explicit Methods.
+ * Note that the methods will be checked for conformance to standard
+ * Property method rules, as described above at the top of this class.
+ *
+ * @param name the programmatic name of the property, usually
+ * starting with a lowercase letter (e.g. fooManChu
+ * instead of FooManChu).
+ * @param getMethod the get array method.
+ * @param setMethod the set array method.
+ * @param getIndex the get index method.
+ * @param setIndex the set index method.
+ *
+ * @exception IntrospectionException if the methods are not found or invalid.
+ */
+ public IndexedPropertyDescriptor(String name, Method getMethod,
+ Method setMethod, Method getIndex,
+ Method setIndex)
+ throws IntrospectionException
+ {
+ super(name);
+ if(getMethod != null && getMethod.getParameterTypes().length > 0)
+ throw new IntrospectionException("get method has parameters");
+ if(getMethod != null && setMethod.getParameterTypes().length != 1)
+ throw new IntrospectionException("set method does not have exactly one parameter");
+ if(getMethod != null && setMethod != null)
+ {
+ if(!getMethod.getReturnType().equals(setMethod.getParameterTypes()[0]))
+ {
+ throw new IntrospectionException("set and get methods do not "
+ + "share the same type");
+ }
+ if(!getMethod.getDeclaringClass().isAssignableFrom
+ (setMethod.getDeclaringClass())
+ && !setMethod.getDeclaringClass().isAssignableFrom
+ (getMethod.getDeclaringClass()))
+ {
+ throw new IntrospectionException("set and get methods are not in "
+ + "the same class.");
+ }
+ }
- /** Create a new PropertyDescriptor using explicit Methods.
- ** Note that the methods will be checked for conformance to standard
- ** Property method rules, as described above at the top of this class.
- **
- ** @param name the programmatic name of the property, usually
- ** starting with a lowercase letter (e.g. fooManChu
- ** instead of FooManChu).
- ** @param getMethod the get array method.
- ** @param setMethod the set array method.
- ** @param getIndex the get index method.
- ** @param setIndex the set index method.
- ** @exception IntrospectionException if the methods are not found or invalid.
- **/
- public IndexedPropertyDescriptor(String name, Method getMethod, Method setMethod, Method getIndex, Method setIndex) throws IntrospectionException {
- super(name);
- if(getMethod != null && getMethod.getParameterTypes().length > 0) {
- throw new IntrospectionException("get method has parameters");
- }
- if(getMethod != null && setMethod.getParameterTypes().length != 1) {
- throw new IntrospectionException("set method does not have exactly one parameter");
- }
- if(getMethod != null && setMethod != null) {
- if(!getMethod.getReturnType().equals(setMethod.getParameterTypes()[0])) {
- throw new IntrospectionException("set and get methods do not share the same type");
- }
- if(!getMethod.getDeclaringClass().isAssignableFrom(setMethod.getDeclaringClass())
- && !setMethod.getDeclaringClass().isAssignableFrom(getMethod.getDeclaringClass())) {
- throw new IntrospectionException("set and get methods are not in the same class.");
- }
- }
+ if (getIndex != null
+ && (getIndex.getParameterTypes().length != 1
+ || !(getIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)))
+ {
+ throw new IntrospectionException("get index method has wrong "
+ + "parameters");
+ }
+ if (setIndex != null
+ && (setIndex.getParameterTypes().length != 2
+ || !(setIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)))
+ {
+ throw new IntrospectionException("set index method has wrong "
+ + "parameters");
+ }
+ if (getIndex != null && setIndex != null)
+ {
+ if(!getIndex.getReturnType().equals(setIndex.getParameterTypes()[1]))
+ {
+ throw new IntrospectionException("set index methods do not share "
+ + "the same type");
+ }
+ if(!getIndex.getDeclaringClass().isAssignableFrom
+ (setIndex.getDeclaringClass())
+ && !setIndex.getDeclaringClass().isAssignableFrom
+ (getIndex.getDeclaringClass()))
+ {
+ throw new IntrospectionException("get and set index methods are "
+ + "not in the same class.");
+ }
+ }
- if(getIndex != null && (getIndex.getParameterTypes().length != 1
- || !(getIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE))) {
- throw new IntrospectionException("get index method has wrong parameters");
- }
- if(setIndex != null && (setIndex.getParameterTypes().length != 2
- || !(setIndex.getParameterTypes()[0]).equals(java.lang.Integer.TYPE))) {
- throw new IntrospectionException("set index method has wrong parameters");
- }
- if(getIndex != null && setIndex != null) {
- if(!getIndex.getReturnType().equals(setIndex.getParameterTypes()[1])) {
- throw new IntrospectionException("set index methods do not share the same type");
- }
- if(!getIndex.getDeclaringClass().isAssignableFrom(setIndex.getDeclaringClass())
- && !setIndex.getDeclaringClass().isAssignableFrom(getIndex.getDeclaringClass())) {
- throw new IntrospectionException("get and set index methods are not in the same class.");
- }
- }
+ if (getIndex != null && getMethod != null
+ && !getIndex.getDeclaringClass().isAssignableFrom
+ (getMethod.getDeclaringClass())
+ && !getMethod.getDeclaringClass().isAssignableFrom
+ (getIndex.getDeclaringClass()))
+ {
+ throw new IntrospectionException("methods are not in the same class.");
+ }
- if(getIndex != null && getMethod != null && !getIndex.getDeclaringClass().isAssignableFrom(getMethod.getDeclaringClass())
- && !getMethod.getDeclaringClass().isAssignableFrom(getIndex.getDeclaringClass())) {
- throw new IntrospectionException("methods are not in the same class.");
- }
+ if (getIndex != null && getMethod != null
+ && !Array.newInstance(getIndex.getReturnType(),0)
+ .getClass().equals(getMethod.getReturnType()))
+ {
+ throw new IntrospectionException("array methods do not match index "
+ + "methods.");
+ }
- if(getIndex != null && getMethod != null && !Array.newInstance(getIndex.getReturnType(),0).getClass().equals(getMethod.getReturnType())) {
- throw new IntrospectionException("array methods do not match index methods.");
- }
+ this.getMethod = getMethod;
+ this.setMethod = setMethod;
+ this.getIndex = getIndex;
+ this.setIndex = setIndex;
+ this.indexedPropertyType = getIndex != null ? getIndex.getReturnType()
+ : setIndex.getParameterTypes()[1];
+ this.propertyType = getMethod != null ? getMethod.getReturnType()
+ : (setMethod != null ? setMethod.getParameterTypes()[0]
+ : Array.newInstance(this.indexedPropertyType,0).getClass());
+ }
- this.getMethod = getMethod;
- this.setMethod = setMethod;
- this.getIndex = getIndex;
- this.setIndex = setIndex;
- this.indexedPropertyType = getIndex != null ? getIndex.getReturnType() : setIndex.getParameterTypes()[1];
- this.propertyType = getMethod != null ? getMethod.getReturnType() : (setMethod != null ? setMethod.getParameterTypes()[0] : Array.newInstance(this.indexedPropertyType,0).getClass());
- }
+ public Class getIndexedPropertyType()
+ {
+ return indexedPropertyType;
+ }
- public Class getIndexedPropertyType() {
- return indexedPropertyType;
- }
+ public Method getIndexedReadMethod()
+ {
+ return getIndex;
+ }
- public Method getIndexedReadMethod() {
- return getIndex;
- }
+ /**
+ * Sets the method that is used to read an indexed property.
+ *
+ * @param m the method to set
+ */
+ public void setIndexedReadMethod(Method m) throws IntrospectionException
+ {
+ getIndex = m;
+ }
- public Method getIndexedWriteMethod() {
- return setIndex;
- }
+ public Method getIndexedWriteMethod()
+ {
+ return setIndex;
+ }
- private void findMethods(Class beanClass, String getMethodName, String setMethodName, String getIndexName, String setIndexName) throws IntrospectionException {
- try {
- if(getIndexName != null) {
- try {
- Class[] getArgs = new Class[1];
- getArgs[0] = java.lang.Integer.TYPE;
- getIndex = beanClass.getMethod(getIndexName,getArgs);
- indexedPropertyType = getIndex.getReturnType();
- } catch(NoSuchMethodException E) {
- }
- }
- if(getIndex != null) {
- if(setIndexName != null) {
- try {
- Class[] setArgs = new Class[2];
- setArgs[0] = java.lang.Integer.TYPE;
- setArgs[1] = indexedPropertyType;
- setIndex = beanClass.getMethod(setIndexName,setArgs);
- if(!setIndex.getReturnType().equals(java.lang.Void.TYPE)) {
- throw new IntrospectionException(setIndexName + " has non-void return type");
- }
- } catch(NoSuchMethodException E) {
- }
- }
- } else if(setIndexName != null) {
- Method[] m = beanClass.getMethods();
- for(int i=0;i<m.length;i++) {
- Method current = m[i];
- if(current.getName().equals(setIndexName)
- && current.getParameterTypes().length == 2
- && (current.getParameterTypes()[0]).equals(java.lang.Integer.TYPE)
- && current.getReturnType().equals(java.lang.Void.TYPE)) {
- if(setIndex != null) {
- throw new IntrospectionException("Multiple, different set methods found that fit the bill!");
- } else {
- setIndex = current;
- indexedPropertyType = current.getParameterTypes()[1];
- }
- }
- }
- if(setIndex == null) {
- throw new IntrospectionException("Cannot find get or set methods.");
- }
- } else {
- throw new IntrospectionException("Cannot find get or set methods.");
- }
+ /**
+ * Sets the method that is used to write an indexed property.
+ *
+ * @param m the method to set
+ */
+ public void setIndexedWriteMethod(Method m) throws IntrospectionException
+ {
+ setIndex = m;
+ }
- Class arrayType = Array.newInstance(indexedPropertyType,0).getClass();
+ private void findMethods(Class beanClass, String getMethodName,
+ String setMethodName, String getIndexName,
+ String setIndexName)
+ throws IntrospectionException
+ {
+ try
+ {
+ if(getIndexName != null)
+ {
+ try
+ {
+ Class[] getArgs = new Class[1];
+ getArgs[0] = java.lang.Integer.TYPE;
+ getIndex = beanClass.getMethod(getIndexName,getArgs);
+ indexedPropertyType = getIndex.getReturnType();
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+ }
+ if(getIndex != null)
+ {
+ if(setIndexName != null)
+ {
+ try
+ {
+ Class[] setArgs = new Class[2];
+ setArgs[0] = java.lang.Integer.TYPE;
+ setArgs[1] = indexedPropertyType;
+ setIndex = beanClass.getMethod(setIndexName,setArgs);
+ if(!setIndex.getReturnType().equals(java.lang.Void.TYPE))
+ {
+ throw new IntrospectionException(setIndexName
+ + " has non-void return type");
+ }
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+ }
+ }
+ else if(setIndexName != null)
+ {
+ Method[] m = beanClass.getMethods();
+ for(int i=0;i<m.length;i++)
+ {
+ Method current = m[i];
+ if(current.getName().equals(setIndexName)
+ && current.getParameterTypes().length == 2
+ && (current.getParameterTypes()[0])
+ .equals(java.lang.Integer.TYPE)
+ && current.getReturnType().equals(java.lang.Void.TYPE))
+ {
+ if(setIndex != null)
+ {
+ throw new IntrospectionException("Multiple, different "
+ + "set methods found that fit the bill!");
+ }
+ else
+ {
+ setIndex = current;
+ indexedPropertyType = current.getParameterTypes()[1];
+ }
+ }
+ }
+ if(setIndex == null)
+ {
+ throw new IntrospectionException("Cannot find get or set "
+ + "methods.");
+ }
+ }
+ else
+ {
+ throw new IntrospectionException("Cannot find get or set methods.");
+ }
- Class[] setArgs = new Class[1];
- setArgs[0] = arrayType;
- try {
- setMethod = beanClass.getMethod(setMethodName,setArgs);
- if(!setMethod.getReturnType().equals(java.lang.Void.TYPE)) {
- setMethod = null;
- }
- } catch(NoSuchMethodException E) {
- }
+ Class arrayType = Array.newInstance(indexedPropertyType,0).getClass();
- Class[] getArgs = new Class[0];
- try {
- getMethod = beanClass.getMethod(getMethodName,getArgs);
- if(!getMethod.getReturnType().equals(arrayType)) {
- getMethod = null;
- }
- } catch(NoSuchMethodException E) {
- }
- } catch(SecurityException E) {
- throw new IntrospectionException("SecurityException while trying to find methods.");
- }
- }
+ Class[] setArgs = new Class[1];
+ setArgs[0] = arrayType;
+ try
+ {
+ setMethod = beanClass.getMethod(setMethodName,setArgs);
+ if (!setMethod.getReturnType().equals(java.lang.Void.TYPE))
+ {
+ setMethod = null;
+ }
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+
+ Class[] getArgs = new Class[0];
+ try
+ {
+ getMethod = beanClass.getMethod(getMethodName,getArgs);
+ if (!getMethod.getReturnType().equals(arrayType))
+ {
+ getMethod = null;
+ }
+ }
+ catch(NoSuchMethodException E)
+ {
+ }
+ }
+ catch(SecurityException E)
+ {
+ throw new IntrospectionException("SecurityException while trying to "
+ + "find methods.");
+ }
+ }
}
diff --git a/libjava/classpath/java/beans/PropertyDescriptor.java b/libjava/classpath/java/beans/PropertyDescriptor.java
index 416d468576f..a22d6252e28 100644
--- a/libjava/classpath/java/beans/PropertyDescriptor.java
+++ b/libjava/classpath/java/beans/PropertyDescriptor.java
@@ -61,7 +61,6 @@ import java.lang.reflect.Method;
** @since 1.1
** @status updated to 1.4
**/
-
public class PropertyDescriptor extends FeatureDescriptor
{
Class propertyType;
@@ -521,6 +520,22 @@ public class PropertyDescriptor extends FeatureDescriptor
return newPropertyType;
}
+ /**
+ * Return a hash code for this object, conforming to the contract described
+ * in {@link Object#hashCode()}.
+ * @return the hash code
+ * @since 1.5
+ */
+ public int hashCode()
+ {
+ return ((propertyType == null ? 0 : propertyType.hashCode())
+ | (propertyEditorClass == null ? 0 : propertyEditorClass.hashCode())
+ | (bound ? Boolean.TRUE : Boolean.FALSE).hashCode()
+ | (constrained ? Boolean.TRUE : Boolean.FALSE).hashCode()
+ | (getMethod == null ? 0 : getMethod.hashCode())
+ | (setMethod == null ? 0 : setMethod.hashCode()));
+ }
+
/** Compares this <code>PropertyDescriptor</code> against the
* given object.
* Two PropertyDescriptors are equals if
diff --git a/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java
index b7c4a49d8a9..5455adbaec3 100644
--- a/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java
+++ b/libjava/classpath/java/beans/beancontext/BeanContextServicesSupport.java
@@ -61,7 +61,7 @@ public class BeanContextServicesSupport
protected class BCSSChild
extends BeanContextSupport.BCSChild
{
- private static final long serialVersionUID = -6848044915271367103L;
+ private static final long serialVersionUID = -3263851306889194873L;
}
protected class BCSSProxyServiceProvider
diff --git a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
index 7e024e23a13..60ccc3af3e4 100644
--- a/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
+++ b/libjava/classpath/java/beans/beancontext/BeanContextSupport.java
@@ -79,7 +79,7 @@ public class BeanContextSupport extends BeanContextChildSupport
protected class BCSChild implements Serializable
{
- private static final long serialVersionUID = 3289144128843950629L;
+ private static final long serialVersionUID = -5815286101609939109L;
}
protected static final class BCSIterator implements Iterator
diff --git a/libjava/classpath/java/io/ByteArrayOutputStream.java b/libjava/classpath/java/io/ByteArrayOutputStream.java
index e996ebbc70f..4196523d28e 100644
--- a/libjava/classpath/java/io/ByteArrayOutputStream.java
+++ b/libjava/classpath/java/io/ByteArrayOutputStream.java
@@ -1,5 +1,6 @@
/* BufferedReader.java
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -192,7 +193,7 @@ public class ByteArrayOutputStream extends OutputStream
*/
public String toString (int hibyte)
{
- return new String (buf, 0, count, hibyte);
+ return new String (buf, hibyte, 0, count);
}
// Resize buffer to accommodate new bytes.
diff --git a/libjava/classpath/java/io/DataOutputStream.java b/libjava/classpath/java/io/DataOutputStream.java
index 39f7ed1ff24..25178160dc8 100644
--- a/libjava/classpath/java/io/DataOutputStream.java
+++ b/libjava/classpath/java/io/DataOutputStream.java
@@ -302,7 +302,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
*
* @exception IOException If an error occurs
*
- * @see writeInt
+ * @see #writeInt(int)
* @see DataInput#readFloat
* @see Float#floatToIntBits
*/
@@ -326,7 +326,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
*
* @exception IOException If an error occurs
*
- * @see writeLong
+ * @see #writeLong(long)
* @see DataInput#readDouble
* @see Double#doubleToLongBits
*/
@@ -363,7 +363,7 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
*
* @exception IOException If an error occurs
*
- * @see writeChar
+ * @see #writeChar(char)
*/
public final void writeChars (String value) throws IOException
{
diff --git a/libjava/classpath/java/io/File.java b/libjava/classpath/java/io/File.java
index 3b747e6bd03..3c7ac21301c 100644
--- a/libjava/classpath/java/io/File.java
+++ b/libjava/classpath/java/io/File.java
@@ -100,6 +100,17 @@ public class File implements Serializable, Comparable
* may be an absolute or relative path name.
*/
private String path;
+
+
+ /**
+ * The time (millisecond), when the last temporary file was created.
+ */
+ private static long last_tmp;
+
+ /**
+ * The number of files, created during the current millisecond.
+ */
+ private static int n_created;
/**
* This method tests whether or not the current thread is allowed to
@@ -446,6 +457,8 @@ public class File implements Serializable, Comparable
else
return drvDir;
}
+ else if (path.equals(""))
+ return System.getProperty ("user.dir");
else
return System.getProperty ("user.dir") + separatorChar + path;
}
@@ -532,6 +545,9 @@ public class File implements Serializable, Comparable
{
String prefix = null;
int nameSeqIndex = 0;
+
+ if (path.equals(""))
+ return null;
// The "prefix", if present, is the leading "/" on UNIX and
// either the drive specifier (e.g. "C:") or the leading "\\"
@@ -943,8 +959,8 @@ public class File implements Serializable, Comparable
public URI toURI()
{
String abspath = getAbsolutePath();
-
- if (isDirectory())
+
+ if (isDirectory() || path.equals(""))
abspath = abspath + separatorChar;
if (separatorChar == '\\')
@@ -1059,7 +1075,7 @@ public class File implements Serializable, Comparable
*
* @since 1.2
*/
- public static File createTempFile(String prefix, String suffix,
+ public static synchronized File createTempFile(String prefix, String suffix,
File directory)
throws IOException
{
@@ -1091,10 +1107,23 @@ public class File implements Serializable, Comparable
// Now identify a file name and make sure it doesn't exist.
File file;
if (!VMFile.IS_DOS_8_3)
- {
+ {
do
{
- String filename = prefix + System.currentTimeMillis() + suffix;
+ long now = System.currentTimeMillis();
+ if (now > last_tmp)
+ {
+ // The last temporary file was created more than 1 ms ago.
+ last_tmp = now;
+ n_created = 0;
+ }
+ else
+ n_created++;
+
+ String name = Long.toHexString(now);
+ if (n_created > 0)
+ name += '_'+Integer.toHexString(n_created);
+ String filename = prefix + name + suffix;
file = new File(directory, filename);
}
while (VMFile.exists(file.path));
diff --git a/libjava/classpath/java/io/FileWriter.java b/libjava/classpath/java/io/FileWriter.java
index b34db83231e..ce18efe5e39 100644
--- a/libjava/classpath/java/io/FileWriter.java
+++ b/libjava/classpath/java/io/FileWriter.java
@@ -119,7 +119,7 @@ public class FileWriter extends OutputStreamWriter
* This method intializes a new <code>FileWriter</code> object to
* write to the
* specified named file. This form of the constructor allows the caller
- * to determin whether data should be written starting at the beginning or
+ * to determine whether data should be written starting at the beginning or
* the end of the file.
*
* @param name The name of the file to write to
diff --git a/libjava/classpath/java/io/FilterReader.java b/libjava/classpath/java/io/FilterReader.java
index 2bd040a7f72..1abaa8a4b68 100644
--- a/libjava/classpath/java/io/FilterReader.java
+++ b/libjava/classpath/java/io/FilterReader.java
@@ -131,7 +131,7 @@ public abstract class FilterReader extends Reader
/**
* Calls the <code>in.skip(long)</code> method
*
- * @param numBytes The requested number of chars to skip.
+ * @param num_chars The requested number of chars to skip.
*
* @return The value returned from <code>in.skip(long)</code>
*
diff --git a/libjava/classpath/java/io/InputStreamReader.java b/libjava/classpath/java/io/InputStreamReader.java
index 315af83e1a4..57cdc53ed22 100644
--- a/libjava/classpath/java/io/InputStreamReader.java
+++ b/libjava/classpath/java/io/InputStreamReader.java
@@ -38,16 +38,14 @@ exception statement from your version. */
package java.io;
-import java.nio.charset.UnsupportedCharsetException;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
+import gnu.java.nio.charset.EncodingHelper;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
-import java.nio.CharBuffer;
-import java.nio.ByteBuffer;
-import gnu.java.nio.charset.EncodingHelper;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
/**
* This class reads characters from a byte input stream. The characters
@@ -251,8 +249,12 @@ public class InputStreamReader extends Reader
this.in = in;
this.decoder = decoder;
+ Charset charset = decoder.charset();
try {
- maxBytesPerChar = decoder.charset().newEncoder().maxBytesPerChar();
+ if (charset == null)
+ maxBytesPerChar = 1f;
+ else
+ maxBytesPerChar = charset.newEncoder().maxBytesPerChar();
} catch(UnsupportedOperationException _){
maxBytesPerChar = 1f;
}
@@ -260,7 +262,10 @@ public class InputStreamReader extends Reader
decoder.onMalformedInput(CodingErrorAction.REPLACE);
decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
decoder.reset();
- encoding = EncodingHelper.getOldCanonical(decoder.charset().name());
+ if (charset == null)
+ encoding = "US-ASCII";
+ else
+ encoding = EncodingHelper.getOldCanonical(decoder.charset().name());
}
/**
diff --git a/libjava/classpath/java/io/LineNumberReader.java b/libjava/classpath/java/io/LineNumberReader.java
index ea418a5e4d6..5e263f76111 100644
--- a/libjava/classpath/java/io/LineNumberReader.java
+++ b/libjava/classpath/java/io/LineNumberReader.java
@@ -115,7 +115,7 @@ public class LineNumberReader extends BufferedReader
/**
* This method sets the current line number to the specified value.
*
- * @param line_number The new line number
+ * @param lineNumber The new line number
*/
public void setLineNumber(int lineNumber)
{
@@ -139,7 +139,7 @@ public class LineNumberReader extends BufferedReader
* is called, the line number will be restored to the saved line number in
* addition to the stream position.
*
- * @param readlimit The number of chars that can be read before the
+ * @param readLimit The number of chars that can be read before the
* mark becomes invalid
*
* @exception IOException If an error occurs
@@ -269,7 +269,7 @@ public class LineNumberReader extends BufferedReader
*
* @param buf The array into which the chars read should be stored
* @param offset The offset into the array to start storing chars
- * @param len The requested number of chars to read
+ * @param count The requested number of chars to read
*
* @return The actual number of chars read, or -1 if end of stream
*
diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java
index 54d5eeafadd..98a11dae3e1 100644
--- a/libjava/classpath/java/io/ObjectInputStream.java
+++ b/libjava/classpath/java/io/ObjectInputStream.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package java.io;
-import gnu.classpath.Configuration;
import gnu.java.io.ObjectIdentityWrapper;
import java.lang.reflect.Array;
@@ -53,6 +52,8 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.TreeSet;
import java.util.Vector;
public class ObjectInputStream extends InputStream
@@ -91,7 +92,6 @@ public class ObjectInputStream extends InputStream
}
this.resolveEnabled = false;
- this.isDeserializing = false;
this.blockDataPosition = 0;
this.blockDataBytes = 0;
this.blockData = new byte[BUFFER_SIZE];
@@ -99,7 +99,6 @@ public class ObjectInputStream extends InputStream
this.realInputStream = new DataInputStream(in);
this.nextOID = baseWireHandle;
this.objectLookupTable = new Hashtable();
- this.validators = new Vector();
this.classLookupTable = new Hashtable();
setBlockDataMode(true);
readStreamHeader();
@@ -113,7 +112,10 @@ public class ObjectInputStream extends InputStream
* <code>private void readObject (ObjectInputStream)</code>.
*
* If an exception is thrown from this method, the stream is left in
- * an undefined state.
+ * an undefined state. This method can also throw Errors and
+ * RuntimeExceptions if caused by existing readResolve() user code.
+ *
+ * @return The object read from the underlying stream.
*
* @exception ClassNotFoundException The class that an object being
* read in belongs to cannot be found.
@@ -121,291 +123,312 @@ public class ObjectInputStream extends InputStream
* @exception IOException Exception from underlying
* <code>InputStream</code>.
*/
- public final Object readObject() throws ClassNotFoundException, IOException
+ public final Object readObject()
+ throws ClassNotFoundException, IOException
{
if (this.useSubclassMethod)
return readObjectOverride();
- boolean was_deserializing;
-
Object ret_val;
- was_deserializing = this.isDeserializing;
-
- boolean is_consumed = false;
boolean old_mode = setBlockDataMode(false);
-
- this.isDeserializing = true;
-
byte marker = this.realInputStream.readByte();
- depth += 2;
+ if (DEBUG)
+ depth += 2;
if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " ");
try
{
- switch (marker)
- {
- case TC_ENDBLOCKDATA:
- {
- ret_val = null;
- is_consumed = true;
- break;
- }
-
- case TC_BLOCKDATA:
- case TC_BLOCKDATALONG:
- {
- if (marker == TC_BLOCKDATALONG)
- { if(dump) dumpElementln("BLOCKDATALONG"); }
- else
- { if(dump) dumpElementln("BLOCKDATA"); }
- readNextBlock(marker);
- throw new StreamCorruptedException("Unexpected blockData");
- }
-
- case TC_NULL:
- {
- if(dump) dumpElementln("NULL");
- ret_val = null;
- break;
- }
-
- case TC_REFERENCE:
- {
- if(dump) dumpElement("REFERENCE ");
- Integer oid = new Integer(this.realInputStream.readInt());
- if(dump) dumpElementln(Integer.toHexString(oid.intValue()));
- ret_val = ((ObjectIdentityWrapper)
- this.objectLookupTable.get(oid)).object;
- break;
- }
-
- case TC_CLASS:
- {
- if(dump) dumpElementln("CLASS");
- ObjectStreamClass osc = (ObjectStreamClass)readObject();
- Class clazz = osc.forClass();
- assignNewHandle(clazz);
- ret_val = clazz;
- break;
- }
+ ret_val = parseContent(marker);
+ }
+ finally
+ {
+ setBlockDataMode(old_mode);
+ if (DEBUG)
+ depth -= 2;
+ }
+
+ return ret_val;
+ }
- case TC_PROXYCLASSDESC:
+ /**
+ * Handles a content block within the stream, which begins with a marker
+ * byte indicating its type.
+ *
+ * @param marker the byte marker.
+ * @return an object which represents the parsed content.
+ * @throws ClassNotFoundException if the class of an object being
+ * read in cannot be found.
+ * @throws IOException if invalid data occurs or one is thrown by the
+ * underlying <code>InputStream</code>.
+ */
+ private Object parseContent(byte marker)
+ throws ClassNotFoundException, IOException
+ {
+ Object ret_val;
+ boolean is_consumed = false;
+
+ switch (marker)
+ {
+ case TC_ENDBLOCKDATA:
+ {
+ ret_val = null;
+ is_consumed = true;
+ break;
+ }
+
+ case TC_BLOCKDATA:
+ case TC_BLOCKDATALONG:
+ {
+ if (marker == TC_BLOCKDATALONG)
+ { if(dump) dumpElementln("BLOCKDATALONG"); }
+ else
+ { if(dump) dumpElementln("BLOCKDATA"); }
+ readNextBlock(marker);
+ }
+
+ case TC_NULL:
+ {
+ if(dump) dumpElementln("NULL");
+ ret_val = null;
+ break;
+ }
+
+ case TC_REFERENCE:
+ {
+ if(dump) dumpElement("REFERENCE ");
+ Integer oid = new Integer(this.realInputStream.readInt());
+ if(dump) dumpElementln(Integer.toHexString(oid.intValue()));
+ ret_val = ((ObjectIdentityWrapper)
+ this.objectLookupTable.get(oid)).object;
+ break;
+ }
+
+ case TC_CLASS:
+ {
+ if(dump) dumpElementln("CLASS");
+ ObjectStreamClass osc = (ObjectStreamClass)readObject();
+ Class clazz = osc.forClass();
+ assignNewHandle(clazz);
+ ret_val = clazz;
+ break;
+ }
+
+ case TC_PROXYCLASSDESC:
+ {
+ if(dump) dumpElementln("PROXYCLASS");
+ int n_intf = this.realInputStream.readInt();
+ String[] intfs = new String[n_intf];
+ for (int i = 0; i < n_intf; i++)
+ {
+ intfs[i] = this.realInputStream.readUTF();
+ }
+
+ boolean oldmode = setBlockDataMode(true);
+ Class cl = resolveProxyClass(intfs);
+ setBlockDataMode(oldmode);
+
+ ObjectStreamClass osc = lookupClass(cl);
+ if (osc.firstNonSerializableParentConstructor == null)
+ {
+ osc.realClassIsSerializable = true;
+ osc.fields = osc.fieldMapping = new ObjectStreamField[0];
+ try
+ {
+ osc.firstNonSerializableParentConstructor =
+ Object.class.getConstructor(new Class[0]);
+ }
+ catch (NoSuchMethodException x)
+ {
+ throw (InternalError)
+ new InternalError("Object ctor missing").initCause(x);
+ }
+ }
+ assignNewHandle(osc);
+
+ if (!is_consumed)
+ {
+ byte b = this.realInputStream.readByte();
+ if (b != TC_ENDBLOCKDATA)
+ throw new IOException("Data annotated to class was not consumed." + b);
+ }
+ else
+ is_consumed = false;
+ ObjectStreamClass superosc = (ObjectStreamClass)readObject();
+ osc.setSuperclass(superosc);
+ ret_val = osc;
+ break;
+ }
+
+ case TC_CLASSDESC:
+ {
+ ObjectStreamClass osc = readClassDescriptor();
+
+ if (!is_consumed)
+ {
+ byte b = this.realInputStream.readByte();
+ if (b != TC_ENDBLOCKDATA)
+ throw new IOException("Data annotated to class was not consumed." + b);
+ }
+ else
+ is_consumed = false;
+
+ osc.setSuperclass ((ObjectStreamClass)readObject());
+ ret_val = osc;
+ break;
+ }
+
+ case TC_STRING:
+ case TC_LONGSTRING:
+ {
+ if(dump) dumpElement("STRING=");
+ String s = this.realInputStream.readUTF();
+ if(dump) dumpElementln(s);
+ ret_val = processResolution(null, s, assignNewHandle(s));
+ break;
+ }
+
+ case TC_ARRAY:
+ {
+ if(dump) dumpElementln("ARRAY");
+ ObjectStreamClass osc = (ObjectStreamClass)readObject();
+ Class componentType = osc.forClass().getComponentType();
+ if(dump) dumpElement("ARRAY LENGTH=");
+ int length = this.realInputStream.readInt();
+ if(dump) dumpElementln (length + "; COMPONENT TYPE=" + componentType);
+ Object array = Array.newInstance(componentType, length);
+ int handle = assignNewHandle(array);
+ readArrayElements(array, componentType);
+ if(dump)
+ for (int i = 0, len = Array.getLength(array); i < len; i++)
+ dumpElementln(" ELEMENT[" + i + "]=" + Array.get(array, i));
+ ret_val = processResolution(null, array, handle);
+ break;
+ }
+
+ case TC_OBJECT:
+ {
+ if(dump) dumpElementln("OBJECT");
+ ObjectStreamClass osc = (ObjectStreamClass)readObject();
+ Class clazz = osc.forClass();
+
+ if (!osc.realClassIsSerializable)
+ throw new NotSerializableException
+ (clazz + " is not Serializable, and thus cannot be deserialized.");
+
+ if (osc.realClassIsExternalizable)
{
- if(dump) dumpElementln("PROXYCLASS");
- int n_intf = this.realInputStream.readInt();
- String[] intfs = new String[n_intf];
- for (int i = 0; i < n_intf; i++)
- {
- intfs[i] = this.realInputStream.readUTF();
- System.out.println(intfs[i]);
- }
+ Externalizable obj = osc.newInstance();
- boolean oldmode = setBlockDataMode(true);
- Class cl = resolveProxyClass(intfs);
- setBlockDataMode(oldmode);
+ int handle = assignNewHandle(obj);
- ObjectStreamClass osc = lookupClass(cl);
- assignNewHandle(osc);
+ boolean read_from_blocks = ((osc.getFlags() & SC_BLOCK_DATA) != 0);
- if (!is_consumed)
- {
- byte b = this.realInputStream.readByte();
- if (b != TC_ENDBLOCKDATA)
- throw new IOException("Data annotated to class was not consumed." + b);
- }
- else
- is_consumed = false;
- ObjectStreamClass superosc = (ObjectStreamClass)readObject();
- osc.setSuperclass(superosc);
- ret_val = osc;
- break;
- }
-
- case TC_CLASSDESC:
- {
- ObjectStreamClass osc = readClassDescriptor();
+ boolean oldmode = this.readDataFromBlock;
+ if (read_from_blocks)
+ setBlockDataMode(true);
- if (!is_consumed)
- {
- byte b = this.realInputStream.readByte();
- if (b != TC_ENDBLOCKDATA)
- throw new IOException("Data annotated to class was not consumed." + b);
+ obj.readExternal(this);
+
+ if (read_from_blocks)
+ {
+ setBlockDataMode(oldmode);
+ if (!oldmode)
+ if (this.realInputStream.readByte() != TC_ENDBLOCKDATA)
+ throw new IOException("No end of block data seen for class with readExternal (ObjectInputStream) method.");
}
- else
- is_consumed = false;
-
- osc.setSuperclass ((ObjectStreamClass)readObject());
- ret_val = osc;
- break;
- }
-
- case TC_STRING:
- case TC_LONGSTRING:
- {
- if(dump) dumpElement("STRING=");
- String s = this.realInputStream.readUTF();
- if(dump) dumpElementln(s);
- ret_val = processResolution(null, s, assignNewHandle(s));
- break;
- }
-
- case TC_ARRAY:
- {
- if(dump) dumpElementln("ARRAY");
- ObjectStreamClass osc = (ObjectStreamClass)readObject();
- Class componentType = osc.forClass().getComponentType();
- if(dump) dumpElement("ARRAY LENGTH=");
- int length = this.realInputStream.readInt();
- if(dump) dumpElementln (length + "; COMPONENT TYPE=" + componentType);
- Object array = Array.newInstance(componentType, length);
- int handle = assignNewHandle(array);
- readArrayElements(array, componentType);
- if(dump)
- for (int i = 0, len = Array.getLength(array); i < len; i++)
- dumpElementln(" ELEMENT[" + i + "]=" + Array.get(array, i));
- ret_val = processResolution(null, array, handle);
- break;
- }
-
- case TC_OBJECT:
- {
- if(dump) dumpElementln("OBJECT");
- ObjectStreamClass osc = (ObjectStreamClass)readObject();
- Class clazz = osc.forClass();
-
- if (!osc.realClassIsSerializable)
- throw new NotSerializableException
- (clazz + " is not Serializable, and thus cannot be deserialized.");
-
- if (osc.realClassIsExternalizable)
- {
- Externalizable obj = osc.newInstance();
-
- int handle = assignNewHandle(obj);
-
- boolean read_from_blocks = ((osc.getFlags() & SC_BLOCK_DATA) != 0);
-
- boolean oldmode = this.readDataFromBlock;
- if (read_from_blocks)
- setBlockDataMode(true);
-
- obj.readExternal(this);
-
- if (read_from_blocks)
- {
- setBlockDataMode(oldmode);
- if (!oldmode)
- if (this.realInputStream.readByte() != TC_ENDBLOCKDATA)
- throw new IOException("No end of block data seen for class with readExternal (ObjectInputStream) method.");
- }
-
- ret_val = processResolution(osc, obj, handle);
- break;
- } // end if (osc.realClassIsExternalizable)
- Object obj = newObject(clazz, osc.firstNonSerializableParentConstructor);
-
- int handle = assignNewHandle(obj);
- Object prevObject = this.currentObject;
- ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass;
-
- this.currentObject = obj;
- ObjectStreamClass[] hierarchy =
- inputGetObjectStreamClasses(clazz);
+ ret_val = processResolution(osc, obj, handle);
+ break;
- for (int i = 0; i < hierarchy.length; i++)
- {
- this.currentObjectStreamClass = hierarchy[i];
-
- if(dump) dumpElementln("Reading fields of " + this.currentObjectStreamClass.getName ());
-
- // XXX: should initialize fields in classes in the hierarchy
- // that aren't in the stream
- // should skip over classes in the stream that aren't in the
- // real classes hierarchy
-
- Method readObjectMethod = this.currentObjectStreamClass.readObjectMethod;
- if (readObjectMethod != null)
- {
- fieldsAlreadyRead = false;
- boolean oldmode = setBlockDataMode(true);
- callReadMethod(readObjectMethod, this.currentObjectStreamClass.forClass(), obj);
- setBlockDataMode(oldmode);
- }
- else
- {
- readFields(obj, currentObjectStreamClass);
- }
-
- if (this.currentObjectStreamClass.hasWriteMethod())
- {
- if(dump) dumpElement("ENDBLOCKDATA? ");
- try
- {
- // FIXME: XXX: This try block is to
- // catch EOF which is thrown for some
- // objects. That indicates a bug in
- // the logic.
-
- if (this.realInputStream.readByte() != TC_ENDBLOCKDATA)
- throw new IOException
- ("No end of block data seen for class with readObject (ObjectInputStream) method.");
- if(dump) dumpElementln("yes");
- }
-// catch (EOFException e)
-// {
-// if(dump) dumpElementln("no, got EOFException");
-// }
- catch (IOException e)
- {
- if(dump) dumpElementln("no, got IOException");
+ } // end if (osc.realClassIsExternalizable)
+
+ Object obj = newObject(clazz, osc.firstNonSerializableParentConstructor);
+
+ int handle = assignNewHandle(obj);
+ Object prevObject = this.currentObject;
+ ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass;
+ TreeSet prevObjectValidators = this.currentObjectValidators;
+
+ this.currentObject = obj;
+ this.currentObjectValidators = null;
+ ObjectStreamClass[] hierarchy =
+ inputGetObjectStreamClasses(clazz);
+
+ for (int i = 0; i < hierarchy.length; i++)
+ {
+ this.currentObjectStreamClass = hierarchy[i];
+ if(dump) dumpElementln("Reading fields of " + this.currentObjectStreamClass.getName ());
+
+ // XXX: should initialize fields in classes in the hierarchy
+ // that aren't in the stream
+ // should skip over classes in the stream that aren't in the
+ // real classes hierarchy
+
+ Method readObjectMethod = this.currentObjectStreamClass.readObjectMethod;
+ if (readObjectMethod != null)
+ {
+ fieldsAlreadyRead = false;
+ boolean oldmode = setBlockDataMode(true);
+ callReadMethod(readObjectMethod, this.currentObjectStreamClass.forClass(), obj);
+ setBlockDataMode(oldmode);
+ }
+ else
+ {
+ readFields(obj, currentObjectStreamClass);
+ }
+
+ if (this.currentObjectStreamClass.hasWriteMethod())
+ {
+ if(dump) dumpElement("ENDBLOCKDATA? ");
+ try
+ {
+ /* Read blocks until an end marker */
+ byte writeMarker = this.realInputStream.readByte();
+ while (writeMarker != TC_ENDBLOCKDATA)
+ {
+ parseContent(writeMarker);
+ writeMarker = this.realInputStream.readByte();
}
+ if(dump) dumpElementln("yes");
+ }
+ catch (EOFException e)
+ {
+ throw (IOException) new IOException
+ ("No end of block data seen for class with readObject (ObjectInputStream) method.").initCause(e);
}
}
-
- this.currentObject = prevObject;
- this.currentObjectStreamClass = prevObjectStreamClass;
- ret_val = processResolution(osc, obj, handle);
-
- break;
- }
-
- case TC_RESET:
- if(dump) dumpElementln("RESET");
- clearHandles();
- ret_val = readObject();
- break;
-
- case TC_EXCEPTION:
- {
- if(dump) dumpElement("EXCEPTION=");
- Exception e = (Exception)readObject();
- if(dump) dumpElementln(e.toString());
- clearHandles();
- throw new WriteAbortedException("Exception thrown during writing of stream", e);
}
-
- default:
- throw new IOException("Unknown marker on stream: " + marker);
- }
- }
- finally
- {
- setBlockDataMode(old_mode);
+
+ this.currentObject = prevObject;
+ this.currentObjectStreamClass = prevObjectStreamClass;
+ ret_val = processResolution(osc, obj, handle);
+ if (currentObjectValidators != null)
+ invokeValidators();
+ this.currentObjectValidators = prevObjectValidators;
+
+ break;
+ }
- this.isDeserializing = was_deserializing;
+ case TC_RESET:
+ if(dump) dumpElementln("RESET");
+ clearHandles();
+ ret_val = readObject();
+ break;
- depth -= 2;
+ case TC_EXCEPTION:
+ {
+ if(dump) dumpElement("EXCEPTION=");
+ Exception e = (Exception)readObject();
+ if(dump) dumpElementln(e.toString());
+ clearHandles();
+ throw new WriteAbortedException("Exception thrown during writing of stream", e);
+ }
- if (! was_deserializing)
- {
- if (validators.size() > 0)
- invokeValidators();
- }
+ default:
+ throw new IOException("Unknown marker on stream: " + marker);
}
-
return ret_val;
}
@@ -716,8 +739,10 @@ public class ObjectInputStream extends InputStream
throw new InvalidObjectException("attempt to add a null "
+ "ObjectInputValidation object");
- this.validators.addElement(new ValidatorAndPriority (validator,
- priority));
+ if (currentObjectValidators == null)
+ currentObjectValidators = new TreeSet();
+
+ currentObjectValidators.add(new ValidatorAndPriority(validator, priority));
}
@@ -805,7 +830,7 @@ public class ObjectInputStream extends InputStream
/**
* Reconstruct class hierarchy the same way
- * {@link java.io.ObjectStreamClass.getObjectStreamClasses(java.lang.Class)} does
+ * {@link java.io.ObjectStreamClass#getObjectStreamClasses(Class)} does
* but using lookupClass instead of ObjectStreamClass.lookup. This
* dup is necessary localize the lookup table. Hopefully some future
* rewritings will be able to prevent this.
@@ -874,7 +899,7 @@ public class ObjectInputStream extends InputStream
}
else
for (int i = 0; i < intfs.length; i++)
- clss[i] = cl.loadClass(intfs[i]);
+ clss[i] = Class.forName(intfs[i], false, cl);
try
{
return Proxy.getProxyClass(cl, clss);
@@ -1195,7 +1220,7 @@ public class ObjectInputStream extends InputStream
* This method should be called by a method called 'readObject' in the
* deserializing class (if present). It cannot (and should not)be called
* outside of it. Its goal is to read all fields in the real input stream
- * and keep them accessible through the {@link #GetField} class. Calling
+ * and keep them accessible through the {@link GetField} class. Calling
* this method will not alter the deserializing object.
*
* @return A valid freshly created 'GetField' instance to get access to
@@ -1543,8 +1568,15 @@ public class ObjectInputStream extends InputStream
catch (IllegalAccessException ignore)
{
}
- catch (InvocationTargetException ignore)
+ catch (InvocationTargetException exception)
{
+ Throwable cause = exception.getCause();
+ if (cause instanceof ObjectStreamException)
+ throw (ObjectStreamException) cause;
+ else if (cause instanceof RuntimeException)
+ throw (RuntimeException) cause;
+ else if (cause instanceof Error)
+ throw (Error) cause;
}
}
@@ -1821,18 +1853,19 @@ public class ObjectInputStream extends InputStream
// on OBJ
private void invokeValidators() throws InvalidObjectException
{
- Object[] validators = new Object[this.validators.size()];
- this.validators.copyInto (validators);
- Arrays.sort (validators);
-
try
{
- for (int i=0; i < validators.length; i++)
- ((ObjectInputValidation)validators[i]).validateObject();
+ Iterator it = currentObjectValidators.iterator();
+ while(it.hasNext())
+ {
+ ValidatorAndPriority vap = (ValidatorAndPriority) it.next();
+ ObjectInputValidation validator = vap.validator;
+ validator.validateObject();
+ }
}
finally
{
- this.validators.removeAllElements();
+ currentObjectValidators = null;
}
}
@@ -1881,10 +1914,9 @@ public class ObjectInputStream extends InputStream
private Hashtable objectLookupTable;
private Object currentObject;
private ObjectStreamClass currentObjectStreamClass;
+ private TreeSet currentObjectValidators;
private boolean readDataFromBlock;
- private boolean isDeserializing;
private boolean fieldsAlreadyRead;
- private Vector validators;
private Hashtable classLookupTable;
private GetField prereadFields;
@@ -1908,14 +1940,6 @@ public class ObjectInputStream extends InputStream
System.out.print (Thread.currentThread() + ": ");
}
- static
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- {
- System.loadLibrary ("javaio");
- }
- }
-
// used to keep a prioritized list of object validators
private static final class ValidatorAndPriority implements Comparable
{
diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java
index 5e754c5ec7a..573b9cfa1de 100644
--- a/libjava/classpath/java/io/ObjectOutputStream.java
+++ b/libjava/classpath/java/io/ObjectOutputStream.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package java.io;
-import gnu.classpath.Configuration;
import gnu.java.io.ObjectIdentityWrapper;
import gnu.java.lang.reflect.TypeSignature;
import gnu.java.security.action.SetAccessibleAction;
@@ -362,7 +361,9 @@ public class ObjectOutputStream extends OutputStream
break;
}
- throw new NotSerializableException(clazz.getName ());
+ throw new NotSerializableException(clazz.getName()
+ + " in "
+ + obj.getClass());
} // end pseudo-loop
}
catch (ObjectStreamException ose)
@@ -412,37 +413,53 @@ public class ObjectOutputStream extends OutputStream
protected void writeClassDescriptor(ObjectStreamClass osc) throws IOException
{
- realOutput.writeByte(TC_CLASSDESC);
- realOutput.writeUTF(osc.getName());
- realOutput.writeLong(osc.getSerialVersionUID());
- assignNewHandle(osc);
+ if (osc.isProxyClass)
+ {
+ realOutput.writeByte(TC_PROXYCLASSDESC);
+ Class[] intfs = osc.forClass().getInterfaces();
+ realOutput.writeInt(intfs.length);
+ for (int i = 0; i < intfs.length; i++)
+ realOutput.writeUTF(intfs[i].getName());
+
+ boolean oldmode = setBlockDataMode(true);
+ annotateProxyClass(osc.forClass());
+ setBlockDataMode(oldmode);
+ realOutput.writeByte(TC_ENDBLOCKDATA);
+ }
+ else
+ {
+ realOutput.writeByte(TC_CLASSDESC);
+ realOutput.writeUTF(osc.getName());
+ realOutput.writeLong(osc.getSerialVersionUID());
+ assignNewHandle(osc);
- int flags = osc.getFlags();
+ int flags = osc.getFlags();
- if (protocolVersion == PROTOCOL_VERSION_2
- && osc.isExternalizable())
- flags |= SC_BLOCK_DATA;
+ if (protocolVersion == PROTOCOL_VERSION_2
+ && osc.isExternalizable())
+ flags |= SC_BLOCK_DATA;
- realOutput.writeByte(flags);
+ realOutput.writeByte(flags);
- ObjectStreamField[] fields = osc.fields;
- realOutput.writeShort(fields.length);
+ ObjectStreamField[] fields = osc.fields;
+ realOutput.writeShort(fields.length);
- ObjectStreamField field;
- for (int i = 0; i < fields.length; i++)
- {
- field = fields[i];
- realOutput.writeByte(field.getTypeCode ());
- realOutput.writeUTF(field.getName ());
+ ObjectStreamField field;
+ for (int i = 0; i < fields.length; i++)
+ {
+ field = fields[i];
+ realOutput.writeByte(field.getTypeCode ());
+ realOutput.writeUTF(field.getName ());
- if (! field.isPrimitive())
- writeObject(field.getTypeString());
- }
+ if (! field.isPrimitive())
+ writeObject(field.getTypeString());
+ }
- boolean oldmode = setBlockDataMode(true);
- annotateClass(osc.forClass());
- setBlockDataMode(oldmode);
- realOutput.writeByte(TC_ENDBLOCKDATA);
+ boolean oldmode = setBlockDataMode(true);
+ annotateClass(osc.forClass());
+ setBlockDataMode(oldmode);
+ realOutput.writeByte(TC_ENDBLOCKDATA);
+ }
if (osc.isSerializable() || osc.isExternalizable())
writeObject(osc.getSuper());
@@ -531,7 +548,7 @@ public class ObjectOutputStream extends OutputStream
* version)</code> is provided to change the default protocol
* version.
*
- * For an explination of the differences beween the two protocols
+ * For an explanation of the differences between the two protocols
* see XXX: the Java ObjectSerialization Specification.
*
* @exception IOException if <code>version</code> is not a valid
@@ -1567,12 +1584,4 @@ public class ObjectOutputStream extends OutputStream
private boolean dump = false;
private static final boolean DEBUG = false;
-
- static
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- {
- System.loadLibrary("javaio");
- }
- }
}
diff --git a/libjava/classpath/java/io/ObjectStreamField.java b/libjava/classpath/java/io/ObjectStreamField.java
index 611457b3cfb..61ccdc7db76 100644
--- a/libjava/classpath/java/io/ObjectStreamField.java
+++ b/libjava/classpath/java/io/ObjectStreamField.java
@@ -208,7 +208,7 @@ public class ObjectStreamField implements Comparable
* This method sets the current offset of the field.
*
* @param off The offset of the field in bytes.
- * @see getOffset()
+ * @see #getOffset()
*/
protected void setOffset (int off)
{
diff --git a/libjava/classpath/java/io/OutputStreamWriter.java b/libjava/classpath/java/io/OutputStreamWriter.java
index ee229796cce..29fb631faf4 100644
--- a/libjava/classpath/java/io/OutputStreamWriter.java
+++ b/libjava/classpath/java/io/OutputStreamWriter.java
@@ -39,16 +39,14 @@ exception statement from your version. */
package java.io;
import gnu.java.nio.charset.EncodingHelper;
+
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
-import java.nio.charset.MalformedInputException;
-import java.nio.charset.UnsupportedCharsetException;
import java.nio.charset.CharacterCodingException;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.MalformedInputException;
/**
* This class writes characters to an output stream that is byte oriented
@@ -124,52 +122,58 @@ public class OutputStreamWriter extends Writer
{
this.out = out;
try
- {
- // Don't use NIO if avoidable
- if(EncodingHelper.isISOLatin1(encoding_scheme))
{
- 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){
- }
+ // Don't use NIO if avoidable
+ if(EncodingHelper.isISOLatin1(encoding_scheme))
+ {
+ encodingName = "ISO8859_1";
+ encoder = null;
+ return;
+ }
- outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
+ /*
+ * 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());
+ 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) {
- // Default to ISO Latin-1, will happen if this is called, for instance,
- // before the NIO provider is loadable.
- encoder = null;
- encodingName = "ISO8859_1";
- }
+ encoder.onMalformedInput(CodingErrorAction.REPLACE);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ }
+ catch(RuntimeException e)
+ {
+ // Default to ISO Latin-1, will happen if this is called, for instance,
+ // before the NIO provider is loadable.
+ encoder = null;
+ encodingName = "ISO8859_1";
+ }
}
/**
@@ -183,21 +187,55 @@ public class OutputStreamWriter extends Writer
this.out = out;
outputBuffer = null;
try
- {
- String encoding = System.getProperty("file.encoding");
- Charset cs = Charset.forName(encoding);
- encoder = cs.newEncoder();
- encodingName = EncodingHelper.getOldCanonical(cs.name());
- } catch(RuntimeException e) {
- encoder = null;
- encodingName = "ISO8859_1";
- }
+ {
+ String encoding = System.getProperty("file.encoding");
+ Charset cs = Charset.forName(encoding);
+ encoder = cs.newEncoder();
+ encodingName = EncodingHelper.getOldCanonical(cs.name());
+ }
+ catch(RuntimeException e)
+ {
+ encoder = null;
+ encodingName = "ISO8859_1";
+ }
+
if(encoder != null)
- {
- encoder.onMalformedInput(CodingErrorAction.REPLACE);
- encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
- outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
- }
+ {
+ encoder.onMalformedInput(CodingErrorAction.REPLACE);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
+ }
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using a given <code>Charset</code>.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ * @param cs The <code>Charset</code> of the encoding to use
+ */
+ public OutputStreamWriter(OutputStream out, Charset cs)
+ {
+ this.out = out;
+ encoder = cs.newEncoder();
+ encoder.onMalformedInput(CodingErrorAction.REPLACE);
+ encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
+ }
+
+ /**
+ * This method initializes a new instance of <code>OutputStreamWriter</code>
+ * to write to the specified stream using a given
+ * <code>CharsetEncoder</code>.
+ *
+ * @param out The <code>OutputStream</code> to write to
+ * @param enc The <code>CharsetEncoder</code> to encode the output with
+ */
+ public OutputStreamWriter(OutputStream out, CharsetEncoder enc)
+ {
+ this.out = out;
+ encoder = enc;
+ outputBuffer = CharBuffer.allocate(BUFFER_SIZE);
}
/**
diff --git a/libjava/classpath/java/io/PipedInputStream.java b/libjava/classpath/java/io/PipedInputStream.java
index beb310b4f0c..523ae2c70d3 100644
--- a/libjava/classpath/java/io/PipedInputStream.java
+++ b/libjava/classpath/java/io/PipedInputStream.java
@@ -130,7 +130,7 @@ public class PipedInputStream extends InputStream
* This stream is then ready for reading. If this stream is already
* connected or has been previously closed, then an exception is thrown
*
- * @param src The <code>PipedOutputStream</code> to connect this stream to
+ * @param source The <code>PipedOutputStream</code> to connect this stream to
*
* @exception IOException If this PipedInputStream or <code>source</code>
* has been connected already.
diff --git a/libjava/classpath/java/io/PrintWriter.java b/libjava/classpath/java/io/PrintWriter.java
index 5fd0b162f31..5667e705004 100644
--- a/libjava/classpath/java/io/PrintWriter.java
+++ b/libjava/classpath/java/io/PrintWriter.java
@@ -70,6 +70,11 @@ public class PrintWriter extends Writer
* on this stream.
*/
private boolean error;
+
+ /**
+ * Indicates whether or not the stream has been closed.
+ */
+ private boolean closed;
/**
* This is the underlying <code>Writer</code> we are sending output
@@ -139,6 +144,68 @@ public class PrintWriter extends Writer
}
/**
+ * This initializes a new PrintWriter object to write to the specified
+ * file. It creates a FileOutputStream object and wraps it in an
+ * OutputStreamWriter using the default encoding.
+ * @param file name of the file to write to
+ * @throws FileNotFoundException if the file cannot be written or created
+ *
+ * @since 1.5
+ */
+ public PrintWriter(String file) throws FileNotFoundException
+ {
+ this(new FileOutputStream(file));
+ }
+
+ /**
+ * This initializes a new PrintWriter object to write to the specified
+ * file. It creates a FileOutputStream object and wraps it in an
+ * OutputStreamWriter using the specified encoding.
+ * @param file name of the file to write to
+ * @param enc the encoding to use
+ * @throws FileNotFoundException if the file cannot be written or created
+ * @throws UnsupportedEncodingException if the encoding is not supported
+ *
+ * @since 1.5
+ */
+ public PrintWriter(String file, String enc)
+ throws FileNotFoundException, UnsupportedEncodingException
+ {
+ this(new OutputStreamWriter(new FileOutputStream(file), enc));
+ }
+
+ /**
+ * This initializes a new PrintWriter object to write to the specified
+ * file. It creates a FileOutputStream object and wraps it in an
+ * OutputStreamWriter using the default encoding.
+ * @param file the file to write to
+ * @throws FileNotFoundException if the file cannot be written or created
+ *
+ * @since 1.5
+ */
+ public PrintWriter(File file) throws FileNotFoundException
+ {
+ this(new FileOutputStream(file));
+ }
+
+ /**
+ * This initializes a new PrintWriter object to write to the specified
+ * file. It creates a FileOutputStream object and wraps it in an
+ * OutputStreamWriter using the specified encoding.
+ * @param file the file to write to
+ * @param enc the encoding to use
+ * @throws FileNotFoundException if the file cannot be written or created
+ * @throws UnsupportedEncodingException if the encoding is not supported
+ *
+ * @since 1.5
+ */
+ public PrintWriter(File file, String enc)
+ throws FileNotFoundException, UnsupportedEncodingException
+ {
+ this(new OutputStreamWriter(new FileOutputStream(file), enc));
+ }
+
+ /**
* This method can be called by subclasses to indicate that an error
* has occurred and should be reported by <code>checkError</code>.
*/
@@ -158,7 +225,8 @@ public class PrintWriter extends Writer
*/
public boolean checkError()
{
- flush();
+ if (! closed)
+ flush();
return error;
}
@@ -185,7 +253,8 @@ public class PrintWriter extends Writer
{
try
{
- out.close();
+ out.close();
+ closed = true;
}
catch (IOException ex)
{
@@ -310,7 +379,7 @@ public class PrintWriter extends Writer
* This is the system dependent line separator
*/
private static final char[] line_separator
- = System.getProperty("line.separator").toCharArray();
+ = System.getProperty("line.separator", "\n").toCharArray();
/**
* This method prints a line separator sequence to the stream. The value
diff --git a/libjava/classpath/java/io/PushbackInputStream.java b/libjava/classpath/java/io/PushbackInputStream.java
index 71cf244274e..ff202c72df1 100644
--- a/libjava/classpath/java/io/PushbackInputStream.java
+++ b/libjava/classpath/java/io/PushbackInputStream.java
@@ -116,7 +116,14 @@ public class PushbackInputStream extends FilterInputStream
*/
public int available() throws IOException
{
- return (buf.length - pos) + super.available();
+ try
+ {
+ return (buf.length - pos) + super.available();
+ }
+ catch (NullPointerException npe)
+ {
+ throw new IOException ("Stream closed");
+ }
}
/**
diff --git a/libjava/classpath/java/lang/Boolean.java b/libjava/classpath/java/lang/Boolean.java
index b6910280e6b..902c93b3186 100644
--- a/libjava/classpath/java/lang/Boolean.java
+++ b/libjava/classpath/java/lang/Boolean.java
@@ -221,4 +221,36 @@ public final class Boolean implements Serializable
return false;
return "true".equalsIgnoreCase(System.getProperty(name));
}
+
+ /**
+ * If the String argument is "true", ignoring case, return true.
+ * Otherwise, return false.
+ *
+ * @param b String to parse
+ * @since 1.5
+ */
+ public static boolean parseBoolean(String b)
+ {
+ return "true".equalsIgnoreCase(b) ? true : false;
+ }
+
+ /**
+ * Compares this Boolean to another.
+ * @param b the Boolean to compare this Boolean to
+ * @return 0 if both Booleans represent the same value, a positive number
+ * if this Boolean represents true and b represents false, or a negative
+ * number otherwise.
+ * @since 1.5
+ */
+ public int compareTo (Boolean b)
+ {
+ if (b == null)
+ throw new NullPointerException("argument passed to compareTo(Boolean) cannot be null");
+
+ if (this.value == b.value)
+ return 0;
+ if (this.value == true)
+ return 1;
+ return -1;
+ }
}
diff --git a/libjava/classpath/java/lang/Byte.java b/libjava/classpath/java/lang/Byte.java
index 338e2167aa1..2560bfcffc3 100644
--- a/libjava/classpath/java/lang/Byte.java
+++ b/libjava/classpath/java/lang/Byte.java
@@ -50,7 +50,7 @@ package java.lang;
* @author Per Bothner
* @author Eric Blake (ebb9@email.byu.edu)
* @since 1.1
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public final class Byte extends Number implements Comparable
{
@@ -78,6 +78,16 @@ public final class Byte extends Number implements Comparable
public static final Class TYPE = VMClassLoader.getPrimitiveClass('B');
/**
+ * The number of bits needed to represent a <code>byte</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 8;
+
+ // This caches Byte values, and is used by boxing conversions via
+ // valueOf(). We're required to cache all possible values here.
+ private static Byte[] byteCache = new Byte[MAX_VALUE - MIN_VALUE + 1];
+
+ /**
* The immutable value of this Byte.
*
* @serial the wrapped byte
@@ -192,6 +202,26 @@ public final class Byte extends Number implements Comparable
}
/**
+ * Returns a <code>Byte</code> object wrapping the value.
+ * In contrast to the <code>Byte</code> constructor, this method
+ * will cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Byte</code>
+ *
+ * @since 1.5
+ */
+ public static Byte valueOf(byte val)
+ {
+ synchronized (byteCache)
+ {
+ if (byteCache[val - MIN_VALUE] == null)
+ byteCache[val - MIN_VALUE] = new Byte(val);
+ return byteCache[val - MIN_VALUE];
+ }
+ }
+
+ /**
* Convert the specified <code>String</code> into a <code>Byte</code>.
* The <code>String</code> may represent decimal, hexadecimal, or
* octal numbers.
diff --git a/libjava/classpath/java/lang/Character.java b/libjava/classpath/java/lang/Character.java
index 1e4f219a15f..78db41ef216 100644
--- a/libjava/classpath/java/lang/Character.java
+++ b/libjava/classpath/java/lang/Character.java
@@ -1,5 +1,5 @@
/* java.lang.Character -- Wrapper class for char, and Unicode subsets
- Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -1034,6 +1034,18 @@ public final class Character implements Serializable, Comparable
public static final Class TYPE = VMClassLoader.getPrimitiveClass('C');
/**
+ * The number of bits needed to represent a <code>char</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 16;
+
+ // This caches some Character values, and is used by boxing
+ // conversions via valueOf(). We must cache at least 0..127;
+ // this constant controls how much we actually cache.
+ private static final int MAX_CACHE = 127;
+ private static Character[] charCache = new Character[MAX_CACHE + 1];
+
+ /**
* Lu = Letter, Uppercase (Informative).
*
* @since 1.1
@@ -1480,34 +1492,48 @@ public final class Character implements Serializable, Comparable
/**
- * Minimum high surrrogate code in UTF-16 encoding.
+ * Minimum high surrogate code in UTF-16 encoding.
*
* @since 1.5
*/
public static final char MIN_HIGH_SURROGATE = '\ud800';
/**
- * Maximum high surrrogate code in UTF-16 encoding.
+ * Maximum high surrogate code in UTF-16 encoding.
*
* @since 1.5
*/
public static final char MAX_HIGH_SURROGATE = '\udbff';
/**
- * Minimum low surrrogate code in UTF-16 encoding.
+ * Minimum low surrogate code in UTF-16 encoding.
*
* @since 1.5
*/
public static final char MIN_LOW_SURROGATE = '\udc00';
/**
- * Maximum low surrrogate code in UTF-16 encoding.
+ * Maximum low surrogate code in UTF-16 encoding.
*
* @since 1.5
*/
public static final char MAX_LOW_SURROGATE = '\udfff';
/**
+ * Minimum surrogate code in UTF-16 encoding.
+ *
+ * @since 1.5
+ */
+ public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE;
+
+ /**
+ * Maximum low surrogate code in UTF-16 encoding.
+ *
+ * @since 1.5
+ */
+ public static final char MAX_SURROGATE = MAX_LOW_SURROGATE;
+
+ /**
* Grabs an attribute offset from the Unicode attribute database. The lower
* 5 bits are the character type, the next 2 bits are flags, and the top
* 9 bits are the offset into the attribute tables.
@@ -2303,6 +2329,37 @@ public final class Character implements Serializable, Comparable
}
/**
+ * Returns an <code>Character</code> object wrapping the value.
+ * In contrast to the <code>Character</code> constructor, this method
+ * will cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Character</code>
+ *
+ * @since 1.5
+ */
+ public static Character valueOf(char val)
+ {
+ if (val > MAX_CACHE)
+ return new Character(val);
+ synchronized (charCache)
+ {
+ if (charCache[val - MIN_VALUE] == null)
+ charCache[val - MIN_VALUE] = new Character(val);
+ return charCache[val - MIN_VALUE];
+ }
+ }
+
+ /**
+ * Reverse the bytes in val.
+ * @since 1.5
+ */
+ public static char reverseBytes(char val)
+ {
+ return (char) (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
+ }
+
+ /**
* Converts a unicode code point to a UTF-16 representation of that
* code point.
*
@@ -2370,7 +2427,7 @@ public final class Character implements Serializable, Comparable
* Return number of 16-bit characters required to represent the given
* code point.
*
- * @param codePoint a uncode code point
+ * @param codePoint a unicode code point
*
* @return 2 if codePoint >= 0x10000, 1 otherwise.
*
@@ -2415,4 +2472,210 @@ public final class Character implements Serializable, Comparable
{
return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT;
}
+
+ /**
+ * Return true if the given character is a high surrogate.
+ * @param ch the character
+ * @return true if the character is a high surrogate character
+ *
+ * @since 1.5
+ */
+ public static boolean isHighSurrogate(char ch)
+ {
+ return ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE;
+ }
+
+ /**
+ * Return true if the given character is a low surrogate.
+ * @param ch the character
+ * @return true if the character is a low surrogate character
+ *
+ * @since 1.5
+ */
+ public static boolean isLowSurrogate(char ch)
+ {
+ return ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE;
+ }
+
+ /**
+ * Return true if the given characters compose a surrogate pair.
+ * This is true if the first character is a high surrogate and the
+ * second character is a low surrogate.
+ * @param ch1 the first character
+ * @param ch2 the first character
+ * @return true if the characters compose a surrogate pair
+ *
+ * @since 1.5
+ */
+ public static boolean isSurrogatePair(char ch1, char ch2)
+ {
+ return isHighSurrogate(ch1) && isLowSurrogate(ch2);
+ }
+
+ /**
+ * Given a valid surrogate pair, this returns the corresponding
+ * code point.
+ * @param high the high character of the pair
+ * @param low the low character of the pair
+ * @return the corresponding code point
+ *
+ * @since 1.5
+ */
+ public static int toCodePoint(char high, char low)
+ {
+ return ((high - MIN_HIGH_SURROGATE) << 10) + (low - MIN_LOW_SURROGATE);
+ }
+
+ /**
+ * Get the code point at the specified index in the CharSequence.
+ * This is like CharSequence#charAt(int), but if the character is
+ * the start of a surrogate pair, and there is a following
+ * character, and this character completes the pair, then the
+ * corresponding supplementary code point is returned. Otherwise,
+ * the character at the index is returned.
+ *
+ * @param sequence the CharSequence
+ * @param index the index of the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * @since 1.5
+ */
+ public static int codePointAt(CharSequence sequence, int index)
+ {
+ int len = sequence.length();
+ if (index < 0 || index >= len)
+ throw new IndexOutOfBoundsException();
+ char high = sequence.charAt(index);
+ if (! isHighSurrogate(high) || ++index >= len)
+ return high;
+ char low = sequence.charAt(index);
+ if (! isLowSurrogate(low))
+ return high;
+ return toCodePoint(high, low);
+ }
+
+ /**
+ * Get the code point at the specified index in the CharSequence.
+ * If the character is the start of a surrogate pair, and there is a
+ * following character, and this character completes the pair, then
+ * the corresponding supplementary code point is returned.
+ * Otherwise, the character at the index is returned.
+ *
+ * @param chars the character array in which to look
+ * @param index the index of the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * @since 1.5
+ */
+ public static int codePointAt(char[] chars, int index)
+ {
+ return codePointAt(chars, index, chars.length);
+ }
+
+ /**
+ * Get the code point at the specified index in the CharSequence.
+ * If the character is the start of a surrogate pair, and there is a
+ * following character within the specified range, and this
+ * character completes the pair, then the corresponding
+ * supplementary code point is returned. Otherwise, the character
+ * at the index is returned.
+ *
+ * @param chars the character array in which to look
+ * @param index the index of the codepoint to get, starting at 0
+ * @param limit the limit past which characters should not be examined
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;=
+ * limit, or if limit is negative or &gt;= the length of the array
+ * @since 1.5
+ */
+ public static int codePointAt(char[] chars, int index, int limit)
+ {
+ if (index < 0 || index >= limit || limit < 0 || limit >= chars.length)
+ throw new IndexOutOfBoundsException();
+ char high = chars[index];
+ if (! isHighSurrogate(high) || ++index >= limit)
+ return high;
+ char low = chars[index];
+ if (! isLowSurrogate(low))
+ return high;
+ return toCodePoint(high, low);
+ }
+
+ /**
+ * Get the code point before the specified index. This is like
+ * #codePointAt(char[], int), but checks the characters at
+ * <code>index-1</code> and <code>index-2</code> to see if they form
+ * a supplementary code point. If they do not, the character at
+ * <code>index-1</code> is returned.
+ *
+ * @param chars the character array
+ * @param index the index just past the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * @since 1.5
+ */
+ public static int codePointBefore(char[] chars, int index)
+ {
+ return codePointBefore(chars, index, 1);
+ }
+
+ /**
+ * Get the code point before the specified index. This is like
+ * #codePointAt(char[], int), but checks the characters at
+ * <code>index-1</code> and <code>index-2</code> to see if they form
+ * a supplementary code point. If they do not, the character at
+ * <code>index-1</code> is returned. The start parameter is used to
+ * limit the range of the array which may be examined.
+ *
+ * @param chars the character array
+ * @param index the index just past the codepoint to get, starting at 0
+ * @param start the index before which characters should not be examined
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is &gt; start or &gt;
+ * the length of the array, or if limit is negative or &gt;= the
+ * length of the array
+ * @since 1.5
+ */
+ public static int codePointBefore(char[] chars, int index, int start)
+ {
+ if (index < start || index > chars.length
+ || start < 0 || start >= chars.length)
+ throw new IndexOutOfBoundsException();
+ --index;
+ char low = chars[index];
+ if (! isLowSurrogate(low) || --index < start)
+ return low;
+ char high = chars[index];
+ if (! isHighSurrogate(high))
+ return low;
+ return toCodePoint(high, low);
+ }
+
+ /**
+ * Get the code point before the specified index. This is like
+ * #codePointAt(CharSequence, int), but checks the characters at
+ * <code>index-1</code> and <code>index-2</code> to see if they form
+ * a supplementary code point. If they do not, the character at
+ * <code>index-1</code> is returned.
+ *
+ * @param sequence the CharSequence
+ * @param index the index just past the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * @since 1.5
+ */
+ public static int codePointBefore(CharSequence sequence, int index)
+ {
+ int len = sequence.length();
+ if (index < 1 || index > len)
+ throw new IndexOutOfBoundsException();
+ --index;
+ char low = sequence.charAt(index);
+ if (! isLowSurrogate(low) || --index < 0)
+ return low;
+ char high = sequence.charAt(index);
+ if (! isHighSurrogate(high))
+ return low;
+ return toCodePoint(high, low);
+ }
} // class Character
diff --git a/libjava/classpath/java/lang/Class.java b/libjava/classpath/java/lang/Class.java
index 22f148e9136..726c794a413 100644
--- a/libjava/classpath/java/lang/Class.java
+++ b/libjava/classpath/java/lang/Class.java
@@ -41,7 +41,9 @@ package java.lang;
import gnu.classpath.VMStackWalker;
import java.io.InputStream;
+import java.io.ObjectStreamClass;
import java.io.Serializable;
+import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@@ -99,7 +101,7 @@ public final class Class implements Serializable
/** The class signers. */
private Object[] signers = null;
/** The class protection domain. */
- private final ProtectionDomain pd;
+ private final transient ProtectionDomain pd;
/* We use an inner class, so that Class doesn't have a static initializer */
private static final class StaticData
@@ -592,7 +594,8 @@ public final class Class implements Serializable
ClassLoader cl = getClassLoader();
if (cl != null)
return cl.getPackage(getPackagePortion(getName()));
- return null;
+ else
+ return VMClassLoader.getPackage(getPackagePortion(getName()));
}
/**
@@ -721,7 +724,7 @@ public final class Class implements Serializable
* @param list List of methods to search
* @param name Name of method
* @param args Method parameter types
- * @see #getMethod()
+ * @see #getMethod(String, Class[])
*/
private static Method matchMethod(Method[] list, String name, Class[] args)
{
@@ -829,7 +832,7 @@ public final class Class implements Serializable
* public and final, but not an interface.
*
* @return the modifiers of this class
- * @see Modifer
+ * @see Modifier
* @since 1.1
*/
public int getModifiers()
diff --git a/libjava/classpath/java/lang/ClassLoader.java b/libjava/classpath/java/lang/ClassLoader.java
index 0d50a6e005d..9f586c4cffc 100644
--- a/libjava/classpath/java/lang/ClassLoader.java
+++ b/libjava/classpath/java/lang/ClassLoader.java
@@ -49,6 +49,7 @@ import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.ByteBuffer;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.Policy;
@@ -472,6 +473,35 @@ public abstract class ClassLoader
}
/**
+ * Helper to define a class using the contents of a byte buffer. If
+ * the domain is null, the default of
+ * <code>Policy.getPolicy().getPermissions(new CodeSource(null,
+ * null))</code> is used. Once a class has been defined in a
+ * package, all further classes in that package must have the same
+ * set of certificates or a SecurityException is thrown.
+ *
+ * @param name the name to give the class. null if unknown
+ * @param buf a byte buffer containing bytes that form a class.
+ * @param domain the ProtectionDomain to give to the class, null for the
+ * default protection domain
+ * @return the class that was defined
+ * @throws ClassFormatError if data is not in proper classfile format
+ * @throws NoClassDefFoundError if the supplied name is not the same as
+ * the one specified by the byte buffer.
+ * @throws SecurityException if name starts with "java.", or if certificates
+ * do not match up
+ * @since 1.5
+ */
+ protected final Class defineClass(String name, ByteBuffer buf,
+ ProtectionDomain domain)
+ throws ClassFormatError
+ {
+ byte[] data = new byte[buf.remaining()];
+ buf.get(data);
+ return defineClass(name, data, 0, data.length, domain);
+ }
+
+ /**
* Links the class, if that has not already been done. Linking basically
* resolves all references to other classes made by this class.
*
@@ -883,7 +913,7 @@ public abstract class ClassLoader
*
* @param name the (system specific) name of the requested library
* @return the full pathname to the requested library, or null
- * @see Runtime#loadLibrary()
+ * @see Runtime#loadLibrary(String)
* @since 1.2
*/
protected String findLibrary(String name)
@@ -913,7 +943,7 @@ public abstract class ClassLoader
*
* @param name the package (and subpackages) to affect
* @param enabled true to set the default to enabled
- * @see #setDefaultAssertionStatus(String, boolean)
+ * @see #setDefaultAssertionStatus(boolean)
* @see #setClassAssertionStatus(String, boolean)
* @see #clearAssertionStatus()
* @since 1.4
@@ -934,7 +964,7 @@ public abstract class ClassLoader
* @param name the class to affect
* @param enabled true to set the default to enabled
* @throws NullPointerException if name is null
- * @see #setDefaultAssertionStatus(String, boolean)
+ * @see #setDefaultAssertionStatus(boolean)
* @see #setPackageAssertionStatus(String, boolean)
* @see #clearAssertionStatus()
* @since 1.4
diff --git a/libjava/classpath/java/lang/Double.java b/libjava/classpath/java/lang/Double.java
index 4fa47f46ddd..26b398bb695 100644
--- a/libjava/classpath/java/lang/Double.java
+++ b/libjava/classpath/java/lang/Double.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.lang;
-import gnu.classpath.Configuration;
/**
* Instances of class <code>Double</code> represent primitive
@@ -89,6 +88,12 @@ public final class Double extends Number implements Comparable
public static final double NaN = 0.0 / 0.0;
/**
+ * The number of bits needed to represent a <code>double</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 64;
+
+ /**
* The primitive type <code>double</code> is represented by this
* <code>Class</code> object.
* @since 1.1
@@ -168,6 +173,22 @@ public final class Double extends Number implements Comparable
}
/**
+ * Returns a <code>Double</code> object wrapping the value.
+ * In contrast to the <code>Double</code> constructor, this method
+ * may cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Double</code>
+ *
+ * @since 1.5
+ */
+ public static Double valueOf(double val)
+ {
+ // We don't actually cache, but we could.
+ return new Double(val);
+ }
+
+ /**
* Create a new <code>Double</code> object using the <code>String</code>.
*
* @param s the <code>String</code> to convert
diff --git a/libjava/classpath/java/lang/EnumConstantNotPresentException.java b/libjava/classpath/java/lang/EnumConstantNotPresentException.java
new file mode 100644
index 00000000000..dbec9d658ef
--- /dev/null
+++ b/libjava/classpath/java/lang/EnumConstantNotPresentException.java
@@ -0,0 +1,93 @@
+/* EnumConstantNotPresentException.java -- thrown when enum constant
+ not available
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+/**
+ * An exception of this type is thrown when a symbolic reference is
+ * made to an enum constant which does not exist.
+ *
+ * @author Tom Tromey (tromey@redhat.com)
+ * @since 1.5
+ */
+public class EnumConstantNotPresentException extends RuntimeException
+{
+ /**
+ * The enum's type. Note that the name is fixed by the
+ * serialization spec.
+ */
+ private Class enumType;
+
+ /**
+ * The name of the missing enum constant. Note that the name is
+ * fixed by the serialization spec.
+ */
+ private String constantName;
+
+ /**
+ * Create a new EnumConstantNotPresentException with the indicated
+ * enum type and enum constant name.
+ * @param theEnum the enum's class
+ * @param name the name of the missing enum constant
+ */
+ public EnumConstantNotPresentException(Class theEnum, String name)
+ {
+ super("enum " + theEnum + " is missing the constant " + name);
+ enumType = theEnum;
+ constantName = name;
+ }
+
+ /**
+ * Return the name of the missing constant.
+ * @return the name of the missing constant
+ */
+ public String constantName()
+ {
+ return constantName;
+ }
+
+ /**
+ * Return the enum type which is missing a constant.
+ * @return the enum type which is missing a constant
+ */
+ public Class enumType()
+ {
+ return enumType;
+ }
+}
diff --git a/libjava/classpath/java/lang/Float.java b/libjava/classpath/java/lang/Float.java
index e6200dabddc..eef34a0abeb 100644
--- a/libjava/classpath/java/lang/Float.java
+++ b/libjava/classpath/java/lang/Float.java
@@ -94,6 +94,12 @@ public final class Float extends Number implements Comparable
public static final Class TYPE = VMClassLoader.getPrimitiveClass('F');
/**
+ * The number of bits needed to represent a <code>float</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 32;
+
+ /**
* The immutable value of this Float.
*
* @serial the wrapped float
@@ -192,6 +198,22 @@ public final class Float extends Number implements Comparable
}
/**
+ * Returns a <code>Float</code> object wrapping the value.
+ * In contrast to the <code>Float</code> constructor, this method
+ * may cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Float</code>
+ *
+ * @since 1.5
+ */
+ public static Float valueOf(float val)
+ {
+ // We don't actually cache, but we could.
+ return new Float(val);
+ }
+
+ /**
* Parse the specified <code>String</code> as a <code>float</code>. The
* extended BNF grammar is as follows:<br>
* <pre>
diff --git a/libjava/classpath/java/lang/Integer.java b/libjava/classpath/java/lang/Integer.java
index 53de9ab9667..f3fe85f5041 100644
--- a/libjava/classpath/java/lang/Integer.java
+++ b/libjava/classpath/java/lang/Integer.java
@@ -707,8 +707,8 @@ public final class Integer extends Number implements Comparable
* @throws NullPointerException if decode is true and str if null
* @see #parseInt(String, int)
* @see #decode(String)
- * @see Byte#parseInt(String, int)
- * @see Short#parseInt(String, int)
+ * @see Byte#parseByte(String, int)
+ * @see Short#parseShort(String, int)
*/
static int parseInt(String str, int radix, boolean decode)
{
diff --git a/libjava/classpath/java/lang/Long.java b/libjava/classpath/java/lang/Long.java
index 703eab8a0f3..74e2a52df7c 100644
--- a/libjava/classpath/java/lang/Long.java
+++ b/libjava/classpath/java/lang/Long.java
@@ -50,7 +50,7 @@ package java.lang;
* @author Warren Levy
* @author Eric Blake (ebb9@email.byu.edu)
* @since 1.0
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public final class Long extends Number implements Comparable
{
@@ -79,6 +79,12 @@ public final class Long extends Number implements Comparable
public static final Class TYPE = VMClassLoader.getPrimitiveClass ('J');
/**
+ * The number of bits needed to represent a <code>long</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 64;
+
+ /**
* The immutable value of this Long.
*
* @serial the wrapped long
@@ -282,6 +288,21 @@ public final class Long extends Number implements Comparable
}
/**
+ * Returns a <code>Long</code> object wrapping the value.
+ *
+ * @param val the value to wrap
+ * @return the <code>Long</code>
+ *
+ * @since 1.5
+ */
+ public static synchronized Long valueOf(long val)
+ {
+ // We aren't required to cache here. We could, though perhaps we
+ // ought to consider that as an empirical question.
+ return new Long(val);
+ }
+
+ /**
* Convert the specified <code>String</code> into a <code>Long</code>.
* The <code>String</code> may represent decimal, hexadecimal, or
* octal numbers.
@@ -512,6 +533,136 @@ public final class Long extends Number implements Comparable
}
/**
+ * Return the number of bits set in x.
+ * @param x value to examine
+ * @since 1.5
+ */
+ public static int bitCount(long x)
+ {
+ // Successively collapse alternating bit groups into a sum.
+ x = ((x >> 1) & 0x5555555555555555L) + (x & 0x5555555555555555L);
+ x = ((x >> 2) & 0x3333333333333333L) + (x & 0x3333333333333333L);
+ int v = (int) ((x >>> 32) + x);
+ v = ((v >> 4) & 0x0f0f0f0f) + (v & 0x0f0f0f0f);
+ v = ((v >> 8) & 0x00ff00ff) + (v & 0x00ff00ff);
+ return ((v >> 16) & 0x0000ffff) + (v & 0x0000ffff);
+ }
+
+ /**
+ * Rotate x to the left by distance bits.
+ * @param x the value to rotate
+ * @param distance the number of bits by which to rotate
+ * @since 1.5
+ */
+ public static long rotateLeft(long x, int distance)
+ {
+ // This trick works because the shift operators implicitly mask
+ // the shift count.
+ return (x << distance) | (x >>> - distance);
+ }
+
+ /**
+ * Rotate x to the right by distance bits.
+ * @param x the value to rotate
+ * @param distance the number of bits by which to rotate
+ * @since 1.5
+ */
+ public static long rotateRight(long x, int distance)
+ {
+ // This trick works because the shift operators implicitly mask
+ // the shift count.
+ return (x << - distance) | (x >>> distance);
+ }
+
+ /**
+ * Find the highest set bit in value, and return a new value
+ * with only that bit set.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static long highestOneBit(long value)
+ {
+ value |= value >>> 1;
+ value |= value >>> 2;
+ value |= value >>> 4;
+ value |= value >>> 8;
+ value |= value >>> 16;
+ value |= value >>> 32;
+ return value ^ (value >>> 1);
+ }
+
+ /**
+ * Return the number of leading zeros in value.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static int numberOfLeadingZeros(long value)
+ {
+ value |= value >>> 1;
+ value |= value >>> 2;
+ value |= value >>> 4;
+ value |= value >>> 8;
+ value |= value >>> 16;
+ value |= value >>> 32;
+ return bitCount(~value);
+ }
+
+ /**
+ * Find the lowest set bit in value, and return a new value
+ * with only that bit set.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static long lowestOneBit(long value)
+ {
+ // Classic assembly trick.
+ return value & - value;
+ }
+
+ /**
+ * Find the number of trailing zeros in value.
+ * @param value the value to examine
+ * @since 1.5
+ */
+ public static int numberOfTrailingZeros(long value)
+ {
+ return bitCount((value & -value) - 1);
+ }
+
+ /**
+ * Return 1 if x is positive, -1 if it is negative, and 0 if it is
+ * zero.
+ * @param x the value to examine
+ * @since 1.5
+ */
+ public static int signum(long x)
+ {
+ return x < 0 ? -1 : (x > 0 ? 1 : 0);
+ }
+
+ /**
+ * Reverse the bytes in val.
+ * @since 1.5
+ */
+ public static long reverseBytes(long val)
+ {
+ int hi = Integer.reverseBytes((int) val);
+ int lo = Integer.reverseBytes((int) (val >>> 32));
+ return (((long) hi) << 32) | lo;
+ }
+
+ /**
+ * Reverse the bits in val.
+ * @since 1.5
+ */
+ public static long reverse(long val)
+ {
+ long hi = Integer.reverse((int) val) & 0xffffffffL;
+ long lo = Integer.reverse((int) (val >>> 32)) & 0xffffffffL;
+ return (hi << 32) | lo;
+ }
+
+ /**
* Helper for converting unsigned numbers to String.
*
* @param num the number
diff --git a/libjava/classpath/java/lang/Object.java b/libjava/classpath/java/lang/Object.java
index f8c389a57ee..6212d7dfe72 100644
--- a/libjava/classpath/java/lang/Object.java
+++ b/libjava/classpath/java/lang/Object.java
@@ -343,7 +343,7 @@ public class Object
*
* <p>This thread still holds a lock on the object, so it is
* typical to release the lock by exiting the synchronized
- * code, calling wait(), or calling {@link Thread#sleep()}, so
+ * code, calling wait(), or calling {@link Thread#sleep(long)}, so
* that the newly awakened thread can actually resume. The
* awakened thread will most likely be awakened with an
* {@link InterruptedException}, but that is not guaranteed.
@@ -372,7 +372,7 @@ public class Object
*
* <p>This thread still holds a lock on the object, so it is
* typical to release the lock by exiting the synchronized
- * code, calling wait(), or calling {@link Thread#sleep()}, so
+ * code, calling wait(), or calling {@link Thread#sleep(long)}, so
* that one of the newly awakened threads can actually resume.
* The resuming thread will most likely be awakened with an
* {@link InterruptedException}, but that is not guaranteed.
diff --git a/libjava/classpath/java/lang/Process.java b/libjava/classpath/java/lang/Process.java
index b6e18ca4df3..ccaa3f15358 100644
--- a/libjava/classpath/java/lang/Process.java
+++ b/libjava/classpath/java/lang/Process.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.lang;
+import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
diff --git a/libjava/classpath/java/lang/Readable.java b/libjava/classpath/java/lang/Readable.java
index efc1985d606..d8967652b70 100644
--- a/libjava/classpath/java/lang/Readable.java
+++ b/libjava/classpath/java/lang/Readable.java
@@ -39,6 +39,7 @@ package java.lang;
import java.io.IOException;
import java.nio.CharBuffer;
+import java.nio.ReadOnlyBufferException;
/**
* A <code>Readable</code> object is simply a source for Unicode character
diff --git a/libjava/classpath/java/lang/RuntimePermission.java b/libjava/classpath/java/lang/RuntimePermission.java
index ca33307d12b..2f80b91077f 100644
--- a/libjava/classpath/java/lang/RuntimePermission.java
+++ b/libjava/classpath/java/lang/RuntimePermission.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.lang;
import java.security.BasicPermission;
+import java.security.Permission;
/**
* A <code>RuntimePermission</code> contains a permission name, but no
diff --git a/libjava/classpath/java/lang/SecurityManager.java b/libjava/classpath/java/lang/SecurityManager.java
index ef9e7597ddc..26d56a64bf3 100644
--- a/libjava/classpath/java/lang/SecurityManager.java
+++ b/libjava/classpath/java/lang/SecurityManager.java
@@ -41,19 +41,35 @@ package java.lang;
import gnu.classpath.VMStackWalker;
import java.awt.AWTPermission;
+import java.awt.Frame;
+import java.awt.Toolkit;
+import java.awt.Window;
import java.io.File;
import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FilePermission;
+import java.io.RandomAccessFile;
import java.lang.reflect.Member;
import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketImplFactory;
import java.net.SocketPermission;
+import java.net.URL;
+import java.net.URLStreamHandlerFactory;
import java.security.AccessControlContext;
+import java.security.AccessControlException;
import java.security.AccessController;
import java.security.AllPermission;
+import java.security.BasicPermission;
import java.security.Permission;
+import java.security.Policy;
import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
import java.security.Security;
import java.security.SecurityPermission;
+import java.util.Properties;
import java.util.PropertyPermission;
import java.util.StringTokenizer;
@@ -196,7 +212,7 @@ public class SecurityManager
* <ul>
* <li>All methods on the stack are from system classes</li>
* <li>All methods on the stack up to the first "privileged" caller, as
- * created by {@link AccessController.doPrivileged(PrivilegedAction)},
+ * created by {@link AccessController#doPrivileged(PrivilegedAction)},
* are from system classes</li>
* <li>A check of <code>java.security.AllPermission</code> succeeds.</li>
* </ul>
@@ -219,7 +235,7 @@ public class SecurityManager
* <ul>
* <li>All methods on the stack are from system classes</li>
* <li>All methods on the stack up to the first "privileged" caller, as
- * created by {@link AccessController.doPrivileged(PrivilegedAction)},
+ * created by {@link AccessController#doPrivileged(PrivilegedAction)},
* are from system classes</li>
* <li>A check of <code>java.security.AllPermission</code> succeeds.</li>
* </ul>
@@ -258,7 +274,7 @@ public class SecurityManager
* <ul>
* <li>All methods on the stack are from system classes</li>
* <li>All methods on the stack up to the first "privileged" caller, as
- * created by {@link AccessController.doPrivileged(PrivilegedAction)},
+ * created by {@link AccessController#doPrivileged(PrivilegedAction)},
* are from system classes</li>
* <li>A check of <code>java.security.AllPermission</code> succeeds.</li>
* </ul>
@@ -431,7 +447,7 @@ public class SecurityManager
* @throws SecurityException if permission is denied
* @throws NullPointerException if g is null
* @see Thread#Thread()
- * @see ThreadGroup#ThreadGroup()
+ * @see ThreadGroup#ThreadGroup(String)
* @see ThreadGroup#stop()
* @see ThreadGroup#suspend()
* @see ThreadGroup#resume()
@@ -537,7 +553,7 @@ public class SecurityManager
* @throws NullPointerException if filename is null
* @see File
* @see FileInputStream#FileInputStream(String)
- * @see RandomAccessFile#RandomAccessFile(String)
+ * @see RandomAccessFile#RandomAccessFile(String, String)
*/
public void checkRead(String filename)
{
@@ -602,9 +618,9 @@ public class SecurityManager
* @see File
* @see File#canWrite()
* @see File#mkdir()
- * @see File#renameTo()
+ * @see File#renameTo(File)
* @see FileOutputStream#FileOutputStream(String)
- * @see RandomAccessFile#RandomAccessFile(String)
+ * @see RandomAccessFile#RandomAccessFile(String, String)
*/
public void checkWrite(String filename)
{
diff --git a/libjava/classpath/java/lang/Short.java b/libjava/classpath/java/lang/Short.java
index fbeea915bd3..eb40cd9e0e6 100644
--- a/libjava/classpath/java/lang/Short.java
+++ b/libjava/classpath/java/lang/Short.java
@@ -77,6 +77,19 @@ public final class Short extends Number implements Comparable
public static final Class TYPE = VMClassLoader.getPrimitiveClass('S');
/**
+ * The number of bits needed to represent a <code>short</code>.
+ * @since 1.5
+ */
+ public static final int SIZE = 16;
+
+ // This caches some Short values, and is used by boxing conversions
+ // via valueOf(). We must cache at least -128..127; these constants
+ // control how much we actually cache.
+ private static final int MIN_CACHE = -128;
+ private static final int MAX_CACHE = 127;
+ private static Short[] shortCache = new Short[MAX_CACHE - MIN_CACHE + 1];
+
+ /**
* The immutable value of this Short.
*
* @serial the wrapped short
@@ -189,6 +202,28 @@ public final class Short extends Number implements Comparable
}
/**
+ * Returns a <code>Short</code> object wrapping the value.
+ * In contrast to the <code>Short</code> constructor, this method
+ * will cache some values. It is used by boxing conversion.
+ *
+ * @param val the value to wrap
+ * @return the <code>Short</code>
+ *
+ * @since 1.5
+ */
+ public static Short valueOf(short val)
+ {
+ if (val < MIN_CACHE || val > MAX_CACHE)
+ return new Short(val);
+ synchronized (shortCache)
+ {
+ if (shortCache[val - MIN_CACHE] == null)
+ shortCache[val - MIN_CACHE] = new Short(val);
+ return shortCache[val - MIN_CACHE];
+ }
+ }
+
+ /**
* Convert the specified <code>String</code> into a <code>Short</code>.
* The <code>String</code> may represent decimal, hexadecimal, or
* octal numbers.
@@ -350,4 +385,13 @@ public final class Short extends Number implements Comparable
{
return compareTo((Short)o);
}
+
+ /**
+ * Reverse the bytes in val.
+ * @since 1.5
+ */
+ public static short reverseBytes(short val)
+ {
+ return (short) (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
+ }
}
diff --git a/libjava/classpath/java/lang/StrictMath.java b/libjava/classpath/java/lang/StrictMath.java
index 32bd3540d80..2079cc11e41 100644
--- a/libjava/classpath/java/lang/StrictMath.java
+++ b/libjava/classpath/java/lang/StrictMath.java
@@ -1254,7 +1254,7 @@ public final strictfp class StrictMath
/**
* Super precision for 2/pi in 24-bit chunks, for use in
- * {@link #remPiOver2()}.
+ * {@link #remPiOver2(double, double[])}.
*/
private static final int TWO_OVER_PI[] = {
0xa2f983, 0x6e4e44, 0x1529fc, 0x2757d1, 0xf534dd, 0xc0db62,
@@ -1272,7 +1272,7 @@ public final strictfp class StrictMath
/**
* Super precision for pi/2 in 24-bit chunks, for use in
- * {@link #remPiOver2()}.
+ * {@link #remPiOver2(double, double[])}.
*/
private static final double PI_OVER_TWO[] = {
1.570796251296997, // Long bits 0x3ff921fb40000000L.
@@ -1286,8 +1286,8 @@ public final strictfp class StrictMath
};
/**
- * More constants related to pi, used in {@link #remPiOver2()} and
- * elsewhere.
+ * More constants related to pi, used in
+ * {@link #remPiOver2(double, double[])} and elsewhere.
*/
private static final double
PI_L = 1.2246467991473532e-16, // Long bits 0x3ca1a62633145c07L.
@@ -1301,7 +1301,7 @@ public final strictfp class StrictMath
/**
* Natural log and square root constants, for calculation of
* {@link #exp(double)}, {@link #log(double)} and
- * {@link #power(double, double)}. CP is 2/(3*ln(2)).
+ * {@link #pow(double, double)}. CP is 2/(3*ln(2)).
*/
private static final double
SQRT_1_5 = 1.224744871391589, // Long bits 0x3ff3988e1409212eL.
diff --git a/libjava/classpath/java/lang/String.java b/libjava/classpath/java/lang/String.java
index b4db8505051..369d8085a02 100644
--- a/libjava/classpath/java/lang/String.java
+++ b/libjava/classpath/java/lang/String.java
@@ -98,7 +98,7 @@ public final class String implements Serializable, Comparable, CharSequence
/**
* Stores unicode multi-character uppercase expansion table.
- * @see #toUpperCase(char)
+ * @see #toUpperCase(Locale)
* @see CharData#UPPER_EXPAND
*/
private static final char[] upperExpand
@@ -139,7 +139,7 @@ public final class String implements Serializable, Comparable, CharSequence
final int offset;
/**
- * An implementation for {@link CASE_INSENSITIVE_ORDER}.
+ * An implementation for {@link #CASE_INSENSITIVE_ORDER}.
* This must be {@link Serializable}. The class name is dictated by
* compatibility with Sun's JDK.
*/
@@ -233,6 +233,7 @@ public final class String implements Serializable, Comparable, CharSequence
* @param count the number of characters from data to copy
* @throws NullPointerException if data is null
* @throws IndexOutOfBoundsException if (offset &lt; 0 || count &lt; 0
+ * || offset + count &lt; 0 (overflow)
* || offset + count &gt; data.length)
* (while unspecified, this is a StringIndexOutOfBoundsException)
*/
@@ -256,6 +257,7 @@ public final class String implements Serializable, Comparable, CharSequence
* @param count the number of characters from ascii to copy
* @throws NullPointerException if ascii is null
* @throws IndexOutOfBoundsException if (offset &lt; 0 || count &lt; 0
+ * || offset + count &lt; 0 (overflow)
* || offset + count &gt; ascii.length)
* (while unspecified, this is a StringIndexOutOfBoundsException)
* @see #String(byte[])
@@ -267,8 +269,13 @@ public final class String implements Serializable, Comparable, CharSequence
*/
public String(byte[] ascii, int hibyte, int offset, int count)
{
- if (offset < 0 || count < 0 || offset + count > ascii.length)
- throw new StringIndexOutOfBoundsException();
+ if (offset < 0)
+ throw new StringIndexOutOfBoundsException("offset: " + offset);
+ if (count < 0)
+ throw new StringIndexOutOfBoundsException("count: " + count);
+ if (offset + count < 0 || offset + count > ascii.length)
+ throw new StringIndexOutOfBoundsException("offset + count: "
+ + (offset + count));
value = new char[count];
this.offset = 0;
this.count = count;
@@ -327,8 +334,13 @@ public final class String implements Serializable, Comparable, CharSequence
public String(byte[] data, int offset, int count, String encoding)
throws UnsupportedEncodingException
{
- if (offset < 0 || count < 0 || offset + count > data.length)
- throw new StringIndexOutOfBoundsException();
+ if (offset < 0)
+ throw new StringIndexOutOfBoundsException("offset: " + offset);
+ if (count < 0)
+ throw new StringIndexOutOfBoundsException("count: " + count);
+ if (offset + count < 0 || offset + count > data.length)
+ throw new StringIndexOutOfBoundsException("offset + count: "
+ + (offset + count));
try
{
CharsetDecoder csd = Charset.forName(encoding).newDecoder();
@@ -402,8 +414,13 @@ public final class String implements Serializable, Comparable, CharSequence
*/
public String(byte[] data, int offset, int count)
{
- if (offset < 0 || count < 0 || offset + count > data.length)
- throw new StringIndexOutOfBoundsException();
+ if (offset < 0)
+ throw new StringIndexOutOfBoundsException("offset: " + offset);
+ if (count < 0)
+ throw new StringIndexOutOfBoundsException("count: " + count);
+ if (offset + count < 0 || offset + count > data.length)
+ throw new StringIndexOutOfBoundsException("offset + count: "
+ + (offset + count));
int o, c;
char[] v;
String encoding;
@@ -512,8 +529,13 @@ public final class String implements Serializable, Comparable, CharSequence
*/
String(char[] data, int offset, int count, boolean dont_copy)
{
- if (offset < 0 || count < 0 || offset + count > data.length)
- throw new StringIndexOutOfBoundsException();
+ if (offset < 0)
+ throw new StringIndexOutOfBoundsException("offset: " + offset);
+ if (count < 0)
+ throw new StringIndexOutOfBoundsException("count: " + count);
+ if (offset + count < 0 || offset + count > data.length)
+ throw new StringIndexOutOfBoundsException("offset + count: "
+ + (offset + count));
if (dont_copy)
{
value = data;
@@ -554,6 +576,40 @@ public final class String implements Serializable, Comparable, CharSequence
}
/**
+ * Get the code point at the specified index. This is like #charAt(int),
+ * but if the character is the start of a surrogate pair, and the
+ * following character completes the pair, then the corresponding
+ * supplementary code point is returned.
+ * @param index the index of the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * @since 1.5
+ */
+ public synchronized int codePointAt(int index)
+ {
+ // Use the CharSequence overload as we get better range checking
+ // this way.
+ return Character.codePointAt(this, index);
+ }
+
+ /**
+ * Get the code point before the specified index. This is like
+ * #codePointAt(int), but checks the characters at <code>index-1</code> and
+ * <code>index-2</code> to see if they form a supplementary code point.
+ * @param index the index just past the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * (while unspecified, this is a StringIndexOutOfBoundsException)
+ * @since 1.5
+ */
+ public synchronized int codePointBefore(int index)
+ {
+ // Use the CharSequence overload as we get better range checking
+ // this way.
+ return Character.codePointBefore(this, index);
+ }
+
+ /**
* Copies characters from this String starting at a specified start index,
* ending at a specified stop index, to a character array starting at
* a specified destination begin index.
@@ -628,21 +684,26 @@ public final class String implements Serializable, Comparable, CharSequence
ByteBuffer bbuf = cse.encode(CharBuffer.wrap(value, offset, count));
if(bbuf.hasArray())
return bbuf.array();
-
+
// Doubt this will happen. But just in case.
byte[] bytes = new byte[bbuf.remaining()];
bbuf.get(bytes);
return bytes;
-
- } catch(IllegalCharsetNameException e){
- throw new UnsupportedEncodingException("Encoding: "+enc+
- " not found.");
- } catch(UnsupportedCharsetException e){
- throw new UnsupportedEncodingException("Encoding: "+enc+
- " not found.");
- } catch(CharacterCodingException e){
- // XXX - Ignore coding exceptions? They shouldn't really happen.
- return null;
+ }
+ catch(IllegalCharsetNameException e)
+ {
+ throw new UnsupportedEncodingException("Encoding: " + enc
+ + " not found.");
+ }
+ catch(UnsupportedCharsetException e)
+ {
+ throw new UnsupportedEncodingException("Encoding: " + enc
+ + " not found.");
+ }
+ catch(CharacterCodingException e)
+ {
+ // This shouldn't ever happen.
+ throw (InternalError) new InternalError().initCause(e);
}
}
@@ -726,6 +787,26 @@ public final class String implements Serializable, Comparable, CharSequence
}
/**
+ * Compares the given CharSequence to this String. This is true if
+ * the CharSequence has the same content as this String at this
+ * moment.
+ *
+ * @param seq the CharSequence to compare to
+ * @return true if CharSequence has the same character sequence
+ * @throws NullPointerException if the given CharSequence is null
+ * @since 1.5
+ */
+ public boolean contentEquals(CharSequence seq)
+ {
+ if (seq.length() != count)
+ return false;
+ for (int i = 0; i < count; ++i)
+ if (value[offset + i] != seq.charAt(i))
+ return false;
+ return true;
+ }
+
+ /**
* Compares a String to this String, ignoring case. This does not handle
* multi-character capitalization exceptions; instead the comparison is
* made on a character-by-character basis, and is true if:<br><ul>
@@ -1546,6 +1627,7 @@ public final class String implements Serializable, Comparable, CharSequence
* @return String containing the chars from data[offset..offset+count]
* @throws NullPointerException if data is null
* @throws IndexOutOfBoundsException if (offset &lt; 0 || count &lt; 0
+ * || offset + count &lt; 0 (overflow)
* || offset + count &gt; data.length)
* (while unspecified, this is a StringIndexOutOfBoundsException)
* @see #String(char[], int, int)
@@ -1566,6 +1648,7 @@ public final class String implements Serializable, Comparable, CharSequence
* @return String containing the chars from data[offset..offset+count]
* @throws NullPointerException if data is null
* @throws IndexOutOfBoundsException if (offset &lt; 0 || count &lt; 0
+ * || offset + count &lt; 0 (overflow)
* || offset + count &gt; data.length)
* (while unspecified, this is a StringIndexOutOfBoundsException)
* @see #String(char[], int, int)
@@ -1677,6 +1760,49 @@ public final class String implements Serializable, Comparable, CharSequence
}
/**
+ * Return the number of code points between two indices in the
+ * <code>StringBuffer</code>. An unpaired surrogate counts as a
+ * code point for this purpose. Characters outside the indicated
+ * range are not examined, even if the range ends in the middle of a
+ * surrogate pair.
+ *
+ * @param start the starting index
+ * @param end one past the ending index
+ * @return the number of code points
+ * @since 1.5
+ */
+ public synchronized int codePointCount(int start, int end)
+ {
+ if (start < 0 || end >= count || start > end)
+ throw new StringIndexOutOfBoundsException();
+
+ start += offset;
+ end += offset;
+ int count = 0;
+ while (start < end)
+ {
+ char base = value[start];
+ if (base < Character.MIN_HIGH_SURROGATE
+ || base > Character.MAX_HIGH_SURROGATE
+ || start == end
+ || start == count
+ || value[start + 1] < Character.MIN_LOW_SURROGATE
+ || value[start + 1] > Character.MAX_LOW_SURROGATE)
+ {
+ // Nothing.
+ }
+ else
+ {
+ // Surrogate pair.
+ ++start;
+ }
+ ++start;
+ ++count;
+ }
+ return count;
+ }
+
+ /**
* Helper function used to detect which characters have a multi-character
* uppercase expansion. Note that this is only used in locations which
* track one-to-many capitalization (java.lang.Character does not do this).
@@ -1747,4 +1873,43 @@ public final class String implements Serializable, Comparable, CharSequence
return value;
}
+
+ /**
+ * Returns true iff this String contains the sequence of Characters
+ * described in s.
+ * @param s the CharSequence
+ * @return true iff this String contains s
+ */
+ public boolean contains (CharSequence s)
+ {
+ return this.indexOf(s.toString()) != -1;
+ }
+
+ /**
+ * Returns a string that is this string with all instances of the sequence
+ * represented by <code>target</code> replaced by the sequence in
+ * <code>replacement</code>.
+ * @param target the sequence to be replaced
+ * @param replacement the sequence used as the replacement
+ * @return the string constructed as above
+ */
+ public String replace (CharSequence target, CharSequence replacement)
+ {
+ String targetString = target.toString();
+ String replaceString = replacement.toString();
+ int targetLength = target.length();
+ int replaceLength = replacement.length();
+
+ int startPos = this.indexOf(targetString);
+ StringBuilder result = new StringBuilder(this);
+ while (startPos != -1)
+ {
+ // Replace the target with the replacement
+ result.replace(startPos, startPos + targetLength, replaceString);
+
+ // Search for a new occurrence of the target
+ startPos = result.indexOf(targetString, startPos + replaceLength);
+ }
+ return result.toString();
+ }
}
diff --git a/libjava/classpath/java/lang/StringBuffer.java b/libjava/classpath/java/lang/StringBuffer.java
index 94dec4878cb..caffd6e7050 100644
--- a/libjava/classpath/java/lang/StringBuffer.java
+++ b/libjava/classpath/java/lang/StringBuffer.java
@@ -148,6 +148,24 @@ public final class StringBuffer implements Serializable, CharSequence
}
/**
+ * Create a new <code>StringBuffer</code> with the characters from the
+ * specified <code>CharSequence</code>. Initial capacity will be the
+ * size of the CharSequence plus 16.
+ *
+ * @param sequence the <code>String</code> to convert
+ * @throws NullPointerException if str is null
+ *
+ * @since 1.5
+ */
+ public StringBuffer(CharSequence sequence)
+ {
+ count = Math.max(0, sequence.length());
+ value = new char[count + DEFAULT_CAPACITY];
+ for (int i = 0; i < count; ++i)
+ value[i] = sequence.charAt(i);
+ }
+
+ /**
* Get the length of the <code>String</code> this <code>StringBuffer</code>
* would create. Not to be confused with the <em>capacity</em> of the
* <code>StringBuffer</code>.
@@ -234,7 +252,6 @@ public final class StringBuffer implements Serializable, CharSequence
* @param index the index of the character to get, starting at 0
* @return the character at the specified index
* @throws IndexOutOfBoundsException if index is negative or &gt;= length()
- * (while unspecified, this is a StringIndexOutOfBoundsException)
*/
public synchronized char charAt(int index)
{
@@ -244,6 +261,39 @@ public final class StringBuffer implements Serializable, CharSequence
}
/**
+ * Get the code point at the specified index. This is like #charAt(int),
+ * but if the character is the start of a surrogate pair, and the
+ * following character completes the pair, then the corresponding
+ * supplementary code point is returned.
+ * @param index the index of the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * @since 1.5
+ */
+ public synchronized int codePointAt(int index)
+ {
+ return Character.codePointAt(value, index, count);
+ }
+
+ /**
+ * Get the code point before the specified index. This is like
+ * #codePointAt(int), but checks the characters at <code>index-1</code> and
+ * <code>index-2</code> to see if they form a supplementary code point.
+ * @param index the index just past the codepoint to get, starting at 0
+ * @return the codepoint at the specified index
+ * @throws IndexOutOfBoundsException if index is negative or &gt;= length()
+ * @since 1.5
+ */
+ public synchronized int codePointBefore(int index)
+ {
+ // Character.codePointBefore() doesn't perform this check. We
+ // could use the CharSequence overload, but this is just as easy.
+ if (index >= count)
+ throw new IndexOutOfBoundsException();
+ return Character.codePointBefore(value, index, 1);
+ }
+
+ /**
* Get the specified array of characters. <code>srcOffset - srcEnd</code>
* characters will be copied into the array you pass in.
*
@@ -341,6 +391,46 @@ public final class StringBuffer implements Serializable, CharSequence
}
/**
+ * Append the <code>CharSequence</code> value of the argument to this
+ * <code>StringBuffer</code>.
+ *
+ * @param sequence the <code>CharSequence</code> to append
+ * @return this <code>StringBuffer</code>
+ * @see #append(Object)
+ * @since 1.5
+ */
+ public synchronized StringBuffer append(CharSequence sequence)
+ {
+ if (sequence == null)
+ sequence = "null";
+ return append(sequence, 0, sequence.length());
+ }
+
+ /**
+ * Append the specified subsequence of the <code>CharSequence</code>
+ * argument to this <code>StringBuffer</code>.
+ *
+ * @param sequence the <code>CharSequence</code> to append
+ * @param start the starting index
+ * @param end one past the ending index
+ * @return this <code>StringBuffer</code>
+ * @see #append(Object)
+ * @since 1.5
+ */
+ public synchronized StringBuffer append(CharSequence sequence,
+ int start, int end)
+ {
+ if (sequence == null)
+ sequence = "null";
+ if (start < 0 || end < 0 || start > end || end > sequence.length())
+ throw new IndexOutOfBoundsException();
+ ensureCapacity_unsynchronized(this.count + end - start);
+ for (int i = start; i < end; ++i)
+ value[count++] = sequence.charAt(i);
+ return this;
+ }
+
+ /**
* Append the <code>char</code> array to this <code>StringBuffer</code>.
* This is similar (but more efficient) than
* <code>append(new String(data))</code>, except in the case of null.
@@ -407,6 +497,25 @@ public final class StringBuffer implements Serializable, CharSequence
}
/**
+ * Append the code point to this <code>StringBuffer</code>.
+ * This is like #append(char), but will append two characters
+ * if a supplementary code point is given.
+ *
+ * @param code the code point to append
+ * @return this <code>StringBuffer</code>
+ * @see Character#toChars(int, char[], int)
+ * @since 1.5
+ */
+ public synchronized StringBuffer appendCodePoint(int code)
+ {
+ int len = Character.charCount(code);
+ ensureCapacity_unsynchronized(count + len);
+ Character.toChars(code, value, count);
+ count += len;
+ return this;
+ }
+
+ /**
* Append the <code>String</code> value of the argument to this
* <code>StringBuffer</code>. Uses <code>String.valueOf()</code> to convert
* to <code>String</code>.
@@ -660,6 +769,54 @@ public final class StringBuffer implements Serializable, CharSequence
}
/**
+ * Insert the <code>CharSequence</code> argument into this
+ * <code>StringBuffer</code>. If the sequence is null, the String
+ * "null" is used instead.
+ *
+ * @param offset the place to insert in this buffer
+ * @param sequence the <code>CharSequence</code> to insert
+ * @return this <code>StringBuffer</code>
+ * @throws IndexOutOfBoundsException if offset is out of bounds
+ * @since 1.5
+ */
+ public synchronized StringBuffer insert(int offset, CharSequence sequence)
+ {
+ if (sequence == null)
+ sequence = "null";
+ return insert(offset, sequence, 0, sequence.length());
+ }
+
+ /**
+ * Insert a subsequence of the <code>CharSequence</code> argument into this
+ * <code>StringBuffer</code>. If the sequence is null, the String
+ * "null" is used instead.
+ *
+ * @param offset the place to insert in this buffer
+ * @param sequence the <code>CharSequence</code> to insert
+ * @param start the starting index of the subsequence
+ * @param end one past the ending index of the subsequence
+ * @return this <code>StringBuffer</code>
+ * @throws IndexOutOfBoundsException if offset, start,
+ * or end are out of bounds
+ * @since 1.5
+ */
+ public synchronized StringBuffer insert(int offset, CharSequence sequence,
+ int start, int end)
+ {
+ if (sequence == null)
+ sequence = "null";
+ if (start < 0 || end < 0 || start > end || end > sequence.length())
+ throw new IndexOutOfBoundsException();
+ int len = end - start;
+ ensureCapacity_unsynchronized(count + len);
+ VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+ for (int i = start; i < end; ++i)
+ value[offset++] = sequence.charAt(i);
+ count += len;
+ return this;
+ }
+
+ /**
* Insert the <code>char[]</code> argument into this
* <code>StringBuffer</code>.
*
@@ -880,6 +1037,106 @@ public final class StringBuffer implements Serializable, CharSequence
}
/**
+ * This may reduce the amount of memory used by the StringBuffer,
+ * by resizing the internal array to remove unused space. However,
+ * this method is not required to resize, so this behavior cannot
+ * be relied upon.
+ * @since 1.5
+ */
+ public synchronized void trimToSize()
+ {
+ int wouldSave = value.length - count;
+ // Some random heuristics: if we save less than 20 characters, who
+ // cares.
+ if (wouldSave < 20)
+ return;
+ // If we save more than 200 characters, shrink.
+ // If we save more than 1/4 of the buffer, shrink.
+ if (wouldSave > 200 || wouldSave * 4 > value.length)
+ {
+ char[] newValue = new char[count];
+ VMSystem.arraycopy(value, 0, newValue, 0, count);
+ value = newValue;
+ }
+ }
+
+ /**
+ * Return the number of code points between two indices in the
+ * <code>StringBuffer</code>. An unpaired surrogate counts as a
+ * code point for this purpose. Characters outside the indicated
+ * range are not examined, even if the range ends in the middle of a
+ * surrogate pair.
+ *
+ * @param start the starting index
+ * @param end one past the ending index
+ * @return the number of code points
+ * @since 1.5
+ */
+ public synchronized int codePointCount(int start, int end)
+ {
+ if (start < 0 || end >= count || start > end)
+ throw new StringIndexOutOfBoundsException();
+
+ int count = 0;
+ while (start < end)
+ {
+ char base = value[start];
+ if (base < Character.MIN_HIGH_SURROGATE
+ || base > Character.MAX_HIGH_SURROGATE
+ || start == end
+ || start == count
+ || value[start + 1] < Character.MIN_LOW_SURROGATE
+ || value[start + 1] > Character.MAX_LOW_SURROGATE)
+ {
+ // Nothing.
+ }
+ else
+ {
+ // Surrogate pair.
+ ++start;
+ }
+ ++start;
+ ++count;
+ }
+ return count;
+ }
+
+ /**
+ * Starting at the given index, this counts forward by the indicated
+ * number of code points, and then returns the resulting index. An
+ * unpaired surrogate counts as a single code point for this
+ * purpose.
+ *
+ * @param start the starting index
+ * @param codePoints the number of code points
+ * @return the resulting index
+ * @since 1.5
+ */
+ public synchronized int offsetByCodePoints(int start, int codePoints)
+ {
+ while (codePoints > 0)
+ {
+ char base = value[start];
+ if (base < Character.MIN_HIGH_SURROGATE
+ || base > Character.MAX_HIGH_SURROGATE
+ || start == count
+ || value[start + 1] < Character.MIN_LOW_SURROGATE
+ || value[start + 1] > Character.MAX_LOW_SURROGATE)
+ {
+ // Nothing.
+ }
+ else
+ {
+ // Surrogate pair.
+ ++start;
+ }
+ ++start;
+ --codePoints;
+ }
+ return start;
+ }
+
+ /**
* An unsynchronized version of ensureCapacity, used internally to avoid
* the cost of a second lock on the same object. This also has the side
* effect of duplicating the array, if it was shared (to form copy-on-write
diff --git a/libjava/classpath/java/lang/StringBuilder.java b/libjava/classpath/java/lang/StringBuilder.java
index b54c8ef7eb4..470f1ba9ad5 100644
--- a/libjava/classpath/java/lang/StringBuilder.java
+++ b/libjava/classpath/java/lang/StringBuilder.java
@@ -464,6 +464,25 @@ public final class StringBuilder
}
/**
+ * Append the code point to this <code>StringBuilder</code>.
+ * This is like #append(char), but will append two characters
+ * if a supplementary code point is given.
+ *
+ * @param code the code point to append
+ * @return this <code>StringBuilder</code>
+ * @see Character#toChars(int, char[], int)
+ * @since 1.5
+ */
+ public synchronized StringBuilder appendCodePoint(int code)
+ {
+ int len = Character.charCount(code);
+ ensureCapacity(count + len);
+ Character.toChars(code, value, count);
+ count += len;
+ return this;
+ }
+
+ /**
* Append the <code>String</code> value of the argument to this
* <code>StringBuilder</code>. Uses <code>String.valueOf()</code> to convert
* to <code>String</code>.
@@ -705,6 +724,52 @@ public final class StringBuilder
}
/**
+ * Insert the <code>CharSequence</code> argument into this
+ * <code>StringBuilder</code>. If the sequence is null, the String
+ * "null" is used instead.
+ *
+ * @param offset the place to insert in this buffer
+ * @param sequence the <code>CharSequence</code> to insert
+ * @return this <code>StringBuilder</code>
+ * @throws IndexOutOfBoundsException if offset is out of bounds
+ */
+ public synchronized StringBuilder insert(int offset, CharSequence sequence)
+ {
+ if (sequence == null)
+ sequence = "null";
+ return insert(offset, sequence, 0, sequence.length());
+ }
+
+ /**
+ * Insert a subsequence of the <code>CharSequence</code> argument into this
+ * <code>StringBuilder</code>. If the sequence is null, the String
+ * "null" is used instead.
+ *
+ * @param offset the place to insert in this buffer
+ * @param sequence the <code>CharSequence</code> to insert
+ * @param start the starting index of the subsequence
+ * @param end one past the ending index of the subsequence
+ * @return this <code>StringBuilder</code>
+ * @throws IndexOutOfBoundsException if offset, start,
+ * or end are out of bounds
+ */
+ public synchronized StringBuilder insert(int offset, CharSequence sequence,
+ int start, int end)
+ {
+ if (sequence == null)
+ sequence = "null";
+ if (start < 0 || end < 0 || start > end || end > sequence.length())
+ throw new IndexOutOfBoundsException();
+ int len = end - start;
+ ensureCapacity(count + len);
+ VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+ for (int i = start; i < end; ++i)
+ value[offset++] = sequence.charAt(i);
+ count += len;
+ return this;
+ }
+
+ /**
* Insert the <code>char[]</code> argument into this
* <code>StringBuilder</code>.
*
diff --git a/libjava/classpath/java/lang/System.java b/libjava/classpath/java/lang/System.java
index e466d3b8cfb..ea84dba47e2 100644
--- a/libjava/classpath/java/lang/System.java
+++ b/libjava/classpath/java/lang/System.java
@@ -464,7 +464,7 @@ public final class System
*
* @param finalizeOnExit whether to run finalizers on exit
* @throws SecurityException if permission is denied
- * @see Runtime#runFinalizersOnExit()
+ * @see Runtime#runFinalizersOnExit(boolean)
* @since 1.1
* @deprecated never rely on finalizers to do a clean, thread-safe,
* mop-up from your code
diff --git a/libjava/classpath/java/lang/Thread.java b/libjava/classpath/java/lang/Thread.java
index 37ca630b4ed..763228c16ef 100644
--- a/libjava/classpath/java/lang/Thread.java
+++ b/libjava/classpath/java/lang/Thread.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.lang;
+import java.security.Permission;
import java.util.Map;
import java.util.WeakHashMap;
@@ -704,7 +705,7 @@ public class Thread implements Runnable
*
* @return the context class loader
* @throws SecurityException when permission is denied
- * @see setContextClassLoader(ClassLoader)
+ * @see #setContextClassLoader(ClassLoader)
* @since 1.2
*/
public synchronized ClassLoader getContextClassLoader()
@@ -726,7 +727,7 @@ public class Thread implements Runnable
*
* @param classloader the new context class loader
* @throws SecurityException when permission is denied
- * @see getContextClassLoader()
+ * @see #getContextClassLoader()
* @since 1.2
*/
public synchronized void setContextClassLoader(ClassLoader classloader)
@@ -812,8 +813,11 @@ public class Thread implements Runnable
{
// Check parameters
- if (ms < 0 || ns < 0 || ns > 999999)
- throw new IllegalArgumentException();
+ if (ms < 0 )
+ throw new IllegalArgumentException("Negative milliseconds: " + ms);
+
+ if (ns < 0 || ns > 999999)
+ throw new IllegalArgumentException("Nanoseconds ouf of range: " + ns);
// Really sleep
VMThread.sleep(ms, ns);
diff --git a/libjava/classpath/java/lang/ThreadLocal.java b/libjava/classpath/java/lang/ThreadLocal.java
index 0b2b60867b9..bc839044574 100644
--- a/libjava/classpath/java/lang/ThreadLocal.java
+++ b/libjava/classpath/java/lang/ThreadLocal.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.lang;
import java.util.Map;
-import java.util.WeakHashMap;
/**
diff --git a/libjava/classpath/java/lang/ref/Reference.java b/libjava/classpath/java/lang/ref/Reference.java
index 1ec72438198..4b6a3adbcc1 100644
--- a/libjava/classpath/java/lang/ref/Reference.java
+++ b/libjava/classpath/java/lang/ref/Reference.java
@@ -68,7 +68,7 @@ package java.lang.ref;
* work. It is useful to keep track, when an object is finalized.
*
* @author Jochen Hoenicke
- * @see java.util.WeakHashtable
+ * @see java.util.WeakHashMap
*/
public abstract class Reference
{
@@ -104,7 +104,7 @@ public abstract class Reference
* Creates a new reference that is not registered to any queue.
* Since it is package private, it is not possible to overload this
* class in a different package.
- * @param referent the object we refer to.
+ * @param ref the object we refer to.
*/
Reference(Object ref)
{
@@ -115,7 +115,7 @@ public abstract class Reference
* Creates a reference that is registered to a queue. Since this is
* package private, it is not possible to overload this class in a
* different package.
- * @param referent the object we refer to.
+ * @param ref the object we refer to.
* @param q the reference queue to register on.
* @exception NullPointerException if q is null.
*/
diff --git a/libjava/classpath/java/lang/ref/WeakReference.java b/libjava/classpath/java/lang/ref/WeakReference.java
index 9f758ca1eab..b4018fbb55e 100644
--- a/libjava/classpath/java/lang/ref/WeakReference.java
+++ b/libjava/classpath/java/lang/ref/WeakReference.java
@@ -52,7 +52,7 @@ package java.lang.ref;
* automatically cleared, and you may remove it from the set. <br>
*
* @author Jochen Hoenicke
- * @see java.util.WeakHashtable
+ * @see java.util.WeakHashMap
*/
public class WeakReference
extends Reference
diff --git a/libjava/classpath/java/lang/reflect/Member.java b/libjava/classpath/java/lang/reflect/Member.java
index 9983b275a94..c39731f8487 100644
--- a/libjava/classpath/java/lang/reflect/Member.java
+++ b/libjava/classpath/java/lang/reflect/Member.java
@@ -60,7 +60,7 @@ public interface Member
* package-protected, but only which are declared in this class.
* Used in SecurityManager.checkMemberAccess() to determine the
* type of members to access.
- * @see SecurityManager#checkMemberAccess()
+ * @see SecurityManager#checkMemberAccess(Class, int)
*/
int DECLARED = 1;
@@ -68,7 +68,7 @@ public interface Member
* Represents public members only, but includes all inherited members.
* Used in SecurityManager.checkMemberAccess() to determine the type of
* members to access.
- * @see SecurityManager#checkMemberAccess()
+ * @see SecurityManager#checkMemberAccess(Class, int)
*/
int PUBLIC = 0;
diff --git a/libjava/classpath/java/lang/reflect/Proxy.java b/libjava/classpath/java/lang/reflect/Proxy.java
index 7a5fd30de16..137cb5a48a6 100644
--- a/libjava/classpath/java/lang/reflect/Proxy.java
+++ b/libjava/classpath/java/lang/reflect/Proxy.java
@@ -100,7 +100,7 @@ import java.util.Set;
* belongs to the classloader you designated.</li>
* <li>Reflection works as expected: {@link Class#getInterfaces()} and
* {@link Class#getMethods()} work as they do on normal classes.</li>
- * <li>The method {@link #isProxyClass()} will distinguish between
+ * <li>The method {@link #isProxyClass(Class)} will distinguish between
* true proxy classes and user extensions of this class. It only
* returns true for classes created by {@link #getProxyClass}.</li>
* <li>The {@link ProtectionDomain} of a proxy class is the same as for
@@ -111,8 +111,8 @@ import java.util.Set;
* the only way to create an instance of the proxy class.</li>
* <li>The proxy class contains a single constructor, which takes as
* its only argument an {@link InvocationHandler}. The method
- * {@link #newInstance} is shorthand to do the necessary
- * reflection.</li>
+ * {@link #newProxyInstance(ClassLoader, Class[], InvocationHandler)}
+ * is shorthand to do the necessary reflection.</li>
* </ul>
*
* <h3>Proxy Instances</h3>
@@ -126,7 +126,7 @@ import java.util.Set;
* a {@link ClassCastException}.</li>
* <li>Each proxy instance has an invocation handler, which can be
* accessed by {@link #getInvocationHandler(Object)}. Any call
- * to an interface method, including {@link Object#hashcode()},
+ * to an interface method, including {@link Object#hashCode()},
* {@link Object#equals(Object)}, or {@link Object#toString()},
* but excluding the public final methods of Object, will be
* encoded and passed to the {@link InvocationHandler#invoke}
@@ -413,8 +413,6 @@ public class Proxy implements Serializable
*/
ProxyType(ClassLoader loader, Class[] interfaces)
{
- if (loader == null)
- loader = ClassLoader.getSystemClassLoader();
this.loader = loader;
this.interfaces = interfaces;
}
@@ -426,8 +424,7 @@ public class Proxy implements Serializable
*/
public int hashCode()
{
- //loader is always not null
- int hash = loader.hashCode();
+ int hash = loader == null ? 0 : loader.hashCode();
for (int i = 0; i < interfaces.length; i++)
hash = hash * 31 + interfaces[i].hashCode();
return hash;
@@ -436,7 +433,7 @@ public class Proxy implements Serializable
/**
* Calculates equality.
*
- * @param the object to compare to
+ * @param other object to compare to
* @return true if it is a ProxyType with same data
*/
public boolean equals(Object other)
@@ -586,7 +583,7 @@ public class Proxy implements Serializable
/**
* Calculates equality.
*
- * @param the object to compare to
+ * @param other object to compare to
* @return true if it is a ProxySignature with same data
*/
public boolean equals(Object other)
@@ -617,7 +614,7 @@ public class Proxy implements Serializable
* The package this class is in <b>including the trailing dot</b>
* or an empty string for the unnamed (aka default) package.
*/
- String pack;
+ String pack = "";
/**
* The interfaces this class implements. Non-null, but possibly empty.
diff --git a/libjava/classpath/java/lang/reflect/UndeclaredThrowableException.java b/libjava/classpath/java/lang/reflect/UndeclaredThrowableException.java
index 6d5a8008459..ea574ad7c61 100644
--- a/libjava/classpath/java/lang/reflect/UndeclaredThrowableException.java
+++ b/libjava/classpath/java/lang/reflect/UndeclaredThrowableException.java
@@ -65,7 +65,7 @@ public class UndeclaredThrowableException extends RuntimeException
/**
* The immutable exception that this wraps. This field is redundant
- * with {@link Throwable#cause}, but is necessary for serial compatibility.
+ * with {@link Throwable#getCause()}, but is necessary for serial compatibility.
*
* @serial the chained exception
*/
diff --git a/libjava/classpath/java/math/BigDecimal.java b/libjava/classpath/java/math/BigDecimal.java
index d99be0f56ba..693c399874e 100644
--- a/libjava/classpath/java/math/BigDecimal.java
+++ b/libjava/classpath/java/math/BigDecimal.java
@@ -43,12 +43,27 @@ public class BigDecimal extends Number implements Comparable
private int scale;
private static final long serialVersionUID = 6108874887143696463L;
- private static final BigDecimal ZERO =
+ /**
+ * The constant zero as a BigDecimal with scale zero.
+ * @since 1.5
+ */
+ public static final BigDecimal ZERO =
new BigDecimal (BigInteger.valueOf (0), 0);
- private static final BigDecimal ONE =
+ /**
+ * The constant one as a BigDecimal with scale zero.
+ * @since 1.5
+ */
+ public static final BigDecimal ONE =
new BigDecimal (BigInteger.valueOf (1), 0);
+ /**
+ * The constant ten as a BigDecimal with scale zero.
+ * @since 1.5
+ */
+ public static final BigDecimal TEN =
+ new BigDecimal (BigInteger.valueOf (10), 0);
+
public static final int ROUND_UP = 0;
public static final int ROUND_DOWN = 1;
public static final int ROUND_CEILING = 2;
diff --git a/libjava/classpath/java/math/BigInteger.java b/libjava/classpath/java/math/BigInteger.java
index 82f550d144c..5a336b87248 100644
--- a/libjava/classpath/java/math/BigInteger.java
+++ b/libjava/classpath/java/math/BigInteger.java
@@ -76,7 +76,8 @@ public class BigInteger extends Number implements Comparable
private static final long serialVersionUID = -8287574255936472291L;
- /** We pre-allocate integers in the range minFixNum..maxFixNum. */
+ /** We pre-allocate integers in the range minFixNum..maxFixNum.
+ * Note that we must at least preallocate 0, 1, and 10. */
private static final int minFixNum = -100;
private static final int maxFixNum = 1024;
private static final int numFixNum = maxFixNum-minFixNum+1;
@@ -87,11 +88,23 @@ public class BigInteger extends Number implements Comparable
smallFixNums[i] = new BigInteger(i + minFixNum);
}
- // JDK1.2
+ /**
+ * The constant zero as a BigInteger.
+ * @since 1.2
+ */
public static final BigInteger ZERO = smallFixNums[-minFixNum];
- // JDK1.2
+ /**
+ * The constant one as a BigInteger.
+ * @since 1.2
+ */
public static final BigInteger ONE = smallFixNums[1 - minFixNum];
+
+ /**
+ * The constant ten as a BigInteger.
+ * @since 1.5
+ */
+ public static final BigInteger TEN = smallFixNums[10 - minFixNum];
/* Rounding modes: */
private static final int FLOOR = 1;
diff --git a/libjava/classpath/java/net/DatagramSocket.java b/libjava/classpath/java/net/DatagramSocket.java
index 875ddc778e9..40bafbb34dd 100644
--- a/libjava/classpath/java/net/DatagramSocket.java
+++ b/libjava/classpath/java/net/DatagramSocket.java
@@ -484,7 +484,6 @@ public class DatagramSocket
* @param address The address to connect this socket to.
* @param port The port to connect this socket to.
*
- * @exception SocketException If an error occurs.
* @exception IllegalArgumentException If address or port are invalid.
* @exception SecurityException If the caller is not allowed to send
* datagrams to or receive from this address and port.
diff --git a/libjava/classpath/java/net/Inet4Address.java b/libjava/classpath/java/net/Inet4Address.java
index 74ce6efb828..c80f1f175a2 100644
--- a/libjava/classpath/java/net/Inet4Address.java
+++ b/libjava/classpath/java/net/Inet4Address.java
@@ -70,7 +70,7 @@ public final class Inet4Address extends InetAddress
* only by static methods in this class.
*
* @param addr The IP number of this address as an array of bytes
- * @param hostname The hostname of this IP address.
+ * @param host The hostname of this IP address.
*/
Inet4Address(byte[] addr, String host)
{
diff --git a/libjava/classpath/java/net/InetSocketAddress.java b/libjava/classpath/java/net/InetSocketAddress.java
index 30d34e7e808..edeaf27753c 100644
--- a/libjava/classpath/java/net/InetSocketAddress.java
+++ b/libjava/classpath/java/net/InetSocketAddress.java
@@ -216,6 +216,6 @@ public class InetSocketAddress extends SocketAddress
*/
public String toString()
{
- return (addr == null ? hostname : addr.getHostName()) + ":" + port;
+ return (addr == null ? hostname : addr.toString()) + ":" + port;
}
}
diff --git a/libjava/classpath/java/net/ServerSocket.java b/libjava/classpath/java/net/ServerSocket.java
index f73c7482aa5..afc861403a1 100644
--- a/libjava/classpath/java/net/ServerSocket.java
+++ b/libjava/classpath/java/net/ServerSocket.java
@@ -316,7 +316,8 @@ public class ServerSocket
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
- sm.checkListen(impl.getLocalPort());
+ sm.checkAccept(impl.getInetAddress().getHostAddress(),
+ impl.getLocalPort());
Socket socket = new Socket();
@@ -369,6 +370,7 @@ public class ServerSocket
impl.accept(socket.impl);
socket.implCreated = true;
+ socket.bound = true;
}
/**
diff --git a/libjava/classpath/java/net/Socket.java b/libjava/classpath/java/net/Socket.java
index 9432a6be1d8..0ff6e6ea032 100644
--- a/libjava/classpath/java/net/Socket.java
+++ b/libjava/classpath/java/net/Socket.java
@@ -91,8 +91,9 @@ public class Socket
/**
* True if the socket is bound.
+ * Package private so it can be set from ServerSocket when accept is called.
*/
- private boolean bound;
+ boolean bound;
/**
* True if input is shutdown.
@@ -324,7 +325,9 @@ public class Socket
}
catch (IOException e)
{
- throw new SocketException(e.getMessage());
+ SocketException se = new SocketException(e.toString());
+ se.initCause(e);
+ throw se;
}
return impl;
@@ -481,7 +484,7 @@ public class Socket
/**
* Returns the local address to which this socket is bound. If this socket
* is not connected, then a wildcard address, for which
- * @see isAnyLocalAddress() is <code>true</code>, is returned.
+ * @see InetAddress#isAnyLocalAddress() is <code>true</code>, is returned.
*
* @return The local address
*
diff --git a/libjava/classpath/java/net/URLClassLoader.java b/libjava/classpath/java/net/URLClassLoader.java
index 85b38578169..726778eba0f 100644
--- a/libjava/classpath/java/net/URLClassLoader.java
+++ b/libjava/classpath/java/net/URLClassLoader.java
@@ -235,12 +235,10 @@ public class URLClassLoader extends SecureClassLoader
abstract static class Resource
{
final URLLoader loader;
- final String name;
- Resource(URLLoader loader, String name)
+ Resource(URLLoader loader)
{
this.loader = loader;
- this.name = name;
}
/**
@@ -391,11 +389,13 @@ public class URLClassLoader extends SecureClassLoader
static final class JarURLResource extends Resource
{
private final JarEntry entry;
+ private final String name;
JarURLResource(JarURLLoader loader, String name, JarEntry entry)
{
- super(loader, name);
+ super(loader);
this.entry = entry;
+ this.name = name;
}
InputStream getInputStream() throws IOException
@@ -496,7 +496,7 @@ public class URLClassLoader extends SecureClassLoader
RemoteResource(RemoteURLLoader loader, String name, URL url,
InputStream stream, int length)
{
- super(loader, name);
+ super(loader);
this.url = url;
this.stream = stream;
this.length = length;
@@ -535,9 +535,16 @@ public class URLClassLoader extends SecureClassLoader
/** get resource with the name "name" in the file url */
Resource getResource(String name)
{
- File file = new File(dir, name);
- if (file.exists() && !file.isDirectory())
- return new FileResource(this, name, file);
+ try
+ {
+ File file = new File(dir, name).getCanonicalFile();
+ if (file.exists() && !file.isDirectory())
+ return new FileResource(this, file);
+ }
+ catch (IOException e)
+ {
+ // Fall through...
+ }
return null;
}
}
@@ -546,9 +553,9 @@ public class URLClassLoader extends SecureClassLoader
{
final File file;
- FileResource(FileURLLoader loader, String name, File file)
+ FileResource(FileURLLoader loader, File file)
{
- super(loader, name);
+ super(loader);
this.file = file;
}
@@ -566,8 +573,7 @@ public class URLClassLoader extends SecureClassLoader
{
try
{
- return new URL(loader.baseURL, name,
- loader.classloader.getURLStreamHandler("file"));
+ return file.toURL();
}
catch (MalformedURLException e)
{
@@ -701,7 +707,7 @@ public class URLClassLoader extends SecureClassLoader
private void addURLImpl(URL newUrl)
{
- synchronized (urlloaders)
+ synchronized (this)
{
if (newUrl == null)
return; // Silently ignore...
@@ -748,19 +754,42 @@ public class URLClassLoader extends SecureClassLoader
}
/**
- * Adds an array of new locations to the end of the internal URL store.
+ * Adds an array of new locations to the end of the internal URL
+ * store. Called from the the constructors. Should not call to the
+ * protected addURL() method since that can be overridden and
+ * subclasses are not yet in a good state at this point.
+ * jboss 4.0.3 for example depends on this.
+ *
* @param newUrls the locations to add
*/
private void addURLs(URL[] newUrls)
{
for (int i = 0; i < newUrls.length; i++)
- addURL(newUrls[i]);
+ {
+ urls.add(newUrls[i]);
+ addURLImpl(newUrls[i]);
+ }
+ }
+
+ /**
+ * Look in both Attributes for a given value. The first Attributes
+ * object, if not null, has precedence.
+ */
+ private String getAttributeValue(Attributes.Name name, Attributes first,
+ Attributes second)
+ {
+ String result = null;
+ if (first != null)
+ result = first.getValue(name);
+ if (result == null)
+ result = second.getValue(name);
+ return result;
}
/**
* Defines a Package based on the given name and the supplied manifest
- * information. The manifest indicates the tile, version and
- * vendor information of the specification and implementation and wheter the
+ * information. The manifest indicates the title, version and
+ * vendor information of the specification and implementation and whether the
* package is sealed. If the Manifest indicates that the package is sealed
* then the Package will be sealed with respect to the supplied URL.
*
@@ -768,20 +797,43 @@ public class URLClassLoader extends SecureClassLoader
* @param manifest The manifest describing the specification,
* implementation and sealing details of the package
* @param url the code source url to seal the package
- * @exception IllegalArgumentException If this package name already exists
- * in this class loader
* @return the defined Package
+ * @throws IllegalArgumentException If this package name already exists
+ * in this class loader
*/
protected Package definePackage(String name, Manifest manifest, URL url)
throws IllegalArgumentException
{
+ // Compute the name of the package as it may appear in the
+ // Manifest.
+ StringBuffer xform = new StringBuffer(name);
+ for (int i = xform.length () - 1; i >= 0; --i)
+ if (xform.charAt(i) == '.')
+ xform.setCharAt(i, '/');
+ xform.append('/');
+ String xformName = xform.toString();
+
+ Attributes entryAttr = manifest.getAttributes(xformName);
Attributes attr = manifest.getMainAttributes();
- String specTitle = attr.getValue(Attributes.Name.SPECIFICATION_TITLE);
- String specVersion = attr.getValue(Attributes.Name.SPECIFICATION_VERSION);
- String specVendor = attr.getValue(Attributes.Name.SPECIFICATION_VENDOR);
- String implTitle = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
- String implVersion = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
- String implVendor = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR);
+
+ String specTitle
+ = getAttributeValue(Attributes.Name.SPECIFICATION_TITLE,
+ entryAttr, attr);
+ String specVersion
+ = getAttributeValue(Attributes.Name.SPECIFICATION_VERSION,
+ entryAttr, attr);
+ String specVendor
+ = getAttributeValue(Attributes.Name.SPECIFICATION_VENDOR,
+ entryAttr, attr);
+ String implTitle
+ = getAttributeValue(Attributes.Name.IMPLEMENTATION_TITLE,
+ entryAttr, attr);
+ String implVersion
+ = getAttributeValue(Attributes.Name.IMPLEMENTATION_VERSION,
+ entryAttr, attr);
+ String implVendor
+ = getAttributeValue(Attributes.Name.IMPLEMENTATION_VENDOR,
+ entryAttr, attr);
// Look if the Manifest indicates that this package is sealed
// XXX - most likely not completely correct!
@@ -793,8 +845,10 @@ public class URLClassLoader extends SecureClassLoader
// make sure that the URL is null so the package is not sealed
url = null;
- return definePackage(name, specTitle, specVersion, specVendor, implTitle,
- implVersion, implVendor, url);
+ return definePackage(name,
+ specTitle, specVendor, specVersion,
+ implTitle, implVendor, implVersion,
+ url);
}
/**
@@ -926,7 +980,7 @@ public class URLClassLoader extends SecureClassLoader
*/
public String toString()
{
- synchronized (urlloaders)
+ synchronized (this)
{
if (thisString == null)
{
diff --git a/libjava/classpath/java/net/URLConnection.java b/libjava/classpath/java/net/URLConnection.java
index 0a12d588d9a..836f174dae6 100644
--- a/libjava/classpath/java/net/URLConnection.java
+++ b/libjava/classpath/java/net/URLConnection.java
@@ -530,7 +530,7 @@ public abstract class URLConnection
}
/**
- * Returns the value of a flag indicating whether or not input is going
+ * Sets the value of a flag indicating whether or not input is going
* to be done for this connection. This default to true unless the
* doOutput flag is set to false, in which case this defaults to false.
*
@@ -560,7 +560,7 @@ public abstract class URLConnection
}
/**
- * Returns a boolean flag indicating whether or not output will be done
+ * Sets a boolean flag indicating whether or not output will be done
* on this connection. The default value is false, so this method can
* be used to override the default
*
@@ -851,7 +851,7 @@ public abstract class URLConnection
}
/**
- * Set's the ContentHandlerFactory for an application. This can be called
+ * Sets the ContentHandlerFactory for an application. This can be called
* once and only once. If it is called again, then an Error is thrown.
* Unlike for other set factory methods, this one does not do a security
* check prior to setting the factory.
@@ -933,7 +933,7 @@ public abstract class URLConnection
}
/**
- * This method set the <code>FileNameMap</code> object being used
+ * This method sets the <code>FileNameMap</code> object being used
* to decode MIME types by file extension.
*
* @param map The <code>FileNameMap</code>.
diff --git a/libjava/classpath/java/net/URLStreamHandler.java b/libjava/classpath/java/net/URLStreamHandler.java
index 57ce2dfa290..ed95092219e 100644
--- a/libjava/classpath/java/net/URLStreamHandler.java
+++ b/libjava/classpath/java/net/URLStreamHandler.java
@@ -411,8 +411,6 @@ public abstract class URLStreamHandler
* @param url2 The second URL.
*
* @return True if both URLs contain the same host.
- *
- * @exception UnknownHostException If an unknown host is found
*/
protected boolean hostsEqual(URL url1, URL url2)
{
@@ -511,18 +509,24 @@ public abstract class URLStreamHandler
int size = protocol.length() + authority.length() + file.length() + 24;
StringBuffer sb = new StringBuffer(size);
- if (protocol != null && protocol.length() > 0)
+ if (protocol.length() > 0)
{
sb.append(protocol);
sb.append(":");
}
- if (authority.length() != 0)
- {
- sb.append("//").append(authority);
- }
-
- sb.append(file);
+ // If we have superfluous leading slashes (that means, at least 2)
+ // we always add the authority component ("//" + host) to
+ // avoid ambiguity. Otherwise we would generate an URL like
+ // proto://home/foo
+ // where we meant:
+ // host: <empty> - file: //home/foo
+ // but URL spec says it is:
+ // host: home - file: /foo
+ if (authority.length() != 0 || file.startsWith("//") )
+ sb.append("//").append(authority).append(file);
+ else
+ sb.append(file);
if (ref != null)
sb.append('#').append(ref);
diff --git a/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java b/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java
index 42ceab7e2c1..847c02cce06 100644
--- a/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java
+++ b/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java
@@ -43,6 +43,7 @@ import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
+import java.nio.channels.IllegalBlockingModeException;
import java.util.LinkedList;
import java.util.ListIterator;
@@ -209,6 +210,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel
* @return the registered selection key
*
* @exception ClosedChannelException If the channel is already closed.
+ * @exception IllegalBlockingModeException If the channel is configured in
+ * blocking mode.
*/
public final SelectionKey register(Selector selin, int ops, Object att)
throws ClosedChannelException
@@ -224,6 +227,9 @@ public abstract class AbstractSelectableChannel extends SelectableChannel
synchronized (blockingLock())
{
+ if (blocking)
+ throw new IllegalBlockingModeException();
+
key = locate(selector);
if (key != null && key.isValid())
diff --git a/libjava/classpath/java/nio/charset/Charset.java b/libjava/classpath/java/nio/charset/Charset.java
index 0476b0daa2c..91801ddac87 100644
--- a/libjava/classpath/java/nio/charset/Charset.java
+++ b/libjava/classpath/java/nio/charset/Charset.java
@@ -38,19 +38,15 @@ exception statement from your version. */
package java.nio.charset;
+import gnu.classpath.ServiceFactory;
import gnu.classpath.SystemProperties;
-
import gnu.java.nio.charset.Provider;
import gnu.java.nio.charset.iconv.IconvProvider;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.spi.CharsetProvider;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -174,7 +170,7 @@ public abstract class Charset implements Comparable
* Returns the Charset instance for the charset of the given name.
*
* @param charsetName
- * @return
+ * @return the Charset instance for the indicated charset
* @throws UnsupportedCharsetException if this VM does not support
* the charset of the given name.
* @throws IllegalCharsetNameException if the given charset name is
@@ -265,23 +261,10 @@ public abstract class Charset implements Comparable
{
try
{
- Enumeration en = ClassLoader.getSystemResources
- ("META-INF/services/java.nio.charset.spi.CharsetProvider");
+ Iterator i = ServiceFactory.lookupProviders(CharsetProvider.class);
LinkedHashSet set = new LinkedHashSet();
- while (en.hasMoreElements())
- {
- BufferedReader rdr = new BufferedReader(new InputStreamReader
- (((URL) (en.nextElement())).openStream()));
- while (true)
- {
- String s = rdr.readLine();
- if (s == null)
- break;
- CharsetProvider p =
- (CharsetProvider) ((Class.forName(s)).newInstance());
- set.add(p);
- }
- }
+ while (i.hasNext())
+ set.add(i.next());
providers = new CharsetProvider[set.size()];
set.toArray(providers);
diff --git a/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java b/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java
new file mode 100644
index 00000000000..249137b0863
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java
@@ -0,0 +1,110 @@
+/* ActivationGroup_Stub.java -- Stub class for ActivationGroup impls.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.lang.reflect.Method;
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+
+/**
+ * A stub class for {@link ActivationGroup} implementations.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class ActivationGroup_Stub extends RemoteStub
+ implements ActivationInstantiator, Remote
+{
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Creates a new instance of ActivationGroup_Stub.
+ *
+ * @param ref the remote reference
+ */
+ public ActivationGroup_Stub(RemoteRef ref)
+ {
+ super(ref);
+ }
+
+ /**
+ * Stub method for <code>ActivationGroup.newInstance()</code>.
+ *
+ * @param id the activation ID
+ * @param desc the activation description
+ *
+ * @return the return value of the invocation
+ *
+ * @throws RemoteException if the invocation throws a RemoteException
+ * @throws ActivationException if the invocation throws an
+ * ActivationException
+ */
+ public MarshalledObject newInstance(ActivationID id, ActivationDesc desc)
+ throws RemoteException, ActivationException
+ {
+ try
+ {
+ Method method = ActivationGroup_Stub.class.getDeclaredMethod
+ ("newInstance", new Class[]{ ActivationID.class,
+ ActivationDesc.class });
+ return (MarshalledObject) ref.invoke(this, method,
+ new Object[]{id, desc},
+ -5274445189091581345L);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (RemoteException ex)
+ {
+ throw ex;
+ }
+ catch (ActivationException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new UnexpectedException("Unexpected exception", ex);
+ }
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/LoaderHandler.java b/libjava/classpath/java/rmi/server/LoaderHandler.java
index 189085710b4..0489cd16634 100644
--- a/libjava/classpath/java/rmi/server/LoaderHandler.java
+++ b/libjava/classpath/java/rmi/server/LoaderHandler.java
@@ -45,7 +45,11 @@ import java.net.URL;
*/
public interface LoaderHandler
{
- String packagePrefix = "";
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
/**
* @deprecated
diff --git a/libjava/classpath/java/rmi/server/RMIClassLoader.java b/libjava/classpath/java/rmi/server/RMIClassLoader.java
index a7a7cb84a58..f8997fd7e09 100644
--- a/libjava/classpath/java/rmi/server/RMIClassLoader.java
+++ b/libjava/classpath/java/rmi/server/RMIClassLoader.java
@@ -38,14 +38,10 @@ exception statement from your version. */
package java.rmi.server;
+import gnu.java.rmi.server.RMIClassLoaderImpl;
+
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.StringTokenizer;
-
/**
* This class provides a set of public static utility methods for supporting
@@ -60,221 +56,77 @@ public class RMIClassLoader
*/
private RMIClassLoader() {}
- private static class MyClassLoader extends URLClassLoader
- {
- // Package-private to avoid a trampoline constructor.
- MyClassLoader (URL[] urls, ClassLoader parent, String annotation)
- {
- super (urls, parent);
- this.annotation = annotation;
- }
-
- private MyClassLoader (URL[] urls, ClassLoader parent)
- {
- super (urls, parent);
- this.annotation = urlToAnnotation (urls);
- }
-
- public static String urlToAnnotation (URL[] urls)
- {
- if (urls.length == 0)
- return null;
-
- StringBuffer annotation = new StringBuffer (64 * urls.length);
-
- for (int i = 0; i < urls.length; i++)
- {
- annotation.append (urls [i].toExternalForm());
- annotation.append (' ');
- }
-
- return annotation.toString();
- }
-
- public final String getClassAnnotation()
- {
- return annotation;
- }
-
- private final String annotation;
- }
-
- /**
- * This class is used to identify a cached classloader by its codebase and
- * the context classloader that is its parent.
- */
- private static class CacheKey
- {
- private String mCodeBase;
- private ClassLoader mContextClassLoader;
-
- public CacheKey (String theCodebase, ClassLoader theContextClassLoader)
- {
- mCodeBase = theCodebase;
- mContextClassLoader = theContextClassLoader;
- }
-
- /**
- * @return true if the codebase and the context classloader are equal
- */
- public boolean equals (Object theOther)
- {
- if (theOther instanceof CacheKey)
- {
- CacheKey key = (CacheKey) theOther;
-
- return (equals (this.mCodeBase,key.mCodeBase)
- && equals (this.mContextClassLoader, key.mContextClassLoader));
- }
- return false;
- }
-
- /**
- * Test if the two objects are equal or both null.
- * @param theOne
- * @param theOther
- * @return
- */
- private boolean equals (Object theOne, Object theOther)
- {
- return theOne != null ? theOne.equals (theOther) : theOther == null;
- }
-
- /**
- * @return hashCode
- */
- public int hashCode()
- {
- return ((mCodeBase != null ? mCodeBase.hashCode() : 0)
- ^(mContextClassLoader != null ? mContextClassLoader.hashCode() : -1));
- }
-
- public String toString()
- {
- return "[" + mCodeBase + "," + mContextClassLoader + "]";
- }
-
- }
-
- private static Map cacheLoaders; //map annotations to loaders
- private static Map cacheAnnotations; //map loaders to annotations
-
- //defaultAnnotation is got from system property
- // "java.rmi.server.defaultAnnotation"
- private static String defaultAnnotation;
-
- //URL object for defaultAnnotation
- private static URL defaultCodebase;
-
- //class loader for defaultAnnotation
- private static MyClassLoader defaultLoader;
-
- static
- {
- // 89 is a nice prime number for Hashtable initial capacity
- cacheLoaders = new Hashtable (89);
- cacheAnnotations = new Hashtable (89);
-
- defaultAnnotation = System.getProperty ("java.rmi.server.defaultAnnotation");
-
- try
- {
- if (defaultAnnotation != null)
- defaultCodebase = new URL (defaultAnnotation);
- }
- catch (Exception _)
- {
- defaultCodebase = null;
- }
-
- if (defaultCodebase != null)
- {
- defaultLoader = new MyClassLoader (new URL[] { defaultCodebase }, null,
- defaultAnnotation);
- cacheLoaders.put (new CacheKey (defaultAnnotation,
- Thread.currentThread().getContextClassLoader()),
- defaultLoader);
- }
- }
-
/**
* @deprecated
*/
- public static Class loadClass (String name)
+ public static Class loadClass(String name)
throws MalformedURLException, ClassNotFoundException
{
- return loadClass ("", name);
+ return loadClass("", name);
}
- public static Class loadClass (String codebases, String name)
+ public static Class loadClass(String codebase, String name)
throws MalformedURLException, ClassNotFoundException
{
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- //try context class loader first
- try
- {
- return Class.forName(name, false, loader);
- }
- catch (ClassNotFoundException e)
- {
- // class not found in the local classpath
- }
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, null);
+ }
- if (codebases.length() == 0) //==""
- {
- loader = defaultLoader;
- }
- else
- {
- loader = getClassLoader(codebases);
- }
+ public static Class loadClass(String codebase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, defaultLoader);
+ }
- if (loader == null)
- {
- //do not throw NullPointerException
- throw new ClassNotFoundException ("Could not find class (" + name +
- ") at codebase (" + codebases + ")");
- }
-
- return Class.forName(name, false, loader);
+ /**
+ * Loads a class from <code>codeBase</code>.
+ *
+ * This method delegates to
+ * {@link RMIClassLoaderSpi#loadClass(String, String, ClassLoader)} and
+ * passes <code>codeBase.toString()</code> as first argument,
+ * <code>name</code> as second argument and <code>null</code> as third
+ * argument.
+ *
+ * @param codeBase the code base from which to load the class
+ * @param name the name of the class
+ *
+ * @return the loaded class
+ *
+ * @throws MalformedURLException if the URL is not well formed
+ * @throws ClassNotFoundException if the requested class cannot be found
+ */
+ public static Class loadClass(URL codeBase, String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codeBase.toString(), name, null);
}
/**
* Gets a classloader for the given codebase and with the current
* context classloader as parent.
*
- * @param codebases
+ * @param codebase
*
* @return a classloader for the given codebase
*
* @throws MalformedURLException if the codebase contains a malformed URL
*/
- public static ClassLoader getClassLoader (String codebases)
+ public static ClassLoader getClassLoader(String codebase)
throws MalformedURLException
{
- ClassLoader loader;
- CacheKey loaderKey = new CacheKey
- (codebases, Thread.currentThread().getContextClassLoader());
- loader = (ClassLoader) cacheLoaders.get (loaderKey);
-
- if (loader == null)
- {
- //create an entry in cacheLoaders mapping a loader to codebases.
- // codebases are separated by " "
- StringTokenizer tok = new StringTokenizer (codebases, " ");
- ArrayList urls = new ArrayList();
-
- while (tok.hasMoreTokens())
- urls.add (new URL (tok.nextToken()));
-
- loader = new MyClassLoader ((URL[]) urls.toArray (new URL [urls.size()]),
- Thread.currentThread().getContextClassLoader(),
- codebases);
- cacheLoaders.put (loaderKey, loader);
- }
-
- return loader;
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassLoader(codebase);
}
/**
@@ -286,47 +138,12 @@ public class RMIClassLoader
* @return a space seperated list of URLs where the class-definition
* of cl may be found
*/
- public static String getClassAnnotation (Class cl)
+ public static String getClassAnnotation(Class cl)
{
- ClassLoader loader = cl.getClassLoader();
-
- if (loader == null
- || loader == ClassLoader.getSystemClassLoader())
- {
- return System.getProperty ("java.rmi.server.codebase");
- }
-
- if (loader instanceof MyClassLoader)
- {
- return ((MyClassLoader) loader).getClassAnnotation();
- }
-
- String s = (String) cacheAnnotations.get (loader);
-
- if (s != null)
- return s;
-
- if (loader instanceof URLClassLoader)
- {
- URL[] urls = ((URLClassLoader) loader).getURLs();
-
- if (urls.length == 0)
- return null;
-
- StringBuffer annotation = new StringBuffer (64 * urls.length);
-
- for (int i = 0; i < urls.length; i++)
- {
- annotation.append (urls [i].toExternalForm());
- annotation.append (' ');
- }
-
- s = annotation.toString();
- cacheAnnotations.put (loader, s);
- return s;
- }
-
- return System.getProperty ("java.rmi.server.codebase");
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassAnnotation(cl);
}
/**
@@ -336,4 +153,25 @@ public class RMIClassLoader
{
throw new Error ("Not implemented");
}
+
+ /**
+ * Returns the default service provider for <code>RMIClassLoader</code>.
+ *
+ * @return the default provider for <code>RMIClassLoader</code>
+ */
+ public static RMIClassLoaderSpi getDefaultProviderInstance()
+ {
+ return RMIClassLoaderImpl.getInstance();
+ }
+
+ /**
+ * Chooses, instantiates and returns a service provider.
+ *
+ * @return a service provider
+ */
+ private static RMIClassLoaderSpi getProviderInstance()
+ {
+ // TODO: Do something more useful here.
+ return null;
+ }
}
diff --git a/libjava/classpath/java/rmi/server/RemoteObject.java b/libjava/classpath/java/rmi/server/RemoteObject.java
index 0b3c229c9d9..60e57dc2428 100644
--- a/libjava/classpath/java/rmi/server/RemoteObject.java
+++ b/libjava/classpath/java/rmi/server/RemoteObject.java
@@ -120,7 +120,9 @@ public boolean equals(Object obj) {
in.read (); //some unknown UnicastRef2 field
}
- cname = RemoteRef.packagePrefix + '.' + cname;
+ // It would be nice to use RemoteRef.packagePrefix here, but for binary
+ // compatibility with the JDK that has to contain "sun.rmi.server"...
+ cname = "gnu.java.rmi.server." + cname;
try
{
Class cls = Class.forName(cname);
diff --git a/libjava/classpath/java/rmi/server/RemoteRef.java b/libjava/classpath/java/rmi/server/RemoteRef.java
index 7e34db39e89..f33f9d374c3 100644
--- a/libjava/classpath/java/rmi/server/RemoteRef.java
+++ b/libjava/classpath/java/rmi/server/RemoteRef.java
@@ -48,7 +48,11 @@ public interface RemoteRef extends Externalizable
{
long serialVersionUID = 3632638527362204081L;
- String packagePrefix = "gnu.java.rmi.server";
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
/**
* @deprecated
diff --git a/libjava/classpath/java/security/AccessControlContext.java b/libjava/classpath/java/security/AccessControlContext.java
index 9a6ad208144..3b51e94125b 100644
--- a/libjava/classpath/java/security/AccessControlContext.java
+++ b/libjava/classpath/java/security/AccessControlContext.java
@@ -77,14 +77,23 @@ public final class AccessControlContext
/**
* Construct a new AccessControlContext with the specified
- * ProtectionDomains and DomainCombiner
+ * {@link ProtectionDomain}s and {@link DomainCombiner}.
*
+ * <p>Code calling this constructor must have a {@link
+ * SecurityPermission} of <i>createAccessControlContext</i>.</p>
+ *
+ * @throws SecurityException If the caller does not have permission
+ * to create an access control context.
* @since 1.3
*/
public AccessControlContext(AccessControlContext acc,
DomainCombiner combiner)
{
- // XXX check permission to call this.
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ {
+ sm.checkPermission (new SecurityPermission ("createAccessControlContext"));
+ }
AccessControlContext acc2 = AccessController.getContext();
protectionDomains = combiner.combine (acc2.protectionDomains,
acc.protectionDomains);
@@ -119,10 +128,20 @@ public final class AccessControlContext
public void checkPermission(Permission perm) throws AccessControlException
{
if (protectionDomains.length == 0)
- throw new AccessControlException ("permission not granted");
+ throw new AccessControlException ("permission "
+ + perm
+ + " not granted: no protection domains");
+
for (int i = 0; i < protectionDomains.length; i++)
- if (!protectionDomains[i].implies(perm))
- throw new AccessControlException ("permission not granted");
+ {
+ final ProtectionDomain domain = protectionDomains[i];
+ if (!domain.implies(perm))
+ throw new AccessControlException ("permission "
+ + perm
+ + " not granted: "
+ + domain
+ + " does not imply it.");
+ }
}
/**
@@ -173,4 +192,9 @@ public final class AccessControlContext
return h;
}
+
+ ProtectionDomain[] getProtectionDomains ()
+ {
+ return protectionDomains;
+ }
}
diff --git a/libjava/classpath/java/security/AccessController.java b/libjava/classpath/java/security/AccessController.java
index bc9c2deefbb..93e34b87c22 100644
--- a/libjava/classpath/java/security/AccessController.java
+++ b/libjava/classpath/java/security/AccessController.java
@@ -142,8 +142,8 @@ public final class AccessController
* @param action the <code>PrivilegedExceptionAction</code> whose
* <code>run()</code> should be be called.
* @return the result of the <code>action.run()</code> method.
- * @exception PrivilegedActionException wrapped around any exception that
- * is thrown in the <code>run()</code> method.
+ * @exception PrivilegedActionException wrapped around any checked exception
+ * that is thrown in the <code>run()</code> method.
*/
public static Object doPrivileged(PrivilegedExceptionAction action)
throws PrivilegedActionException
@@ -153,6 +153,10 @@ public final class AccessController
{
return action.run();
}
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
throw new PrivilegedActionException(e);
@@ -178,8 +182,8 @@ public final class AccessController
* @param context the <code>AccessControlContext</code> whose protection
* domains should be added to the protection domain of the calling class.
* @return the result of the <code>action.run()</code> method.
- * @exception PrivilegedActionException wrapped around any exception that
- * is thrown in the <code>run()</code> method.
+ * @exception PrivilegedActionException wrapped around any checked exception
+ * that is thrown in the <code>run()</code> method.
*/
public static Object doPrivileged(PrivilegedExceptionAction action,
AccessControlContext context)
@@ -190,6 +194,10 @@ public final class AccessController
{
return action.run();
}
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
throw new PrivilegedActionException(e);
diff --git a/libjava/classpath/java/security/Identity.java b/libjava/classpath/java/security/Identity.java
index 26b01a50a6b..7ef59cfe2de 100644
--- a/libjava/classpath/java/security/Identity.java
+++ b/libjava/classpath/java/security/Identity.java
@@ -297,8 +297,8 @@ public abstract class Identity implements Principal, Serializable
if (identity == this)
return true;
- if ((((Identity) identity).getName() == this.name) &&
- (((Identity) identity).getScope() == this.scope))
+ if ((((Identity) identity).getName().equals(this.name)) &&
+ (((Identity) identity).getScope().equals(this.scope)))
return true;
return identityEquals((Identity) identity);
@@ -319,8 +319,8 @@ public abstract class Identity implements Principal, Serializable
*/
protected boolean identityEquals(Identity identity)
{
- return ((identity.getName() == this.name) &&
- (identity.getPublicKey() == this.publicKey));
+ return ((identity.getName().equals(this.name)) &&
+ (identity.getPublicKey().equals(this.publicKey)));
}
/**
diff --git a/libjava/classpath/java/security/Security.java b/libjava/classpath/java/security/Security.java
index 54b97923efd..fd51d0535b3 100644
--- a/libjava/classpath/java/security/Security.java
+++ b/libjava/classpath/java/security/Security.java
@@ -1,5 +1,5 @@
/* Security.java --- Java base security class implementation
- Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -651,7 +651,7 @@ public final class Security
if (result.isEmpty())
return null;
- return (Provider[]) result.toArray(new Provider[0]);
+ return (Provider[]) result.toArray(new Provider[result.size()]);
}
private static void selectProviders(String svc, String algo, String attr,
diff --git a/libjava/classpath/java/text/AttributedString.java b/libjava/classpath/java/text/AttributedString.java
index 9f0d5af1c49..c751ab43cf8 100644
--- a/libjava/classpath/java/text/AttributedString.java
+++ b/libjava/classpath/java/text/AttributedString.java
@@ -49,7 +49,7 @@ import java.util.Set;
/**
* This class models a <code>String</code> with attributes over various
* subranges of the string. It allows applications to access this
- * information via the <code>AttributedCharcterIterator</code> interface.
+ * information via the <code>AttributedCharacterIterator</code> interface.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
@@ -166,16 +166,16 @@ public class AttributedString
*
* @param aci The <code>AttributedCharacterIterator</code> containing the
* text and attribute information.
- * @param begin_index The beginning index of the text subrange.
- * @param end_index The ending index of the text subrange.
+ * @param begin The beginning index of the text subrange.
+ * @param end The ending index of the text subrange.
* @param attributes A list of attributes to include from the iterator, or
* <code>null</code> to include all attributes.
*/
- public AttributedString(AttributedCharacterIterator aci, int begin_index,
- int end_index, AttributedCharacterIterator.Attribute[] attributes)
+ public AttributedString(AttributedCharacterIterator aci, int begin, int end,
+ AttributedCharacterIterator.Attribute[] attributes)
{
// Validate some arguments
- if ((begin_index < 0) || (end_index < begin_index))
+ if ((begin < 0) || (end < begin) || end > aci.getEndIndex())
throw new IllegalArgumentException("Bad index values");
StringBuffer sb = new StringBuffer("");
@@ -186,7 +186,7 @@ public class AttributedString
all_attribs.retainAll(Arrays.asList(attributes));
// Loop through and extract the attributes
- char c = aci.setIndex(begin_index);
+ char c = aci.setIndex(begin);
ArrayList accum = new ArrayList();
do
@@ -209,28 +209,28 @@ public class AttributedString
int rl = aci.getRunLimit(attrib);
if (rl == -1)
continue;
- if (rl > end_index)
- rl = end_index;
- rl -= begin_index;
+ if (rl > end)
+ rl = end;
+ rl -= begin;
// Check to see if we already processed this one
int rs = aci.getRunStart(attrib);
- if ((rs < aci.getIndex()) && (aci.getIndex() != begin_index))
+ if ((rs < aci.getIndex()) && (aci.getIndex() != begin))
continue;
// If the attribute run starts before the beginning index, we
// need to junk it if it is an Annotation.
Object attrib_obj = aci.getAttribute(attrib);
- if (rs < begin_index)
+ if (rs < begin)
{
if (attrib_obj instanceof Annotation)
continue;
- rs = begin_index;
+ rs = begin;
}
else
{
- rs -= begin_index;
+ rs -= begin;
}
// Create a map object. Yes this will only contain one attribute
@@ -269,22 +269,23 @@ public class AttributedString
*
* @param attrib The attribute to add.
* @param value The value of the attribute, which may be <code>null</code>.
- * @param begin_index The beginning index of the subrange.
- * @param end_index The ending index of the subrange.
+ * @param begin The beginning index of the subrange.
+ * @param end The ending index of the subrange.
*
* @exception IllegalArgumentException If attribute is <code>null</code> or
* the subrange is not valid.
*/
public void addAttribute(AttributedCharacterIterator.Attribute attrib,
- Object value, int begin_index, int end_index)
+ Object value, int begin, int end)
{
if (attrib == null)
throw new IllegalArgumentException("null attribute");
-
+ if (end <= begin)
+ throw new IllegalArgumentException("Requires end > begin");
HashMap hm = new HashMap();
hm.put(attrib, value);
- addAttributes(hm, begin_index, end_index);
+ addAttributes(hm, begin, end);
}
/**
@@ -295,16 +296,17 @@ public class AttributedString
* @param begin_index The beginning index.
* @param end_index The ending index
*
- * @throws IllegalArgumentException If the list is <code>null</code> or the
- * subrange is not valid.
+ * @throws NullPointerException if <code>attributes</code> is
+ * <code>null</code>.
+ * @throws IllegalArgumentException if the subrange is not valid.
*/
public void addAttributes(Map attributes, int begin_index, int end_index)
{
if (attributes == null)
- throw new IllegalArgumentException("null attribute");
+ throw new NullPointerException("null attribute");
if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
- (end_index < begin_index))
+ (end_index <= begin_index))
throw new IllegalArgumentException("bad range");
AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
diff --git a/libjava/classpath/java/text/AttributedStringIterator.java b/libjava/classpath/java/text/AttributedStringIterator.java
index 7fba5d63c3a..f6b9b186831 100644
--- a/libjava/classpath/java/text/AttributedStringIterator.java
+++ b/libjava/classpath/java/text/AttributedStringIterator.java
@@ -188,30 +188,44 @@ class AttributedStringIterator implements AttributedCharacterIterator
return(getRunLimit(s));
}
- public synchronized int getRunLimit(Set attribute_set)
+ public synchronized int getRunLimit(Set attributeSet)
{
- boolean hit = false;
- int runLimit = ci.getEndIndex ();
- int pos = ci.getIndex ();
-
- for (int i = 0; i < attribs.length; ++i)
+ if (attributeSet == null)
+ return ci.getEndIndex();
+
+ int current = ci.getIndex();
+ int end = ci.getEndIndex();
+ int limit = current;
+ if (current == end)
+ return end;
+ Map runValues = getAttributes();
+ while (limit < end)
+ {
+ Iterator iterator = attributeSet.iterator();
+ while (iterator.hasNext())
{
- if (pos >= attribs[i].begin_index &&
- pos < attribs[i].end_index)
+ // Qualified name is a workaround for a gcj 4.0 bug.
+ AttributedCharacterIterator.Attribute attributeKey
+ = (AttributedCharacterIterator.Attribute) iterator.next();
+ Object v1 = runValues.get(attributeKey);
+ Object v2 = getAttribute(attributeKey, limit + 1);
+ boolean changed = false;
+ // check for equal or both null, if NO return start
+ if (v1 != null)
+ {
+ changed = !v1.equals(v2);
+ }
+ else
{
- Iterator iter = attribute_set.iterator();
- while(iter.hasNext())
- if (attribs[i].attribs.containsKey(iter.next()))
- {
- hit = true;
- runLimit = Math.min(runLimit, attribs[i].end_index);
- }
+ changed = (v2 != null);
}
+ if (changed)
+ return limit + 1;
}
- if (hit)
- return runLimit;
- else
- return ci.getEndIndex();
+ // no differences, so increment limit and next and loop again
+ limit++;
+ }
+ return end;
}
/*************************************************************************/
@@ -221,69 +235,128 @@ class AttributedStringIterator implements AttributedCharacterIterator
* attribute combinations.
*/
+ /**
+ * Returns the index of the first character in the run containing the current
+ * character and defined by all the attributes defined for that character
+ * position.
+ *
+ * @return The run start index.
+ */
public int getRunStart()
{
return(getRunStart(getAttributes().keySet()));
}
+ /**
+ * Returns the index of the first character in the run, defined by the
+ * specified attribute, that contains the current character.
+ *
+ * @param attrib the attribute (<code>null</code> permitted).
+ *
+ * return The index of the first character in the run.
+ */
public int getRunStart(AttributedCharacterIterator.Attribute attrib)
{
+ if (attrib == null)
+ return ci.getBeginIndex();
HashSet s = new HashSet();
s.add(attrib);
-
return(getRunStart(s));
}
- public int getRunStart(Set attribute_set)
+ /**
+ * Returns the index of the first character in the run, defined by the
+ * specified attribute set, that contains the current character.
+ *
+ * @param attributeSet the attribute set (<code>null</code> permitted).
+ *
+ * return The index of the first character in the run.
+ */
+ public int getRunStart(Set attributeSet)
{
- boolean hit = false;
- int runBegin = 0;
- int pos = ci.getIndex();
-
- for (int i = 0; i < attribs.length; ++i)
+ if (attributeSet == null)
+ return ci.getBeginIndex();
+
+ int current = ci.getIndex();
+ int begin = ci.getBeginIndex();
+ int start = current;
+ if (start == begin)
+ return begin;
+ Map runValues = getAttributes();
+ int prev = start - 1;
+ while (start > begin)
+ {
+ Iterator iterator = attributeSet.iterator();
+ while (iterator.hasNext())
{
- if (pos >= attribs[i].begin_index &&
- pos <= attribs[i].end_index)
+ // Qualified name is a workaround for a gcj 4.0 bug.
+ AttributedCharacterIterator.Attribute attributeKey
+ = (AttributedCharacterIterator.Attribute) iterator.next();
+ Object v1 = runValues.get(attributeKey);
+ Object v2 = getAttribute(attributeKey, prev);
+ boolean changed = false;
+ // check for equal or both null, if NO return start
+ if (v1 != null)
+ {
+ changed = !v1.equals(v2);
+ }
+ else
{
- Iterator iter = attribute_set.iterator();
- while(iter.hasNext())
- if (attribs[i].attribs.containsKey(iter.next()))
- {
- hit = true;
- runBegin = Math.max(runBegin, attribs[i].begin_index);
- }
+ changed = (v2 != null);
}
+ if (changed)
+ return start;
}
- if (hit)
- return runBegin;
- else
- return -1;
+ // no differences, so decrement start and prev and loop again
+ start--;
+ prev--;
+ }
+ return start;
}
/*************************************************************************/
- public Object getAttribute(AttributedCharacterIterator.Attribute attrib)
+ /**
+ * Returns the value for an attribute at the specified position. If the
+ * attribute key (<code>key</code>) is <code>null</code>, the method returns
+ * <code>null</code>.
+ *
+ * @param key the key (<code>null</code> permitted).
+ * @param pos the character position.
+ *
+ * @return The attribute value (possibly <code>null</code>).
+ */
+ private Object getAttribute(AttributedCharacterIterator.Attribute key,
+ int pos)
{
if (attribs == null)
- return(null);
-
- for (int i = 0; i < attribs.length; i++)
+ return null;
+ for (int i = attribs.length - 1; i >= 0; i--)
{
- Set key_set = attribs[i].attribs.keySet();
- Iterator iter = key_set.iterator();
- while (iter.hasNext())
+ if (pos >= attribs[i].begin_index && pos < attribs[i].end_index)
{
- Object obj = iter.next();
-
- // Check for attribute match and range match
- if (obj.equals(attrib))
- if ((ci.getIndex() >= attribs[i].begin_index) &&
- (ci.getIndex() < attribs[i].end_index))
- return(attribs[i].attribs.get(obj));
+ Set keys = attribs[i].attribs.keySet();
+ if (keys.contains(key))
+ {
+ return attribs[i].attribs.get(key);
+ }
}
}
-
- return(null);
+ return null;
+ }
+
+ /**
+ * Returns the value for an attribute at the current position. If the
+ * attribute key (<code>key</code>) is <code>null</code>, the method returns
+ * <code>null</code>.
+ *
+ * @param key the key (<code>null</code> permitted).
+ *
+ * @return The attribute value (possibly <code>null</code>).
+ */
+ public Object getAttribute(AttributedCharacterIterator.Attribute key)
+ {
+ return getAttribute(key, ci.getIndex());
}
/*************************************************************************/
diff --git a/libjava/classpath/java/text/CharacterIterator.java b/libjava/classpath/java/text/CharacterIterator.java
index 58d6ddc3951..42da33c432f 100644
--- a/libjava/classpath/java/text/CharacterIterator.java
+++ b/libjava/classpath/java/text/CharacterIterator.java
@@ -68,7 +68,7 @@ public interface CharacterIterator extends Cloneable
* <code>getEndIndex() - 1</code>, it will not be incremented.
*
* @return The character at the position of the incremented index value,
- * or <code>DONE</code> if the index has reached getEndIndex() - 1
+ * or {@link #DONE} if the index has reached getEndIndex() - 1
*/
char next();
diff --git a/libjava/classpath/java/text/DateFormat.java b/libjava/classpath/java/text/DateFormat.java
index 5d412aada52..73aa62d9805 100644
--- a/libjava/classpath/java/text/DateFormat.java
+++ b/libjava/classpath/java/text/DateFormat.java
@@ -58,6 +58,9 @@ import java.util.TimeZone;
public abstract class DateFormat extends Format implements Cloneable
{
+ private static final long serialVersionUID = 7218322306649953788L;
+
+ // Names fixed by serialization spec.
protected Calendar calendar;
protected NumberFormat numberFormat;
diff --git a/libjava/classpath/java/text/ParsePosition.java b/libjava/classpath/java/text/ParsePosition.java
index 782f5e0eda2..b0a8a4a0b36 100644
--- a/libjava/classpath/java/text/ParsePosition.java
+++ b/libjava/classpath/java/text/ParsePosition.java
@@ -136,6 +136,15 @@ public class ParsePosition
ParsePosition other = (ParsePosition) obj;
return index == other.index && error_index == other.error_index;
}
+
+ /**
+ * Return the hash code for this object.
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ return index ^ error_index;
+ }
/**
* This method returns a <code>String</code> representation of this
diff --git a/libjava/classpath/java/text/RuleBasedCollator.java b/libjava/classpath/java/text/RuleBasedCollator.java
index ae84a41032d..5756e9aa791 100644
--- a/libjava/classpath/java/text/RuleBasedCollator.java
+++ b/libjava/classpath/java/text/RuleBasedCollator.java
@@ -510,7 +510,7 @@ main_parse_loop:
int idx;
// Parse the subrules but do not iterate through all
- // sublist. This is the priviledge of the first call.
+ // sublist. This is the privilege of the first call.
idx = subParseString(true, sorted_rules, base_offset+i, subrules);
// Merge new parsed rules into the list.
diff --git a/libjava/classpath/java/text/StringCharacterIterator.java b/libjava/classpath/java/text/StringCharacterIterator.java
index e2674881333..85ca302cbe8 100644
--- a/libjava/classpath/java/text/StringCharacterIterator.java
+++ b/libjava/classpath/java/text/StringCharacterIterator.java
@@ -143,7 +143,7 @@ public final class StringCharacterIterator implements CharacterIterator
* an existing StringCharacterIterator and resets the beginning and
* ending index.
*
- * @param scci The StringCharacterIterator to copy the info from
+ * @param sci The StringCharacterIterator to copy the info from
* @param begin The beginning index of the range we are interested in.
* @param end The ending index of the range we are interested in.
*/
@@ -340,6 +340,16 @@ public final class StringCharacterIterator implements CharacterIterator
&& index == sci.index
&& text.equals (sci.text));
}
+
+ /**
+ * Return the hash code for this object.
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ // Incorporate all the data in a goofy way.
+ return begin ^ end ^ index ^ text.hashCode();
+ }
/*************************************************************************/
diff --git a/libjava/classpath/java/util/ArrayList.java b/libjava/classpath/java/util/ArrayList.java
index 82bcca8c3e0..752f9da4ee0 100644
--- a/libjava/classpath/java/util/ArrayList.java
+++ b/libjava/classpath/java/util/ArrayList.java
@@ -551,7 +551,7 @@ public class ArrayList extends AbstractList
/**
* Serializes this object to the given stream.
*
- * @param out the stream to write to
+ * @param s the stream to write to
* @throws IOException if the underlying stream fails
* @serialData the size field (int), the length of the backing array
* (int), followed by its elements (Objects) in proper order.
@@ -572,7 +572,7 @@ public class ArrayList extends AbstractList
/**
* Deserializes this object from the given stream.
*
- * @param in the stream to read from
+ * @param s the stream to read from
* @throws ClassNotFoundException if the underlying stream fails
* @throws IOException if the underlying stream fails
* @serialData the size field (int), the length of the backing array
diff --git a/libjava/classpath/java/util/Arrays.java b/libjava/classpath/java/util/Arrays.java
index 15c1a5f33bf..b28c156b46e 100644
--- a/libjava/classpath/java/util/Arrays.java
+++ b/libjava/classpath/java/util/Arrays.java
@@ -2353,6 +2353,186 @@ public class Arrays
}
/**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (long[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (int[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (short[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (char[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (byte[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (boolean[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (float[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (double[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
+ * Returns a String representation of the argument array. Returns "null"
+ * if <code>a</code> is null.
+ * @param a the array to represent
+ * @return a String representing this array
+ * @since 1.5
+ */
+ public static String toString (Object[] a)
+ {
+ if (a == null)
+ return "null";
+ if (a.length == 0)
+ return "[]";
+ String result = "[";
+ for (int i = 0; i < a.length - 1; i++)
+ result += String.valueOf(a[i]) + ", ";
+ result += String.valueOf(a[a.length - 1]) + "]";
+ return result;
+ }
+
+ /**
* Inner class used by {@link #asList(Object[])} to provide a list interface
* to an array. The name, though it clashes with java.util.ArrayList, is
* Sun's choice for Serialization purposes. Element addition and removal
diff --git a/libjava/classpath/java/util/Calendar.java b/libjava/classpath/java/util/Calendar.java
index 88bd76bcadc..f94bed40dad 100644
--- a/libjava/classpath/java/util/Calendar.java
+++ b/libjava/classpath/java/util/Calendar.java
@@ -914,8 +914,19 @@ public abstract class Calendar implements Serializable, Cloneable
*/
public boolean equals(Object o)
{
- return (o instanceof Calendar)
- && getTimeInMillis() == ((Calendar) o).getTimeInMillis();
+ if (! (o instanceof Calendar))
+ return false;
+ Calendar cal = (Calendar) o;
+ if (getTimeInMillis() == ((Calendar) o).getTimeInMillis()
+ && cal.getFirstDayOfWeek() == getFirstDayOfWeek()
+ && cal.isLenient() == isLenient()
+ && cal.getMinimalDaysInFirstWeek() == getMinimalDaysInFirstWeek())
+ {
+ TimeZone self = getTimeZone();
+ TimeZone oth = cal.getTimeZone();
+ return self == null ? oth == null : self.equals(oth);
+ }
+ return false;
}
/**
@@ -926,7 +937,13 @@ public abstract class Calendar implements Serializable, Cloneable
public int hashCode()
{
long time = getTimeInMillis();
- return (int) ((time & 0xffffffffL) ^ (time >> 32));
+ int val = (int) ((time & 0xffffffffL) ^ (time >> 32));
+ val += (getFirstDayOfWeek() + (isLenient() ? 1230 : 1237)
+ + getMinimalDaysInFirstWeek());
+ TimeZone self = getTimeZone();
+ if (self != null)
+ val ^= self.hashCode();
+ return val;
}
/**
diff --git a/libjava/classpath/java/util/Collections.java b/libjava/classpath/java/util/Collections.java
index ed8a00500c6..e650bf8bda9 100644
--- a/libjava/classpath/java/util/Collections.java
+++ b/libjava/classpath/java/util/Collections.java
@@ -1731,8 +1731,8 @@ public class Collections
}
/**
- * The implementation of {@link #singletonMap(Object)}. This class name
- * is required for compatibility with Sun's JDK serializability.
+ * The implementation of {@link #singletonMap(Object, Object)}. This class
+ * name is required for compatibility with Sun's JDK serializability.
*
* @author Eric Blake (ebb9@email.byu.edu)
*/
@@ -2518,12 +2518,13 @@ public class Collections
}
/**
- * Add an element to the end of the underlying list (optional operation).
- * If the list imposes restraints on what can be inserted, such as no null
- * elements, this should be documented. A lock is obtained on the mutex before
- * any of the elements are added.
+ * Add the contents of a collection to the underlying list at the given
+ * index (optional operation). If the list imposes restraints on what
+ * can be inserted, such as no null elements, this should be documented.
+ * A lock is obtained on the mutex before any of the elements are added.
*
- * @param o the object to add
+ * @param index the index at which to insert
+ * @param c the collection to add
* @return <code>true</code>, as defined by Collection for a modified list
* @throws UnsupportedOperationException if this list does not support the
* add operation
@@ -3858,7 +3859,7 @@ public class Collections
/**
* Called only by trusted code to specify the mutex as well as the set.
* @param sync the mutex
- * @param l the list
+ * @param ss the set
*/
SynchronizedSortedSet(Object sync, SortedSet ss)
{
diff --git a/libjava/classpath/java/util/GregorianCalendar.java b/libjava/classpath/java/util/GregorianCalendar.java
index b086a7d04a4..89b7c4dbd02 100644
--- a/libjava/classpath/java/util/GregorianCalendar.java
+++ b/libjava/classpath/java/util/GregorianCalendar.java
@@ -868,6 +868,17 @@ public class GregorianCalendar extends Calendar
areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true;
}
+
+ /**
+ * Return a hash code for this object, following the general contract
+ * specified by {@link Object#hashCode()}.
+ * @return the hash code
+ */
+ public int hashCode()
+ {
+ int val = (int) ((gregorianCutover >>> 32) ^ (gregorianCutover & 0xffffffff));
+ return super.hashCode() ^ val;
+ }
/**
* Compares the given calendar with this. An object, o, is
@@ -890,7 +901,8 @@ public class GregorianCalendar extends Calendar
return false;
GregorianCalendar cal = (GregorianCalendar) o;
- return (cal.getTimeInMillis() == getTimeInMillis());
+ return (cal.gregorianCutover == gregorianCutover
+ && super.equals(o));
}
/**
diff --git a/libjava/classpath/java/util/HashMap.java b/libjava/classpath/java/util/HashMap.java
index 5ca9cf6d500..7176db0d58e 100644
--- a/libjava/classpath/java/util/HashMap.java
+++ b/libjava/classpath/java/util/HashMap.java
@@ -449,7 +449,7 @@ public class HashMap extends AbstractMap
*
* @param value the value to search for in this HashMap
* @return true if at least one key maps to the value
- * @see containsKey(Object)
+ * @see #containsKey(Object)
*/
public boolean containsValue(Object value)
{
diff --git a/libjava/classpath/java/util/InvalidPropertiesFormatException.java b/libjava/classpath/java/util/InvalidPropertiesFormatException.java
new file mode 100644
index 00000000000..6540c2313f3
--- /dev/null
+++ b/libjava/classpath/java/util/InvalidPropertiesFormatException.java
@@ -0,0 +1,57 @@
+/* InvalidPropertiesFormatException.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.util;
+
+import java.io.IOException;
+
+// FIXME: serialization methods should throw NotSerializableException
+/** @since 1.5 */
+public class InvalidPropertiesFormatException extends IOException
+{
+ public InvalidPropertiesFormatException(String message)
+ {
+ super(message);
+ }
+
+ public InvalidPropertiesFormatException(Throwable cause)
+ {
+ super();
+ initCause(cause);
+ }
+}
diff --git a/libjava/classpath/java/util/Locale.java b/libjava/classpath/java/util/Locale.java
index 6d3f8463252..9e7bbfea2b3 100644
--- a/libjava/classpath/java/util/Locale.java
+++ b/libjava/classpath/java/util/Locale.java
@@ -915,7 +915,7 @@ public final class Locale implements Serializable, Cloneable
/**
* Write the locale to an object stream.
*
- * @param output the stream to write to
+ * @param s the stream to write to
* @throws IOException if the write fails
* @serialData The first three fields are Strings representing language,
* country, and variant. The fourth field is a placeholder for
@@ -935,7 +935,7 @@ public final class Locale implements Serializable, Cloneable
/**
* Reads a locale from the input stream.
*
- * @param input the stream to read from
+ * @param s the stream to read from
* @throws IOException if reading fails
* @throws ClassNotFoundException if reading fails
* @serialData the hashCode is always invalid and must be recomputed
diff --git a/libjava/classpath/java/util/Map.java b/libjava/classpath/java/util/Map.java
index 256e98899f6..986ab9a84b4 100644
--- a/libjava/classpath/java/util/Map.java
+++ b/libjava/classpath/java/util/Map.java
@@ -324,10 +324,10 @@ public interface Map
* this must be:
*
<p><pre>(o instanceof Map.Entry)
-&& (getKey() == null ? ((HashMap) o).getKey() == null
- : getKey().equals(((HashMap) o).getKey()))
-&& (getValue() == null ? ((HashMap) o).getValue() == null
- : getValue().equals(((HashMap) o).getValue()))</pre>
+&& (getKey() == null ? ((Map.Entry) o).getKey() == null
+ : getKey().equals(((Map.Entry) o).getKey()))
+&& (getValue() == null ? ((Map.Entry) o).getValue() == null
+ : getValue().equals(((Map.Entry) o).getValue()))</pre>
*
* @param o the object to compare
*
diff --git a/libjava/classpath/java/util/Properties.java b/libjava/classpath/java/util/Properties.java
index f00615ba0bf..7c468da8b4f 100644
--- a/libjava/classpath/java/util/Properties.java
+++ b/libjava/classpath/java/util/Properties.java
@@ -47,6 +47,25 @@ import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.DefaultHandler2;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Element;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
/**
* A set of persistent properties, which can be saved or loaded from a stream.
* A property list may also contain defaults, searched if the main list
@@ -200,12 +219,15 @@ label = Name:\\u0020</pre>
// The characters up to the next Whitespace, ':', or '='
// describe the key. But look for escape sequences.
- StringBuffer key = new StringBuffer();
+ // Try to short-circuit when there is no escape char.
+ int start = pos;
+ boolean needsEscape = line.indexOf('\\', pos) != -1;
+ StringBuilder key = needsEscape ? new StringBuilder() : null;
while (pos < line.length()
&& ! Character.isWhitespace(c = line.charAt(pos++))
&& c != '=' && c != ':')
{
- if (c == '\\')
+ if (needsEscape && c == '\\')
{
if (pos == line.length())
{
@@ -249,11 +271,20 @@ label = Name:\\u0020</pre>
}
}
}
- else
+ else if (needsEscape)
key.append(c);
}
boolean isDelim = (c == ':' || c == '=');
+
+ String keyString;
+ if (needsEscape)
+ keyString = key.toString();
+ else if (isDelim || Character.isWhitespace(c))
+ keyString = line.substring(start, pos - 1);
+ else
+ keyString = line.substring(start, pos);
+
while (pos < line.length()
&& Character.isWhitespace(c = line.charAt(pos)))
pos++;
@@ -266,7 +297,15 @@ label = Name:\\u0020</pre>
pos++;
}
- StringBuffer element = new StringBuffer(line.length() - pos);
+ // Short-circuit if no escape chars found.
+ if (!needsEscape)
+ {
+ put(keyString, line.substring(pos));
+ continue;
+ }
+
+ // Escape char found so iterate through the rest of the line.
+ StringBuilder element = new StringBuilder(line.length() - pos);
while (pos < line.length())
{
c = line.charAt(pos++);
@@ -322,7 +361,7 @@ label = Name:\\u0020</pre>
else
element.append(c);
}
- put(key.toString(), element.toString());
+ put(keyString, element.toString());
}
}
@@ -386,7 +425,7 @@ label = Name:\\u0020</pre>
Iterator iter = entrySet ().iterator ();
int i = size ();
- StringBuffer s = new StringBuffer (); // Reuse the same buffer.
+ StringBuilder s = new StringBuilder (); // Reuse the same buffer.
while (--i >= 0)
{
Map.Entry entry = (Map.Entry) iter.next ();
@@ -529,7 +568,7 @@ label = Name:\\u0020</pre>
* leading spaces must be escaped for the value
* @see #store(OutputStream, String)
*/
- private void formatForOutput(String str, StringBuffer buffer, boolean key)
+ private void formatForOutput(String str, StringBuilder buffer, boolean key)
{
if (key)
{
@@ -578,4 +617,299 @@ label = Name:\\u0020</pre>
head = key;
}
}
+
+ /**
+ * <p>
+ * Encodes the properties as an XML file using the UTF-8 encoding.
+ * The format of the XML file matches the DTD
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ * </p>
+ * <p>
+ * Invoking this method provides the same behaviour as invoking
+ * <code>storeToXML(os, comment, "UTF-8")</code>.
+ * </p>
+ *
+ * @param os the stream to output to.
+ * @param comment a comment to include at the top of the XML file, or
+ * <code>null</code> if one is not required.
+ * @throws IOException if the serialization fails.
+ * @throws NullPointerException if <code>os</code> is null.
+ * @since 1.5
+ */
+ public void storeToXML(OutputStream os, String comment)
+ throws IOException
+ {
+ storeToXML(os, comment, "UTF-8");
+ }
+
+ /**
+ * <p>
+ * Encodes the properties as an XML file using the supplied encoding.
+ * The format of the XML file matches the DTD
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ * </p>
+ *
+ * @param os the stream to output to.
+ * @param comment a comment to include at the top of the XML file, or
+ * <code>null</code> if one is not required.
+ * @param encoding the encoding to use for the XML output.
+ * @throws IOException if the serialization fails.
+ * @throws NullPointerException if <code>os</code> or <code>encoding</code>
+ * is null.
+ * @since 1.5
+ */
+ public void storeToXML(OutputStream os, String comment, String encoding)
+ throws IOException
+ {
+ if (os == null)
+ throw new NullPointerException("Null output stream supplied.");
+ if (encoding == null)
+ throw new NullPointerException("Null encoding supplied.");
+ try
+ {
+ DOMImplementationRegistry registry =
+ DOMImplementationRegistry.newInstance();
+ DOMImplementation domImpl = registry.getDOMImplementation("LS 3.0");
+ DocumentType doctype =
+ domImpl.createDocumentType("properties", null,
+ "http://java.sun.com/dtd/properties.dtd");
+ Document doc = domImpl.createDocument(null, "properties", doctype);
+ Element root = doc.getDocumentElement();
+ if (comment != null)
+ {
+ Element commentElement = doc.createElement("comment");
+ commentElement.appendChild(doc.createTextNode(comment));
+ root.appendChild(commentElement);
+ }
+ Iterator iterator = entrySet().iterator();
+ while (iterator.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ Element entryElement = doc.createElement("entry");
+ entryElement.setAttribute("key", (String) entry.getKey());
+ entryElement.appendChild(doc.createTextNode((String)
+ entry.getValue()));
+ root.appendChild(entryElement);
+ }
+ DOMImplementationLS loadAndSave = (DOMImplementationLS) domImpl;
+ LSSerializer serializer = loadAndSave.createLSSerializer();
+ LSOutput output = loadAndSave.createLSOutput();
+ output.setByteStream(os);
+ output.setEncoding(encoding);
+ serializer.write(doc, output);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw (IOException)
+ new IOException("The XML classes could not be found.").initCause(e);
+ }
+ catch (InstantiationException e)
+ {
+ throw (IOException)
+ new IOException("The XML classes could not be instantiated.")
+ .initCause(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw (IOException)
+ new IOException("The XML classes could not be accessed.")
+ .initCause(e);
+ }
+ }
+
+ /**
+ * <p>
+ * Decodes the contents of the supplied <code>InputStream</code> as
+ * an XML file, which represents a set of properties. The format of
+ * the XML file must match the DTD
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ * </p>
+ *
+ * @param in the input stream from which to receive the XML data.
+ * @throws IOException if an I/O error occurs in reading the input data.
+ * @throws InvalidPropertiesFormatException if the input data does not
+ * constitute an XML properties
+ * file.
+ * @throws NullPointerException if <code>in</code> is null.
+ * @since 1.5
+ */
+ public void loadFromXML(InputStream in)
+ throws IOException, InvalidPropertiesFormatException
+ {
+ if (in == null)
+ throw new NullPointerException("Null input stream supplied.");
+ try
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false); /* Don't use the URI */
+ XMLReader parser = factory.newSAXParser().getXMLReader();
+ PropertiesHandler handler = new PropertiesHandler();
+ parser.setContentHandler(handler);
+ parser.setProperty("http://xml.org/sax/properties/lexical-handler",
+ handler);
+ parser.parse(new InputSource(in));
+ }
+ catch (SAXException e)
+ {
+ throw (InvalidPropertiesFormatException)
+ new InvalidPropertiesFormatException("Error in parsing XML.").
+ initCause(e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw (IOException)
+ new IOException("An XML parser could not be found.").
+ initCause(e);
+ }
+ }
+
+ /**
+ * This class deals with the parsing of XML using
+ * <a href="http://java.sun.com/dtd/properties.dtd">
+ * http://java.sun.com/dtd/properties.dtd</a>.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+ private class PropertiesHandler
+ extends DefaultHandler2
+ {
+
+ /**
+ * The current key.
+ */
+ private String key;
+
+ /**
+ * The current value.
+ */
+ private String value;
+
+ /**
+ * A flag to check whether a valid DTD declaration has been seen.
+ */
+ private boolean dtdDeclSeen;
+
+ /**
+ * Constructs a new Properties handler.
+ */
+ public PropertiesHandler()
+ {
+ key = null;
+ value = null;
+ dtdDeclSeen = false;
+ }
+
+ /**
+ * <p>
+ * Captures the start of the DTD declarations, if they exist.
+ * A valid properties file must declare the following doctype:
+ * </p>
+ * <p>
+ * <code>!DOCTYPE properties SYSTEM
+ * "http://java.sun.com/dtd/properties.dtd"</code>
+ * </p>
+ *
+ * @param name the name of the document type.
+ * @param publicId the public identifier that was declared, or
+ * null if there wasn't one.
+ * @param systemId the system identifier that was declared, or
+ * null if there wasn't one.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException
+ {
+ if (name.equals("properties") &&
+ publicId == null &&
+ systemId.equals("http://java.sun.com/dtd/properties.dtd"))
+ {
+ dtdDeclSeen = true;
+ }
+ else
+ throw new SAXException("Invalid DTD declaration: " + name);
+ }
+
+ /**
+ * Captures the start of an XML element.
+ *
+ * @param uri the namespace URI.
+ * @param localName the local name of the element inside the namespace.
+ * @param qName the local name qualified with the namespace URI.
+ * @param attributes the attributes of this element.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void startElement(String uri, String localName,
+ String qName, Attributes attributes)
+ throws SAXException
+ {
+ if (qName.equals("entry"))
+ {
+ int index = attributes.getIndex("key");
+ if (index != -1)
+ key = attributes.getValue(index);
+ }
+ else if (qName.equals("comment") || qName.equals("properties"))
+ {
+ /* Ignore it */
+ }
+ else
+ throw new SAXException("Invalid tag: " + qName);
+ }
+
+ /**
+ * Captures characters within an XML element.
+ *
+ * @param ch the array of characters.
+ * @param start the start index of the characters to use.
+ * @param length the number of characters to use from the start index on.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void characters(char[] ch, int start, int length)
+ throws SAXException
+ {
+ if (key != null)
+ value = new String(ch,start,length);
+ }
+
+ /**
+ * Captures the end of an XML element.
+ *
+ * @param uri the namespace URI.
+ * @param localName the local name of the element inside the namespace.
+ * @param qName the local name qualified with the namespace URI.
+ * @throws SAXException if some error occurs in parsing.
+ */
+ public void endElement(String uri, String localName,
+ String qName)
+ throws SAXException
+ {
+ if (qName.equals("entry"))
+ {
+ if (value == null)
+ value = "";
+ setProperty(key, value);
+ key = null;
+ value = null;
+ }
+ }
+
+ /**
+ * Captures the end of the XML document. If a DTD declaration has
+ * not been seen, the document is erroneous and an exception is thrown.
+ *
+ * @throws SAXException if the correct DTD declaration didn't appear.
+ */
+ public void endDocument()
+ throws SAXException
+ {
+ if (!dtdDeclSeen)
+ throw new SAXException("No appropriate DTD declaration was seen.");
+ }
+
+ } // class PropertiesHandler
+
} // class Properties
diff --git a/libjava/classpath/java/util/Random.java b/libjava/classpath/java/util/Random.java
index bc005075140..b016f78d4a2 100644
--- a/libjava/classpath/java/util/Random.java
+++ b/libjava/classpath/java/util/Random.java
@@ -102,7 +102,7 @@ public class Random implements Serializable
* in next.
*
* @serial the internal state of this generator
- * @see #next()
+ * @see #next(int)
*/
private long seed;
diff --git a/libjava/classpath/java/util/ResourceBundle.java b/libjava/classpath/java/util/ResourceBundle.java
index 91007e9b1aa..6aea6731a5d 100644
--- a/libjava/classpath/java/util/ResourceBundle.java
+++ b/libjava/classpath/java/util/ResourceBundle.java
@@ -419,7 +419,11 @@ public abstract class ResourceBundle
}
}
- throw new MissingResourceException("Bundle " + baseName + " not found",
+ throw new MissingResourceException("Bundle " + baseName
+ + " not found for locale "
+ + locale
+ + " by classloader "
+ + classLoader,
baseName, "");
}
@@ -508,8 +512,7 @@ public abstract class ResourceBundle
*
* @param baseName the raw bundle name, without locale qualifiers
* @param locale the locale
- * @param classloader the classloader
- * @param bundle the backup (parent) bundle
+ * @param classLoader the classloader
* @param wantBase whether a resource bundle made only from the base name
* (with no locale information attached) should be returned.
* @return the resource bundle if it was loaded, otherwise the backup
diff --git a/libjava/classpath/java/util/SimpleTimeZone.java b/libjava/classpath/java/util/SimpleTimeZone.java
index 995ccea84ca..0bda44c3327 100644
--- a/libjava/classpath/java/util/SimpleTimeZone.java
+++ b/libjava/classpath/java/util/SimpleTimeZone.java
@@ -468,6 +468,7 @@ public class SimpleTimeZone extends TimeZone
* @param dayOfWeek The day of week where daylight savings start.
* @param time The time in milliseconds standard time where daylight
* savings start.
+ * @exception IllegalArgumentException if parameters are out of range.
* @see SimpleTimeZone
*/
public void setStartRule(int month, int day, int dayOfWeek, int time)
@@ -796,7 +797,7 @@ public class SimpleTimeZone extends TimeZone
* dst and standard time.
* @param calYear the year of the date to check (for leap day checking).
* @param calMonth the month of the date to check.
- * @param calDay the day of month of the date to check.
+ * @param calDayOfMonth the day of month of the date to check.
* @param calDayOfWeek the day of week of the date to check.
* @param calMillis the millis of day of the date to check (standard time).
* @param mode the change mode; same semantic as startMode.
diff --git a/libjava/classpath/java/util/Timer.java b/libjava/classpath/java/util/Timer.java
index 715f06cf641..01a6fe8eab3 100644
--- a/libjava/classpath/java/util/Timer.java
+++ b/libjava/classpath/java/util/Timer.java
@@ -1,5 +1,5 @@
/* Timer.java -- Timer that runs TimerTasks at a later time.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -297,12 +297,67 @@ public class Timer
this.notify();
}
+ /**
+ * Remove all canceled tasks from the queue.
+ */
+ public synchronized int purge()
+ {
+ int removed = 0;
+ // Null out any elements that are canceled. Skip element 0 as
+ // it is the sentinel.
+ for (int i = elements; i > 0; --i)
+ {
+ if (heap[i].scheduled < 0)
+ {
+ ++removed;
+
+ // Remove an element by pushing the appropriate child
+ // into place, and then iterating to the bottom of the
+ // tree.
+ int index = i;
+ while (heap[index] != null)
+ {
+ int child = 2 * index;
+ if (child >= heap.length)
+ {
+ // Off end; we're done.
+ heap[index] = null;
+ break;
+ }
+
+ if (child + 1 >= heap.length || heap[child + 1] == null)
+ {
+ // Nothing -- we're done.
+ }
+ else if (heap[child] == null
+ || (heap[child].scheduled
+ > heap[child + 1].scheduled))
+ ++child;
+ heap[index] = heap[child];
+ index = child;
+ }
+ }
+ }
+
+ // Make a new heap if we shrank enough.
+ int newLen = heap.length;
+ while (elements - removed + DEFAULT_SIZE / 2 <= newLen / 4)
+ newLen /= 2;
+ if (newLen != heap.length)
+ {
+ TimerTask[] newHeap = new TimerTask[newLen];
+ System.arraycopy(heap, 0, newHeap, 0, elements + 1);
+ heap = newHeap;
+ }
+
+ return removed;
+ }
} // TaskQueue
/**
* The scheduler that executes all the tasks on a particular TaskQueue,
* reschedules any repeating tasks and that waits when no task has to be
- * executed immediatly. Stops running when canceled or when the parent
+ * executed immediately. Stops running when canceled or when the parent
* Timer has been finalized and no more tasks have to be executed.
*/
private static final class Scheduler implements Runnable
@@ -420,6 +475,30 @@ public class Timer
}
/**
+ * Create a new Timer whose Thread has the indicated name. It will have
+ * normal priority and will not be a daemon thread.
+ * @param name the name of the Thread
+ * @since 1.5
+ */
+ public Timer(String name)
+ {
+ this(false, Thread.NORM_PRIORITY, name);
+ }
+
+ /**
+ * Create a new Timer whose Thread has the indicated name. It will have
+ * normal priority. The boolean argument controls whether or not it
+ * will be a daemon thread.
+ * @param name the name of the Thread
+ * @param daemon true if the Thread should be a daemon thread
+ * @since 1.5
+ */
+ public Timer(String name, boolean daemon)
+ {
+ this(daemon, Thread.NORM_PRIORITY, name);
+ }
+
+ /**
* Creates a new Timer with a daemon Thread as scheduler if daemon is true,
* with the priority given and a default name.
*/
@@ -612,4 +691,14 @@ public class Timer
{
queue.setNullOnEmpty(true);
}
+
+ /**
+ * Removes all cancelled tasks from the queue.
+ * @return the number of tasks removed
+ * @since 1.5
+ */
+ public int purge()
+ {
+ return queue.purge();
+ }
}
diff --git a/libjava/classpath/java/util/TreeMap.java b/libjava/classpath/java/util/TreeMap.java
index 1e8c805d908..a00f257aa8b 100644
--- a/libjava/classpath/java/util/TreeMap.java
+++ b/libjava/classpath/java/util/TreeMap.java
@@ -1146,7 +1146,7 @@ public class TreeMap extends AbstractMap
*
* @param s the stream to read from
* @param count the number of keys to read
- * @param readValue true to read values, false to insert "" as the value
+ * @param readValues true to read values, false to insert "" as the value
* @throws ClassNotFoundException if the underlying stream fails
* @throws IOException if the underlying stream fails
* @see #readObject(ObjectInputStream)
diff --git a/libjava/classpath/java/util/WeakHashMap.java b/libjava/classpath/java/util/WeakHashMap.java
index 7593f7e330e..514ad8cd29f 100644
--- a/libjava/classpath/java/util/WeakHashMap.java
+++ b/libjava/classpath/java/util/WeakHashMap.java
@@ -241,7 +241,8 @@ public class WeakHashMap extends AbstractMap implements Map
// This method will get inlined.
cleanQueue();
if (knownMod != modCount)
- throw new ConcurrentModificationException();
+ throw new ConcurrentModificationException(knownMod + " != "
+ + modCount);
}
/**
@@ -698,21 +699,20 @@ public class WeakHashMap extends AbstractMap implements Map
// bucket may be enqueued later by the garbage collection, and
// internalRemove will be called a second time.
bucket.slot = -1;
- if (buckets[slot] == bucket)
- buckets[slot] = bucket.next;
- else
+
+ WeakBucket prev = null;
+ WeakBucket next = buckets[slot];
+ while (next != bucket)
{
- WeakBucket prev = buckets[slot];
- /* This may throw a NullPointerException. It shouldn't but if
- * a race condition occurred (two threads removing the same
- * bucket at the same time) it may happen. <br>
- * But with race condition many much worse things may happen
- * anyway.
- */
- while (prev.next != bucket)
- prev = prev.next;
- prev.next = bucket.next;
+ if (next == null) throw new InternalError("WeakHashMap in incosistent state");
+ prev = next;
+ next = prev.next;
}
+ if (prev == null)
+ buckets[slot] = bucket.next;
+ else
+ prev.next = bucket.next;
+
size--;
}
diff --git a/libjava/classpath/java/util/jar/Manifest.java b/libjava/classpath/java/util/jar/Manifest.java
index fdc76ff97ee..ff82aa2db96 100644
--- a/libjava/classpath/java/util/jar/Manifest.java
+++ b/libjava/classpath/java/util/jar/Manifest.java
@@ -80,10 +80,10 @@ public class Manifest implements Cloneable
/**
* Creates a Manifest from the supplied input stream.
*
- * @see read(Inputstream)
- * @see write(OutputStream)
+ * @see #read(InputStream)
+ * @see #write(OutputStream)
*
- * @param InputStream the input stream to read the manifest from
+ * @param in the input stream to read the manifest from
* @exception IOException when an i/o exception occurs or the input stream
* does not describe a valid manifest
*/
@@ -102,7 +102,7 @@ public class Manifest implements Cloneable
* a particular entry also changes the attributes of that entry in the
* original manifest.
*
- * @see clone()
+ * @see #clone()
* @param man the Manifest to copy from
*/
public Manifest(Manifest man)
diff --git a/libjava/classpath/java/util/logging/FileHandler.java b/libjava/classpath/java/util/logging/FileHandler.java
index 3d958b7d760..b03df97ec60 100644
--- a/libjava/classpath/java/util/logging/FileHandler.java
+++ b/libjava/classpath/java/util/logging/FileHandler.java
@@ -43,10 +43,6 @@ import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-
import java.util.LinkedList;
import java.util.ListIterator;
diff --git a/libjava/classpath/java/util/logging/Handler.java b/libjava/classpath/java/util/logging/Handler.java
index c3227d6f531..616b50234c4 100644
--- a/libjava/classpath/java/util/logging/Handler.java
+++ b/libjava/classpath/java/util/logging/Handler.java
@@ -191,8 +191,8 @@ h.setFormatter(h.getFormatter());</pre>
* Returns the character encoding which this handler uses for publishing
* log records.
*
- * @param encoding the name of a character encoding, or <code>null</code>
- * for the default platform encoding.
+ * @return the name of a character encoding, or <code>null</code>
+ * for the default platform encoding.
*/
public String getEncoding()
{
@@ -252,7 +252,7 @@ h.setFormatter(h.getFormatter());</pre>
* Sets the <code>Filter</code> for controlling which
* log records will be published by this <code>Handler</code>.
*
- * @return the <code>Filter</code> to use, or
+ * @param filter the <code>Filter</code> to use, or
* <code>null</code> to filter log records purely based
* on their severity level.
*/
diff --git a/libjava/classpath/java/util/logging/LogManager.java b/libjava/classpath/java/util/logging/LogManager.java
index 7e3fd97d01f..b62292f7978 100644
--- a/libjava/classpath/java/util/logging/LogManager.java
+++ b/libjava/classpath/java/util/logging/LogManager.java
@@ -664,7 +664,7 @@ public class LogManager
{
try
{
- return (new Boolean(getLogManager().getProperty(name))).booleanValue();
+ return (Boolean.valueOf(getLogManager().getProperty(name))).booleanValue();
}
catch (Exception ex)
{
@@ -682,7 +682,7 @@ public class LogManager
*
* @param defaultValue the value that will be returned if the
* property is not defined, or if
- * {@link Level.parse(java.lang.String)} does not like
+ * {@link Level#parse(java.lang.String)} does not like
* the property value.
*/
static Level getLevelProperty(String propertyName, Level defaultValue)
diff --git a/libjava/classpath/java/util/logging/LoggingPermission.java b/libjava/classpath/java/util/logging/LoggingPermission.java
index c7a2255ecea..1139a793a70 100644
--- a/libjava/classpath/java/util/logging/LoggingPermission.java
+++ b/libjava/classpath/java/util/logging/LoggingPermission.java
@@ -41,6 +41,8 @@ package java.util.logging;
public final class LoggingPermission
extends java.security.BasicPermission
{
+ private static final long serialVersionUID = 63564341580231582L;
+
/**
* Creates a new LoggingPermission.
*
diff --git a/libjava/classpath/java/util/logging/SimpleFormatter.java b/libjava/classpath/java/util/logging/SimpleFormatter.java
index f7a442792f9..ff53db8c055 100644
--- a/libjava/classpath/java/util/logging/SimpleFormatter.java
+++ b/libjava/classpath/java/util/logging/SimpleFormatter.java
@@ -85,7 +85,7 @@ public class SimpleFormatter
/**
* Formats a log record into a String.
*
- * @param the log record to be formatted.
+ * @param record the log record to be formatted.
*
* @return a short human-readable message, typically one or two
* lines. Lines are separated using the default platform line
diff --git a/libjava/classpath/java/util/logging/XMLFormatter.java b/libjava/classpath/java/util/logging/XMLFormatter.java
index 4dd63281727..8bd83ba3973 100644
--- a/libjava/classpath/java/util/logging/XMLFormatter.java
+++ b/libjava/classpath/java/util/logging/XMLFormatter.java
@@ -307,7 +307,7 @@ public class XMLFormatter
*
* @return a string for the header.
*
- * @param handler the handler which will prepend the returned
+ * @param h the handler which will prepend the returned
* string in front of the first log record. This method
* will inspect certain properties of the handler, for
* example its encoding, in order to construct the header.
diff --git a/libjava/classpath/java/util/prefs/Preferences.java b/libjava/classpath/java/util/prefs/Preferences.java
index c407ae6127a..3fee1c5da74 100644
--- a/libjava/classpath/java/util/prefs/Preferences.java
+++ b/libjava/classpath/java/util/prefs/Preferences.java
@@ -230,15 +230,15 @@ public abstract class Preferences {
}
/**
- * Returns the system preferences node for the package of an object.
- * The package node name of the object is determined by dropping the
- * class name of the object of the fully quallified class name and
- * replacing all '.' to '/' in the package name. If the class of the
+ * Returns the system preferences node for the package of a class.
+ * The package node name of the class is determined by dropping the
+ * final component of the fully qualified class name and
+ * changing all '.' to '/' in the package name. If the class of the
* object has no package then the package node name is "&lt;unnamed&gt;".
- * The returened node is <code>systemRoot().node(packageNodeName)</code>.
+ * The returned node is <code>systemRoot().node(packageNodeName)</code>.
*
- * @param o Object whose default system preference node is requested
- * @returns system preferences node that should be used by object o
+ * @param c Object whose default system preference node is requested
+ * @returns system preferences node that should be used by class c
* @exception SecurityException when a security manager is installed and
* the caller does not have <code>RuntimePermission("preferences")</code>.
*/
@@ -249,15 +249,15 @@ public abstract class Preferences {
}
/**
- * Returns the user preferences node for the package of an object.
- * The package node name of the object is determined by dropping the
- * class name of the object of the fully quallified class name and
- * replacing all '.' to '/' in the package name. If the class of the
+ * Returns the user preferences node for the package of a class.
+ * The package node name of the class is determined by dropping the
+ * final component of the fully qualified class name and
+ * changing all '.' to '/' in the package name. If the class of the
* object has no package then the package node name is "&lt;unnamed&gt;".
- * The returened node is <code>userRoot().node(packageNodeName)</code>.
+ * The returned node is <code>userRoot().node(packageNodeName)</code>.
*
- * @param o Object whose default user preference node is requested
- * @returns user preferences node that should be used by object o
+ * @param c Object whose default userpreference node is requested
+ * @returns userpreferences node that should be used by class c
* @exception SecurityException when a security manager is installed and
* the caller does not have <code>RuntimePermission("preferences")</code>.
*/
diff --git a/libjava/classpath/java/util/regex/Matcher.java b/libjava/classpath/java/util/regex/Matcher.java
index bd97ace54a8..5d04bdbfc2f 100644
--- a/libjava/classpath/java/util/regex/Matcher.java
+++ b/libjava/classpath/java/util/regex/Matcher.java
@@ -227,9 +227,9 @@ public final class Matcher
* If the match succeeds then more information can be obtained via the
* start, end, and group methods.
*
- * @see #start
- * @see #end
- * @see #group
+ * @see #start()
+ * @see #end()
+ * @see #group()
*/
public boolean matches ()
{
@@ -267,7 +267,7 @@ public final class Matcher
}
/**
- * @param group The index of a capturing group in this matcher's pattern
+ * @returns the index of a capturing group in this matcher's pattern
*
* @exception IllegalStateException If no match has yet been attempted,
* or if the previous match operation failed
diff --git a/libjava/classpath/java/util/zip/PendingBuffer.java b/libjava/classpath/java/util/zip/PendingBuffer.java
index dd7ed1008fb..9079b9804b7 100644
--- a/libjava/classpath/java/util/zip/PendingBuffer.java
+++ b/libjava/classpath/java/util/zip/PendingBuffer.java
@@ -183,7 +183,7 @@ class PendingBuffer
/**
* Flushes the pending buffer and returns that data in a new array
*
- * @param output the output stream
+ * @return the output stream
*/
public final byte[] toByteArray()
diff --git a/libjava/classpath/java/util/zip/ZipFile.java b/libjava/classpath/java/util/zip/ZipFile.java
index 0243abed1f8..4be845ea781 100644
--- a/libjava/classpath/java/util/zip/ZipFile.java
+++ b/libjava/classpath/java/util/zip/ZipFile.java
@@ -144,9 +144,18 @@ public class ZipFile implements ZipConstants
private void checkZipFile() throws IOException, ZipException
{
byte[] magicBuf = new byte[4];
- raf.read(magicBuf);
+ boolean validRead = true;
- if (readLeInt(magicBuf, 0) != LOCSIG)
+ try
+ {
+ raf.readFully(magicBuf);
+ }
+ catch (EOFException eof)
+ {
+ validRead = false;
+ }
+
+ if (validRead == false || readLeInt(magicBuf, 0) != LOCSIG)
{
raf.close();
throw new ZipException("Not a valid zip file");
@@ -377,7 +386,7 @@ public class ZipFile implements ZipConstants
* Checks that the ZipFile is still open and reads entries when necessary.
*
* @exception IllegalStateException when the ZipFile has already been closed.
- * @exception IOEexception when the entries could not be read.
+ * @exception IOException when the entries could not be read.
*/
private HashMap getEntries() throws IOException
{
@@ -395,7 +404,7 @@ public class ZipFile implements ZipConstants
/**
* Searches for a zip entry in this archive with the given name.
*
- * @param the name. May contain directory components separated by
+ * @param name the name. May contain directory components separated by
* slashes ('/').
* @return the zip entry, or null if no entry with that name exists.
*