Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.

       * sources.am: Regenerated.
       * gcj/javaprims.h: Regenerated.
       * Makefile.in: Regenerated.
       * gcj/Makefile.in: Regenerated.
       * include/Makefile.in: Regenerated.
       * testsuite/Makefile.in: Regenerated.

       * gnu/java/lang/VMInstrumentationImpl.java: New override.
       * gnu/java/net/local/LocalSocketImpl.java: Likewise.
       * gnu/classpath/jdwp/VMMethod.java: Likewise.
       * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
       interface.
       * java/lang/Thread.java: Add UncaughtExceptionHandler.
       * java/lang/reflect/Method.java: Implements GenericDeclaration and
       isSynthetic(),
       * java/lang/reflect/Field.java: Likewise.
       * java/lang/reflect/Constructor.java
       * java/lang/Class.java: Implements Type, GenericDeclaration,
       getSimpleName() and getEnclosing*() methods.
       * java/lang/Class.h: Add new public methods.
       * java/lang/Math.java: Add signum(), ulp() and log10().
       * java/lang/natMath.cc (log10): New function.
       * java/security/VMSecureRandom.java: New override.
       * java/util/logging/Logger.java: Updated to latest classpath
       version.
       * java/util/logging/LogManager.java: New override.

From-SVN: r113887
This commit is contained in:
Mark Wielaard 2006-05-18 17:29:21 +00:00
parent eaec4980e1
commit 4f9533c772
1640 changed files with 126485 additions and 104808 deletions

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt;
import gnu.java.awt.java2d.AlphaCompositeContext;
import java.awt.image.ColorModel;
import java.util.LinkedHashMap;
import java.util.Map;
@ -137,14 +139,25 @@ public final class AlphaComposite implements Composite
}
return a;
}
/**
* Creates a {@link CompositeContext} that can be used to perform
* compositing operations according to this AlphaComposite settings.
*
* @param srcColorModel the color model of the source raster
* @param dstColorModel the color model of the destination raster
* @param hints the rendering hints to use
*
* @return a {@link CompositeContext} that can be used to perform
* compositing operations according to this AlphaComposite settings
*/
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints hints)
{
// XXX Implement. Sun uses undocumented implementation class
// sun.java2d.SunCompositeContext.
throw new Error("not implemented");
return new AlphaCompositeContext(this, srcColorModel, dstColorModel);
}
public float getAlpha()
{
return alpha;

View file

@ -38,6 +38,15 @@ exception statement from your version. */
package java.awt;
import gnu.java.awt.java2d.CubicSegment;
import gnu.java.awt.java2d.LineSegment;
import gnu.java.awt.java2d.QuadSegment;
import gnu.java.awt.java2d.Segment;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.util.Arrays;
/**
@ -109,6 +118,8 @@ public class BasicStroke implements Stroke
/** The dash phase. */
private final float phase;
private Segment start, end;
/**
* Creates a new <code>BasicStroke</code> instance with the given attributes.
*
@ -249,8 +260,12 @@ public class BasicStroke implements Stroke
*/
public Shape createStrokedShape(Shape s)
{
// FIXME: Implement this
throw new Error("not implemented");
PathIterator pi = s.getPathIterator( new AffineTransform() );
if( dash == null )
return solidStroke( pi );
return dashedStroke( pi );
}
/**
@ -366,4 +381,355 @@ public class BasicStroke implements Stroke
return width == s.width && cap == s.cap && join == s.join
&& limit == s.limit && Arrays.equals(dash, s.dash) && phase == s.phase;
}
private Shape solidStroke(PathIterator pi)
{
double[] coords = new double[6];
double x, y, x0, y0;
boolean pathOpen = false;
GeneralPath output = new GeneralPath( );
Segment[] p;
x = x0 = y = y0 = 0;
while( !pi.isDone() )
{
switch( pi.currentSegment(coords) )
{
case PathIterator.SEG_MOVETO:
x0 = x = coords[0];
y0 = y = coords[1];
if( pathOpen )
{
capEnds();
convertPath(output, start);
start = end = null;
pathOpen = false;
}
break;
case PathIterator.SEG_LINETO:
p = (new LineSegment(x, y, coords[0], coords[1])).
getDisplacedSegments(width/2.0);
if( !pathOpen )
{
start = p[0];
end = p[1];
pathOpen = true;
}
else
addSegments(p);
x = coords[0];
y = coords[1];
break;
case PathIterator.SEG_QUADTO:
p = (new QuadSegment(x, y, coords[0], coords[1], coords[2],
coords[3])).getDisplacedSegments(width/2.0);
if( !pathOpen )
{
start = p[0];
end = p[1];
pathOpen = true;
}
else
addSegments(p);
x = coords[0];
y = coords[1];
break;
case PathIterator.SEG_CUBICTO:
p = new CubicSegment(x, y, coords[0], coords[1],
coords[2], coords[3],
coords[4], coords[5]).getDisplacedSegments(width/2.0);
if( !pathOpen )
{
start = p[0];
end = p[1];
pathOpen = true;
}
else
addSegments(p);
x = coords[0];
y = coords[1];
break;
case PathIterator.SEG_CLOSE:
p = (new LineSegment(x, y, x0, y0)).getDisplacedSegments(width/2.0);
addSegments(p);
convertPath(output, start);
convertPath(output, end);
start = end = null;
pathOpen = false;
break;
}
pi.next();
}
if( pathOpen )
{
capEnds();
convertPath(output, start);
}
return output;
}
private Shape dashedStroke(PathIterator pi)
{
GeneralPath out = new GeneralPath();
return out;
}
/**
* Cap the ends of the path (joining the start and end list of segments)
*/
private void capEnds()
{
Segment returnPath = end.last;
end.reverseAll(); // reverse the path.
end = null;
capEnd(start, returnPath);
start.last = returnPath.last;
end = null;
capEnd(start, start);
}
/**
* Convert and add the linked list of Segments in s to a GeneralPath p.
*/
private void convertPath(GeneralPath p, Segment s)
{
Segment v = s;
p.moveTo((float)s.P1.getX(), (float)s.P1.getY());
do
{
if(v instanceof LineSegment)
p.lineTo((float)v.P2.getX(), (float)v.P2.getY());
else if(v instanceof QuadSegment)
p.quadTo((float)((QuadSegment)v).cp.getX(),
(float)((QuadSegment)v).cp.getY(),
(float)v.P2.getX(),
(float)v.P2.getY());
else if(v instanceof CubicSegment)
p.curveTo((float)((CubicSegment)v).cp1.getX(),
(float)((CubicSegment)v).cp1.getY(),
(float)((CubicSegment)v).cp2.getX(),
(float)((CubicSegment)v).cp2.getY(),
(float)v.P2.getX(),
(float)v.P2.getY());
v = v.next;
} while(v != s && v != null);
p.closePath();
}
/**
* Add to segments to start and end, joining the outer pair and
*/
private void addSegments(Segment[] segments)
{
double[] p0 = start.last.last();
double[] p1 = new double[]{start.last.P2.getX(), start.last.P2.getY()};
double[] p2 = new double[]{segments[0].P1.getX(), segments[0].P1.getY()};
double[] p3 = segments[0].first();
Point2D p;
double det = (p1[0] - p0[0])*(p3[1] - p2[1]) -
(p3[0] - p2[0])*(p1[1] - p0[1]);
if( det > 0 )
{
// start and segment[0] form the 'inner' part of a join,
// connect the overlapping segments
p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], false);
if( p == null )
{
// Dodgy.
start.add(new LineSegment(start.last.P2, segments[0].P1));
p = new Point2D.Double((segments[0].P1.getX()+ start.last.P2.getX())/2.0,
(segments[0].P1.getY()+ start.last.P2.getY())/2.0);
}
else
segments[0].P1 = start.last.P2 = p;
start.add( segments[0] );
joinSegments(end, segments[1], p);
}
else
{
// end and segment[1] form the 'inner' part
p0 = end.last.last();
p1 = new double[]{end.last.P2.getX(), end.last.P2.getY()};
p2 = new double[]{segments[1].P1.getX(), segments[1].P1.getY()};
p3 = segments[1].first();
p = lineIntersection(p0[0],p0[1],p1[0],p1[1],
p2[0],p2[1],p3[0],p3[1], false);
if( p == null )
{
// Dodgy.
end.add(new LineSegment(end.last.P2, segments[1].P1));
p = new Point2D.Double((segments[1].P1.getX()+ end.last.P2.getX())/2.0,
(segments[1].P1.getY()+ end.last.P2.getY())/2.0);
}
else
segments[1].P1 = end.last.P2 = p;
end.add( segments[1] );
joinSegments(start, segments[0], p);
}
}
/**
* Make a cap between a and b segments,
* where a-->b is the direction of iteration.
*/
private void capEnd(Segment a, Segment b)
{
double[] p0, p1;
double dx, dy, l;
Point2D c1,c2;
switch( cap )
{
case CAP_BUTT:
a.add(new LineSegment(a.last.P2, b.P1));
break;
case CAP_SQUARE:
p0 = a.last.last();
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 = 0.5*width*dx/l;
dy = 0.5*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 LineSegment(a.last.P2, c1));
a.add(new LineSegment(c1, c2));
a.add(new LineSegment(c2, b.P1));
break;
case CAP_ROUND:
p0 = a.last.last();
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;
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));
break;
}
a.add(b);
}
/**
* Returns the intersection of two lines, or null if there isn't one.
* @param infinite - true if the lines should be regarded as infinite, false
* if the intersection must be within the given segments.
* @return a Point2D or null.
*/
private Point2D lineIntersection(double X1, double Y1,
double X2, double Y2,
double X3, double Y3,
double X4, double Y4,
boolean infinite)
{
double x1 = X1;
double y1 = Y1;
double rx = X2 - x1;
double ry = Y2 - y1;
double x2 = X3;
double y2 = Y3;
double sx = X4 - x2;
double sy = Y4 - y2;
double determinant = sx * ry - sy * rx;
double nom = (sx * (y2 - y1) + sy * (x1 - x2));
// lines can be considered parallel.
if (Math.abs(determinant) < 1E-6)
return null;
nom = nom / determinant;
// check if lines are within the bounds
if(!infinite && (nom > 1.0 || nom < 0.0))
return null;
return new Point2D.Double(x1 + nom * rx, y1 + nom * ry);
}
/**
* Join a and b segments, where a-->b is the direction of iteration.
*
* insideP is the inside intersection point of the join, needed for
* calculating miter lengths.
*/
private void joinSegments(Segment a, Segment b, Point2D insideP)
{
double[] p0, p1;
double dx, dy, l;
Point2D c1,c2;
switch( join )
{
case JOIN_MITER:
p0 = a.last.last();
p1 = new double[]{a.last.P2.getX(), a.last.P2.getY()};
double[] p2 = new double[]{b.P1.getX(), b.P1.getY()};
double[] p3 = b.first();
Point2D p = lineIntersection(p0[0],p0[1],p1[0],p1[1],p2[0],p2[1],p3[0],p3[1], true);
if( p == null || insideP == null )
a.add(new LineSegment(a.last.P2, b.P1));
else if((p.distance(insideP)/width) < limit)
{
a.add(new LineSegment(a.last.P2, p));
a.add(new LineSegment(p, b.P1));
}
else
{
// outside miter limit, do a bevel join.
a.add(new LineSegment(a.last.P2, b.P1));
}
break;
case JOIN_ROUND:
p0 = a.last.last();
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 = 0.5*width*dx/l;
dy = 0.5*width*dy/l;
c1 = new Point2D.Double(p1[0] + dx, p1[1] + dy);
p0 = new double[]{b.P1.getX(), b.P1.getY()};
p1 = b.first();
dx = p0[0] - p1[0]; // backwards direction.
dy = p0[1] - p1[1];
l = Math.sqrt(dx * dx + dy * dy);
dx = 0.5*width*dx/l;
dy = 0.5*width*dy/l;
c2 = new Point2D.Double(p0[0] + dx, p0[1] + dy);
a.add(new CubicSegment(a.last.P2, c1, c2, b.P1));
break;
case JOIN_BEVEL:
a.add(new LineSegment(a.last.P2, b.P1));
break;
}
a.add(b);
}
}

View file

