summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-10 19:35:37 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-12-10 19:35:37 +0000
commitf4b2de8ebb01a1e4a906682edaa17785fff813c9 (patch)
treecaae0a89736a380f7879b2181ad999725ac83f5b /java
parentd1b6fb1ce48424b1eb608f8432a758627a3ba25d (diff)
downloadclasspath-generics-stoppoint.tar.gz
2006-12-10 Andrew John Hughes <gnu_andrew@member.fsf.org>generics-stoppoint
* Merge of HEAD-->generics-branch for classpath-0.93-branch-point to generics-mergepoint
Diffstat (limited to 'java')
-rw-r--r--java/awt/BasicStroke.java10
-rw-r--r--java/awt/ScrollPane.java26
-rw-r--r--java/awt/geom/Arc2D.java44
-rw-r--r--java/awt/geom/RectangularShape.java5
-rw-r--r--java/lang/management/ManagementFactory.java175
-rw-r--r--java/net/URLConnection.java57
6 files changed, 286 insertions, 31 deletions
diff --git a/java/awt/BasicStroke.java b/java/awt/BasicStroke.java
index e6cb87e34..ef6a7f0b7 100644
--- a/java/awt/BasicStroke.java
+++ b/java/awt/BasicStroke.java
@@ -761,9 +761,13 @@ public class BasicStroke implements Stroke
p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
dx = p1[0] - p0[0];
dy = p1[1] - p0[1];
- l = Math.sqrt(dx * dx + dy * dy);
- dx = (2.0/3.0)*width*dx/l;
- dy = (2.0/3.0)*width*dy/l;
+ if (dx != 0 && dy != 0)
+ {
+ l = Math.sqrt(dx * dx + dy * dy);
+ dx = (2.0/3.0)*width*dx/l;
+ dy = (2.0/3.0)*width*dy/l;
+ }
+
c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);
c2 = new Point2D.Double(b.P1.getX() + dx, b.P1.getY() + dy);
a.add(new CubicSegment(a.last.P2, c1, c2, b.P1));
diff --git a/java/awt/ScrollPane.java b/java/awt/ScrollPane.java
index 35a81300d..ec9746f93 100644
--- a/java/awt/ScrollPane.java
+++ b/java/awt/ScrollPane.java
@@ -338,10 +338,15 @@ getVScrollbarWidth()
* Returns the current scroll position of the viewport.
*
* @return The current scroll position of the viewport.
+ *
+ * @throws NullPointerException if the scrollpane does have a child.
*/
public Point
getScrollPosition()
{
+ if (getComponentCount() == 0)
+ throw new NullPointerException();
+
int x = 0;
int y = 0;
@@ -380,20 +385,35 @@ setScrollPosition(Point scrollPosition) throws IllegalArgumentException
* @param x The new X coordinate of the scroll position.
* @param y The new Y coordinate of the scroll position.
*
+ * @throws NullPointerException if scrollpane does not have a child.
+ *
* @exception IllegalArgumentException If the specified value is outside
* the legal scrolling range.
*/
public void
setScrollPosition(int x, int y)
{
+ if (getComponentCount() == 0)
+ throw new NullPointerException("child is null");
+
+ if (x > (int) (getComponent(0).getWidth() - getViewportSize().getWidth()))
+ x = (int) (getComponent(0).getWidth() - getViewportSize().getWidth());
+ if (y > (int) (getComponent(0).getHeight() - getViewportSize().getHeight()))
+ y = (int) (getComponent(0).getHeight() - getViewportSize().getHeight());
+
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
Adjustable h = getHAdjustable();
Adjustable v = getVAdjustable();
-
+
if (h != null)
h.setValue(x);
if (v != null)
v.setValue(y);
-
+
ScrollPanePeer spp = (ScrollPanePeer)getPeer();
if (spp != null)
spp.setScrollPosition(x, y);
@@ -505,6 +525,8 @@ layout()
p.y = dim.height;
setScrollPosition (p);
+
+ list[0].setLocation(new Point());
}
}
diff --git a/java/awt/geom/Arc2D.java b/java/awt/geom/Arc2D.java
index eff34a081..8d5b01cd5 100644
--- a/java/awt/geom/Arc2D.java
+++ b/java/awt/geom/Arc2D.java
@@ -774,14 +774,9 @@ public abstract class Arc2D extends RectangularShape
y = a.getY();
w = a.getWidth();
h = a.getHeight();
- double start = a.getAngleStart() * (Math.PI / 180);
- double extent = a.getAngleExtent() * (Math.PI / 180);
+ double start = Math.toRadians(a.getAngleStart());
+ double extent = Math.toRadians(a.getAngleExtent());
- if (extent < 0)
- {
- extent = -extent;
- start = 2 * Math.PI - extent + start;
- }
this.start = start;
this.extent = extent;
@@ -790,11 +785,11 @@ public abstract class Arc2D extends RectangularShape
limit = -1;
else if (extent == 0)
limit = type;
- else if (extent <= Math.PI / 2.0)
+ else if (Math.abs(extent) <= Math.PI / 2.0)
limit = type + 1;
- else if (extent <= Math.PI)
+ else if (Math.abs(extent) <= Math.PI)
limit = type + 2;
- else if (extent <= 3.0 * (Math.PI / 2.0))
+ else if (Math.abs(extent) <= 3.0 * (Math.PI / 2.0))
limit = type + 3;
else
limit = type + 4;
@@ -909,9 +904,20 @@ public abstract class Arc2D extends RectangularShape
double kappa = (Math.sqrt(2.0) - 1.0) * (4.0 / 3.0);
double quad = (Math.PI / 2.0);
- double curr_begin = start + (current - 1) * quad;
- double curr_extent = Math.min((start + extent) - curr_begin, quad);
- double portion_of_a_quadrant = curr_extent / quad;
+ double curr_begin;
+ double curr_extent;
+ if (extent > 0)
+ {
+ curr_begin = start + (current - 1) * quad;
+ curr_extent = Math.min((start + extent) - curr_begin, quad);
+ }
+ else
+ {
+ curr_begin = start - (current - 1) * quad;
+ curr_extent = Math.max((start + extent) - curr_begin, -quad);
+ }
+
+ double portion_of_a_quadrant = Math.abs(curr_extent / quad);
double x0 = xmid + rx * Math.cos(curr_begin);
double y0 = ymid - ry * Math.sin(curr_begin);
@@ -932,7 +938,11 @@ public abstract class Arc2D extends RectangularShape
// will *subtract* the y value of this control vector from our first
// point.
cvec[0] = 0;
- cvec[1] = len;
+ if (extent > 0)
+ cvec[1] = len;
+ else
+ cvec[1] = -len;
+
trans.scale(rx, ry);
trans.rotate(angle);
trans.transform(cvec, 0, cvec, 0, 1);
@@ -942,7 +952,11 @@ public abstract class Arc2D extends RectangularShape
// control vector #2 would, ideally, be sticking out and to the
// right, in a first quadrant arc segment. again, subtraction of y.
cvec[0] = 0;
- cvec[1] = -len;
+ if (extent > 0)
+ cvec[1] = -len;
+ else
+ cvec[1] = len;
+
trans.rotate(curr_extent);
trans.transform(cvec, 0, cvec, 0, 1);
coords[2] = x1 + cvec[0];
diff --git a/java/awt/geom/RectangularShape.java b/java/awt/geom/RectangularShape.java
index 8f66dabf2..3ee161541 100644
--- a/java/awt/geom/RectangularShape.java
+++ b/java/awt/geom/RectangularShape.java
@@ -326,15 +326,12 @@ public abstract class RectangularShape implements Shape, Cloneable
/**
* Returns a bounding box for this shape, in integer format. Notice that you
- * may get a tighter bound with getBounds2D. If the frame is empty, the
- * box is the default empty box at the origin.
+ * may get a tighter bound with getBounds2D.
*
* @return a bounding box
*/
public Rectangle getBounds()
{
- if (isEmpty())
- return new Rectangle();
double x = getX();
double y = getY();
double maxx = Math.ceil(x + getWidth());
diff --git a/java/lang/management/ManagementFactory.java b/java/lang/management/ManagementFactory.java
index d9a02ee23..a51ca0f4c 100644
--- a/java/lang/management/ManagementFactory.java
+++ b/java/lang/management/ManagementFactory.java
@@ -50,9 +50,18 @@ import gnu.java.lang.management.RuntimeMXBeanImpl;
import gnu.java.lang.management.ThreadMXBeanImpl;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.logging.LogManager;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
/**
* <p>
@@ -66,6 +75,11 @@ import javax.management.NotCompliantMBeanException;
* <ol>
* <li>Calling the appropriate static method of this factory.
* </li>
+ * <li>Using the platform {@link javax.management.MBeanServer}
+ * to access the beans locally, or an
+ * {@link javax.management.MBeanServerConnection} for remote
+ * access. The attributes and operations use the limited
+ * range of data types specified below.</li>
* </ol>
* <h2>Open Data Types</h2>
* <p>
@@ -118,6 +132,60 @@ public class ManagementFactory
{
/**
+ * The object name for the class loading bean.
+ */
+ public static final String CLASS_LOADING_MXBEAN_NAME =
+ "java.lang:type=ClassLoading";
+
+ /**
+ * The object name for the compilation bean.
+ */
+ public static final String COMPILATION_MXBEAN_NAME =
+ "java.lang:type=Compilation";
+
+ /**
+ * The domain for the garbage collecting beans.
+ */
+ public static final String GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE =
+ "java.lang:type=GarbageCollector";
+
+ /**
+ * The domain for the memory manager beans.
+ */
+ public static final String MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE =
+ "java.lang:type=MemoryManager";
+
+ /**
+ * The object name for the memory bean.
+ */
+ public static final String MEMORY_MXBEAN_NAME =
+ "java.lang:type=Memory";
+
+ /**
+ * The domain for the memory pool beans.
+ */
+ public static final String MEMORY_POOL_MXBEAN_DOMAIN_TYPE =
+ "java.lang:type=MemoryPool";
+
+ /**
+ * The object name for the operating system bean.
+ */
+ public static final String OPERATING_SYSTEM_MXBEAN_NAME =
+ "java.lang:type=OperatingSystem";
+
+ /**
+ * The object name for the runtime bean.
+ */
+ public static final String RUNTIME_MXBEAN_NAME =
+ "java.lang:type=Runtime";
+
+ /**
+ * The object name for the threading bean.
+ */
+ public static final String THREAD_MXBEAN_NAME =
+ "java.lang:type=Threading";
+
+ /**
* The operating system management bean.
*/
private static OperatingSystemMXBean osBean;
@@ -148,6 +216,11 @@ public class ManagementFactory
private static CompilationMXBean compilationBean;
/**
+ * The platform server.
+ */
+ private static MBeanServer platformServer;
+
+ /**
* Private constructor to prevent instance creation.
*/
private ManagementFactory() {}
@@ -374,4 +447,106 @@ public class ManagementFactory
return gcBeans;
}
+ /**
+ * <p>
+ * Returns the platform {@link javax.management.MBeanServer}. On the
+ * first call to this method, a server instance is retrieved from
+ * the {@link javax.management.MBeanServerFactory} and each of the
+ * beans are registered with it. Subsequent calls return the existing
+ * instance. If the property <code>javax.management.builder.initial</code>
+ * is set, its value will be used as the name of the class which is used
+ * to provide the server instance.
+ * </p>
+ * <p>
+ * It is recommended that the platform server is used for other beans as
+ * well, in order to simplify their discovery and publication. Name conflicts
+ * should be avoided.
+ * </p>
+ *
+ * @return the platform {@link javax.management.MBeanServer}
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanServerPermission(String)}("createMBeanServer")
+ * @see javax.management.MBeanServerFactory
+ * @see javax.management.MBeanServerFactory#createMBeanServer()
+ */
+ public static MBeanServer getPlatformMBeanServer()
+ {
+ if (platformServer == null)
+ {
+ platformServer = MBeanServerFactory.createMBeanServer();
+ try
+ {
+ platformServer.registerMBean(getOperatingSystemMXBean(),
+ new ObjectName(OPERATING_SYSTEM_MXBEAN_NAME));
+ platformServer.registerMBean(getRuntimeMXBean(),
+ new ObjectName(RUNTIME_MXBEAN_NAME));
+ platformServer.registerMBean(getClassLoadingMXBean(),
+ new ObjectName(CLASS_LOADING_MXBEAN_NAME));
+ platformServer.registerMBean(getThreadMXBean(),
+ new ObjectName(THREAD_MXBEAN_NAME));
+ platformServer.registerMBean(getMemoryMXBean(),
+ new ObjectName(MEMORY_MXBEAN_NAME));
+ CompilationMXBean compBean = getCompilationMXBean();
+ if (compBean != null)
+ platformServer.registerMBean(compBean,
+ new ObjectName(COMPILATION_MXBEAN_NAME));
+ Iterator beans = getMemoryPoolMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();
+ platformServer.registerMBean(bean,
+ new ObjectName(MEMORY_POOL_MXBEAN_DOMAIN_TYPE +
+ ",name=" +
+ bean.getName()));
+ }
+ beans = getMemoryManagerMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ MemoryManagerMXBean bean = (MemoryManagerMXBean) beans.next();
+ platformServer.registerMBean(bean,
+ new ObjectName(MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE +
+ ",name=" +
+ bean.getName()));
+ }
+ beans = getGarbageCollectorMXBeans().iterator();
+ while (beans.hasNext())
+ {
+ GarbageCollectorMXBean bean = (GarbageCollectorMXBean) beans.next();
+ platformServer.registerMBean(bean,
+ new ObjectName(GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE +
+ ",name=" +
+ bean.getName()));
+ }
+ platformServer.registerMBean(LogManager.getLoggingMXBean(),
+ new ObjectName(LogManager.LOGGING_MXBEAN_NAME));
+ }
+ catch (InstanceAlreadyExistsException e)
+ {
+ throw (Error)
+ (new InternalError("One of the management beans is " +
+ "already registered.").initCause(e));
+ }
+ catch (MBeanRegistrationException e)
+ {
+ throw (Error)
+ (new InternalError("One of the management beans' preRegister " +
+ "methods threw an exception.").initCause(e));
+ }
+ catch (NotCompliantMBeanException e)
+ {
+ throw (Error)
+ (new InternalError("One of the management beans is " +
+ "not compliant.").initCause(e));
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw (Error)
+ (new InternalError("The object name of a management bean is " +
+ "not compliant.").initCause(e));
+ }
+ }
+ return platformServer;
+ }
+
}
diff --git a/java/net/URLConnection.java b/java/net/URLConnection.java
index 325ff2329..674058014 100644
--- a/java/net/URLConnection.java
+++ b/java/net/URLConnection.java
@@ -175,9 +175,14 @@ public abstract class URLConnection
private static boolean dateformats_initialized;
/**
- * The timeout period.
+ * The connection timeout period.
*/
- private int timeout;
+ private int connectTimeout;
+
+ /**
+ * The read timeout period.
+ */
+ private int readTimeout;
/* Cached ParsePosition, used when parsing dates. */
private ParsePosition position;
@@ -217,8 +222,8 @@ public abstract class URLConnection
}
/**
- * Returns the connection timeout speed, in milliseconds, or zero if the timeout
- * is infinite or not set.
+ * Returns the connection timeout speed, in milliseconds, or zero if
+ * the timeout is infinite or not set.
*
* @return The timeout.
*
@@ -226,7 +231,7 @@ public abstract class URLConnection
*/
public int getConnectTimeout()
{
- return timeout;
+ return connectTimeout;
}
/**
@@ -236,7 +241,7 @@ public abstract class URLConnection
*
* Throws an <code>IllegalArgumentException</code> if timeout < 0.
*
- * @param timeout - The timeout, in milliseconds.
+ * @param timeout the timeout, in milliseconds.
*
* @since 1.5
*/
@@ -245,7 +250,45 @@ public abstract class URLConnection
{
if( timeout < 0 )
throw new IllegalArgumentException("Timeout must be 0 or positive.");
- this.timeout = timeout;
+ connectTimeout = timeout;
+ }
+
+ /**
+ * Returns the read timeout, in milliseconds, or zero if the timeout
+ * is infinite or not set.
+ *
+ * @return The timeout.
+ *
+ * @see #setReadTimeout
+ *
+ * @since 1.5
+ */
+ public int getReadTimeout()
+ {
+ return readTimeout;
+ }
+
+ /**
+ * Set the read timeout, in milliseconds, or zero if the timeout
+ * is to be considered infinite. Note that in certain socket
+ * implementations/platforms this method may not have any effect.
+ *
+ * Throws an <code>IllegalArgumentException</code> if timeout < 0.
+ *
+ * @param timeout - The timeout, in milliseconds.
+ *
+ * @throws IllegalArgumentException if timeout is negative.
+ *
+ * @see #getReadTimeout
+ *
+ * @since 1.5
+ */
+ public void setReadTimeout(int timeout)
+ throws IllegalArgumentException
+ {
+ if( timeout < 0 )
+ throw new IllegalArgumentException("Timeout must be 0 or positive.");
+ readTimeout = timeout;
}
/**