aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java
diff options
context:
space:
mode:
authorMatthias Klose <doko@gcc.gnu.org>2007-08-04 10:53:49 +0000
committerMatthias Klose <doko@gcc.gnu.org>2007-08-04 10:53:49 +0000
commitf06a83c0b2f7761510836194a6c9a8a72000937c (patch)
tree871b70a606d87369d5aa9d6f621baedc13b49eba /libjava/classpath/java
parent2c3de459b647a72fc35d66adeda274ba0f14347b (diff)
downloadgcc-f06a83c0b2f7761510836194a6c9a8a72000937c.zip
gcc-f06a83c0b2f7761510836194a6c9a8a72000937c.tar.gz
gcc-f06a83c0b2f7761510836194a6c9a8a72000937c.tar.bz2
Import GNU Classpath (libgcj-import-20070727).
libjava/ 2007-08-04 Matthias Klose <doko@ubuntu.com> Import GNU Classpath (libgcj-import-20070727). * Regenerate class and header files. * Regenerate auto* files. * include/jvm.h: * jni-libjvm.cc (Jv_JNI_InvokeFunctions): Rename type. * jni.cc (_Jv_JNIFunctions, _Jv_JNI_InvokeFunctions): Likewise. * jni.cc (_Jv_JNI_CallAnyMethodA, _Jv_JNI_CallAnyVoidMethodA, _Jv_JNI_CallMethodA, _Jv_JNI_CallVoidMethodA, _Jv_JNI_CallStaticMethodA, _Jv_JNI_CallStaticVoidMethodA, _Jv_JNI_NewObjectA, _Jv_JNI_SetPrimitiveArrayRegion): Constify jvalue parameter. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Likewise. * java/lang/VMFloat.java (toString, parseFloat): New. * gnu/awt/xlib/XToolkit.java (setAlwaysOnTop, isModalityTypeSupported, isModalExclusionTypeSupported): New (stub only). * gnu/awt/xlib/XCanvasPeer.java (requestFocus): Likewise. * gnu/awt/xlib/XFramePeer.java (updateMinimumSize, updateIconImages, updateFocusableWindowState, setModalBlocked, getBoundsPrivate, setAlwaysOnTop): Likewise. * gnu/awt/xlib/XFontPeer.java (canDisplay): Update signature. * scripts/makemake.tcl: Ignore gnu/javax/sound/sampled/gstreamer, ignore javax.sound.sampled.spi.MixerProvider, ignore .in files. * HACKING: Mention --enable-gstreamer-peer, removal of generated files. libjava/classpath/ 2007-08-04 Matthias Klose <doko@ubuntu.com> * java/util/EnumMap.java (clone): Add cast. From-SVN: r127204
Diffstat (limited to 'libjava/classpath/java')
-rw-r--r--libjava/classpath/java/awt/AWTKeyStroke.java2
-rw-r--r--libjava/classpath/java/awt/AlphaComposite.java2
-rw-r--r--libjava/classpath/java/awt/Dialog.java15
-rw-r--r--libjava/classpath/java/awt/Font.java43
-rw-r--r--libjava/classpath/java/awt/Toolkit.java6
-rw-r--r--libjava/classpath/java/awt/event/MouseEvent.java95
-rw-r--r--libjava/classpath/java/awt/peer/ComponentPeer.java13
-rw-r--r--libjava/classpath/java/awt/peer/FramePeer.java3
-rw-r--r--libjava/classpath/java/awt/peer/RobotPeer.java2
-rw-r--r--libjava/classpath/java/awt/peer/WindowPeer.java9
-rw-r--r--libjava/classpath/java/io/ObjectStreamClass.java8
-rw-r--r--libjava/classpath/java/lang/Float.java10
-rw-r--r--libjava/classpath/java/lang/Integer.java7
-rw-r--r--libjava/classpath/java/lang/reflect/Array.java11
-rw-r--r--libjava/classpath/java/net/URLClassLoader.java10
-rw-r--r--libjava/classpath/java/nio/Buffer.java61
-rw-r--r--libjava/classpath/java/nio/CharBuffer.java15
-rw-r--r--libjava/classpath/java/nio/CharSequenceBuffer.java208
-rw-r--r--libjava/classpath/java/nio/CharViewBufferImpl.java2
-rw-r--r--libjava/classpath/java/nio/DoubleViewBufferImpl.java2
-rw-r--r--libjava/classpath/java/nio/FloatViewBufferImpl.java2
-rw-r--r--libjava/classpath/java/nio/IntViewBufferImpl.java2
-rw-r--r--libjava/classpath/java/nio/LongViewBufferImpl.java2
-rw-r--r--libjava/classpath/java/nio/ShortViewBufferImpl.java2
-rw-r--r--libjava/classpath/java/rmi/MarshalledObject.java8
-rw-r--r--libjava/classpath/java/rmi/activation/Activatable.java6
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationDesc.java12
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationGroup.java3
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationGroupDesc.java6
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationInstantiator.java2
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationMonitor.java2
-rw-r--r--libjava/classpath/java/rmi/activation/Activator.java2
-rw-r--r--libjava/classpath/java/util/Arrays.java3
-rw-r--r--libjava/classpath/java/util/Currency.java5
-rw-r--r--libjava/classpath/java/util/EnumMap.java19
35 files changed, 530 insertions, 70 deletions
diff --git a/libjava/classpath/java/awt/AWTKeyStroke.java b/libjava/classpath/java/awt/AWTKeyStroke.java
index e0b34e9..0fc4428 100644
--- a/libjava/classpath/java/awt/AWTKeyStroke.java
+++ b/libjava/classpath/java/awt/AWTKeyStroke.java
@@ -93,7 +93,7 @@ public class AWTKeyStroke implements Serializable
private static final int MAX_CACHE_SIZE = 2048;
/** Prune stale entries. */
- protected boolean removeEldestEntry(Entry<AWTKeyStroke,AWTKeyStroke>
+ protected boolean removeEldestEntry(Map.Entry<AWTKeyStroke,AWTKeyStroke>
eldest)
{
return size() > MAX_CACHE_SIZE;
diff --git a/libjava/classpath/java/awt/AlphaComposite.java b/libjava/classpath/java/awt/AlphaComposite.java
index 90df2e6..addd1e7 100644
--- a/libjava/classpath/java/awt/AlphaComposite.java
+++ b/libjava/classpath/java/awt/AlphaComposite.java
@@ -61,7 +61,7 @@ public final class AlphaComposite implements Composite
private static final int MAX_CACHE_SIZE = 2048;
/** Prune stale entries. */
- protected boolean removeEldestEntry(Entry eldest)
+ protected boolean removeEldestEntry(Map.Entry eldest)
{
return size() > MAX_CACHE_SIZE;
}
diff --git a/libjava/classpath/java/awt/Dialog.java b/libjava/classpath/java/awt/Dialog.java
index 7df2f52..83fb52d89 100644
--- a/libjava/classpath/java/awt/Dialog.java
+++ b/libjava/classpath/java/awt/Dialog.java
@@ -61,6 +61,21 @@ import javax.accessibility.AccessibleStateSet;
*/
public class Dialog extends Window
{
+ public enum ModalExclusionType
+ {
+ APPLICATION_EXCLUDE,
+ NO_EXCLUDE,
+ TOOLKIT_EXCLUDE
+ }
+
+ public enum ModalityType
+ {
+ APPLICATION_MODAL,
+ DOCUMENT_MODAL,
+ MODELESS,
+ TOOLKIT_MODAL
+ }
+
// Serialization constant
private static final long serialVersionUID = 5920926903803293709L;
diff --git a/libjava/classpath/java/awt/Font.java b/libjava/classpath/java/awt/Font.java
index 29b87d6..d6892a6 100644
--- a/libjava/classpath/java/awt/Font.java
+++ b/libjava/classpath/java/awt/Font.java
@@ -170,6 +170,31 @@ public class Font implements Serializable
public static final int LAYOUT_NO_LIMIT_CONTEXT = 4;
/**
+ * @since 1.6
+ */
+ public static final String DIALOG = "Dialog";
+
+ /**
+ * @since 1.6
+ */
+ public static final String DIALOG_INPUT = "DialogInput";
+
+ /**
+ * @since 1.6
+ */
+ public static final String MONOSPACED = "Monospaced";
+
+ /**
+ * @since 1.6
+ */
+ public static final String SANS_SERIF = "SansSerif";
+
+ /**
+ * @since 1.6
+ */
+ public static final String SERIF = "Serif";
+
+ /**
* The logical name of this font.
*
* @since 1.0
@@ -330,6 +355,11 @@ public class Font implements Serializable
return getFont(propname, (Font) null);
}
+ protected Font(Font font)
+ {
+ this(font.getName(), font.getAttributes());
+ }
+
/**
* Initializes a new instance of <code>Font</code> with the specified
* attributes.
@@ -491,7 +521,12 @@ public class Font implements Serializable
*/
public boolean canDisplay(char c)
{
- return peer.canDisplay(this, c);
+ return canDisplay((int) c);
+ }
+
+ public boolean canDisplay(int codePoint)
+ {
+ return peer.canDisplay(this, codePoint);
}
/**
@@ -1373,6 +1408,12 @@ public class Font implements Serializable
return getLineMetrics(str, 0, str.length() - 1, frc);
}
+ public boolean hasLayoutAttributes()
+ {
+ // TODO: Implement properly.
+ return false;
+ }
+
/**
* Reads the normal fields from the stream and then constructs the
* peer from the style and size through getPeerFromToolkit().
diff --git a/libjava/classpath/java/awt/Toolkit.java b/libjava/classpath/java/awt/Toolkit.java
index 305402e..b12e9e1 100644
--- a/libjava/classpath/java/awt/Toolkit.java
+++ b/libjava/classpath/java/awt/Toolkit.java
@@ -1287,6 +1287,12 @@ public abstract class Toolkit
public abstract Map<TextAttribute,?>
mapInputMethodHighlight(InputMethodHighlight highlight);
+ public abstract boolean isModalExclusionTypeSupported
+ (Dialog.ModalExclusionType modalExclusionType);
+
+ public abstract boolean isModalityTypeSupported
+ (Dialog.ModalityType modalityType);
+
/**
* Initializes the accessibility framework. In particular, this loads the
* properties javax.accessibility.screen_magnifier_present and
diff --git a/libjava/classpath/java/awt/event/MouseEvent.java b/libjava/classpath/java/awt/event/MouseEvent.java
index f2bcfbc..ad777e8 100644
--- a/libjava/classpath/java/awt/event/MouseEvent.java
+++ b/libjava/classpath/java/awt/event/MouseEvent.java
@@ -164,6 +164,16 @@ public class MouseEvent extends InputEvent
private int y;
/**
+ * The screen position of that mouse event, X coordinate.
+ */
+ private int absX;
+
+ /**
+ * The screen position of that mouse event, Y coordinate.
+ */
+ private int absY;
+
+ /**
* The number of clicks that took place. For MOUSE_CLICKED, MOUSE_PRESSED,
* and MOUSE_RELEASED, this will be at least 1; otherwise it is 0.
*
@@ -212,6 +222,7 @@ public class MouseEvent extends InputEvent
int button)
{
super(source, id, when, modifiers);
+
this.x = x;
this.y = y;
this.clickCount = clickCount;
@@ -234,6 +245,13 @@ public class MouseEvent extends InputEvent
this.modifiersEx &= ~(BUTTON1_DOWN_MASK
| BUTTON2_DOWN_MASK
| BUTTON3_DOWN_MASK);
+
+ if (source != null)
+ {
+ Point screenLoc = source.getLocationOnScreen();
+ absX = screenLoc.x + x;
+ absY = screenLoc.y + y;
+ }
}
/**
@@ -258,6 +276,59 @@ public class MouseEvent extends InputEvent
}
/**
+ * Creates a new MouseEvent. This is like the other constructors and adds
+ * specific absolute coordinates.
+ *
+ * @param source the source of the event
+ * @param id the event id
+ * @param when the timestamp of when the event occurred
+ * @param modifiers the modifier keys during the event, in old or new style
+ * @param x the X coordinate of the mouse point
+ * @param y the Y coordinate of the mouse point
+ * @param absX the absolute X screen coordinate of this event
+ * @param absY the absolute Y screen coordinate of this event
+ * @param clickCount the number of mouse clicks for this event
+ * @param popupTrigger true if this event triggers a popup menu
+ * @param button the most recent mouse button to change state
+ *
+ * @throws IllegalArgumentException if source is null or button is invalid
+ *
+ * @since 1.6
+ */
+ public MouseEvent(Component source, int id, long when, int modifiers,
+ int x, int y, int absX, int absY, int clickCount,
+ boolean popupTrigger, int button)
+ {
+ super(source, id, when, modifiers);
+
+ this.x = x;
+ this.y = y;
+ this.clickCount = clickCount;
+ this.popupTrigger = popupTrigger;
+ this.button = button;
+ if (button < NOBUTTON || button > BUTTON3)
+ throw new IllegalArgumentException();
+ if ((modifiers & EventModifier.OLD_MASK) != 0)
+ {
+ if ((modifiers & BUTTON1_MASK) != 0)
+ this.button = BUTTON1;
+ else if ((modifiers & BUTTON2_MASK) != 0)
+ this.button = BUTTON2;
+ else if ((modifiers & BUTTON3_MASK) != 0)
+ this.button = BUTTON3;
+ }
+ // clear the mouse button modifier masks if this is a button
+ // release event.
+ if (id == MOUSE_RELEASED)
+ this.modifiersEx &= ~(BUTTON1_DOWN_MASK
+ | BUTTON2_DOWN_MASK
+ | BUTTON3_DOWN_MASK);
+
+ this.absX = absX;
+ this.absY = absY;
+ }
+
+ /**
* This method returns the X coordinate of the mouse position. This is
* relative to the source component.
*
@@ -280,6 +351,30 @@ public class MouseEvent extends InputEvent
}
/**
+ * @since 1.6
+ */
+ public Point getLocationOnScreen()
+ {
+ return new Point(absX, absY);
+ }
+
+ /**
+ * @since 1.6
+ */
+ public int getXOnScreen()
+ {
+ return absX;
+ }
+
+ /**
+ * @since 1.6
+ */
+ public int getYOnScreen()
+ {
+ return absY;
+ }
+
+ /**
* This method returns a <code>Point</code> for the x,y position of
* the mouse pointer. This is relative to the source component.
*
diff --git a/libjava/classpath/java/awt/peer/ComponentPeer.java b/libjava/classpath/java/awt/peer/ComponentPeer.java
index bc6e3a4..b498ddf 100644
--- a/libjava/classpath/java/awt/peer/ComponentPeer.java
+++ b/libjava/classpath/java/awt/peer/ComponentPeer.java
@@ -59,6 +59,8 @@ import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
+import sun.awt.CausedFocusEvent;
+
/**
* Defines the methods that a component peer is required to implement.
*/
@@ -264,7 +266,7 @@ public interface ComponentPeer
/**
* Requests that this component receives the focus. This is called from
* {@link Component#requestFocus()}.
- *
+ *
* @specnote Part of the earlier 1.1 API, apparently replaced by argument
* form of the same method.
*/
@@ -518,4 +520,13 @@ public interface ComponentPeer
* @since 1.5
*/
void layout();
+
+
+ /**
+ * Requests the focus on the component.
+ */
+ boolean requestFocus(Component lightweightChild, boolean temporary,
+ boolean focusedWindowChangeAllowed, long time,
+ CausedFocusEvent.Cause cause);
+
}
diff --git a/libjava/classpath/java/awt/peer/FramePeer.java b/libjava/classpath/java/awt/peer/FramePeer.java
index 13435f8..9297914 100644
--- a/libjava/classpath/java/awt/peer/FramePeer.java
+++ b/libjava/classpath/java/awt/peer/FramePeer.java
@@ -71,5 +71,8 @@ public interface FramePeer extends WindowPeer
* @since 1.5
*/
void setBoundsPrivate(int x, int y, int width, int height);
+
+ Rectangle getBoundsPrivate();
+
} // interface FramePeer
diff --git a/libjava/classpath/java/awt/peer/RobotPeer.java b/libjava/classpath/java/awt/peer/RobotPeer.java
index db81c80..a11bfc7 100644
--- a/libjava/classpath/java/awt/peer/RobotPeer.java
+++ b/libjava/classpath/java/awt/peer/RobotPeer.java
@@ -50,5 +50,7 @@ public interface RobotPeer
void keyRelease (int keycode);
int getRGBPixel (int x, int y);
int[] getRGBPixels (Rectangle screen);
+ void dispose();
+
} // interface RobotPeer
diff --git a/libjava/classpath/java/awt/peer/WindowPeer.java b/libjava/classpath/java/awt/peer/WindowPeer.java
index 00d1035..e8b7d72 100644
--- a/libjava/classpath/java/awt/peer/WindowPeer.java
+++ b/libjava/classpath/java/awt/peer/WindowPeer.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.peer;
+import java.awt.Dialog;
+
public interface WindowPeer extends ContainerPeer
{
void toBack();
@@ -57,5 +59,12 @@ public interface WindowPeer extends ContainerPeer
* @since 1.5
*/
boolean requestWindowFocus();
+
+ void setAlwaysOnTop(boolean alwaysOnTop);
+ void updateFocusableWindowState();
+ void setModalBlocked(Dialog blocker, boolean blocked);
+ void updateMinimumSize();
+ void updateIconImages();
+
} // interface WindowPeer
diff --git a/libjava/classpath/java/io/ObjectStreamClass.java b/libjava/classpath/java/io/ObjectStreamClass.java
index cc3d0a9..1f3ba73 100644
--- a/libjava/classpath/java/io/ObjectStreamClass.java
+++ b/libjava/classpath/java/io/ObjectStreamClass.java
@@ -799,6 +799,14 @@ outer:
result = cache.longValue();
else
{
+ // Note that we can't use Class.isEnum() here, because that returns
+ // false for java.lang.Enum and enum value sub classes.
+ if (Enum.class.isAssignableFrom(cl) || Proxy.isProxyClass(cl))
+ {
+ // Spec says that enums and dynamic proxies have
+ // a serialVersionUID of 0L.
+ return 0L;
+ }
try
{
result = getClassUIDFromField(cl);
diff --git a/libjava/classpath/java/lang/Float.java b/libjava/classpath/java/lang/Float.java
index 1e85922..dc39ec2 100644
--- a/libjava/classpath/java/lang/Float.java
+++ b/libjava/classpath/java/lang/Float.java
@@ -181,7 +181,7 @@ public final class Float extends Number implements Comparable<Float>
*/
public static String toString(float f)
{
- return VMDouble.toString(f, true);
+ return VMFloat.toString(f);
}
/**
@@ -331,9 +331,9 @@ public final class Float extends Number implements Comparable<Float>
*
* @param str the <code>String</code> to convert
* @return the <code>float</code> value of <code>s</code>
- * @throws NumberFormatException if <code>s</code> cannot be parsed as a
+ * @throws NumberFormatException if <code>str</code> cannot be parsed as a
* <code>float</code>
- * @throws NullPointerException if <code>s</code> is null
+ * @throws NullPointerException if <code>str</code> is null
* @see #MIN_VALUE
* @see #MAX_VALUE
* @see #POSITIVE_INFINITY
@@ -342,9 +342,7 @@ public final class Float extends Number implements Comparable<Float>
*/
public static float parseFloat(String str)
{
- // XXX Rounding parseDouble() causes some errors greater than 1 ulp from
- // the infinitely precise decimal.
- return (float) Double.parseDouble(str);
+ return VMFloat.parseFloat(str);
}
/**
diff --git a/libjava/classpath/java/lang/Integer.java b/libjava/classpath/java/lang/Integer.java
index e38eb53..62907ff 100644
--- a/libjava/classpath/java/lang/Integer.java
+++ b/libjava/classpath/java/lang/Integer.java
@@ -705,10 +705,13 @@ public final class Integer extends Number implements Comparable<Integer>
if (len == 0)
throw new NumberFormatException("string length is null");
int ch = str.charAt(index);
- if (ch == '-')
+ if (ch == '-' || ch == '+')
{
if (len == 1)
- throw new NumberFormatException("pure '-'");
+ if (ch == '-')
+ throw new NumberFormatException("pure '-'");
+ else if (ch == '+')
+ throw new NumberFormatException("pure '+'");
isNeg = true;
ch = str.charAt(++index);
}
diff --git a/libjava/classpath/java/lang/reflect/Array.java b/libjava/classpath/java/lang/reflect/Array.java
index 373bf20..fee9f01 100644
--- a/libjava/classpath/java/lang/reflect/Array.java
+++ b/libjava/classpath/java/lang/reflect/Array.java
@@ -147,8 +147,7 @@ public final class Array
{
if (dimensions.length <= 0)
throw new IllegalArgumentException ("Empty dimensions array.");
- return createMultiArray(componentType, dimensions,
- dimensions.length - 1);
+ return createMultiArray(componentType, dimensions, 0);
}
/**
@@ -638,10 +637,10 @@ public final class Array
private static Object createMultiArray(Class type, int[] dimensions,
int index)
{
- if (index == 0)
- return newInstance(type, dimensions[0]);
+ if (index == dimensions.length - 1)
+ return newInstance(type, dimensions[index]);
- Object toAdd = createMultiArray(type, dimensions, index - 1);
+ Object toAdd = createMultiArray(type, dimensions, index + 1);
Class thisType = toAdd.getClass();
Object[] retval
= (Object[]) VMArray.createObjectArray(thisType, dimensions[index]);
@@ -649,7 +648,7 @@ public final class Array
retval[0] = toAdd;
int i = dimensions[index];
while (--i > 0)
- retval[i] = createMultiArray(type, dimensions, index - 1);
+ retval[i] = createMultiArray(type, dimensions, index + 1);
return retval;
}
diff --git a/libjava/classpath/java/net/URLClassLoader.java b/libjava/classpath/java/net/URLClassLoader.java
index 6df2818..346f51c 100644
--- a/libjava/classpath/java/net/URLClassLoader.java
+++ b/libjava/classpath/java/net/URLClassLoader.java
@@ -262,10 +262,9 @@ public class URLClassLoader extends SecureClassLoader
super(parent);
this.securityContext = null;
this.factory = factory;
- addURLs(urls);
-
- // If this factory is still not in factoryCache, add it.
+ // If this factory is not yet in factoryCache, add it.
factoryCache.add(factory);
+ addURLs(urls);
}
// Methods
@@ -624,10 +623,7 @@ public class URLClassLoader extends SecureClassLoader
}
catch (IOException ioe)
{
- ClassNotFoundException cnfe;
- cnfe = new ClassNotFoundException(className + " not found in " + this);
- cnfe.initCause(ioe);
- throw cnfe;
+ throw new ClassNotFoundException(className + " not found in " + this, ioe);
}
}
diff --git a/libjava/classpath/java/nio/Buffer.java b/libjava/classpath/java/nio/Buffer.java
index 2c7e00d..c2569ee 100644
--- a/libjava/classpath/java/nio/Buffer.java
+++ b/libjava/classpath/java/nio/Buffer.java
@@ -358,4 +358,65 @@ public abstract class Buffer
(arraylength < length + offset))
throw new IndexOutOfBoundsException ();
}
+
+ /**
+ * Returns the backing array of this buffer, if this buffer has one.
+ * Modification to the array are directly visible in this buffer and vice
+ * versa.
+ *
+ * <p>
+ * If this is a read-only buffer, then a {@link ReadOnlyBufferException} is
+ * thrown because exposing the array would allow to circumvent the read-only
+ * property. If this buffer doesn't have an array, then an
+ * {@link UnsupportedOperationException} is thrown. Applications should check
+ * if this buffer supports a backing array by calling {@link #hasArray}
+ * first.</p>
+ *
+ * @return the backing array of this buffer
+ *
+ * @throws ReadOnlyBufferException when this buffer is read only
+ * @throws UnsupportedOperationException when this buffer does not provide
+ * a backing array
+ *
+ * @since 1.6
+ */
+ public abstract Object array();
+
+ /**
+ * Returns <code>true</code> if this buffer can provide a backing array,
+ * <code>false</code> otherwise. When <code>true</code>, application code
+ * can call {@link #array()} to access this backing array.
+ *
+ * @return <code>true</code> if this buffer can provide a backing array,
+ * <code>false</code> otherwise
+ *
+ * @since 1.6
+ */
+ public abstract boolean hasArray();
+
+ /**
+ * For buffers that are backed by a Java array, this returns the offset
+ * into that array at which the buffer content starts.
+ *
+ * @return the offset into the backing array at which the buffer content
+ * starts
+ * @throws ReadOnlyBufferException when this buffer is read only
+ * @throws UnsupportedOperationException when this buffer does not provide
+ * a backing array
+ *
+ * @since 1.6
+ */
+ public abstract int arrayOffset();
+
+ /**
+ * Returns <code>true</code> when this buffer is direct, <code>false</code>
+ * otherwise. A direct buffer is usually backed by a raw memory area instead
+ * of a Java array.
+ *
+ * @return <code>true</code> when this buffer is direct, <code>false</code>
+ * otherwise
+ *
+ * @since 1.6
+ */
+ public abstract boolean isDirect();
}
diff --git a/libjava/classpath/java/nio/CharBuffer.java b/libjava/classpath/java/nio/CharBuffer.java
index 34f429f..2feada4 100644
--- a/libjava/classpath/java/nio/CharBuffer.java
+++ b/libjava/classpath/java/nio/CharBuffer.java
@@ -107,20 +107,7 @@ public abstract class CharBuffer extends Buffer
*/
public static final CharBuffer wrap(CharSequence seq, int start, int end)
{
- // FIXME: implement better handling of java.lang.String.
- // Probably share data with String via reflection.
-
- int len = end - start;
-
- if( len < 0 )
- throw new IndexOutOfBoundsException();
-
- char[] buffer = new char[len];
-
- for (int i = 0; i < len; i++)
- buffer[i] = seq.charAt(i + start);
-
- return wrap(buffer, 0, len).asReadOnlyBuffer();
+ return new CharSequenceBuffer(seq, start, end);
}
/**
diff --git a/libjava/classpath/java/nio/CharSequenceBuffer.java b/libjava/classpath/java/nio/CharSequenceBuffer.java
new file mode 100644
index 0000000..26aad1c
--- /dev/null
+++ b/libjava/classpath/java/nio/CharSequenceBuffer.java
@@ -0,0 +1,208 @@
+/* CharBuffer.java --
+ Copyright (C) 2007 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.nio;
+
+/**
+ * A CharBuffer that wraps a {@link CharSequence}.
+ */
+final class CharSequenceBuffer
+ extends CharBuffer
+{
+
+ /**
+ * The wrapped char sequence.
+ */
+ private CharSequence charSequence;
+
+ /**
+ * Creates a new CharSequenceBuffer.
+ *
+ * @param charSeq the CharSequence to wrap
+ * @param capacity the capacity
+ * @param limit the limit
+ * @param position the position
+ * @param mark the mark
+ * @param offs the offset
+ */
+ CharSequenceBuffer(CharSequence charSeq, int capacity, int limit,
+ int position, int mark, int offs)
+ {
+ super(capacity, limit, position, mark);
+ charSequence = charSeq;
+ array_offset = offs;
+ }
+
+ /**
+ * Creates a new instance of CharSequenceBuffer, wrapping the specified
+ * {@link CharSequence}.
+ *
+ * @param charSeq the char sequence to wrap
+ * @param start the start index in the char sequence
+ * @param end the end index in the char sequence
+ */
+ CharSequenceBuffer(CharSequence charSeq, int start, int end)
+ {
+ this(charSeq, charSeq.length(), end, start, -1, 0);
+ }
+
+ /**
+ * Returns a read-only view of this buffer.
+ */
+ public CharBuffer asReadOnlyBuffer()
+ {
+ return duplicate();
+ }
+
+ /**
+ * This buffer class is not writable by definition and thus throws
+ * a ReadOnlyBufferException here.
+ */
+ public CharBuffer compact()
+ {
+ throw new ReadOnlyBufferException();
+ }
+
+ /**
+ * Returns a duplicate of this buffer.
+ *
+ * @return a duplicate of this buffer
+ */
+ public CharBuffer duplicate()
+ {
+ return new CharSequenceBuffer(charSequence, cap, limit, pos, mark, 0);
+ }
+
+ /**
+ * Returns the character at the current position.
+ *
+ * @return the character at the current position
+ */
+ public char get()
+ {
+ if (pos >= limit)
+ throw new BufferUnderflowException();
+
+ return charSequence.charAt(array_offset + pos++);
+ }
+
+ /**
+ * Returns the character at the specified position.
+ *
+ * @return the character at the specified position
+ */
+ public char get(int index)
+ {
+ if (index < 0 || index >= limit)
+ throw new IndexOutOfBoundsException();
+
+ return charSequence.charAt(array_offset + index);
+ }
+
+ /**
+ * Cannot be direct, return <code>false</code> here.
+ *
+ * @return false
+ */
+ public boolean isDirect()
+ {
+ return false;
+ }
+
+ /**
+ * Returns the byte order of this buffer. This is always the native byte
+ * order.
+ *
+ * @return the byte order of this buffer
+ */
+ public ByteOrder order()
+ {
+ return ByteOrder.nativeOrder();
+ }
+
+ /**
+ * This buffer class is not writable by definition and thus throws
+ * a ReadOnlyBufferException here.
+ */
+ public CharBuffer put(char b)
+ {
+ throw new ReadOnlyBufferException();
+ }
+
+ /**
+ * This buffer class is not writable by definition and thus throws
+ * a ReadOnlyBufferException here.
+ */
+ public CharBuffer put(int index, char b)
+ {
+ throw new ReadOnlyBufferException();
+ }
+
+ /**
+ * Returns a slice of this buffer, exposing the current position and limit.
+ */
+ public CharBuffer slice()
+ {
+ int newCapacity = limit - pos;
+ return new CharSequenceBuffer(charSequence, newCapacity, newCapacity, 0,
+ -1, pos);
+ }
+
+ /**
+ * Returns a sub sequence from the specified start index and with the
+ * specified length.
+ *
+ * @param start the start index
+ * @param length the length of the sub sequence
+ */
+ public CharSequence subSequence(int start, int length)
+ {
+ int begin = array_offset + start + pos;
+ return charSequence.subSequence(begin, begin + length);
+ }
+
+ /**
+ * This kind of CharBuffer is read-only, so we return <code>true</code>
+ * here.
+ */
+ public boolean isReadOnly()
+ {
+ return true;
+ }
+
+}
diff --git a/libjava/classpath/java/nio/CharViewBufferImpl.java b/libjava/classpath/java/nio/CharViewBufferImpl.java
index 3198315..33bbac8 100644
--- a/libjava/classpath/java/nio/CharViewBufferImpl.java
+++ b/libjava/classpath/java/nio/CharViewBufferImpl.java
@@ -133,7 +133,7 @@ class CharViewBufferImpl extends CharBuffer
public CharBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
- return new CharViewBufferImpl (bb, (position () >> 1) + offset,
+ return new CharViewBufferImpl (bb, (position () << 1) + offset,
remaining (), remaining (), 0, -1,
isReadOnly (), endian);
}
diff --git a/libjava/classpath/java/nio/DoubleViewBufferImpl.java b/libjava/classpath/java/nio/DoubleViewBufferImpl.java
index e860f2f..d139915 100644
--- a/libjava/classpath/java/nio/DoubleViewBufferImpl.java
+++ b/libjava/classpath/java/nio/DoubleViewBufferImpl.java
@@ -130,7 +130,7 @@ final class DoubleViewBufferImpl extends DoubleBuffer
public DoubleBuffer slice ()
{
- return new DoubleViewBufferImpl (bb, (position () >> 3) + offset,
+ return new DoubleViewBufferImpl (bb, (position () << 3) + offset,
remaining(), remaining(), 0, -1,
readOnly, endian);
}
diff --git a/libjava/classpath/java/nio/FloatViewBufferImpl.java b/libjava/classpath/java/nio/FloatViewBufferImpl.java
index 55770d5..8bb342d 100644
--- a/libjava/classpath/java/nio/FloatViewBufferImpl.java
+++ b/libjava/classpath/java/nio/FloatViewBufferImpl.java
@@ -131,7 +131,7 @@ final class FloatViewBufferImpl extends FloatBuffer
public FloatBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
- return new FloatViewBufferImpl (bb, (position () >> 2) + offset,
+ return new FloatViewBufferImpl (bb, (position () << 2) + offset,
remaining(), remaining(), 0, -1,
readOnly, endian);
}
diff --git a/libjava/classpath/java/nio/IntViewBufferImpl.java b/libjava/classpath/java/nio/IntViewBufferImpl.java
index d0b0057..cd8307f 100644
--- a/libjava/classpath/java/nio/IntViewBufferImpl.java
+++ b/libjava/classpath/java/nio/IntViewBufferImpl.java
@@ -131,7 +131,7 @@ final class IntViewBufferImpl extends IntBuffer
public IntBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
- return new IntViewBufferImpl (bb, (position () >> 2) + offset,
+ return new IntViewBufferImpl (bb, (position () << 2) + offset,
remaining(), remaining(), 0, -1,
readOnly, endian);
}
diff --git a/libjava/classpath/java/nio/LongViewBufferImpl.java b/libjava/classpath/java/nio/LongViewBufferImpl.java
index 9c3452a..eefbcbd 100644
--- a/libjava/classpath/java/nio/LongViewBufferImpl.java
+++ b/libjava/classpath/java/nio/LongViewBufferImpl.java
@@ -131,7 +131,7 @@ final class LongViewBufferImpl extends LongBuffer
public LongBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
- return new LongViewBufferImpl (bb, (position () >> 3) + offset,
+ return new LongViewBufferImpl (bb, (position () << 3) + offset,
remaining(), remaining(), 0, -1,
readOnly, endian);
}
diff --git a/libjava/classpath/java/nio/ShortViewBufferImpl.java b/libjava/classpath/java/nio/ShortViewBufferImpl.java
index cdd5595..df713361 100644
--- a/libjava/classpath/java/nio/ShortViewBufferImpl.java
+++ b/libjava/classpath/java/nio/ShortViewBufferImpl.java
@@ -131,7 +131,7 @@ final class ShortViewBufferImpl extends ShortBuffer
public ShortBuffer slice ()
{
// Create a sliced copy of this object that shares its content.
- return new ShortViewBufferImpl (bb, (position () >> 1) + offset,
+ return new ShortViewBufferImpl (bb, (position () << 1) + offset,
remaining(), remaining(), 0, -1,
readOnly, endian);
}
diff --git a/libjava/classpath/java/rmi/MarshalledObject.java b/libjava/classpath/java/rmi/MarshalledObject.java
index e1a30f5..180c0a9 100644
--- a/libjava/classpath/java/rmi/MarshalledObject.java
+++ b/libjava/classpath/java/rmi/MarshalledObject.java
@@ -58,7 +58,7 @@ import java.io.Serializable;
*
* @author unknown
*/
-public final class MarshalledObject
+public final class MarshalledObject<T>
implements Serializable
{
// The following fields are from Java API Documentation "Serialized form"
@@ -74,7 +74,7 @@ public final class MarshalledObject
* @param obj the object to marshal
* @throws IOException if an I/O error during serialization occurs.
*/
- public MarshalledObject(Object obj) throws IOException
+ public MarshalledObject(T obj) throws IOException
{
ByteArrayOutputStream objStream = new ByteArrayOutputStream();
RMIMarshalledObjectOutputStream stream =
@@ -136,14 +136,14 @@ public final class MarshalledObject
* @throws ClassNotFoundException if the class of the deserialized object
* cannot be found.
*/
- public Object get() throws IOException, ClassNotFoundException
+ public T get() throws IOException, ClassNotFoundException
{
if (objBytes == null)
return null;
RMIMarshalledObjectInputStream stream =
new RMIMarshalledObjectInputStream(objBytes, locBytes);
- return stream.readObject();
+ return (T) stream.readObject();
}
public int hashCode()
diff --git a/libjava/classpath/java/rmi/activation/Activatable.java b/libjava/classpath/java/rmi/activation/Activatable.java
index 472c65c..0f201ca 100644
--- a/libjava/classpath/java/rmi/activation/Activatable.java
+++ b/libjava/classpath/java/rmi/activation/Activatable.java
@@ -103,7 +103,7 @@ public abstract class Activatable
* @throws ActivationException if the activation failed
* @throws RemoteException if the remote call failed.
*/
- protected Activatable(String codebase, MarshalledObject data,
+ protected Activatable(String codebase, MarshalledObject<?> data,
boolean restart, int port) throws ActivationException,
RemoteException
{
@@ -133,7 +133,7 @@ public abstract class Activatable
* @throws ActivationException if the activation failed
* @throws RemoteException if the remote call failed.
*/
- protected Activatable(String codebase, MarshalledObject data,
+ protected Activatable(String codebase, MarshalledObject<?> data,
boolean restart, int port, RMIClientSocketFactory csf,
RMIServerSocketFactory ssf) throws ActivationException,
RemoteException
@@ -314,7 +314,7 @@ public abstract class Activatable
* @throws RemoteException if the registration or export fails
*/
public static ActivationID exportObject(Remote obj, String location,
- MarshalledObject data,
+ MarshalledObject<?> data,
boolean restart, int port)
throws ActivationException, RemoteException
{
diff --git a/libjava/classpath/java/rmi/activation/ActivationDesc.java b/libjava/classpath/java/rmi/activation/ActivationDesc.java
index b861656..ae2b78e 100644
--- a/libjava/classpath/java/rmi/activation/ActivationDesc.java
+++ b/libjava/classpath/java/rmi/activation/ActivationDesc.java
@@ -80,7 +80,7 @@ public final class ActivationDesc
/**
* The object specific intitalization data.
*/
- private MarshalledObject data;
+ private MarshalledObject<?> data;
/**
* The start mode.
@@ -95,7 +95,7 @@ public final class ActivationDesc
* @param location the code base URL
* @param data the object initialization data, contained in a marshalled form
*/
- public ActivationDesc(String className, String location, MarshalledObject data)
+ public ActivationDesc(String className, String location, MarshalledObject<?> data)
throws ActivationException
{
this(ActivationGroup.currentGroupID(), className, location, data, false);
@@ -115,7 +115,7 @@ public final class ActivationDesc
* object is normally activated on demand).
*/
public ActivationDesc(String className, String location,
- MarshalledObject data, boolean restart)
+ MarshalledObject<?> data, boolean restart)
throws ActivationException
{
this(ActivationGroup.currentGroupID(), className, location, data, restart);
@@ -131,7 +131,7 @@ public final class ActivationDesc
* @param data the object initialization data, contained in a marshalled form
*/
public ActivationDesc(ActivationGroupID groupID, String className,
- String location, MarshalledObject data)
+ String location, MarshalledObject<?> data)
{
this(groupID, className, location, data, false);
}
@@ -150,7 +150,7 @@ public final class ActivationDesc
* object is normally activated on demand).
*/
public ActivationDesc(ActivationGroupID groupID, String className,
- String location, MarshalledObject data, boolean restart)
+ String location, MarshalledObject<?> data, boolean restart)
{
this.groupid = groupID;
this.classname = className;
@@ -184,7 +184,7 @@ public final class ActivationDesc
return location;
}
- public MarshalledObject getData()
+ public MarshalledObject<?> getData()
{
return data;
}
diff --git a/libjava/classpath/java/rmi/activation/ActivationGroup.java b/libjava/classpath/java/rmi/activation/ActivationGroup.java
index 5e7bbd2..ad5a05d 100644
--- a/libjava/classpath/java/rmi/activation/ActivationGroup.java
+++ b/libjava/classpath/java/rmi/activation/ActivationGroup.java
@@ -314,7 +314,8 @@ public abstract class ActivationGroup
* @throws UnknownObjectException if such object is not registered
* @throws RemoteException on remote call (to monitor) error
*/
- protected void activeObject(ActivationID id, MarshalledObject mObject)
+ protected void activeObject(ActivationID id,
+ MarshalledObject<? extends Remote> mObject)
throws ActivationException, UnknownObjectException, RemoteException
{
if (monitor!=null)
diff --git a/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java b/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java
index 76ac63b..bf7445f 100644
--- a/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java
+++ b/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java
@@ -199,7 +199,7 @@ public final class ActivationGroupDesc
/**
* The group initialization data.
*/
- final MarshalledObject data;
+ final MarshalledObject<?> data;
/**
* The path to the group jre and the parameters of this jre, may be
@@ -252,7 +252,7 @@ public final class ActivationGroupDesc
* options.
*/
public ActivationGroupDesc(String aClassName, String aLocation,
- MarshalledObject aData, Properties aProperties,
+ MarshalledObject<?> aData, Properties aProperties,
ActivationGroupDesc.CommandEnvironment environment)
{
className = aClassName;
@@ -288,7 +288,7 @@ public final class ActivationGroupDesc
*
* @return the group intialization data in the marshalled form.
*/
- public MarshalledObject getData()
+ public MarshalledObject<?> getData()
{
return data;
}
diff --git a/libjava/classpath/java/rmi/activation/ActivationInstantiator.java b/libjava/classpath/java/rmi/activation/ActivationInstantiator.java
index a0f04ed..3f4b557 100644
--- a/libjava/classpath/java/rmi/activation/ActivationInstantiator.java
+++ b/libjava/classpath/java/rmi/activation/ActivationInstantiator.java
@@ -68,6 +68,6 @@ public interface ActivationInstantiator
* @throws ActivationException if the activation fails
* @throws RemoteException if the remote call fails
*/
- MarshalledObject newInstance (ActivationID id, ActivationDesc desc)
+ MarshalledObject<? extends Remote> newInstance (ActivationID id, ActivationDesc desc)
throws ActivationException, RemoteException;
}
diff --git a/libjava/classpath/java/rmi/activation/ActivationMonitor.java b/libjava/classpath/java/rmi/activation/ActivationMonitor.java
index e9f43ae..93def8c 100644
--- a/libjava/classpath/java/rmi/activation/ActivationMonitor.java
+++ b/libjava/classpath/java/rmi/activation/ActivationMonitor.java
@@ -59,7 +59,7 @@ public interface ActivationMonitor extends Remote
* @throws UnknownObjectException is such object is not known in this group
* @throws RemoteException if remote call fails
*/
- void activeObject (ActivationID id, MarshalledObject obj)
+ void activeObject (ActivationID id, MarshalledObject<? extends Remote> obj)
throws UnknownObjectException, RemoteException;
/**
diff --git a/libjava/classpath/java/rmi/activation/Activator.java b/libjava/classpath/java/rmi/activation/Activator.java
index 57a4d16..d0de12d 100644
--- a/libjava/classpath/java/rmi/activation/Activator.java
+++ b/libjava/classpath/java/rmi/activation/Activator.java
@@ -67,6 +67,6 @@ public interface Activator
* @throws ActivationException if the activation has failed due other reason
* @throws RemoteException if the remote call has failed.
*/
- MarshalledObject activate (ActivationID id, boolean force)
+ MarshalledObject<? extends Remote> activate (ActivationID id, boolean force)
throws ActivationException, UnknownObjectException, RemoteException;
}
diff --git a/libjava/classpath/java/util/Arrays.java b/libjava/classpath/java/util/Arrays.java
index 9443ced..e5f7727 100644
--- a/libjava/classpath/java/util/Arrays.java
+++ b/libjava/classpath/java/util/Arrays.java
@@ -3941,7 +3941,8 @@ public class Arrays
if (from > to)
throw new IllegalArgumentException("The initial index is after " +
"the final index.");
- T[] newArray = (T[]) new Object[to - from];
+ Class elemType = original.getClass().getComponentType();
+ T[] newArray = (T[]) Array.newInstance(elemType, to - from);
if (to > original.length)
{
System.arraycopy(original, from, newArray, 0,
diff --git a/libjava/classpath/java/util/Currency.java b/libjava/classpath/java/util/Currency.java
index a0933ec..b5da13c 100644
--- a/libjava/classpath/java/util/Currency.java
+++ b/libjava/classpath/java/util/Currency.java
@@ -273,6 +273,11 @@ public final class Currency
throw new
NullPointerException("The locale or its country is null.");
}
+
+ /* Check that country of locale given is valid. */
+ if (country.length() != 2)
+ throw new IllegalArgumentException();
+
/* Attempt to get the currency from the cache */
String code = (String) countryMap.get(country);
if (code == null)
diff --git a/libjava/classpath/java/util/EnumMap.java b/libjava/classpath/java/util/EnumMap.java
index 477dff8..b7187b9 100644
--- a/libjava/classpath/java/util/EnumMap.java
+++ b/libjava/classpath/java/util/EnumMap.java
@@ -1,5 +1,5 @@
/* EnumMap.java - Map where keys are enum constants
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -140,7 +140,8 @@ public class EnumMap<K extends Enum<K>, V>
Enum<K> e = (Enum<K>) key;
if (e.getDeclaringClass() != enumClass)
return null;
- return store[e.ordinal()];
+ V o = store[e.ordinal()];
+ return o == emptySlot ? null : o;
}
public V put(K key, V value)
@@ -387,8 +388,18 @@ public class EnumMap<K extends Enum<K>, V>
public EnumMap<K, V> clone()
{
- /* This constructor provides this functionality */
- return new EnumMap(this);
+ EnumMap<K, V> result;
+ try
+ {
+ result = (EnumMap<K, V>) super.clone();
+ }
+ catch (CloneNotSupportedException ignore)
+ {
+ // Can't happen.
+ result = null;
+ }
+ result.store = (V[]) store.clone();
+ return result;
}
}