@ -98,7 +98,7 @@ private transient ActionListener action_listeners;
protected class AccessibleAWTButton extends AccessibleAWTComponent
implements AccessibleAction, AccessibleValue
{
public static final long serialVersionUID = -5932203980244017102L;
private static final long serialVersionUID = -5932203980244017102L;
protected AccessibleAWTButton()
{

View file

@ -556,6 +556,17 @@ processEvent(AWTEvent event)
super.processEvent(event);
}
void
dispatchEventImpl(AWTEvent e)
{
if (e.id <= ItemEvent.ITEM_LAST
&& e.id >= ItemEvent.ITEM_FIRST
&& (item_listeners != null || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
processEvent(e);
else
super.dispatchEventImpl(e);
}
/*************************************************************************/
/**

View file

@ -906,7 +906,7 @@ public abstract class Component
// The JDK repaints the component before invalidating the parent.
// So do we.
if (isShowing())
if (isShowing() && isLightweight())
repaint();
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
@ -1075,8 +1075,6 @@ public abstract class Component
Component p = parent;
if (p != null)
return p.getFont();
if (peer != null)
return peer.getGraphics().getFont();
return null;
}
@ -2315,6 +2313,10 @@ public abstract class Component
if (oldEvent != null)
postEvent (oldEvent);
// Give toolkit a chance to dispatch the event
// to globally registered listeners.
Toolkit.getDefaultToolkit().globalDispatchEvent(e);
// Some subclasses in the AWT package need to override this behavior,
// hence the use of dispatchEventImpl().
dispatchEventImpl(e);
@ -3089,6 +3091,8 @@ public abstract class Component
mouseListener.mouseClicked(e);
break;
case MouseEvent.MOUSE_ENTERED:
if( isLightweight() )
setCursor( getCursor() );
mouseListener.mouseEntered(e);
break;
case MouseEvent.MOUSE_EXITED:
@ -3101,7 +3105,6 @@ public abstract class Component
mouseListener.mouseReleased(e);
break;
}
e.consume();
}
/**
@ -4079,14 +4082,9 @@ public abstract class Component
*/
public Container getFocusCycleRootAncestor ()
{
if (this instanceof Window
&& ((Container) this).isFocusCycleRoot ())
return (Container) this;
Container parent = getParent ();
while (parent != null
&& !parent.isFocusCycleRoot ())
while (parent != null && !parent.isFocusCycleRoot())
parent = parent.getParent ();
return parent;
@ -4114,9 +4112,32 @@ public abstract class Component
*/
public void nextFocus ()
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
// Find the nearest valid (== showing && focusable && enabled) focus
// cycle root ancestor and the focused component in it.
Container focusRoot = getFocusCycleRootAncestor();
Component focusComp = this;
while (focusRoot != null
&& ! (focusRoot.isShowing() && focusRoot.isFocusable()
&& focusRoot.isEnabled()))
{
focusComp = focusRoot;
focusRoot = focusComp.getFocusCycleRootAncestor();
}
manager.focusNextComponent (this);
if (focusRoot != null)
{
// First try to get the componentBefore from the policy.
FocusTraversalPolicy policy = focusRoot.getFocusTraversalPolicy();
Component nextFocus = policy.getComponentAfter(focusRoot, focusComp);
// If this fails, then ask for the defaultComponent.
if (nextFocus == null)
nextFocus = policy.getDefaultComponent(focusRoot);
// Request focus on this component, if not null.
if (nextFocus != null)
nextFocus.requestFocus();
}
}
/**
@ -4128,9 +4149,32 @@ public abstract class Component
*/
public void transferFocusBackward ()
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
// Find the nearest valid (== showing && focusable && enabled) focus
// cycle root ancestor and the focused component in it.
Container focusRoot = getFocusCycleRootAncestor();
Component focusComp = this;
while (focusRoot != null
&& ! (focusRoot.isShowing() && focusRoot.isFocusable()
&& focusRoot.isEnabled()))
{
focusComp = focusRoot;
focusRoot = focusComp.getFocusCycleRootAncestor();
}
manager.focusPreviousComponent (this);
if (focusRoot != null)
{
// First try to get the componentBefore from the policy.
FocusTraversalPolicy policy = focusRoot.getFocusTraversalPolicy();
Component nextFocus = policy.getComponentBefore(focusRoot, focusComp);
// If this fails, then ask for the defaultComponent.
if (nextFocus == null)
nextFocus = policy.getDefaultComponent(focusRoot);
// Request focus on this component, if not null.
if (nextFocus != null)
nextFocus.requestFocus();
}
}
/**
@ -4144,9 +4188,63 @@ public abstract class Component
*/
public void transferFocusUpCycle ()
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
// Find the nearest focus cycle root ancestor that is itself
// focusable, showing and enabled.
Container focusCycleRoot = getFocusCycleRootAncestor();
while (focusCycleRoot != null &&
! (focusCycleRoot.isShowing() && focusCycleRoot.isFocusable()
&& focusCycleRoot.isEnabled()))
{
focusCycleRoot = focusCycleRoot.getFocusCycleRootAncestor();
}
manager.upFocusCycle (this);
KeyboardFocusManager fm =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
if (focusCycleRoot != null)
{
// If we found a focus cycle root, then we make this the new
// focused component, and make it's focus cycle root the new
// global focus cycle root. If the found root has no focus cycle
// root ancestor itself, then the component will be both the focused
// component and the new global focus cycle root.
Container focusCycleAncestor =
focusCycleRoot.getFocusCycleRootAncestor();
Container globalFocusCycleRoot;
if (focusCycleAncestor == null)
globalFocusCycleRoot = focusCycleRoot;
else
globalFocusCycleRoot = focusCycleAncestor;
fm.setGlobalCurrentFocusCycleRoot(globalFocusCycleRoot);
focusCycleRoot.requestFocus();
}
else
{
// If this component has no applicable focus cycle root, we try
// find the nearest window and set this as the new global focus cycle
// root and the default focus component of this window the new focused
// component.
Container cont;
if (this instanceof Container)
cont = (Container) this;
else
cont = getParent();
while (cont != null && !(cont instanceof Window))
cont = cont.getParent();
if (cont != null)
{
FocusTraversalPolicy policy = cont.getFocusTraversalPolicy();
Component focusComp = policy.getDefaultComponent(cont);
if (focusComp != null)
{
fm.setGlobalCurrentFocusCycleRoot(cont);
focusComp.requestFocus();
}
}
}
}
/**
@ -4876,7 +4974,7 @@ p * <li>the set of backward traversal keys
oldKey = Event.UP;
break;
default:
oldKey = newKey;
oldKey = (int) ((KeyEvent) e).getKeyChar();
}
translated = new Event (target, when, oldID,
@ -4922,10 +5020,6 @@ p * <li>the set of backward traversal keys
void dispatchEventImpl(AWTEvent e)
{
// Give toolkit a chance to dispatch the event
// to globally registered listeners.
Toolkit.getDefaultToolkit().globalDispatchEvent(e);
// This boolean tells us not to process focus events when the focus
// opposite component is the same as the focus component.
boolean ignoreFocus =
@ -4934,6 +5028,10 @@ p * <li>the set of backward traversal keys
if (eventTypeEnabled (e.id))
{
if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE
&& !ignoreFocus)
processEvent(e);
// the trick we use to communicate between dispatch and redispatch
// is to have KeyboardFocusManager.redispatch synchronize on the
// object itself. we then do not redispatch to KeyboardFocusManager
@ -4954,14 +5052,11 @@ p * <li>the set of backward traversal keys
.dispatchEvent(e))
return;
case MouseEvent.MOUSE_PRESSED:
if (isLightweight())
requestFocus();
if (isLightweight() && !e.isConsumed())
requestFocus();
break;
}
}
if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE
&& !ignoreFocus)
processEvent(e);
}
if (peer != null)
@ -4978,6 +5073,15 @@ p * <li>the set of backward traversal keys
switch (type)
{
case HierarchyEvent.HIERARCHY_CHANGED:
return (hierarchyListener != null
|| (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0);
case HierarchyEvent.ANCESTOR_MOVED:
case HierarchyEvent.ANCESTOR_RESIZED:
return (hierarchyBoundsListener != null
|| (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0);
case ComponentEvent.COMPONENT_HIDDEN:
case ComponentEvent.COMPONENT_MOVED:
case ComponentEvent.COMPONENT_RESIZED:
@ -5002,6 +5106,9 @@ p * <li>the set of backward traversal keys
case MouseEvent.MOUSE_DRAGGED:
return (mouseMotionListener != null
|| (eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0);
case MouseEvent.MOUSE_WHEEL:
return (mouseWheelListener != null
|| (eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0);
case FocusEvent.FOCUS_GAINED:
case FocusEvent.FOCUS_LOST:
@ -5289,7 +5396,7 @@ p * <li>the set of backward traversal keys
*/
public String getAccessibleName()
{
return accessibleName == null ? getName() : accessibleName;
return accessibleName;
}
/**
@ -5329,8 +5436,10 @@ p * <li>the set of backward traversal keys
s.add(AccessibleState.FOCUSABLE);
if (isFocusOwner())
s.add(AccessibleState.FOCUSED);
if (isOpaque())
s.add(AccessibleState.OPAQUE);
// Note: While the java.awt.Component has an 'opaque' property, it
// seems that it is not added to the accessible state set here, even
// if this property is true. However, it is handled for
// javax.swing.JComponent, so we add it there.
if (Component.this.isShowing())
s.add(AccessibleState.SHOWING);
if (Component.this.isVisible())
@ -5614,7 +5723,7 @@ p * <li>the set of backward traversal keys
*/
public Point getLocation()
{
return Component.this.isShowing() ? Component.this.getLocation() : null;
return Component.this.getLocation();
}
/**
@ -5638,7 +5747,7 @@ p * <li>the set of backward traversal keys
*/
public Rectangle getBounds()
{
return Component.this.isShowing() ? Component.this.getBounds() : null;
return Component.this.getBounds();
}
/**
@ -5661,7 +5770,7 @@ p * <li>the set of backward traversal keys
*/
public Dimension getSize()
{
return Component.this.isShowing() ? Component.this.getSize() : null;
return Component.this.getSize();
}
/**

View file

@ -388,10 +388,6 @@ public class Container extends Component
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());
}
}
@ -968,6 +964,13 @@ public class Container extends Component
* child component claims the point, the container itself is returned,
* unless the point does not exist within this container, in which
* case <code>null</code> is returned.
*
* When components overlap, the first component is returned. The component
* that is closest to (x, y), containing that location, is returned.
* Heavyweight components take precedence of lightweight components.
*
* This function does not ignore invisible components. If there is an invisible
* component at (x,y), it will be returned.
*
* @param x The X coordinate of the point.
* @param y The Y coordinate of the point.
@ -987,7 +990,14 @@ public class Container extends Component
* child component claims the point, the container itself is returned,
* unless the point does not exist within this container, in which
* case <code>null</code> is returned.
*
*
* When components overlap, the first component is returned. The component
* that is closest to (x, y), containing that location, is returned.
* Heavyweight components take precedence of lightweight components.
*
* This function does not ignore invisible components. If there is an invisible
* component at (x,y), it will be returned.
*
* @param x The x position of the point to return the component at.
* @param y The y position of the point to return the component at.
*
@ -1002,17 +1012,28 @@ public class Container extends Component
{
if (!contains (x, y))
return null;
// First find the component closest to (x,y) that is a heavyweight.
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;
if (component[i].contains (x2, y2))
return component[i];
Component comp = component[i];
int x2 = x - comp.x;
int y2 = y - comp.y;
if (comp.contains (x2, y2) && !comp.isLightweight())
return comp;
}
// if a heavyweight component is not found, look for a lightweight
// closest to (x,y).
for (int i = 0; i < ncomponents; ++i)
{
Component comp = component[i];
int x2 = x - comp.x;
int y2 = y - comp.y;
if (comp.contains (x2, y2) && comp.isLightweight())
return comp;
}
return this;
}
}
@ -1025,6 +1046,13 @@ public class Container extends Component
* unless the point does not exist within this container, in which
* case <code>null</code> is returned.
*
* The top-most child component is returned in the case where components overlap.
* This is determined by finding the component closest to (x,y) and contains
* that location. Heavyweight components take precedence of lightweight components.
*
* This function does not ignore invisible components. If there is an invisible
* component at (x,y), it will be returned.
*
* @param p The point to return the component at.
* @return The component containing the specified point, or <code>null</code>
* if there is no such point.
@ -1034,6 +1062,22 @@ public class Container extends Component
return getComponentAt (p.x, p.y);
}
/**
* Locates the visible child component that contains the specified position.
* The top-most child component is returned in the case where there is overlap
* in the components. If the containing child component is a Container,
* this method will continue searching for the deepest nested child
* component. Components which are not visible are ignored during the search.
*
* findComponentAt differs from getComponentAt, because it recursively
* searches a Container's children.
*
* @param x - x coordinate
* @param y - y coordinate
* @return null if the component does not contain the position.
* If there is no child component at the requested point and the point is
* within the bounds of the container the container itself is returned.
*/
public Component findComponentAt(int x, int y)
{
synchronized (getTreeLock ())
@ -1067,53 +1111,20 @@ public class Container extends Component
}
/**
* 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.
* Locates the visible child component that contains the specified position.
* The top-most child component is returned in the case where there is overlap
* in the components. If the containing child component is a Container,
* this method will continue searching for the deepest nested child
* component. Components which are not visible are ignored during the search.
*
* findComponentAt differs from getComponentAt, because it recursively
* searches a Container's children.
*
* @param p - the component's location
* @return null if the component does not contain the position.
* If there is no child component at the requested point and the point is
* within the bounds of the container the container itself is returned.
*/
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 (getMouseListeners().length == 0
&& getMouseMotionListeners().length == 0)
return null;
return this;
}
}
public Component findComponentAt(Point p)
{
return findComponentAt(p.x, p.y);
@ -1454,7 +1465,7 @@ public class Container extends Component
{
Container ancestor = getFocusCycleRootAncestor ();
if (ancestor != this)
if (ancestor != this && ancestor != null)
return ancestor.getFocusTraversalPolicy ();
else
{
@ -1524,9 +1535,16 @@ public class Container extends Component
*/
public void transferFocusDownCycle ()
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
manager.downFocusCycle (this);
if (isFocusCycleRoot())
{
KeyboardFocusManager fm =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
fm.setGlobalCurrentFocusCycleRoot(this);
FocusTraversalPolicy policy = getFocusTraversalPolicy();
Component defaultComponent = policy.getDefaultComponent(this);
if (defaultComponent != null)
defaultComponent.requestFocus();
}
}
/**

View file

@ -61,6 +61,8 @@ package java.awt;
public class DefaultFocusTraversalPolicy
extends ContainerOrderFocusTraversalPolicy
{
private static final long serialVersionUID = 8876966522510157497L;
/**
* Construct a default focus traversal policy.
*/

View file

@ -478,59 +478,25 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
public void focusPreviousComponent (Component comp)
{
Component focusComp = (comp == null) ? getGlobalFocusOwner () : comp;
Container focusCycleRoot = focusComp.getFocusCycleRootAncestor ();
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component previous = policy.getComponentBefore (focusCycleRoot, focusComp);
if (previous != null)
previous.requestFocusInWindow ();
if (comp != null)
comp.transferFocusBackward();
}
public void focusNextComponent (Component comp)
{
Component focusComp = (comp == null) ? getGlobalFocusOwner () : comp;
Container focusCycleRoot = focusComp.getFocusCycleRootAncestor ();
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component next = policy.getComponentAfter (focusCycleRoot, focusComp);
if (next != null)
next.requestFocusInWindow ();
if (comp != null)
comp.transferFocus();
}
public void upFocusCycle (Component comp)
{
Component focusComp = (comp == null) ? getGlobalFocusOwner () : comp;
Container focusCycleRoot = focusComp.getFocusCycleRootAncestor ();
if (focusCycleRoot instanceof Window)
{
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component defaultComponent = policy.getDefaultComponent (focusCycleRoot);
if (defaultComponent != null)
defaultComponent.requestFocusInWindow ();
}
else
{
Container parentFocusCycleRoot = focusCycleRoot.getFocusCycleRootAncestor ();
focusCycleRoot.requestFocusInWindow ();
setGlobalCurrentFocusCycleRoot (parentFocusCycleRoot);
}
if (comp != null)
comp.transferFocusUpCycle();
}
public void downFocusCycle (Container cont)
{
if (cont == null)
return;
if (cont.isFocusCycleRoot (cont))
{
FocusTraversalPolicy policy = cont.getFocusTraversalPolicy ();
Component defaultComponent = policy.getDefaultComponent (cont);
if (defaultComponent != null)
defaultComponent.requestFocusInWindow ();
setGlobalCurrentFocusCycleRoot (cont);
}
if (cont != null)
cont.transferFocusDownCycle();
}
} // class DefaultKeyboardFocusManager

View file

@ -1,39 +1,40 @@
/* Dialog.java -- An AWT dialog box
Copyright (C) 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
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 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.
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.
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.
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. */
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.awt;
@ -46,457 +47,422 @@ import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
/**
* A dialog box widget class.
*
* <code>Dialog</code> provides a top-level window normally used to receive
* user input in applications.
* <p>
* A dialog always has another top-level window as owner and is only visible
* if this owner is visible to the user. The default layout of dialogs is the
* <code>BorderLayout</code>. Dialogs can be modal (blocks user input to other
* components) or non-modal (user input in other components are allowed).
* </p>
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Tom Tromey (tromey@redhat.com)
*/
public class Dialog extends Window
{
// Serialization constant
private static final long serialVersionUID = 5920926903803293709L;
/*
* Static Variables
*/
/**
* @serial Indicates whether or not this dialog box is modal.
*/
private boolean modal;
// Serialization constant
private static final long serialVersionUID = 5920926903803293709L;
/**
* @serial Indicates whether or not this dialog box is resizable.
*/
private boolean resizable = true;
/*************************************************************************/
/**
* @serial The title string for this dialog box, which can be
* <code>null</code>.
*/
private String title;
/*
* Instance Variables
*/
/**
* This field indicates whether the dialog is undecorated or not.
*/
private boolean undecorated = false;
/**
* @serial Indicates whether or not this dialog box is modal.
*/
private boolean modal;
/**
* Indicates that we are blocked for modality in show
*/
private boolean blocked = false;
/**
* @serial Indicates whether or not this dialog box is resizable.
*/
private boolean resizable = true;
/**
* Secondary EventQueue to handle AWT events while we are blocked for
* modality in show.
*/
private EventQueue eq2 = null;
/**
* @serial The title string for this dialog box, which can be
* <code>null</code>.
*/
private String title;
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent, that is resizable and not modal, and which has no title.
*
* @param parent The parent frame of this dialog box.
* @exception IllegalArgumentException If the owner's GraphicsConfiguration
* is not from a screen device, or if owner is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns true.
*/
public Dialog(Frame parent)
{
this(parent, "", false);
}
/**
* This field indicates whether the dialog is undecorated or not.
*/
private boolean undecorated = false;
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent and modality, that is resizable and which has no title.
*
* @param parent The parent frame of this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
*
* @exception IllegalArgumentException If the owner's GraphicsConfiguration
* is not from a screen device, or if owner is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns true.
*/
public Dialog(Frame parent, boolean modal)
{
this(parent, "", modal);
}
/**
* Indicates that we are blocked for modality in show
*/
private boolean blocked = false;
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent, that is resizable and not modal, and which has the specified
* title.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
*
* @exception IllegalArgumentException If the owner's GraphicsConfiguration
* is not from a screen device, or if owner is null. This exceptionnis
* always thrown when GraphicsEnvironment.isHeadless() returns true.
*/
public Dialog(Frame parent, String title)
{
this(parent, title, false);
}
/**
* Secondary EventQueue to handle AWT events while
* we are blocked for modality in show
*/
private EventQueue eq2 = null;
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title, and modality, that is resizable.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
*
* @exception IllegalArgumentException If owner is null or
* GraphicsEnvironment.isHeadless() returns true.
*/
public Dialog(Frame parent, String title, boolean modal)
{
this(parent, title, modal, parent.getGraphicsConfiguration());
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title, modality and <code>GraphicsConfiguration</code>, that is
* resizable.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
* @param gc The <code>GraphicsConfiguration</code> object to use. If
* <code>null</code> the <code>GraphicsConfiguration</code> of the target
* frame is used.
*
* @exception IllegalArgumentException If owner is null, the
* GraphicsConfiguration is not a screen device or
* GraphicsEnvironment.isHeadless() returns true.
* @since 1.4
*/
public Dialog(Frame parent, String title, boolean modal,
GraphicsConfiguration gc)
{
super(parent, (gc == null) ? parent.getGraphicsConfiguration() : gc);
/*
* Constructors
*/
// A null title is equivalent to an empty title
this.title = (title != null) ? title : "";
this.modal = modal;
visible = false;
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent, that is resizable and not modal, and which has no title.
*
* @param parent The parent frame of this dialog box.
*
* @exception IllegalArgumentException If the owner's GraphicsConfiguration
* is not from a screen device, or if owner is null. This exception is always
* thrown when GraphicsEnvironment.isHeadless() returns true.
*/
public
Dialog(Frame parent)
{
this(parent, "", false);
}
setLayout(new BorderLayout());
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, that is resizable.
*
* @param owner The parent frame of this dialog box.
*
* @exception IllegalArgumentException If parent is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns true.
*
* @since 1.2
*/
public Dialog(Dialog owner)
{
this(owner, "", false, owner.getGraphicsConfiguration());
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent and modality, that is resizable and which has no title.
*
* @param parent The parent frame of this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
*
* @exception IllegalArgumentException If the owner's GraphicsConfiguration
* is not from a screen device, or if owner is null. This exception is always
* thrown when GraphicsEnvironment.isHeadless() returns true.
*/
public
Dialog(Frame parent, boolean modal)
{
this(parent, "", modal);
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent and title, that is resizable.
*
* @param owner The parent frame of this dialog box.
* @param title The title string for this dialog box.
*
* @exception IllegalArgumentException If parent is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns
* true.
* @since 1.2
*/
public Dialog(Dialog owner, String title)
{
this(owner, title, false, owner.getGraphicsConfiguration());
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title and modality, that is resizable.
*
* @param owner The parent frame of this dialog box.
* @param title The title string for this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
*
* @exception IllegalArgumentException If parent is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns true.
* @since 1.2
*/
public Dialog(Dialog owner, String title, boolean modal)
{
this(owner, title, modal, owner.getGraphicsConfiguration());
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified
* parent, that is resizable and not modal, and which has the specified
* title.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
*
* @exception IllegalArgumentException If the owner's GraphicsConfiguration
* is not from a screen device, or if owner is null. This exception is always
* thrown when GraphicsEnvironment.isHeadless() returns true.
*/
public
Dialog(Frame parent, String title)
{
this(parent, title, false);
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title, modality and <code>GraphicsConfiguration</code>, that is
* resizable.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
* @param gc The <code>GraphicsConfiguration</code> object to use. If
* <code>null</code> the <code>GraphicsConfiguration</code> of the target
* frame is used.
*
* @exception IllegalArgumentException If parent is null, the
* GraphicsConfiguration is not a screen device or
* GraphicsEnvironment.isHeadless() returns true.
*
* @since 1.4
*/
public Dialog(Dialog parent, String title, boolean modal,
GraphicsConfiguration gc)
{
super(parent, (gc == null) ? parent.getGraphicsConfiguration() : gc);
/*************************************************************************/
// A null title is equivalent to an empty title
this.title = (title != null) ? title : "";
this.modal = modal;
visible = false;
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title, and modality, that is resizable.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
*
* @exception IllegalArgumentException If owner is null or
* GraphicsEnvironment.isHeadless() returns true.
*/
public
Dialog(Frame parent, String title, boolean modal)
{
this (parent, title, modal, parent.getGraphicsConfiguration ());
}
setLayout(new BorderLayout());
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title, modality and <code>GraphicsConfiguration</code>,
* that is resizable.
*
* @param parent The parent frame of this dialog box.
* @param title The title string for this dialog box.
* @param modal <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
* @param gc The <code>GraphicsConfiguration</code> object to use.
*
* @exception IllegalArgumentException If owner is null, the
* GraphicsConfiguration is not a screen device or
* GraphicsEnvironment.isHeadless() returns true.
*
* @since 1.4
*/
public
Dialog (Frame parent, String title, boolean modal, GraphicsConfiguration gc)
{
super (parent, gc);
/**
* Returns the title of this dialog box.
*
* @return The title of this dialog box.
*/
public String getTitle()
{
return title;
}
// A null title is equivalent to an empty title
this.title = (title != null) ? title : "";
this.modal = modal;
visible = false;
/**
* Sets the title of this dialog box to the specified string.
*
* @param title the new title. If <code>null</code> an empty
* title will be set.
*/
public synchronized void setTitle(String title)
{
// A null title is equivalent to an empty title
this.title = (title != null) ? title : "";
setLayout(new BorderLayout());
}
if (peer != null)
{
DialogPeer d = (DialogPeer) peer;
d.setTitle(title);
}
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, that is resizable.
*
* @exception IllegalArgumentException If parent is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns true.
*
* @since 1.2
*/
public
Dialog (Dialog owner)
{
this (owner, "", false, owner.getGraphicsConfiguration ());
}
/**
* Tests whether or not this dialog box is modal.
*
* @return <code>true</code> if this dialog box is modal, <code>false</code>
* otherwise.
*/
public boolean isModal()
{
return modal;
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent and title, that is resizable.
*
* @exception IllegalArgumentException If parent is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns true.
*
* @since 1.2
*/
public
Dialog (Dialog owner, String title)
{
this (owner, title, false, owner.getGraphicsConfiguration ());
}
/**
* Changes the modality of this dialog box. This can only be done before the
* peer is created.
*
* @param modal <code>true</code> to make this dialog box modal,
* <code>false</code> to make it non-modal.
*/
public void setModal(boolean modal)
{
this.modal = modal;
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title and modality, that is resizable.
*
* @exception IllegalArgumentException If parent is null. This exception is
* always thrown when GraphicsEnvironment.isHeadless() returns true.
*
* @since 1.2
*/
public
Dialog (Dialog owner, String title, boolean modal)
{
this (owner, title, modal, owner.getGraphicsConfiguration ());
}
/**
* Tests whether or not this dialog box is resizable.
*
* @return <code>true</code> if this dialog is resizable,
* <code>false</code> otherwise.
*/
public boolean isResizable()
{
return resizable;
}
/**
* Initializes a new instance of <code>Dialog</code> with the specified,
* parent, title, modality and <code>GraphicsConfiguration</code>,
* that is resizable.
*
* @exception IllegalArgumentException If parent is null, the
* GraphicsConfiguration is not a screen device or
* GraphicsEnvironment.isHeadless() returns true.
*
* @since 1.4
*/
public
Dialog (Dialog parent, String title, boolean modal, GraphicsConfiguration gc)
{
super (parent, parent.getGraphicsConfiguration ());
/**
* Changes the resizability of this dialog box.
*
* @param resizable <code>true</code> to make this dialog resizable,
* <code>false</code> to make it non-resizable.
*/
public synchronized void setResizable(boolean resizable)
{
this.resizable = resizable;
if (peer != null)
{
DialogPeer d = (DialogPeer) peer;
d.setResizable(resizable);
}
}
// A null title is equivalent to an empty title
this.title = (title != null) ? title : "";
this.modal = modal;
visible = false;
/**
* Creates this object's native peer.
*/
public synchronized void addNotify()
{
if (peer == null)
peer = getToolkit().createDialog(this);
super.addNotify();
}
setLayout (new BorderLayout ());
}
/**
* Makes this dialog visible and brings it to the front. If the dialog is
* modal and is not already visible, this call will not return until the
* dialog is hidden by someone calling hide or dispose. If this is the event
* dispatching thread we must ensure that another event thread runs while the
* one which invoked this method is blocked.
*
* @deprecated Use {@link Component#setVisible(boolean)} instead.
*/
public synchronized void show()
{
super.show();
/*************************************************************************/
if (isModal())
{
// If already shown (and blocked) just return
if (blocked)
return;
/*
* Instance Variables
*/
/*
* If show is called in the dispatch thread for a modal dialog it will
* block so we must run another thread so the events keep being
* dispatched.
*/
if (EventQueue.isDispatchThread())
{
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
eq2 = new EventQueue();
eq.push(eq2);
}
/**
* Returns the title of this dialog box.
*
* @return The title of this dialog box.
*/
public String
getTitle()
{
return(title);
}
try
{
blocked = true;
wait();
blocked = false;
}
catch (InterruptedException e)
{
blocked = false;
}
/*************************************************************************/
if (eq2 != null)
{
eq2.pop();
eq2 = null;
}
}
}
/**
* Sets the title of this dialog box to the specified string.
*
* @param title The new title.
*/
public synchronized void
setTitle(String title)
{
// A null title is equivalent to an empty title
this.title = (title != null) ? title : "";
/**
* Hides the Dialog and then causes show() to return if it is currently
* blocked.
*
* @deprecated Use {@link Component#setVisible(boolean)} instead.
*/
public synchronized void hide()
{
if (blocked)
{
notifyAll();
}
if (peer != null)
{
DialogPeer d = (DialogPeer) peer;
d.setTitle (title);
}
}
super.hide();
}
/*************************************************************************/
/**
* Disposes the Dialog and then causes show() to return if it is currently
* blocked.
*/
public synchronized void dispose()
{
if (blocked)
{
notifyAll();
}
/**
* Tests whether or not this dialog box is modal.
*
* @return <code>true</code> if this dialog box is modal,
* <code>false</code> otherwise.
*/
public boolean
isModal()
{
return(modal);
}
super.dispose();
}
/*************************************************************************/
/**
* Changes the modality of this dialog box. This can only be done before
* the peer is created.
*
* @param modal <code>true</code> to make this dialog box modal,
* <code>false</code> to make it non-modal.
*/
public void
setModal(boolean modal)
{
this.modal = modal;
}
/*************************************************************************/
/**
* Tests whether or not this dialog box is resizable.
*
* @return <code>true</code> if this dialog is resizable, <code>false</code>,
* otherwise.
*/
public boolean
isResizable()
{
return(resizable);
}
/*************************************************************************/
/**
* Changes the resizability of this dialog box.
*
* @param resizable <code>true</code> to make this dialog resizable,
* <code>false</code> to make it non-resizable.
*/
public synchronized void
setResizable(boolean resizable)
{
this.resizable = resizable;
if (peer != null)
{
DialogPeer d = (DialogPeer) peer;
d.setResizable (resizable);
}
}
/*************************************************************************/
/**
* Creates this object's native peer.
*/
public synchronized void
addNotify()
{
if (peer == null)
peer = getToolkit ().createDialog (this);
super.addNotify ();
}
/*************************************************************************/
/**
* Makes this dialog visible and brings it to the front.
* If the dialog is modal and is not already visible, this call will not
* return until the dialog is hidden by someone calling hide or dispose.
* If this is the event dispatching thread we must ensure that another event
* thread runs while the one which invoked this method is blocked.
*/
public synchronized void
show()
{
super.show();
if (isModal())
{
// If already shown (and blocked) just return
if (blocked)
return;
/* If show is called in the dispatch thread for a modal dialog it will
block so we must run another thread so the events keep being
dispatched.*/
if (EventQueue.isDispatchThread ())
{
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
eq2 = new EventQueue ();
eq.push (eq2);
}
try
{
blocked = true;
wait ();
blocked = false;
}
catch (InterruptedException e)
{
blocked = false;
}
if (eq2 != null)
{
eq2.pop ();
eq2 = null;
}
}
}
/*************************************************************************/
/**
* Hides the Dialog and then
* causes show() to return if it is currently blocked.
*/
public synchronized void
hide ()
{
if (blocked)
{
notifyAll ();
}
super.hide();
}
/*************************************************************************/
/**
* Disposes the Dialog and then causes show() to return
* if it is currently blocked.
*/
public synchronized void
dispose ()
{
if (blocked)
{
notifyAll ();
}
super.dispose();
}
/*************************************************************************/
/**
* Returns a debugging string for this component.
*
* @return A debugging string for this component.
*/
protected String
paramString()
{
return ("title+" + title + ",modal=" + modal +
",resizable=" + resizable + "," + super.paramString());
}
/**
* Returns a debugging string for this component.
*
* @return A debugging string for this component.
*/
protected String paramString()
{
return "title+" + title + ",modal=" + modal + ",resizable=" + resizable
+ "," + super.paramString();
}
/**
* Returns whether this frame is undecorated or not.
*
* @return <code>true</code> if this dialog is undecorated,
* <code>false</code> otherwise.
*
* @since 1.4
*/
public boolean isUndecorated ()
public boolean isUndecorated()
{
return undecorated;
}
@ -505,28 +471,42 @@ paramString()
* Disables or enables decorations for this frame. This method can only be
* called while the frame is not displayable.
*
* @exception IllegalComponentStateException If this frame is displayable.
* @param undecorated <code>true</code> to disable dialog decorations,
* <code>false</code> otherwise.
*
* @exception IllegalComponentStateException If this frame is displayable.
* @since 1.4
*/
public void setUndecorated (boolean undecorated)
public void setUndecorated(boolean undecorated)
{
if (isDisplayable ())
throw new IllegalComponentStateException ();
if (isDisplayable())
throw new IllegalComponentStateException();
this.undecorated = undecorated;
}
protected class AccessibleAWTDialog extends AccessibleAWTWindow
/**
* Accessibility support for <code>Dialog</code>.
*/
protected class AccessibleAWTDialog
extends AccessibleAWTWindow
{
private static final long serialVersionUID = 4837230331833941201L;
/**
* Gets the role of this object.
* @return AccessibleRole.DIALOG
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.DIALOG;
}
public AccessibleStateSet getAccessibleState()
/**
* Gets the state set of this object.
* @return The current state of this dialog.
*/
public AccessibleStateSet getAccessibleStateSet()
{
AccessibleStateSet states = super.getAccessibleStateSet();
if (isResizable())
@ -536,11 +516,11 @@ paramString()
return states;
}
}
/**
* Gets the AccessibleContext associated with this <code>Dialog</code>.
* The context is created, if necessary.
*
* Gets the AccessibleContext associated with this <code>Dialog</code>. The
* context is created, if necessary.
*
* @return the associated context
*/
public AccessibleContext getAccessibleContext()
@ -551,5 +531,4 @@ paramString()
return accessibleContext;
}
} // class Dialog
}

View file

@ -614,16 +614,27 @@ public class Frame extends Window implements MenuContainer
return next_frame_number++;
}
/**
* Accessibility support for <code>Frame</code>.
*/
protected class AccessibleAWTFrame extends AccessibleAWTWindow
{
private static final long serialVersionUID = -6172960752956030250L;
/**
* Gets the role of this object.
* @return AccessibleRole.FRAME
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.FRAME;
}
public AccessibleStateSet getAccessibleState()
/**
* Gets the state set of this object.
* @return The current state of this frame.
*/
public AccessibleStateSet getAccessibleStateSet()
{
AccessibleStateSet states = super.getAccessibleStateSet();
if (isResizable())

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt;
import gnu.classpath.NotImplementedException;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
@ -216,6 +218,7 @@ public abstract class GraphicsConfiguration
* @since 1.4
*/
public BufferCapabilities getBufferCapabilities()
throws NotImplementedException
{
throw new Error("not implemented");
}
@ -227,6 +230,7 @@ public abstract class GraphicsConfiguration
* @since 1.4
*/
public ImageCapabilities getImageCapabilities()
throws NotImplementedException
{
throw new Error("not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt;
import gnu.classpath.NotImplementedException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
@ -323,6 +325,7 @@ public class GridBagLayout
* Obsolete.
*/
protected void AdjustForGravity (GridBagConstraints gbc, Rectangle rect)
throws NotImplementedException
{
// FIXME
throw new Error ("Not implemented");
@ -349,107 +352,121 @@ public class GridBagLayout
// be invalidated, clearing the layout information cache,
// layoutInfo. So we wait until after this for loop to set
// layoutInfo.
for(int i = 0; i < components.length; i++)
{
Component component = components [i];
// If component is not visible we dont have to care about it.
if (!component.isVisible())
continue;
GridBagConstraints constraints =
lookupInternalConstraints(component);
Component lastComp = null;
int cellx = 0;
int celly = 0;
int cellw = 0;
int cellh = 0;
for (int i = 0; i < components.length; i++)
{
Component component = components[i];
int cellx = sumIntArray(info.colWidths, constraints.gridx);
int celly = sumIntArray(info.rowHeights, constraints.gridy);
int cellw = sumIntArray(info.colWidths,
constraints.gridx + constraints.gridwidth) - cellx;
int cellh = sumIntArray(info.rowHeights,
constraints.gridy + constraints.gridheight) - celly;
// If component is not visible we dont have to care about it.
if (! component.isVisible())
continue;
Insets insets = constraints.insets;
if (insets != null)
{
cellx += insets.left;
celly += insets.top;
cellw -= insets.left + insets.right;
cellh -= insets.top + insets.bottom;
}
Dimension dim = component.getPreferredSize();
GridBagConstraints constraints = lookupInternalConstraints(component);
if (lastComp != null
&& constraints.gridheight == GridBagConstraints.REMAINDER)
celly += cellh;
else
celly = sumIntArray(info.rowHeights, constraints.gridy);
if (lastComp != null
&& constraints.gridwidth == GridBagConstraints.REMAINDER)
cellx += cellw;
else
cellx = sumIntArray(info.colWidths, constraints.gridx);
Dimension dim = component.getPreferredSize();
cellw = sumIntArray(info.colWidths, constraints.gridx
+ constraints.gridwidth) - cellx;
cellh = sumIntArray(info.rowHeights, constraints.gridy
+ constraints.gridheight) - celly;
Insets insets = constraints.insets;
if (insets != null)
{
cellx += insets.left;
celly += insets.top;
cellw -= insets.left + insets.right;
cellh -= insets.top + insets.bottom;
}
// Note: Documentation says that padding is added on both sides, but
// visual inspection shows that the Sun implementation only adds it
// once, so we do the same.
dim.width += constraints.ipadx;
dim.height += constraints.ipady;
// Note: Documentation says that padding is added on both sides, but
// visual inspection shows that the Sun implementation only adds it
// once, so we do the same.
dim.width += constraints.ipadx;
dim.height += constraints.ipady;
switch(constraints.fill)
{
case GridBagConstraints.HORIZONTAL:
dim.width = cellw;
break;
case GridBagConstraints.VERTICAL:
dim.height = cellh;
break;
case GridBagConstraints.BOTH:
dim.width = cellw;
dim.height = cellh;
break;
}
switch (constraints.fill)
{
case GridBagConstraints.HORIZONTAL:
dim.width = cellw;
break;
case GridBagConstraints.VERTICAL:
dim.height = cellh;
break;
case GridBagConstraints.BOTH:
dim.width = cellw;
dim.height = cellh;
break;
}
int x;
int y;
int x = 0;
int y = 0;
switch(constraints.anchor)
{
case GridBagConstraints.NORTH:
x = cellx + (cellw - dim.width) / 2;
y = celly;
break;
case GridBagConstraints.SOUTH:
x = cellx + (cellw - dim.width) / 2;
y = celly + cellh - dim.height;
break;
case GridBagConstraints.WEST:
x = cellx;
y = celly + (cellh - dim.height) / 2;
break;
case GridBagConstraints.EAST:
x = cellx + cellw - dim.width;
y = celly + (cellh - dim.height) / 2;
break;
case GridBagConstraints.NORTHEAST:
x = cellx + cellw - dim.width;
y = celly;
break;
case GridBagConstraints.NORTHWEST:
x = cellx;
y = celly;
break;
case GridBagConstraints.SOUTHEAST:
x = cellx + cellw - dim.width;
y = celly + cellh - dim.height;
break;
case GridBagConstraints.SOUTHWEST:
x = cellx;
y = celly + cellh - dim.height;
break;
default:
x = cellx + (cellw - dim.width) / 2;
y = celly + (cellh - dim.height) / 2;
break;
}
switch (constraints.anchor)
{
case GridBagConstraints.NORTH:
x = cellx + (cellw - dim.width) / 2;
y = celly;
break;
case GridBagConstraints.SOUTH:
x = cellx + (cellw - dim.width) / 2;
y = celly + cellh - dim.height;
break;
case GridBagConstraints.WEST:
x = cellx;
y = celly + (cellh - dim.height) / 2;
break;
case GridBagConstraints.EAST:
x = cellx + cellw - dim.width;
y = celly + (cellh - dim.height) / 2;
break;
case GridBagConstraints.NORTHEAST:
x = cellx + cellw - dim.width;
y = celly;
break;
case GridBagConstraints.NORTHWEST:
x = cellx;
y = celly;
break;
case GridBagConstraints.SOUTHEAST:
x = cellx + cellw - dim.width;
y = celly + cellh - dim.height;
break;
case GridBagConstraints.SOUTHWEST:
x = cellx;
y = celly + cellh - dim.height;
break;
default:
x = cellx + (cellw - dim.width) / 2;
y = celly + (cellh - dim.height) / 2;
break;
}
component.setBounds(info.pos_x + x, info.pos_y + y, dim.width,
dim.height);
lastComp = component;
}
component.setBounds(info.pos_x + x, info.pos_y + y, dim.width, dim.height);
}
// DEBUG
//dumpLayoutInfo(info);
// DEBUG
//dumpLayoutInfo (info);
// Cache layout information.
layoutInfo = getLayoutInfo (parent, PREFERREDSIZE);
}
// Cache layout information.
layoutInfo = getLayoutInfo(parent, PREFERREDSIZE);
}
/**
* Obsolete.
@ -485,11 +502,10 @@ public class GridBagLayout
for (int i = 0; i < components.length; i++)
{
Component component = components [i];
// If component is not visible we dont have to care about it.
if (!component.isVisible())
continue;
// When looking up the constraint for the first time, check the
// original unmodified constraint. After the first time, always
// refer to the internal modified constraint.
@ -516,7 +532,6 @@ public class GridBagLayout
//
// nothing to check; just add it
// cases 1 and 2
if(constraints.gridx == GridBagConstraints.RELATIVE)
{
@ -560,7 +575,9 @@ public class GridBagLayout
// this column. We want to add this component below it.
// If this column is empty, add to the 0 position.
if (!lastInCol.containsKey(new Integer(constraints.gridx)))
y = 0;
{
y = current_y;
}
else
{
Component lastComponent = (Component)lastInCol.get(new Integer(constraints.gridx));
@ -596,7 +613,7 @@ public class GridBagLayout
// Update our reference points for RELATIVE gridx and gridy.
if(constraints.gridwidth == GridBagConstraints.REMAINDER)
{
current_y = constraints.gridy + Math.max(1, constraints.gridheight);
current_y = constraints.gridy + Math.max(1, constraints.gridheight);
}
else if (constraints.gridwidth != GridBagConstraints.REMAINDER)
{
@ -788,7 +805,7 @@ public class GridBagLayout
height += constraints.insets.top + constraints.insets.bottom;
height += constraints.ipady;
distributeSizeAndWeight(height,
constraints.weighty,
constraints.gridy,
@ -918,7 +935,7 @@ public class GridBagLayout
sizes[start] = Math.max(sizes[start], size);
weights[start] = Math.max(weights[start], weight);
}
else if (span > 1)
else
{
int numOccupied = span;
int lastOccupied = -1;

View file

@ -166,6 +166,8 @@ public abstract class Image
* loading will be produced according to the hints of the algorithm
* requested. If either the width or height is non-positive, it is adjusted
* to preserve the original aspect ratio.
* If an illegal value of <code>flags</code> is passed,
* the default algorithm is used.
*
* @param width the width of the scaled image
* @param height the height of the scaled image
@ -183,18 +185,15 @@ public abstract class Image
ImageFilter filter;
switch (flags)
{
case SCALE_AREA_AVERAGING:
case SCALE_SMOOTH:
filter = new AreaAveragingScaleFilter(width, height);
break;
case SCALE_DEFAULT:
case SCALE_FAST:
case SCALE_REPLICATE:
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("Unknown flag or not implemented: " + flags);
filter = new ReplicateScaleFilter(width, height);
}
ImageProducer producer = new FilteredImageSource(getSource(), filter);

View file

@ -110,14 +110,12 @@ class LightweightDispatcher
*/
public boolean dispatchEvent(AWTEvent event)
{
boolean dispatched = false;
if (event instanceof MouseEvent && event.getSource() instanceof Window)
{
MouseEvent mouseEvent = (MouseEvent) event;
handleMouseEvent(mouseEvent);
dispatched = true;
return handleMouseEvent(mouseEvent);
}
return dispatched;
return false;
}
/**
@ -125,12 +123,14 @@ class LightweightDispatcher
* (Window instances) and dispatches them to the correct lightweight child.
*
* @param ev the mouse event
* @return whether or not we found a lightweight that handled the event.
*/
private void handleMouseEvent(MouseEvent ev)
private boolean handleMouseEvent(MouseEvent ev)
{
Window window = (Window) ev.getSource();
Component target = window.findComponentAt(ev.getX(), ev.getY());
if (target != null && target.isLightweight())
target = findTarget(target);
if (target == null || target.isLightweight())
{
// Dispatch additional MOUSE_EXITED and MOUSE_ENTERED if event target
// is different from the last event target.
@ -146,13 +146,16 @@ class LightweightDispatcher
ev.getClickCount(), ev.isPopupTrigger());
lastTarget.dispatchEvent(mouseExited);
}
Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
target);
MouseEvent mouseEntered =
new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
ev.getModifiers(), p.x, p.y, ev.getClickCount(),
ev.isPopupTrigger());
target.dispatchEvent(mouseEntered);
if (target != null)
{
Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
target);
MouseEvent mouseEntered =
new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
ev.getModifiers(), p.x, p.y, ev.getClickCount(),
ev.isPopupTrigger());
target.dispatchEvent(mouseEntered);
}
}
switch (ev.getID())
@ -183,18 +186,43 @@ class LightweightDispatcher
lastTarget = target;
Point targetCoordinates =
AWTUtilities.convertPoint(window, ev.getX(), ev.getY(), target);
int dx = targetCoordinates.x - ev.getX();
int dy = targetCoordinates.y - ev.getY();
ev.translatePoint(dx, dy);
ev.setSource(target);
target.dispatchEvent(ev);
if (target != null)
{
Point targetCoordinates =
AWTUtilities.convertPoint(window, ev.getX(), ev.getY(), target);
int dx = targetCoordinates.x - ev.getX();
int dy = targetCoordinates.y - ev.getY();
ev.translatePoint(dx, dy);
ev.setSource(target);
target.dispatchEvent(ev);
// We reset the event, so that the normal event dispatching is not
// influenced by this modified event.
ev.setSource(window);
ev.translatePoint(-dx, -dy);
}
// We reset the event, so that the normal event dispatching is not
// influenced by this modified event.
ev.setSource(window);
ev.translatePoint(-dx, -dy);
return true;
}
else
return false;
}
/**
* Finds the actual target for a mouseevent, starting at <code>c</code>.
* This searches upwards the component hierarchy until it finds a component
* that has a mouselistener attached.
*
* @param c the component to start searching from
*
* @return the actual receiver of the mouse event
*/
private Component findTarget(Component c)
{
Component target = c;
while (target != null && target.getMouseListeners().length == 0)
{
target = target.getParent();
}
return target;
}
}

View file

@ -446,7 +446,7 @@ preferredSize(int rows)
if (peer != null)
return peer.preferredSize (rows);
else
return new Dimension (0, 0);
return getSize();
}
/*************************************************************************/

View file

@ -634,7 +634,8 @@ public class MediaTracker implements java.io.Serializable
else
prev.next = e.next;
}
prev = e;
else
prev = e;
e = e.next;
}
}

View file

@ -111,7 +111,7 @@ private transient ActionListener action_listeners;
private static final long serialVersionUID = -217847831945965825L;
/** Constructor */
public AccessibleAWTMenuItem()
protected AccessibleAWTMenuItem()
{
super();
}

View file

@ -178,7 +178,16 @@ public class ScrollPaneAdjustable
public String paramString ()
{
throw new Error ("not implemented");
return ("scrollpane=" + sp + ", orientation=" + orientation
+ ", value=" + value + ", minimum=" + minimum
+ ", maximum=" + maximum + ", visibleAmount=" + visibleAmount
+ ", unitIncrement=" + unitIncrement
+ ", blockIncrement=" + blockIncrement);
}
public String toString()
{
return getClass().getName() + "[" + paramString() + "]";
}
/**

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt;
import gnu.classpath.NotImplementedException;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
@ -65,10 +67,12 @@ public class TexturePaint implements Paint
Rectangle2D userBounds,
AffineTransform xform,
RenderingHints hints)
throws NotImplementedException
{
throw new Error("not implemented");
}
public int getTransparency()
throws NotImplementedException
{
throw new Error("not implemented");
}

View file

@ -1,5 +1,5 @@
/* Toolkit.java -- AWT Toolkit superclass
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt;
import gnu.classpath.SystemProperties;
import gnu.java.awt.peer.GLightweightPeer;
import java.awt.datatransfer.Clipboard;
@ -78,10 +79,15 @@ import java.awt.peer.TextFieldPeer;
import java.awt.peer.WindowPeer;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
/**
* The AWT system uses a set of native peer objects to implement its
@ -525,16 +531,27 @@ public abstract class Toolkit
{
if (toolkit != null)
return toolkit;
String toolkit_name = System.getProperty("awt.toolkit",
default_toolkit_name);
String toolkit_name = SystemProperties.getProperty("awt.toolkit",
default_toolkit_name);
try
{
Class cls = Class.forName(toolkit_name);
ClassLoader cl;
cl = (ClassLoader) AccessController.doPrivileged
(new PrivilegedAction()
{
public Object run()
{
return ClassLoader.getSystemClassLoader();
}
});
Class cls = cl.loadClass(toolkit_name);
Object obj = cls.newInstance();
if (!(obj instanceof Toolkit))
throw new AWTError(toolkit_name + " is not a subclass of " +
"java.awt.Toolkit");
toolkit = (Toolkit) obj;
initAccessibility();
return toolkit;
}
catch (ThreadDeath death)
@ -696,9 +713,18 @@ public abstract class Toolkit
public abstract Clipboard getSystemClipboard();
/**
* Gets the singleton instance of the system selection as a Clipboard object.
* Gets the singleton instance of the system selection as a
* Clipboard object. The system selection contains the selected text
* of the last component/widget that had focus and a text selection.
* The default implementation returns null.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
* @return The Clipboard holding the system (text) selection or null
* if the Toolkit or system doesn't support a selection clipboard.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless()
* is true.
* @exception SecurityException If the current security manager
* checkSystemClipboardAccess() doesn't allow access.
*
* @since 1.4
*/
@ -1206,4 +1232,138 @@ public abstract class Toolkit
* @since 1.3
*/
public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight);
/**
* Initializes the accessibility framework. In particular, this loads the
* properties javax.accessibility.screen_magnifier_present and
* javax.accessibility.screen_reader_present and loads
* the classes specified in javax.accessibility.assistive_technologies.
*/
private static void initAccessibility()
{
AccessController.doPrivileged
(new PrivilegedAction()
{
public Object run()
{
Properties props = new Properties();
String sep = File.separator;
// Try the user configuration.
try
{
File propsFile = new File(System.getProperty("user.home") + sep
+ ".accessibility.properties");
FileInputStream in = new FileInputStream(propsFile);
props.load(in);
in.close();
}
catch (Exception ex)
{
// User configuration not present, ignore.
}
// Try the system configuration if there was no user configuration.
if (props.size() == 0)
{
try
{
File propsFile =
new File(System.getProperty("gnu.classpath.home.url")
+ sep + "accessibility.properties");
FileInputStream in = new FileInputStream(propsFile);
props.load(in);
in.close();
}
catch (Exception ex)
{
// System configuration not present, ignore.
}
}
// Fetch the screen_magnifier_present property. Check systen properties
// first, then fallback to the configuration file.
String magPresent = SystemProperties.getProperty
("javax.accessibility.screen_magnifier_present");
if (magPresent == null)
{
magPresent = props.getProperty("screen_magnifier_present");
if (magPresent != null)
{
SystemProperties.setProperty
("javax.accessibility.screen_magnifier_present", magPresent);
}
}
// Fetch the screen_reader_present property. Check systen properties
// first, then fallback to the configuration file.
String readerPresent = SystemProperties.getProperty
("javax.accessibility.screen_reader_present");
if (readerPresent == null)
{
readerPresent = props.getProperty("screen_reader_present");
if (readerPresent != null)
{
SystemProperties.setProperty
("javax.accessibility.screen_reader_present", readerPresent);
}
}
// Fetch the list of classes to be loaded.
String classes = SystemProperties.getProperty
("javax.accessibility.assistive_technologies");
if (classes == null)
{
classes = props.getProperty("assistive_technologies");
if (classes != null)
{
SystemProperties.setProperty
("javax.accessibility.assistive_technologies", classes);
}
}
// Try to load the assisitive_technologies classes.
if (classes != null)
{
ClassLoader cl = ClassLoader.getSystemClassLoader();
StringTokenizer tokenizer = new StringTokenizer(classes, ",");
while (tokenizer.hasMoreTokens())
{
String className = tokenizer.nextToken();
try
{
Class atClass = cl.loadClass(className);
atClass.newInstance();
}
catch (ClassNotFoundException ex)
{
AWTError err = new AWTError("Assistive Technology class not"
+ " found: " + className);
err.initCause(ex);
throw err;
}
catch (InstantiationException ex)
{
AWTError err =
new AWTError("Assistive Technology class cannot be "
+ "instantiated: " + className);
err.initCause(ex);
throw err;
}
catch (IllegalAccessException ex)
{
AWTError err =
new AWTError("Assistive Technology class cannot be "
+ "accessed: " + className);
err.initCause(err);
throw err;
}
}
}
return null;
}
});
}
} // class Toolkit

View file

@ -1,5 +1,5 @@
/* Window.java --
Copyright (C) 1999, 2000, 2002, 2003, 2004 Free Software Foundation
Copyright (C) 1999, 2000, 2002, 2003, 2004, 2006 Free Software Foundation
This file is part of GNU Classpath.
@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt;
import gnu.classpath.NotImplementedException;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter;
@ -620,10 +622,25 @@ public class Window extends Container implements Accessible
|| windowStateListener != null
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
processEvent(e);
else if (e.id == ComponentEvent.COMPONENT_RESIZED)
validate ();
else
super.dispatchEventImpl(e);
else
{
if (peer != null && (e.id == ComponentEvent.COMPONENT_RESIZED
|| e.id == ComponentEvent.COMPONENT_MOVED))
{
Rectangle bounds = peer.getBounds();
x = bounds.x;
y = bounds.y;
height = bounds.height;
width = bounds.width;
if (e.id == ComponentEvent.COMPONENT_RESIZED)
{
invalidate();
validate();
}
}
super.dispatchEventImpl(e);
}
}
/**
@ -1032,6 +1049,7 @@ public class Window extends Container implements Accessible
* @deprecated
*/
public void applyResourceBundle(ResourceBundle rb)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
@ -1143,6 +1161,47 @@ public class Window extends Container implements Accessible
{
this.focusableWindowState = focusableWindowState;
}
/**
* Check whether this Container is a focus cycle root.
* Returns always <code>true</code> as Windows are the
* root of the focus cycle.
*
* @return Always <code>true</code>.
*
* @since 1.4
*/
public final boolean isFocusCycleRoot()
{
return true;
}
/**
* Set whether or not this Container is the root of a focus
* traversal cycle. Windows are the root of the focus cycle
* and therefore this method does nothing.
*
* @param focusCycleRoot ignored.
*
* @since 1.4
*/
public final void setFocusCycleRoot(boolean focusCycleRoot)
{
// calls to the method are ignored
}
/**
* Returns the root container that owns the focus cycle where this
* component resides. Windows have no ancestors and this method
* returns always <code>null</code>.
*
* @return Always <code>null</code>.
* @since 1.4
*/
public final Container getFocusCycleRootAncestor()
{
return null;
}
/**
* Generate a unique name for this window.

View file

@ -45,6 +45,8 @@ import java.util.EventObject;
* Fired by a ClipBoard for registered FlavorListeners.
*
* @author Mark J. Wielaard (mark@klomp.org)
*
* @since 1.5
*/
public class FlavorEvent extends EventObject
{

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.datatransfer;
import gnu.classpath.NotImplementedException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -262,11 +264,13 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable
* version of the native.
*/
public List getFlavorsForNative (String nat)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public List getNativesForFlavor (DataFlavor flav)
throws NotImplementedException
{
throw new Error ("Not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.dnd;
import gnu.classpath.NotImplementedException;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.InputEvent;
@ -126,6 +128,7 @@ public abstract class DragGestureRecognizer implements Serializable
}
public void resetRecognizer()
throws NotImplementedException
{
throw new Error("not implemented");
}
@ -152,6 +155,7 @@ public abstract class DragGestureRecognizer implements Serializable
}
protected void fireDragGestureRecognized(int dragAction, Point p)
throws NotImplementedException
{
throw new Error("not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.dnd;
import gnu.classpath.NotImplementedException;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Image;
@ -86,6 +88,7 @@ public class DragSourceContext
DragGestureEvent trigger, Cursor cursor,
Image image, Point offset, Transferable trans,
DragSourceListener dsl)
throws NotImplementedException
{
if (peer == null
|| trigger == null)
@ -130,6 +133,7 @@ public class DragSourceContext
}
public void setCursor (Cursor cursor)
throws NotImplementedException
{
this.cursor = cursor;
// FIXME: Check if we need to do more here
@ -162,30 +166,37 @@ public class DragSourceContext
}
public void transferablesFlavorsChanged()
throws NotImplementedException
{
}
public void dragEnter(DragSourceDragEvent e)
throws NotImplementedException
{
}
public void dragOver(DragSourceDragEvent e)
throws NotImplementedException
{
}
public void dragExit(DragSourceEvent e)
throws NotImplementedException
{
}
public void dropActionChanged(DragSourceDragEvent e)
throws NotImplementedException
{
}
public void dragDropEnd(DragSourceDropEvent e)
throws NotImplementedException
{
}
public void dragMouseMoved(DragSourceDragEvent e)
throws NotImplementedException
{
}
@ -195,6 +206,7 @@ public class DragSourceContext
}
protected void updateCurrentCursor(int dropOp, int targetAct, int status)
throws NotImplementedException
{
}
} // class DragSourceContext

View file

@ -61,9 +61,7 @@ public class DropTarget
*/
private static final long serialVersionUID = -6283860791671019047L;
/** @specnote According to the online documentation, this is
* protected, but in reality it is public. */
public static class DropTargetAutoScroller
protected static class DropTargetAutoScroller
implements ActionListener
{
private Component component;

View file

@ -54,9 +54,7 @@ public class DropTargetContext implements Serializable
{
static final long serialVersionUID = -634158968993743371L;
/** @specnote According to the online documentation, this is
* protected, but in reality it is public. */
public class TransferableProxy implements Transferable
protected class TransferableProxy implements Transferable
{
protected boolean isLocal;
protected Transferable transferable;

View file

@ -41,6 +41,8 @@ import java.util.EventObject;
public class DropTargetEvent extends EventObject
{
private static final long serialVersionUID = 2821229066521922993L;
protected DropTargetContext context;
public DropTargetEvent (DropTargetContext context)

View file

@ -402,7 +402,11 @@ public class MouseEvent extends InputEvent
// FIXME: need a mauve test for this method
if (modifiersEx != 0)
s.append(",extModifiers=").append(getModifiersExText(modifiersEx));
return s.append(",clickCount=").append(clickCount).toString();
s.append(",clickCount=").append(clickCount);
s.append(",consumed=").append(consumed);
return s.toString();
}
/**

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.font;
import gnu.classpath.NotImplementedException;
import java.awt.geom.Rectangle2D;
/**
@ -93,11 +95,13 @@ public final class GlyphMetrics
}
public float getLSB ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
public float getRSB ()
throws NotImplementedException
{
throw new Error ("not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.font;
import gnu.classpath.NotImplementedException;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.Shape;
@ -70,12 +72,14 @@ public abstract class GlyphVector implements Cloneable
public abstract FontRenderContext getFontRenderContext ();
public int getGlyphCharIndex (int glyphIndex)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public int[] getGlyphCharIndices (int beginGlyphIndex, int numEntries,
int[] codeReturn)
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -95,12 +99,14 @@ public abstract class GlyphVector implements Cloneable
public abstract Shape getGlyphOutline (int glyphIndex);
public Shape getGlyphOutline (int glyphIndex, float x, float y)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public Rectangle getGlyphPixelBounds (int index, FontRenderContext renderFRC,
float x, float y)
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -116,6 +122,7 @@ public abstract class GlyphVector implements Cloneable
public abstract Shape getGlyphVisualBounds (int glyphIndex);
public int getLayoutFlags ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -130,6 +137,7 @@ public abstract class GlyphVector implements Cloneable
public Rectangle getPixelBounds (FontRenderContext renderFRC,
float x, float y)
throws NotImplementedException
{
throw new Error ("not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.font;
import gnu.classpath.NotImplementedException;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
@ -71,6 +73,7 @@ public abstract class GraphicAttribute
public abstract float getAscent ();
public Rectangle2D getBounds ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -78,6 +81,7 @@ public abstract class GraphicAttribute
public abstract float getDescent ();
public GlyphJustificationInfo getJustificationInfo ()
throws NotImplementedException
{
throw new Error ("not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.font;
import gnu.classpath.NotImplementedException;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.Rectangle2D;
@ -57,6 +59,7 @@ public final class ImageGraphicAttribute extends GraphicAttribute
public ImageGraphicAttribute (Image image, int alignment, float originX,
float originY)
throws NotImplementedException
{
super (alignment);
this.image = image;
@ -65,6 +68,7 @@ public final class ImageGraphicAttribute extends GraphicAttribute
}
public void draw (Graphics2D graphics, float x, float y)
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -78,31 +82,37 @@ public final class ImageGraphicAttribute extends GraphicAttribute
}
public boolean equals (ImageGraphicAttribute rhs)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public float getAdvance ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
public float getAscent ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
public Rectangle2D getBounds ()
public Rectangle2D getBounds ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
public float getDescent ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
public int hashCode ()
throws NotImplementedException
{
throw new Error ("not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.font;
import gnu.classpath.NotImplementedException;
import java.text.AttributedCharacterIterator;
import java.text.BreakIterator;
@ -69,6 +71,7 @@ public final class LineBreakMeasurer
public void deleteChar (AttributedCharacterIterator newParagraph,
int deletePos)
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -80,28 +83,33 @@ public final class LineBreakMeasurer
public void insertChar (AttributedCharacterIterator newParagraph,
int insertPos)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public TextLayout nextLayout (float wrappingWidth)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public TextLayout nextLayout (float wrappingWidth, int offsetLimit,
boolean requireNextWord)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public int nextOffset (float wrappingWidth)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public int nextOffset (float wrappingWidth, int offsetLimit,
boolean requireNextWord)
throws NotImplementedException
{
throw new Error ("not implemented");
}

View file

@ -39,99 +39,387 @@ exception statement from your version. */
package java.awt.font;
import java.io.Serializable;
import java.lang.Character.UnicodeBlock;
/**
* This class handles numeric shaping. A shaper can either be contextual
* or not. A non-contextual shaper will always translate ASCII digits
* in its input into the target Unicode range. A contextual shaper will
* change the target Unicode range depending on the characters it has
* previously processed.
*
* @author Michael Koch
* @author Tom Tromey
*
* @since 1.4
* @specnote This class does not handle LIMBU or OSMANYA.
* @specnote The JDK does not seem to properly handle ranges without a
* digit zero, such as TAMIL. This implementation does.
*/
public final class NumericShaper implements Serializable
{
private static final long serialVersionUID = -8022764705923730308L;
/** Convenience constant representing all the valid Unicode ranges. */
public static final int ALL_RANGES = 524287;
/**
* Constant representing the Unicode ARABIC range. Shaping done
* using this range will translate to the arabic decimal characters.
* Use EASTERN_ARABIC if you want to shape to the eastern arabic
* (also known as the extended arabic) decimal characters.
*/
public static final int ARABIC = 2;
/** Constant representing the Unicode BENGALI range. */
public static final int BENGALI = 16;
/** Constant representing the Unicode DEVANAGARI range. */
public static final int DEVANAGARI = 8;
/**
* Constant representing the Unicode extended arabic range.
* In Unicode there are two different sets of arabic digits;
* this selects the extended or eastern set.
*/
public static final int EASTERN_ARABIC = 4;
/**
* Constant representing the Unicode ETHIOPIC range. Note that
* there is no digit zero in this range; an ASCII digit zero
* is left unchanged when shaping to this range.
*/
public static final int ETHIOPIC = 65536;
/**
* Constant representing the Unicode EUROPEAN range. For
* contextual shaping purposes, characters in the various
* extended Latin character blocks are recognized as EUROPEAN.
*/
public static final int EUROPEAN = 1;
/** Constant representing the Unicode GUJARATI range. */
public static final int GUJARATI = 64;
/** Constant representing the Unicode GURMUKHI range. */
public static final int GURMUKHI = 32;
/** Constant representing the Unicode KANNADA range. */
public static final int KANNADA = 1024;
/** Constant representing the Unicode KHMER range. */
public static final int KHMER = 131072;
/** Constant representing the Unicode LAO range. */
public static final int LAO = 8192;
/** Constant representing the Unicode MALAYALAM range. */
public static final int MALAYALAM = 2048;
/** Constant representing the Unicode MONGOLIAN range. */
public static final int MONGOLIAN = 262144;
/** Constant representing the Unicode MYANMAR range. */
public static final int MYANMAR = 32768;
/** Constant representing the Unicode ORIYA range. */
public static final int ORIYA = 128;
/**
* Constant representing the Unicode TAMIL range. Note that
* there is no digit zero in this range; an ASCII digit zero
* is left unchanged when shaping to this range.
*/
public static final int TAMIL = 256;
/** Constant representing the Unicode TELUGU range. */
public static final int TELUGU = 512;
/** Constant representing the Unicode THAI range. */
public static final int THAI = 4096;
/** Constant representing the Unicode TIBETAN range. */
public static final int TIBETAN = 16384;
private int ranges;
private int context;
private NumericShaper (int ranges, int context)
/**
* This table holds the zero digits for each language. This is hard-coded
* because the values will not change and the table layout is tied to the
* other constants in this class in any case. In the two places where a
* language does not have a zero digit, the character immediately preceeding
* the one digit is used instead. These languages are special-cased in
* the shaping code.
*/
private static final char[] zeroDigits =
{
this.ranges = ranges;
this.context = context;
'0', // EUROPEAN
'\u0660', // ARABIC
'\u06f0', // EASTERN_ARABIC
'\u0966', // DEVANAGARI
'\u09e6', // BENGALI
'\u0a66', // GURMUKHI
'\u0ae6', // GUJARATI
'\u0b66', // ORIYA
'\u0be6', // TAMIL - special case as there is no digit zero
'\u0c66', // TELUGU
'\u0ce6', // KANNADA
'\u0d66', // MALAYALAM
'\u0e50', // THAI
'\u0ed0', // LAO
'\u0f20', // TIBETAN
'\u1040', // MYANMAR
'\u1368', // ETHIOPIC - special case as there is no digit zero
'\u17e0', // KHMER
'\u1810' // MONGOLIAN
};
/**
* The default initial context for this shaper, specified as
* an integer from 0 to 18.
*/
private int key;
/**
* The target ranges handled by this shaper. If the shaper
* is not contextual, the high bit of this field will be set.
* @specnote This was discovered by reading the serialization spec
*/
private int mask;
/**
* Create a new numeric shaper. The key given is a constant from
* this class, the constructor turns it into its internal form.
* @param key the key to use, as one of the manifest constants
* @param mask a mask of languages to shape for
*/
private NumericShaper (int key, int mask)
{
// This internal form is a bit goofy, but it is specified by
// the serialization spec.
this.key = Integer.numberOfTrailingZeros(key);
this.mask = mask;
}
/**
* Return an integer representing all the languages for which this
* shaper will shape. The result is taken by "or"ing together
* the constants representing the various languages.
*/
public int getRanges ()
{
return mask & ALL_RANGES;
}
/**
* Return true if this shaper is contextual, false if it is not.
*/
public boolean isContextual ()
{
return mask > 0;
}
/**
* Shape the text in the given array. The starting context will
* be the context passed to the shaper at creation time.
* @param text the text to shape
* @param start the index of the starting character of the array
* @param count the number of characters in the array
*/
public void shape (char[] text, int start, int count)
{
shape (text, start, count, 1 << key);
}
/**
* Given a unicode block object, return corresponding language constant.
* If the block is not recognized, returns zero. Note that as there
* is no separate ARABIC block in Character, this case must
* be specially handled by the caller; EASTERN_ARABIC is preferred when
* both are specified.
* @param b the unicode block to classify
* @return the language constant, or zero if not recognized
*/
private int classify(UnicodeBlock b)
{
if (b == null)
return 0;
// ARABIC is handled by the caller; from testing we know
// that EASTERN_ARABIC takes precedence.
if (b == UnicodeBlock.ARABIC)
return EASTERN_ARABIC;
if (b == UnicodeBlock.BENGALI)
return BENGALI;
if (b == UnicodeBlock.DEVANAGARI)
return DEVANAGARI;
if (b == UnicodeBlock.ETHIOPIC)
return ETHIOPIC;
if (b == UnicodeBlock.BASIC_LATIN
|| b == UnicodeBlock.LATIN_1_SUPPLEMENT
|| b == UnicodeBlock.LATIN_EXTENDED_A
|| b == UnicodeBlock.LATIN_EXTENDED_ADDITIONAL
|| b == UnicodeBlock.LATIN_EXTENDED_B)
return EUROPEAN;
if (b == UnicodeBlock.GUJARATI)
return GUJARATI;
if (b == UnicodeBlock.GURMUKHI)
return GURMUKHI;
if (b == UnicodeBlock.KANNADA)
return KANNADA;
if (b == UnicodeBlock.KHMER)
return KHMER;
if (b == UnicodeBlock.LAO)
return LAO;
if (b == UnicodeBlock.MALAYALAM)
return MALAYALAM;
if (b == UnicodeBlock.MONGOLIAN)
return MONGOLIAN;
if (b == UnicodeBlock.MYANMAR)
return MYANMAR;
if (b == UnicodeBlock.ORIYA)
return ORIYA;
if (b == UnicodeBlock.TAMIL)
return TAMIL;
if (b == UnicodeBlock.TELUGU)
return TELUGU;
if (b == UnicodeBlock.THAI)
return THAI;
if (b == UnicodeBlock.TIBETAN)
return TIBETAN;
return 0;
}
/**
* Shape the given text, using the indicated initial context.
* If this shaper is not a contextual shaper, then the given context
* will be ignored.
* @param text the text to shape
* @param start the index of the first character of the text to shape
* @param count the number of characters to shape in the text
* @param context the initial context
* @throws IllegalArgumentException if the initial context is invalid
*/
public void shape (char[] text, int start, int count, int context)
{
int currentContext;
if (isContextual())
{
if (Integer.bitCount(context) != 1 || (context & ~ALL_RANGES) != 0)
throw new IllegalArgumentException("invalid context argument");
// If the indicated context is not one we are handling, reset it.
if ((context & mask) == 0)
currentContext = -1;
else
currentContext = Integer.numberOfTrailingZeros(context);
}
else
currentContext = key;
for (int i = 0; i < count; ++i)
{
char c = text[start + i];
if (c >= '0' && c <= '9')
{
if (currentContext >= 0)
{
// Shape into the current context.
if (c == '0'
&& ((1 << currentContext) == TAMIL
|| (1 << currentContext) == ETHIOPIC))
{
// No digit 0 in this context; do nothing.
}
else
text[start + i]
= (char) (zeroDigits[currentContext] + c - '0');
}
}
else if (isContextual())
{
// if c is in a group, set currentContext; else reset it.
int group = classify(UnicodeBlock.of(c));
// Specially handle ARABIC.
if (group == EASTERN_ARABIC && (mask & EASTERN_ARABIC) == 0
&& (mask & ARABIC) != 0)
group = ARABIC;
if ((mask & group) != 0)
{
// The character was classified as being in a group
// we recognize, and it was selected by the shaper.
// So, change the context.
currentContext = Integer.numberOfTrailingZeros(group);
}
}
}
}
public boolean equals (Object obj)
{
if (! (obj instanceof NumericShaper))
return false;
NumericShaper tmp = (NumericShaper) obj;
return (ranges == tmp.ranges
&& context == tmp.context);
}
public static NumericShaper getContextualShaper (int ranges)
{
throw new Error ("not implemented");
}
public static NumericShaper getContextualShaper (int ranges,
int defaultContext)
{
throw new Error ("not implemented");
}
public int getRanges ()
{
return ranges;
}
public static NumericShaper getShaper (int singleRange)
{
throw new Error ("not implemented");
return key == tmp.key && mask == tmp.mask;
}
public int hashCode ()
{
throw new Error ("not implemented");
}
public boolean isContextual ()
{
throw new Error ("not implemented");
}
public void shape (char[] text, int start, int count)
{
shape (text, start, count, context);
}
public void shape (char[] text, int start, int count, int context)
{
throw new Error ("not implemented");
return key ^ mask;
}
public String toString ()
{
throw new Error ("not implemented");
// For debugging only.
return "key=" + key + "; mask=" + mask;
}
/**
* Return a non-contextual shaper which can shape to a single range.
* All ASCII digits in the input text are translated to this language.
* @param singleRange the target language
* @return a non-contextual shaper for this language
* @throws IllegalArgumentException if the argument does not name a
* single language, as specified by the constants declared in this class
*/
public static NumericShaper getShaper (int singleRange)
{
if (Integer.bitCount(singleRange) != 1)
throw new IllegalArgumentException("more than one bit set in argument");
if ((singleRange & ~ALL_RANGES) != 0)
throw new IllegalArgumentException("argument out of range");
return new NumericShaper(singleRange, Integer.MIN_VALUE | singleRange);
}
/**
* Return a contextual shaper which can shape to any of the indicated
* languages. The default initial context for this shaper is EUROPEAN.
* @param ranges the ranges to shape to
* @return a contextual shaper which will target any of these ranges
* @throws IllegalArgumentException if the argument specifies an
* unrecognized range
*/
public static NumericShaper getContextualShaper (int ranges)
{
if ((ranges & ~ALL_RANGES) != 0)
throw new IllegalArgumentException("argument out of range");
return new NumericShaper(EUROPEAN, ranges);
}
/**
* Return a contextual shaper which can shape to any of the indicated
* languages. The default initial context for this shaper is given as
* an argument.
* @param ranges the ranges to shape to
* @param defaultContext the default initial context
* @return a contextual shaper which will target any of these ranges
* @throws IllegalArgumentException if the ranges argument specifies an
* unrecognized range, or if the defaultContext argument does not specify
* a single valid range
*/
public static NumericShaper getContextualShaper (int ranges,
int defaultContext)
{
if (Integer.bitCount(defaultContext) != 1)
throw new IllegalArgumentException("more than one bit set in context");
if ((ranges & ~ALL_RANGES) != 0 || (defaultContext & ~ALL_RANGES) != 0)
throw new IllegalArgumentException("argument out of range");
return new NumericShaper(defaultContext, ranges);
}
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.font;
import gnu.classpath.NotImplementedException;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
@ -58,6 +60,7 @@ public final class ShapeGraphicAttribute extends GraphicAttribute
}
public void draw (Graphics2D graphics, float x, float y)
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -78,11 +81,13 @@ public final class ShapeGraphicAttribute extends GraphicAttribute
}
public float getAdvance ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
public float getAscent ()
throws NotImplementedException
{
throw new Error ("not implemented");
}
@ -93,6 +98,7 @@ public final class ShapeGraphicAttribute extends GraphicAttribute
}
public float getDescent ()
throws NotImplementedException
{
throw new Error ("not implemented");
}

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.awt.font;
import gnu.classpath.NotImplementedException;
import java.text.AttributedCharacterIterator;
/**
@ -70,27 +72,32 @@ public final class TextMeasurer implements Cloneable
public void deleteChar (AttributedCharacterIterator newParagraph,
int deletePos)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public float getAdvanceBetween (int start, int limit)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public TextLayout getLayout (int start, int limit)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public int getLineBreakIndex (int start, float maxAdvance)
throws NotImplementedException
{
throw new Error ("not implemented");
}
public void insertChar (AttributedCharacterIterator newParagraph,
int insertPos)
throws NotImplementedException
{
throw new Error ("not implemented");
}

View file

@ -1,5 +1,5 @@
/* GeneralPath.java -- represents a shape built from subpaths
Copyright (C) 2002, 2003, 2004 Free Software Foundation
Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation
This file is part of GNU Classpath.
@ -79,8 +79,16 @@ import java.awt.Shape;
*/
public final class GeneralPath implements Shape, Cloneable
{
public static final int WIND_EVEN_ODD = PathIterator.WIND_EVEN_ODD;
public static final int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO;
// WORKAROUND for gcj 4.0.x (x < 3)
// fully qualify PathIterator constants.
/** Same constant as {@link PathIterator#WIND_EVEN_ODD}. */
public static final int WIND_EVEN_ODD
= java.awt.geom.PathIterator.WIND_EVEN_ODD;
/** Same constant as {@link PathIterator.WIND_NON_ZERO}. */
public static final int WIND_NON_ZERO
= java.awt.geom.PathIterator.WIND_NON_ZERO;
/** Initial size if not specified. */
private static final int INIT_SIZE = 10;

View file

@ -1,5 +1,5 @@
/* Point2D.java -- generic point in 2-D space
Copyright (C) 1999, 2000, 2002, 2004 Free Software Foundation
Copyright (C) 1999, 2000, 2002, 2004, 2006, Free Software Foundation
This file is part of GNU Classpath.
@ -135,7 +135,7 @@ public abstract class Point2D implements Cloneable
*/
public double distanceSq(double x, double y)
{
return distanceSq(getX(), x, getY(), y);
return distanceSq(getX(), getY(), x, y);
}
/**
@ -147,7 +147,7 @@ public abstract class Point2D implements Cloneable
*/
public double distanceSq(Point2D p)
{
return distanceSq(getX(), p.getX(), getY(), p.getY());
return distanceSq(getX(), getY(), p.getX(), p.getY());
}
/**
@ -159,7 +159,7 @@ public abstract class Point2D implements Cloneable
*/
public double distance(double x, double y)
{
return distance(getX(), x, getY(), y);
return distance(getX(), getY(), x, y);
}
/**
@ -171,7 +171,7 @@ public abstract class Point2D implements Cloneable
*/
public double distance(Point2D p)
{
return distance(getX(), p.getX(), getY(), p.getY());
return distance(getX(), getY(), p.getX(), p.getY());
}
/**

View file

@ -347,7 +347,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
* @param dstPt destination point
* @return the location of the transformed source point.
*/
public Point2D getPoint2D (Point2D srcPt, Point2D dstPt)
public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt)
{
return transform.transform (srcPt, dstPt);
}

View file

@ -1,5 +1,5 @@
/* AreaAveragingScaleFilter.java -- Java class for filtering images
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -45,86 +45,225 @@ package java.awt.image;
* points should give the desired results although Sun does not
* specify what the exact algorithm should be.
* <br>
* FIXME: Currently this filter does nothing and needs to be implemented.
*
* @author C. Brian Jones (cbj@gnu.org)
*/
public class AreaAveragingScaleFilter extends ReplicateScaleFilter
{
/**
* Construct an instance of <code>AreaAveragingScaleFilter</code> which
* should be used in conjunction with a <code>FilteredImageSource</code>
* object.
*
* @param width the width of the destination image
* @param height the height of the destination image
*/
public AreaAveragingScaleFilter(int width, int height) {
super(width, height);
}
/**
* Construct an instance of <code>AreaAveragingScaleFilter</code> which
* should be used in conjunction with a <code>FilteredImageSource</code>
* object.
*
* @param width the width of the destination image
* @param height the height of the destination image
*/
public AreaAveragingScaleFilter(int width, int height) {
super(width, height);
}
/**
* The <code>ImageProducer</code> should call this method with a
* bit mask of hints from any of <code>RANDOMPIXELORDER</code>,
* <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>,
* <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the
* <code>ImageConsumer</code> interface.
* <br>
* FIXME - more than likely Sun's implementation desires
* <code>TOPDOWNLEFTRIGHT</code> order and this method is overloaded here
* in order to assure that mask is part of the hints added to
* the consumer.
*
* @param flags a bit mask of hints
* @see ImageConsumer
*/
public void setHints(int flags)
{
if (consumer != null)
consumer.setHints(flags);
}
/**
* The <code>ImageProducer</code> should call this method with a
* bit mask of hints from any of <code>RANDOMPIXELORDER</code>,
* <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>,
* <code>SINGLEPASS</code>, <code>SINGLEFRAME</code> from the
* <code>ImageConsumer</code> interface.
* <br>
* FIXME - more than likely Sun's implementation desires
* <code>TOPDOWNLEFTRIGHT</code> order and this method is overloaded here
* in order to assure that mask is part of the hints added to
* the consumer.
*
* @param flags a bit mask of hints
* @see ImageConsumer
*/
public void setHints(int flags)
{
if (consumer != null)
consumer.setHints(flags);
}
/**
* This function delivers a rectangle of pixels where any
* pixel(m,n) is stored in the array as a <code>byte</code> at
* index (n * scansize + m + offset).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @param offset the index of the first pixels in the <code>pixels</code> array
* @param scansize the width to use in extracting pixels from the <code>pixels</code> array
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
/**
* This function delivers a rectangle of pixels where any
* pixel(m,n) is stored in the array as a <code>byte</code> at
* index (n * scansize + m + offset).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @param offset the index of the first pixels in the <code>pixels</code> array
* @param scansize the width to use in extracting pixels from the <code>pixels</code> array
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
double rx = ((double) srcWidth) / destWidth;
double ry = ((double) srcHeight) / destHeight;
/**
* This function delivers a rectangle of pixels where any
* pixel(m,n) is stored in the array as an <code>int</code> at
* index (n * scansize + m + offset).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @param offset the index of the first pixels in the <code>pixels</code> array
* @param scansize the width to use in extracting pixels from the <code>pixels</code> array
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
int destScansize = (int) Math.round(scansize / rx);
byte[] destPixels = averagePixels(x, y, w, h,
model, pixels, offset, scansize,
rx, ry, destScansize);
if (consumer != null)
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
}
/**
* This function delivers a rectangle of pixels where any
* pixel(m,n) is stored in the array as an <code>int</code> at
* index (n * scansize + m + offset).
*
* @param x the x coordinate of the rectangle
* @param y the y coordinate of the rectangle
* @param w the width of the rectangle
* @param h the height of the rectangle
* @param model the <code>ColorModel</code> used to translate the pixels
* @param pixels the array of pixel values
* @param offset the index of the first pixels in the <code>pixels</code> array
* @param scansize the width to use in extracting pixels from the <code>pixels</code> array
*/
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
double rx = ((double) srcWidth) / destWidth;
double ry = ((double) srcHeight) / destHeight;
int destScansize = (int) Math.round(scansize / rx);
int[] destPixels = averagePixels(x, y, w, h,
model, pixels, offset, scansize,
rx, ry, destScansize);
if (consumer != null)
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
}
/**
* This is a really terrible implementation,
* since it uses the nearest-neighbor method. This filter is rarely used though.
*
* @param srcx, srcy - Source rectangle upper-left corner
* @param srcw, srch - Source rectangle width and height
* @param model - Pixel color model
* @param srcPixels - Source pixel data.
* @param srcOffset - Starting offset into the source pixel data array.
* @param srcScansize - Source array scanline size.
* @param rx,ry - Scaling factor.
* @param dstScansize - Destination array scanline size.
*/
private byte[] averagePixels(int srcx, int srcy, int srcw, int srch,
ColorModel model, byte[] srcPixels,
int srcOffset, int srcScansize,
double rx, double ry, int destScansize)
{
int destW = (int) Math.ceil(srcw/rx);
int destH = (int) Math.ceil(srch/ry);
byte[] destPixels = new byte[ destW * destH ];
int sx, sy;
int w = (int)Math.ceil(rx);
int h = (int)Math.ceil(ry);
for(int x = 0; x < destW; x++)
for(int y = 0; y < destH; y++)
{
sx = (int) (x * rx);
sy = (int) (y * ry);
int r,g,b,a;
r = g = b = a = 0;
for(int i = 0; i < w; i++)
{
for(int j = 0; j < h; j++)
{
int idx = srcx + sx + i + (srcy + sy + j)*srcScansize;
r += model.getRed(srcPixels[ idx ]);
g += model.getGreen(srcPixels[ idx ]);
b += model.getBlue(srcPixels[ idx ]);
a += model.getAlpha(srcPixels[ idx ]);
}
}
r = r / (w * h);
g = g / (w * h);
b = b / (w * h);
a = a / (w * h);
// Does this really work?
destPixels[x + destScansize*y] = (byte)model.getDataElement
(new int[]{r, g, b, a}, 0);
}
return destPixels;
}
/**
* This is a really terrible implementation,
* since it uses the nearest-neighbor method. This filter is rarely used though.
*
* @param srcx, srcy - Source rectangle upper-left corner
* @param srcw, srch - Source rectangle width and height
* @param model - Pixel color model
* @param srcPixels - Source pixel data.
* @param srcOffset - Starting offset into the source pixel data array.
* @param srcScansize - Source array scanline size.
* @param rx,ry - Scaling factor.
* @param dstScansize - Destination array scanline size.
*/
private int[] averagePixels(int srcx, int srcy, int srcw, int srch,
ColorModel model, int[] srcPixels,
int srcOffset, int srcScansize,
double rx, double ry, int destScansize)
{
int destW = (int) Math.ceil(srcw/rx);
int destH = (int) Math.ceil(srch/ry);
int[] destPixels = new int[ destW * destH ];
int sx, sy;
int w = (int)Math.ceil(rx);
int h = (int)Math.ceil(ry);
for(int x = 0; x < destW; x++)
for(int y = 0; y < destH; y++)
{
sx = (int) (x * rx);
sy = (int) (y * ry);
int r,g,b,a;
r = g = b = a = 0;
for(int i = 0; i < w; i++)
{
for(int j = 0; j < h; j++)
{
int idx = srcx + sx + i + (srcy + sy + j)*srcScansize;
r += model.getRed(srcPixels[ idx ]);
g += model.getGreen(srcPixels[ idx ]);
b += model.getBlue(srcPixels[ idx ]);
a += model.getAlpha(srcPixels[ idx ]);
}
}
r = r / (w * h);
g = g / (w * h);
b = b / (w * h);
a = a / (w * h);
destPixels[x + destScansize*y] = model.getDataElement
(new int[]{r, g, b, a}, 0);
}
return destPixels;
}
}

View file

@ -118,7 +118,7 @@ public class BandCombineOp implements RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
*/
public Rectangle2D getBounds2D(Raster src)
public final Rectangle2D getBounds2D(Raster src)
{
return src.getBounds();
}
@ -144,7 +144,7 @@ public class BandCombineOp implements RasterOp
* @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D,
*java.awt.geom.Point2D)
*/
public Point2D getPoint2D(Point2D src, Point2D dst)
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null) return (Point2D)src.clone();
dst.setLocation(src);
@ -154,13 +154,13 @@ public class BandCombineOp implements RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}
/** Return the matrix for this Op. */
public float[][] getMatrix()
public final float[][] getMatrix()
{
return matrix;
}

View file

@ -452,8 +452,14 @@ public abstract class ColorModel implements Transparency
* This method is typically overriden in subclasses to provide a
* more efficient implementation.
*
* @param array of transferType containing a single pixel. The
* pixel should be encoded in the natural way of the color model.
* @param pixel an array of transferType containing a single pixel. The
* pixel should be encoded in the natural way of the color model. If
* this argument is not an array, as expected, a {@link ClassCastException}
* will be thrown.
* @param components an array that will be filled with the color component
* of the pixel. If this is null, a new array will be allocated
* @param offset index into the components array at which the result
* will be stored
*
* @return arrays of unnormalized component samples of single
* pixel. The scale and multiplication state of the samples are
@ -521,8 +527,8 @@ public abstract class ColorModel implements Transparency
float[] normComponents,
int normOffset)
{
// subclasses has to implement this method.
throw new UnsupportedOperationException();
int[] components = getComponents(pixel, null, 0);
return getNormalizedComponents(components, 0, normComponents, normOffset);
}
/**

File diff suppressed because it is too large Load diff

View file

@ -110,7 +110,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage,
* java.awt.image.BufferedImage)
*/
public BufferedImage filter(BufferedImage src, BufferedImage dst)
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
{
if (src == dst)
throw new IllegalArgumentException();
@ -163,7 +163,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}
@ -181,7 +181,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
*
* @return The convolution kernel.
*/
public Kernel getKernel()
public final Kernel getKernel()
{
return (Kernel) kernel.clone();
}
@ -190,7 +190,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* @see java.awt.image.RasterOp#filter(java.awt.image.Raster,
* java.awt.image.WritableRaster)
*/
public WritableRaster filter(Raster src, WritableRaster dest) {
public final WritableRaster filter(Raster src, WritableRaster dest) {
if (src == dest)
throw new IllegalArgumentException();
if (src.getWidth() < kernel.getWidth() ||
@ -309,7 +309,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
*/
public Rectangle2D getBounds2D(BufferedImage src)
public final Rectangle2D getBounds2D(BufferedImage src)
{
return src.getRaster().getBounds();
}
@ -317,7 +317,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
*/
public Rectangle2D getBounds2D(Raster src)
public final Rectangle2D getBounds2D(Raster src)
{
return src.getBounds();
}
@ -330,7 +330,7 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D,
* java.awt.geom.Point2D)
*/
public Point2D getPoint2D(Point2D src, Point2D dst)
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null) return (Point2D)src.clone();
dst.setLocation(src);

View file

@ -167,7 +167,7 @@ public class DirectColorModel extends PackedColorModel
private int extractAndNormalizeSample(int pixel, int component)
{
int value = extractAndScaleSample(pixel, component);
if (hasAlpha() && isAlphaPremultiplied())
if (hasAlpha() && isAlphaPremultiplied() && getAlpha(pixel) != 0)
value = value*255/getAlpha(pixel);
return value;
}

View file

@ -81,7 +81,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
*/
public BufferedImage filter(BufferedImage src, BufferedImage dst)
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
{
if (src.getColorModel() instanceof IndexColorModel)
throw new IllegalArgumentException("LookupOp.filter: IndexColorModel "
@ -149,7 +149,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getBounds2D(java.awt.image.BufferedImage)
*/
public Rectangle2D getBounds2D(BufferedImage src)
public final Rectangle2D getBounds2D(BufferedImage src)
{
return src.getRaster().getBounds();
}
@ -173,7 +173,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
* @param dst The destination point.
* @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D)
*/
public Point2D getPoint2D(Point2D src, Point2D dst)
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null)
return (Point2D) src.clone();
@ -183,7 +183,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
}
/** Return the LookupTable for this op. */
public LookupTable getTable()
public final LookupTable getTable()
{
return lut;
}
@ -191,7 +191,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}
@ -209,7 +209,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
* component but not the same as src and dest.
* @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster)
*/
public WritableRaster filter(Raster src, WritableRaster dest)
public final WritableRaster filter(Raster src, WritableRaster dest)
{
if (dest == null)
// Allocate a raster if needed
@ -236,7 +236,7 @@ public class LookupOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.RasterOp#getBounds2D(java.awt.image.Raster)
*/
public Rectangle2D getBounds2D(Raster src)
public final Rectangle2D getBounds2D(Raster src)
{
return src.getBounds();
}

View file

@ -46,7 +46,6 @@ import java.util.Hashtable;
* exact method is not defined by Sun but some sort of fast Box filter should
* probably be correct.
* <br>
* Currently this filter does nothing and needs to be implemented.
*
* @author C. Brian Jones (cbj@gnu.org)
*/

View file

@ -93,7 +93,7 @@ public class RescaleOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getRenderingHints()
*/
public RenderingHints getRenderingHints()
public final RenderingHints getRenderingHints()
{
return hints;
}

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation
/* Copyright (C) 2000, 2001, 2002, 2005, 2006, Free Software Foundation
This file is part of GNU Classpath.
@ -57,15 +57,43 @@ public abstract class SampleModel
*/
protected int dataType;
/**
* Creates a new sample model with the specified attributes.
*
* @param dataType the data type (one of {@link DataBuffer#TYPE_BYTE},
* {@link DataBuffer#TYPE_USHORT}, {@link DataBuffer#TYPE_SHORT},
* {@link DataBuffer#TYPE_INT}, {@link DataBuffer#TYPE_FLOAT},
* {@link DataBuffer#TYPE_DOUBLE} or {@link DataBuffer#TYPE_UNDEFINED}).
* @param w the width in pixels (must be greater than zero).
* @param h the height in pixels (must be greater than zero).
* @param numBands the number of bands (must be greater than zero).
*
* @throws IllegalArgumentException if <code>dataType</code> is not one of
* the listed values.
* @throws IllegalArgumentException if <code>w</code> is less than or equal
* to zero.
* @throws IllegalArgumentException if <code>h</code> is less than or equal
* to zero.
* @throws IllegalArgumentException if <code>w * h</code> is greater than
* {@link Integer#MAX_VALUE}.
*/
public SampleModel(int dataType, int w, int h, int numBands)
{
if (dataType != DataBuffer.TYPE_UNDEFINED)
if (dataType < DataBuffer.TYPE_BYTE || dataType > DataBuffer.TYPE_DOUBLE)
throw new IllegalArgumentException("Unrecognised 'dataType' argument.");
if ((w <= 0) || (h <= 0))
throw new IllegalArgumentException((w <= 0 ? " width<=0" : " width is ok")
+(h <= 0 ? " height<=0" : " height is ok"));
// FIXME: How can an int be greater than Integer.MAX_VALUE?
// FIXME: How do we identify an unsupported data type?
+ (h <= 0 ? " height<=0" : " height is ok"));
long area = (long) w * (long) h;
if (area > Integer.MAX_VALUE)
throw new IllegalArgumentException("w * h exceeds Integer.MAX_VALUE.");
if (numBands <= 0)
throw new IllegalArgumentException("Requires numBands > 0.");
this.dataType = dataType;
this.width = w;
this.height = h;
@ -102,8 +130,10 @@ public abstract class SampleModel
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
{
if (iArray == null) iArray = new int[numBands];
for (int b=0; b<numBands; b++) iArray[b] = getSample(x, y, b, data);
if (iArray == null)
iArray = new int[numBands];
for (int b = 0; b < numBands; b++)
iArray[b] = getSample(x, y, b, data);
return iArray;
}
@ -121,94 +151,95 @@ public abstract class SampleModel
* DataBuffer.TYPE_USHORT, then a short[] object is returned.
*/
public abstract Object getDataElements(int x, int y, Object obj,
DataBuffer data);
DataBuffer data);
public Object getDataElements(int x, int y, int w, int h, Object obj,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int numDataElements = getNumDataElements();
int dataSize = numDataElements*size;
int dataSize = numDataElements * size;
if (obj == null)
{
switch (getTransferType())
{
case DataBuffer.TYPE_BYTE:
obj = new byte[dataSize];
break;
case DataBuffer.TYPE_USHORT:
obj = new short[dataSize];
break;
case DataBuffer.TYPE_INT:
obj = new int[dataSize];
break;
default:
// Seems like the only sensible thing to do.
throw new ClassCastException();
}
switch (getTransferType())
{
case DataBuffer.TYPE_BYTE:
obj = new byte[dataSize];
break;
case DataBuffer.TYPE_USHORT:
obj = new short[dataSize];
break;
case DataBuffer.TYPE_INT:
obj = new int[dataSize];
break;
default:
// Seems like the only sensible thing to do.
throw new ClassCastException();
}
}
Object pixelData = null;
int outOffset = 0;
for (int yy = y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx = x; xx<(x+w); xx++)
{
pixelData = getDataElements(xx, yy, pixelData, data);
System.arraycopy(pixelData, 0, obj, outOffset,
numDataElements);
outOffset += numDataElements;
}
for (int xx = x; xx < (x + w); xx++)
{
pixelData = getDataElements(xx, yy, pixelData, data);
System.arraycopy(pixelData, 0, obj, outOffset,
numDataElements);
outOffset += numDataElements;
}
}
return obj;
}
public abstract void setDataElements(int x, int y, Object obj,
DataBuffer data);
DataBuffer data);
public void setDataElements(int x, int y, int w, int h,
Object obj, DataBuffer data)
Object obj, DataBuffer data)
{
int size = w*h;
int size = w * h;
int numDataElements = getNumDataElements();
int dataSize = numDataElements*size;
int dataSize = numDataElements * size;
Object pixelData;
switch (getTransferType())
{
case DataBuffer.TYPE_BYTE:
pixelData = new byte[numDataElements];
break;
pixelData = new byte[numDataElements];
break;
case DataBuffer.TYPE_USHORT:
pixelData = new short[numDataElements];
break;
pixelData = new short[numDataElements];
break;
case DataBuffer.TYPE_INT:
pixelData = new int[numDataElements];
break;
pixelData = new int[numDataElements];
break;
default:
// Seems like the only sensible thing to do.
throw new ClassCastException();
// Seems like the only sensible thing to do.
throw new ClassCastException();
}
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(obj, inOffset, pixelData, 0,
numDataElements);
setDataElements(xx, yy, pixelData, data);
inOffset += numDataElements;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(obj, inOffset, pixelData, 0,
numDataElements);
setDataElements(xx, yy, pixelData, data);
inOffset += numDataElements;
}
}
}
public float[] getPixel(int x, int y, float[] fArray, DataBuffer data)
{
if (fArray == null) fArray = new float[numBands];
if (fArray == null)
fArray = new float[numBands];
for (int b=0; b<numBands; b++)
for (int b = 0; b < numBands; b++)
{
fArray[b] = getSampleFloat(x, y, b, data);
}
@ -216,10 +247,11 @@ public abstract class SampleModel
}
public double[] getPixel(int x, int y, double[] dArray, DataBuffer data) {
if (dArray == null) dArray = new double[numBands];
for (int b=0; b<numBands; b++)
if (dArray == null)
dArray = new double[numBands];
for (int b = 0; b < numBands; b++)
{
dArray[b] = getSampleDouble(x, y, b, data);
dArray[b] = getSampleDouble(x, y, b, data);
}
return dArray;
}
@ -227,20 +259,21 @@ public abstract class SampleModel
/* FIXME: Should it return a banded or pixel interleaved array of
samples? (Assume interleaved.) */
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
int[] pixel = null;
if (iArray == null) iArray = new int[w*h*numBands];
for (int yy=y; yy<(y+h); yy++)
if (iArray == null)
iArray = new int[w * h * numBands];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, iArray, outOffset, numBands);
outOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, iArray, outOffset, numBands);
outOffset += numBands;
}
}
return iArray;
}
@ -248,20 +281,20 @@ public abstract class SampleModel
/* FIXME: Should it return a banded or pixel interleaved array of
samples? (Assume interleaved.) */
public float[] getPixels(int x, int y, int w, int h, float[] fArray,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
float[] pixel = null;
if (fArray == null) fArray = new float[w*h*numBands];
for (int yy=y; yy<(y+h); yy++)
if (fArray == null) fArray = new float[w * h * numBands];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, fArray, outOffset, numBands);
outOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, fArray, outOffset, numBands);
outOffset += numBands;
}
}
return fArray;
}
@ -269,20 +302,21 @@ public abstract class SampleModel
/* FIXME: Should it return a banded or pixel interleaved array of
samples? (Assume interleaved.) */
public double[] getPixels(int x, int y, int w, int h, double[] dArray,
DataBuffer data)
DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
double[] pixel = null;
if (dArray == null) dArray = new double[w*h*numBands];
for (int yy=y; yy<(y+h); yy++)
if (dArray == null)
dArray = new double[w * h * numBands];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, dArray, outOffset, numBands);
outOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
pixel = getPixel(xx, yy, pixel, data);
System.arraycopy(pixel, 0, dArray, outOffset, numBands);
outOffset += numBands;
}
}
return dArray;
}
@ -300,179 +334,185 @@ public abstract class SampleModel
}
public int[] getSamples(int x, int y, int w, int h, int b,
int[] iArray, DataBuffer data)
int[] iArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
if (iArray == null) iArray = new int[size];
for (int yy=y; yy<(y+h); yy++)
if (iArray == null)
iArray = new int[size];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
iArray[outOffset++] = getSample(xx, yy, b, data);
}
for (int xx = x; xx < (x + w); xx++)
{
iArray[outOffset++] = getSample(xx, yy, b, data);
}
}
return iArray;
}
public float[] getSamples(int x, int y, int w, int h, int b,
float[] fArray, DataBuffer data)
float[] fArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
if (fArray == null) fArray = new float[size];
for (int yy=y; yy<(y+h); yy++)
if (fArray == null)
fArray = new float[size];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
fArray[outOffset++] = getSampleFloat(xx, yy, b, data);
}
for (int xx = x; xx < (x + w); xx++)
{
fArray[outOffset++] = getSampleFloat(xx, yy, b, data);
}
}
return fArray;
}
public double[] getSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data)
double[] dArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int outOffset = 0;
if (dArray == null) dArray = new double[size];
for (int yy=y; yy<(y+h); yy++)
if (dArray == null)
dArray = new double[size];
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
dArray[outOffset++] = getSampleDouble(xx, yy, b, data);
}
for (int xx = x; xx < (x + w); xx++)
{
dArray[outOffset++] = getSampleDouble(xx, yy, b, data);
}
}
return dArray;
}
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
{
for (int b=0; b<numBands; b++) setSample(x, y, b, iArray[b], data);
for (int b = 0; b < numBands; b++)
setSample(x, y, b, iArray[b], data);
}
public void setPixel(int x, int y, float[] fArray, DataBuffer data)
{
for (int b=0; b<numBands; b++) setSample(x, y, b, fArray[b], data);
for (int b = 0; b < numBands; b++)
setSample(x, y, b, fArray[b], data);
}
public void setPixel(int x, int y, double[] dArray, DataBuffer data)
{
for (int b=0; b<numBands; b++) setSample(x, y, b, dArray[b], data);
for (int b = 0; b < numBands; b++)
setSample(x, y, b, dArray[b], data);
}
public void setPixels(int x, int y, int w, int h, int[] iArray,
DataBuffer data)
DataBuffer data)
{
int inOffset = 0;
int[] pixel = new int[numBands];
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(iArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(iArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
}
}
public void setPixels(int x, int y, int w, int h, float[] fArray,
DataBuffer data)
DataBuffer data)
{
int inOffset = 0;
float[] pixel = new float[numBands];
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(fArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(fArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
}
}
public void setPixels(int x, int y, int w, int h, double[] dArray,
DataBuffer data)
DataBuffer data)
{
int inOffset = 0;
double[] pixel = new double[numBands];
for (int yy=y; yy<(y+h); yy++)
for (int yy = y; yy < (y + h); yy++)
{
for (int xx=x; xx<(x+w); xx++)
{
System.arraycopy(dArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
for (int xx = x; xx < (x + w); xx++)
{
System.arraycopy(dArray, inOffset, pixel, 0, numBands);
setPixel(xx, yy, pixel, data);
inOffset += numBands;
}
}
}
public abstract void setSample(int x, int y, int b, int s,
DataBuffer data);
DataBuffer data);
public void setSample(int x, int y, int b, float s,
DataBuffer data)
DataBuffer data)
{
setSample(x, y, b, (int) s, data);
}
public void setSample(int x, int y, int b, double s,
DataBuffer data)
DataBuffer data)
{
setSample(x, y, b, (float) s, data);
}
public void setSamples(int x, int y, int w, int h, int b,
int[] iArray, DataBuffer data)
int[] iArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int xx=x; xx<(x+w); xx++)
setSample(xx, yy, b, iArray[inOffset++], data);
for (int yy = y; yy < (y + h); yy++)
for (int xx = x; xx < (x + w); xx++)
setSample(xx, yy, b, iArray[inOffset++], data);
}
public void setSamples(int x, int y, int w, int h, int b,
float[] fArray, DataBuffer data)
float[] fArray, DataBuffer data)
{
int size = w*h;
int size = w * h;
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int xx=x; xx<(x+w); xx++)
setSample(xx, yy, b, fArray[inOffset++], data);
for (int yy = y; yy < (y + h); yy++)
for (int xx = x; xx < (x + w); xx++)
setSample(xx, yy, b, fArray[inOffset++], data);
}
}
public void setSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data) {
int size = w*h;
int inOffset = 0;
for (int yy=y; yy<(y+h); yy++)
for (int xx=x; xx<(x+w); xx++)
setSample(xx, yy, b, dArray[inOffset++], data);
}
public void setSamples(int x, int y, int w, int h, int b,
double[] dArray, DataBuffer data) {
int size = w * h;
int inOffset = 0;
for (int yy = y; yy < (y + h); yy++)
for (int xx = x; xx < (x + w); xx++)
setSample(xx, yy, b, dArray[inOffset++], data);
}
public abstract SampleModel createCompatibleSampleModel(int w, int h);
public abstract SampleModel createCompatibleSampleModel(int w, int h);
/**
* Return a SampleModel with a subset of the bands in this model.
*
* Selects bands.length bands from this sample model. The bands chosen
* are specified in the indices of bands[]. This also permits permuting
* the bands as well as taking a subset. Thus, giving an array with
* 1, 2, 3, ..., numbands, will give an identical sample model.
*
* @param bands Array with band indices to include.
* @return A new sample model
*/
public abstract SampleModel createSubsetSampleModel(int[] bands);
/**
* Return a SampleModel with a subset of the bands in this model.
*
* Selects bands.length bands from this sample model. The bands chosen
* are specified in the indices of bands[]. This also permits permuting
* the bands as well as taking a subset. Thus, giving an array with
* 1, 2, 3, ..., numbands, will give an identical sample model.
*
* @param bands Array with band indices to include.
* @return A new sample model
*/
public abstract SampleModel createSubsetSampleModel(int[] bands);
public abstract DataBuffer createDataBuffer();
public abstract DataBuffer createDataBuffer();
public abstract int[] getSampleSize();
public abstract int[] getSampleSize();
public abstract int getSampleSize(int band);
public abstract int getSampleSize(int band);
}

View file

@ -1,5 +1,5 @@
/* RenderableImageProducer.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,42 +38,129 @@ exception statement from your version. */
package java.awt.image.renderable;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.ImageConsumer;
import java.awt.image.ImageProducer;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
import java.util.ArrayList;
import java.util.Iterator;
public class RenderableImageProducer implements ImageProducer, Runnable
{
private RenderableImage image;
private RenderContext context;
private ArrayList consumers = new ArrayList();
public RenderableImageProducer(RenderableImage image, RenderContext context)
{
throw new Error("not implemented");
this.image = image;
this.context = context;
}
public void setRenderContext(RenderContext context)
{
this.context = context;
}
public void addConsumer(ImageConsumer consumer)
{
synchronized (consumers)
{
if (! consumers.contains(consumer))
consumers.add(consumer);
}
}
public boolean isConsumer(ImageConsumer consumer)
{
return false;
synchronized (consumers)
{
return consumers.contains(consumer);
}
}
public void removeConsumer(ImageConsumer consumer)
{
synchronized (consumers)
{
consumers.remove(consumer);
}
}
public void startProduction(ImageConsumer consumer)
{
addConsumer(consumer);
Thread t = new Thread(this, "RenderableImageProducerWorker");
t.start();
}
public void requestTopDownLeftRightResend(ImageConsumer consumer)
{
// Do nothing. The contract says we can ignore this call, so we do.
}
public void run()
{
// This isn't ideal but it avoids fail-fast problems.
// Alternatively, we could clone 'consumers' here.
synchronized (consumers)
{
RenderedImage newImage;
if (context == null)
newImage = image.createDefaultRendering();
else
newImage = image.createRendering(context);
Raster newData = newImage.getData();
ColorModel colorModel = newImage.getColorModel();
if (colorModel == null)
colorModel = ColorModel.getRGBdefault();
SampleModel sampleModel = newData.getSampleModel();
DataBuffer dataBuffer = newData.getDataBuffer();
int width = newData.getWidth();
int height = newData.getHeight();
// Initialize the consumers.
Iterator it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.setHints(ImageConsumer.COMPLETESCANLINES
| ImageConsumer.SINGLEFRAME
| ImageConsumer.SINGLEPASS
| ImageConsumer.TOPDOWNLEFTRIGHT);
target.setDimensions(width, height);
}
// Work in scan-line order.
int[] newLine = new int[width];
int[] bands = new int[sampleModel.getNumBands()];
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
sampleModel.getPixel(x, y, bands, dataBuffer);
newLine[x] = colorModel.getDataElement(bands, 0);
}
// Tell the consumers about the new scan line.
it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.setPixels(0, y, width, 1, colorModel, newLine, 0, width);
}
}
// Tell the consumers that we're done.
it = consumers.iterator();
while (it.hasNext())
{
ImageConsumer target = (ImageConsumer) it.next();
target.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
}
}
} // class RenderableImageProducer

View file

@ -198,7 +198,7 @@ public interface BeanContext
* @return the created Bean
*
* @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String)
* @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String,java.lang.BeanContext)
* @see java.beans.Beans#instantiate(java.lang.ClassLoader,java.lang.String,java.beans.beancontext.BeanContext)
* @exception IOException if there is an I/O problem during
* instantiation.
* @exception ClassNotFoundException if a serialized Bean's class

View file

@ -52,7 +52,9 @@ import java.util.Iterator;
* @see java.beans.beancontext.BeanContextMembershipListener
*/
public class BeanContextMembershipEvent extends BeanContextEvent {
/**
private static final long serialVersionUID = 3499346510334590959L;
/**
* The children that were added or removed.
*/
protected Collection children;

View file

@ -49,7 +49,9 @@ import java.util.Iterator;
*/
public class BeanContextServiceAvailableEvent extends BeanContextEvent {
/**
private static final long serialVersionUID = -5333985775656400778L;
/**
* The <code>Class</code> representing the service which is now
* available.
*/

View file

@ -47,7 +47,9 @@ package java.beans.beancontext;
*/
public class BeanContextServiceRevokedEvent extends BeanContextEvent {
/**
private static final long serialVersionUID = -1295543154724961754L;
/**
* The <code>Class</code> representing the service which is now
* available.
*/

View file

@ -38,6 +38,8 @@ exception statement from your version. */
package java.beans.beancontext;
import gnu.classpath.NotImplementedException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@ -62,6 +64,11 @@ public class BeanContextServicesSupport
extends BeanContextSupport.BCSChild
{
private static final long serialVersionUID = -3263851306889194873L;
BCSSChild(Object targetChild, Object peer)
{
super(targetChild, peer);
}
}
protected class BCSSProxyServiceProvider
@ -69,9 +76,14 @@ public class BeanContextServicesSupport
BeanContextServiceRevokedListener
{
private static final long serialVersionUID = 7078212910685744490L;
private BCSSProxyServiceProvider()
{
}
public Iterator getCurrentServiceSelectors (BeanContextServices bcs,
Class serviceClass)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
@ -80,6 +92,7 @@ public class BeanContextServicesSupport
Object requestor,
Class serviceClass,
Object serviceSelector)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
@ -87,11 +100,13 @@ public class BeanContextServicesSupport
public void releaseService (BeanContextServices bcs,
Object requestor,
Object service)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public void serviceRevoked (BeanContextServiceRevokedEvent bcsre)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
@ -104,6 +119,10 @@ public class BeanContextServicesSupport
protected BeanContextServiceProvider serviceProvider;
private BCSSServiceProvider()
{
}
protected BeanContextServiceProvider getServiceProvider()
{
return serviceProvider;
@ -148,105 +167,154 @@ public class BeanContextServicesSupport
public void addBeanContextServicesListener
(BeanContextServicesListener listener)
{
if (! bcsListeners.contains(listener))
bcsListeners.add(listener);
synchronized (bcsListeners)
{
if (! bcsListeners.contains(listener))
bcsListeners.add(listener);
}
}
public boolean addService (Class serviceClass, BeanContextServiceProvider bcsp)
public boolean addService (Class serviceClass,
BeanContextServiceProvider bcsp)
{
throw new Error ("Not implemented");
return addService(serviceClass, bcsp, true);
}
protected boolean addService (Class serviceClass,
BeanContextServiceProvider bcsp,
boolean fireEvent)
{
throw new Error ("Not implemented");
synchronized (services)
{
if (services.containsKey(serviceClass))
return false;
services.put(serviceClass, bcsp);
if (bcsp instanceof Serializable)
++serializable;
fireServiceAdded(serviceClass);
return true;
}
}
protected void bcsPreDeserializationHook (ObjectInputStream ois)
throws ClassNotFoundException, IOException
throws ClassNotFoundException, IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
protected void bcsPreSerializationHook (ObjectOutputStream oos)
throws IOException
throws IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
protected void childJustRemovedHook (Object child,
BeanContextSupport.BCSChild bcsc)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected BeanContextSupport.BCSChild createBCSChild (Object targetChild,
Object peer)
Object peer)
{
throw new Error ("Not implemented");
return new BCSSChild(targetChild, peer);
}
protected BeanContextServicesSupport.BCSSServiceProvider
createBCSSServiceProvider (Class sc, BeanContextServiceProvider bcsp)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected final void fireServiceAdded (BeanContextServiceAvailableEvent bcssae)
{
throw new Error ("Not implemented");
synchronized (bcsListeners)
{
int size = bcsListeners.size();
for (int i = 0; i < size; ++i)
{
BeanContextServicesListener bcsl
= (BeanContextServicesListener) bcsListeners.get(i);
bcsl.serviceAvailable(bcssae);
}
}
}
protected final void fireServiceAdded (Class serviceClass)
protected final void fireServiceAdded (Class serviceClass)
{
throw new Error ("Not implemented");
fireServiceAdded(new BeanContextServiceAvailableEvent(this,
serviceClass));
}
protected final void fireServiceRevoked(BeanContextServiceRevokedEvent event)
{
throw new Error ("Not implemented");
synchronized (bcsListeners)
{
int size = bcsListeners.size();
for (int i = 0; i < size; ++i)
{
BeanContextServicesListener bcsl
= (BeanContextServicesListener) bcsListeners.get(i);
bcsl.serviceRevoked(event);
}
}
}
protected final void fireServiceRevoked (Class serviceClass,
boolean revokeNow)
{
throw new Error ("Not implemented");
fireServiceRevoked(new BeanContextServiceRevokedEvent(this, serviceClass,
revokeNow));
}
public BeanContextServices getBeanContextServicesPeer ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected static final BeanContextServicesListener
getChildBeanContextServicesListener (Object child)
getChildBeanContextServicesListener (Object child)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public Iterator getCurrentServiceClasses ()
public Iterator getCurrentServiceClasses ()
{
throw new Error ("Not implemented");
synchronized (services)
{
return services.keySet().iterator();
}
}
public Iterator getCurrentServiceSelectors (Class serviceClass)
public Iterator getCurrentServiceSelectors (Class serviceClass)
{
throw new Error ("Not implemented");
synchronized (services)
{
// FIXME: what if service does not exist? Must write a test.
BeanContextServiceProvider bcsp
= (BeanContextServiceProvider) services.get(serviceClass);
return bcsp.getCurrentServiceSelectors(this, serviceClass);
}
}
public Object getService (BeanContextChild child, Object requestor,
Class serviceClass, Object serviceSelector,
BeanContextServiceRevokedListener bcsrl)
throws TooManyListenersException
throws TooManyListenersException, NotImplementedException
{
throw new Error ("Not implemented");
}
public boolean hasService (Class serviceClass)
{
throw new Error ("Not implemented");
synchronized (services)
{
return services.containsKey(serviceClass);
}
}
public void initialize ()
@ -257,18 +325,21 @@ public class BeanContextServicesSupport
services = new HashMap();
}
protected void initializeBeanContextResources ()
protected void initializeBeanContextResources ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected void releaseBeanContextResources ()
protected void releaseBeanContextResources ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public void releaseService (BeanContextChild child, Object requestor,
Object service)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
@ -276,25 +347,52 @@ public class BeanContextServicesSupport
public void removeBeanContextServicesListener
(BeanContextServicesListener listener)
{
int index = bcsListeners.indexOf(listener);
if (index > -1)
bcsListeners.remove(index);
synchronized (bcsListeners)
{
int index = bcsListeners.indexOf(listener);
if (index > -1)
bcsListeners.remove(index);
}
}
public void revokeService (Class serviceClass, BeanContextServiceProvider bcsp,
boolean revokeCurrentServicesNow)
boolean revokeCurrentServicesNow)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public void serviceAvailable (BeanContextServiceAvailableEvent bcssae)
public void serviceAvailable (BeanContextServiceAvailableEvent bcssae)
{
throw new Error ("Not implemented");
synchronized (services)
{
Class klass = bcssae.getServiceClass();
if (services.containsKey(klass))
return;
Iterator it = bcsChildren();
while (it.hasNext())
{
Object obj = it.next();
if (obj instanceof BeanContextServices)
((BeanContextServices) obj).serviceAvailable(bcssae);
}
}
}
public void serviceRevoked (BeanContextServiceRevokedEvent bcssre)
public void serviceRevoked (BeanContextServiceRevokedEvent bcssre)
{
throw new Error ("Not implemented");
synchronized (services)
{
Class klass = bcssre.getServiceClass();
if (services.containsKey(klass))
return;
Iterator it = bcsChildren();
while (it.hasNext())
{
Object obj = it.next();
if (obj instanceof BeanContextServices)
((BeanContextServices) obj).serviceRevoked(bcssre);
}
}
}
}

View file

@ -38,6 +38,9 @@ exception statement from your version. */
package java.beans.beancontext;
import gnu.classpath.NotImplementedException;
import java.beans.DesignMode;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
@ -64,15 +67,19 @@ public class BeanContextSupport extends BeanContextChildSupport
VetoableChangeListener
{
private static final long serialVersionUID = -4879613978649577204L;
// This won't show up in japi, but we mark it as a stub anyway,
// so that searches for NotImplementedException will find it.
private void readObject (ObjectInputStream s)
throws ClassNotFoundException, IOException
throws ClassNotFoundException, IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
// This won't show up in japi, but we mark it as a stub anyway,
// so that searches for NotImplementedException will find it.
private void writeObject (ObjectOutputStream s)
throws ClassNotFoundException, IOException
throws ClassNotFoundException, IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
@ -80,18 +87,34 @@ public class BeanContextSupport extends BeanContextChildSupport
protected class BCSChild implements Serializable
{
private static final long serialVersionUID = -5815286101609939109L;
private Object targetChild;
private Object peer;
BCSChild(Object targetChild, Object peer)
{
this.targetChild = targetChild;
this.peer = peer;
}
}
protected static final class BCSIterator implements Iterator
{
private Iterator child;
BCSIterator(Iterator child)
{
this.child = child;
}
public boolean hasNext ()
{
throw new Error ("Not implemented");
return child.hasNext();
}
public Object next ()
{
throw new Error ("Not implemented");
return child.next();
}
public void remove ()
@ -148,7 +171,9 @@ public class BeanContextSupport extends BeanContextChildSupport
public BeanContextSupport (BeanContext peer, Locale lcle, boolean dtime,
boolean visible)
{
locale = lcle;
super(peer);
locale = lcle == null ? Locale.getDefault() : lcle;
designTime = dtime;
okToUseGui = visible;
@ -160,150 +185,214 @@ public class BeanContextSupport extends BeanContextChildSupport
if (targetChild == null)
throw new IllegalArgumentException();
if (children.containsKey(targetChild))
return false;
// FIXME: The second argument is surely wrong.
children.put(targetChild, targetChild);
BCSChild child;
synchronized (children)
{
if (children.containsKey(targetChild)
|| ! validatePendingAdd(targetChild))
return false;
child = createBCSChild(targetChild, beanContextChildPeer);
children.put(targetChild, child);
}
synchronized (targetChild)
{
childJustAddedHook(targetChild, child);
}
fireChildrenAdded(new BeanContextMembershipEvent(this,
new Object[] { targetChild }));
return true;
}
public boolean addAll (Collection c)
{
// Intentionally throws an exception.
throw new UnsupportedOperationException();
}
public void addBeanContextMembershipListener
(BeanContextMembershipListener listener)
{
if (! bcmListeners.contains(listener))
bcmListeners.add(listener);
synchronized (bcmListeners)
{
if (! bcmListeners.contains(listener))
bcmListeners.add(listener);
}
}
public boolean avoidingGui ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected Iterator bcsChildren ()
{
throw new Error ("Not implemented");
synchronized (children)
{
return new BCSIterator(children.values().iterator());
}
}
protected void bcsPreDeserializationHook (ObjectInputStream ois)
throws ClassNotFoundException, IOException
throws ClassNotFoundException, IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
protected void bcsPreSerializationHook (ObjectOutputStream oos)
throws IOException
throws IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
protected void childDeserializedHook (Object child, BeanContextSupport.BCSChild bcsc)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected void childJustAddedHook (Object child, BeanContextSupport.BCSChild bcsc)
{
throw new Error ("Not implemented");
// Do nothing in the base class.
}
protected void childJustRemovedHook (Object child, BeanContextSupport.BCSChild bcsc)
{
throw new Error ("Not implemented");
// Do nothing in the base class.
}
protected static final boolean classEquals (Class first, Class second)
{
throw new Error ("Not implemented");
// Lame function!
return (first == second || first.getName().equals(second.getName()));
}
public void clear ()
{
// This is the right thing to do.
// The JDK docs are really bad here.
throw new UnsupportedOperationException();
}
public boolean contains (Object o)
{
throw new Error ("Not implemented");
synchronized (children)
{
return children.containsKey(o);
}
}
public boolean containsAll (Collection c)
{
throw new Error ("Not implemented");
synchronized (children)
{
Iterator it = c.iterator();
while (it.hasNext())
if (! children.containsKey(it.next()))
return false;
}
return true;
}
public boolean containsKey (Object o)
{
throw new Error ("Not implemented");
synchronized (children)
{
return children.containsKey(o);
}
}
protected final Object[] copyChildren ()
{
throw new Error ("Not implemented");
synchronized (children)
{
return children.keySet().toArray();
}
}
protected BeanContextSupport.BCSChild createBCSChild (Object targetChild, Object peer)
{
throw new Error ("Not implemented");
return new BCSChild(targetChild, peer);
}
protected final void deserialize (ObjectInputStream ois, Collection coll)
throws ClassNotFoundException, IOException
throws ClassNotFoundException, IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
public void dontUseGui ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected final void fireChildrenAdded (BeanContextMembershipEvent bcme)
{
throw new Error ("Not implemented");
synchronized (bcmListeners)
{
Iterator it = bcmListeners.iterator();
while (it.hasNext())
{
BeanContextMembershipListener l
= (BeanContextMembershipListener) it.next();
l.childrenAdded(bcme);
}
}
}
protected final void fireChildrenRemoved (BeanContextMembershipEvent bcme)
{
throw new Error ("Not implemented");
synchronized (bcmListeners)
{
Iterator it = bcmListeners.iterator();
while (it.hasNext())
{
BeanContextMembershipListener l
= (BeanContextMembershipListener) it.next();
l.childrenRemoved(bcme);
}
}
}
public BeanContext getBeanContextPeer ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected static final BeanContextChild getChildBeanContextChild (Object child)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected static final BeanContextMembershipListener getChildBeanContextMembershipListener (Object child)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected static final PropertyChangeListener getChildPropertyChangeListener (Object child)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected static final Serializable getChildSerializable (Object child)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected static final VetoableChangeListener getChildVetoableChangeListener (Object child)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
protected static final Visibility getChildVisibility (Object child)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
@ -315,12 +404,20 @@ public class BeanContextSupport extends BeanContextChildSupport
public URL getResource (String name, BeanContextChild bcc)
{
throw new Error ("Not implemented");
if (! contains(bcc))
throw new IllegalArgumentException("argument not a child");
ClassLoader loader = bcc.getClass().getClassLoader();
return (loader == null ? ClassLoader.getSystemResource(name)
: loader.getResource(name));
}
public InputStream getResourceAsStream (String name, BeanContextChild bcc)
{
throw new Error ("Not implemented");
if (! contains(bcc))
throw new IllegalArgumentException("argument not a child");
ClassLoader loader = bcc.getClass().getClassLoader();
return (loader == null ? ClassLoader.getSystemResourceAsStream(name)
: loader.getResourceAsStream(name));
}
protected void initialize ()
@ -330,48 +427,58 @@ public class BeanContextSupport extends BeanContextChildSupport
}
public Object instantiateChild (String beanName)
throws IOException, ClassNotFoundException
throws IOException, ClassNotFoundException, NotImplementedException
{
throw new Error ("Not implemented");
}
public boolean isDesignTime ()
{
throw new Error ("Not implemented");
return designTime;
}
public boolean isEmpty ()
{
throw new Error ("Not implemented");
synchronized (children)
{
return children.isEmpty();
}
}
public boolean isSerializing ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public Iterator iterator ()
{
return children.keySet().iterator();
synchronized (children)
{
return children.keySet().iterator();
}
}
public boolean needsGui ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public void okToUseGui ()
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public void propertyChange (PropertyChangeEvent pce)
throws NotImplementedException
{
throw new Error ("Not implemented");
}
public final void readChildren (ObjectInputStream ois)
throws IOException, ClassNotFoundException
throws IOException, ClassNotFoundException, NotImplementedException
{
throw new Error ("Not implemented");
}
@ -382,6 +489,7 @@ public class BeanContextSupport extends BeanContextChildSupport
}
protected boolean remove (Object targetChild, boolean callChildSetBC)
throws NotImplementedException
{
if (targetChild == null)
throw new IllegalArgumentException();
@ -391,69 +499,93 @@ public class BeanContextSupport extends BeanContextChildSupport
public boolean removeAll (Collection c)
{
// Intentionally throws an exception.
throw new UnsupportedOperationException();
}
public void removeBeanContextMembershipListener (BeanContextMembershipListener bcml)
{
throw new Error ("Not implemented");
synchronized (bcmListeners)
{
bcmListeners.remove(bcml);
}
}
public boolean retainAll (Collection c)
{
// Intentionally throws an exception.
throw new UnsupportedOperationException();
}
protected final void serialize (ObjectOutputStream oos, Collection coll)
throws IOException
throws IOException, NotImplementedException
{
throw new Error ("Not implemented");
}
public void setDesignTime (boolean dtime)
{
throw new Error ("Not implemented");
boolean save = designTime;
designTime = dtime;
firePropertyChange(DesignMode.PROPERTYNAME, Boolean.valueOf(save),
Boolean.valueOf(dtime));
}
public void setLocale (Locale newLocale)
throws PropertyVetoException
{
throw new Error ("Not implemented");
if (newLocale == null || locale == newLocale)
return;
fireVetoableChange("locale", locale, newLocale);
Locale oldLocale = locale;
locale = newLocale;
firePropertyChange("locale", oldLocale, newLocale);
}
public int size ()
{
throw new Error ("Not implemented");
synchronized (children)
{
return children.size();
}
}
public Object[] toArray ()
{
return children.keySet().toArray();
synchronized (children)
{
return children.keySet().toArray();
}
}
public Object[] toArray(Object[] array)
throws NotImplementedException
{
return children.keySet().toArray(array);
// This implementation is incorrect, I think.
synchronized (children)
{
return children.keySet().toArray(array);
}
}
protected boolean validatePendingAdd (Object targetChild)
{
throw new Error ("Not implemented");
return true;
}
protected boolean validatePendingRemove (Object targetChild)
{
throw new Error ("Not implemented");
return true;
}
public void vetoableChange (PropertyChangeEvent pce)
throws PropertyVetoException
throws PropertyVetoException, NotImplementedException
{
throw new Error ("Not implemented");
}
public final void writeChildren (ObjectOutputStream oos)
throws IOException
throws IOException, NotImplementedException
{
throw new Error ("Not implemented");
}

View file

@ -242,6 +242,84 @@ public class CharArrayWriter extends Writer
}
}
/**
* Appends the Unicode character, <code>c</code>, to the output stream
* underlying this writer. This is equivalent to <code>write(c)</code>.
*
* @param c the character to append.
* @return a reference to this object.
* @since 1.5
*/
public CharArrayWriter append(char c)
{
write(c);
return this;
}
/**
* Appends the specified sequence of Unicode characters to the
* output stream underlying this writer. This is equivalent to
* appending the results of calling <code>toString()</code> on the
* character sequence. As a result, the entire sequence may not be
* appended, as it depends on the implementation of
* <code>toString()</code> provided by the
* <code>CharSequence</code>. For example, if the character
* sequence is wrapped around an input buffer, the results will
* depend on the current position and length of that buffer.
*
* @param cs the character sequence to append. If cs is null,
* then the string "null" (the string representation of null)
* is appended.
* @return a reference to this object.
* @since 1.5
*/
public CharArrayWriter append(CharSequence cs)
{
try
{
write(cs == null ? "null" : cs.toString());
}
catch (IOException _)
{
// Can't happen.
}
return this;
}
/**
* Appends the specified subsequence of Unicode characters to the
* output stream underlying this writer, starting and ending at the
* specified positions within the sequence. The behaviour of this
* method matches the behaviour of writing the result of
* <code>append(cs.subSequence(start,end))</code> when the sequence
* is not null.
*
* @param cs the character sequence to append. If cs is null,
* then the string "null" (the string representation of null)
* is appended.
* @param start the index of the first Unicode character to use from
* the sequence.
* @param end the index of the last Unicode character to use from the
* sequence.
* @return a reference to this object.
* @throws IndexOutOfBoundsException if either of the indices are negative,
* the start index occurs after the end index, or the end index is
* beyond the end of the sequence.
* @since 1.5
*/
public CharArrayWriter append(CharSequence cs, int start, int end)
{
try
{
write(cs == null ? "null" : cs.subSequence(start, end).toString());
}
catch (IOException _)
{
// Can't happen.
}
return this;
}
/**
* This private method makes the buffer bigger when we run out of room
* by allocating a larger buffer and copying the valid chars from the

View file

@ -62,6 +62,11 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
*/
protected int written;
/**
* Utf8 byte buffer, used by writeUTF()
*/
private byte[] buf;
/**
* This method initializes an instance of <code>DataOutputStream</code> to
* write its data to the specified underlying <code>OutputStream</code>
@ -372,6 +377,37 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
writeChar (value.charAt(i));
}
/**
* Calculate the length, in bytes, of a <code>String</code> in Utf8 format.
*
* @param value The <code>String</code> to measure
* @param start String index at which to begin count
* @param sum Starting Utf8 byte count
*
* @throws UTFDataFormatException if result would exceed 65535
*/
private int getUTFlength(String value, int start, int sum)
throws IOException
{
int len = value.length();
for (int i = start; i < len && sum <= 65535; ++i)
{
char c = value.charAt(i);
if (c >= '\u0001' && c <= '\u007f')
sum += 1;
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
sum += 2;
else
sum += 3;
}
if (sum > 65535)
throw new UTFDataFormatException ();
return sum;
}
/**
* This method writes a Java <code>String</code> to the stream in a modified
* UTF-8 format. First, two bytes are written to the stream indicating the
@ -407,48 +443,47 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput
public final synchronized void writeUTF(String value) throws IOException
{
int len = value.length();
int sum = 0;
for (int i = 0; i < len && sum <= 65535; ++i)
{
char c = value.charAt(i);
if (c >= '\u0001' && c <= '\u007f')
sum += 1;
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
sum += 2;
else
sum += 3;
}
if (sum > 65535)
throw new UTFDataFormatException ();
int i = 0;
int pos = 0;
byte[] buf = new byte[sum];
boolean lengthWritten = false;
for (int i = 0; i < len; ++i)
{
char c = value.charAt(i);
if (c >= '\u0001' && c <= '\u007f')
buf[pos++] = (byte) c;
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
{
buf[pos++] = (byte) (0xc0 | (0x1f & (c >> 6)));
buf[pos++] = (byte) (0x80 | (0x3f & c));
}
else
{
// JSL says the first byte should be or'd with 0xc0, but
// that is a typo. Unicode says 0xe0, and that is what is
// consistent with DataInputStream.
buf[pos++] = (byte) (0xe0 | (0x0f & (c >> 12)));
buf[pos++] = (byte) (0x80 | (0x3f & (c >> 6)));
buf[pos++] = (byte) (0x80 | (0x3f & c));
}
}
if (buf == null)
buf = new byte[512];
writeShort (sum);
write(buf, 0, sum);
do
{
while (i < len && pos < buf.length - 3)
{
char c = value.charAt(i++);
if (c >= '\u0001' && c <= '\u007f')
buf[pos++] = (byte) c;
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
{
buf[pos++] = (byte) (0xc0 | (0x1f & (c >> 6)));
buf[pos++] = (byte) (0x80 | (0x3f & c));
}
else
{
// JSL says the first byte should be or'd with 0xc0, but
// that is a typo. Unicode says 0xe0, and that is what is
// consistent with DataInputStream.
buf[pos++] = (byte) (0xe0 | (0x0f & (c >> 12)));
buf[pos++] = (byte) (0x80 | (0x3f & (c >> 6)));
buf[pos++] = (byte) (0x80 | (0x3f & c));
}
}
if (! lengthWritten)
{
if (i == len)
writeShort(pos);
else
writeShort(getUTFlength(value, i, pos));
lengthWritten = true;
}
write(buf, 0, pos);
pos = 0;
}
while (i < len);
}
} // class DataOutputStream

View file

@ -1,5 +1,6 @@
/* FilePermission.java --
Copyright (C) 1998, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1998, 2000, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -44,9 +45,6 @@ public final class FilePermission extends Permission implements Serializable
{
private static final long serialVersionUID = 7930732926638008763L;
private static final String CURRENT_DIRECTORY =
System.getProperty("user.dir");
private static final String ALL_FILES = "<<ALL FILES>>";
private boolean readPerm = false;
@ -213,10 +211,18 @@ public final class FilePermission extends Permission implements Serializable
FilePermission fp = (FilePermission) p;
String f2 = fp.getName();
if (f1.charAt(0) != File.separatorChar)
f1 = CURRENT_DIRECTORY + f1;
if (f2.charAt(0) != File.separatorChar)
f2 = CURRENT_DIRECTORY + f2;
if (f2.equals(ALL_FILES))
return false;
try
{
f1 = new File(f1).getCanonicalPath();
f2 = new File(f2).getCanonicalPath();
}
catch (IOException ioe)
{
return false;
}
String sub1;

View file

@ -1,5 +1,5 @@
/* InputStream.java -- Base class for input
Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -48,7 +48,7 @@ package java.io;
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Warren Levy (warrenl@cygnus.com)
*/
public abstract class InputStream
public abstract class InputStream implements Closeable
{
/**
* Default, no-arg, public constructor

View file

@ -549,53 +549,37 @@ public class ObjectOutputStream extends OutputStream
* different protocols, specified by <code>PROTOCOL_VERSION_1</code>
* and <code>PROTOCOL_VERSION_2</code>. This implementation writes
* data using <code>PROTOCOL_VERSION_2</code> by default, as is done
* by the JDK 1.2.
*
* A non-portable method, <code>setDefaultProtocolVersion (int
* version)</code> is provided to change the default protocol
* version.
*
* since the JDK 1.2.
* <p>
* 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
* protocol
*
* @see #setDefaultProtocolVersion(int)
* see the Java Object Serialization Specification.
* </p>
*
* @param version the version to use.
*
* @throws IllegalArgumentException if <code>version</code> is not a valid
* protocol.
* @throws IllegalStateException if called after the first the first object
* was serialized.
* @throws IOException if an I/O error occurs.
*
* @see ObjectStreamConstants#PROTOCOL_VERSION_1
* @see ObjectStreamConstants#PROTOCOL_VERSION_2
*
* @since 1.2
*/
public void useProtocolVersion(int version) throws IOException
{
if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2)
throw new IOException("Invalid protocol version requested.");
throw new IllegalArgumentException("Invalid protocol version requested.");
if (nextOID != baseWireHandle)
throw new IllegalStateException("Protocol version cannot be changed "
+ "after serialization started.");
protocolVersion = version;
}
/**
* <em>GNU $classpath specific</em>
*
* Changes the default stream protocol used by all
* <code>ObjectOutputStream</code>s. There are currently two
* different protocols, specified by <code>PROTOCOL_VERSION_1</code>
* and <code>PROTOCOL_VERSION_2</code>. The default default is
* <code>PROTOCOL_VERSION_1</code>.
*
* @exception IOException if <code>version</code> is not a valid
* protocol
*
* @see #useProtocolVersion(int)
*/
public static void setDefaultProtocolVersion(int version)
throws IOException
{
if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2)
throw new IOException("Invalid protocol version requested.");
defaultProtocolVersion = version;
}
/**
* An empty hook that allows subclasses to write extra information
* about classes to the stream. This method is called the first

View file

@ -1,6 +1,6 @@
/* ObjectStreamConstants.java -- Interface containing constant values
used in reading and writing serialized objects
Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -45,11 +45,29 @@ package java.io;
* <code>ObjectInputStream</code>, and <code>ObjectStreamClass</code>.
* The values for these constants are specified by the Java library
* specification.
*
* @since 1.1
*/
public interface ObjectStreamConstants
{
// FIXME: Javadoc comment these values.
/**
* The serialization stream protocol version 1. This version was
* the default serialization protocol before JDK 1.2.
*
* @see ObjectOutputStream#useProtocolVersion(int)
* @since 1.2
*/
int PROTOCOL_VERSION_1 = 1;
/**
* The serialization stream protocol version 2. This version is
* used as the default serialization protocol since JDK 1.2.
*
* @see ObjectOutputStream#useProtocolVersion(int)
* @since 1.2
*/
int PROTOCOL_VERSION_2 = 2;
short STREAM_MAGIC = (short)0xaced;

View file

@ -1,100 +0,0 @@
# This property file contains dependencies of classes, methods, and
# field on other methods or classes.
#
# Syntax:
#
# <used>: <needed 1> [... <needed N>]
#
# means that when <used> is included, <needed 1> (... <needed N>) must
# be included as well.
#
# <needed X> and <used> are of the form
#
# <class.methodOrField(signature)>
#
# or just
#
# <class>
#
# Within dependencies, variables can be used. A variable is defined as
# follows:
#
# {variable}: value1 value2 ... value<n>
#
# variables can be used on the right side of dependencies as follows:
#
# <used>: com.bla.blu.{variable}.Class.m()V
#
# The use of the variable will expand to <n> dependencies of the form
#
# <used>: com.bla.blu.value1.Class.m()V
# <used>: com.bla.blu.value2.Class.m()V
# ...
# <used>: com.bla.blu.value<n>.Class.m()V
#
# Variables can be redefined when building a system to select the
# required support for features like encodings, protocols, etc.
#
# Hints:
#
# - For methods and fields, the signature is mandatory. For
# specification, please see the Java Virtual Machine Specification by
# SUN. Unlike in the spec, field signatures (types) are in brackets.
#
# - Package names must be separated by '/' (and not '.'). E.g.,
# java/lang/Class (this is necessary, because the '.' is used to
# separate method or field names from classes)
#
# - In case <needed> refers to a class, only the class itself will be
# included in the resulting binary, NOT necessarily all its methods
# and fields. If you want to refer to all methods and fields, you can
# write class.* as an abbreviation.
#
# - Abbreviations for packages are also possible: my/package/* means all
# methods and fields of all classes in my/package.
#
# - A line with a trailing '\' continues in the next line.
java/io/File: \
java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
java/lang/InternalError.<init>(Ljava/lang/String;)V \
java/io/IOException.<init>(Ljava/lang/String;)V \
java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V
java/io/FileDescriptor: \
java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
java/lang/InternalError.<init>(Ljava/lang/String;)V \
java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V \
java/io/IOException.<init>(Ljava/lang/String;)V
java/io/FileInputStream: \
java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
java/lang/InternalError.<init>(Ljava/lang/String;)V \
java/io/IOException.<init>(Ljava/lang/String;)V \
java/io/FileNotFoundException.<init>(Ljava/lang/String;)V
java/io/FileOutputStream: \
java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
java/lang/InternalError.<init>(Ljava/lang/String;)V \
java/io/FileNotFoundException.<init>(Ljava/lang/String;)V \
java/io/IOException.<init>(Ljava/lang/String;)V
java/io/ObjectInputStream: \
java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
java/lang/InternalError.<init>(Ljava/lang/String;)V \
java/lang/SecurityManager.currentClassLoader()Ljava/lang/ClassLoader; \
java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V
java/io/ObjectOutputStream: \
java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
java/lang/InternalError.<init>(Ljava/lang/String;)V \
java/lang/SecurityManager.currentClassLoader()Ljava/lang/ClassLoader; \
java/lang/IllegalArgumentException.<init>(Ljava/lang/String;)V
java/io/RandomAccessFile: \
java/lang/ClassNotFoundException.<init>(Ljava/lang/String;)V \
java/lang/InternalError.<init>(Ljava/lang/String;)V \
java/io/FileNotFoundException.<init>(Ljava/lang/String;)V \
java/io/IOException.<init>(Ljava/lang/String;)V
# end of file

View file

@ -1,5 +1,5 @@
/* Boolean.java -- object wrapper for boolean
Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation, Inc.
Copyright (C) 1998, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -47,9 +47,9 @@ import java.io.Serializable;
* @author Paul Fisher
* @author Eric Blake (ebb9@email.byu.edu)
* @since 1.0
* @status updated to 1.4
* @status updated to 1.5
*/
public final class Boolean implements Serializable
public final class Boolean implements Serializable, Comparable
{
/**
* Compatible with JDK 1.0.2+.
@ -222,6 +222,28 @@ public final class Boolean implements Serializable
return "true".equalsIgnoreCase(System.getProperty(name));
}
/**
* Compares this Boolean to another.
*
* @param other 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 the other false, and a negative
* number otherwise.
* @since 1.5
*/
public int compareTo(Boolean other)
{
return value == other.value ? 0 : (value ? 1 : -1);
}
/**
* Bridge method
*/
public int compareTo(Object other)
{
return compareTo((Boolean)other);
}
/**
* If the String argument is "true", ignoring case, return true.
* Otherwise, return false.
@ -233,24 +255,5 @@ public final class Boolean implements Serializable
{
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;
}
}

View file

@ -47,7 +47,7 @@ import java.util.Locale;
/**
* Wrapper class for the primitive char data type. In addition, this class
* allows one to retrieve property information and perform transformations
* on the 57,707 defined characters in the Unicode Standard, Version 3.0.0.
* on the defined characters in the Unicode Standard, Version 4.0.0.
* java.lang.Character is designed to be very dynamic, and as such, it
* retrieves information on the Unicode character set from a separate
* database, gnu.java.lang.CharData, which can be easily upgraded.
@ -55,7 +55,7 @@ import java.util.Locale;
* <p>For predicates, boundaries are used to describe
* the set of characters for which the method will return true.
* This syntax uses fairly normal regular expression notation.
* See 5.13 of the Unicode Standard, Version 3.0, for the
* See 5.13 of the Unicode Standard, Version 4.0, for the
* boundary specification.
*
* <p>See <a href="http://www.unicode.org">http://www.unicode.org</a>

View file

@ -1,5 +1,5 @@
/* Class.java -- Representation of a Java class.
Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005
Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
Free Software Foundation
This file is part of GNU Classpath.
@ -39,17 +39,25 @@ exception statement from your version. */
package java.lang;
import gnu.classpath.VMStackWalker;
import gnu.java.lang.reflect.ClassSignatureParser;
import java.io.InputStream;
import java.io.ObjectStreamClass;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Array;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.GenericSignatureFormatError;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.MalformedParameterizedTypeException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.net.URL;
import java.security.AccessController;
import java.security.AllPermission;
@ -87,17 +95,37 @@ import java.util.HashSet;
*
* @author John Keiser
* @author Eric Blake (ebb9@email.byu.edu)
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @author Tom Tromey (tromey@cygnus.com)
* @since 1.0
* @see ClassLoader
*/
public final class Class implements Serializable
public final class Class
implements Serializable, Type, AnnotatedElement, GenericDeclaration
{
/**
* Compatible with JDK 1.0+.
*/
private static final long serialVersionUID = 3206093459760846163L;
/**
* Flag indicating a synthetic member.
* Note that this duplicates a constant in Modifier.
*/
private static final int SYNTHETIC = 0x1000;
/**
* Flag indiciating an annotation class.
*/
private static final int ANNOTATION = 0x2000;
/**
* Flag indicating an enum constant or an enum class.
* Note that this duplicates a constant in Modifier.
*/
private static final int ENUM = 0x4000;
/** The class signers. */
private Object[] signers = null;
/** The class protection domain. */
@ -259,7 +287,7 @@ public final class Class implements Serializable
ClassLoader loader = VMClass.getClassLoader(this);
// Check if we may get the classloader
SecurityManager sm = SecurityManager.current;
if (sm != null)
if (loader != null && sm != null)
{
// Get the calling classloader
ClassLoader cl = VMStackWalker.getCallingClassLoader();
@ -631,17 +659,16 @@ public final class Class implements Serializable
public boolean equals(Object o)
{
if(o instanceof MethodKey)
if (o instanceof MethodKey)
{
MethodKey m = (MethodKey)o;
if(m.name.equals(name) && m.params.length == params.length && m.returnType == returnType)
MethodKey m = (MethodKey) o;
if (m.name.equals(name) && m.params.length == params.length
&& m.returnType == returnType)
{
for(int i = 0; i < params.length; i++)
for (int i = 0; i < params.length; i++)
{
if(m.params[i] != params[i])
{
return false;
}
if (m.params[i] != params[i])
return false;
}
return true;
}
@ -1252,8 +1279,60 @@ public final class Class implements Serializable
}
/**
* Like <code>getField(String)</code> but without the security checks and returns null
* instead of throwing NoSuchFieldException.
* <p>
* Casts this class to represent a subclass of the specified class.
* This method is useful for `narrowing' the type of a class so that
* the class object, and instances of that class, can match the contract
* of a more restrictive method. For example, if this class has the
* static type of <code>Class&lt;Object&gt;</code>, and a dynamic type of
* <code>Class&lt;Rectangle&gt;</code>, then, assuming <code>Shape</code> is
* a superclass of <code>Rectangle</code>, this method can be used on
* this class with the parameter, <code>Class&lt;Shape&gt;</code>, to retain
* the same instance but with the type
* <code>Class&lt;? extends Shape&gt;</code>.
* </p>
* <p>
* If this class can be converted to an instance which is parameterised
* over a subtype of the supplied type, <code>U</code>, then this method
* returns an appropriately cast reference to this object. Otherwise,
* a <code>ClassCastException</code> is thrown.
* </p>
*
* @param klass the class object, the parameterized type (<code>U</code>) of
* which should be a superclass of the parameterized type of
* this instance.
* @return a reference to this object, appropriately cast.
* @throws ClassCastException if this class can not be converted to one
* which represents a subclass of the specified
* type, <code>U</code>.
* @since 1.5
*/
/* FIXME[GENERICS]: Should be <U> Class<? extends U> asSubClass(Class<U> klass */
public Class asSubclass(Class klass)
{
if (! klass.isAssignableFrom(this))
throw new ClassCastException();
return this; /* FIXME[GENERICS]: Should cast to Class<? extends U> */
}
/**
* Returns the specified object, cast to this <code>Class</code>' type.
*
* @param obj the object to cast
* @throws ClassCastException if obj is not an instance of this class
* @since 1.5
*/
/* FIXME[GENERICS]: Should be T cast(Object obj) */
public Object cast(Object obj)
{
if (obj != null && ! isInstance(obj))
throw new ClassCastException();
return obj; /* FIXME[GENERICS]: Should be cast to T */
}
/**
* Like <code>getField(String)</code> but without the security checks and
* returns null instead of throwing NoSuchFieldException.
*/
private Field internalGetField(String name)
{
@ -1306,4 +1385,411 @@ public final class Class implements Serializable
sm.checkPackageAccess(pkg.getName());
}
}
/**
* Returns the enumeration constants of this class, or
* null if this class is not an <code>Enum</code>.
*
* @return an array of <code>Enum</code> constants
* associated with this class, or null if this
* class is not an <code>enum</code>.
* @since 1.5
*/
/* FIXME[GENERICS]: T[] getEnumConstants() */
public Object[] getEnumConstants()
{
if (isEnum())
{
try
{
return (Object[])
getMethod("values", new Class[0]).invoke(null, new Object[0]);
}
catch (NoSuchMethodException exception)
{
throw new Error("Enum lacks values() method");
}
catch (IllegalAccessException exception)
{
throw new Error("Unable to access Enum class");
}
catch (InvocationTargetException exception)
{
throw new
RuntimeException("The values method threw an exception",
exception);
}
}
else
{
return null;
}
}
/**
* Returns true if this class is an <code>Enum</code>.
*
* @return true if this is an enumeration class.
* @since 1.5
*/
public boolean isEnum()
{
int mod = VMClass.getModifiers (this, true);
return (mod & ENUM) != 0;
}
/**
* Returns true if this class is a synthetic class, generated by
* the compiler.
*
* @return true if this is a synthetic class.
* @since 1.5
*/
public boolean isSynthetic()
{
int mod = VMClass.getModifiers (this, true);
return (mod & SYNTHETIC) != 0;
}
/**
* Returns true if this class is an <code>Annotation</code>.
*
* @return true if this is an annotation class.
* @since 1.5
*/
public boolean isAnnotation()
{
int mod = VMClass.getModifiers (this, true);
return (mod & ANNOTATION) != 0;
}
/**
* Returns the simple name for this class, as used in the source
* code. For normal classes, this is the content returned by
* <code>getName()</code> which follows the last ".". Anonymous
* classes have no name, and so the result of calling this method is
* "". The simple name of an array consists of the simple name of
* its component type, followed by "[]". Thus, an array with the
* component type of an anonymous class has a simple name of simply
* "[]".
*
* @return the simple name for this class.
* @since 1.5
*/
public String getSimpleName()
{
return VMClass.getSimpleName(this);
}
/**
* Returns this class' annotation for the specified annotation type,
* or <code>null</code> if no such annotation exists.
*
* @param annotationClass the type of annotation to look for.
* @return this class' annotation for the specified type, or
* <code>null</code> if no such annotation exists.
* @since 1.5
*/
/* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
public Annotation getAnnotation(Class annotationClass)
{
Annotation foundAnnotation = null;
Annotation[] annotations = getAnnotations();
for (int i = 0; i < annotations.length; i++)
if (annotations[i].annotationType() == annotationClass)
foundAnnotation = annotations[i];
return foundAnnotation;
}
/**
* Returns all annotations associated with this class. If there are
* no annotations associated with this class, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* class, and hence no effect on the return value of this method for
* future callers.
*
* @return this class' annotations.
* @since 1.5
*/
public Annotation[] getAnnotations()
{
HashSet set = new HashSet();
set.addAll(Arrays.asList(getDeclaredAnnotations()));
Class[] interfaces = getInterfaces();
for (int i = 0; i < interfaces.length; i++)
set.addAll(Arrays.asList(interfaces[i].getAnnotations()));
Class superClass = getSuperclass();
if (superClass != null)
set.addAll(Arrays.asList(superClass.getAnnotations()));
return (Annotation[]) set.toArray(new Annotation[set.size()]);
}
/**
* <p>
* Returns the canonical name of this class, as defined by section
* 6.7 of the Java language specification. Each package, top-level class,
* top-level interface and primitive type has a canonical name. A member
* class has a canonical name, if its parent class has one. Likewise,
* an array type has a canonical name, if its component type does.
* Local or anonymous classes do not have canonical names.
* </p>
* <p>
* The canonical name for top-level classes, top-level interfaces and
* primitive types is always the same as the fully-qualified name.
* For array types, the canonical name is the canonical name of its
* component type with `[]' appended.
* </p>
* <p>
* The canonical name of a member class always refers to the place where
* the class was defined, and is composed of the canonical name of the
* defining class and the simple name of the member class, joined by `.'.
* For example, if a <code>Person</code> class has an inner class,
* <code>M</code>, then both its fully-qualified name and canonical name
* is <code>Person.M</code>. A subclass, <code>Staff</code>, of
* <code>Person</code> refers to the same inner class by the fully-qualified
* name of <code>Staff.M</code>, but its canonical name is still
* <code>Person.M</code>.
* </p>
* <p>
* Where no canonical name is present, <code>null</code> is returned.
* </p>
*
* @return the canonical name of the class, or <code>null</code> if the
* class doesn't have a canonical name.
* @since 1.5
*/
public String getCanonicalName()
{
return VMClass.getCanonicalName(this);
}
/**
* Returns all annotations directly defined by this class. If there are
* no annotations associated with this class, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* class, and hence no effect on the return value of this method for
* future callers.
*
* @return the annotations directly defined by this class.
* @since 1.5
*/
public Annotation[] getDeclaredAnnotations()
{
return VMClass.getDeclaredAnnotations(this);
}
/**
* Returns the class which immediately encloses this class. If this class
* is a top-level class, this method returns <code>null</code>.
*
* @return the immediate enclosing class, or <code>null</code> if this is
* a top-level class.
* @since 1.5
*/
/* FIXME[GENERICS]: Should return Class<?> */
public Class getEnclosingClass()
{
return VMClass.getEnclosingClass(this);
}
/**
* Returns the constructor which immediately encloses this class. If
* this class is a top-level class, or a local or anonymous class
* immediately enclosed by a type definition, instance initializer
* or static initializer, then <code>null</code> is returned.
*
* @return the immediate enclosing constructor if this class is
* declared within a constructor. Otherwise, <code>null</code>
* is returned.
* @since 1.5
*/
/* FIXME[GENERICS]: Should return Constructor<?> */
public Constructor getEnclosingConstructor()
{
return VMClass.getEnclosingConstructor(this);
}
/**
* Returns the method which immediately encloses this class. If
* this class is a top-level class, or a local or anonymous class
* immediately enclosed by a type definition, instance initializer
* or static initializer, then <code>null</code> is returned.
*
* @return the immediate enclosing method if this class is
* declared within a method. Otherwise, <code>null</code>
* is returned.
* @since 1.5
*/
public Method getEnclosingMethod()
{
return VMClass.getEnclosingMethod(this);
}
/**
* <p>
* Returns an array of <code>Type</code> objects which represent the
* interfaces directly implemented by this class or extended by this
* interface.
* </p>
* <p>
* If one of the superinterfaces is a parameterized type, then the
* object returned for this interface reflects the actual type
* parameters used in the source code. Type parameters are created
* using the semantics specified by the <code>ParameterizedType</code>
* interface, and only if an instance has not already been created.
* </p>
* <p>
* The order of the interfaces in the array matches the order in which
* the interfaces are declared. For classes which represent an array,
* an array of two interfaces, <code>Cloneable</code> and
* <code>Serializable</code>, is always returned, with the objects in
* that order. A class representing a primitive type or void always
* returns an array of zero size.
* </p>
*
* @return an array of interfaces implemented or extended by this class.
* @throws GenericSignatureFormatError if the generic signature of one
* of the interfaces does not comply with that specified by the Java
* Virtual Machine specification, 3rd edition.
* @throws TypeNotPresentException if any of the superinterfaces refers
* to a non-existant type.
* @throws MalformedParameterizedTypeException if any of the interfaces
* refer to a parameterized type that can not be instantiated for
* some reason.
* @since 1.5
* @see java.lang.reflect.ParameterizedType
*/
public Type[] getGenericInterfaces()
{
if (isPrimitive())
return new Type[0];
String sig = VMClass.getClassSignature(this);
if (sig == null)
return getInterfaces();
ClassSignatureParser p = new ClassSignatureParser(this, sig);
return p.getInterfaceTypes();
}
/**
* <p>
* Returns a <code>Type</code> object representing the direct superclass,
* whether class, interface, primitive type or void, of this class.
* If this class is an array class, then a class instance representing
* the <code>Object</code> class is returned. If this class is primitive,
* an interface, or a representation of either the <code>Object</code>
* class or void, then <code>null</code> is returned.
* </p>
* <p>
* If the superclass is a parameterized type, then the
* object returned for this interface reflects the actual type
* parameters used in the source code. Type parameters are created
* using the semantics specified by the <code>ParameterizedType</code>
* interface, and only if an instance has not already been created.
* </p>
*
* @return the superclass of this class.
* @throws GenericSignatureFormatError if the generic signature of the
* class does not comply with that specified by the Java
* Virtual Machine specification, 3rd edition.
* @throws TypeNotPresentException if the superclass refers
* to a non-existant type.
* @throws MalformedParameterizedTypeException if the superclass
* refers to a parameterized type that can not be instantiated for
* some reason.
* @since 1.5
* @see java.lang.reflect.ParameterizedType
*/
public Type getGenericSuperclass()
{
if (isArray())
return Object.class;
if (isPrimitive() || isInterface() || this == Object.class)
return null;
String sig = VMClass.getClassSignature(this);
if (sig == null)
return getSuperclass();
ClassSignatureParser p = new ClassSignatureParser(this, sig);
return p.getSuperclassType();
}
/**
* Returns an array of <code>TypeVariable</code> objects that represents
* the type variables declared by this class, in declaration order.
* An array of size zero is returned if this class has no type
* variables.
*
* @return the type variables associated with this class.
* @throws GenericSignatureFormatError if the generic signature does
* not conform to the format specified in the Virtual Machine
* specification, version 3.
* @since 1.5
*/
/* FIXME[GENERICS]: Should return TypeVariable<Class<T>> */
public TypeVariable[] getTypeParameters()
{
String sig = VMClass.getClassSignature(this);
if (sig == null)
return new TypeVariable[0];
ClassSignatureParser p = new ClassSignatureParser(this, sig);
return p.getTypeParameters();
}
/**
* Returns true if an annotation for the specified type is associated
* with this class. This is primarily a short-hand for using marker
* annotations.
*
* @param annotationClass the type of annotation to look for.
* @return true if an annotation exists for the specified type.
* @since 1.5
*/
/* FIXME[GENERICS]: Should be Class<? extends Annotation> */
public boolean isAnnotationPresent(Class
annotationClass)
{
return getAnnotation(annotationClass) != null;
}
/**
* Returns true if this object represents an anonymous class.
*
* @return true if this object represents an anonymous class.
* @since 1.5
*/
public boolean isAnonymousClass()
{
return VMClass.isAnonymousClass(this);
}
/**
* Returns true if this object represents an local class.
*
* @return true if this object represents an local class.
* @since 1.5
*/
public boolean isLocalClass()
{
return VMClass.isLocalClass(this);
}
/**
* Returns true if this object represents an member class.
*
* @return true if this object represents an member class.
* @since 1.5
*/
public boolean isMemberClass()
{
return VMClass.isMemberClass(this);
}
}

View file

@ -469,7 +469,8 @@ public abstract class ClassLoader
if (domain == null)
domain = StaticData.defaultProtectionDomain;
return VMClassLoader.defineClass(this, name, data, offset, len, domain);
return VMClassLoader.defineClassWithTransformers(this, name, data, offset,
len, domain);
}
/**
@ -628,8 +629,9 @@ public abstract class ClassLoader
* @return an enumaration of all resources found
* @throws IOException if I/O errors occur in the process
* @since 1.2
* @specnote this was <code>final</code> prior to 1.5
*/
public final Enumeration getResources(String name) throws IOException
public Enumeration getResources(String name) throws IOException
{
Enumeration parentResources;
if (parent == null)
@ -834,7 +836,7 @@ public abstract class ClassLoader
throw new IllegalArgumentException("Package " + name
+ " already defined");
Package p = new Package(name, specTitle, specVendor, specVersion,
implTitle, implVendor, implVersion, sealed);
implTitle, implVendor, implVersion, sealed, this);
synchronized (definedPackages)
{
definedPackages.put(name, p);

View file

@ -0,0 +1,248 @@
/* Enum.java - Base class for all enums
Copyright (C) 2004, 2005 Free Software Foundation
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;
import java.io.Serializable;
import java.lang.reflect.Field;
/**
* This class represents a Java enumeration. All enumerations are
* subclasses of this class.
*
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
/* FIXME[GENERICS]: Should be Enum<T extends Enum<T>>
and Comparable<T> */
public abstract class Enum
implements Comparable, Serializable
{
/**
* For compatability with Sun's JDK
*/
private static final long serialVersionUID = -4300926546619394005L;
/**
* The name of this enum constant.
*/
String name;
/**
* The number of this enum constant. Each constant is given a number
* which matches the order in which it was declared, starting with zero.
*/
int ordinal;
/**
* This constructor is used by the compiler to create enumeration constants.
*
* @param name the name of the enumeration constant.
* @param ordinal the number of the enumeration constant, based on the
* declaration order of the constants and starting from zero.
*/
protected Enum(String name, int ordinal)
{
this.name = name;
this.ordinal = ordinal;
}
/**
* Returns an Enum for a enum class given a description string of
* the enum constant.
*
* @exception NullPointerException when etype or s are null.
* @exception IllegalArgumentException when there is no value s in
* the enum etype.
*/
/* FIXME[GENERICS]: Should be <S extends Enum<S>> S valueOf(Class<S>) */
public static Enum valueOf(Class etype, String s)
{
if (etype == null || s == null)
throw new NullPointerException();
try
{
Field f = etype.getDeclaredField(s);
if (! f.isEnumConstant())
throw new IllegalArgumentException(s);
/* FIXME[GENERICS]: Should cast to S */
return (Enum) f.get(null);
}
catch (NoSuchFieldException exception)
{
throw new IllegalArgumentException(s);
}
catch (IllegalAccessException exception)
{
throw new Error("Unable to access Enum class");
}
}
/**
* Returns true if this enumeration is equivalent to the supplied object,
* <code>o</code>. Only one instance of an enumeration constant exists,
* so the comparison is simply done using <code>==</code>.
*
* @param o the object to compare to this.
* @return true if <code>this == o</code>.
*/
public final boolean equals(Object o)
{
// Enum constants are singular, so we need only compare `=='.
return this == o;
}
/**
* Returns the hash code of this constant. This is simply the ordinal.
*
* @return the hash code of this enumeration constant.
*/
public final int hashCode()
{
return ordinal;
}
/**
* Returns a textual representation of this enumeration constant.
* By default, this is simply the declared name of the constant, but
* specific enumeration types may provide an implementation more suited
* to the data being stored.
*
* @return a textual representation of this constant.
*/
public String toString()
{
return name;
}
/**
* Returns an integer which represents the relative ordering of this
* enumeration constant. Enumeration constants are ordered by their
* ordinals, which represents their declaration order. So, comparing
* two identical constants yields zero, while one declared prior to
* this returns a positive integer and one declared after yields a
* negative integer.
*
* @param e the enumeration constant to compare.
* @return a negative integer if <code>e.ordinal < this.ordinal</code>,
* zero if <code>e.ordinal == this.ordinal</code> and a positive
* integer if <code>e.ordinal > this.ordinal</code>.
* @throws ClassCastException if <code>e</code> is not an enumeration
* constant of the same class.
*/
public final int compareTo(Enum e)
{
if (getDeclaringClass() != e.getDeclaringClass())
throw new ClassCastException();
return ordinal - e.ordinal;
}
/**
* Returns an integer which represents the relative ordering of this
* enumeration constant. Enumeration constants are ordered by their
* ordinals, which represents their declaration order. So, comparing
* two identical constants yields zero, while one declared prior to
* this returns a positive integer and one declared after yields a
* negative integer.
*
* @param o the enumeration constant to compare.
* @return a negative integer if <code>e.ordinal < this.ordinal</code>,
* zero if <code>e.ordinal == this.ordinal</code> and a positive
* integer if <code>e.ordinal > this.ordinal</code>.
* @throws ClassCastException if <code>e</code> is not an enumeration
* constant of the same class.
*/
/* FIXME[GENERICS]: Remove this method */
public final int compareTo(Object o)
{
return compareTo((Enum)o);
}
/**
* Cloning of enumeration constants is prevented, to maintain their
* singleton status.
*
* @return the cloned object.
* @throws CloneNotSupportedException as enumeration constants can't be
* cloned.
*/
protected final Object clone() throws CloneNotSupportedException
{
throw new CloneNotSupportedException("can't clone an enum constant");
}
/**
* Returns the name of this enumeration constant.
*
* @return the name of the constant.
*/
public final String name()
{
return name;
}
/**
* Returns the number of this enumeration constant, which represents
* the order in which it was originally declared, starting from zero.
*
* @return the number of this constant.
*/
public final int ordinal()
{
return ordinal;
}
/**
* Returns the type of this enumeration constant. This is the class
* corresponding to the declaration of the enumeration.
*
* @return the type of this enumeration constant.
*/
/* FIXME[GENERICS]: Should return Class<T> */
public final Class getDeclaringClass()
{
Class k = getClass();
// We might be in an anonymous subclass of the enum class, so go
// up one more level.
if (k.getSuperclass() != Enum.class)
k = k.getSuperclass();
return k;
}
}

View file

@ -48,6 +48,8 @@ package java.lang;
*/
public class EnumConstantNotPresentException extends RuntimeException
{
private static final long serialVersionUID = -6046998521960521108L;
/**
* The enum's type. Note that the name is fixed by the
* serialization spec.

View file

@ -0,0 +1,59 @@
/* Iterable.java -- Notes collection over which one may iterate
Copyright (C) 2004 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;
import java.util.Iterator;
/**
* This interface is used to indicate that a given class can be
* iterated over. The compiler uses this interface to determine which
* classes are suitable targets of the <code>foreach</code> construct.
*
* @author Tom Tromey <tromey@redhat.com>
* @since 1.5
*/
public interface Iterable
{
/**
* Returns an iterator for the collection.
*
* @return an iterator.
*/
Iterator iterator ();
}

View file

@ -948,4 +948,105 @@ public final class Math
return VMMath.tanh(a);
}
/**
* Return the ulp for the given double argument. The ulp is the
* difference between the argument and the next larger double. Note
* that the sign of the double argument is ignored, that is,
* ulp(x) == ulp(-x). If the argument is a NaN, then NaN is returned.
* If the argument is an infinity, then +Inf is returned. If the
* argument is zero (either positive or negative), then
* {@link Double#MIN_VALUE} is returned.
* @param d the double whose ulp should be returned
* @return the difference between the argument and the next larger double
* @since 1.5
*/
public static double ulp(double d)
{
if (Double.isNaN(d))
return d;
if (Double.isInfinite(d))
return Double.POSITIVE_INFINITY;
// This handles both +0.0 and -0.0.
if (d == 0.0)
return Double.MIN_VALUE;
long bits = Double.doubleToLongBits(d);
final int mantissaBits = 52;
final int exponentBits = 11;
final long mantMask = (1L << mantissaBits) - 1;
long mantissa = bits & mantMask;
final long expMask = (1L << exponentBits) - 1;
long exponent = (bits >>> mantissaBits) & expMask;
// Denormal number, so the answer is easy.
if (exponent == 0)
{
long result = (exponent << mantissaBits) | 1L;
return Double.longBitsToDouble(result);
}
// Conceptually we want to have '1' as the mantissa. Then we would
// shift the mantissa over to make a normal number. If this underflows
// the exponent, we will make a denormal result.
long newExponent = exponent - mantissaBits;
long newMantissa;
if (newExponent > 0)
newMantissa = 0;
else
{
newMantissa = 1L << -(newExponent - 1);
newExponent = 0;
}
return Double.longBitsToDouble((newExponent << mantissaBits) | newMantissa);
}
/**
* Return the ulp for the given float argument. The ulp is the
* difference between the argument and the next larger float. Note
* that the sign of the float argument is ignored, that is,
* ulp(x) == ulp(-x). If the argument is a NaN, then NaN is returned.
* If the argument is an infinity, then +Inf is returned. If the
* argument is zero (either positive or negative), then
* {@link Float#MIN_VALUE} is returned.
* @param f the float whose ulp should be returned
* @return the difference between the argument and the next larger float
* @since 1.5
*/
public static float ulp(float f)
{
if (Float.isNaN(f))
return f;
if (Float.isInfinite(f))
return Float.POSITIVE_INFINITY;
// This handles both +0.0 and -0.0.
if (f == 0.0)
return Float.MIN_VALUE;
int bits = Float.floatToIntBits(f);
final int mantissaBits = 23;
final int exponentBits = 8;
final int mantMask = (1 << mantissaBits) - 1;
int mantissa = bits & mantMask;
final int expMask = (1 << exponentBits) - 1;
int exponent = (bits >>> mantissaBits) & expMask;
// Denormal number, so the answer is easy.
if (exponent == 0)
{
int result = (exponent << mantissaBits) | 1;
return Float.intBitsToFloat(result);
}
// Conceptually we want to have '1' as the mantissa. Then we would
// shift the mantissa over to make a normal number. If this underflows
// the exponent, we will make a denormal result.
int newExponent = exponent - mantissaBits;
int newMantissa;
if (newExponent > 0)
newMantissa = 0;
else
{
newMantissa = 1 << -(newExponent - 1);
newExponent = 0;
}
return Float.intBitsToFloat((newExponent << mantissaBits) | newMantissa);
}
}

View file

@ -1,5 +1,6 @@
/* Package.java -- information about a package
Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -39,6 +40,8 @@ package java.lang;
import gnu.classpath.VMStackWalker;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.net.URL;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
@ -70,9 +73,10 @@ import java.util.StringTokenizer;
* @see ClassLoader#definePackage(String, String, String, String, String,
* String, String, URL)
* @since 1.2
* @status updated to 1.4
* @status updated to 1.5
*/
public class Package
implements AnnotatedElement
{
/** The name of the Package */
private final String name;
@ -98,6 +102,20 @@ public class Package
/** If sealed the origin of the package classes, otherwise null */
private final URL sealed;
/** The class loader that defined this package */
private ClassLoader loader;
/** @deprecated Please use the other constructor that takes the class loader
* that defines the Package.
*/
Package(String name,
String specTitle, String specVendor, String specVersion,
String implTitle, String implVendor, String implVersion, URL sealed)
{
this(name, specTitle, specVendor, specVersion, implTitle, implVendor,
implVersion, sealed, null);
}
/**
* A package local constructor for the Package class. All parameters except
* the <code>name</code> of the package may be <code>null</code>.
@ -115,7 +133,8 @@ public class Package
*/
Package(String name,
String specTitle, String specVendor, String specVersion,
String implTitle, String implVendor, String implVersion, URL sealed)
String implTitle, String implVendor, String implVersion, URL sealed,
ClassLoader loader)
{
if (name == null)
throw new IllegalArgumentException("null Package name");
@ -128,6 +147,7 @@ public class Package
this.specVendor = specVendor;
this.specVersion = specVersion;
this.sealed = sealed;
this.loader = loader;
}
/**
@ -233,7 +253,7 @@ public class Package
*
* @return true if the version is compatible, false otherwise
*
* @Throws NumberFormatException if either version string is invalid
* @throws NumberFormatException if either version string is invalid
* @throws NullPointerException if either version string is null
*/
public boolean isCompatibleWith(String version)
@ -315,4 +335,82 @@ public class Package
return ("package " + name + (specTitle == null ? "" : ", " + specTitle)
+ (specVersion == null ? "" : ", version " + specVersion));
}
/**
* Returns this package's annotation for the specified annotation type,
* or <code>null</code> if no such annotation exists.
*
* @param annotationClass the type of annotation to look for.
* @return this package's annotation for the specified type, or
* <code>null</code> if no such annotation exists.
* @since 1.5
*/
/* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
public Annotation getAnnotation(Class annotationClass)
{
Annotation foundAnnotation = null;
Annotation[] annotations = getAnnotations();
for (int i = 0; i < annotations.length; i++)
if (annotations[i].annotationType() == annotationClass)
foundAnnotation = annotations[i];
return foundAnnotation;
}
/**
* Returns all annotations associated with this package. If there are
* no annotations associated with this package, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* package, and hence no effect on the return value of this method for
* future callers.
*
* @return this package' annotations.
* @since 1.5
*/
public Annotation[] getAnnotations()
{
/** All a package's annotations are declared within it. */
return getDeclaredAnnotations();
}
/**
* Returns all annotations directly defined by this package. If there are
* no annotations associated with this package, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* package, and hence no effect on the return value of this method for
* future callers.
*
* @return the annotations directly defined by this package.
* @since 1.5
*/
public Annotation[] getDeclaredAnnotations()
{
try
{
Class pkgInfo = Class.forName(name + ".package-info", false, loader);
return pkgInfo.getDeclaredAnnotations();
}
catch (ClassNotFoundException _)
{
return new Annotation[0];
}
}
/**
* Returns true if an annotation for the specified type is associated
* with this package. This is primarily a short-hand for using marker
* annotations.
*
* @param annotationClass the type of annotation to look for.
* @return true if an annotation exists for the specified type.
* @since 1.5
*/
/* FIXME[GENERICS]: Signature is Class<? extends Annotation> */
public boolean isAnnotationPresent(Class
annotationClass)
{
return getAnnotation(annotationClass) != null;
}
} // class Package

View file

@ -1,5 +1,5 @@
/* StackTraceElement.java -- One function call or call stack element
Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -211,7 +211,7 @@ public final class StackTraceElement implements Serializable
}
if (methodName != null)
sb.append(methodName);
sb.append(" (");
sb.append("(");
if (fileName != null)
sb.append(fileName);
else

View file

@ -1841,4 +1841,84 @@ public final strictfp class StrictMath
double t = (float) a;
return t + a * (1 + t * z + t * v);
}
/**
* <p>
* Returns the sign of the argument as follows:
* </p>
* <ul>
* <li>If <code>a</code> is greater than zero, the result is 1.0.</li>
* <li>If <code>a</code> is less than zero, the result is -1.0.</li>
* <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
* <li>If <code>a</code> is positive or negative zero, the result is the
* same.</li>
* </ul>
*
* @param a the numeric argument.
* @return the sign of the argument.
* @since 1.5.
*/
public static double signum(double a)
{
// There's no difference.
return Math.signum(a);
}
/**
* <p>
* Returns the sign of the argument as follows:
* </p>
* <ul>
* <li>If <code>a</code> is greater than zero, the result is 1.0f.</li>
* <li>If <code>a</code> is less than zero, the result is -1.0f.</li>
* <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
* <li>If <code>a</code> is positive or negative zero, the result is the
* same.</li>
* </ul>
*
* @param a the numeric argument.
* @return the sign of the argument.
* @since 1.5.
*/
public static float signum(float a)
{
// There's no difference.
return Math.signum(a);
}
/**
* Return the ulp for the given double argument. The ulp is the
* difference between the argument and the next larger double. Note
* that the sign of the double argument is ignored, that is,
* ulp(x) == ulp(-x). If the argument is a NaN, then NaN is returned.
* If the argument is an infinity, then +Inf is returned. If the
* argument is zero (either positive or negative), then
* {@link Double#MIN_VALUE} is returned.
* @param d the double whose ulp should be returned
* @return the difference between the argument and the next larger double
* @since 1.5
*/
public static double ulp(double d)
{
// There's no difference.
return Math.ulp(d);
}
/**
* Return the ulp for the given float argument. The ulp is the
* difference between the argument and the next larger float. Note
* that the sign of the float argument is ignored, that is,
* ulp(x) == ulp(-x). If the argument is a NaN, then NaN is returned.
* If the argument is an infinity, then +Inf is returned. If the
* argument is zero (either positive or negative), then
* {@link Float#MIN_VALUE} is returned.
* @param f the float whose ulp should be returned
* @return the difference between the argument and the next larger float
* @since 1.5
*/
public static float ulp(float f)
{
// There's no difference.
return Math.ulp(f);
}
}

View file

@ -206,7 +206,7 @@ public final class StringBuilder
int max = value.length * 2 + 2;
minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
char[] nb = new char[minimumCapacity];
System.arraycopy(value, 0, nb, 0, count);
VMSystem.arraycopy(value, 0, nb, 0, count);
value = nb;
}
}
@ -285,7 +285,7 @@ public final class StringBuilder
{
if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
throw new StringIndexOutOfBoundsException();
System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
VMSystem.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
}
/**
@ -355,7 +355,7 @@ public final class StringBuilder
{
int len = stringBuffer.count;
ensureCapacity(count + len);
System.arraycopy(stringBuffer.value, 0, value, count, len);
VMSystem.arraycopy(stringBuffer.value, 0, value, count, len);
count += len;
}
return this;
@ -395,7 +395,7 @@ public final class StringBuilder
if (offset < 0 || count < 0 || offset > data.length - count)
throw new StringIndexOutOfBoundsException();
ensureCapacity(this.count + count);
System.arraycopy(data, offset, value, this.count, count);
VMSystem.arraycopy(data, offset, value, this.count, count);
this.count += count;
return this;
}
@ -558,7 +558,7 @@ public final class StringBuilder
// This will unshare if required.
ensureCapacity(count);
if (count - end != 0)
System.arraycopy(value, end, value, start, count - end);
VMSystem.arraycopy(value, end, value, start, count - end);
count -= end - start;
return this;
}
@ -599,7 +599,7 @@ public final class StringBuilder
ensureCapacity(count + delta);
if (delta != 0 && end < count)
System.arraycopy(value, end, value, end + delta, count - end);
VMSystem.arraycopy(value, end, value, end + delta, count - end);
str.getChars(0, len, value, start);
count += delta;
@ -677,8 +677,8 @@ public final class StringBuilder
|| str_offset < 0 || str_offset > str.length - len)
throw new StringIndexOutOfBoundsException();
ensureCapacity(count + len);
System.arraycopy(value, offset, value, offset + len, count - offset);
System.arraycopy(str, str_offset, value, offset, len);
VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
VMSystem.arraycopy(str, str_offset, value, offset, len);
count += len;
return this;
}
@ -717,7 +717,7 @@ public final class StringBuilder
str = "null";
int len = str.count;
ensureCapacity(count + len);
System.arraycopy(value, offset, value, offset + len, count - offset);
VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
str.getChars(0, len, value, offset);
count += len;
return this;
@ -814,7 +814,7 @@ public final class StringBuilder
if (offset < 0 || offset > count)
throw new StringIndexOutOfBoundsException(offset);
ensureCapacity(count + 1);
System.arraycopy(value, offset, value, offset + 1, count - offset);
VMSystem.arraycopy(value, offset, value, offset + 1, count - offset);
value[offset] = ch;
count++;
return this;
@ -1063,7 +1063,7 @@ public final class StringBuilder
if (count < value.length)
{
char[] newValue = new char[count];
System.arraycopy(value, 0, newValue, 0, count);
VMSystem.arraycopy(value, 0, newValue, 0, count);
value = newValue;
}
}

View file

@ -364,7 +364,7 @@ public final class System
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertyAccess(key);
else if (key.length() == 0)
if (key.length() == 0)
throw new IllegalArgumentException("key can't be empty");
return SystemProperties.getProperty(key);
}
@ -385,6 +385,10 @@ public final class System
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPropertyAccess(key);
// This handles both the null pointer exception and the illegal
// argument exception.
if (key.length() == 0)
throw new IllegalArgumentException("key can't be empty");
return SystemProperties.getProperty(key, def);
}
@ -405,9 +409,36 @@ public final class System
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new PropertyPermission(key, "write"));
// This handles both the null pointer exception and the illegal
// argument exception.
if (key.length() == 0)
throw new IllegalArgumentException("key can't be empty");
return SystemProperties.setProperty(key, value);
}
/**
* Remove a single system property by name. A security check may be
* performed, <code>checkPropertyAccess(key, "write")</code>.
*
* @param key the name of the system property to remove
* @return the previous value, or null
* @throws SecurityException if permission is denied
* @throws NullPointerException if key is null
* @throws IllegalArgumentException if key is ""
* @since 1.5
*/
public static String clearProperty(String key)
{
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new PropertyPermission(key, "write"));
// This handles both the null pointer exception and the illegal
// argument exception.
if (key.length() == 0)
throw new IllegalArgumentException("key can't be empty");
return SystemProperties.remove(key);
}
/**
* Gets the value of an environment variable.
*

View file

@ -1,5 +1,5 @@
/* Thread -- an independent thread of executable code
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation
This file is part of GNU Classpath.
@ -81,6 +81,7 @@ import java.util.Map;
* @author Tom Tromey
* @author John Keiser
* @author Eric Blake (ebb9@email.byu.edu)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see Runnable
* @see Runtime#exit(int)
* @see #run()
@ -130,15 +131,27 @@ public class Thread implements Runnable
/** The context classloader for this Thread. */
private ClassLoader contextClassLoader;
/** This thread's ID. */
private final long threadId;
/** The next thread number to use. */
private static int numAnonymousThreadsCreated;
/** The next thread ID to use. */
private static long nextThreadId;
/** The default exception handler. */
private static UncaughtExceptionHandler defaultHandler;
/** Thread local storage. Package accessible for use by
* InheritableThreadLocal.
*/
WeakIdentityHashMap locals;
/** The uncaught exception handler. */
UncaughtExceptionHandler exceptionHandler;
/**
* Allocates a new <code>Thread</code> object. This constructor has
* the same effect as <code>Thread(null, null,</code>
@ -342,6 +355,11 @@ public class Thread implements Runnable
this.name = name.toString();
this.runnable = target;
this.stacksize = size;
synchronized (Thread.class)
{
this.threadId = nextThreadId++;
}
priority = current.priority;
daemon = current.daemon;
@ -371,6 +389,11 @@ public class Thread implements Runnable
this.priority = priority;
this.daemon = daemon;
this.contextClassLoader = ClassLoader.getSystemClassLoader();
synchronized (Thread.class)
{
this.threadId = nextThreadId++;
}
}
/**
@ -434,6 +457,19 @@ public class Thread implements Runnable
/**
* Originally intended to destroy this thread, this method was never
* implemented by Sun, and is hence a no-op.
*
* @deprecated This method was originally intended to simply destroy
* the thread without performing any form of cleanup operation.
* However, it was never implemented. It is now deprecated
* for the same reason as <code>suspend()</code>,
* <code>stop()</code> and <code>resume()</code>; namely,
* it is prone to deadlocks. If a thread is destroyed while
* it still maintains a lock on a resource, then this resource
* will remain locked and any attempts by other threads to
* access the resource will result in a deadlock. Thus, even
* an implemented version of this method would be still be
* deprecated, due to its unsafe nature.
* @throws NoSuchMethodError as this method was never implemented.
*/
public void destroy()
{
@ -1000,4 +1036,159 @@ public class Thread implements Runnable
}
return locals;
}
/**
* Assigns the given <code>UncaughtExceptionHandler</code> to this
* thread. This will then be called if the thread terminates due
* to an uncaught exception, pre-empting that of the
* <code>ThreadGroup</code>.
*
* @param h the handler to use for this thread.
* @throws SecurityException if the current thread can't modify this thread.
* @since 1.5
*/
public void setUncaughtExceptionHandler(UncaughtExceptionHandler h)
{
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkAccess(this);
exceptionHandler = h;
}
/**
* <p>
* Returns the handler used when this thread terminates due to an
* uncaught exception. The handler used is determined by the following:
* </p>
* <ul>
* <li>If this thread has its own handler, this is returned.</li>
* <li>If not, then the handler of the thread's <code>ThreadGroup</code>
* object is returned.</li>
* <li>If both are unavailable, then <code>null</code> is returned
* (which can only happen when the thread was terminated since
* then it won't have an associated thread group anymore).</li>
* </ul>
*
* @return the appropriate <code>UncaughtExceptionHandler</code> or
* <code>null</code> if one can't be obtained.
* @since 1.5
*/
public UncaughtExceptionHandler getUncaughtExceptionHandler()
{
return exceptionHandler != null ? exceptionHandler : group;
}
/**
* <p>
* Sets the default uncaught exception handler used when one isn't
* provided by the thread or its associated <code>ThreadGroup</code>.
* This exception handler is used when the thread itself does not
* have an exception handler, and the thread's <code>ThreadGroup</code>
* does not override this default mechanism with its own. As the group
* calls this handler by default, this exception handler should not defer
* to that of the group, as it may lead to infinite recursion.
* </p>
* <p>
* Uncaught exception handlers are used when a thread terminates due to
* an uncaught exception. Replacing this handler allows default code to
* be put in place for all threads in order to handle this eventuality.
* </p>
*
* @param h the new default uncaught exception handler to use.
* @throws SecurityException if a security manager is present and
* disallows the runtime permission
* "setDefaultUncaughtExceptionHandler".
* @since 1.5
*/
public static void
setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler h)
{
SecurityManager sm = SecurityManager.current; // Be thread-safe.
if (sm != null)
sm.checkPermission(new RuntimePermission("setDefaultUncaughtExceptionHandler"));
defaultHandler = h;
}
/**
* Returns the handler used by default when a thread terminates
* unexpectedly due to an exception, or <code>null</code> if one doesn't
* exist.
*
* @return the default uncaught exception handler.
* @since 1.5
*/
public static UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()
{
return defaultHandler;
}
/**
* Returns the unique identifier for this thread. This ID is generated
* on thread creation, and may be re-used on its death.
*
* @return a positive long number representing the thread's ID.
* @since 1.5
*/
public long getId()
{
return threadId;
}
/**
* <p>
* This interface is used to handle uncaught exceptions
* which cause a <code>Thread</code> to terminate. When
* a thread, t, is about to terminate due to an uncaught
* exception, the virtual machine looks for a class which
* implements this interface, in order to supply it with
* the dying thread and its uncaught exception.
* </p>
* <p>
* The virtual machine makes two attempts to find an
* appropriate handler for the uncaught exception, in
* the following order:
* </p>
* <ol>
* <li>
* <code>t.getUncaughtExceptionHandler()</code> --
* the dying thread is queried first for a handler
* specific to that thread.
* </li>
* <li>
* <code>t.getThreadGroup()</code> --
* the thread group of the dying thread is used to
* handle the exception. If the thread group has
* no special requirements for handling the exception,
* it may simply forward it on to
* <code>Thread.getDefaultUncaughtExceptionHandler()</code>,
* the default handler, which is used as a last resort.
* </li>
* </ol>
* <p>
* The first handler found is the one used to handle
* the uncaught exception.
* </p>
*
* @author Tom Tromey <tromey@redhat.com>
* @author Andrew John Hughes <gnu_andrew@member.fsf.org>
* @since 1.5
* @see Thread#getUncaughtExceptionHandler()
* @see Thread#setUncaughtExceptionHander(java.lang.Thread.UncaughtExceptionHandler)
* @see Thread#getDefaultUncaughtExceptionHandler()
* @see
* Thread#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
*/
public interface UncaughtExceptionHandler
{
/**
* Invoked by the virtual machine with the dying thread
* and the uncaught exception. Any exceptions thrown
* by this method are simply ignored by the virtual
* machine.
*
* @param thr the dying thread.
* @param exc the uncaught exception.
*/
void uncaughtException(Thread thr, Throwable exc);
}
}

View file

@ -37,6 +37,7 @@ exception statement from your version. */
package java.lang;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Vector;
/**
@ -53,7 +54,7 @@ import java.util.Vector;
* @since 1.0
* @status updated to 1.4
*/
public class ThreadGroup
public class ThreadGroup implements UncaughtExceptionHandler
{
/** The Initial, top-level ThreadGroup. */
static ThreadGroup root = new ThreadGroup();
@ -545,6 +546,8 @@ public class ThreadGroup
{
if (parent != null)
parent.uncaughtException(thread, t);
else if (Thread.getDefaultUncaughtExceptionHandler() != null)
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(thread, t);
else if (! (t instanceof ThreadDeath))
{
if (t == null)

View file

@ -152,4 +152,15 @@ public class ThreadLocal
// ever modify the map.
map.put(this, value == null ? NULL : value);
}
/**
* Removes the value associated with the ThreadLocal object for the
* currently executing Thread.
* @since 1.5
*/
public void remove()
{
Map map = Thread.getThreadLocals();
map.remove(this);
}
}

View file

@ -58,7 +58,8 @@ package java.lang;
public class TypeNotPresentException
extends RuntimeException
{
private static final long serialVersionUID = -5101214195716534496L;
/**
* Constructs a <code>TypeNotPresentException</code> for
* the supplied type. The specified cause <code>Throwable</code>

View file

@ -0,0 +1,136 @@
/* Annotation.java - Base interface for all annotations
Copyright (C) 2004 Free Software Foundation
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.annotation;
/**
* This is the common interface for all annotations. Note that classes
* that implement this class manually are not classed as annotations, and
* that this interface does not define an annotation type in itself.
*
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public interface Annotation
{
/**
* Returns the type of this annotation.
*
* @return the class of which this annotation is an instance.
*/
/* FIXME[GENERICS]: Should return Class<? extends Annotation> */
Class annotationType();
/**
* <p>
* Returns true if the supplied object is equivalent to this annotation.
* For this property to hold, the following must be true of <code>o</code>:
* </p>
* <ul>
* <li>The object is also an instance of the same annotation type.</li>
* <li>The members of the supplied annotation are equal to those of this
* annotation, according to the following:
* <ul>
* <li>If the members are <code>float</code>s, then, for floats
* <code>x</code> and <code>y</code>,
* <code>Float.valueOf(x).equals(Float.valueOf(y)</code> must return
* true. This differs from the usual (<code>==</code>) comparison
* in that <code>NaN</code> is considered equal to itself and positive
* and negative zero are seen as different.</li>
* <li>Likewise, if the members are <code>double</code>s, then, for doubles
* <code>x</code> and <code>y</code>,
* <code>Double.valueOf(x).equals(Double.valueOf(y)</code> must return
* true. This differs from the usual (<code>==</code>) comparison
* in that <code>NaN</code> is considered equal to itself and positive
* and negative zero are seen as different.</li>
* <li>Strings, classes, enumerations and annotations are considered
* equal according to the <code>equals()</code> implementation for these
* types.</li>
* <li>Arrays are considered equal according to <code>Arrays.equals()</code>
* </li>
* <li>Any remaining types are considered equal using <code>==</code>.</li>
* </li>
* </ul>
*
* @param o the object to compare with this annotation.
* @return true if the supplied object is an annotation with equivalent
* members.
*/
boolean equals(Object o);
/**
* <p>
* Returns the hash code of the annotation. This is computed as the
* sum of the hash codes of the annotation's members.
* </p>
* <p>
* The hash code of a member of the annotation is the result of XORing
* the hash code of its value with the result of multiplying the hash code
* of its name by 127. Formally, if the value is <code>v</code> and the
* name is <code>n</code>, the hash code of the member is
* v.hashCode() XOR (127 * String.hashCode(n)). <code>v.hashCode()</code>
* is defined as follows:
* </p>
* <ul>
* <li>The hash code of a primitive value (i.e. <code>byte</code>,
* <code>char</code>, <code>double</code>, <code>float</code>,
* <code>int</code>, <code>long</code>, <code>short</code> and
* <code>boolean</code>) is the hash code obtained from its corresponding
* wrapper class using <code>valueOf(v).hashCode()</code>, where
* <code>v</code> is the primitive value.</li>
* <li>The hash code of an enumeration, string, class or other annotation
* is obtained using <code>v.hashCode()</code>.</li>
* <li>The hash code of an array is computed using
* <code>Arrays.hashCode(v)</code>.</li>
* </ul>
*
* @return the hash code of the annotation, computed as the sum of its
* member hashcodes.
*/
int hashCode();
/**
* Returns a textual representation of the annotation. This is
* implementation-dependent, but is expected to include the classname
* and the names and values of each member.
*
* @return a textual representation of the annotation.
*/
String toString();
}

View file

@ -49,6 +49,7 @@ package java.lang.annotation;
*/
public class AnnotationFormatError extends Error
{
private static final long serialVersionUID = -4256701562333669892L;
/**
* Constructs a new <code>AnnotationFormatError</code>

View file

@ -1,58 +0,0 @@
# This property file contains dependencies of classes, methods, and
# field on other methods or classes.
#
# Syntax:
#
# <used>: <needed 1> [... <needed N>]
#
# means that when <used> is included, <needed 1> (... <needed N>) must
# be included as well.
#
# <needed X> and <used> are of the form
#
# <class.methodOrField(signature)>
#
# or just
#
# <class>
#
# Within dependencies, variables can be used. A variable is defined as
# follows:
#
# {variable}: value1 value2 ... value<n>
#
# variables can be used on the right side of dependencies as follows:
#
# <used>: com.bla.blu.{variable}.Class.m()V
#
# The use of the variable will expand to <n> dependencies of the form
#
# <used>: com.bla.blu.value1.Class.m()V
# <used>: com.bla.blu.value2.Class.m()V
# ...
# <used>: com.bla.blu.value<n>.Class.m()V
#
# Variables can be redefined when building a system to select the
# required support for features like encodings, protocols, etc.
#
# Hints:
#
# - For methods and fields, the signature is mandatory. For
# specification, please see the Java Virtual Machine Specification by
# SUN. Unlike in the spec, field signatures (types) are in brackets.
#
# - Package names must be separated by '/' (and not '.'). E.g.,
# java/lang/Class (this is necessary, because the '.' is used to
# separate method or field names from classes)
#
# - In case <needed> refers to a class, only the class itself will be
# included in the resulting binary, NOT necessarily all its methods
# and fields. If you want to refer to all methods and fields, you can
# write class.* as an abbreviation.
#
# - Abbreviations for packages are also possible: my/package/* means all
# methods and fields of all classes in my/package.
#
# - A line with a trailing '\' continues in the next line.
# end of file

View file

@ -0,0 +1,88 @@
/* ClassDefinition.java -- Class that binds a class with a new class file
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.instrument;
/**
* This class binds a class that will be redefined with a new
* class file.
*
* @author Nicolas Geoffray (nicolas.geoffray@menlina.com)
* @see Instrumentation#redefineClasses(java.lang.instrument.ClassDefinition[])
* @since 1.5
*/
public final class ClassDefinition
{
/* The class it's related */
private Class theClass;
/* The new bytecode of theClass */
private byte[] theClassFile;
/**
* @param theClass the Class that will be redefined
* @param theClassFile the new class file
* @throws NullPointerException if one of the argument is null
*/
/* FIXME[GENERICS]: Signature should be (Class<?>, byte[]) */
public ClassDefinition(Class theClass, byte[] theClassFile)
{
if (theClass == null || theClassFile == null)
throw new NullPointerException();
this.theClass = theClass;
this.theClassFile = theClassFile;
}
/**
* @return the Class
*/
/* FIXME[GENERICS]: Should return Class<?> */
public Class getDefinitionClass()
{
return theClass;
}
/**
* @return the bytes
*/
public byte[] getDefinitionClassFile()
{
return theClassFile;
}
}

View file

@ -0,0 +1,86 @@
/* ClassFileTransformer.java -- Implementation of this interface is used by an agent to
transform class files.
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.instrument;
import java.security.ProtectionDomain;
/**
* This interface should be implemented by classes wishing to transform
* classes bytecode when defining or redefining classes.
*
* @author Nicolas Geoffray (nicolas.geoffray@menlina.com)
* @see Instrumentation
* @see Instrumentation#addTransformer(java.lang.instrument.ClassFileTransformer)
* @see Instrumentation#removeTransformer(java.lang.instrument.ClassFileTransformer)
* @since 1.5
*/
public interface ClassFileTransformer
{
/**
* Implementation of this method transforms a class by redefining its
* bytecodes. Once a ClassFileTransformer object registers itself to the
* Instrumentation object, this method will be called each time a class is
* defined (<code>ClassLoader.defineClass</code>) or redefined
* (<code>Instrumentation.redefineClasses</code>)
* @param loader the loader of the class
* @param className the name of the class with packages separated with "/"
* @param classBeingRedefined the class being redefined if it's the case,
* null otherwise
* @param protectionDomain the protection domain of the class being defined or
* redefined
* @param classfileBuffer the input byte buffer in class file format
*
* @return a class file buffer or null when no transformation has been performed
*
* @throws IllegalClassFormatException if the byte buffer does not represent
* a well-formed class file
* @see Instrumentation#redefineClasses(java.lang.instrument.ClassDefinition[])
*
*/
/* FIXME[GENERICS]: Class should be Class<?> */
byte[] transform(ClassLoader loader,
String className,
Class classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer)
throws IllegalClassFormatException;
}

View file

@ -0,0 +1,70 @@
/* IllegalClassFormatException.java -- thrown when an array of byte does
not represent a valid class file
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.instrument;
/**
* @author Nicolas Geoffray (nicolas.geoffray@menlina.com)
* @since 1.5
*/
public class IllegalClassFormatException extends Exception
{
/**
* Compatible with JDK 1.5+.
*/
private static final long serialVersionUID = -3841736710924794009L;
/**
* Create an exception without a message.
*/
public IllegalClassFormatException()
{
}
/**
* Create an exception with a message.
*
* @param s the message
*/
public IllegalClassFormatException(String s)
{
super(s);
}
}

View file

@ -0,0 +1,139 @@
/* Instrumentation.java -- Implementation of this interface is used to
instrument Java bytecode.
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.instrument;
/**
* An Instrumentation object has transformers that will
* be called each time a class is defined or redefined.
* The object is given to a <code>premain</code> function
* that is called before the <code>main</code> function.
*
* @author Nicolas Geoffray (nicolas.geoffray@menlina.com)
* @since 1.5
*/
public interface Instrumentation
{
/**
* Adds a <code>ClassFileTransformer</class> object
* to the instrumentation. Each time a class is defined
* or redefined, the <code>transform</code> method of the
* <code>transformer</code> object is called.
*
* @param transformer the transformer to add
* @throws NullPointerException if transformer is null
*/
void addTransformer(ClassFileTransformer transformer);
/**
* Removes the given transformer from the set of transformers
* this Instrumentation object has.
*
* @param transformer the transformer to remove
* @return true if the transformer was found and removed, false if
* the transformer was not found
* @throws NullPointerException if transformer is null
*/
boolean removeTransformer(ClassFileTransformer transformer);
/**
* Returns if the current JVM supports class redefinition
*
* @return true if the current JVM supports class redefinition
*/
boolean isRedefineClassesSupported();
/**
* Redefine classes present in the definitions array, with
* the corresponding class files.
*
* @param definitions an array of classes to redefine
*
* @throws ClassNotFoundException if a class cannot be found
* @throws UnmodifiableClassException if a class cannot be modified
* @throws UnsupportedOperationException if the JVM does not support
* redefinition or the redefinition made unsupported changes
* @throws ClassFormatError if a class file is not valid
* @throws NoClassDefFoundError if a class name is not equal to the name
* in the class file specified
* @throws UnsupportedClassVersionError if the class file version numbers
* are unsupported
* @throws ClassCircularityError if circularity occured with the new
* classes
* @throws LinkageError if a linkage error occurs
* @throws NullPointerException if the definitions array is null, or any
* of its element
*
* @see #isRedefineClassesSupported()
* @see #addTransformer(java.lang.instrument.ClassFileTransformer)
* @see ClassFileTransformer
*/
void redefineClasses(ClassDefinition[] definitions)
throws ClassNotFoundException,
UnmodifiableClassException;
/**
* Get all the classes loaded by the JVM.
*
* @return an array containing all the classes loaded by the JVM. The array
* is empty if no class is loaded.
*/
Class[] getAllLoadedClasses();
/**
* Get all the classes loaded by a given class loader
*
* @param loader the loader
*
* @return an array containing all the classes loaded by the given loader.
* The array is empty if no class was loaded by the loader.
*/
Class[] getInitiatedClasses(ClassLoader loader);
/**
* Get the size of an object. It contains the size of all fields.
*
* @param objectToSize the object
* @return the size of the object
* @throws NullPointerException if objectToSize is null.
*/
long getObjectSize(Object objectToSize);
}

View file

@ -0,0 +1,69 @@
/* UnmodifiableClassException.java -- thrown when attempting to redefine
an unmodifiable class
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.instrument;
/**
* @author Nicolas Geoffray (nicolas.geoffray@menlina.com)
* @since 1.5
*/
public class UnmodifiableClassException extends Exception
{
/**
* Compatible with JDK 1.5+.
*/
private static final long serialVersionUID = 1716652643585309178L;
/**
* Create an exception without a message.
*/
public UnmodifiableClassException()
{
}
/**
* Create an exception with a message.
*
* @param s the message
*/
public UnmodifiableClassException(String s)
{
super(s);
}
}

View file

@ -1,5 +1,5 @@
/* java.lang.reflect.AccessibleObject
Copyright (C) 2001, 2005 Free Software Foundation, Inc.
Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,6 +38,8 @@ exception statement from your version. */
package java.lang.reflect;
import java.lang.annotation.Annotation;
/**
* This class is the superclass of various reflection classes, and
* allows sufficiently trusted code to bypass normal restrictions to
@ -53,9 +55,10 @@ package java.lang.reflect;
* @see Method
* @see ReflectPermission
* @since 1.2
* @status updated to 1.4
* @status updated to 1.5
*/
public class AccessibleObject
implements AnnotatedElement
{
/**
* True if this object is marked accessible, which means the reflected
@ -156,4 +159,26 @@ public class AccessibleObject
throw new SecurityException("Cannot make object accessible: " + this);
this.flag = flag;
}
/* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
public Annotation getAnnotation(Class annotationClass)
{
throw new AssertionError("Subclass must override this method");
}
public Annotation[] getAnnotations()
{
return getDeclaredAnnotations();
}
public Annotation[] getDeclaredAnnotations()
{
throw new AssertionError("Subclass must override this method");
}
/* FIXME[GENERICS]: Signature is Class<? extends Annotation> */
public boolean isAnnotationPresent(Class annotationClass)
{
return getAnnotation(annotationClass) != null;
}
}

View file

@ -0,0 +1,117 @@
/* AnnotatedElement.java
Copyright (C) 2004, 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.reflect;
import java.lang.annotation.Annotation;
/**
* <p>
* Represents an element that can be annotated. The methods of this interface
* provide reflection-based access to the annotations associated with a
* particular element, such as a class, field, method or package. Each
* annotation returned by these methods is both immutable and serializable.
* The returned arrays may be freely modified, without any effect on the
* arrays returned to future callers.
* </p>
* <p>
* If an annotation refers to a type or enumeration constant that is
* inaccessible, then a <code>TypeNotPresentException</code> or
* <code>EnumConstantNotPresentException</code> will be thrown. Likewise,
* invalid annotations will produce either a
* <code>AnnotationTypeMismatchException</code> or
* <code>IncompleteAnnotationException</code>.
* </p>
*
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public interface AnnotatedElement
{
/**
* Returns the element's annotation for the specified annotation type,
* or <code>null</code> if no such annotation exists.
*
* @param annotationClass the type of annotation to look for.
* @return this element's annotation for the specified type, or
* <code>null</code> if no such annotation exists.
* @throws NullPointerException if the annotation class is <code>null</code>.
*/
/* FIXME[GENERICS]: <T extends Annotation> T getAnnotation(Class <T>) */
Annotation getAnnotation(Class annotationClass);
/**
* Returns all annotations associated with the element. If there are
* no annotations associated with the element, then a zero-length array
* will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of the
* element, and hence no effect on the return value of this method for
* future callers.
*
* @return this element's annotations.
*/
Annotation[] getAnnotations();
/**
* Returns all annotations directly defined by the element. If there are
* no annotations directly associated with the element, then a zero-length
* array will be returned. The returned array may be modified by the client
* code, but this will have no effect on the annotation content of this
* class, and hence no effect on the return value of this method for
* future callers.
*
* @return the annotations directly defined by the element.
* @since 1.5
*/
Annotation[] getDeclaredAnnotations();
/**
* Returns true if an annotation for the specified type is associated
* with the element. This is primarily a short-hand for using marker
* annotations.
*
* @param annotationClass the type of annotation to look for.
* @return true if an annotation exists for the specified type.
* @since 1.5
*/
/* FIXME[GENERICS]: Signature is Class<? extends Annotation> */
boolean isAnnotationPresent(Class annotationClass);
}

View file

@ -38,8 +38,6 @@ exception statement from your version. */
package java.lang.reflect;
import gnu.classpath.Configuration;
/**
* Array holds static helper functions that allow you to create and
* manipulate arrays by reflection. Operations know how to perform widening
@ -78,13 +76,6 @@ import gnu.classpath.Configuration;
*/
public final class Array
{
static
{
if (Configuration.INIT_LOAD_LIBRARY)
{
System.loadLibrary("javalangreflect");
}
}
/**
* This class is uninstantiable.
@ -107,7 +98,7 @@ public final class Array
public static Object newInstance(Class componentType, int length)
{
if (! componentType.isPrimitive())
return createObjectArray(componentType, length);
return VMArray.createObjectArray(componentType, length);
if (componentType == boolean.class)
return new boolean[length];
if (componentType == byte.class)
@ -653,7 +644,7 @@ public final class Array
Object toAdd = createMultiArray(type, dimensions, index - 1);
Class thisType = toAdd.getClass();
Object[] retval
= (Object[]) createObjectArray(thisType, dimensions[index]);
= (Object[]) VMArray.createObjectArray(thisType, dimensions[index]);
if (dimensions[index] > 0)
retval[0] = toAdd;
int i = dimensions[index];
@ -662,14 +653,4 @@ public final class Array
return retval;
}
/**
* Dynamically create an array of objects.
*
* @param type guaranteed to be a valid object type
* @param dim the length of the array
* @return the new array
* @throws NegativeArraySizeException if dim is negative
* @throws OutOfMemoryError if memory allocation fails
*/
private static native Object createObjectArray(Class type, int dim);
}

View file

@ -0,0 +1,63 @@
/* GenericDeclaration.java
Copyright (C) 2004 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.reflect;
/**
* Represents an entity that declares one or more type parameters.
* This includes classes and methods (including constructors).
*
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public interface GenericDeclaration
{
/**
* Returns a <code>TypeVariable</code> object for each type variable
* declared by this entity, in order of declaration. An empty array
* is returned if no type variables are declared.
*
* @return an array of <code>TypeVariable</code> objects.
* @throws GenericSignatureFormatError if the signature format within the
* class file does not conform to that specified in the 3rd edition
* of the Java Virtual Machine Specification.
*/
/* FIXME[GENERICS]: Should be TypeVariable<?>[] */
TypeVariable[] getTypeParameters();
}

View file

@ -51,6 +51,7 @@ package java.lang.reflect;
public class GenericSignatureFormatError
extends ClassFormatError
{
private static final long serialVersionUID = 6709919147137911034L;
/**
* Constructs a new <code>GenericSignatureFormatError</code>.

View file

@ -0,0 +1,60 @@
/* MalformedParameterizedTypeException.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.lang.reflect;
/**
* This exception class is thrown when one of the reflection
* methods encountered an invalid parameterized type within
* the metadata of a class. One possible reason for this
* exception being thrown is the specification of too few or
* too many type variables.
*
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
public class MalformedParameterizedTypeException
extends RuntimeException
{
private static final long serialVersionUID = -5696557788586220964L;
public MalformedParameterizedTypeException()
{
}
}

View file

@ -97,4 +97,13 @@ public interface Member
* @see Modifier
*/
int getModifiers();
/**
* Return true if this member is synthetic, meaning that it was
* created by the compiler and does not appear in the user's
* source code.
* @return true if the member is synthetic
* @since 1.5
*/
boolean isSynthetic();
}

View file

@ -157,6 +157,26 @@ public class Modifier
*/
static final int ALL_FLAGS = 0xfff;
/**
* Flag indicating a bridge method.
*/
static final int BRIDGE = 0x40;
/**
* Flag indicating a varargs method.
*/
static final int VARARGS = 0x80;
/**
* Flag indicating a synthetic member.
*/
static final int SYNTHETIC = 0x1000;
/**
* Flag indicating an enum constant or an enum class.
*/
static final int ENUM = 0x4000;
/**
* Check whether the given modifier is abstract.
* @param mod the modifier.
@ -288,7 +308,19 @@ public class Modifier
*/
public static String toString(int mod)
{
return toString(mod, new StringBuffer()).toString();
return toString(mod, new StringBuilder()).toString();
}
/**
* Package helper method that can take a StringBuilder.
* @param mod the modifier
* @param r the StringBuilder to which the String representation is appended
* @return r, with information appended
*/
static StringBuilder toString(int mod, StringBuilder r)
{
r.append(toString(mod, new StringBuffer()));
return r;
}
/**

View file

@ -63,7 +63,7 @@ package java.lang.reflect;
*
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see GenericTypeDeclaration
* @see GenericDeclaration
* @see TypeVariable
* @since 1.5
*/

View file

@ -0,0 +1,99 @@
/* TypeVariable.java
Copyright (C) 2004 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.reflect;
/**
* <p>
* This is a common interface for all type variables provided by
* the Java language. Instances are created the first time a type
* variable is needed by one of the reflective methods declared in
* this package.
* </p>
* <p>
* Creating a type variable requires resolving the appropriate type.
* This may involve resolving other classes as a side effect (e.g.
* if the type is nested inside other classes). Creation should not
* involve resolving the bounds. Repeated creation has no effect; an
* equivalent instance is returned. Caching is not required, but all
* instances must be <code>equal()</code> to each other.
* </p>
*
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
*/
/* FIXME[GENERICS]: Should be TypeVariable<T extends GenericDeclaration> */
public interface TypeVariable
extends Type
{
/**
* Returns an array of <code>Type</code> objects which represent the upper
* bounds of this type variable. There is always a default bound of
* <code>Object</code>. Any <code>ParameterizedType</code>s will be
* created as necessary, and other types resolved.
*
* @return an array of <code>Type</code> objects representing the upper
* bounds.
* @throws TypeNotPresentException if any of the bounds refer to a
* non-existant type.
* @throws MalformedParameterizedTypeException if the creation of a
* <code>ParameterizedType</code> fails.
*/
Type[] getBounds();
/**
* Returns a representation of the declaration used to declare this
* type variable.
*
* @return the <code>GenericDeclaration</code> object for this type
* variable.
*/
/* FIXME[GENERICS]: Should return type T */
GenericDeclaration getGenericDeclaration();
/**
* Returns the name of the type variable, as written in the source
* code.
*
* @return the name of the type variable.
*/
String getName();
}

View file

@ -1,58 +0,0 @@
# This property file contains dependencies of classes, methods, and
# field on other methods or classes.
#
# Syntax:
#
# <used>: <needed 1> [... <needed N>]
#
# means that when <used> is included, <needed 1> (... <needed N>) must
# be included as well.
#
# <needed X> and <used> are of the form
#
# <class.methodOrField(signature)>
#
# or just
#
# <class>
#
# Within dependencies, variables can be used. A variable is defined as
# follows:
#
# {variable}: value1 value2 ... value<n>
#
# variables can be used on the right side of dependencies as follows:
#
# <used>: com.bla.blu.{variable}.Class.m()V
#
# The use of the variable will expand to <n> dependencies of the form
#
# <used>: com.bla.blu.value1.Class.m()V
# <used>: com.bla.blu.value2.Class.m()V
# ...
# <used>: com.bla.blu.value<n>.Class.m()V
#
# Variables can be redefined when building a system to select the
# required support for features like encodings, protocols, etc.
#
# Hints:
#
# - For methods and fields, the signature is mandatory. For
# specification, please see the Java Virtual Machine Specification by
# SUN. Unlike in the spec, field signatures (types) are in brackets.
#
# - Package names must be separated by '/' (and not '.'). E.g.,
# java/lang/Class (this is necessary, because the '.' is used to
# separate method or field names from classes)
#
# - In case <needed> refers to a class, only the class itself will be
# included in the resulting binary, NOT necessarily all its methods
# and fields. If you want to refer to all methods and fields, you can
# write class.* as an abbreviation.
#
# - Abbreviations for packages are also possible: my/package/* means all
# methods and fields of all classes in my/package.
#
# - A line with a trailing '\' continues in the next line.
# end of file

Some files were not shown because too many files have changed in this diff Show more