From 02440ca432f1aa4de7aeda563d2493a20148554b Mon Sep 17 00:00:00 2001
From: Thomas Fitzsimmons <fitzsim@redhat.com>
Date: Fri, 9 Jun 2006 16:07:07 +0000
Subject: [PATCH] String.java, [...]: Merge from GNU Classpath HEAD.

2006-06-09  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* java/lang/String.java, classpath/native/jni/classpath/jcl.h,
	classpath/native/jni/qt-peer/eventmethods.h,
	classpath/native/jni/qt-peer/qtmenupeer.cpp,
	classpath/native/jni/qt-peer/.cvsignore,
	classpath/native/jni/gtk-peer/gdkdisplay.h,
	classpath/native/jni/gtk-peer/cairographics2d.h,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c,
	classpath/native/jni/gtk-peer/.cvsignore,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c,
	classpath/native/jni/gtk-peer/gtkpeer.h,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c,
	classpath/native/jni/gtk-peer/Makefile.am,
	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,
	classpath/native/jawt/Makefile.am,
	classpath/native/jawt/.cvsignore,
	classpath/native/target/Linux/Makefile.in,
	classpath/native/plugin/gcjwebplugin.cc,
	classpath/native/plugin/Makefile.am,
	classpath/native/plugin/.cvsignore,
	classpath/resource/Makefile.in,
	classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java,
	classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,
	classpath/gnu/java/awt/peer/gtk/CairoSurface.java,
	classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java,
	classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java,
	classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,
	classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,
	classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java,
	classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java,
	classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	classpath/gnu/java/awt/peer/gtk/GdkGraphics.java,
	classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,
	classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java,
	classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java,
	classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java,
	classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java,
	classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java,
	classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java,
	classpath/gnu/java/awt/peer/gtk/GtkImage.java,
	classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java,
	classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java,
	classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java,
	classpath/gnu/java/awt/peer/swing/SwingContainerPeer.java,
	classpath/gnu/java/awt/peer/swing/SwingComponent.java,
	classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java,
	classpath/gnu/java/awt/peer/swing/SwingMenuBarPeer.java,
	classpath/gnu/java/awt/peer/swing/SwingFramePeer.java,
	classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java,
	classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java,
	classpath/gnu/java/awt/print/JavaPrinterJob.java,
	classpath/gnu/java/awt/print/PostScriptGraphics2D.java,
	classpath/gnu/java/awt/print/SpooledDocument.java,
	classpath/gnu/java/awt/print/JavaPrinterGraphics.java,
	classpath/gnu/java/awt/BitwiseXORComposite.java,
	classpath/gnu/java/awt/font/GNUGlyphVector.java,
	classpath/gnu/java/awt/font/opentype/NameDecoder.java,
	classpath/gnu/java/awt/java2d/RasterGraphics.java,
	classpath/gnu/java/awt/java2d/TexturePaintContext.java,
	classpath/gnu/java/awt/java2d/PolyEdge.java,
	classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,
	classpath/gnu/java/awt/java2d/AlphaCompositeContext.java,
	classpath/gnu/java/awt/java2d/ImagePaint.java,
	classpath/gnu/java/awt/Buffers.java,
	classpath/gnu/classpath/Configuration.java.in,
	classpath/gnu/javax/swing/text/html/CombinedAttributes.java,
	classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java,
	classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java,
	classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java,
	classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java,
	classpath/tools/toolwrapper.c,
	classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java,
	classpath/tools/gnu/classpath/tools/native2ascii/Messages.java,
	classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java,
	classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java,
	classpath/tools/gnu/classpath/tools/getopt/OptionException.java,
	classpath/tools/gnu/classpath/tools/getopt/Messages.java,
	classpath/tools/gnu/classpath/tools/getopt/Option.java,
	classpath/tools/gnu/classpath/tools/getopt/Parser.java,
	classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java,
	classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java,
	classpath/tools/gnu/classpath/tools/jarsigner/Main.java,
	classpath/tools/gnu/classpath/tools/jarsigner/Messages.java,
	classpath/tools/gnu/classpath/tools/jarsigner/package.html,
	classpath/tools/gnu/classpath/tools/keytool/ListCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/Messages.java,
	classpath/tools/gnu/classpath/tools/keytool/package.html,
	classpath/tools/gnu/classpath/tools/keytool/Command.java,
	classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/Main.java,
	classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java,
	classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java,
	classpath/tools/gnu/classpath/tools/rmi/registry/package.html,
	classpath/tools/gnu/classpath/tools/rmi/RMIC.txt,
	classpath/tools/gnu/classpath/tools/rmi/RMIC.java,
	classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java,
	classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java,
	classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java,
	classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java,
	classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java,
	classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java,
	classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java,
	classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java,
	classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java,
	classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java,
	classpath/tools/gnu/classpath/tools/appletviewer/Main.java,
	classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java,
	classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java,
	classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java,
	classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java,
	classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java,
	classpath/tools/gnu/classpath/tools/serialver/Messages.java,
	classpath/tools/gnu/classpath/tools/serialver/SerialVer.java,
	classpath/tools/gnu/classpath/tools/jar/Creator.java,
	classpath/tools/gnu/classpath/tools/jar/Entry.java,
	classpath/tools/gnu/classpath/tools/jar/Lister.java,
	classpath/tools/gnu/classpath/tools/jar/Main.java,
	classpath/tools/gnu/classpath/tools/jar/Updater.java,
	classpath/tools/gnu/classpath/tools/jar/Messages.java,
	classpath/tools/gnu/classpath/tools/jar/Extractor.java,
	classpath/tools/gnu/classpath/tools/jar/Action.java,
	classpath/tools/gnu/classpath/tools/jar/Indexer.java,
	classpath/tools/gnu/classpath/tools/jar/WorkSet.java,
	classpath/tools/gnu/classpath/tools/giop/GRMIC.txt,
	classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java,
	classpath/tools/gnu/classpath/tools/giop/GRMIC.java,
	classpath/tools/Makefile.am, classpath/tools/jarsigner.in,
	classpath/tools/keytool.in, classpath/tools/appletviewer.in,
	classpath/tools/.cvsignore, classpath/configure.ac,
	classpath/javax/swing/JTabbedPane.java,
	classpath/javax/swing/AbstractButton.java,
	classpath/javax/swing/JViewport.java,
	classpath/javax/swing/KeyboardManager.java,
	classpath/javax/swing/JMenuItem.java,
	classpath/javax/swing/JMenuBar.java,
	classpath/javax/swing/MenuSelectionManager.java,
	classpath/javax/swing/JOptionPane.java,
	classpath/javax/swing/JSpinner.java,
	classpath/javax/swing/JCheckBoxMenuItem.java,
	classpath/javax/swing/JEditorPane.java,
	classpath/javax/swing/JFormattedTextField.java,
	classpath/javax/swing/JTree.java,
	classpath/javax/swing/CellRendererPane.java,
	classpath/javax/swing/JScrollPane.java,
	classpath/javax/swing/tree/VariableHeightLayoutCache.java,
	classpath/javax/swing/tree/TreeNode.java,
	classpath/javax/swing/tree/FixedHeightLayoutCache.java,
	classpath/javax/swing/tree/DefaultTreeCellEditor.java,
	classpath/javax/swing/tree/TreePath.java,
	classpath/javax/swing/tree/RowMapper.java,
	classpath/javax/swing/tree/DefaultMutableTreeNode.java,
	classpath/javax/swing/tree/DefaultTreeModel.java,
	classpath/javax/swing/tree/AbstractLayoutCache.java,
	classpath/javax/swing/tree/TreeSelectionModel.java,
	classpath/javax/swing/tree/DefaultTreeSelectionModel.java,
	classpath/javax/swing/tree/DefaultTreeCellRenderer.java,
	classpath/javax/swing/tree/ExpandVetoException.java,
	classpath/javax/swing/JList.java,
	classpath/javax/swing/table/JTableHeader.java,
	classpath/javax/swing/table/AbstractTableModel.java,
	classpath/javax/swing/table/DefaultTableModel.java,
	classpath/javax/swing/table/TableCellEditor.java,
	classpath/javax/swing/table/TableCellRenderer.java,
	classpath/javax/swing/ProgressMonitor.java,
	classpath/javax/swing/JToolBar.java,
	classpath/javax/swing/TransferHandler.java,
	classpath/javax/swing/DefaultCellEditor.java,
	classpath/javax/swing/DefaultButtonModel.java,
	classpath/javax/swing/JLayeredPane.java,
	classpath/javax/swing/text/DefaultEditorKit.java,
	classpath/javax/swing/text/DefaultCaret.java,
	classpath/javax/swing/text/FieldView.java,
	classpath/javax/swing/text/JTextComponent.java,
	classpath/javax/swing/text/TextAction.java,
	classpath/javax/swing/text/StyleContext.java,
	classpath/javax/swing/text/html/HTMLDocument.java,
	classpath/javax/swing/text/html/MinimalHTMLWriter.java,
	classpath/javax/swing/text/html/ImageView.java,
	classpath/javax/swing/text/html/HTMLEditorKit.java,
	classpath/javax/swing/text/AbstractWriter.java,
	classpath/javax/swing/text/GapContent.java,
	classpath/javax/swing/text/Utilities.java,
	classpath/javax/swing/text/PlainView.java,
	classpath/javax/swing/UIManager.java,
	classpath/javax/swing/JSplitPane.java,
	classpath/javax/swing/JComponent.java,
	classpath/javax/swing/SwingUtilities.java,
	classpath/javax/swing/border/AbstractBorder.java,
	classpath/javax/swing/border/CompoundBorder.java,
	classpath/javax/swing/border/TitledBorder.java,
	classpath/javax/swing/border/MatteBorder.java,
	classpath/javax/swing/border/BevelBorder.java,
	classpath/javax/swing/RepaintManager.java,
	classpath/javax/swing/JTable.java,
	classpath/javax/swing/UIDefaults.java,
	classpath/javax/swing/DefaultDesktopManager.java,
	classpath/javax/swing/JMenu.java,
	classpath/javax/swing/JLabel.java,
	classpath/javax/swing/JSlider.java,
	classpath/javax/swing/plaf/basic/BasicToolBarUI.java,
	classpath/javax/swing/plaf/basic/BasicButtonUI.java,
	classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java,
	classpath/javax/swing/plaf/basic/BasicTextAreaUI.java,
	classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java,
	classpath/javax/swing/plaf/basic/BasicSpinnerUI.java,
	classpath/javax/swing/plaf/basic/BasicSliderUI.java,
	classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,
	classpath/javax/swing/plaf/basic/BasicComboPopup.java,
	classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java,
	classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java,
	classpath/javax/swing/plaf/basic/BasicProgressBarUI.java,
	classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java,
	classpath/javax/swing/plaf/basic/BasicPanelUI.java,
	classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,
	classpath/javax/swing/plaf/basic/BasicTreeUI.java,
	classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java,
	classpath/javax/swing/plaf/basic/BasicFileChooserUI.java,
	classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java,
	classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,
	classpath/javax/swing/plaf/basic/BasicListUI.java,
	classpath/javax/swing/plaf/basic/BasicIconFactory.java,
	classpath/javax/swing/plaf/basic/BasicTextUI.java,
	classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,
	classpath/javax/swing/plaf/basic/BasicDirectoryModel.java,
	classpath/javax/swing/plaf/basic/BasicRootPaneUI.java,
	classpath/javax/swing/plaf/basic/BasicTableUI.java,
	classpath/javax/swing/plaf/basic/SharedUIDefaults.java,
	classpath/javax/swing/plaf/multi/MultiComboBoxUI.java,
	classpath/javax/swing/plaf/multi/MultiListUI.java,
	classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java,
	classpath/javax/swing/plaf/multi/MultiFileChooserUI.java,
	classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java,
	classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java,
	classpath/javax/swing/plaf/multi/MultiLookAndFeel.java,
	classpath/javax/swing/plaf/metal/MetalSliderUI.java,
	classpath/javax/swing/plaf/metal/MetalIconFactory.java,
	classpath/javax/swing/plaf/metal/MetalComboBoxIcon.java,
	classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java,
	classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,
	classpath/javax/swing/plaf/metal/MetalCheckBoxUI.java,
	classpath/javax/swing/plaf/metal/MetalSeparatorUI.java,
	classpath/javax/swing/plaf/metal/MetalBorders.java,
	classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java,
	classpath/javax/swing/plaf/metal/MetalScrollBarUI.java,
	classpath/javax/swing/plaf/metal/MetalRootPaneUI.java,
	classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java,
	classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java,
	classpath/javax/swing/plaf/metal/MetalToolTipUI.java,
	classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java,
	classpath/javax/swing/plaf/metal/MetalFileChooserUI.java,
	classpath/javax/swing/plaf/metal/MetalUtils.java,
	classpath/javax/swing/plaf/metal/MetalComboBoxButton.java,
	classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java,
	classpath/javax/swing/plaf/metal/MetalButtonUI.java,
	classpath/javax/swing/JPopupMenu.java,
	classpath/javax/swing/JProgressBar.java,
	classpath/javax/swing/WindowConstants.java,
	classpath/javax/swing/JFrame.java,
	classpath/javax/swing/JFileChooser.java,
	classpath/javax/swing/JComboBox.java,
	classpath/javax/swing/event/EventListenerList.java,
	classpath/javax/swing/ListSelectionModel.java,
	classpath/javax/swing/JScrollBar.java,
	classpath/java/text/SimpleDateFormat.java,
	classpath/java/text/NumberFormat.java,
	classpath/java/text/class-dependencies.conf,
	classpath/java/awt/image/ColorModel.java,
	classpath/java/awt/image/BufferedImage.java,
	classpath/java/awt/Window.java,
	classpath/java/awt/ContainerOrderFocusTraversalPolicy.java,
	classpath/java/awt/LightweightDispatcher.java,
	classpath/java/awt/EventDispatchThread.java,
	classpath/java/awt/BasicStroke.java,
	classpath/java/awt/ColorPaintContext.java,
	classpath/java/awt/Container.java,
	classpath/java/awt/TexturePaint.java,
	classpath/java/awt/Component.java, classpath/java/awt/Font.java,
	classpath/java/awt/GraphicsConfiguration.java,
	classpath/java/awt/DefaultKeyboardFocusManager.java,
	classpath/java/awt/print/PrinterJob.java,
	classpath/java/awt/im/InputContext.java,
	classpath/java/awt/dnd/DragGestureRecognizer.java,
	classpath/java/awt/Toolkit.java,
	classpath/java/awt/font/GraphicAttribute.java,
	classpath/java/awt/font/ImageGraphicAttribute.java,
	classpath/java/awt/font/GlyphVector.java,
	classpath/java/awt/font/GlyphMetrics.java,
	classpath/java/awt/font/ShapeGraphicAttribute.java,
	classpath/java/awt/Graphics2D.java,
	classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,
	classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h,
	classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h,
	classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h,
	classpath/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h,
	classpath/include/config.h.in,
	classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h,
	classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h,
	classpath/include/gnu_java_awt_peer_gtk_GdkFontPeer.h,
	classpath/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h,
	classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h,
	classpath/include/gnu_java_awt_peer_gtk_GtkImage.h,
	classpath/include/gnu_java_awt_peer_gtk_CairoSurface.h,
	classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h:
	Merge from GNU Classpath HEAD.

From-SVN: r114510
---
 libjava/ChangeLog                             |  326 +
 libjava/Makefile.in                           |   69 +-
 libjava/classpath/Makefile.in                 |   25 +-
 libjava/classpath/configure                   | 5898 +++++++++--------
 libjava/classpath/configure.ac                |  138 +-
 libjava/classpath/doc/Makefile.in             |   19 +-
 libjava/classpath/doc/api/Makefile.in         |   19 +-
 libjava/classpath/examples/Makefile.in        |   19 +-
 libjava/classpath/external/Makefile.in        |   19 +-
 .../external/relaxngDatatype/Makefile.in      |   19 +-
 libjava/classpath/external/sax/Makefile.in    |   19 +-
 .../classpath/external/w3c_dom/Makefile.in    |   19 +-
 .../gnu/classpath/Configuration.java.in       |    6 -
 .../gnu/java/awt/BitwiseXORComposite.java     |    2 +-
 libjava/classpath/gnu/java/awt/Buffers.java   |   88 +-
 .../gnu/java/awt/font/GNUGlyphVector.java     |    2 +-
 .../java/awt/font/opentype/NameDecoder.java   |   46 +-
 .../java/awt/java2d/AbstractGraphics2D.java   | 1002 ++-
 .../awt/java2d/AlphaCompositeContext.java     |    2 +-
 .../gnu/java/awt/java2d/ImagePaint.java       |  192 +
 .../gnu/java/awt/java2d/PolyEdge.java         |    8 +-
 .../gnu/java/awt/java2d/RasterGraphics.java   |    2 +
 .../java/awt/java2d/TexturePaintContext.java  |  205 +
 .../awt/peer/gtk/BufferedImageGraphics.java   |  258 +
 ...dkGraphics2D.java => CairoGraphics2D.java} | 1933 +++---
 .../gnu/java/awt/peer/gtk/CairoSurface.java   |  288 +
 .../awt/peer/gtk/CairoSurfaceGraphics.java    |  100 +
 .../java/awt/peer/gtk/ComponentGraphics.java  |  243 +
 .../awt/peer/gtk/ComponentGraphicsCopy.java   |  129 +
 .../awt/peer/gtk/FreetypeGlyphVector.java     |  392 ++
 .../gnu/java/awt/peer/gtk/GdkFontPeer.java    |  108 +-
 .../gnu/java/awt/peer/gtk/GdkGlyphVector.java |  359 -
 .../gnu/java/awt/peer/gtk/GdkGraphics.java    |  494 --
 .../peer/gtk/GdkGraphicsConfiguration.java    |   40 +-
 .../awt/peer/gtk/GdkGraphicsEnvironment.java  |   80 +-
 .../java/awt/peer/gtk/GdkPixbufDecoder.java   |   71 +-
 .../awt/peer/gtk/GdkScreenGraphicsDevice.java |  282 +-
 .../gnu/java/awt/peer/gtk/GdkTextLayout.java  |   72 +-
 .../gnu/java/awt/peer/gtk/GtkCanvasPeer.java  |    1 -
 .../java/awt/peer/gtk/GtkComponentPeer.java   |   32 +-
 .../gnu/java/awt/peer/gtk/GtkImage.java       |  273 +-
 .../gnu/java/awt/peer/gtk/GtkToolkit.java     |   64 +-
 .../java/awt/peer/gtk/GtkVolatileImage.java   |   81 +-
 .../awt/peer/gtk/VolatileImageGraphics.java   |  122 +
 .../java/awt/peer/swing/SwingComponent.java   |    6 +-
 .../awt/peer/swing/SwingComponentPeer.java    |   43 +-
 .../awt/peer/swing/SwingContainerPeer.java    |    9 +-
 .../java/awt/peer/swing/SwingFramePeer.java   |    6 +-
 .../java/awt/peer/swing/SwingMenuBarPeer.java |    2 +-
 .../awt/peer/swing/SwingTextFieldPeer.java    |    2 +-
 .../java/awt/peer/swing/SwingWindowPeer.java  |    6 +-
 .../java/awt/print/JavaPrinterGraphics.java   |  518 ++
 .../gnu/java/awt/print/JavaPrinterJob.java    |  403 ++
 .../java/awt/print/PostScriptGraphics2D.java  | 1349 ++++
 .../gnu/java/awt/print/SpooledDocument.java   |   91 +
 .../html/CharacterAttributeTranslator.java    |  192 +
 .../swing/text/html/CombinedAttributes.java   |  213 +
 .../swing/text/html/ImageViewIconFactory.java |  282 +
 .../html/parser/SmallHtmlAttributeSet.java    |  263 +
 .../text/html/parser/htmlAttributeSet.java    |   98 +-
 libjava/classpath/include/Makefile.in         |   19 +-
 libjava/classpath/include/config.h.in         |   18 +-
 .../gnu_java_awt_peer_gtk_CairoGraphics2D.h   |   45 +
 .../gnu_java_awt_peer_gtk_CairoSurface.h      |   28 +
 .../gnu_java_awt_peer_gtk_ComponentGraphics.h |   26 +
 ..._java_awt_peer_gtk_ComponentGraphicsCopy.h |   20 +
 ...nu_java_awt_peer_gtk_FreetypeGlyphVector.h |   22 +
 .../gnu_java_awt_peer_gtk_GdkFontPeer.h       |    5 +-
 ...java_awt_peer_gtk_GdkGraphicsEnvironment.h |    4 +
 ...ava_awt_peer_gtk_GdkScreenGraphicsDevice.h |   26 +
 .../gnu_java_awt_peer_gtk_GdkTextLayout.h     |    2 +
 .../gnu_java_awt_peer_gtk_GtkCanvasPeer.h     |    1 -
 .../gnu_java_awt_peer_gtk_GtkComponentPeer.h  |    2 +-
 .../include/gnu_java_awt_peer_gtk_GtkImage.h  |    9 +-
 .../gnu_java_awt_peer_gtk_GtkVolatileImage.h  |   23 +
 libjava/classpath/java/awt/BasicStroke.java   |    2 +-
 .../classpath/java/awt/ColorPaintContext.java |   12 +-
 libjava/classpath/java/awt/Component.java     |   55 +-
 libjava/classpath/java/awt/Container.java     |   40 +-
 .../ContainerOrderFocusTraversalPolicy.java   |  173 +-
 .../java/awt/DefaultKeyboardFocusManager.java |   10 +-
 .../java/awt/EventDispatchThread.java         |   22 +-
 libjava/classpath/java/awt/Font.java          |    2 +-
 libjava/classpath/java/awt/Graphics2D.java    |  222 +-
 .../java/awt/GraphicsConfiguration.java       |   21 +-
 .../java/awt/LightweightDispatcher.java       |  165 +-
 libjava/classpath/java/awt/TexturePaint.java  |   55 +-
 libjava/classpath/java/awt/Toolkit.java       |    2 +-
 libjava/classpath/java/awt/Window.java        |   96 +-
 .../java/awt/dnd/DragGestureRecognizer.java   |   13 +-
 .../classpath/java/awt/font/GlyphMetrics.java |   16 +-
 .../classpath/java/awt/font/GlyphVector.java  |   61 +-
 .../java/awt/font/GraphicAttribute.java       |   91 +-
 .../java/awt/font/ImageGraphicAttribute.java  |  140 +-
 .../java/awt/font/ShapeGraphicAttribute.java  |  128 +-
 .../classpath/java/awt/im/InputContext.java   |    4 +-
 .../java/awt/image/BufferedImage.java         |    2 +-
 .../classpath/java/awt/image/ColorModel.java  |   61 +-
 .../classpath/java/awt/print/PrinterJob.java  |   29 +-
 libjava/classpath/java/text/NumberFormat.java |    2 +-
 .../classpath/java/text/SimpleDateFormat.java |    2 +-
 .../java/text/class-dependencies.conf         |  220 +
 .../classpath/javax/swing/AbstractButton.java |   10 +-
 .../javax/swing/CellRendererPane.java         |    2 +-
 .../javax/swing/DefaultButtonModel.java       |   18 +-
 .../javax/swing/DefaultCellEditor.java        |   19 +-
 .../javax/swing/DefaultDesktopManager.java    |   11 +-
 .../javax/swing/JCheckBoxMenuItem.java        |   37 +-
 libjava/classpath/javax/swing/JComboBox.java  |  213 +-
 libjava/classpath/javax/swing/JComponent.java |   73 +-
 .../classpath/javax/swing/JEditorPane.java    |    8 +-
 .../classpath/javax/swing/JFileChooser.java   |  100 +-
 .../javax/swing/JFormattedTextField.java      |   74 +-
 libjava/classpath/javax/swing/JFrame.java     |   86 +-
 libjava/classpath/javax/swing/JLabel.java     |   85 +-
 .../classpath/javax/swing/JLayeredPane.java   |   14 +-
 libjava/classpath/javax/swing/JList.java      |   13 +-
 libjava/classpath/javax/swing/JMenu.java      |  273 +-
 libjava/classpath/javax/swing/JMenuBar.java   |   27 +-
 libjava/classpath/javax/swing/JMenuItem.java  |  109 +-
 .../classpath/javax/swing/JOptionPane.java    |  112 +-
 libjava/classpath/javax/swing/JPopupMenu.java |   31 +
 .../classpath/javax/swing/JProgressBar.java   |  462 +-
 libjava/classpath/javax/swing/JScrollBar.java |   18 +-
 .../classpath/javax/swing/JScrollPane.java    |    8 +-
 libjava/classpath/javax/swing/JSlider.java    |    6 +-
 libjava/classpath/javax/swing/JSpinner.java   |    2 +-
 libjava/classpath/javax/swing/JSplitPane.java |    9 +-
 .../classpath/javax/swing/JTabbedPane.java    |  176 +-
 libjava/classpath/javax/swing/JTable.java     | 1482 ++++-
 libjava/classpath/javax/swing/JToolBar.java   |   24 +-
 libjava/classpath/javax/swing/JTree.java      |   40 +-
 libjava/classpath/javax/swing/JViewport.java  |    2 +-
 .../javax/swing/KeyboardManager.java          |    3 +-
 .../javax/swing/ListSelectionModel.java       |  264 +-
 .../javax/swing/MenuSelectionManager.java     |    3 +
 .../javax/swing/ProgressMonitor.java          |   21 +-
 .../classpath/javax/swing/RepaintManager.java |  145 +-
 .../classpath/javax/swing/SwingUtilities.java |  153 +
 .../javax/swing/TransferHandler.java          |   24 +-
 libjava/classpath/javax/swing/UIDefaults.java |   26 +-
 libjava/classpath/javax/swing/UIManager.java  |   27 +-
 .../javax/swing/WindowConstants.java          |   29 +-
 .../javax/swing/border/AbstractBorder.java    |    2 +-
 .../javax/swing/border/BevelBorder.java       |    2 +-
 .../javax/swing/border/CompoundBorder.java    |    6 +-
 .../javax/swing/border/MatteBorder.java       |    9 +-
 .../javax/swing/border/TitledBorder.java      |  729 +-
 .../javax/swing/event/EventListenerList.java  |   10 +-
 .../javax/swing/plaf/basic/BasicButtonUI.java |    9 +-
 .../swing/plaf/basic/BasicCheckBoxUI.java     |   25 +-
 .../swing/plaf/basic/BasicComboBoxUI.java     |  126 +-
 .../swing/plaf/basic/BasicComboPopup.java     |   10 +-
 .../swing/plaf/basic/BasicDirectoryModel.java |   14 +-
 .../swing/plaf/basic/BasicFileChooserUI.java  |    4 +-
 .../swing/plaf/basic/BasicIconFactory.java    |   10 +-
 .../plaf/basic/BasicInternalFrameUI.java      |  216 +-
 .../javax/swing/plaf/basic/BasicListUI.java   |   55 +-
 .../swing/plaf/basic/BasicLookAndFeel.java    |    8 +-
 .../swing/plaf/basic/BasicOptionPaneUI.java   |    2 +-
 .../javax/swing/plaf/basic/BasicPanelUI.java  |   64 +-
 .../swing/plaf/basic/BasicProgressBarUI.java  |   31 +-
 .../swing/plaf/basic/BasicRadioButtonUI.java  |    8 +-
 .../swing/plaf/basic/BasicRootPaneUI.java     |    5 +-
 .../swing/plaf/basic/BasicScrollPaneUI.java   |  256 +-
 .../javax/swing/plaf/basic/BasicSliderUI.java |   65 +-
 .../swing/plaf/basic/BasicSpinnerUI.java      |    4 +-
 .../swing/plaf/basic/BasicSplitPaneUI.java    |  150 +-
 .../swing/plaf/basic/BasicTabbedPaneUI.java   |   23 +-
 .../swing/plaf/basic/BasicTableHeaderUI.java  |   26 +-
 .../javax/swing/plaf/basic/BasicTableUI.java  |   67 +-
 .../swing/plaf/basic/BasicTextAreaUI.java     |    4 +-
 .../javax/swing/plaf/basic/BasicTextUI.java   |  100 +-
 .../swing/plaf/basic/BasicToggleButtonUI.java |   37 +-
 .../swing/plaf/basic/BasicToolBarUI.java      |   68 +-
 .../javax/swing/plaf/basic/BasicTreeUI.java   |  800 ++-
 .../swing/plaf/basic/SharedUIDefaults.java    |   78 +
 .../javax/swing/plaf/metal/MetalBorders.java  |  100 +-
 .../javax/swing/plaf/metal/MetalButtonUI.java |   67 +-
 .../swing/plaf/metal/MetalCheckBoxUI.java     |    2 +-
 .../swing/plaf/metal/MetalComboBoxButton.java |    5 +-
 .../swing/plaf/metal/MetalComboBoxIcon.java   |    3 +-
 .../swing/plaf/metal/MetalFileChooserUI.java  |   68 +-
 .../swing/plaf/metal/MetalIconFactory.java    |    3 +-
 .../metal/MetalInternalFrameTitlePane.java    |    9 +-
 .../plaf/metal/MetalInternalFrameUI.java      |   18 +
 .../swing/plaf/metal/MetalLookAndFeel.java    |   12 +-
 .../plaf/metal/MetalPopupMenuSeparatorUI.java |    2 +-
 .../swing/plaf/metal/MetalRadioButtonUI.java  |    9 +-
 .../swing/plaf/metal/MetalRootPaneUI.java     |    2 +-
 .../swing/plaf/metal/MetalScrollBarUI.java    |   16 +-
 .../swing/plaf/metal/MetalSeparatorUI.java    |    2 +-
 .../javax/swing/plaf/metal/MetalSliderUI.java |   34 +-
 .../plaf/metal/MetalSplitPaneDivider.java     |   19 +-
 .../swing/plaf/metal/MetalTabbedPaneUI.java   |    6 +-
 .../swing/plaf/metal/MetalToolTipUI.java      |    6 +-
 .../javax/swing/plaf/metal/MetalUtils.java    |    2 +-
 .../swing/plaf/multi/MultiComboBoxUI.java     |    9 +-
 .../swing/plaf/multi/MultiFileChooserUI.java  |   18 +-
 .../javax/swing/plaf/multi/MultiListUI.java   |    9 +-
 .../swing/plaf/multi/MultiLookAndFeel.java    |    3 +-
 .../swing/plaf/multi/MultiOptionPaneUI.java   |    6 +-
 .../swing/plaf/multi/MultiSplitPaneUI.java    |   18 +-
 .../swing/plaf/multi/MultiTabbedPaneUI.java   |    9 +-
 .../javax/swing/table/AbstractTableModel.java |   12 +-
 .../javax/swing/table/DefaultTableModel.java  |   61 +-
 .../javax/swing/table/JTableHeader.java       |  423 +-
 .../javax/swing/table/TableCellEditor.java    |   28 +-
 .../javax/swing/table/TableCellRenderer.java  |   30 +-
 .../javax/swing/text/AbstractWriter.java      |    3 +-
 .../javax/swing/text/DefaultCaret.java        |   64 +-
 .../javax/swing/text/DefaultEditorKit.java    |  551 +-
 .../classpath/javax/swing/text/FieldView.java |   24 +-
 .../javax/swing/text/GapContent.java          |  469 +-
 .../javax/swing/text/JTextComponent.java      |   31 +-
 .../classpath/javax/swing/text/PlainView.java |  233 +-
 .../javax/swing/text/StyleContext.java        |  119 +-
 .../javax/swing/text/TextAction.java          |  104 +
 .../classpath/javax/swing/text/Utilities.java |   66 +-
 .../javax/swing/text/html/HTMLDocument.java   |  154 +-
 .../javax/swing/text/html/HTMLEditorKit.java  |    5 +-
 .../javax/swing/text/html/ImageView.java      |  441 ++
 .../swing/text/html/MinimalHTMLWriter.java    |  452 ++
 .../javax/swing/tree/AbstractLayoutCache.java |    7 +-
 .../swing/tree/DefaultMutableTreeNode.java    |   15 +-
 .../swing/tree/DefaultTreeCellEditor.java     |    1 -
 .../swing/tree/DefaultTreeCellRenderer.java   |  442 +-
 .../javax/swing/tree/DefaultTreeModel.java    |    6 +-
 .../swing/tree/DefaultTreeSelectionModel.java |   18 +-
 .../javax/swing/tree/ExpandVetoException.java |   71 +-
 .../swing/tree/FixedHeightLayoutCache.java    |    6 +-
 .../classpath/javax/swing/tree/RowMapper.java |   20 +-
 .../classpath/javax/swing/tree/TreeNode.java  |    3 +-
 .../classpath/javax/swing/tree/TreePath.java  |   16 +-
 .../javax/swing/tree/TreeSelectionModel.java  |  102 +-
 .../swing/tree/VariableHeightLayoutCache.java |   22 +-
 libjava/classpath/lib/Makefile.in             |   19 +-
 libjava/classpath/native/Makefile.in          |   19 +-
 libjava/classpath/native/fdlibm/Makefile.in   |   19 +-
 libjava/classpath/native/jawt/.cvsignore      |    8 +
 libjava/classpath/native/jawt/Makefile.am     |   14 +-
 libjava/classpath/native/jawt/Makefile.in     |   91 +-
 libjava/classpath/native/jni/Makefile.in      |   19 +-
 .../native/jni/classpath/Makefile.in          |   19 +-
 libjava/classpath/native/jni/classpath/jcl.h  |    6 +-
 .../classpath/native/jni/gtk-peer/.cvsignore  |    8 +
 .../classpath/native/jni/gtk-peer/Makefile.am |   27 +-
 .../classpath/native/jni/gtk-peer/Makefile.in |  105 +-
 .../native/jni/gtk-peer/cairographics2d.h     |  119 +
 .../native/jni/gtk-peer/gdkdisplay.h          |   67 +
 .../gnu_java_awt_peer_gtk_CairoGraphics2D.c   |  703 ++
 .../gnu_java_awt_peer_gtk_CairoSurface.c      |  312 +
 .../gnu_java_awt_peer_gtk_ComponentGraphics.c |  307 +
 ..._java_awt_peer_gtk_ComponentGraphicsCopy.c |  132 +
 ...nu_java_awt_peer_gtk_FreetypeGlyphVector.c |  335 +
 .../gnu_java_awt_peer_gtk_GdkFontPeer.c       |  221 +-
 ...java_awt_peer_gtk_GdkGraphicsEnvironment.c |  142 +-
 ...ava_awt_peer_gtk_GdkScreenGraphicsDevice.c |  354 +
 .../gnu_java_awt_peer_gtk_GdkTextLayout.c     |  154 +-
 .../gnu_java_awt_peer_gtk_GtkCanvasPeer.c     |   14 -
 .../gnu_java_awt_peer_gtk_GtkClipboard.c      |    9 +-
 .../gnu_java_awt_peer_gtk_GtkComponentPeer.c  |   49 +-
 .../gnu_java_awt_peer_gtk_GtkFramePeer.c      |    5 -
 .../gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c |  352 +-
 .../gnu_java_awt_peer_gtk_GtkToolkit.c        |    4 -
 .../gnu_java_awt_peer_gtk_GtkVolatileImage.c  |  216 +
 .../classpath/native/jni/gtk-peer/gtkpeer.h   |   44 +-
 .../classpath/native/jni/java-io/Makefile.in  |   19 +-
 .../native/jni/java-lang/Makefile.in          |   19 +-
 .../classpath/native/jni/java-net/Makefile.in |   19 +-
 .../classpath/native/jni/java-nio/Makefile.in |   19 +-
 .../native/jni/java-util/Makefile.in          |   19 +-
 .../native/jni/midi-alsa/Makefile.in          |   19 +-
 .../native/jni/midi-dssi/Makefile.in          |   19 +-
 .../classpath/native/jni/qt-peer/.cvsignore   |    9 +
 .../classpath/native/jni/qt-peer/Makefile.in  |   19 +-
 .../native/jni/qt-peer/eventmethods.h         |    6 +-
 .../native/jni/qt-peer/qtmenupeer.cpp         |   47 +-
 libjava/classpath/native/jni/xmlj/Makefile.in |   19 +-
 libjava/classpath/native/plugin/.cvsignore    |    6 +
 libjava/classpath/native/plugin/Makefile.am   |   19 +
 libjava/classpath/native/plugin/Makefile.in   |  596 ++
 .../classpath/native/plugin/gcjwebplugin.cc   | 1759 +++++
 .../classpath/native/target/Linux/Makefile.in |   19 +-
 libjava/classpath/native/target/Makefile.in   |   19 +-
 .../native/target/generic/Makefile.in         |   19 +-
 libjava/classpath/resource/Makefile.in        |   19 +-
 libjava/classpath/scripts/Makefile.in         |   19 +-
 libjava/classpath/tools/.cvsignore            |    6 +
 libjava/classpath/tools/Makefile.am           |   54 +-
 libjava/classpath/tools/Makefile.in           |  351 +-
 libjava/classpath/tools/appletviewer.in       |   46 +
 .../tools/appletviewer/AppletClassLoader.java |   81 +
 .../appletviewer/AppletSecurityManager.java   |   95 +
 .../tools/appletviewer/AppletTag.java         |  489 ++
 .../tools/appletviewer/AppletWarning.java     |   66 +
 .../appletviewer/CommonAppletContext.java     |  133 +
 .../tools/appletviewer/CommonAppletStub.java  |  138 +
 .../tools/appletviewer/ConsoleDialog.java     |  175 +
 .../tools/appletviewer/ErrorApplet.java       |   53 +
 .../classpath/tools/appletviewer/Main.java    |  293 +
 .../appletviewer/PluginAppletContext.java     |   72 +
 .../appletviewer/PluginAppletViewer.java      |  172 +
 .../appletviewer/PluginAppletWindow.java      |  454 ++
 .../appletviewer/StandaloneAppletContext.java |   75 +
 .../appletviewer/StandaloneAppletViewer.java  |  144 +
 .../appletviewer/StandaloneAppletWindow.java  |  559 ++
 .../tools/appletviewer/TagParser.java         |  302 +
 .../tools/getopt/ClasspathToolParser.java     |   73 +
 .../tools/getopt/FileArgumentCallback.java    |   62 +
 .../gnu/classpath/tools/getopt/Messages.java  |   67 +
 .../gnu/classpath/tools/getopt/Option.java    |  200 +
 .../tools/getopt/OptionException.java         |   52 +
 .../classpath/tools/getopt/OptionGroup.java   |  271 +
 .../gnu/classpath/tools/getopt/Parser.java    |  454 ++
 .../tools/gnu/classpath/tools/giop/GRMIC.java |   23 +-
 .../tools/gnu/classpath/tools/giop/GRMIC.txt  |   24 +-
 .../tools/giop/grmic/GiopRmicCompiler.java    |   94 +-
 .../tools/gnu/classpath/tools/jar/Action.java |   51 +
 .../gnu/classpath/tools/jar/Creator.java      |  247 +
 .../tools/gnu/classpath/tools/jar/Entry.java  |   60 +
 .../gnu/classpath/tools/jar/Extractor.java    |  127 +
 .../gnu/classpath/tools/jar/Indexer.java      |  144 +
 .../tools/gnu/classpath/tools/jar/Lister.java |  112 +
 .../tools/gnu/classpath/tools/jar/Main.java   |  266 +
 .../gnu/classpath/tools/jar/Messages.java     |   67 +
 .../gnu/classpath/tools/jar/Updater.java      |   91 +
 .../gnu/classpath/tools/jar/WorkSet.java      |   86 +
 .../classpath/tools/jarsigner/JarSigner.java  |    2 +-
 .../gnu/classpath/tools/jarsigner/Main.java   |  269 +-
 .../classpath/tools/jarsigner/Messages.java   |    4 +-
 .../classpath/tools/jarsigner/package.html    |   60 +
 .../classpath/tools/keytool/CertReqCmd.java   |  169 +-
 .../gnu/classpath/tools/keytool/Command.java  |   63 +-
 .../classpath/tools/keytool/DeleteCmd.java    |  116 +-
 .../classpath/tools/keytool/ExportCmd.java    |  170 +-
 .../classpath/tools/keytool/GenKeyCmd.java    |  199 +-
 .../tools/keytool/IdentityDBCmd.java          |  128 +-
 .../classpath/tools/keytool/ImportCmd.java    |  333 +-
 .../classpath/tools/keytool/KeyCloneCmd.java  |  162 +-
 .../classpath/tools/keytool/KeyPasswdCmd.java |  143 +-
 .../gnu/classpath/tools/keytool/ListCmd.java  |  132 +-
 .../gnu/classpath/tools/keytool/Main.java     |  231 +-
 .../gnu/classpath/tools/keytool/Messages.java |    4 +-
 .../classpath/tools/keytool/PrintCertCmd.java |   73 +-
 .../classpath/tools/keytool/SelfCertCmd.java  |  196 +-
 .../tools/keytool/StorePasswdCmd.java         |  116 +-
 .../gnu/classpath/tools/keytool/package.html  |   65 +
 .../tools/native2ascii/Messages.java          |   67 +
 .../tools/native2ascii/Native2ASCII.java      |  185 +
 .../tools/gnu/classpath/tools/rmi/RMIC.java   |   25 +-
 .../tools/gnu/classpath/tools/rmi/RMIC.txt    |   36 +-
 .../classpath/tools/rmi/registry/package.html |   46 +
 .../classpath/tools/serialver/Messages.java   |   68 +
 .../classpath/tools/serialver/SerialVer.java  |  163 +
 libjava/classpath/tools/jarsigner.in          |   47 +
 libjava/classpath/tools/keytool.in            |   47 +
 libjava/classpath/tools/toolwrapper.c         |  220 +
 libjava/java/lang/String.java                 |    2 +-
 libjava/sources.am                            |   64 +-
 360 files changed, 36302 insertions(+), 10896 deletions(-)
 create mode 100644 libjava/classpath/gnu/java/awt/java2d/ImagePaint.java
 create mode 100644 libjava/classpath/gnu/java/awt/java2d/TexturePaintContext.java
 create mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
 rename libjava/classpath/gnu/java/awt/peer/gtk/{GdkGraphics2D.java => CairoGraphics2D.java} (57%)
 create mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java
 create mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
 create mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java
 create mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
 create mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
 delete mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java
 delete mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java
 create mode 100644 libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
 create mode 100644 libjava/classpath/gnu/java/awt/print/JavaPrinterGraphics.java
 create mode 100644 libjava/classpath/gnu/java/awt/print/JavaPrinterJob.java
 create mode 100644 libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java
 create mode 100644 libjava/classpath/gnu/java/awt/print/SpooledDocument.java
 create mode 100644 libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java
 create mode 100644 libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java
 create mode 100644 libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java
 create mode 100644 libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
 create mode 100644 libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
 create mode 100644 libjava/classpath/include/gnu_java_awt_peer_gtk_CairoSurface.h
 create mode 100644 libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
 create mode 100644 libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h
 create mode 100644 libjava/classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
 create mode 100644 libjava/classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h
 create mode 100644 libjava/classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
 create mode 100644 libjava/classpath/java/text/class-dependencies.conf
 create mode 100644 libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java
 create mode 100644 libjava/classpath/javax/swing/text/html/ImageView.java
 create mode 100644 libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java
 create mode 100644 libjava/classpath/native/jawt/.cvsignore
 create mode 100644 libjava/classpath/native/jni/gtk-peer/.cvsignore
 create mode 100644 libjava/classpath/native/jni/gtk-peer/cairographics2d.h
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gdkdisplay.h
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c
 create mode 100644 libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
 create mode 100644 libjava/classpath/native/jni/qt-peer/.cvsignore
 create mode 100644 libjava/classpath/native/plugin/.cvsignore
 create mode 100644 libjava/classpath/native/plugin/Makefile.am
 create mode 100644 libjava/classpath/native/plugin/Makefile.in
 create mode 100644 libjava/classpath/native/plugin/gcjwebplugin.cc
 create mode 100644 libjava/classpath/tools/.cvsignore
 create mode 100644 libjava/classpath/tools/appletviewer.in
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Action.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Main.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/keytool/package.html
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java
 create mode 100644 libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java
 create mode 100644 libjava/classpath/tools/jarsigner.in
 create mode 100644 libjava/classpath/tools/keytool.in
 create mode 100644 libjava/classpath/tools/toolwrapper.c

diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index b08cf7835889..e9fd6467220e 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,329 @@
+2006-06-09  Thomas Fitzsimmons  <fitzsim@redhat.com>
+
+	* java/lang/String.java, classpath/native/jni/classpath/jcl.h,
+	classpath/native/jni/qt-peer/eventmethods.h,
+	classpath/native/jni/qt-peer/qtmenupeer.cpp,
+	classpath/native/jni/qt-peer/.cvsignore,
+	classpath/native/jni/gtk-peer/gdkdisplay.h,
+	classpath/native/jni/gtk-peer/cairographics2d.h,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c,
+	classpath/native/jni/gtk-peer/.cvsignore,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c,
+	classpath/native/jni/gtk-peer/gtkpeer.h,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c,
+	classpath/native/jni/gtk-peer/Makefile.am,
+	classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,
+	classpath/native/jawt/Makefile.am,
+	classpath/native/jawt/.cvsignore,
+	classpath/native/target/Linux/Makefile.in,
+	classpath/native/plugin/gcjwebplugin.cc,
+	classpath/native/plugin/Makefile.am,
+	classpath/native/plugin/.cvsignore,
+	classpath/resource/Makefile.in,
+	classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java,
+	classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,
+	classpath/gnu/java/awt/peer/gtk/CairoSurface.java,
+	classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java,
+	classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java,
+	classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,
+	classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,
+	classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java,
+	classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java,
+	classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,
+	classpath/gnu/java/awt/peer/gtk/GdkGraphics.java,
+	classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,
+	classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java,
+	classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java,
+	classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java,
+	classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java,
+	classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java,
+	classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java,
+	classpath/gnu/java/awt/peer/gtk/GtkImage.java,
+	classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java,
+	classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java,
+	classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java,
+	classpath/gnu/java/awt/peer/swing/SwingContainerPeer.java,
+	classpath/gnu/java/awt/peer/swing/SwingComponent.java,
+	classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java,
+	classpath/gnu/java/awt/peer/swing/SwingMenuBarPeer.java,
+	classpath/gnu/java/awt/peer/swing/SwingFramePeer.java,
+	classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java,
+	classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java,
+	classpath/gnu/java/awt/print/JavaPrinterJob.java,
+	classpath/gnu/java/awt/print/PostScriptGraphics2D.java,
+	classpath/gnu/java/awt/print/SpooledDocument.java,
+	classpath/gnu/java/awt/print/JavaPrinterGraphics.java,
+	classpath/gnu/java/awt/BitwiseXORComposite.java,
+	classpath/gnu/java/awt/font/GNUGlyphVector.java,
+	classpath/gnu/java/awt/font/opentype/NameDecoder.java,
+	classpath/gnu/java/awt/java2d/RasterGraphics.java,
+	classpath/gnu/java/awt/java2d/TexturePaintContext.java,
+	classpath/gnu/java/awt/java2d/PolyEdge.java,
+	classpath/gnu/java/awt/java2d/AbstractGraphics2D.java,
+	classpath/gnu/java/awt/java2d/AlphaCompositeContext.java,
+	classpath/gnu/java/awt/java2d/ImagePaint.java,
+	classpath/gnu/java/awt/Buffers.java,
+	classpath/gnu/classpath/Configuration.java.in,
+	classpath/gnu/javax/swing/text/html/CombinedAttributes.java,
+	classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java,
+	classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java,
+	classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java,
+	classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java,
+	classpath/tools/toolwrapper.c,
+	classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java,
+	classpath/tools/gnu/classpath/tools/native2ascii/Messages.java,
+	classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java,
+	classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java,
+	classpath/tools/gnu/classpath/tools/getopt/OptionException.java,
+	classpath/tools/gnu/classpath/tools/getopt/Messages.java,
+	classpath/tools/gnu/classpath/tools/getopt/Option.java,
+	classpath/tools/gnu/classpath/tools/getopt/Parser.java,
+	classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java,
+	classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java,
+	classpath/tools/gnu/classpath/tools/jarsigner/Main.java,
+	classpath/tools/gnu/classpath/tools/jarsigner/Messages.java,
+	classpath/tools/gnu/classpath/tools/jarsigner/package.html,
+	classpath/tools/gnu/classpath/tools/keytool/ListCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/Messages.java,
+	classpath/tools/gnu/classpath/tools/keytool/package.html,
+	classpath/tools/gnu/classpath/tools/keytool/Command.java,
+	classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/Main.java,
+	classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java,
+	classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java,
+	classpath/tools/gnu/classpath/tools/rmi/registry/package.html,
+	classpath/tools/gnu/classpath/tools/rmi/RMIC.txt,
+	classpath/tools/gnu/classpath/tools/rmi/RMIC.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/Main.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java,
+	classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java,
+	classpath/tools/gnu/classpath/tools/serialver/Messages.java,
+	classpath/tools/gnu/classpath/tools/serialver/SerialVer.java,
+	classpath/tools/gnu/classpath/tools/jar/Creator.java,
+	classpath/tools/gnu/classpath/tools/jar/Entry.java,
+	classpath/tools/gnu/classpath/tools/jar/Lister.java,
+	classpath/tools/gnu/classpath/tools/jar/Main.java,
+	classpath/tools/gnu/classpath/tools/jar/Updater.java,
+	classpath/tools/gnu/classpath/tools/jar/Messages.java,
+	classpath/tools/gnu/classpath/tools/jar/Extractor.java,
+	classpath/tools/gnu/classpath/tools/jar/Action.java,
+	classpath/tools/gnu/classpath/tools/jar/Indexer.java,
+	classpath/tools/gnu/classpath/tools/jar/WorkSet.java,
+	classpath/tools/gnu/classpath/tools/giop/GRMIC.txt,
+	classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java,
+	classpath/tools/gnu/classpath/tools/giop/GRMIC.java,
+	classpath/tools/Makefile.am, classpath/tools/jarsigner.in,
+	classpath/tools/keytool.in, classpath/tools/appletviewer.in,
+	classpath/tools/.cvsignore, classpath/configure.ac,
+	classpath/javax/swing/JTabbedPane.java,
+	classpath/javax/swing/AbstractButton.java,
+	classpath/javax/swing/JViewport.java,
+	classpath/javax/swing/KeyboardManager.java,
+	classpath/javax/swing/JMenuItem.java,
+	classpath/javax/swing/JMenuBar.java,
+	classpath/javax/swing/MenuSelectionManager.java,
+	classpath/javax/swing/JOptionPane.java,
+	classpath/javax/swing/JSpinner.java,
+	classpath/javax/swing/JCheckBoxMenuItem.java,
+	classpath/javax/swing/JEditorPane.java,
+	classpath/javax/swing/JFormattedTextField.java,
+	classpath/javax/swing/JTree.java,
+	classpath/javax/swing/CellRendererPane.java,
+	classpath/javax/swing/JScrollPane.java,
+	classpath/javax/swing/tree/VariableHeightLayoutCache.java,
+	classpath/javax/swing/tree/TreeNode.java,
+	classpath/javax/swing/tree/FixedHeightLayoutCache.java,
+	classpath/javax/swing/tree/DefaultTreeCellEditor.java,
+	classpath/javax/swing/tree/TreePath.java,
+	classpath/javax/swing/tree/RowMapper.java,
+	classpath/javax/swing/tree/DefaultMutableTreeNode.java,
+	classpath/javax/swing/tree/DefaultTreeModel.java,
+	classpath/javax/swing/tree/AbstractLayoutCache.java,
+	classpath/javax/swing/tree/TreeSelectionModel.java,
+	classpath/javax/swing/tree/DefaultTreeSelectionModel.java,
+	classpath/javax/swing/tree/DefaultTreeCellRenderer.java,
+	classpath/javax/swing/tree/ExpandVetoException.java,
+	classpath/javax/swing/JList.java,
+	classpath/javax/swing/table/JTableHeader.java,
+	classpath/javax/swing/table/AbstractTableModel.java,
+	classpath/javax/swing/table/DefaultTableModel.java,
+	classpath/javax/swing/table/TableCellEditor.java,
+	classpath/javax/swing/table/TableCellRenderer.java,
+	classpath/javax/swing/ProgressMonitor.java,
+	classpath/javax/swing/JToolBar.java,
+	classpath/javax/swing/TransferHandler.java,
+	classpath/javax/swing/DefaultCellEditor.java,
+	classpath/javax/swing/DefaultButtonModel.java,
+	classpath/javax/swing/JLayeredPane.java,
+	classpath/javax/swing/text/DefaultEditorKit.java,
+	classpath/javax/swing/text/DefaultCaret.java,
+	classpath/javax/swing/text/FieldView.java,
+	classpath/javax/swing/text/JTextComponent.java,
+	classpath/javax/swing/text/TextAction.java,
+	classpath/javax/swing/text/StyleContext.java,
+	classpath/javax/swing/text/html/HTMLDocument.java,
+	classpath/javax/swing/text/html/MinimalHTMLWriter.java,
+	classpath/javax/swing/text/html/ImageView.java,
+	classpath/javax/swing/text/html/HTMLEditorKit.java,
+	classpath/javax/swing/text/AbstractWriter.java,
+	classpath/javax/swing/text/GapContent.java,
+	classpath/javax/swing/text/Utilities.java,
+	classpath/javax/swing/text/PlainView.java,
+	classpath/javax/swing/UIManager.java,
+	classpath/javax/swing/JSplitPane.java,
+	classpath/javax/swing/JComponent.java,
+	classpath/javax/swing/SwingUtilities.java,
+	classpath/javax/swing/border/AbstractBorder.java,
+	classpath/javax/swing/border/CompoundBorder.java,
+	classpath/javax/swing/border/TitledBorder.java,
+	classpath/javax/swing/border/MatteBorder.java,
+	classpath/javax/swing/border/BevelBorder.java,
+	classpath/javax/swing/RepaintManager.java,
+	classpath/javax/swing/JTable.java,
+	classpath/javax/swing/UIDefaults.java,
+	classpath/javax/swing/DefaultDesktopManager.java,
+	classpath/javax/swing/JMenu.java,
+	classpath/javax/swing/JLabel.java,
+	classpath/javax/swing/JSlider.java,
+	classpath/javax/swing/plaf/basic/BasicToolBarUI.java,
+	classpath/javax/swing/plaf/basic/BasicButtonUI.java,
+	classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java,
+	classpath/javax/swing/plaf/basic/BasicTextAreaUI.java,
+	classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java,
+	classpath/javax/swing/plaf/basic/BasicSpinnerUI.java,
+	classpath/javax/swing/plaf/basic/BasicSliderUI.java,
+	classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java,
+	classpath/javax/swing/plaf/basic/BasicComboPopup.java,
+	classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java,
+	classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java,
+	classpath/javax/swing/plaf/basic/BasicProgressBarUI.java,
+	classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java,
+	classpath/javax/swing/plaf/basic/BasicPanelUI.java,
+	classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,
+	classpath/javax/swing/plaf/basic/BasicTreeUI.java,
+	classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java,
+	classpath/javax/swing/plaf/basic/BasicFileChooserUI.java,
+	classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java,
+	classpath/javax/swing/plaf/basic/BasicComboBoxUI.java,
+	classpath/javax/swing/plaf/basic/BasicListUI.java,
+	classpath/javax/swing/plaf/basic/BasicIconFactory.java,
+	classpath/javax/swing/plaf/basic/BasicTextUI.java,
+	classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,
+	classpath/javax/swing/plaf/basic/BasicDirectoryModel.java,
+	classpath/javax/swing/plaf/basic/BasicRootPaneUI.java,
+	classpath/javax/swing/plaf/basic/BasicTableUI.java,
+	classpath/javax/swing/plaf/basic/SharedUIDefaults.java,
+	classpath/javax/swing/plaf/multi/MultiComboBoxUI.java,
+	classpath/javax/swing/plaf/multi/MultiListUI.java,
+	classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java,
+	classpath/javax/swing/plaf/multi/MultiFileChooserUI.java,
+	classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java,
+	classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java,
+	classpath/javax/swing/plaf/multi/MultiLookAndFeel.java,
+	classpath/javax/swing/plaf/metal/MetalSliderUI.java,
+	classpath/javax/swing/plaf/metal/MetalIconFactory.java,
+	classpath/javax/swing/plaf/metal/MetalComboBoxIcon.java,
+	classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java,
+	classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,
+	classpath/javax/swing/plaf/metal/MetalCheckBoxUI.java,
+	classpath/javax/swing/plaf/metal/MetalSeparatorUI.java,
+	classpath/javax/swing/plaf/metal/MetalBorders.java,
+	classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java,
+	classpath/javax/swing/plaf/metal/MetalScrollBarUI.java,
+	classpath/javax/swing/plaf/metal/MetalRootPaneUI.java,
+	classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java,
+	classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java,
+	classpath/javax/swing/plaf/metal/MetalToolTipUI.java,
+	classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java,
+	classpath/javax/swing/plaf/metal/MetalFileChooserUI.java,
+	classpath/javax/swing/plaf/metal/MetalUtils.java,
+	classpath/javax/swing/plaf/metal/MetalComboBoxButton.java,
+	classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java,
+	classpath/javax/swing/plaf/metal/MetalButtonUI.java,
+	classpath/javax/swing/JPopupMenu.java,
+	classpath/javax/swing/JProgressBar.java,
+	classpath/javax/swing/WindowConstants.java,
+	classpath/javax/swing/JFrame.java,
+	classpath/javax/swing/JFileChooser.java,
+	classpath/javax/swing/JComboBox.java,
+	classpath/javax/swing/event/EventListenerList.java,
+	classpath/javax/swing/ListSelectionModel.java,
+	classpath/javax/swing/JScrollBar.java,
+	classpath/java/text/SimpleDateFormat.java,
+	classpath/java/text/NumberFormat.java,
+	classpath/java/text/class-dependencies.conf,
+	classpath/java/awt/image/ColorModel.java,
+	classpath/java/awt/image/BufferedImage.java,
+	classpath/java/awt/Window.java,
+	classpath/java/awt/ContainerOrderFocusTraversalPolicy.java,
+	classpath/java/awt/LightweightDispatcher.java,
+	classpath/java/awt/EventDispatchThread.java,
+	classpath/java/awt/BasicStroke.java,
+	classpath/java/awt/ColorPaintContext.java,
+	classpath/java/awt/Container.java,
+	classpath/java/awt/TexturePaint.java,
+	classpath/java/awt/Component.java, classpath/java/awt/Font.java,
+	classpath/java/awt/GraphicsConfiguration.java,
+	classpath/java/awt/DefaultKeyboardFocusManager.java,
+	classpath/java/awt/print/PrinterJob.java,
+	classpath/java/awt/im/InputContext.java,
+	classpath/java/awt/dnd/DragGestureRecognizer.java,
+	classpath/java/awt/Toolkit.java,
+	classpath/java/awt/font/GraphicAttribute.java,
+	classpath/java/awt/font/ImageGraphicAttribute.java,
+	classpath/java/awt/font/GlyphVector.java,
+	classpath/java/awt/font/GlyphMetrics.java,
+	classpath/java/awt/font/ShapeGraphicAttribute.java,
+	classpath/java/awt/Graphics2D.java,
+	classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,
+	classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h,
+	classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h,
+	classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h,
+	classpath/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h,
+	classpath/include/config.h.in,
+	classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h,
+	classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h,
+	classpath/include/gnu_java_awt_peer_gtk_GdkFontPeer.h,
+	classpath/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h,
+	classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h,
+	classpath/include/gnu_java_awt_peer_gtk_GtkImage.h,
+	classpath/include/gnu_java_awt_peer_gtk_CairoSurface.h,
+	classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h:
+	Merge from GNU Classpath HEAD.
+
 2006-06-08  Tom Tromey  <tromey@redhat.com>
 
 	* gnu/classpath/natSystemProperties.cc (insertSystemProperties):
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index 01b2ab7dbf4b..e17fd0aa4daf 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -145,9 +145,10 @@ am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
 	gnu/gcj/util.lo gnu/java/awt.lo gnu/java/awt/color.lo \
 	gnu/java/awt/font.lo gnu/java/awt/font/opentype.lo \
 	gnu/java/awt/font/opentype/truetype.lo gnu/java/awt/image.lo \
-	gnu/java/awt/java2d.lo gnu/java/awt/peer.lo gnu/java/io.lo \
-	gnu/java/lang.lo gnu/java/lang/reflect.lo gnu/java/locale.lo \
-	gnu/java/math.lo gnu/java/net.lo gnu/java/net/local.lo \
+	gnu/java/awt/java2d.lo gnu/java/awt/peer.lo \
+	gnu/java/awt/print.lo gnu/java/io.lo gnu/java/lang.lo \
+	gnu/java/lang/reflect.lo gnu/java/locale.lo gnu/java/math.lo \
+	gnu/java/net.lo gnu/java/net/local.lo \
 	gnu/java/net/protocol/core.lo gnu/java/net/protocol/file.lo \
 	gnu/java/net/protocol/ftp.lo gnu/java/net/protocol/gcjlib.lo \
 	gnu/java/net/protocol/http.lo gnu/java/net/protocol/https.lo \
@@ -189,7 +190,7 @@ am__DEPENDENCIES_1 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
 	gnu/javax/print/ipp/attribute/supported.lo \
 	gnu/javax/security/auth.lo gnu/javax/security/auth/callback.lo \
 	gnu/javax/security/auth/login.lo gnu/javax/swing/plaf/gnu.lo \
-	gnu/javax/swing/plaf/metal.lo \
+	gnu/javax/swing/plaf/metal.lo gnu/javax/swing/text/html.lo \
 	gnu/javax/swing/text/html/parser.lo \
 	gnu/javax/swing/text/html/parser/models.lo \
 	gnu/javax/swing/text/html/parser/support.lo \
@@ -1256,12 +1257,14 @@ gnu_java_awt_java2d_source_files = \
 classpath/gnu/java/awt/java2d/AbstractGraphics2D.java \
 classpath/gnu/java/awt/java2d/AlphaCompositeContext.java \
 classpath/gnu/java/awt/java2d/CubicSegment.java \
+classpath/gnu/java/awt/java2d/ImagePaint.java \
 classpath/gnu/java/awt/java2d/LineSegment.java \
 classpath/gnu/java/awt/java2d/PolyEdge.java \
 classpath/gnu/java/awt/java2d/PolyEdgeComparator.java \
 classpath/gnu/java/awt/java2d/QuadSegment.java \
 classpath/gnu/java/awt/java2d/RasterGraphics.java \
-classpath/gnu/java/awt/java2d/Segment.java
+classpath/gnu/java/awt/java2d/Segment.java \
+classpath/gnu/java/awt/java2d/TexturePaintContext.java
 
 gnu_java_awt_java2d_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_java2d_source_files)))
 gnu_java_awt_peer_source_files = \
@@ -1272,13 +1275,17 @@ classpath/gnu/java/awt/peer/GLightweightPeer.java
 
 gnu_java_awt_peer_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_peer_source_files)))
 gnu_java_awt_peer_gtk_source_files = \
+classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java \
+classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java \
+classpath/gnu/java/awt/peer/gtk/CairoSurface.java \
+classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java \
+classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java \
+classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java \
+classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java \
 classpath/gnu/java/awt/peer/gtk/GThreadMutex.java \
 classpath/gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java \
 classpath/gnu/java/awt/peer/gtk/GdkFontMetrics.java \
 classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java \
-classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java \
-classpath/gnu/java/awt/peer/gtk/GdkGraphics.java \
-classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java \
 classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java \
 classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \
 classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
@@ -1318,7 +1325,8 @@ classpath/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java \
 classpath/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java \
 classpath/gnu/java/awt/peer/gtk/GtkToolkit.java \
 classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java \
-classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java
+classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java \
+classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
 
 gnu_java_awt_peer_qt_source_files = \
 classpath/gnu/java/awt/peer/qt/MainQtThread.java \
@@ -1381,6 +1389,13 @@ classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java \
 classpath/gnu/java/awt/peer/swing/SwingToolkit.java \
 classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java
 
+gnu_java_awt_print_source_files = \
+classpath/gnu/java/awt/print/JavaPrinterGraphics.java \
+classpath/gnu/java/awt/print/JavaPrinterJob.java \
+classpath/gnu/java/awt/print/PostScriptGraphics2D.java \
+classpath/gnu/java/awt/print/SpooledDocument.java
+
+gnu_java_awt_print_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_print_source_files)))
 gnu_java_beans_source_files = \
 classpath/gnu/java/beans/BeanInfoEmbryo.java \
 classpath/gnu/java/beans/DefaultExceptionListener.java \
@@ -2718,8 +2733,15 @@ gnu_javax_swing_plaf_metal_source_files = \
 classpath/gnu/javax/swing/plaf/metal/CustomizableTheme.java
 
 gnu_javax_swing_plaf_metal_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_swing_plaf_metal_source_files)))
+gnu_javax_swing_text_html_source_files = \
+classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java \
+classpath/gnu/javax/swing/text/html/CombinedAttributes.java \
+classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java
+
+gnu_javax_swing_text_html_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_swing_text_html_source_files)))
 gnu_javax_swing_text_html_parser_source_files = \
 classpath/gnu/javax/swing/text/html/parser/HTML_401F.java \
+classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java \
 classpath/gnu/javax/swing/text/html/parser/gnuDTD.java \
 classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java \
 classpath/gnu/javax/swing/text/html/parser/htmlValidator.java
@@ -5353,7 +5375,8 @@ classpath/javax/swing/plaf/basic/BasicToolTipUI.java \
 classpath/javax/swing/plaf/basic/BasicTreeUI.java \
 classpath/javax/swing/plaf/basic/BasicViewportUI.java \
 classpath/javax/swing/plaf/basic/ComboPopup.java \
-classpath/javax/swing/plaf/basic/DefaultMenuLayout.java
+classpath/javax/swing/plaf/basic/DefaultMenuLayout.java \
+classpath/javax/swing/plaf/basic/SharedUIDefaults.java
 
 javax_swing_plaf_basic_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_swing_plaf_basic_source_files)))
 javax_swing_plaf_metal_source_files = \
@@ -5531,8 +5554,10 @@ classpath/javax/swing/text/html/HTMLDocument.java \
 classpath/javax/swing/text/html/HTMLEditorKit.java \
 classpath/javax/swing/text/html/HTMLFrameHyperlinkEvent.java \
 classpath/javax/swing/text/html/HTMLTableView.java \
+classpath/javax/swing/text/html/ImageView.java \
 classpath/javax/swing/text/html/InlineView.java \
 classpath/javax/swing/text/html/ListView.java \
+classpath/javax/swing/text/html/MinimalHTMLWriter.java \
 classpath/javax/swing/text/html/NullView.java \
 classpath/javax/swing/text/html/ObjectView.java \
 classpath/javax/swing/text/html/Option.java \
@@ -6476,6 +6501,7 @@ all_packages_source_files = \
   gnu/java/awt/image.list \
   gnu/java/awt/java2d.list \
   gnu/java/awt/peer.list \
+  gnu/java/awt/print.list \
   gnu/java/io.list \
   gnu/java/lang.list \
   gnu/java/lang/reflect.list \
@@ -6563,6 +6589,7 @@ all_packages_source_files = \
   gnu/javax/security/auth/login.list \
   gnu/javax/swing/plaf/gnu.list \
   gnu/javax/swing/plaf/metal.list \
+  gnu/javax/swing/text/html.list \
   gnu/javax/swing/text/html/parser.list \
   gnu/javax/swing/text/html/parser/models.list \
   gnu/javax/swing/text/html/parser/support.list \
@@ -6693,6 +6720,7 @@ ordinary_header_files = \
   $(gnu_java_awt_image_header_files) \
   $(gnu_java_awt_java2d_header_files) \
   $(gnu_java_awt_peer_header_files) \
+  $(gnu_java_awt_print_header_files) \
   $(gnu_java_io_header_files) \
   $(gnu_java_lang_header_files) \
   $(gnu_java_lang_reflect_header_files) \
@@ -6780,6 +6808,7 @@ ordinary_header_files = \
   $(gnu_javax_security_auth_login_header_files) \
   $(gnu_javax_swing_plaf_gnu_header_files) \
   $(gnu_javax_swing_plaf_metal_header_files) \
+  $(gnu_javax_swing_text_html_header_files) \
   $(gnu_javax_swing_text_html_parser_header_files) \
   $(gnu_javax_swing_text_html_parser_models_header_files) \
   $(gnu_javax_swing_text_html_parser_support_header_files) \
@@ -8989,6 +9018,16 @@ gnu-java-awt-peer-swing.lo: $(gnu_java_awt_peer_swing_source_files)
 	$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-java-awt-peer-swing.lo @gnu-java-awt-peer-swing.list
 	@rm -f gnu-java-awt-peer-swing.list
 
+gnu/java/awt/print.list: $(gnu_java_awt_print_source_files)
+	@$(mkinstalldirs) $(dir $@)
+	@for file in $(gnu_java_awt_print_source_files); do \
+	  if test -f $(srcdir)/$$file; then \
+	    echo $(srcdir)/$$file; \
+	  else echo $$file; fi; \
+	done > gnu/java/awt/print.list
+
+-include gnu/java/awt/print.deps
+
 gnu-java-beans.lo: $(gnu_java_beans_source_files)
 	@find classpath/lib/gnu/java/beans -name '*.class' > gnu-java-beans.list
 	$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-java-beans.lo @gnu-java-beans.list
@@ -9874,6 +9913,16 @@ gnu/javax/swing/plaf/metal.list: $(gnu_javax_swing_plaf_metal_source_files)
 
 -include gnu/javax/swing/plaf/metal.deps
 
+gnu/javax/swing/text/html.list: $(gnu_javax_swing_text_html_source_files)
+	@$(mkinstalldirs) $(dir $@)
+	@for file in $(gnu_javax_swing_text_html_source_files); do \
+	  if test -f $(srcdir)/$$file; then \
+	    echo $(srcdir)/$$file; \
+	  else echo $$file; fi; \
+	done > gnu/javax/swing/text/html.list
+
+-include gnu/javax/swing/text/html.deps
+
 gnu/javax/swing/text/html/parser.list: $(gnu_javax_swing_text_html_parser_source_files)
 	@$(mkinstalldirs) $(dir $@)
 	@for file in $(gnu_javax_swing_text_html_parser_source_files); do \
diff --git a/libjava/classpath/Makefile.in b/libjava/classpath/Makefile.in
index 2bb88f584b0a..2f99e810e1a7 100644
--- a/libjava/classpath/Makefile.in
+++ b/libjava/classpath/Makefile.in
@@ -39,9 +39,9 @@ target_triplet = @target@
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(top_srcdir)/configure \
 	$(top_srcdir)/gnu/classpath/Configuration.java.in AUTHORS \
-	COPYING ChangeLog INSTALL NEWS TODO config.guess config.sub \
-	depcomp install-sh ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh ltconfig \
-	ltmain.sh missing mkinstalldirs
+	COPYING ChangeLog INSTALL NEWS TODO compile config.guess \
+	config.sub depcomp install-sh ltcf-c.sh ltcf-cxx.sh \
+	ltcf-gcj.sh ltconfig ltmain.sh missing mkinstalldirs
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
@@ -89,8 +89,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -117,8 +115,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -141,6 +143,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -156,9 +160,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -180,6 +183,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -193,6 +197,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -206,6 +212,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -225,11 +232,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/configure b/libjava/classpath/configure
index a9f4175326e3..adb5cbb7cc9d 100755
--- a/libjava/classpath/configure
+++ b/libjava/classpath/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for GNU Classpath 0.91.
+# Generated by GNU Autoconf 2.59 for GNU Classpath 0.92-pre.
 #
 # Report bugs to <classpath@gnu.org>.
 #
@@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='GNU Classpath'
 PACKAGE_TARNAME='classpath'
-PACKAGE_VERSION='0.91'
-PACKAGE_STRING='GNU Classpath 0.91'
+PACKAGE_VERSION='0.92-pre'
+PACKAGE_STRING='GNU Classpath 0.92-pre'
 PACKAGE_BUGREPORT='classpath@gnu.org'
 
 ac_unique_file="java/lang/System.java"
@@ -312,7 +312,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os LIBVERSION CLASSPATH_MODULE CLASSPATH_CONVENIENCE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CREATE_COLLECTIONS_TRUE CREATE_COLLECTIONS_FALSE CREATE_JNI_LIBRARIES_TRUE CREATE_JNI_LIBRARIES_FALSE CREATE_CORE_JNI_LIBRARIES_TRUE CREATE_CORE_JNI_LIBRARIES_FALSE default_toolkit CREATE_XMLJ_LIBRARY_TRUE CREATE_XMLJ_LIBRARY_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP CREATE_ALSA_LIBRARIES_TRUE CREATE_ALSA_LIBRARIES_FALSE CREATE_DSSI_LIBRARIES_TRUE CREATE_DSSI_LIBRARIES_FALSE CREATE_GTK_PEER_LIBRARIES_TRUE CREATE_GTK_PEER_LIBRARIES_FALSE GTK_CAIRO_ENABLED GTK_CAIRO_TRUE GTK_CAIRO_FALSE CREATE_QT_PEER_LIBRARIES_TRUE CREATE_QT_PEER_LIBRARIES_FALSE nativeexeclibdir glibjdir CREATE_JNI_HEADERS_TRUE CREATE_JNI_HEADERS_FALSE LN_S RANLIB ac_ct_RANLIB LIBTOOL CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP PERL COLLECTIONS_PREFIX LIBICONV LTLIBICONV WARNING_CFLAGS STRICT_WARNING_CFLAGS ERROR_CFLAGS PKG_CONFIG XML_CFLAGS XML_LIBS XSLT_CFLAGS XSLT_LIBS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS GTK_CFLAGS GTK_LIBS CAIRO_CFLAGS CAIRO_LIBS FREETYPE2_CFLAGS FREETYPE2_LIBS PANGOFT2_CFLAGS PANGOFT2_LIBS QT_CFLAGS QT_LIBS MOC USER_JAVAH USER_SPECIFIED_JAVAH_TRUE USER_SPECIFIED_JAVAH_FALSE CLASSPATH_INCLUDES GCJ JIKES JIKESENCODING JIKESWARNINGS KJC GCJX ECJ FOUND_GCJ_TRUE FOUND_GCJ_FALSE FOUND_JIKES_TRUE FOUND_JIKES_FALSE FOUND_ECJ_TRUE FOUND_ECJ_FALSE FOUND_KJC_TRUE FOUND_KJC_FALSE FOUND_GCJX_TRUE FOUND_GCJX_FALSE USER_CLASSLIB USER_SPECIFIED_CLASSLIB_TRUE USER_SPECIFIED_CLASSLIB_FALSE vm_classes MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBDEBUG INIT_LOAD_LIBRARY JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION REMOVE MKDIR CP DATE FIND ZIP FASTJAR INSTALL_GLIBJ_ZIP_TRUE INSTALL_GLIBJ_ZIP_FALSE INSTALL_CLASS_FILES_TRUE INSTALL_CLASS_FILES_FALSE BUILD_CLASS_FILES_TRUE BUILD_CLASS_FILES_FALSE EXAMPLESDIR GJDOC CREATE_API_DOCS_TRUE CREATE_API_DOCS_FALSE JAY JAY_SKELETON REGEN_PARSERS_TRUE REGEN_PARSERS_FALSE USE_PREBUILT_GLIBJ_ZIP_TRUE USE_PREBUILT_GLIBJ_ZIP_FALSE PATH_TO_GLIBJ_ZIP ENABLE_LOCAL_SOCKETS_TRUE ENABLE_LOCAL_SOCKETS_FALSE LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os LIBVERSION CLASSPATH_MODULE CLASSPATH_CONVENIENCE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CREATE_COLLECTIONS_TRUE CREATE_COLLECTIONS_FALSE CREATE_JNI_LIBRARIES_TRUE CREATE_JNI_LIBRARIES_FALSE CREATE_CORE_JNI_LIBRARIES_TRUE CREATE_CORE_JNI_LIBRARIES_FALSE default_toolkit CREATE_XMLJ_LIBRARY_TRUE CREATE_XMLJ_LIBRARY_FALSE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP CREATE_ALSA_LIBRARIES_TRUE CREATE_ALSA_LIBRARIES_FALSE CREATE_DSSI_LIBRARIES_TRUE CREATE_DSSI_LIBRARIES_FALSE CREATE_GTK_PEER_LIBRARIES_TRUE CREATE_GTK_PEER_LIBRARIES_FALSE CREATE_QT_PEER_LIBRARIES_TRUE CREATE_QT_PEER_LIBRARIES_FALSE CREATE_PLUGIN_TRUE CREATE_PLUGIN_FALSE nativeexeclibdir glibjdir VM_BINARY FOUND_CACAO_TRUE FOUND_CACAO_FALSE CREATE_JNI_HEADERS_TRUE CREATE_JNI_HEADERS_FALSE CREATE_WRAPPERS_TRUE CREATE_WRAPPERS_FALSE LN_S CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE RANLIB ac_ct_RANLIB LIBTOOL CXXCPP PERL COLLECTIONS_PREFIX LIBMAGIC LIBICONV LTLIBICONV WARNING_CFLAGS STRICT_WARNING_CFLAGS ERROR_CFLAGS PKG_CONFIG XML_CFLAGS XML_LIBS XSLT_CFLAGS XSLT_LIBS X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS GTK_CFLAGS GTK_LIBS FREETYPE2_CFLAGS FREETYPE2_LIBS PANGOFT2_CFLAGS PANGOFT2_LIBS XTEST_LIBS QT_CFLAGS QT_LIBS MOC MOZILLA_CFLAGS MOZILLA_LIBS GLIB_CFLAGS GLIB_LIBS PLUGIN_DIR USER_JAVAH USER_SPECIFIED_JAVAH_TRUE USER_SPECIFIED_JAVAH_FALSE CLASSPATH_INCLUDES GCJ JIKES JIKESENCODING JIKESWARNINGS KJC GCJX ECJ FOUND_GCJ_TRUE FOUND_GCJ_FALSE FOUND_JIKES_TRUE FOUND_JIKES_FALSE FOUND_ECJ_TRUE FOUND_ECJ_FALSE FOUND_KJC_TRUE FOUND_KJC_FALSE FOUND_GCJX_TRUE FOUND_GCJX_FALSE USER_CLASSLIB USER_SPECIFIED_CLASSLIB_TRUE USER_SPECIFIED_CLASSLIB_FALSE vm_classes MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBDEBUG INIT_LOAD_LIBRARY JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION REMOVE MKDIR CP DATE FIND ZIP FASTJAR INSTALL_GLIBJ_ZIP_TRUE INSTALL_GLIBJ_ZIP_FALSE INSTALL_CLASS_FILES_TRUE INSTALL_CLASS_FILES_FALSE BUILD_CLASS_FILES_TRUE BUILD_CLASS_FILES_FALSE EXAMPLESDIR GJDOC CREATE_API_DOCS_TRUE CREATE_API_DOCS_FALSE JAY JAY_SKELETON REGEN_PARSERS_TRUE REGEN_PARSERS_FALSE USE_PREBUILT_GLIBJ_ZIP_TRUE USE_PREBUILT_GLIBJ_ZIP_FALSE PATH_TO_GLIBJ_ZIP ENABLE_LOCAL_SOCKETS_TRUE ENABLE_LOCAL_SOCKETS_FALSE LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -793,7 +793,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures GNU Classpath 0.91 to adapt to many kinds of systems.
+\`configure' configures GNU Classpath 0.92-pre to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -864,7 +864,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of GNU Classpath 0.91:";;
+     short | recursive ) echo "Configuration of GNU Classpath 0.92-pre:";;
    esac
   cat <<\_ACEOF
 
@@ -889,11 +889,12 @@ Optional Features:
   --disable-gtk-peer      compile GTK native peers (disabled by --disable-jni)
                           default=yes
 
-  --enable-gtk-cairo      build the cairo Graphics2D implementation on GTK
-                          default=no
   --enable-qt-peer        compile Qt4 native peers (disabled by --disable-jni)
                           default=no
+  --disable-plugin        compile gcjwebplugin (disabled by --disable-plugin)
+                          default=yes
   --enable-regen-headers  automatically regenerate JNI headers default=no
+  --enable-tool-wrappers  create tool wrapper binaries default=no
   --enable-static=PKGS  build static libraries default=no
   --enable-shared=PKGS  build shared libraries default=yes
   --enable-fast-install=PKGS  optimize for fast installation default=yes
@@ -914,10 +915,12 @@ Optional Features:
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-native-libdir    sets the installation directore for native libraries
+  --with-native-libdir    sets the installation directory for native libraries
                           default='${libdir}/${PACKAGE}'
   --with-glibj-dir        sets the installation directory for glibj.zip
                           default='${libdir}/${PACKAGE}'
+  --with-vm               sets the VM binary name
+                          default='${prefix}/bin/jamvm'
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-pic              try to use only PIC/non-PIC objects default=use both
   --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
@@ -1053,7 +1056,7 @@ fi
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-GNU Classpath configure 0.91
+GNU Classpath configure 0.92-pre
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1067,7 +1070,7 @@ cat >&5 <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by GNU Classpath $as_me 0.91, which was
+It was created by GNU Classpath $as_me 0.92-pre, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1815,7 +1818,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='classpath'
- VERSION='0.91'
+ VERSION='0.92-pre'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2030,8 +2033,6 @@ echo "${ECHO_T}$am_cv_prog_tar_ustar" >&6
 
 
 
-GCC_NO_EXECUTABLES
-
 # Check whether --enable-collections or --disable-collections was given.
 if test "${enable_collections+set}" = set; then
   enableval="$enable_collections"
@@ -4182,36 +4183,6 @@ echo "$as_me: error: No --enable-gtk-peers (or --disable-gtk-peers) option; you
    { (exit 1); exit 1; }; }
 fi;
 
-# Check whether --enable-gtk-cairo or --disable-gtk-cairo was given.
-if test "${enable_gtk_cairo+set}" = set; then
-  enableval="$enable_gtk_cairo"
-  case "${enableval}" in
-                yes) GTK_CAIRO_ENABLED=true ;;
-                no) GTK_CAIRO_ENABLED=false ;;
-                *) GTK_CAIRO_ENABLED=true ;;
-              esac
-else
-  GTK_CAIRO_ENABLED=false
-fi;
-
-if test "x${GTK_CAIRO_ENABLED}" = xtrue; then
-
-cat >>confdefs.h <<\_ACEOF
-#define GTK_CAIRO 1
-_ACEOF
-
-fi
-
-
-if test "x${GTK_CAIRO_ENABLED}" = xtrue; then
-  GTK_CAIRO_TRUE=
-  GTK_CAIRO_FALSE='#'
-else
-  GTK_CAIRO_TRUE='#'
-  GTK_CAIRO_FALSE=
-fi
-
-
 # Check whether --enable-qt-peer or --disable-qt-peer was given.
 if test "${enable_qt_peer+set}" = set; then
   enableval="$enable_qt_peer"
@@ -4234,6 +4205,27 @@ else
 fi
 
 
+# Check whether --enable-plugin or --disable-plugin was given.
+if test "${enable_plugin+set}" = set; then
+  enableval="$enable_plugin"
+  case "${enableval}" in
+                yes) COMPILE_PLUGIN=yes ;;
+                no) COMPILE_PLUGIN=no ;;
+                *) COMPILE_PLUGIN=yes ;;
+              esac
+else
+  COMPILE_PLUGIN=yes
+fi;
+
+
+if test "x${COMPILE_PLUGIN}" = xyes; then
+  CREATE_PLUGIN_TRUE=
+  CREATE_PLUGIN_FALSE='#'
+else
+  CREATE_PLUGIN_TRUE='#'
+  CREATE_PLUGIN_FALSE=
+fi
+
 
 
 # Check whether --with-native-libdir or --without-native-libdir was given.
@@ -4265,6 +4257,31 @@ fi;
 
 
 
+
+# Check whether --with-vm or --without-vm was given.
+if test "${with_vm+set}" = set; then
+  withval="$with_vm"
+
+	     VM_BINARY=${withval}
+
+else
+
+	     VM_BINARY='${prefix}/bin/jamvm'
+
+fi;
+
+
+
+
+if test "x`basename $VM_BINARY`" = xcacao; then
+  FOUND_CACAO_TRUE=
+  FOUND_CACAO_FALSE='#'
+else
+  FOUND_CACAO_TRUE='#'
+  FOUND_CACAO_FALSE=
+fi
+
+
 # Check whether --enable-regen-headers or --disable-regen-headers was given.
 if test "${enable_regen_headers+set}" = set; then
   enableval="$enable_regen_headers"
@@ -4287,6 +4304,29 @@ else
 fi
 
 
+# Check whether --enable-tool-wrappers or --disable-tool-wrappers was given.
+if test "${enable_tool_wrappers+set}" = set; then
+  enableval="$enable_tool_wrappers"
+  case x"${enableval}" in
+                xyes) COMPILE_WRAPPERS=yes ;;
+                xno) COMPILE_WRAPPERS=no ;;
+		x) COMPILE_WRAPPERS=yes ;;
+                *) COMPILE_WRAPPERS=yes ;;
+              esac
+else
+  COMPILE_WRAPPERS=no
+fi;
+
+
+if test "x${COMPILE_WRAPPERS}" = xyes; then
+  CREATE_WRAPPERS_TRUE=
+  CREATE_WRAPPERS_FALSE='#'
+else
+  CREATE_WRAPPERS_TRUE='#'
+  CREATE_WRAPPERS_FALSE=
+fi
+
+
 echo "$as_me:$LINENO: checking whether ln -s works" >&5
 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
 LN_S=$as_ln_s
@@ -4378,1309 +4418,1070 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 
-
-# Check whether --enable-static or --disable-static was given.
-if test "${enable_static+set}" = set; then
-  enableval="$enable_static"
-  p=${PACKAGE-default}
-case $enableval in
-yes) enable_static=yes ;;
-no) enable_static=no ;;
-*)
-  enable_static=no
-  # Look at the argument we got.  We use all the common list separators.
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
-  for pkg in $enableval; do
-    if test "X$pkg" = "X$p"; then
-      enable_static=yes
-    fi
-  done
-  IFS="$ac_save_ifs"
-  ;;
-esac
-else
-  enable_static=no
-fi;
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
-  enableval="$enable_shared"
-  p=${PACKAGE-default}
-case $enableval in
-yes) enable_shared=yes ;;
-no) enable_shared=no ;;
-*)
-  enable_shared=no
-  # Look at the argument we got.  We use all the common list separators.
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
-  for pkg in $enableval; do
-    if test "X$pkg" = "X$p"; then
-      enable_shared=yes
-    fi
-  done
-  IFS="$ac_save_ifs"
-  ;;
-esac
+ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CXX+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  enable_shared=yes
-fi;
-# Check whether --enable-fast-install or --disable-fast-install was given.
-if test "${enable_fast_install+set}" = set; then
-  enableval="$enable_fast_install"
-  p=${PACKAGE-default}
-case $enableval in
-yes) enable_fast_install=yes ;;
-no) enable_fast_install=no ;;
-*)
-  enable_fast_install=no
-  # Look at the argument we got.  We use all the common list separators.
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
-  for pkg in $enableval; do
-    if test "X$pkg" = "X$p"; then
-      enable_fast_install=yes
-    fi
-  done
-  IFS="$ac_save_ifs"
-  ;;
-esac
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
 else
-  enable_fast_install=yes
-fi;
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
-  withval="$with_gnu_ld"
-  test "$withval" = no || with_gnu_ld=yes
-else
-  with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  echo "$as_me:$LINENO: checking for ld used by GCC" >&5
-echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [\\/]* | [A-Za-z]:[\\/]*)
-      re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the path of ld
-      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
-      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6
 else
-  echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
-if test "${lt_cv_path_LD+set}" = set; then
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -z "$LD"; then
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
-  for ac_dir in $PATH; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some GNU ld's only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
-	test "$with_gnu_ld" != no && break
-      else
-	test "$with_gnu_ld" != yes && break
-      fi
-    fi
-  done
-  IFS="$ac_save_ifs"
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
 fi
 fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
-  echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6
 else
   echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
-   { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
-  lt_cv_prog_gnu_ld=yes
-else
-  lt_cv_prog_gnu_ld=no
-fi
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
 
+  test -n "$ac_ct_CXX" && break
+done
+test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
 
-echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
-echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
-if test "${lt_cv_ld_reload_flag+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  lt_cv_ld_reload_flag='-r'
+  CXX=$ac_ct_CXX
 fi
-echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
-echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
-reload_flag=$lt_cv_ld_reload_flag
-test -n "$reload_flag" && reload_flag=" $reload_flag"
 
-echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
-echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
-if test "${lt_cv_path_NM+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
-  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
-    test -z "$ac_dir" && ac_dir=.
-    tmp_nm=$ac_dir/${ac_tool_prefix}nm
-    if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then
-      # Check to see if the nm accepts a BSD-compat flag.
-      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
-      #   nm: unknown option "B" ignored
-      # Tru64's nm complains that /dev/null is an invalid object file
-      if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then
-	lt_cv_path_NM="$tmp_nm -B"
-	break
-      elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
-	lt_cv_path_NM="$tmp_nm -p"
-	break
-      else
-	lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	continue # so that we can try to find one that supports BSD flags
-      fi
-    fi
-  done
-  IFS="$ac_save_ifs"
-  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi
-fi
 
-NM="$lt_cv_path_NM"
-echo "$as_me:$LINENO: result: $NM" >&5
-echo "${ECHO_T}$NM" >&6
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+     "checking for C++ compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+  (eval $ac_compiler --version </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+  (eval $ac_compiler -v </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+  (eval $ac_compiler -V </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }
 
-echo "$as_me:$LINENO: checking how to recognise dependant libraries" >&5
-echo $ECHO_N "checking how to recognise dependant libraries... $ECHO_C" >&6
-if test "${lt_cv_deplibs_check_method+set}" = set; then
+echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
+if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [regex]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given egrep regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-beos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
 
-bsdi4*)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
-  lt_cv_file_magic_cmd='/usr/bin/file -L'
-  lt_cv_file_magic_test_file=/shlib/libc.so
-  ;;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-cygwin* | mingw* |pw32*)
-  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
-  ;;
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
-darwin* | rhapsody*)
-  # this will be overwritten by pass_all, but leave it in just in case
-  lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library'
-  lt_cv_file_magic_cmd='/usr/bin/file -L'
-  case "$host_os" in
-  rhapsody* | darwin1.012)
-    lt_cv_file_magic_test_file='/System/Library/Frameworks/System.framework/System'
-    ;;
-  *) # Darwin 1.3 on
-    lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib'
-    ;;
-  esac
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+fi
+echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
+GXX=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cxx_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
-freebsd* | kfreebsd*-gnu)
-  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
-    case $host_cpu in
-    i*86 )
-      # Not sure whether the presence of OpenBSD here was a mistake.
-      # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
-      lt_cv_file_magic_cmd=/usr/bin/file
-      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
-      ;;
-    esac
-  else
-    lt_cv_deplibs_check_method=pass_all
-  fi
-  ;;
+int
+main ()
+{
 
-gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-hpux10.20*|hpux11*)
-  case $host_cpu in
-  hppa*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
-    lt_cv_file_magic_cmd=/usr/bin/file
-    lt_cv_file_magic_test_file=/usr/lib/libc.sl
-    ;;
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
-    lt_cv_file_magic_cmd=/usr/bin/file
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
-  esac
-  ;;
-
-irix5* | irix6*)
-  case $host_os in
-  irix5*)
-    # this will be overridden with pass_all, but let us keep it just in case
-    lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
-    ;;
-  *)
-    case $LD in
-    *-32|*"-32 ") libmagic=32-bit;;
-    *-n32|*"-n32 ") libmagic=N32;;
-    *-64|*"-64 ") libmagic=64-bit;;
-    *) libmagic=never-match;;
-    esac
-    # this will be overridden with pass_all, but let us keep it just in case
-    lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"
-    ;;
-  esac
-  lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*`
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-# This must be Linux ELF.
-linux-gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-netbsd* | knetbsd*-gnu)
-  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$'
-  fi
-  ;;
-
-newsos6)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
-  lt_cv_file_magic_cmd=/usr/bin/file
-  lt_cv_file_magic_test_file=/usr/lib/libnls.so
-  ;;
-
-osf3* | osf4* | osf5*)
-  # this will be overridden with pass_all, but let us keep it just in case
-  lt_cv_deplibs_check_method='file_magic COFF format alpha shared library'
-  lt_cv_file_magic_test_file=/shlib/libc.so
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sco3.2v5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-solaris*)
-  lt_cv_deplibs_check_method=pass_all
-  lt_cv_file_magic_test_file=/lib/libc.so
-  ;;
-
-sysv5uw[78]* | sysv4*uw2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-  case $host_vendor in
-  ncr)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  motorola)
-    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
-    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
-    ;;
-  esac
-  ;;
-esac
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cxx_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+ac_cv_prog_cxx_g=no
 fi
-echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
-echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-
-
-
-
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-
-# find the maximum length of command line arguments
-echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
-echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
-if test "${lt_cv_sys_max_cmd_len+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-    i=0
-  teststring="ABCD"
-
-  case $build_os in
-  msdosdjgpp*)
-    # On DJGPP, this test can blow up pretty badly due to problems in libc
-    # (any single argument exceeding 2000 bytes causes a buffer overrun
-    # during glob expansion).  Even if it were fixed, the result of this
-    # check would be larger than it should be.
-    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
-    ;;
-
-  cygwin* | mingw*)
-    # On Win9x/ME, this test blows up -- it succeeds, but takes
-    # about 5 minutes as the teststring grows exponentially.
-    # Worse, since 9x/ME are not pre-emptively multitasking,
-    # you end up with a "frozen" computer, even though with patience
-    # the test eventually succeeds (with a max line length of 256k).
-    # Instead, let's just punt: use the minimum linelength reported by
-    # all of the supported platforms: 8192 (on NT/2K/XP).
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  amigaos*)
-    # On AmigaOS with pdksh, this test takes hours, literally.
-    # So we just punt and use a minimum line length of 8192.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
-
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
-  esac
-
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-
-if test -n "$lt_cv_sys_max_cmd_len" ; then
-  echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
-echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
+echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
 else
-  echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
 fi
-
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
-  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
-echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+for ac_declaration in \
+   '' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
 else
-  case $MAGIC_CMD in
-  /*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-  ?:/*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
-  ;;
-  *)
-  ac_save_MAGIC_CMD="$MAGIC_CMD"
-  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="/usr/bin:$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    egrep "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-  MAGIC_CMD="$ac_save_MAGIC_CMD"
-  ;;
-esac
-fi
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+continue
 fi
-
-if test -z "$lt_cv_path_MAGIC_CMD"; then
-  if test -n "$ac_tool_prefix"; then
-    echo "$as_me:$LINENO: checking for file" >&5
-echo $ECHO_N "checking for file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_cxx_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
 else
-  case $MAGIC_CMD in
-  /*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-  ?:/*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
-  ;;
-  *)
-  ac_save_MAGIC_CMD="$MAGIC_CMD"
-  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="/usr/bin:$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    egrep "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-  MAGIC_CMD="$ac_save_MAGIC_CMD"
-  ;;
-esac
 fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
 fi
 
-  else
-    MAGIC_CMD=:
-  fi
-fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-  fi
-  ;;
-esac
+depcc="$CXX"  am_compiler_list=
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
+echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
+echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
+if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
   fi
-done
-done
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    case $depmode in
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    none) break ;;
+    esac
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.
+    if depmode=$depmode \
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
 
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
+  cd ..
+  rm -rf conftest.dir
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  am_cv_CXX_dependencies_compiler_type=none
 fi
 
 fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
+echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
 
-  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
 
-  RANLIB=$ac_ct_RANLIB
+
+if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
 else
-  RANLIB="$ac_cv_prog_RANLIB"
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
 fi
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_STRIP+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+
+# Check whether --enable-static or --disable-static was given.
+if test "${enable_static+set}" = set; then
+  enableval="$enable_static"
+  p=${PACKAGE-default}
+case $enableval in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
 else
-  if test -n "$STRIP"; then
-  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+  enable_static=no
+fi;
+# Check whether --enable-shared or --disable-shared was given.
+if test "${enable_shared+set}" = set; then
+  enableval="$enable_shared"
+  p=${PACKAGE-default}
+case $enableval in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
 else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
-  echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
+  enable_shared=yes
+fi;
+# Check whether --enable-fast-install or --disable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then
+  enableval="$enable_fast_install"
+  p=${PACKAGE-default}
+case $enableval in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
+  enable_fast_install=yes
+fi;
 
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+  withval="$with_gnu_ld"
+  test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi;
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  echo "$as_me:$LINENO: checking for ld used by GCC" >&5
+echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+else
+  echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
 fi
-if test -z "$ac_cv_prog_STRIP"; then
-  ac_ct_STRIP=$STRIP
-  # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
+if test "${lt_cv_path_LD+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_STRIP"; then
-  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_STRIP="strip"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
 fi
 fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
-  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6
 else
   echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
-
-  STRIP=$ac_ct_STRIP
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+   { (exit 1); exit 1; }; }
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  STRIP="$ac_cv_prog_STRIP"
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  lt_cv_prog_gnu_ld=yes
+else
+  lt_cv_prog_gnu_ld=no
 fi
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
 
-# Check for any special flags to pass to ltconfig.
-libtool_flags="--cache-file=$cache_file"
-test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
-test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
-test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
-test "$GCC" = yes && libtool_flags="$libtool_flags --with-gcc"
-test "$lt_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
-
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
-  enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
-test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
-
-
-# Check whether --with-pic or --without-pic was given.
-if test "${with_pic+set}" = set; then
-  withval="$with_pic"
-  pic_mode="$withval"
+echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
+echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
+if test "${lt_cv_ld_reload_flag+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  pic_mode=default
-fi;
-test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic"
-test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-*-*-irix6*)
-  # Find out which ABI we are using.
-  echo '#line 5166 "configure"' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-   if test "$lt_cv_prog_gnu_ld" = yes; then
-    case `/usr/bin/file conftest.$ac_objext` in
-    *32-bit*)
-      LD="${LD-ld} -melf32bsmip"
-      ;;
-    *N32*)
-      LD="${LD-ld} -melf32bmipn32"
-      ;;
-    *64-bit*)
-      LD="${LD-ld} -melf64bmip"
-      ;;
-    esac
-   else
-    case `/usr/bin/file conftest.$ac_objext` in
-    *32-bit*)
-      LD="${LD-ld} -32"
-      ;;
-    *N32*)
-      LD="${LD-ld} -n32"
-      ;;
-    *64-bit*)
-      LD="${LD-ld} -64"
-      ;;
-    esac
-   fi
-  fi
-  rm -rf conftest*
-  ;;
-
-ia64-*-hpux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-    case "`/usr/bin/file conftest.o`" in
-    *ELF-32*)
-      HPUX_IA64_MODE="32"
-      ;;
-    *ELF-64*)
-      HPUX_IA64_MODE="64"
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; then
-    case "`/usr/bin/file conftest.o`" in
-    *32-bit*)
-      case $host in
-        x86_64-*linux*)
-          LD="${LD-ld} -m elf_i386"
-          ;;
-        ppc64-*linux*|powerpc64-*linux*)
-          LD="${LD-ld} -m elf32ppclinux"
-          ;;
-        s390x-*linux*)
-          LD="${LD-ld} -m elf_s390"
-          ;;
-        sparc64-*linux*)
-          LD="${LD-ld} -m elf32_sparc"
-          ;;
-      esac
-      ;;
-    *64-bit*)
-      case $host in
-        x86_64-*linux*)
-          LD="${LD-ld} -m elf_x86_64"
-          ;;
-        ppc*-*linux*|powerpc*-*linux*)
-          LD="${LD-ld} -m elf64ppc"
-          ;;
-        s390*-*linux*)
-          LD="${LD-ld} -m elf64_s390"
-          ;;
-        sparc*-*linux*)
-          LD="${LD-ld} -m elf64_sparc"
-          ;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
+  lt_cv_ld_reload_flag='-r'
+fi
+echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
+echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
+reload_flag=$lt_cv_ld_reload_flag
+test -n "$reload_flag" && reload_flag=" $reload_flag"
 
-*-*-sco3.2v5*)
-  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -belf"
-  echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
-echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
-if test "${lt_cv_cc_needs_belf+set}" = set; then
+echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
+echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
+if test "${lt_cv_path_NM+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-
-     ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-     cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  lt_cv_cc_needs_belf=yes
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-lt_cv_cc_needs_belf=no
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm=$ac_dir/${ac_tool_prefix}nm
+    if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then
+	lt_cv_path_NM="$tmp_nm -B"
+	break
+      elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+	lt_cv_path_NM="$tmp_nm -p"
+	break
+      else
+	lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
 fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-     ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
 fi
-echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
-echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
-    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
-  fi
-  ;;
 
+NM="$lt_cv_path_NM"
+echo "$as_me:$LINENO: result: $NM" >&5
+echo "${ECHO_T}$NM" >&6
 
-esac
+echo "$as_me:$LINENO: checking how to recognise dependant libraries" >&5
+echo $ECHO_N "checking how to recognise dependant libraries... $ECHO_C" >&6
+if test "${lt_cv_deplibs_check_method+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [regex]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given egrep regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
 
+case $host_os in
+aix*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-# Save cache, so that ltconfig can load it
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-_ACEOF
+bsdi4*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
 
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-{
-  (set) 2>&1 |
-    case `(ac_space=' '; set | grep ac_space) 2>&1` in
-    *ac_space=\ *)
-      # `set' does not quote correctly, so add quotes (double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \).
-      sed -n \
-	"s/'/'\\\\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;;
-    *)
-      # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n \
-	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+cygwin* | mingw* |pw32*)
+  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  # this will be overwritten by pass_all, but leave it in just in case
+  lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  case "$host_os" in
+  rhapsody* | darwin1.012)
+    lt_cv_file_magic_test_file='/System/Library/Frameworks/System.framework/System'
+    ;;
+  *) # Darwin 1.3 on
+    lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib'
+    ;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | kfreebsd*-gnu)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
       ;;
-    esac;
-} |
-  sed '
-     t clear
-     : clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
-     t end
-     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
-  if test -w $cache_file; then
-    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
-    cat confcache >$cache_file
+    esac
   else
-    echo "not updating unwritable cache $cache_file"
+    lt_cv_deplibs_check_method=pass_all
   fi
-fi
-rm -f confcache
+  ;;
 
-# Actually configure libtool.  ac_aux_dir is where install-sh is found.
-AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
-MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
-LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
-AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
-objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
-deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \
-${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
-$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \
-|| { { echo "$as_me:$LINENO: error: libtool configure failed" >&5
-echo "$as_me: error: libtool configure failed" >&2;}
-   { (exit 1); exit 1; }; }
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-# Reload cache, that may have been modified by ltconfig
-if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special
-  # files actually), so we avoid doing that.
-  if test -f "$cache_file"; then
-    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
-    case $cache_file in
-      [\\/]* | ?:[\\/]* ) . $cache_file;;
-      *)                      . ./$cache_file;;
+hpux10.20*|hpux11*)
+  case $host_cpu in
+  hppa*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    lt_cv_file_magic_cmd=/usr/bin/file
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_cmd=/usr/bin/file
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  esac
+  ;;
+
+irix5* | irix6*)
+  case $host_os in
+  irix5*)
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
+    ;;
+  *)
+    case $LD in
+    *-32|*"-32 ") libmagic=32-bit;;
+    *-n32|*"-n32 ") libmagic=N32;;
+    *-64|*"-64 ") libmagic=64-bit;;
+    *) libmagic=never-match;;
     esac
+    # this will be overridden with pass_all, but let us keep it just in case
+    lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"
+    ;;
+  esac
+  lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*`
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux-gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd* | knetbsd*-gnu)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$'
   fi
-else
-  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
-  >$cache_file
-fi
+  ;;
 
+newsos6)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
 
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh"
+osf3* | osf4* | osf5*)
+  # this will be overridden with pass_all, but let us keep it just in case
+  lt_cv_deplibs_check_method='file_magic COFF format alpha shared library'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-# Redirect the config.log output again, so that the ltconfig log is not
-# clobbered by the next message.
-exec 5>>./config.log
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  lt_cv_file_magic_test_file=/lib/libc.so
+  ;;
+
+sysv5uw[78]* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  case $host_vendor in
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  esac
+  ;;
+esac
 
+fi
+echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
+echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
 
 
 
 
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
+# find the maximum length of command line arguments
+echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
+echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
+    i=0
+  teststring="ABCD"
 
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="gcc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
 
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
-  CC=$ac_ct_CC
-else
-  CC="$ac_cv_prog_CC"
-fi
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
-if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="${ac_tool_prefix}cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+  esac
 
 fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+
+if test -n "$lt_cv_sys_max_cmd_len" ; then
+  echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
+echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  echo "$as_me:$LINENO: result: none" >&5
+echo "${ECHO_T}none" >&6
 fi
 
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
+echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
+  case $MAGIC_CMD in
+  /*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+  ?:/*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
+  ;;
+  *)
+  ac_save_MAGIC_CMD="$MAGIC_CMD"
+  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="/usr/bin:$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    egrep "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<EOF 1>&2
 
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  MAGIC_CMD="$ac_save_MAGIC_CMD"
+  ;;
+esac
 fi
 
-  CC=$ac_ct_CC
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
 else
-  CC="$ac_cv_prog_CC"
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
 
-fi
-if test -z "$CC"; then
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    echo "$as_me:$LINENO: checking for file" >&5
+echo $ECHO_N "checking for file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-  ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
-       ac_prog_rejected=yes
-       continue
-     fi
-    ac_cv_prog_CC="cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
+  case $MAGIC_CMD in
+  /*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+  ?:/*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
+  ;;
+  *)
+  ac_save_MAGIC_CMD="$MAGIC_CMD"
+  IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="/usr/bin:$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    egrep "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<EOF 1>&2
 
-if test $ac_prog_rejected = yes; then
-  # We found a bogon in the path, so make sure we never use it.
-  set dummy $ac_cv_prog_CC
-  shift
-  if test $# != 0; then
-    # We chose a different compiler from the bogus one.
-    # However, it has the same basename, so the bogon will be chosen
-    # first if we set CC to just the basename; use the full file name.
-    shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
-  fi
-fi
-fi
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  MAGIC_CMD="$ac_save_MAGIC_CMD"
+  ;;
+esac
 fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
 else
   echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
+  else
+    MAGIC_CMD=:
+  fi
 fi
-if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+
+  fi
+  ;;
+esac
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
+if test "${ac_cv_prog_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -5689,7 +5490,7 @@ do
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -5698,31 +5499,27 @@ done
 
 fi
 fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6
 else
   echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-    test -n "$CC" && break
-  done
 fi
-if test -z "$CC"; then
-  ac_ct_CC=$CC
-  for ac_prog in cl
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -5731,407 +5528,280 @@ do
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="$ac_prog"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  test -n "$ac_ct_CC" && break
-done
-
-  CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
-     "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_compiler_gnu=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-ac_compiler_gnu=no
+  test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
 fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
-int
-main ()
-{
+  RANLIB=$ac_ct_RANLIB
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_cc_g=yes
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_STRIP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-ac_cv_prog_cc_g=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
 else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
-  else
-    CFLAGS=
-  fi
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std1 is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std1.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+  test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
+echo "${ECHO_T}$ac_ct_STRIP" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX			-qlanglvl=ansi
-# Ultrix and OSF/1	-std1
-# HP-UX 10.20 and later	-Ae
-# HP-UX older versions	-Aa -D_HPUX_SOURCE
-# SVR4			-Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_prog_cc_stdc=$ac_arg
-break
+  STRIP=$ac_ct_STRIP
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags="--cache-file=$cache_file"
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$GCC" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$lt_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+
 
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
+# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+  enableval="$enable_libtool_lock"
 
-fi
+fi;
+test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
+test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
 
-case "x$ac_cv_prog_cc_stdc" in
-  x|xno)
-    echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
-  *)
-    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
-    CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
 
-# Some people use a C++ compiler to compile C.  Since we use `exit',
-# in C++ we need to declare it.  In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
-  choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  for ac_declaration in \
-   '' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+# Check whether --with-pic or --without-pic was given.
+if test "${with_pic+set}" = set; then
+  withval="$with_pic"
+  pic_mode="$withval"
+else
+  pic_mode=default
+fi;
+test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic"
+test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 5669 "configure"' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  (exit $ac_status); }; then
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+   fi
+  fi
+  rm -rf conftest*
+  ;;
+
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  (exit $ac_status); }; then
+    case "`/usr/bin/file conftest.o`" in
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
+  (exit $ac_status); }; then
+    case "`/usr/bin/file conftest.o`" in
+    *32-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
+echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
+if test "${lt_cv_cc_needs_belf+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
+
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_declaration
+
 int
 main ()
 {
-exit (42);
+
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -6144,169 +5814,155 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  lt_cv_cc_needs_belf=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+lt_cv_cc_needs_belf=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-depcc="$CC"   am_compiler_list=
+fi
+echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
+echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
 
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
-  # We make a subdir and do the tests there.  Otherwise we can end up
-  # making bogus files that we don't know about and never remove.  For
-  # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named `D' -- because `-MD' means `put the output
-  # in D'.
-  mkdir conftest.dir
-  # Copy depcomp to subdir because otherwise we won't find it if we're
-  # using a relative directory.
-  cp "$am_depcomp" conftest.dir
-  cd conftest.dir
-  # We will build objects and dependencies in a subdirectory because
-  # it helps to detect inapplicable dependency modes.  For instance
-  # both Tru64's cc and ICC support -MD to output dependencies as a
-  # side effect of compilation, but ICC will put the dependencies in
-  # the current directory while Tru64 will put them in the object
-  # directory.
-  mkdir sub
 
-  am_cv_CC_dependencies_compiler_type=none
-  if test "$am_compiler_list" = ""; then
-     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
-  fi
-  for depmode in $am_compiler_list; do
-    # Setup a source with many dependencies, because some compilers
-    # like to wrap large dependency lists on column 80 (with \), and
-    # we should not choose a depcomp mode which is confused by this.
-    #
-    # We need to recreate these files for each test, as the compiler may
-    # overwrite some of them when testing with obscure command lines.
-    # This happens at least with the AIX C compiler.
-    : > sub/conftest.c
-    for i in 1 2 3 4 5 6; do
-      echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
-      # Solaris 8's {/usr,}/bin/sh.
-      touch sub/conftst$i.h
-    done
-    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+esac
 
-    case $depmode in
-    nosideeffect)
-      # after this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested
-      if test "x$enable_dependency_tracking" = xyes; then
-	continue
-      else
-	break
-      fi
-      ;;
-    none) break ;;
-    esac
-    # We check with `-c' and `-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle `-M -o', and we need to detect this.
-    if depmode=$depmode \
-       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
-       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
-         >/dev/null 2>conftest.err &&
-       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
-       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      # icc doesn't choke on unknown options, it will just issue warnings
-      # or remarks (even with -Werror).  So we grep stderr for any message
-      # that says an option was ignored or not supported.
-      # When given -MP, icc 7.0 and 7.1 complain thusly:
-      #   icc: Command line warning: ignoring option '-M'; no argument required
-      # The diagnosis changed in icc 8.0:
-      #   icc: Command line remark: option '-MP' not supported
-      if (grep 'ignoring option' conftest.err ||
-          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
-        am_cv_CC_dependencies_compiler_type=$depmode
-        break
-      fi
-    fi
-  done
 
-  cd ..
-  rm -rf conftest.dir
-else
-  am_cv_CC_dependencies_compiler_type=none
-fi
+# Save cache, so that ltconfig can load it
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
 
-fi
-echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
-CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+_ACEOF
 
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+  (set) 2>&1 |
+    case `(ac_space=' '; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+	"s/'/'\\\\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;;
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n \
+	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} |
+  sed '
+     t clear
+     : clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+  if test -w $cache_file; then
+    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+    cat confcache >$cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
 
+# Actually configure libtool.  ac_aux_dir is where install-sh is found.
+AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
+LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
+AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
+objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
+deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \
+|| { { echo "$as_me:$LINENO: error: libtool configure failed" >&5
+echo "$as_me: error: libtool configure failed" >&2;}
+   { (exit 1); exit 1; }; }
 
-if
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
-  am__fastdepCC_TRUE=
-  am__fastdepCC_FALSE='#'
+# Reload cache, that may have been modified by ltconfig
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . $cache_file;;
+      *)                      . ./$cache_file;;
+    esac
+  fi
 else
-  am__fastdepCC_TRUE='#'
-  am__fastdepCC_FALSE=
+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
 fi
 
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
-fi
-if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+
+ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
+echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
+if test -z "$CXXCPP"; then
+  if test "${ac_cv_prog_CXXCPP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+      # Double quotes because CXXCPP needs to be expanded
+    for CXXCPP in "$CXX -E" "/lib/cpp"
     do
       ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
+for ac_cxx_preproc_warn_flag in '' yes
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
@@ -6336,8 +5992,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+    ac_cpp_err=$ac_cxx_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
   else
     ac_cpp_err=
   fi
@@ -6374,8 +6030,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+    ac_cpp_err=$ac_cxx_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
   else
     ac_cpp_err=
   fi
@@ -6403,17 +6059,17 @@ if $ac_preproc_ok; then
 fi
 
     done
-    ac_cv_prog_CPP=$CPP
+    ac_cv_prog_CXXCPP=$CXXCPP
 
 fi
-  CPP=$ac_cv_prog_CPP
+  CXXCPP=$ac_cv_prog_CXXCPP
 else
-  ac_cv_prog_CPP=$CPP
+  ac_cv_prog_CXXCPP=$CXXCPP
 fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
+echo "$as_me:$LINENO: result: $CXXCPP" >&5
+echo "${ECHO_T}$CXXCPP" >&6
 ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
+for ac_cxx_preproc_warn_flag in '' yes
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
@@ -6443,8 +6099,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+    ac_cpp_err=$ac_cxx_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
   else
     ac_cpp_err=
   fi
@@ -6481,8 +6137,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+    ac_cpp_err=$ac_cxx_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
   else
     ac_cpp_err=
   fi
@@ -6508,9 +6164,9 @@ rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+  { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
 See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -6521,23 +6177,267 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+
+
+LIBTOOL_DEPS=$LIBTOOL_DEPS" $ac_aux_dir/ltcf-cxx.sh"
+lt_save_CC="$CC"
+lt_save_CFLAGS="$CFLAGS"
+AR="$AR" LTCC="$CC" CC="$CXX" CXX="$CXX" CFLAGS="$CXXFLAGS" CPPFLAGS="$CPPFLAGS" \
+MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
+LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
+AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
+objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
+deplibs_check_method="$deplibs_check_method" \
+file_magic_cmd="$file_magic_cmd" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig -o libtool $libtool_flags \
+--build="$build" --add-tag=CXX $ac_aux_dir/ltcf-cxx.sh $host \
+|| { { echo "$as_me:$LINENO: error: libtool tag configuration failed" >&5
+echo "$as_me: error: libtool tag configuration failed" >&2;}
+   { (exit 1); exit 1; }; }
+CC="$lt_save_CC"
+CFLAGS="$lt_save_CFLAGS"
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CXX+set}" = set; then
+if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -6546,7 +6446,7 @@ do
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -6555,31 +6455,31 @@ done
 
 fi
 fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
-  echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
 else
   echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-    test -n "$CXX" && break
+    test -n "$CC" && break
   done
 fi
-if test -z "$CXX"; then
-  ac_ct_CXX=$CXX
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -n "$ac_ct_CXX"; then
-  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -6588,7 +6488,7 @@ do
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
   if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    ac_cv_prog_ac_ct_CC="$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -6597,26 +6497,33 @@ done
 
 fi
 fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
 else
   echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-  test -n "$ac_ct_CXX" && break
+  test -n "$ac_ct_CC" && break
 done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
 
-  CXX=$ac_ct_CXX
+  CC=$ac_ct_CC
+fi
+
 fi
 
 
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+   { (exit 1); exit 1; }; }
+
 # Provide some information about the compiler.
 echo "$as_me:$LINENO:" \
-     "checking for C++ compiler version" >&5
+     "checking for C compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
 { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
@@ -6634,9 +6541,9 @@ ac_compiler=`set X $ac_compile; echo $2`
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
 
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -6666,7 +6573,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
+	 { ac_try='test -z "$ac_c_werror_flag"
 			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
@@ -6684,37 +6591,209 @@ else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_compiler_gnu=no
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std1 is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std1.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX 10.20 and later	-Ae
+# HP-UX older versions	-Aa -D_HPUX_SOURCE
+# SVR4			-Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cxx_g+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
 
-int
-main ()
-{
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
 
-  ;
-  return 0;
-}
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
 _ACEOF
 rm -f conftest.$ac_objext
 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
@@ -6725,7 +6804,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
+	 { ac_try='test -z "$ac_c_werror_flag"
 			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
@@ -6738,33 +6817,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_prog_cxx_g=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-for ac_declaration in \
+  for ac_declaration in \
    '' \
    'extern "C" void std::exit (int) throw (); using std::exit;' \
    'extern "C" void std::exit (int); using std::exit;' \
@@ -6797,7 +6850,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
+	 { ac_try='test -z "$ac_c_werror_flag"
 			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
@@ -6842,7 +6895,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
+	 { ac_try='test -z "$ac_c_werror_flag"
 			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
@@ -6870,17 +6923,23 @@ if test -n "$ac_declaration"; then
   echo '#endif'             >>confdefs.h
 fi
 
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-depcc="$CXX"  am_compiler_list=
+depcc="$CC"   am_compiler_list=
 
 echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
@@ -6902,7 +6961,7 @@ else
   # directory.
   mkdir sub
 
-  am_cv_CXX_dependencies_compiler_type=none
+  am_cv_CC_dependencies_compiler_type=none
   if test "$am_compiler_list" = ""; then
      am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
   fi
@@ -6955,7 +7014,7 @@ else
       #   icc: Command line remark: option '-MP' not supported
       if (grep 'ignoring option' conftest.err ||
           grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
-        am_cv_CXX_dependencies_compiler_type=$depmode
+        am_cv_CC_dependencies_compiler_type=$depmode
         break
       fi
     fi
@@ -6964,42 +7023,47 @@ else
   cd ..
   rm -rf conftest.dir
 else
-  am_cv_CXX_dependencies_compiler_type=none
+  am_cv_CC_dependencies_compiler_type=none
 fi
 
 fi
-echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6
-CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
+echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
 
 
 
 if
   test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
-  am__fastdepCXX_TRUE=
-  am__fastdepCXX_FALSE='#'
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
 else
-  am__fastdepCXX_TRUE='#'
-  am__fastdepCXX_FALSE=
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
 fi
 
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
-echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
-if test -z "$CXXCPP"; then
-  if test "${ac_cv_prog_CXXCPP+set}" = set; then
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-      # Double quotes because CXXCPP needs to be expanded
-    for CXXCPP in "$CXX -E" "/lib/cpp"
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
     do
       ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
+for ac_c_preproc_warn_flag in '' yes
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
@@ -7029,8 +7093,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
   else
     ac_cpp_err=
   fi
@@ -7067,8 +7131,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
   else
     ac_cpp_err=
   fi
@@ -7096,17 +7160,17 @@ if $ac_preproc_ok; then
 fi
 
     done
-    ac_cv_prog_CXXCPP=$CXXCPP
+    ac_cv_prog_CPP=$CPP
 
 fi
-  CXXCPP=$ac_cv_prog_CXXCPP
+  CPP=$ac_cv_prog_CPP
 else
-  ac_cv_prog_CXXCPP=$CXXCPP
+  ac_cv_prog_CPP=$CPP
 fi
-echo "$as_me:$LINENO: result: $CXXCPP" >&5
-echo "${ECHO_T}$CXXCPP" >&6
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
 ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
+for ac_c_preproc_warn_flag in '' yes
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
@@ -7136,8 +7200,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
   else
     ac_cpp_err=
   fi
@@ -7174,8 +7238,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
-    ac_cpp_err=$ac_cxx_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
   else
     ac_cpp_err=
   fi
@@ -7201,9 +7265,9 @@ rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+  { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&5
-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -7215,32 +7279,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-
-LIBTOOL_DEPS=$LIBTOOL_DEPS" $ac_aux_dir/ltcf-cxx.sh"
-lt_save_CC="$CC"
-lt_save_CFLAGS="$CFLAGS"
-AR="$AR" LTCC="$CC" CC="$CXX" CXX="$CXX" CFLAGS="$CXXFLAGS" CPPFLAGS="$CPPFLAGS" \
-MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
-LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
-AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
-objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
-deplibs_check_method="$deplibs_check_method" \
-file_magic_cmd="$file_magic_cmd" \
-${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig -o libtool $libtool_flags \
---build="$build" --add-tag=CXX $ac_aux_dir/ltcf-cxx.sh $host \
-|| { { echo "$as_me:$LINENO: error: libtool tag configuration failed" >&5
-echo "$as_me: error: libtool tag configuration failed" >&2;}
-   { (exit 1); exit 1; }; }
-CC="$lt_save_CC"
-CFLAGS="$lt_save_CFLAGS"
-
-# Redirect the config.log output again, so that the ltconfig log is not
-# clobbered by the next message.
-exec 5>>./config.log
-
-
-
-
 if test "x${COMPILE_COLLECTIONS}" = xyes; then
   # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
@@ -7755,6 +7793,7 @@ fi
 
 
 
+
 for ac_header in unistd.h sys/types.h sys/config.h sys/ioctl.h \
 		    asm/ioctls.h \
 		    inttypes.h stdint.h utime.h sys/utime.h sys/filio.h \
@@ -7762,7 +7801,8 @@ for ac_header in unistd.h sys/types.h sys/config.h sys/ioctl.h \
 		    sys/select.h \
 		    crt_externs.h \
                     fcntl.h \
-		    sys/mman.h
+		    sys/mman.h \
+		    magic.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -8027,6 +8067,8 @@ rm -f conftest*
 
 
 
+
+
 
 
 
@@ -8039,6 +8081,7 @@ for ac_func in ftruncate fsync select \
 		  strerror_r \
                   fcntl \
 		  mmap munmap mincore msync madvise getpagesize sysconf \
+		  lstat readlink \
 
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -8138,7 +8181,78 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
 _ACEOF
 
 fi
-done
+done
+
+
+  LIBMAGIC=
+  echo "$as_me:$LINENO: checking for magic_open in -lmagic" >&5
+echo $ECHO_N "checking for magic_open in -lmagic... $ECHO_C" >&6
+if test "${ac_cv_lib_magic_magic_open+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmagic  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char magic_open ();
+int
+main ()
+{
+magic_open ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_magic_magic_open=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_magic_magic_open=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_magic_magic_open" >&5
+echo "${ECHO_T}$ac_cv_lib_magic_magic_open" >&6
+if test $ac_cv_lib_magic_magic_open = yes; then
+  LIBMAGIC=-lmagic
+fi
+
 
 
   echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
@@ -10065,7 +10179,261 @@ cat >>conftest.$ac_ext <<_ACEOF
 int
 main ()
 {
-
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_nospace=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_R_nospace=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+      if test $ac_R_nospace = yes; then
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+	X_LIBS="$X_LIBS -R$x_libraries"
+      else
+	LIBS="$ac_xsave_LIBS -R $x_libraries"
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_space=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_R_space=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+	if test $ac_R_space = yes; then
+	  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+	  X_LIBS="$X_LIBS -R $x_libraries"
+	else
+	  echo "$as_me:$LINENO: result: neither works" >&5
+echo "${ECHO_T}neither works" >&6
+	fi
+      fi
+      LIBS=$ac_xsave_LIBS
+    esac
+  fi
+
+  # Check for system-dependent libraries X programs must link with.
+  # Do this before checking for the system-independent R6 libraries
+  # (-lICE), since we may need -lsocket or whatever for X linking.
+
+  if test "$ISC" = yes; then
+    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
+  else
+    # Martyn Johnson says this is needed for Ultrix, if the X
+    # libraries were built with DECnet support.  And Karl Berry says
+    # the Alpha needs dnet_stub (dnet does not exist).
+    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+int
+main ()
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main ()
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dnet_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dnet_dnet_ntoa=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+fi
+
+    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
+      echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet_stub  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main ()
+{
+dnet_ntoa ();
   ;
   return 0;
 }
@@ -10092,32 +10460,89 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_R_nospace=yes
+  ac_cv_lib_dnet_stub_dnet_ntoa=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_R_nospace=no
+ac_cv_lib_dnet_stub_dnet_ntoa=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-      if test $ac_R_nospace = yes; then
-	echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-	X_LIBS="$X_LIBS -R$x_libraries"
-      else
-	LIBS="$ac_xsave_LIBS -R $x_libraries"
-	cat >conftest.$ac_ext <<_ACEOF
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
+fi
+
+    fi
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_xsave_LIBS"
+
+    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
+    # to get the SysV transport functions.
+    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
+    # needs -lnsl.
+    # The nsl library prevents programs from opening the X display
+    # on Irix 5.2, according to T.E. Dickey.
+    # The functions gethostbyname, getservbyname, and inet_addr are
+    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
+    echo "$as_me:$LINENO: checking for gethostbyname" >&5
+echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
+if test "${ac_cv_func_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+/* Define gethostbyname to an innocuous variant, in case <limits.h> declares gethostbyname.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define gethostbyname innocuous_gethostbyname
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char gethostbyname (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef gethostbyname
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
+choke me
+#else
+char (*f) () = gethostbyname;
+#endif
+#ifdef __cplusplus
+}
+#endif
 
 int
 main ()
 {
-
+return f != gethostbyname;
   ;
   return 0;
 }
@@ -10144,40 +10569,28 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_R_space=yes
+  ac_cv_func_gethostbyname=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_R_space=no
+ac_cv_func_gethostbyname=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-	if test $ac_R_space = yes; then
-	  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-	  X_LIBS="$X_LIBS -R $x_libraries"
-	else
-	  echo "$as_me:$LINENO: result: neither works" >&5
-echo "${ECHO_T}neither works" >&6
-	fi
-      fi
-      LIBS=$ac_xsave_LIBS
-    esac
-  fi
-
-  # Check for system-dependent libraries X programs must link with.
-  # Do this before checking for the system-independent R6 libraries
-  # (-lICE), since we may need -lsocket or whatever for X linking.
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
 
-  if test "$ISC" = yes; then
-    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
-  else
-    # Martyn Johnson says this is needed for Ultrix, if the X
-    # libraries were built with DECnet support.  And Karl Berry says
-    # the Alpha needs dnet_stub (dnet does not exist).
-    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
-    cat >conftest.$ac_ext <<_ACEOF
+    if test $ac_cv_func_gethostbyname = no; then
+      echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
+echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
+if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnsl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -10190,11 +10603,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XOpenDisplay ();
+char gethostbyname ();
 int
 main ()
 {
-XOpenDisplay ();
+gethostbyname ();
   ;
   return 0;
 }
@@ -10221,18 +10634,31 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  :
+  ac_cv_lib_nsl_gethostbyname=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5
-echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
-if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
+ac_cv_lib_nsl_gethostbyname=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
+if test $ac_cv_lib_nsl_gethostbyname = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
+fi
+
+      if test $ac_cv_lib_nsl_gethostbyname = no; then
+	echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5
+echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet  $LIBS"
+LIBS="-lbsd  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -10246,11 +10672,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char dnet_ntoa ();
+char gethostbyname ();
 int
 main ()
 {
-dnet_ntoa ();
+gethostbyname ();
   ;
   return 0;
 }
@@ -10277,49 +10703,85 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_dnet_dnet_ntoa=yes
+  ac_cv_lib_bsd_gethostbyname=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_dnet_dnet_ntoa=no
+ac_cv_lib_bsd_gethostbyname=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
-echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
-if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
+if test $ac_cv_lib_bsd_gethostbyname = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
 fi
 
-    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
-      echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5
-echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
-if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
+      fi
+    fi
+
+    # lieder@skyler.mavd.honeywell.com says without -lsocket,
+    # socket/setsockopt and other routines are undefined under SCO ODT
+    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
+    # on later versions), says Simon Leinen: it contains gethostby*
+    # variants that don't use the name server (or something).  -lsocket
+    # must be given before -lnsl if both are needed.  We assume that
+    # if connect needs -lnsl, so does gethostbyname.
+    echo "$as_me:$LINENO: checking for connect" >&5
+echo $ECHO_N "checking for connect... $ECHO_C" >&6
+if test "${ac_cv_func_connect+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldnet_stub  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+/* Define connect to an innocuous variant, in case <limits.h> declares connect.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define connect innocuous_connect
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char connect (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef connect
 
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
+{
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char dnet_ntoa ();
+char connect ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_connect) || defined (__stub___connect)
+choke me
+#else
+char (*f) () = connect;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
 int
 main ()
 {
-dnet_ntoa ();
+return f != connect;
   ;
   return 0;
 }
@@ -10346,89 +10808,45 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_dnet_stub_dnet_ntoa=yes
+  ac_cv_func_connect=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_dnet_stub_dnet_ntoa=no
+ac_cv_func_connect=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
-echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
-if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
-fi
-
-    fi
 fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-    LIBS="$ac_xsave_LIBS"
+echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5
+echo "${ECHO_T}$ac_cv_func_connect" >&6
 
-    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
-    # to get the SysV transport functions.
-    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
-    # needs -lnsl.
-    # The nsl library prevents programs from opening the X display
-    # on Irix 5.2, according to T.E. Dickey.
-    # The functions gethostbyname, getservbyname, and inet_addr are
-    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
-    echo "$as_me:$LINENO: checking for gethostbyname" >&5
-echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
-if test "${ac_cv_func_gethostbyname+set}" = set; then
+    if test $ac_cv_func_connect = no; then
+      echo "$as_me:$LINENO: checking for connect in -lsocket" >&5
+echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
+if test "${ac_cv_lib_socket_connect+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define gethostbyname to an innocuous variant, in case <limits.h> declares gethostbyname.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define gethostbyname innocuous_gethostbyname
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char gethostbyname (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef gethostbyname
 
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
-{
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
-choke me
-#else
-char (*f) () = gethostbyname;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
+char connect ();
 int
 main ()
 {
-return f != gethostbyname;
+connect ();
   ;
   return 0;
 }
@@ -10455,45 +10873,78 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_func_gethostbyname=yes
+  ac_cv_lib_socket_connect=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_func_gethostbyname=no
+ac_cv_lib_socket_connect=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5
+echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
+if test $ac_cv_lib_socket_connect = yes; then
+  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
 fi
-echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
 
-    if test $ac_cv_func_gethostbyname = no; then
-      echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5
-echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
-if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
+    fi
+
+    # Guillermo Gomez says -lposix is necessary on A/UX.
+    echo "$as_me:$LINENO: checking for remove" >&5
+echo $ECHO_N "checking for remove... $ECHO_C" >&6
+if test "${ac_cv_func_remove+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnsl  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+/* Define remove to an innocuous variant, in case <limits.h> declares remove.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define remove innocuous_remove
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char remove (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef remove
 
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
+{
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
+char remove ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_remove) || defined (__stub___remove)
+choke me
+#else
+char (*f) () = remove;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
 int
 main ()
 {
-gethostbyname ();
+return f != remove;
   ;
   return 0;
 }
@@ -10520,31 +10971,27 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_nsl_gethostbyname=yes
+  ac_cv_func_remove=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_nsl_gethostbyname=no
+ac_cv_func_remove=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
-if test $ac_cv_lib_nsl_gethostbyname = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
 fi
+echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5
+echo "${ECHO_T}$ac_cv_func_remove" >&6
 
-      if test $ac_cv_lib_nsl_gethostbyname = no; then
-	echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5
-echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
-if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
+    if test $ac_cv_func_remove = no; then
+      echo "$as_me:$LINENO: checking for remove in -lposix" >&5
+echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
+if test "${ac_cv_lib_posix_remove+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbsd  $LIBS"
+LIBS="-lposix  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -10558,11 +11005,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char gethostbyname ();
+char remove ();
 int
 main ()
 {
-gethostbyname ();
+remove ();
   ;
   return 0;
 }
@@ -10589,36 +11036,29 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_bsd_gethostbyname=yes
+  ac_cv_lib_posix_remove=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_bsd_gethostbyname=no
+ac_cv_lib_posix_remove=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5
-echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
-if test $ac_cv_lib_bsd_gethostbyname = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
+echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5
+echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
+if test $ac_cv_lib_posix_remove = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
 fi
 
-      fi
     fi
 
-    # lieder@skyler.mavd.honeywell.com says without -lsocket,
-    # socket/setsockopt and other routines are undefined under SCO ODT
-    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
-    # on later versions), says Simon Leinen: it contains gethostby*
-    # variants that don't use the name server (or something).  -lsocket
-    # must be given before -lnsl if both are needed.  We assume that
-    # if connect needs -lnsl, so does gethostbyname.
-    echo "$as_me:$LINENO: checking for connect" >&5
-echo $ECHO_N "checking for connect... $ECHO_C" >&6
-if test "${ac_cv_func_connect+set}" = set; then
+    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
+    echo "$as_me:$LINENO: checking for shmat" >&5
+echo $ECHO_N "checking for shmat... $ECHO_C" >&6
+if test "${ac_cv_func_shmat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -10627,12 +11067,12 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define connect to an innocuous variant, in case <limits.h> declares connect.
+/* Define shmat to an innocuous variant, in case <limits.h> declares shmat.
    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define connect innocuous_connect
+#define shmat innocuous_shmat
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char connect (); below.
+    which can conflict with char shmat (); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */
 
@@ -10642,7 +11082,7 @@ cat >>conftest.$ac_ext <<_ACEOF
 # include <assert.h>
 #endif
 
-#undef connect
+#undef shmat
 
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
@@ -10651,14 +11091,14 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char connect ();
+char shmat ();
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
-#if defined (__stub_connect) || defined (__stub___connect)
+#if defined (__stub_shmat) || defined (__stub___shmat)
 choke me
 #else
-char (*f) () = connect;
+char (*f) () = shmat;
 #endif
 #ifdef __cplusplus
 }
@@ -10667,7 +11107,7 @@ char (*f) () = connect;
 int
 main ()
 {
-return f != connect;
+return f != shmat;
   ;
   return 0;
 }
@@ -10694,27 +11134,27 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_func_connect=yes
+  ac_cv_func_shmat=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_func_connect=no
+ac_cv_func_shmat=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5
-echo "${ECHO_T}$ac_cv_func_connect" >&6
+echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5
+echo "${ECHO_T}$ac_cv_func_shmat" >&6
 
-    if test $ac_cv_func_connect = no; then
-      echo "$as_me:$LINENO: checking for connect in -lsocket" >&5
-echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
-if test "${ac_cv_lib_socket_connect+set}" = set; then
+    if test $ac_cv_func_shmat = no; then
+      echo "$as_me:$LINENO: checking for shmat in -lipc" >&5
+echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
+if test "${ac_cv_lib_ipc_shmat+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
+LIBS="-lipc  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -10728,11 +11168,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char connect ();
+char shmat ();
 int
 main ()
 {
-connect ();
+shmat ();
   ;
   return 0;
 }
@@ -10759,78 +11199,60 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_socket_connect=yes
+  ac_cv_lib_ipc_shmat=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_socket_connect=no
+ac_cv_lib_ipc_shmat=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5
-echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
-if test $ac_cv_lib_socket_connect = yes; then
-  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
+echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5
+echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
+if test $ac_cv_lib_ipc_shmat = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
 fi
 
     fi
+  fi
 
-    # Guillermo Gomez says -lposix is necessary on A/UX.
-    echo "$as_me:$LINENO: checking for remove" >&5
-echo $ECHO_N "checking for remove... $ECHO_C" >&6
-if test "${ac_cv_func_remove+set}" = set; then
+  # Check for libraries that X11R6 Xt/Xaw programs need.
+  ac_save_LDFLAGS=$LDFLAGS
+  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
+  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
+  # check for ICE first), but we must link in the order -lSM -lICE or
+  # we get undefined symbols.  So assume we have SM if we have ICE.
+  # These have to be linked with before -lX11, unlike the other
+  # libraries we check for below, so use a different variable.
+  # John Interrante, Karl Berry
+  echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5
+echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
+if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define remove to an innocuous variant, in case <limits.h> declares remove.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define remove innocuous_remove
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char remove (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef remove
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char remove ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_remove) || defined (__stub___remove)
-choke me
-#else
-char (*f) () = remove;
-#endif
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
-}
+extern "C"
 #endif
-
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char IceConnectionNumber ();
 int
 main ()
 {
-return f != remove;
+IceConnectionNumber ();
   ;
   return 0;
 }
@@ -10857,27 +11279,39 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_func_remove=yes
+  ac_cv_lib_ICE_IceConnectionNumber=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_func_remove=no
+ac_cv_lib_ICE_IceConnectionNumber=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
+echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
+if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
+  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
 fi
-echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5
-echo "${ECHO_T}$ac_cv_func_remove" >&6
 
-    if test $ac_cv_func_remove = no; then
-      echo "$as_me:$LINENO: checking for remove in -lposix" >&5
-echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
-if test "${ac_cv_lib_posix_remove+set}" = set; then
+  LDFLAGS=$ac_save_LDFLAGS
+
+fi
+
+    if test "$no_x" = yes; then
+        { { echo "$as_me:$LINENO: error: GTK+ peers requested but no X library available" >&5
+echo "$as_me: error: GTK+ peers requested but no X library available" >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+        echo "$as_me:$LINENO: checking for XTestQueryExtension in -lXtst" >&5
+echo $ECHO_N "checking for XTestQueryExtension in -lXtst... $ECHO_C" >&6
+if test "${ac_cv_lib_Xtst_XTestQueryExtension+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lposix  $LIBS"
+LIBS="-lXtst ${X_LIBS} $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -10891,11 +11325,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char remove ();
+char XTestQueryExtension ();
 int
 main ()
 {
-remove ();
+XTestQueryExtension ();
   ;
   return 0;
 }
@@ -10922,205 +11356,329 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_posix_remove=yes
+  ac_cv_lib_Xtst_XTestQueryExtension=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_posix_remove=no
+ac_cv_lib_Xtst_XTestQueryExtension=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5
-echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
-if test $ac_cv_lib_posix_remove = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
+echo "$as_me:$LINENO: result: $ac_cv_lib_Xtst_XTestQueryExtension" >&5
+echo "${ECHO_T}$ac_cv_lib_Xtst_XTestQueryExtension" >&6
+if test $ac_cv_lib_Xtst_XTestQueryExtension = yes; then
+  XTEST_LIBS="$XTEST_LIBS -lX11 -lXtst"
+else
+  { { echo "$as_me:$LINENO: error: libXtst NOT found, required for GdkRobot" >&5
+echo "$as_me: error: libXtst NOT found, required for GdkRobot" >&2;}
+   { (exit 1); exit 1; }; }
 fi
 
-    fi
 
-    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
-    echo "$as_me:$LINENO: checking for shmat" >&5
-echo $ECHO_N "checking for shmat... $ECHO_C" >&6
-if test "${ac_cv_func_shmat+set}" = set; then
+
+  succeeded=no
+
+  if test -z "$PKG_CONFIG"; then
+    # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+  echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  fi
+
+  if test "$PKG_CONFIG" = "no" ; then
+     echo "*** The pkg-config script could not be found. Make sure it is"
+     echo "*** in your path, or set the PKG_CONFIG environment variable"
+     echo "*** to the full path to pkg-config."
+     echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+  else
+     PKG_CONFIG_MIN_VERSION=0.9.0
+     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+        echo "$as_me:$LINENO: checking for gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0" >&5
+echo $ECHO_N "checking for gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0... $ECHO_C" >&6
+
+        if $PKG_CONFIG --exists "gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0" ; then
+            echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+            succeeded=yes
+
+            echo "$as_me:$LINENO: checking GTK_CFLAGS" >&5
+echo $ECHO_N "checking GTK_CFLAGS... $ECHO_C" >&6
+            GTK_CFLAGS=`$PKG_CONFIG --cflags "gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0"`
+            echo "$as_me:$LINENO: result: $GTK_CFLAGS" >&5
+echo "${ECHO_T}$GTK_CFLAGS" >&6
+
+            echo "$as_me:$LINENO: checking GTK_LIBS" >&5
+echo $ECHO_N "checking GTK_LIBS... $ECHO_C" >&6
+            GTK_LIBS=`$PKG_CONFIG --libs "gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0"`
+            echo "$as_me:$LINENO: result: $GTK_LIBS" >&5
+echo "${ECHO_T}$GTK_LIBS" >&6
+        else
+            GTK_CFLAGS=""
+            GTK_LIBS=""
+            ## If we have a custom action on failure, don't print errors, but
+            ## do set a variable so people can do so.
+            GTK_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0"`
+            echo $GTK_PKG_ERRORS
+        fi
+
+
+
+     else
+        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+        echo "*** See http://www.freedesktop.org/software/pkgconfig"
+     fi
+  fi
+
+  if test $succeeded = yes; then
+     :
+  else
+     { { echo "$as_me:$LINENO: error: Library requirements (gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
+echo "$as_me: error: Library requirements (gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+
+
+  succeeded=no
+
+  if test -z "$PKG_CONFIG"; then
+    # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+  echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  fi
+
+  if test "$PKG_CONFIG" = "no" ; then
+     echo "*** The pkg-config script could not be found. Make sure it is"
+     echo "*** in your path, or set the PKG_CONFIG environment variable"
+     echo "*** to the full path to pkg-config."
+     echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+  else
+     PKG_CONFIG_MIN_VERSION=0.9.0
+     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+        echo "$as_me:$LINENO: checking for freetype2" >&5
+echo $ECHO_N "checking for freetype2... $ECHO_C" >&6
+
+        if $PKG_CONFIG --exists "freetype2" ; then
+            echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+            succeeded=yes
+
+            echo "$as_me:$LINENO: checking FREETYPE2_CFLAGS" >&5
+echo $ECHO_N "checking FREETYPE2_CFLAGS... $ECHO_C" >&6
+            FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags "freetype2"`
+            echo "$as_me:$LINENO: result: $FREETYPE2_CFLAGS" >&5
+echo "${ECHO_T}$FREETYPE2_CFLAGS" >&6
+
+            echo "$as_me:$LINENO: checking FREETYPE2_LIBS" >&5
+echo $ECHO_N "checking FREETYPE2_LIBS... $ECHO_C" >&6
+            FREETYPE2_LIBS=`$PKG_CONFIG --libs "freetype2"`
+            echo "$as_me:$LINENO: result: $FREETYPE2_LIBS" >&5
+echo "${ECHO_T}$FREETYPE2_LIBS" >&6
+        else
+            FREETYPE2_CFLAGS=""
+            FREETYPE2_LIBS=""
+            ## If we have a custom action on failure, don't print errors, but
+            ## do set a variable so people can do so.
+            FREETYPE2_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "freetype2"`
+            echo $FREETYPE2_PKG_ERRORS
+        fi
+
+
+
+     else
+        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+        echo "*** See http://www.freedesktop.org/software/pkgconfig"
+     fi
+  fi
+
+  if test $succeeded = yes; then
+     :
+  else
+     { { echo "$as_me:$LINENO: error: Library requirements (freetype2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
+echo "$as_me: error: Library requirements (freetype2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+
+
+  succeeded=no
+
+  if test -z "$PKG_CONFIG"; then
+    # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define shmat to an innocuous variant, in case <limits.h> declares shmat.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define shmat innocuous_shmat
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
 
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char shmat (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
+  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
 
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
+if test -n "$PKG_CONFIG"; then
+  echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
 
-#undef shmat
+  fi
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char shmat ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_shmat) || defined (__stub___shmat)
-choke me
-#else
-char (*f) () = shmat;
-#endif
-#ifdef __cplusplus
-}
-#endif
+  if test "$PKG_CONFIG" = "no" ; then
+     echo "*** The pkg-config script could not be found. Make sure it is"
+     echo "*** in your path, or set the PKG_CONFIG environment variable"
+     echo "*** to the full path to pkg-config."
+     echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+  else
+     PKG_CONFIG_MIN_VERSION=0.9.0
+     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+        echo "$as_me:$LINENO: checking for pangoft2" >&5
+echo $ECHO_N "checking for pangoft2... $ECHO_C" >&6
 
-int
-main ()
-{
-return f != shmat;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_func_shmat=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+        if $PKG_CONFIG --exists "pangoft2" ; then
+            echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+            succeeded=yes
 
-ac_cv_func_shmat=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5
-echo "${ECHO_T}$ac_cv_func_shmat" >&6
+            echo "$as_me:$LINENO: checking PANGOFT2_CFLAGS" >&5
+echo $ECHO_N "checking PANGOFT2_CFLAGS... $ECHO_C" >&6
+            PANGOFT2_CFLAGS=`$PKG_CONFIG --cflags "pangoft2"`
+            echo "$as_me:$LINENO: result: $PANGOFT2_CFLAGS" >&5
+echo "${ECHO_T}$PANGOFT2_CFLAGS" >&6
 
-    if test $ac_cv_func_shmat = no; then
-      echo "$as_me:$LINENO: checking for shmat in -lipc" >&5
-echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
-if test "${ac_cv_lib_ipc_shmat+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lipc  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+            echo "$as_me:$LINENO: checking PANGOFT2_LIBS" >&5
+echo $ECHO_N "checking PANGOFT2_LIBS... $ECHO_C" >&6
+            PANGOFT2_LIBS=`$PKG_CONFIG --libs "pangoft2"`
+            echo "$as_me:$LINENO: result: $PANGOFT2_LIBS" >&5
+echo "${ECHO_T}$PANGOFT2_LIBS" >&6
+        else
+            PANGOFT2_CFLAGS=""
+            PANGOFT2_LIBS=""
+            ## If we have a custom action on failure, don't print errors, but
+            ## do set a variable so people can do so.
+            PANGOFT2_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "pangoft2"`
+            echo $PANGOFT2_PKG_ERRORS
+        fi
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char shmat ();
-int
-main ()
-{
-shmat ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  ac_cv_lib_ipc_shmat=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_ipc_shmat=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5
-echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
-if test $ac_cv_lib_ipc_shmat = yes; then
-  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
-fi
 
-    fi
+     else
+        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+        echo "*** See http://www.freedesktop.org/software/pkgconfig"
+     fi
   fi
 
-  # Check for libraries that X11R6 Xt/Xaw programs need.
-  ac_save_LDFLAGS=$LDFLAGS
-  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
-  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
-  # check for ICE first), but we must link in the order -lSM -lICE or
-  # we get undefined symbols.  So assume we have SM if we have ICE.
-  # These have to be linked with before -lX11, unlike the other
-  # libraries we check for below, so use a different variable.
-  # John Interrante, Karl Berry
-  echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5
-echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
-if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
+  if test $succeeded = yes; then
+     :
+  else
+     { { echo "$as_me:$LINENO: error: Library requirements (pangoft2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
+echo "$as_me: error: Library requirements (pangoft2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
+   { (exit 1); exit 1; }; }
+  fi
+
+            echo "$as_me:$LINENO: checking for XRenderQueryExtension in -lXrender" >&5
+echo $ECHO_N "checking for XRenderQueryExtension in -lXrender... $ECHO_C" >&6
+if test "${ac_cv_lib_Xrender_XRenderQueryExtension+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lICE $X_EXTRA_LIBS $LIBS"
+LIBS="-lXrender ${X_LIBS} $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -11134,11 +11692,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char IceConnectionNumber ();
+char XRenderQueryExtension ();
 int
 main ()
 {
-IceConnectionNumber ();
+XRenderQueryExtension ();
   ;
   return 0;
 }
@@ -11165,39 +11723,37 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_ICE_IceConnectionNumber=yes
+  ac_cv_lib_Xrender_XRenderQueryExtension=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_ICE_IceConnectionNumber=no
+ac_cv_lib_Xrender_XRenderQueryExtension=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
-echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
-if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
-  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
+echo "$as_me:$LINENO: result: $ac_cv_lib_Xrender_XRenderQueryExtension" >&5
+echo "${ECHO_T}$ac_cv_lib_Xrender_XRenderQueryExtension" >&6
+if test $ac_cv_lib_Xrender_XRenderQueryExtension = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XRENDER 1
+_ACEOF
+X_EXTRA_LIBS="$X_EXTRA_LIBS -lXrender"
+else
+  true
 fi
 
-  LDFLAGS=$ac_save_LDFLAGS
-
-fi
 
-    if test "$no_x" = yes; then
-        { { echo "$as_me:$LINENO: error: GTK+ peers requested but no X library available" >&5
-echo "$as_me: error: GTK+ peers requested but no X library available" >&2;}
-   { (exit 1); exit 1; }; }
-    fi
-        echo "$as_me:$LINENO: checking for XTestQueryExtension in -lXtst" >&5
-echo $ECHO_N "checking for XTestQueryExtension in -lXtst... $ECHO_C" >&6
-if test "${ac_cv_lib_Xtst_XTestQueryExtension+set}" = set; then
+            echo "$as_me:$LINENO: checking for XRRQueryExtension in -lXrandr" >&5
+echo $ECHO_N "checking for XRRQueryExtension in -lXrandr... $ECHO_C" >&6
+if test "${ac_cv_lib_Xrandr_XRRQueryExtension+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXtst ${X_LIBS} $LIBS"
+LIBS="-lXrandr ${X_LIBS} $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -11211,11 +11767,11 @@ extern "C"
 #endif
 /* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
-char XTestQueryExtension ();
+char XRRQueryExtension ();
 int
 main ()
 {
-XTestQueryExtension ();
+XRRQueryExtension ();
   ;
   return 0;
 }
@@ -11242,28 +11798,41 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_Xtst_XTestQueryExtension=yes
+  ac_cv_lib_Xrandr_XRRQueryExtension=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_Xtst_XTestQueryExtension=no
+ac_cv_lib_Xrandr_XRRQueryExtension=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_Xtst_XTestQueryExtension" >&5
-echo "${ECHO_T}$ac_cv_lib_Xtst_XTestQueryExtension" >&6
-if test $ac_cv_lib_Xtst_XTestQueryExtension = yes; then
-  true
+echo "$as_me:$LINENO: result: $ac_cv_lib_Xrandr_XRRQueryExtension" >&5
+echo "${ECHO_T}$ac_cv_lib_Xrandr_XRRQueryExtension" >&6
+if test $ac_cv_lib_Xrandr_XRRQueryExtension = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XRANDR 1
+_ACEOF
+X_EXTRA_LIBS="$X_EXTRA_LIBS -lXrandr"
 else
-  { { echo "$as_me:$LINENO: error: libXtst NOT found, required for GdkRobot" >&5
-echo "$as_me: error: libXtst NOT found, required for GdkRobot" >&2;}
-   { (exit 1); exit 1; }; }
+  true
 fi
 
 
+
+
+
+
+
+
+
+  fi
+
+    if test "x${COMPILE_QT_PEER}" = xyes; then
+
   succeeded=no
 
   if test -z "$PKG_CONFIG"; then
@@ -11317,32 +11886,32 @@ fi
   else
      PKG_CONFIG_MIN_VERSION=0.9.0
      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        echo "$as_me:$LINENO: checking for gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0" >&5
-echo $ECHO_N "checking for gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0... $ECHO_C" >&6
+        echo "$as_me:$LINENO: checking for QtCore QtGui >= 4.1.0" >&5
+echo $ECHO_N "checking for QtCore QtGui >= 4.1.0... $ECHO_C" >&6
 
-        if $PKG_CONFIG --exists "gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0" ; then
+        if $PKG_CONFIG --exists "QtCore QtGui >= 4.1.0" ; then
             echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
             succeeded=yes
 
-            echo "$as_me:$LINENO: checking GTK_CFLAGS" >&5
-echo $ECHO_N "checking GTK_CFLAGS... $ECHO_C" >&6
-            GTK_CFLAGS=`$PKG_CONFIG --cflags "gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0"`
-            echo "$as_me:$LINENO: result: $GTK_CFLAGS" >&5
-echo "${ECHO_T}$GTK_CFLAGS" >&6
+            echo "$as_me:$LINENO: checking QT_CFLAGS" >&5
+echo $ECHO_N "checking QT_CFLAGS... $ECHO_C" >&6
+            QT_CFLAGS=`$PKG_CONFIG --cflags "QtCore QtGui >= 4.1.0"`
+            echo "$as_me:$LINENO: result: $QT_CFLAGS" >&5
+echo "${ECHO_T}$QT_CFLAGS" >&6
 
-            echo "$as_me:$LINENO: checking GTK_LIBS" >&5
-echo $ECHO_N "checking GTK_LIBS... $ECHO_C" >&6
-            GTK_LIBS=`$PKG_CONFIG --libs "gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0"`
-            echo "$as_me:$LINENO: result: $GTK_LIBS" >&5
-echo "${ECHO_T}$GTK_LIBS" >&6
+            echo "$as_me:$LINENO: checking QT_LIBS" >&5
+echo $ECHO_N "checking QT_LIBS... $ECHO_C" >&6
+            QT_LIBS=`$PKG_CONFIG --libs "QtCore QtGui >= 4.1.0"`
+            echo "$as_me:$LINENO: result: $QT_LIBS" >&5
+echo "${ECHO_T}$QT_LIBS" >&6
         else
-            GTK_CFLAGS=""
-            GTK_LIBS=""
+            QT_CFLAGS=""
+            QT_LIBS=""
             ## If we have a custom action on failure, don't print errors, but
             ## do set a variable so people can do so.
-            GTK_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0"`
-            echo $GTK_PKG_ERRORS
+            QT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "QtCore QtGui >= 4.1.0"`
+
         fi
 
 
@@ -11354,15 +11923,179 @@ echo "${ECHO_T}$GTK_LIBS" >&6
   fi
 
   if test $succeeded = yes; then
-     :
+     HAVE_QT4="yes"
   else
-     { { echo "$as_me:$LINENO: error: Library requirements (gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
-echo "$as_me: error: Library requirements (gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
+     HAVE_QT4="no"
+  fi
+
+    if test "x$HAVE_QT4" = "xyes"; then
+                  QT_INCLUDE_DIR=$($PKG_CONFIG --variable=includedir QtGui)
+      EXTRA_QT_INCLUDE_DIR="$QT_INCLUDE_DIR/Qt"
+      as_ac_File=`echo "ac_cv_file_$QT_INCLUDE_DIR/QWidget" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $QT_INCLUDE_DIR/QWidget" >&5
+echo $ECHO_N "checking for $QT_INCLUDE_DIR/QWidget... $ECHO_C" >&6
+if eval "test \"\${$as_ac_File+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  test "$cross_compiling" = yes &&
+  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
+echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
+   { (exit 1); exit 1; }; }
+if test -r "$QT_INCLUDE_DIR/QWidget"; then
+  eval "$as_ac_File=yes"
+else
+  eval "$as_ac_File=no"
+fi
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_File'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_File'}'`" >&6
+if test `eval echo '${'$as_ac_File'}'` = yes; then
+  { echo "$as_me:$LINENO: No extra QT_INCLUDE_DIR needed" >&5
+echo "$as_me: No extra QT_INCLUDE_DIR needed" >&6;}
+else
+  as_ac_File=`echo "ac_cv_file_$EXTRA_QT_INCLUDE_DIR/QWidget" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $EXTRA_QT_INCLUDE_DIR/QWidget" >&5
+echo $ECHO_N "checking for $EXTRA_QT_INCLUDE_DIR/QWidget... $ECHO_C" >&6
+if eval "test \"\${$as_ac_File+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  test "$cross_compiling" = yes &&
+  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
+echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
+   { (exit 1); exit 1; }; }
+if test -r "$EXTRA_QT_INCLUDE_DIR/QWidget"; then
+  eval "$as_ac_File=yes"
+else
+  eval "$as_ac_File=no"
+fi
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_File'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_File'}'`" >&6
+if test `eval echo '${'$as_ac_File'}'` = yes; then
+  QT_CFLAGS="$QT_CFLAGS -I$EXTRA_QT_INCLUDE_DIR"
+else
+  { echo "$as_me:$LINENO: WARNING: QWidget not found" >&5
+echo "$as_me: WARNING: QWidget not found" >&2;}
+fi
+
+fi
+
+	# Extract the first word of "moc", so it can be a program name with args.
+set dummy moc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_MOC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$MOC"; then
+  ac_cv_prog_MOC="$MOC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MOC="moc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+fi
+fi
+MOC=$ac_cv_prog_MOC
+if test -n "$MOC"; then
+  echo "$as_me:$LINENO: result: $MOC" >&5
+echo "${ECHO_T}$MOC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+    fi
+    if test "x$HAVE_QT4" = "xno"; then
+      { echo "$as_me:$LINENO: Looking for QT_CFLAGS and QT_LIBS without pkg-config" >&5
+echo "$as_me: Looking for QT_CFLAGS and QT_LIBS without pkg-config" >&6;}
+      case "$host_os" in
+  	darwin*)
+
+# Check whether --with-qt4dir or --without-qt4dir was given.
+if test "${with_qt4dir+set}" = set; then
+  withval="$with_qt4dir"
+  QT4DIR=$withval
+
+fi;
+  	  if test x"$QT4DIR" = x ; then
+  	    { { echo "$as_me:$LINENO: error: *** No path for Qt4 --with-qt4dir option given" >&5
+echo "$as_me: error: *** No path for Qt4 --with-qt4dir option given" >&2;}
    { (exit 1); exit 1; }; }
+  	  fi
+  	  echo "$as_me:$LINENO: result: QT4DIR... $QT4DIR" >&5
+echo "${ECHO_T}QT4DIR... $QT4DIR" >&6
+  	  # Extract the first word of "moc", so it can be a program name with args.
+set dummy moc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_MOC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$MOC"; then
+  ac_cv_prog_MOC="$MOC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $QT4DIR/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MOC="$QT4DIR/bin/moc"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
   fi
+done
+done
+
+fi
+fi
+MOC=$ac_cv_prog_MOC
+if test -n "$MOC"; then
+  echo "$as_me:$LINENO: result: $MOC" >&5
+echo "${ECHO_T}$MOC" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  	  if test x"$MOC" = x; then
+  	    { { echo "$as_me:$LINENO: error: *** This is not the right Qt installation" >&5
+echo "$as_me: error: *** This is not the right Qt installation" >&2;}
+   { (exit 1); exit 1; }; }
+  	  fi
+  	  QT_CFLAGS="-F$QT4DIR/lib -I$QT4DIR/lib/QtCore.framework/Headers"
+  	  QT_CFLAGS="$QT_CFLAGS -I$QT4DIR/lib/QtGui.framework/Headers"
+  	  QT_LIBS="-Xlinker -F$QT4DIR/lib -Xlinker -framework -Xlinker QtCore"
+  	  QT_LIBS="$QT_LIBS -Xlinker -framework -Xlinker QtGui"
+  	  ;;
+  	*)
+  	  { { echo "$as_me:$LINENO: error: *** Please check PKG_CONFIG_PATH or the version
+  	  of your installed Qt4 installation." >&5
+echo "$as_me: error: *** Please check PKG_CONFIG_PATH or the version
+  	  of your installed Qt4 installation." >&2;}
+   { (exit 1); exit 1; }; }
+  	  ;;
+      esac
+    fi
+    { echo "$as_me:$LINENO: Set QT_CFLAGS... $QT_CFLAGS" >&5
+echo "$as_me: Set QT_CFLAGS... $QT_CFLAGS" >&6;}
+
 
+  fi
 
-    if test "x${enable_gtk_cairo}" = xyes; then
+    if test "x${COMPILE_PLUGIN}" = xyes; then
 
   succeeded=no
 
@@ -11417,32 +12150,32 @@ fi
   else
      PKG_CONFIG_MIN_VERSION=0.9.0
      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        echo "$as_me:$LINENO: checking for cairo >= 0.5.0" >&5
-echo $ECHO_N "checking for cairo >= 0.5.0... $ECHO_C" >&6
+        echo "$as_me:$LINENO: checking for mozilla-plugin" >&5
+echo $ECHO_N "checking for mozilla-plugin... $ECHO_C" >&6
 
-        if $PKG_CONFIG --exists "cairo >= 0.5.0" ; then
+        if $PKG_CONFIG --exists "mozilla-plugin" ; then
             echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
             succeeded=yes
 
-            echo "$as_me:$LINENO: checking CAIRO_CFLAGS" >&5
-echo $ECHO_N "checking CAIRO_CFLAGS... $ECHO_C" >&6
-            CAIRO_CFLAGS=`$PKG_CONFIG --cflags "cairo >= 0.5.0"`
-            echo "$as_me:$LINENO: result: $CAIRO_CFLAGS" >&5
-echo "${ECHO_T}$CAIRO_CFLAGS" >&6
-
-            echo "$as_me:$LINENO: checking CAIRO_LIBS" >&5
-echo $ECHO_N "checking CAIRO_LIBS... $ECHO_C" >&6
-            CAIRO_LIBS=`$PKG_CONFIG --libs "cairo >= 0.5.0"`
-            echo "$as_me:$LINENO: result: $CAIRO_LIBS" >&5
-echo "${ECHO_T}$CAIRO_LIBS" >&6
+            echo "$as_me:$LINENO: checking MOZILLA_CFLAGS" >&5
+echo $ECHO_N "checking MOZILLA_CFLAGS... $ECHO_C" >&6
+            MOZILLA_CFLAGS=`$PKG_CONFIG --cflags "mozilla-plugin"`
+            echo "$as_me:$LINENO: result: $MOZILLA_CFLAGS" >&5
+echo "${ECHO_T}$MOZILLA_CFLAGS" >&6
+
+            echo "$as_me:$LINENO: checking MOZILLA_LIBS" >&5
+echo $ECHO_N "checking MOZILLA_LIBS... $ECHO_C" >&6
+            MOZILLA_LIBS=`$PKG_CONFIG --libs "mozilla-plugin"`
+            echo "$as_me:$LINENO: result: $MOZILLA_LIBS" >&5
+echo "${ECHO_T}$MOZILLA_LIBS" >&6
         else
-            CAIRO_CFLAGS=""
-            CAIRO_LIBS=""
+            MOZILLA_CFLAGS=""
+            MOZILLA_LIBS=""
             ## If we have a custom action on failure, don't print errors, but
             ## do set a variable so people can do so.
-            CAIRO_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "cairo >= 0.5.0"`
-            echo $CAIRO_PKG_ERRORS
+            MOZILLA_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "mozilla-plugin"`
+
         fi
 
 
@@ -11454,15 +12187,12 @@ echo "${ECHO_T}$CAIRO_LIBS" >&6
   fi
 
   if test $succeeded = yes; then
-     :
+     MOZILLA_FOUND=yes
   else
-     { { echo "$as_me:$LINENO: error: Library requirements (cairo >= 0.5.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
-echo "$as_me: error: Library requirements (cairo >= 0.5.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
-   { (exit 1); exit 1; }; }
+     MOZILLA_FOUND=no
   fi
 
-    fi
-
+    if test "x${MOZILLA_FOUND}" = xno; then
 
   succeeded=no
 
@@ -11517,32 +12247,32 @@ fi
   else
      PKG_CONFIG_MIN_VERSION=0.9.0
      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        echo "$as_me:$LINENO: checking for freetype2" >&5
-echo $ECHO_N "checking for freetype2... $ECHO_C" >&6
+        echo "$as_me:$LINENO: checking for firefox-plugin" >&5
+echo $ECHO_N "checking for firefox-plugin... $ECHO_C" >&6
 
-        if $PKG_CONFIG --exists "freetype2" ; then
+        if $PKG_CONFIG --exists "firefox-plugin" ; then
             echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
             succeeded=yes
 
-            echo "$as_me:$LINENO: checking FREETYPE2_CFLAGS" >&5
-echo $ECHO_N "checking FREETYPE2_CFLAGS... $ECHO_C" >&6
-            FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags "freetype2"`
-            echo "$as_me:$LINENO: result: $FREETYPE2_CFLAGS" >&5
-echo "${ECHO_T}$FREETYPE2_CFLAGS" >&6
-
-            echo "$as_me:$LINENO: checking FREETYPE2_LIBS" >&5
-echo $ECHO_N "checking FREETYPE2_LIBS... $ECHO_C" >&6
-            FREETYPE2_LIBS=`$PKG_CONFIG --libs "freetype2"`
-            echo "$as_me:$LINENO: result: $FREETYPE2_LIBS" >&5
-echo "${ECHO_T}$FREETYPE2_LIBS" >&6
+            echo "$as_me:$LINENO: checking MOZILLA_CFLAGS" >&5
+echo $ECHO_N "checking MOZILLA_CFLAGS... $ECHO_C" >&6
+            MOZILLA_CFLAGS=`$PKG_CONFIG --cflags "firefox-plugin"`
+            echo "$as_me:$LINENO: result: $MOZILLA_CFLAGS" >&5
+echo "${ECHO_T}$MOZILLA_CFLAGS" >&6
+
+            echo "$as_me:$LINENO: checking MOZILLA_LIBS" >&5
+echo $ECHO_N "checking MOZILLA_LIBS... $ECHO_C" >&6
+            MOZILLA_LIBS=`$PKG_CONFIG --libs "firefox-plugin"`
+            echo "$as_me:$LINENO: result: $MOZILLA_LIBS" >&5
+echo "${ECHO_T}$MOZILLA_LIBS" >&6
         else
-            FREETYPE2_CFLAGS=""
-            FREETYPE2_LIBS=""
+            MOZILLA_CFLAGS=""
+            MOZILLA_LIBS=""
             ## If we have a custom action on failure, don't print errors, but
             ## do set a variable so people can do so.
-            FREETYPE2_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "freetype2"`
-            echo $FREETYPE2_PKG_ERRORS
+            MOZILLA_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "firefox-plugin"`
+
         fi
 
 
@@ -11554,13 +12284,13 @@ echo "${ECHO_T}$FREETYPE2_LIBS" >&6
   fi
 
   if test $succeeded = yes; then
-     :
+     MOZILLA_FOUND=yes
   else
-     { { echo "$as_me:$LINENO: error: Library requirements (freetype2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
-echo "$as_me: error: Library requirements (freetype2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
-   { (exit 1); exit 1; }; }
+     MOZILLA_FOUND=no
   fi
 
+    fi
+    if test "x${MOZILLA_FOUND}" = xno; then
 
   succeeded=no
 
@@ -11615,32 +12345,32 @@ fi
   else
      PKG_CONFIG_MIN_VERSION=0.9.0
      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        echo "$as_me:$LINENO: checking for pangoft2" >&5
-echo $ECHO_N "checking for pangoft2... $ECHO_C" >&6
+        echo "$as_me:$LINENO: checking for xulrunner-plugin" >&5
+echo $ECHO_N "checking for xulrunner-plugin... $ECHO_C" >&6
 
-        if $PKG_CONFIG --exists "pangoft2" ; then
+        if $PKG_CONFIG --exists "xulrunner-plugin" ; then
             echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
             succeeded=yes
 
-            echo "$as_me:$LINENO: checking PANGOFT2_CFLAGS" >&5
-echo $ECHO_N "checking PANGOFT2_CFLAGS... $ECHO_C" >&6
-            PANGOFT2_CFLAGS=`$PKG_CONFIG --cflags "pangoft2"`
-            echo "$as_me:$LINENO: result: $PANGOFT2_CFLAGS" >&5
-echo "${ECHO_T}$PANGOFT2_CFLAGS" >&6
-
-            echo "$as_me:$LINENO: checking PANGOFT2_LIBS" >&5
-echo $ECHO_N "checking PANGOFT2_LIBS... $ECHO_C" >&6
-            PANGOFT2_LIBS=`$PKG_CONFIG --libs "pangoft2"`
-            echo "$as_me:$LINENO: result: $PANGOFT2_LIBS" >&5
-echo "${ECHO_T}$PANGOFT2_LIBS" >&6
+            echo "$as_me:$LINENO: checking MOZILLA_CFLAGS" >&5
+echo $ECHO_N "checking MOZILLA_CFLAGS... $ECHO_C" >&6
+            MOZILLA_CFLAGS=`$PKG_CONFIG --cflags "xulrunner-plugin"`
+            echo "$as_me:$LINENO: result: $MOZILLA_CFLAGS" >&5
+echo "${ECHO_T}$MOZILLA_CFLAGS" >&6
+
+            echo "$as_me:$LINENO: checking MOZILLA_LIBS" >&5
+echo $ECHO_N "checking MOZILLA_LIBS... $ECHO_C" >&6
+            MOZILLA_LIBS=`$PKG_CONFIG --libs "xulrunner-plugin"`
+            echo "$as_me:$LINENO: result: $MOZILLA_LIBS" >&5
+echo "${ECHO_T}$MOZILLA_LIBS" >&6
         else
-            PANGOFT2_CFLAGS=""
-            PANGOFT2_LIBS=""
+            MOZILLA_CFLAGS=""
+            MOZILLA_LIBS=""
             ## If we have a custom action on failure, don't print errors, but
             ## do set a variable so people can do so.
-            PANGOFT2_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "pangoft2"`
-            echo $PANGOFT2_PKG_ERRORS
+            MOZILLA_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xulrunner-plugin"`
+
         fi
 
 
@@ -11652,25 +12382,12 @@ echo "${ECHO_T}$PANGOFT2_LIBS" >&6
   fi
 
   if test $succeeded = yes; then
-     :
+     MOZILLA_FOUND=yes
   else
-     { { echo "$as_me:$LINENO: error: Library requirements (pangoft2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
-echo "$as_me: error: Library requirements (pangoft2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-
-
-
-
-
-
-
-
-
-
+     MOZILLA_FOUND=no
   fi
 
-    if test "x${COMPILE_QT_PEER}" = xyes; then
+    fi
 
   succeeded=no
 
@@ -11725,32 +12442,32 @@ fi
   else
      PKG_CONFIG_MIN_VERSION=0.9.0
      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
-        echo "$as_me:$LINENO: checking for QtCore QtGui >= 4.1.0" >&5
-echo $ECHO_N "checking for QtCore QtGui >= 4.1.0... $ECHO_C" >&6
+        echo "$as_me:$LINENO: checking for glib-2.0" >&5
+echo $ECHO_N "checking for glib-2.0... $ECHO_C" >&6
 
-        if $PKG_CONFIG --exists "QtCore QtGui >= 4.1.0" ; then
+        if $PKG_CONFIG --exists "glib-2.0" ; then
             echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
             succeeded=yes
 
-            echo "$as_me:$LINENO: checking QT_CFLAGS" >&5
-echo $ECHO_N "checking QT_CFLAGS... $ECHO_C" >&6
-            QT_CFLAGS=`$PKG_CONFIG --cflags "QtCore QtGui >= 4.1.0"`
-            echo "$as_me:$LINENO: result: $QT_CFLAGS" >&5
-echo "${ECHO_T}$QT_CFLAGS" >&6
-
-            echo "$as_me:$LINENO: checking QT_LIBS" >&5
-echo $ECHO_N "checking QT_LIBS... $ECHO_C" >&6
-            QT_LIBS=`$PKG_CONFIG --libs "QtCore QtGui >= 4.1.0"`
-            echo "$as_me:$LINENO: result: $QT_LIBS" >&5
-echo "${ECHO_T}$QT_LIBS" >&6
+            echo "$as_me:$LINENO: checking GLIB_CFLAGS" >&5
+echo $ECHO_N "checking GLIB_CFLAGS... $ECHO_C" >&6
+            GLIB_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0"`
+            echo "$as_me:$LINENO: result: $GLIB_CFLAGS" >&5
+echo "${ECHO_T}$GLIB_CFLAGS" >&6
+
+            echo "$as_me:$LINENO: checking GLIB_LIBS" >&5
+echo $ECHO_N "checking GLIB_LIBS... $ECHO_C" >&6
+            GLIB_LIBS=`$PKG_CONFIG --libs "glib-2.0"`
+            echo "$as_me:$LINENO: result: $GLIB_LIBS" >&5
+echo "${ECHO_T}$GLIB_LIBS" >&6
         else
-            QT_CFLAGS=""
-            QT_LIBS=""
+            GLIB_CFLAGS=""
+            GLIB_LIBS=""
             ## If we have a custom action on failure, don't print errors, but
             ## do set a variable so people can do so.
-            QT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "QtCore QtGui >= 4.1.0"`
-
+            GLIB_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "glib-2.0"`
+            echo $GLIB_PKG_ERRORS
         fi
 
 
@@ -11762,175 +12479,20 @@ echo "${ECHO_T}$QT_LIBS" >&6
   fi
 
   if test $succeeded = yes; then
-     HAVE_QT4="yes"
+     :
   else
-     HAVE_QT4="no"
-  fi
-
-    if test "x$HAVE_QT4" = "xyes"; then
-                  QT_INCLUDE_DIR=$($PKG_CONFIG --variable=includedir QtGui)
-      EXTRA_QT_INCLUDE_DIR="$QT_INCLUDE_DIR/Qt"
-      as_ac_File=`echo "ac_cv_file_$QT_INCLUDE_DIR/QWidget" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $QT_INCLUDE_DIR/QWidget" >&5
-echo $ECHO_N "checking for $QT_INCLUDE_DIR/QWidget... $ECHO_C" >&6
-if eval "test \"\${$as_ac_File+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  test "$cross_compiling" = yes &&
-  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
-echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
-   { (exit 1); exit 1; }; }
-if test -r "$QT_INCLUDE_DIR/QWidget"; then
-  eval "$as_ac_File=yes"
-else
-  eval "$as_ac_File=no"
-fi
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_File'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_File'}'`" >&6
-if test `eval echo '${'$as_ac_File'}'` = yes; then
-  { echo "$as_me:$LINENO: No extra QT_INCLUDE_DIR needed" >&5
-echo "$as_me: No extra QT_INCLUDE_DIR needed" >&6;}
-else
-  as_ac_File=`echo "ac_cv_file_$EXTRA_QT_INCLUDE_DIR/QWidget" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $EXTRA_QT_INCLUDE_DIR/QWidget" >&5
-echo $ECHO_N "checking for $EXTRA_QT_INCLUDE_DIR/QWidget... $ECHO_C" >&6
-if eval "test \"\${$as_ac_File+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  test "$cross_compiling" = yes &&
-  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
-echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
+     { { echo "$as_me:$LINENO: error: Library requirements (glib-2.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&5
+echo "$as_me: error: Library requirements (glib-2.0) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." >&2;}
    { (exit 1); exit 1; }; }
-if test -r "$EXTRA_QT_INCLUDE_DIR/QWidget"; then
-  eval "$as_ac_File=yes"
-else
-  eval "$as_ac_File=no"
-fi
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_File'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_File'}'`" >&6
-if test `eval echo '${'$as_ac_File'}'` = yes; then
-  QT_CFLAGS="$QT_CFLAGS -I$EXTRA_QT_INCLUDE_DIR"
-else
-  { echo "$as_me:$LINENO: WARNING: QWidget not found" >&5
-echo "$as_me: WARNING: QWidget not found" >&2;}
-fi
-
-fi
-
-	# Extract the first word of "moc", so it can be a program name with args.
-set dummy moc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_MOC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$MOC"; then
-  ac_cv_prog_MOC="$MOC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_MOC="moc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
   fi
-done
-done
 
-fi
-fi
-MOC=$ac_cv_prog_MOC
-if test -n "$MOC"; then
-  echo "$as_me:$LINENO: result: $MOC" >&5
-echo "${ECHO_T}$MOC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
 
-    fi
-    if test "x$HAVE_QT4" = "xno"; then
-      { echo "$as_me:$LINENO: Looking for QT_CFLAGS and QT_LIBS without pkg-config" >&5
-echo "$as_me: Looking for QT_CFLAGS and QT_LIBS without pkg-config" >&6;}
-      case "$host_os" in
-  	darwin*)
 
-# Check whether --with-qt4dir or --without-qt4dir was given.
-if test "${with_qt4dir+set}" = set; then
-  withval="$with_qt4dir"
-  QT4DIR=$withval
 
-fi;
-  	  if test x"$QT4DIR" = x ; then
-  	    { { echo "$as_me:$LINENO: error: *** No path for Qt4 --with-qt4dir option given" >&5
-echo "$as_me: error: *** No path for Qt4 --with-qt4dir option given" >&2;}
-   { (exit 1); exit 1; }; }
-  	  fi
-  	  echo "$as_me:$LINENO: result: QT4DIR... $QT4DIR" >&5
-echo "${ECHO_T}QT4DIR... $QT4DIR" >&6
-  	  # Extract the first word of "moc", so it can be a program name with args.
-set dummy moc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_MOC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$MOC"; then
-  ac_cv_prog_MOC="$MOC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $QT4DIR/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_MOC="$QT4DIR/bin/moc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
 
-fi
-fi
-MOC=$ac_cv_prog_MOC
-if test -n "$MOC"; then
-  echo "$as_me:$LINENO: result: $MOC" >&5
-echo "${ECHO_T}$MOC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
 
-  	  if test x"$MOC" = x; then
-  	    { { echo "$as_me:$LINENO: error: *** This is not the right Qt installation" >&5
-echo "$as_me: error: *** This is not the right Qt installation" >&2;}
-   { (exit 1); exit 1; }; }
-  	  fi
-  	  QT_CFLAGS="-F$QT4DIR/lib -I$QT4DIR/lib/QtCore.framework/Headers"
-  	  QT_CFLAGS="$QT_CFLAGS -I$QT4DIR/lib/QtGui.framework/Headers"
-  	  QT_LIBS="-Xlinker -F$QT4DIR/lib -Xlinker -framework -Xlinker QtCore"
-  	  QT_LIBS="$QT_LIBS -Xlinker -framework -Xlinker QtGui"
-  	  ;;
-  	*)
-  	  { { echo "$as_me:$LINENO: error: *** Please check PKG_CONFIG_PATH or the version
-  	  of your installed Qt4 installation." >&5
-echo "$as_me: error: *** Please check PKG_CONFIG_PATH or the version
-  	  of your installed Qt4 installation." >&2;}
-   { (exit 1); exit 1; }; }
-  	  ;;
-      esac
-    fi
-    { echo "$as_me:$LINENO: Set QT_CFLAGS... $QT_CFLAGS" >&5
-echo "$as_me: Set QT_CFLAGS... $QT_CFLAGS" >&6;}
 
+    PLUGIN_DIR=$HOME/.mozilla/plugins/
 
   fi
 fi
@@ -17848,7 +18410,20 @@ fi
 
 
 
-                                                                                                                                                                                                                                                                                                                                                                                            ac_config_files="$ac_config_files Makefile doc/Makefile doc/api/Makefile external/Makefile external/sax/Makefile external/w3c_dom/Makefile external/relaxngDatatype/Makefile gnu/classpath/Configuration.java include/Makefile native/Makefile native/fdlibm/Makefile native/jawt/Makefile native/jni/Makefile native/jni/classpath/Makefile native/jni/java-io/Makefile native/jni/java-lang/Makefile native/jni/java-net/Makefile native/jni/java-nio/Makefile native/jni/java-util/Makefile native/jni/gtk-peer/Makefile native/jni/qt-peer/Makefile native/jni/xmlj/Makefile native/jni/midi-alsa/Makefile native/jni/midi-dssi/Makefile native/target/Makefile native/target/Linux/Makefile native/target/generic/Makefile resource/Makefile scripts/Makefile scripts/classpath.spec lib/Makefile lib/gen-classlist.sh lib/copy-vmresources.sh tools/Makefile tools/jarsigner.sh tools/keytool.sh examples/Makefile examples/Makefile.jawt"
+                                                                                                                                                                                                                                                                                                                                                                                  ac_config_files="$ac_config_files Makefile doc/Makefile doc/api/Makefile external/Makefile external/sax/Makefile external/w3c_dom/Makefile external/relaxngDatatype/Makefile gnu/classpath/Configuration.java include/Makefile native/Makefile native/fdlibm/Makefile native/jawt/Makefile native/jni/Makefile native/jni/classpath/Makefile native/jni/java-io/Makefile native/jni/java-lang/Makefile native/jni/java-net/Makefile native/jni/java-nio/Makefile native/jni/java-util/Makefile native/jni/gtk-peer/Makefile native/jni/qt-peer/Makefile native/jni/xmlj/Makefile native/jni/midi-alsa/Makefile native/jni/midi-dssi/Makefile native/plugin/Makefile native/target/Makefile native/target/Linux/Makefile native/target/generic/Makefile resource/Makefile scripts/Makefile scripts/classpath.spec lib/Makefile lib/gen-classlist.sh lib/copy-vmresources.sh tools/Makefile examples/Makefile examples/Makefile.jawt"
+
+
+if test "x${COMPILE_WRAPPERS}" = xno
+then
+                              ac_config_files="$ac_config_files tools/appletviewer tools/jarsigner tools/keytool"
+
+          ac_config_commands="$ac_config_commands appletviewer"
+
+          ac_config_commands="$ac_config_commands jarsigner"
+
+          ac_config_commands="$ac_config_commands keytool"
+
+fi
 
           ac_config_commands="$ac_config_commands gen-classlist"
 
@@ -18008,17 +18583,24 @@ echo "$as_me: error: conditional \"CREATE_GTK_PEER_LIBRARIES\" was never defined
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
-if test -z "${GTK_CAIRO_TRUE}" && test -z "${GTK_CAIRO_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"GTK_CAIRO\" was never defined.
+if test -z "${CREATE_QT_PEER_LIBRARIES_TRUE}" && test -z "${CREATE_QT_PEER_LIBRARIES_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CREATE_QT_PEER_LIBRARIES\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"CREATE_QT_PEER_LIBRARIES\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+if test -z "${CREATE_PLUGIN_TRUE}" && test -z "${CREATE_PLUGIN_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CREATE_PLUGIN\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"GTK_CAIRO\" was never defined.
+echo "$as_me: error: conditional \"CREATE_PLUGIN\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
-if test -z "${CREATE_QT_PEER_LIBRARIES_TRUE}" && test -z "${CREATE_QT_PEER_LIBRARIES_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"CREATE_QT_PEER_LIBRARIES\" was never defined.
+if test -z "${FOUND_CACAO_TRUE}" && test -z "${FOUND_CACAO_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"FOUND_CACAO\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"CREATE_QT_PEER_LIBRARIES\" was never defined.
+echo "$as_me: error: conditional \"FOUND_CACAO\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -18029,10 +18611,10 @@ echo "$as_me: error: conditional \"CREATE_JNI_HEADERS\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
-if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
-  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+if test -z "${CREATE_WRAPPERS_TRUE}" && test -z "${CREATE_WRAPPERS_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"CREATE_WRAPPERS\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+echo "$as_me: error: conditional \"CREATE_WRAPPERS\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -18043,6 +18625,13 @@ echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${USER_SPECIFIED_JAVAH_TRUE}" && test -z "${USER_SPECIFIED_JAVAH_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"USER_SPECIFIED_JAVAH\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -18440,7 +19029,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by GNU Classpath $as_me 0.91, which was
+This file was extended by GNU Classpath $as_me 0.92-pre, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -18506,7 +19095,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-GNU Classpath config.status 0.91
+GNU Classpath config.status 0.92-pre
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -18659,6 +19248,7 @@ do
   "native/jni/xmlj/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/xmlj/Makefile" ;;
   "native/jni/midi-alsa/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/midi-alsa/Makefile" ;;
   "native/jni/midi-dssi/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/jni/midi-dssi/Makefile" ;;
+  "native/plugin/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/plugin/Makefile" ;;
   "native/target/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/target/Makefile" ;;
   "native/target/Linux/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/target/Linux/Makefile" ;;
   "native/target/generic/Makefile" ) CONFIG_FILES="$CONFIG_FILES native/target/generic/Makefile" ;;
@@ -18669,14 +19259,18 @@ do
   "lib/gen-classlist.sh" ) CONFIG_FILES="$CONFIG_FILES lib/gen-classlist.sh" ;;
   "lib/copy-vmresources.sh" ) CONFIG_FILES="$CONFIG_FILES lib/copy-vmresources.sh" ;;
   "tools/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
-  "tools/jarsigner.sh" ) CONFIG_FILES="$CONFIG_FILES tools/jarsigner.sh" ;;
-  "tools/keytool.sh" ) CONFIG_FILES="$CONFIG_FILES tools/keytool.sh" ;;
   "examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;;
   "examples/Makefile.jawt" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile.jawt" ;;
+  "tools/appletviewer" ) CONFIG_FILES="$CONFIG_FILES tools/appletviewer" ;;
+  "tools/jarsigner" ) CONFIG_FILES="$CONFIG_FILES tools/jarsigner" ;;
+  "tools/keytool" ) CONFIG_FILES="$CONFIG_FILES tools/keytool" ;;
   "$ac_config_links_1" ) CONFIG_LINKS="$CONFIG_LINKS $ac_config_links_1" ;;
   "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
   "mkcollections.pl" ) CONFIG_COMMANDS="$CONFIG_COMMANDS mkcollections.pl" ;;
   "$ac_stdint_h" ) CONFIG_COMMANDS="$CONFIG_COMMANDS $ac_stdint_h" ;;
+  "appletviewer" ) CONFIG_COMMANDS="$CONFIG_COMMANDS appletviewer" ;;
+  "jarsigner" ) CONFIG_COMMANDS="$CONFIG_COMMANDS jarsigner" ;;
+  "keytool" ) CONFIG_COMMANDS="$CONFIG_COMMANDS keytool" ;;
   "gen-classlist" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gen-classlist" ;;
   "copy-vmresources" ) CONFIG_COMMANDS="$CONFIG_COMMANDS copy-vmresources" ;;
   "include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
@@ -18836,28 +19430,33 @@ s,@CREATE_DSSI_LIBRARIES_TRUE@,$CREATE_DSSI_LIBRARIES_TRUE,;t t
 s,@CREATE_DSSI_LIBRARIES_FALSE@,$CREATE_DSSI_LIBRARIES_FALSE,;t t
 s,@CREATE_GTK_PEER_LIBRARIES_TRUE@,$CREATE_GTK_PEER_LIBRARIES_TRUE,;t t
 s,@CREATE_GTK_PEER_LIBRARIES_FALSE@,$CREATE_GTK_PEER_LIBRARIES_FALSE,;t t
-s,@GTK_CAIRO_ENABLED@,$GTK_CAIRO_ENABLED,;t t
-s,@GTK_CAIRO_TRUE@,$GTK_CAIRO_TRUE,;t t
-s,@GTK_CAIRO_FALSE@,$GTK_CAIRO_FALSE,;t t
 s,@CREATE_QT_PEER_LIBRARIES_TRUE@,$CREATE_QT_PEER_LIBRARIES_TRUE,;t t
 s,@CREATE_QT_PEER_LIBRARIES_FALSE@,$CREATE_QT_PEER_LIBRARIES_FALSE,;t t
+s,@CREATE_PLUGIN_TRUE@,$CREATE_PLUGIN_TRUE,;t t
+s,@CREATE_PLUGIN_FALSE@,$CREATE_PLUGIN_FALSE,;t t
 s,@nativeexeclibdir@,$nativeexeclibdir,;t t
 s,@glibjdir@,$glibjdir,;t t
+s,@VM_BINARY@,$VM_BINARY,;t t
+s,@FOUND_CACAO_TRUE@,$FOUND_CACAO_TRUE,;t t
+s,@FOUND_CACAO_FALSE@,$FOUND_CACAO_FALSE,;t t
 s,@CREATE_JNI_HEADERS_TRUE@,$CREATE_JNI_HEADERS_TRUE,;t t
 s,@CREATE_JNI_HEADERS_FALSE@,$CREATE_JNI_HEADERS_FALSE,;t t
+s,@CREATE_WRAPPERS_TRUE@,$CREATE_WRAPPERS_TRUE,;t t
+s,@CREATE_WRAPPERS_FALSE@,$CREATE_WRAPPERS_FALSE,;t t
 s,@LN_S@,$LN_S,;t t
-s,@RANLIB@,$RANLIB,;t t
-s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
-s,@LIBTOOL@,$LIBTOOL,;t t
 s,@CXX@,$CXX,;t t
 s,@CXXFLAGS@,$CXXFLAGS,;t t
 s,@ac_ct_CXX@,$ac_ct_CXX,;t t
 s,@CXXDEPMODE@,$CXXDEPMODE,;t t
 s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t
 s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t
+s,@RANLIB@,$RANLIB,;t t
+s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
+s,@LIBTOOL@,$LIBTOOL,;t t
 s,@CXXCPP@,$CXXCPP,;t t
 s,@PERL@,$PERL,;t t
 s,@COLLECTIONS_PREFIX@,$COLLECTIONS_PREFIX,;t t
+s,@LIBMAGIC@,$LIBMAGIC,;t t
 s,@LIBICONV@,$LIBICONV,;t t
 s,@LTLIBICONV@,$LTLIBICONV,;t t
 s,@WARNING_CFLAGS@,$WARNING_CFLAGS,;t t
@@ -18874,15 +19473,19 @@ s,@X_LIBS@,$X_LIBS,;t t
 s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
 s,@GTK_CFLAGS@,$GTK_CFLAGS,;t t
 s,@GTK_LIBS@,$GTK_LIBS,;t t
-s,@CAIRO_CFLAGS@,$CAIRO_CFLAGS,;t t
-s,@CAIRO_LIBS@,$CAIRO_LIBS,;t t
 s,@FREETYPE2_CFLAGS@,$FREETYPE2_CFLAGS,;t t
 s,@FREETYPE2_LIBS@,$FREETYPE2_LIBS,;t t
 s,@PANGOFT2_CFLAGS@,$PANGOFT2_CFLAGS,;t t
 s,@PANGOFT2_LIBS@,$PANGOFT2_LIBS,;t t
+s,@XTEST_LIBS@,$XTEST_LIBS,;t t
 s,@QT_CFLAGS@,$QT_CFLAGS,;t t
 s,@QT_LIBS@,$QT_LIBS,;t t
 s,@MOC@,$MOC,;t t
+s,@MOZILLA_CFLAGS@,$MOZILLA_CFLAGS,;t t
+s,@MOZILLA_LIBS@,$MOZILLA_LIBS,;t t
+s,@GLIB_CFLAGS@,$GLIB_CFLAGS,;t t
+s,@GLIB_LIBS@,$GLIB_LIBS,;t t
+s,@PLUGIN_DIR@,$PLUGIN_DIR,;t t
 s,@USER_JAVAH@,$USER_JAVAH,;t t
 s,@USER_SPECIFIED_JAVAH_TRUE@,$USER_SPECIFIED_JAVAH_TRUE,;t t
 s,@USER_SPECIFIED_JAVAH_FALSE@,$USER_SPECIFIED_JAVAH_FALSE,;t t
@@ -20240,6 +20843,9 @@ echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
       mv $ac_stdint $ac_stdint_h
     fi
  ;;
+    appletviewer ) chmod 755 tools/appletviewer ;;
+    jarsigner ) chmod 755 tools/jarsigner ;;
+    keytool ) chmod 755 tools/keytool ;;
     gen-classlist ) chmod 755 lib/gen-classlist.sh ;;
     copy-vmresources ) chmod 755 lib/copy-vmresources.sh ;;
   esac
diff --git a/libjava/classpath/configure.ac b/libjava/classpath/configure.ac
index 658b37541de0..65980fdff058 100644
--- a/libjava/classpath/configure.ac
+++ b/libjava/classpath/configure.ac
@@ -6,7 +6,7 @@ dnl -----------------------------------------------------------
 dnl define([AC_CACHE_LOAD], )dnl
 dnl define([AC_CACHE_SAVE], )dnl
 
-AC_INIT([GNU Classpath],[0.91],[classpath@gnu.org],[classpath])
+AC_INIT([GNU Classpath],[0.92-pre],[classpath@gnu.org],[classpath])
 AC_CONFIG_SRCDIR(java/lang/System.java)
 
 AC_CANONICAL_TARGET
@@ -41,9 +41,6 @@ AM_INIT_AUTOMAKE([1.9.0 gnu std-options tar-ustar])
 AC_CONFIG_HEADERS([include/config.h])
 AC_PREFIX_DEFAULT(/usr/local/classpath)
 
-dnl GCC LOCAL
-GCC_NO_EXECUTABLES
-
 dnl -----------------------------------------------------------
 dnl Enable collections.jar (disabled by default)
 dnl -----------------------------------------------------------
@@ -168,23 +165,6 @@ dnl GTK native peer error checking
 dnl -----------------------------------------------------------
 AC_ARG_ENABLE([gtk-peers],,AC_MSG_ERROR([No --enable-gtk-peers (or --disable-gtk-peers) option; you want --enable-gtk-peer]))
 
-dnl ------------------------------------------------------------
-dnl determine whether to enable the cairo GTK Graphics2D backend
-dnl ------------------------------------------------------------
-AC_ARG_ENABLE([gtk-cairo],
-              [AS_HELP_STRING(--enable-gtk-cairo,build the cairo Graphics2D implementation on GTK [default=no])],
-              [case "${enableval}" in
-                yes) GTK_CAIRO_ENABLED=true ;;
-                no) GTK_CAIRO_ENABLED=false ;;
-                *) GTK_CAIRO_ENABLED=true ;;
-              esac],
-              [GTK_CAIRO_ENABLED=false])
-AC_SUBST(GTK_CAIRO_ENABLED)
-if test "x${GTK_CAIRO_ENABLED}" = xtrue; then
-  AC_DEFINE(GTK_CAIRO, 1, [defined if cairo support was built in])
-fi
-AM_CONDITIONAL(GTK_CAIRO, test "x${GTK_CAIRO_ENABLED}" = xtrue)
-
 dnl -----------------------------------------------------------
 dnl Qt native peer (disabled by default)
 dnl -----------------------------------------------------------
@@ -198,12 +178,24 @@ AC_ARG_ENABLE([qt-peer],
               [COMPILE_QT_PEER=no])
 AM_CONDITIONAL(CREATE_QT_PEER_LIBRARIES, test "x${COMPILE_QT_PEER}" = xyes)
 
+dnl -----------------------------------------------------------
+dnl Plugin (enabled by default)
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE([plugin],
+              [AS_HELP_STRING(--disable-plugin,compile gcjwebplugin (disabled by --disable-plugin) [default=yes])],
+              [case "${enableval}" in
+                yes) COMPILE_PLUGIN=yes ;;
+                no) COMPILE_PLUGIN=no ;;
+                *) COMPILE_PLUGIN=yes ;;
+              esac],
+              [COMPILE_PLUGIN=yes])
+AM_CONDITIONAL(CREATE_PLUGIN, test "x${COMPILE_PLUGIN}" = xyes)
 
 dnl -----------------------------------------------------------
 dnl Sets the native libraries installation dir
 dnl -----------------------------------------------------------
 AC_ARG_WITH([native-libdir],
-	    [AS_HELP_STRING(--with-native-libdir,sets the installation directore for native libraries [default='${libdir}/${PACKAGE}'])],
+	    [AS_HELP_STRING(--with-native-libdir,sets the installation directory for native libraries [default='${libdir}/${PACKAGE}'])],
 	    [
 	     nativeexeclibdir=${withval}
 	    ],
@@ -227,6 +219,21 @@ AC_ARG_WITH([glibj-dir],
 
 AC_SUBST(glibjdir)
 
+dnl -----------------------------------------------------------
+dnl Sets the VM name for use in tool wrapper scripts
+dnl -----------------------------------------------------------
+AC_ARG_WITH([vm],
+	    [AS_HELP_STRING(--with-vm,sets the VM binary name [default='${prefix}/bin/jamvm'])],
+	    [
+	     VM_BINARY=${withval}
+	    ],
+	    [
+	     VM_BINARY='${prefix}/bin/jamvm'
+	    ])
+
+AC_SUBST(VM_BINARY)
+AM_CONDITIONAL(FOUND_CACAO, test "x`basename $VM_BINARY`" = xcacao)
+
 dnl -----------------------------------------------------------
 dnl Regenerate headers at build time (disabled by default)
 dnl -----------------------------------------------------------
@@ -240,20 +247,33 @@ AC_ARG_ENABLE([regen-headers],
               [REGENERATE_JNI_HEADERS=no])
 AM_CONDITIONAL(CREATE_JNI_HEADERS, test "x${REGENERATE_JNI_HEADERS}" = xyes)
 
+dnl -----------------------------------------------------------
+dnl Enable tool wrapper binaries (disabled by default)
+dnl -----------------------------------------------------------
+AC_ARG_ENABLE([tool-wrappers],
+              [AS_HELP_STRING(--enable-tool-wrappers,create tool wrapper binaries [default=no])],
+              [case x"${enableval}" in
+                xyes) COMPILE_WRAPPERS=yes ;;
+                xno) COMPILE_WRAPPERS=no ;;
+		x) COMPILE_WRAPPERS=yes ;;
+                *) COMPILE_WRAPPERS=yes ;;
+              esac],
+              [COMPILE_WRAPPERS=no])
+AM_CONDITIONAL(CREATE_WRAPPERS, test "x${COMPILE_WRAPPERS}" = xyes)
+
 AC_PROG_LN_S
 AC_PROG_INSTALL
 
 dnl -----------------------------------------------------------
 dnl Checks for programs.
 dnl -----------------------------------------------------------
-
+AC_PROG_CXX
 dnl Initialize libtool
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 dnl AC_PROG_AWK
 AC_PROG_CC
 AC_PROG_CPP
-AC_PROG_CXX
 
 if test "x${COMPILE_COLLECTIONS}" = xyes; then
   AC_PATH_PROG(PERL, [perl])
@@ -284,7 +304,8 @@ if test "x${COMPILE_JNI}" = xyes; then
 		    sys/select.h \
 		    crt_externs.h \
                     fcntl.h \
-		    sys/mman.h])
+		    sys/mman.h \
+		    magic.h])
 
   AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
   AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t]))
@@ -300,8 +321,13 @@ if test "x${COMPILE_JNI}" = xyes; then
 		  strerror_r \
                   fcntl \
 		  mmap munmap mincore msync madvise getpagesize sysconf \
+		  lstat readlink \
 		  ])
 
+  LIBMAGIC=
+  AC_CHECK_LIB(magic, magic_open, LIBMAGIC=-lmagic)
+  AC_SUBST(LIBMAGIC)
+
   AC_HEADER_TIME
   AC_STRUCT_TM
   AC_STRUCT_TIMEZONE
@@ -375,26 +401,35 @@ if test "x${COMPILE_JNI}" = xyes; then
         AC_MSG_ERROR([GTK+ peers requested but no X library available])
     fi
     dnl We explicitly want the XTest Extension for Robot support.
-    AC_CHECK_LIB([Xtst], [XTestQueryExtension], [true],
-       	  [AC_MSG_ERROR([libXtst NOT found, required for GdkRobot])],
-       	  [${X_LIBS}])
-    PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.4 gthread-2.0 >= 2.2 gdk-pixbuf-2.0)
-
-    if test "x${enable_gtk_cairo}" = xyes; then
-      PKG_CHECK_MODULES(CAIRO, cairo >= 0.5.0)
-    fi
+    AC_CHECK_LIB([Xtst], [XTestQueryExtension],
+    		 [XTEST_LIBS="$XTEST_LIBS -lX11 -lXtst"],
+		 [AC_MSG_ERROR([libXtst NOT found, required for GdkRobot])],
+		 [${X_LIBS}])
 
+    PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.8 gthread-2.0 >= 2.2 gdk-pixbuf-2.0)
     PKG_CHECK_MODULES(FREETYPE2, freetype2)
     PKG_CHECK_MODULES(PANGOFT2, pangoft2)
+    dnl Check if we can link against the XRender library and set
+    dnl HAVE_XRENDER accordingly.
+    AC_CHECK_LIB([Xrender], [XRenderQueryExtension],
+		 [AC_DEFINE(HAVE_XRENDER, 1, [Define to 1 if you have libXrender.])[X_EXTRA_LIBS="$X_EXTRA_LIBS -lXrender"]],
+		 [true],
+		 [${X_LIBS}])
+
+    dnl Check if we can link against the XRandR library and set
+    dnl HAVE_XRANDR accordingly.
+    AC_CHECK_LIB([Xrandr], [XRRQueryExtension],
+                 [AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you have libXrandr.])[X_EXTRA_LIBS="$X_EXTRA_LIBS -lXrandr"]],
+                 [true],
+                 [${X_LIBS}])
 
     AC_SUBST(GTK_CFLAGS)
     AC_SUBST(GTK_LIBS)
-    AC_SUBST(CAIRO_LIBS)
-    AC_SUBST(CAIRO_CFLAGS)
     AC_SUBST(FREETYPE2_LIBS)
     AC_SUBST(FREETYPE2_CFLAGS)
     AC_SUBST(PANGOFT2_LIBS)
     AC_SUBST(PANGOFT2_CFLAGS)
+    AC_SUBST(XTEST_LIBS)
   fi
 
   dnl Check for AWT related Qt4
@@ -445,6 +480,25 @@ if test "x${COMPILE_JNI}" = xyes; then
     AC_SUBST(QT_CFLAGS)
     AC_SUBST(QT_LIBS)
   fi
+
+  dnl Check for plugin support headers and libraries.
+  if test "x${COMPILE_PLUGIN}" = xyes; then
+    PKG_CHECK_MODULES(MOZILLA, mozilla-plugin, [MOZILLA_FOUND=yes], [MOZILLA_FOUND=no])
+    if test "x${MOZILLA_FOUND}" = xno; then
+      PKG_CHECK_MODULES(MOZILLA, firefox-plugin, [MOZILLA_FOUND=yes], [MOZILLA_FOUND=no])
+    fi
+    if test "x${MOZILLA_FOUND}" = xno; then
+      PKG_CHECK_MODULES(MOZILLA, xulrunner-plugin, [MOZILLA_FOUND=yes], [MOZILLA_FOUND=no])
+    fi
+    PKG_CHECK_MODULES(GLIB, glib-2.0)
+
+    AC_SUBST(MOZILLA_CFLAGS)
+    AC_SUBST(MOZILLA_LIBS)
+    AC_SUBST(GLIB_CFLAGS)
+    AC_SUBST(GLIB_LIBS)
+
+    AC_SUBST(PLUGIN_DIR, $HOME/.mozilla/plugins/)
+  fi
 fi
 
 CLASSPATH_WITH_JAVAH
@@ -669,6 +723,7 @@ native/jni/qt-peer/Makefile
 native/jni/xmlj/Makefile
 native/jni/midi-alsa/Makefile
 native/jni/midi-dssi/Makefile
+native/plugin/Makefile
 native/target/Makefile
 native/target/Linux/Makefile
 native/target/generic/Makefile
@@ -679,10 +734,19 @@ lib/Makefile
 lib/gen-classlist.sh
 lib/copy-vmresources.sh
 tools/Makefile
-tools/jarsigner.sh
-tools/keytool.sh
 examples/Makefile
 examples/Makefile.jawt])
+
+if test "x${COMPILE_WRAPPERS}" = xno
+then
+AC_CONFIG_FILES([tools/appletviewer
+tools/jarsigner
+tools/keytool])
+AC_CONFIG_COMMANDS([appletviewer],[chmod 755 tools/appletviewer])
+AC_CONFIG_COMMANDS([jarsigner],[chmod 755 tools/jarsigner])
+AC_CONFIG_COMMANDS([keytool],[chmod 755 tools/keytool])
+fi
+
 AC_CONFIG_COMMANDS([gen-classlist],[chmod 755 lib/gen-classlist.sh])
 AC_CONFIG_COMMANDS([copy-vmresources],[chmod 755 lib/copy-vmresources.sh])
 AC_OUTPUT
diff --git a/libjava/classpath/doc/Makefile.in b/libjava/classpath/doc/Makefile.in
index 47c3c1dc7606..0a17afee1c19 100644
--- a/libjava/classpath/doc/Makefile.in
+++ b/libjava/classpath/doc/Makefile.in
@@ -73,8 +73,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -101,8 +99,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -125,6 +127,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -140,9 +144,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -164,6 +167,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -177,6 +181,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -190,6 +196,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -209,11 +216,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/doc/api/Makefile.in b/libjava/classpath/doc/api/Makefile.in
index c06cce091f0c..ad4956ce93c4 100644
--- a/libjava/classpath/doc/api/Makefile.in
+++ b/libjava/classpath/doc/api/Makefile.in
@@ -66,8 +66,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -94,8 +92,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -118,6 +120,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -133,9 +137,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -157,6 +160,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -170,6 +174,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -183,6 +189,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -202,11 +209,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/examples/Makefile.in b/libjava/classpath/examples/Makefile.in
index 629f9d4c3656..d8336a98bf30 100644
--- a/libjava/classpath/examples/Makefile.in
+++ b/libjava/classpath/examples/Makefile.in
@@ -75,8 +75,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -103,8 +101,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -127,6 +129,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -142,9 +146,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -166,6 +169,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -179,6 +183,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -192,6 +198,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -211,11 +218,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/external/Makefile.in b/libjava/classpath/external/Makefile.in
index ad85c8871e83..23279c2ee950 100644
--- a/libjava/classpath/external/Makefile.in
+++ b/libjava/classpath/external/Makefile.in
@@ -73,8 +73,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -101,8 +99,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -125,6 +127,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -140,9 +144,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -164,6 +167,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -177,6 +181,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -190,6 +196,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -209,11 +216,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/external/relaxngDatatype/Makefile.in b/libjava/classpath/external/relaxngDatatype/Makefile.in
index 0bc5dd17e0f8..cc063ac9b67f 100644
--- a/libjava/classpath/external/relaxngDatatype/Makefile.in
+++ b/libjava/classpath/external/relaxngDatatype/Makefile.in
@@ -64,8 +64,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -92,8 +90,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -116,6 +118,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -131,9 +135,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -155,6 +158,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -168,6 +172,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -181,6 +187,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -200,11 +207,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/external/sax/Makefile.in b/libjava/classpath/external/sax/Makefile.in
index 50297ac8e98b..cd04e16ff077 100644
--- a/libjava/classpath/external/sax/Makefile.in
+++ b/libjava/classpath/external/sax/Makefile.in
@@ -64,8 +64,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -92,8 +90,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -116,6 +118,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -131,9 +135,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -155,6 +158,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -168,6 +172,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -181,6 +187,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -200,11 +207,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/external/w3c_dom/Makefile.in b/libjava/classpath/external/w3c_dom/Makefile.in
index e0fdf37c1c27..7e61f759deeb 100644
--- a/libjava/classpath/external/w3c_dom/Makefile.in
+++ b/libjava/classpath/external/w3c_dom/Makefile.in
@@ -64,8 +64,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -92,8 +90,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -116,6 +118,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -131,9 +135,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -155,6 +158,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -168,6 +172,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -181,6 +187,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -200,11 +207,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/gnu/classpath/Configuration.java.in b/libjava/classpath/gnu/classpath/Configuration.java.in
index 569ccf541ffa..7f490d529519 100644
--- a/libjava/classpath/gnu/classpath/Configuration.java.in
+++ b/libjava/classpath/gnu/classpath/Configuration.java.in
@@ -95,10 +95,4 @@ public interface Configuration
    */
   boolean JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = 
 	  @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@;
-
-  /**
-   * Set to true if Cairo was found and enabled during configure,
-   * false otherwise.
-   */
-  boolean GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@;
 }
diff --git a/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java b/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java
index b568e1108c1d..9205df1ddbde 100644
--- a/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java
+++ b/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java
@@ -59,7 +59,7 @@ import java.awt.image.WritableRaster;
  * />
  *
  * <p>The above screen shot shows the result of applying six different
- * BitwiseXORComposites. They were constructed with the colors colors
+ * BitwiseXORComposites. They were constructed with the colors
  * white, blue, black, orange, green, and brown, respectively. Each
  * composite was used to paint a fully white rectangle on top of the
  * blue bar in the background.
diff --git a/libjava/classpath/gnu/java/awt/Buffers.java b/libjava/classpath/gnu/java/awt/Buffers.java
index c6ccf9191451..2015634bbf5d 100644
--- a/libjava/classpath/gnu/java/awt/Buffers.java
+++ b/libjava/classpath/gnu/java/awt/Buffers.java
@@ -144,25 +144,7 @@ public final class Buffers
    */
   public static Object getData(DataBuffer buffer)
   {
-    if (buffer instanceof DataBufferByte)
-      return ((DataBufferByte) buffer).getData();
-
-    if (buffer instanceof DataBufferShort)
-      return ((DataBufferShort) buffer).getData();
-
-    if (buffer instanceof DataBufferUShort)
-      return ((DataBufferUShort) buffer).getData();
-
-    if (buffer instanceof DataBufferInt)
-      return ((DataBufferInt) buffer).getData();
-
-    if (buffer instanceof DataBufferFloat)
-      return ((DataBufferFloat) buffer).getData();
-
-    if (buffer instanceof DataBufferDouble)
-      return ((DataBufferDouble) buffer).getData();
-
-    throw new ClassCastException("Unknown data buffer type");
+    return getData(buffer, 0, null, 0, buffer.getSize());
   }
 
     
@@ -172,46 +154,46 @@ public final class Buffers
    * given destination array is null.
    */
   public static Object getData(DataBuffer src, int srcOffset,
-			       Object dest,  int destOffset,
+			       Object dest,  int dstOffset,
 			       int length)
   {
     Object from;
-    if (src instanceof DataBufferByte)
-      {
-	from = ((DataBufferByte) src).getData();
-	if (dest == null) dest = new byte[length+destOffset];
-      }
-    else if (src instanceof DataBufferShort)
-      {
-	from = ((DataBufferShort) src).getData();
-	if (dest == null) dest = new short[length+destOffset];
-      }
-    else if (src instanceof DataBufferUShort)
-      {
-	from = ((DataBufferUShort) src).getData();
-	if (dest == null) dest = new short[length+destOffset];
-      }
-    else if (src instanceof DataBufferInt)
-      {
-	from = ((DataBufferInt) src).getData();
-	if (dest == null) dest = new int[length+destOffset];
-      }
-    else if (src instanceof DataBufferFloat)
-      {
-	from = ((DataBufferFloat) src).getData();
-	if (dest == null) dest = new float[length+destOffset];
-      }
-    else if (src instanceof DataBufferDouble)
-      {
-	from = ((DataBufferDouble) src).getData();
-	if (dest == null) dest = new double[length+destOffset];
-      }
-    else
+    switch(src.getDataType())
       {
+      case DataBuffer.TYPE_BYTE:
+	if (dest == null) dest = new byte[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((byte[])dest)[i + dstOffset] = (byte)src.getElem(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_DOUBLE:
+	if (dest == null) dest = new double[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((double[])dest)[i + dstOffset] = src.getElemDouble(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_FLOAT:
+	if (dest == null) dest = new float[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((float[])dest)[i + dstOffset] = src.getElemFloat(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_INT:
+	if (dest == null) dest = new int[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((int[])dest)[i + dstOffset] = src.getElem(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_SHORT:
+      case DataBuffer.TYPE_USHORT:
+	if (dest == null) dest = new short[length+dstOffset];
+	for(int i = 0; i < length; i++)
+	  ((short[])dest)[i + dstOffset] = (short)src.getElem(i + srcOffset);
+	break;
+
+      case DataBuffer.TYPE_UNDEFINED:
 	throw new ClassCastException("Unknown data buffer type");
       }
-    
-    System.arraycopy(from, srcOffset, dest, destOffset, length);
     return dest;
   }
   
diff --git a/libjava/classpath/gnu/java/awt/font/GNUGlyphVector.java b/libjava/classpath/gnu/java/awt/font/GNUGlyphVector.java
index 9688698de192..f17a4511375d 100644
--- a/libjava/classpath/gnu/java/awt/font/GNUGlyphVector.java
+++ b/libjava/classpath/gnu/java/awt/font/GNUGlyphVector.java
@@ -110,7 +110,7 @@ public class GNUGlyphVector
     
     fontSize = font.getSize2D();
     transform = font.getTransform(); // returns a modifiable copy
-    transform.concatenate(renderContext.getTransform());
+    //transform.concatenate(renderContext.getTransform());
   }
 
 
diff --git a/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java b/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java
index bc0c0df09955..e4ea202bb6ca 100644
--- a/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java
+++ b/libjava/classpath/gnu/java/awt/font/opentype/NameDecoder.java
@@ -48,7 +48,7 @@ import java.util.Locale;
  *
  * @author Sascha Brawer (brawer@dandelis.ch)
  */
-class NameDecoder
+public class NameDecoder
 {
   public static final int NAME_COPYRIGHT = 0;
 
@@ -122,27 +122,38 @@ class NameDecoder
 
     nameTable.position(0);
     /* We understand only format 0 of the name table. */
-    if (nameTable.getChar() != 0)
+    if (nameTable.getShort() != 0)
       return null;
 
     macLanguage = getMacLanguageCode(locale);
     msLanguage = getMicrosoftLanguageCode(locale);
-    numRecords = nameTable.getChar();
-    offset = nameTable.getChar();
+    numRecords = nameTable.getShort();
+    offset = nameTable.getShort();
 
     for (int i = 0; i < numRecords; i++)
     {
-      namePlatform = nameTable.getChar();
-      nameEncoding = nameTable.getChar();
-      nameLanguage = nameTable.getChar();
-      nameID = nameTable.getChar();
-      nameLen = nameTable.getChar();
-      nameStart = offset + nameTable.getChar();
+      namePlatform = nameTable.getShort();
+      nameEncoding = nameTable.getShort();
+      nameLanguage = nameTable.getShort();
+      nameID = nameTable.getShort();
+      nameLen = nameTable.getShort();
+      nameStart = offset + nameTable.getShort();
 
       
       if (nameID != name)
         continue;
 
+      // Handle PS seperately as it can be only ASCII, although
+      // possibly encoded as UTF-16BE
+      if ( name == NAME_POSTSCRIPT )
+	{
+	  if( nameTable.get(nameStart) == 0 ) // Peek at top byte
+	    result = decodeName("UTF-16BE", nameTable, nameStart, nameLen);
+	  else
+	    result = decodeName("ASCII", nameTable, nameStart, nameLen);
+	  return result;
+	}
+
       match = false;
       switch (namePlatform)
       {
@@ -393,14 +404,19 @@ class NameDecoder
   private static String decodeName(int platform, int encoding, int language,
                                    ByteBuffer buffer, int offset, int len)
   {
-    byte[] byteBuf;
-    String charsetName;
-    int oldPosition;
-
-    charsetName = getCharsetName(platform, language, encoding);
+    String charsetName = getCharsetName(platform, language, encoding);
     if (charsetName == null)
       return null;
 
+    return decodeName(charsetName, buffer, offset, len);
+  }
+
+  private static String decodeName(String charsetName,
+                                   ByteBuffer buffer, int offset, int len)
+  {
+    byte[] byteBuf;
+    int oldPosition;
+
     byteBuf = new byte[len];
     oldPosition = buffer.position();
     try
diff --git a/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java b/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java
index e93c43e08afa..7df9949e68e9 100644
--- a/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java
+++ b/libjava/classpath/gnu/java/awt/java2d/AbstractGraphics2D.java
@@ -84,7 +84,48 @@ import java.util.Iterator;
 import java.util.Map;
 
 /**
- * Implements general and shared behaviour for Graphics2D implementation.
+ * This is a 100% Java implementation of the Java2D rendering pipeline. It is
+ * meant as a base class for Graphics2D implementations.
+ *
+ * <h2>Backend interface</h2>
+ * <p>
+ * The backend must at the very least provide a Raster which the the rendering
+ * pipeline can paint into. This must be implemented in
+ * {@link #getDestinationRaster()}. For some backends that might be enough, like
+ * when the target surface can be directly access via the raster (like in
+ * BufferedImages). Other targets need some way to synchronize the raster with
+ * the surface, which can be achieved by implementing the
+ * {@link #updateRaster(Raster, int, int, int, int)} method, which always gets
+ * called after a chunk of data got painted into the raster.
+ * </p>
+ * <p>The backend is free to provide implementations for the various raw*
+ * methods for optimized AWT 1.1 style painting of some primitives. This should
+ * accelerate painting of Swing greatly. When doing so, the backend must also
+ * keep track of the clip and translation, probably by overriding
+ * some clip and translate methods. Don't forget to message super in such a
+ * case.</p>
+ *
+ * <h2>Acceleration options</h2>
+ * <p>
+ * The fact that it is
+ * pure Java makes it a little slow. However, there are several ways of
+ * accelerating the rendering pipeline:
+ * <ol>
+ * <li><em>Optimization hooks for AWT 1.1 - like graphics operations.</em>
+ *   The most important methods from the {@link java.awt.Graphics} class
+ *   have a corresponding <code>raw*</code> method, which get called when
+ *   several optimization conditions are fullfilled. These conditions are
+ *   described below. Subclasses can override these methods and delegate
+ *   it directly to a native backend.</li>
+ * <li><em>Native PaintContexts and CompositeContext.</em> The implementations
+ *   for the 3 PaintContexts and AlphaCompositeContext can be accelerated
+ *   using native code. These have proved to two of the most performance
+ *   critical points in the rendering pipeline and cannot really be done quickly
+ *   in plain Java because they involve lots of shuffling around with large
+ *   arrays. In fact, you really would want to let the graphics card to the
+ *   work, they are made for this.</li>
+ * </ol>
+ * </p>
  *
  * @author Roman Kennke (kennke@aicas.com)
  */
@@ -145,11 +186,6 @@ public abstract class AbstractGraphics2D
    */
   private Raster paintRaster;
 
-  /**
-   * A cached pixel array.
-   */
-  private int[] pixel;
-
   /**
    * The raster of the destination surface. This is where the painting is
    * performed.
@@ -168,7 +204,7 @@ public abstract class AbstractGraphics2D
   private transient ArrayList[] edgeTable;
 
   /**
-   * Indicates if cerain graphics primitives can be rendered in an optimized
+   * Indicates if certain graphics primitives can be rendered in an optimized
    * fashion. This will be the case if the following conditions are met:
    * - The transform may only be a translation, no rotation, shearing or
    *   scaling.
@@ -198,8 +234,6 @@ public abstract class AbstractGraphics2D
     hints.put(RenderingHints.KEY_ANTIALIASING,
               RenderingHints.VALUE_ANTIALIAS_DEFAULT);
     renderingHints = new RenderingHints(hints);
-
-    pixel = new int[4];
   }
 
   /**
@@ -212,40 +246,211 @@ public abstract class AbstractGraphics2D
   {
     // Stroke the shape.
     Shape strokedShape = stroke.createStrokedShape(shape);
-
-    // Clip the stroked shape.
-//    Shape clipped = clipShape(strokedShape);
-//    if (clipped != null)
-//      {
-//        // Fill the shape.
-//        fillShape(clipped, false);
-//      }
-    // FIXME: Clipping doesn't seem to work.
+    // Fill the stroked shape.
     fillShape(strokedShape, false);
   }
 
-  public boolean drawImage(Image image, AffineTransform xform, ImageObserver obs)
+
+  /**
+   * Draws the specified image and apply the transform for image space ->
+   * user space conversion.
+   *
+   * This method is implemented to special case RenderableImages and
+   * RenderedImages and delegate to
+   * {@link #drawRenderableImage(RenderableImage, AffineTransform)} and
+   * {@link #drawRenderedImage(RenderedImage, AffineTransform)} accordingly.
+   * Other image types are not yet handled.
+   *
+   * @param image the image to be rendered
+   * @param xform the transform from image space to user space
+   * @param obs the image observer to be notified
+   */
+  public boolean drawImage(Image image, AffineTransform xform,
+                           ImageObserver obs)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    boolean ret = false;
+    Rectangle areaOfInterest = new Rectangle(0, 0, image.getWidth(obs),
+                                             image.getHeight(obs));
+    return drawImageImpl(image, xform, obs, areaOfInterest);
+  }
+
+  /**
+   * Draws the specified image and apply the transform for image space ->
+   * user space conversion. This method only draw the part of the image
+   * specified by <code>areaOfInterest</code>.
+   *
+   * This method is implemented to special case RenderableImages and
+   * RenderedImages and delegate to
+   * {@link #drawRenderableImage(RenderableImage, AffineTransform)} and
+   * {@link #drawRenderedImage(RenderedImage, AffineTransform)} accordingly.
+   * Other image types are not yet handled.
+   *
+   * @param image the image to be rendered
+   * @param xform the transform from image space to user space
+   * @param obs the image observer to be notified
+   * @param areaOfInterest the area in image space that is rendered
+   */
+  private boolean drawImageImpl(Image image, AffineTransform xform,
+                             ImageObserver obs, Rectangle areaOfInterest)
+  {
+    boolean ret;
+    if (image == null)
+      {
+        ret = true;
+      }
+    else if (image instanceof RenderedImage)
+      {
+        // FIXME: Handle the ImageObserver.
+        drawRenderedImageImpl((RenderedImage) image, xform, areaOfInterest);
+        ret = true;
+      }
+    else if (image instanceof RenderableImage)
+      {
+        // FIXME: Handle the ImageObserver.
+        drawRenderableImageImpl((RenderableImage) image, xform, areaOfInterest);
+        ret = true;
+      }
+    else
+      {
+        // FIXME: Implement rendering of other Image types.
+        ret = false;
+      }
+    return ret;
   }
 
+  /**
+   * Renders a BufferedImage and applies the specified BufferedImageOp before
+   * to filter the BufferedImage somehow. The resulting BufferedImage is then
+   * passed on to {@link #drawRenderedImage(RenderedImage, AffineTransform)}
+   * to perform the final rendering.
+   *
+   * @param image the source buffered image
+   * @param op the filter to apply to the buffered image before rendering
+   * @param x the x coordinate to render the image to 
+   * @param y the y coordinate to render the image to 
+   */
   public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    BufferedImage filtered =
+      op.createCompatibleDestImage(image, image.getColorModel());
+    AffineTransform t = new AffineTransform();
+    t.translate(x, y);
+    drawRenderedImage(filtered, t);
   }
 
+  /**
+   * Renders the specified image to the destination raster. The specified
+   * transform is used to convert the image into user space. The transform
+   * of this AbstractGraphics2D object is used to transform from user space
+   * to device space.
+   * 
+   * The rendering is performed using the scanline algorithm that performs the
+   * rendering of other shapes and a custom Paint implementation, that supplies
+   * the pixel values of the rendered image.
+   *
+   * @param image the image to render to the destination raster
+   * @param xform the transform from image space to user space
+   */
   public void drawRenderedImage(RenderedImage image, AffineTransform xform)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    Rectangle areaOfInterest = new Rectangle(image.getMinX(),
+                                             image.getHeight(),
+                                             image.getWidth(),
+                                             image.getHeight());
+    drawRenderedImageImpl(image, xform, areaOfInterest);
+  }
+
+  /**
+   * Renders the specified image to the destination raster. The specified
+   * transform is used to convert the image into user space. The transform
+   * of this AbstractGraphics2D object is used to transform from user space
+   * to device space. Only the area specified by <code>areaOfInterest</code>
+   * is finally rendered to the target.
+   * 
+   * The rendering is performed using the scanline algorithm that performs the
+   * rendering of other shapes and a custom Paint implementation, that supplies
+   * the pixel values of the rendered image.
+   *
+   * @param image the image to render to the destination raster
+   * @param xform the transform from image space to user space
+   */
+  private void drawRenderedImageImpl(RenderedImage image,
+                                     AffineTransform xform,
+                                     Rectangle areaOfInterest)
+  {
+    // First we compute the transformation. This is made up of 3 parts:
+    // 1. The areaOfInterest -> image space transform.
+    // 2. The image space -> user space transform.
+    // 3. The user space -> device space transform.
+    AffineTransform t = new AffineTransform();
+    t.translate(- areaOfInterest.x - image.getMinX(),
+                - areaOfInterest.y - image.getMinY());
+    t.concatenate(xform);
+    t.concatenate(transform);
+    AffineTransform it = null;
+    try
+      {
+        it = t.createInverse();
+      }
+    catch (NoninvertibleTransformException ex)
+      {
+        // Ignore -- we return if the transform is not invertible.
+      }
+    if (it != null)
+      {
+        // Transform the area of interest into user space.
+        GeneralPath aoi = new GeneralPath(areaOfInterest);
+        aoi.transform(xform);
+        // Render the shape using the standard renderer, but with a temporary
+        // ImagePaint.
+        ImagePaint p = new ImagePaint(image, it);
+        Paint savedPaint = paint;
+        try
+          {
+            paint = p;
+            fillShape(aoi, false);
+          }
+        finally
+          {
+            paint = savedPaint;
+          }
+      }
   }
 
+  /**
+   * Renders a renderable image. This produces a RenderedImage, which is
+   * then passed to {@link #drawRenderedImage(RenderedImage, AffineTransform)}
+   * to perform the final rendering.
+   *
+   * @param image the renderable image to be rendered
+   * @param xform the transform from image space to user space
+   */
   public void drawRenderableImage(RenderableImage image, AffineTransform xform)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    Rectangle areaOfInterest = new Rectangle((int) image.getMinX(),
+                                             (int) image.getHeight(),
+                                             (int) image.getWidth(),
+                                             (int) image.getHeight());
+    drawRenderableImageImpl(image, xform, areaOfInterest);
+                                                       
+  }
+
+  /**
+   * Renders a renderable image. This produces a RenderedImage, which is
+   * then passed to {@link #drawRenderedImage(RenderedImage, AffineTransform)}
+   * to perform the final rendering. Only the area of the image specified
+   * by <code>areaOfInterest</code> is rendered.
+   *
+   * @param image the renderable image to be rendered
+   * @param xform the transform from image space to user space
+   */
+  private void drawRenderableImageImpl(RenderableImage image,
+                                       AffineTransform xform,
+                                       Rectangle areaOfInterest)
+  {
+    // TODO: Maybe make more clever usage of a RenderContext here.
+    RenderedImage rendered = image.createDefaultRendering();
+    drawRenderedImageImpl(rendered, xform, areaOfInterest);
   }
 
   /**
@@ -257,9 +462,14 @@ public abstract class AbstractGraphics2D
    */
   public void drawString(String text, int x, int y)
   {
-    FontRenderContext ctx = getFontRenderContext();
-    GlyphVector gv = font.createGlyphVector(ctx, text.toCharArray());
-    drawGlyphVector(gv, x, y);
+    if (isOptimized)
+      rawDrawString(text, x, y);
+    else
+      {
+        FontRenderContext ctx = getFontRenderContext();
+        GlyphVector gv = font.createGlyphVector(ctx, text.toCharArray());
+        drawGlyphVector(gv, x, y);
+      }
   }
 
   /**
@@ -313,9 +523,6 @@ public abstract class AbstractGraphics2D
    */
   public void fill(Shape shape)
   {
-//    Shape clipped = clipShape(shape);
-//    if (clipped != null)
-//      fillShape(clipped, false);
     fillShape(shape, false);
   }
 
@@ -355,7 +562,6 @@ public abstract class AbstractGraphics2D
         else
           {
             updateOptimization();
-            rawSetForeground((Color) paint);
           }
       }
   }
@@ -537,7 +743,7 @@ public abstract class AbstractGraphics2D
     if (clip != null)
       {
         AffineTransform clipTransform = new AffineTransform();
-        clipTransform.scale(-scaleX, -scaleY);
+        clipTransform.scale(1 / scaleX, 1 / scaleY);
         updateClip(clipTransform);
       }
     updateOptimization();
@@ -712,8 +918,7 @@ public abstract class AbstractGraphics2D
 
   public FontRenderContext getFontRenderContext()
   {
-    //return new FontRenderContext(transform, false, false);
-    return new FontRenderContext(new AffineTransform(), false, false);
+    return new FontRenderContext(transform, false, true);
   }
 
   /**
@@ -726,22 +931,15 @@ public abstract class AbstractGraphics2D
   public void drawGlyphVector(GlyphVector gv, float x, float y)
   {
     int numGlyphs = gv.getNumGlyphs();
-    AffineTransform t = new AffineTransform();
-    t.translate(x, y);
-
-//    // TODO: We could use fill(gv.getOutline()), but that seems to be
-      // slightly more inefficient. 
+    translate(x, y);
+    // TODO: We could use fill(gv.getOutline()), but that seems to be
+    // slightly more inefficient.
     for (int i = 0; i < numGlyphs; i++)
     {
-      //fill(gv.getGlyphVisualBounds(i));
-      GeneralPath p = new GeneralPath(gv.getGlyphOutline(i));
-      p.transform(t);
-      //Shape clipped = clipShape(p);
-      //if (clipped != null)
-      //  fillShape(clipped, true);
-      // FIXME: Clipping doesn't seem to work correctly.
-      fillShape(p, true);
+      Shape o = gv.getGlyphOutline(i);
+      fillShape(o, true);
     }
+    translate(-x, -y);
   }
 
   /**
@@ -918,8 +1116,10 @@ public abstract class AbstractGraphics2D
 
   public void copyArea(int x, int y, int width, int height, int dx, int dy)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    if (isOptimized)
+      rawCopyArea(x, y, width, height, dx, dy);
+    else
+      copyAreaImpl(x, y, width, height, dx, dy);
   }
 
   /**
@@ -978,11 +1178,15 @@ public abstract class AbstractGraphics2D
    */
   public void clearRect(int x, int y, int width, int height)
   {
-    Paint savedForeground = getPaint();
-    setPaint(getBackground());
-    //System.err.println("clearRect transform type: " + transform.getType());
-    fillRect(x, y, width, height);
-    setPaint(savedForeground);
+    if (isOptimized)
+      rawClearRect(x, y, width, height);
+    else
+      {
+        Paint savedForeground = getPaint();
+        setPaint(getBackground());
+        fillRect(x, y, width, height);
+        setPaint(savedForeground);
+      }
   }
 
   /**
@@ -1087,47 +1291,153 @@ public abstract class AbstractGraphics2D
     fill(new Polygon(xPoints, yPoints, npoints));
   }
 
+  /**
+   * Draws the specified image at the specified location. This forwards
+   * to {@link #drawImage(Image, AffineTransform, ImageObserver)}.
+   *
+   * @param image the image to render
+   * @param x the x location to render to
+   * @param y the y location to render to
+   * @param observer the image observer to receive notification
+   */
   public boolean drawImage(Image image, int x, int y, ImageObserver observer)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    boolean ret;
+    if (isOptimized)
+      ret = rawDrawImage(image, x, y, observer);
+    else
+      {
+        AffineTransform t = new AffineTransform();
+        t.translate(x, y);
+        ret = drawImage(image, t, observer);
+      }
+    return ret;
   }
 
+  /**
+   * Draws the specified image at the specified location. The image
+   * is scaled to the specified width and height. This forwards
+   * to {@link #drawImage(Image, AffineTransform, ImageObserver)}.
+   *
+   * @param image the image to render
+   * @param x the x location to render to
+   * @param y the y location to render to
+   * @param width the target width of the image
+   * @param height the target height of the image
+   * @param observer the image observer to receive notification
+   */
   public boolean drawImage(Image image, int x, int y, int width, int height,
                            ImageObserver observer)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    AffineTransform t = new AffineTransform();
+    t.translate(x, y);
+    double scaleX = (double) image.getWidth(observer) / (double) width;
+    double scaleY = (double) image.getHeight(observer) / (double) height;
+    t.scale(scaleX, scaleY);
+    return drawImage(image, t, observer);
   }
 
+  /**
+   * Draws the specified image at the specified location. This forwards
+   * to {@link #drawImage(Image, AffineTransform, ImageObserver)}.
+   *
+   * @param image the image to render
+   * @param x the x location to render to
+   * @param y the y location to render to
+   * @param bgcolor the background color to use for transparent pixels
+   * @param observer the image observer to receive notification
+   */
   public boolean drawImage(Image image, int x, int y, Color bgcolor,
                            ImageObserver observer)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    AffineTransform t = new AffineTransform();
+    t.translate(x, y);
+    // TODO: Somehow implement the background option.
+    return drawImage(image, t, observer);
   }
 
+  /**
+   * Draws the specified image at the specified location. The image
+   * is scaled to the specified width and height. This forwards
+   * to {@link #drawImage(Image, AffineTransform, ImageObserver)}.
+   *
+   * @param image the image to render
+   * @param x the x location to render to
+   * @param y the y location to render to
+   * @param width the target width of the image
+   * @param height the target height of the image
+   * @param bgcolor the background color to use for transparent pixels
+   * @param observer the image observer to receive notification
+   */
   public boolean drawImage(Image image, int x, int y, int width, int height,
                            Color bgcolor, ImageObserver observer)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    AffineTransform t = new AffineTransform();
+    t.translate(x, y);
+    double scaleX = (double) image.getWidth(observer) / (double) width;
+    double scaleY = (double) image.getHeight(observer) / (double) height;
+    t.scale(scaleX, scaleY);
+    // TODO: Somehow implement the background option.
+    return drawImage(image, t, observer);
   }
 
+  /**
+   * Draws an image fragment to a rectangular area of the target.
+   *
+   * @param image the image to render
+   * @param dx1 the first corner of the destination rectangle
+   * @param dy1 the first corner of the destination rectangle
+   * @param dx2 the second corner of the destination rectangle
+   * @param dy2 the second corner of the destination rectangle
+   * @param sx1 the first corner of the source rectangle
+   * @param sy1 the first corner of the source rectangle
+   * @param sx2 the second corner of the source rectangle
+   * @param sy2 the second corner of the source rectangle
+   * @param observer the image observer to be notified
+   */
   public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2,
                            int sx1, int sy1, int sx2, int sy2,
                            ImageObserver observer)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    int sx = Math.min(sx1, sx1);
+    int sy = Math.min(sy1, sy2);
+    int sw = Math.abs(sx1 - sx2);
+    int sh = Math.abs(sy1 - sy2);
+    int dx = Math.min(dx1, dx1);
+    int dy = Math.min(dy1, dy2);
+    int dw = Math.abs(dx1 - dx2);
+    int dh = Math.abs(dy1 - dy2);
+    
+    AffineTransform t = new AffineTransform();
+    t.translate(sx - dx, sy - dy);
+    double scaleX = (double) sw / (double) dw;
+    double scaleY = (double) sh / (double) dh;
+    t.scale(scaleX, scaleY);
+    Rectangle areaOfInterest = new Rectangle(sx, sy, sw, sh);
+    return drawImageImpl(image, t, observer, areaOfInterest);
   }
 
+  /**
+   * Draws an image fragment to a rectangular area of the target.
+   *
+   * @param image the image to render
+   * @param dx1 the first corner of the destination rectangle
+   * @param dy1 the first corner of the destination rectangle
+   * @param dx2 the second corner of the destination rectangle
+   * @param dy2 the second corner of the destination rectangle
+   * @param sx1 the first corner of the source rectangle
+   * @param sy1 the first corner of the source rectangle
+   * @param sx2 the second corner of the source rectangle
+   * @param sy2 the second corner of the source rectangle
+   * @param bgcolor the background color to use for transparent pixels
+   * @param observer the image observer to be notified
+   */
   public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2,
                            int sx1, int sy1, int sx2, int sy2, Color bgcolor,
                            ImageObserver observer)
   {
-    // FIXME: Implement this.
-    throw new UnsupportedOperationException("Not yet implemented");
+    // FIXME: Do something with bgcolor.
+    return drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
   }
 
   /**
@@ -1154,8 +1464,8 @@ public abstract class AbstractGraphics2D
         Object v = renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
         // We default to antialiasing on for text as long as we have no
         // good hinting implemented.
-        antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON
-                     || v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
+        antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+                     //|| v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
       }
     else
       {
@@ -1163,237 +1473,150 @@ public abstract class AbstractGraphics2D
         antialias = (v == RenderingHints.VALUE_ANTIALIAS_ON);
       }
 
-    Rectangle2D userBounds = s.getBounds2D();
-
-    // Flatten the path. TODO: Determine the best flattening factor
-    // wrt to speed and quality.
-    PathIterator path = s.getPathIterator(getTransform(), 1.0);
-
-    // Build up polygons and let the native backend render this using
-    // rawFillShape() which would provide a default implementation for
-    // drawPixel using a PolyScan algorithm.
-    double[] seg = new double[6];
-
-    // TODO: Use ArrayList<PolyEdge> here when availble.
-    ArrayList segs = new ArrayList();
-    double segX = 0.; // The start point of the current edge.
-    double segY = 0.; 
-    double polyX = 0.; // The start point of the current polygon.
-    double polyY = 0.;
-
-    double minX = Integer.MAX_VALUE;
-    double maxX = Integer.MIN_VALUE;
-    double minY = Integer.MAX_VALUE;
-    double maxY = Integer.MIN_VALUE;
+    double offs = 0.5;
+    if (antialias)
+      offs = offs / AA_SAMPLING;
 
-    //System.err.println("fill polygon");
-    while (! path.isDone())
-      {
-        int segType = path.currentSegment(seg);
-        minX = Math.min(minX, seg[0]);
-        maxX = Math.max(maxX, seg[0]);
-        minY = Math.min(minY, seg[1]);
-        maxY = Math.max(maxY, seg[1]);
-
-        //System.err.println("segment: " + segType + ", " + seg[0] + ", " + seg[1]);
-        if (segType == PathIterator.SEG_MOVETO)
-          {
-            segX = seg[0];
-            segY = seg[1];
-            polyX = seg[0];
-            polyY = seg[1];
-          }
-        else if (segType == PathIterator.SEG_CLOSE)
-          {
-            // Close the polyline.
-            PolyEdge edge = new PolyEdge(segX, segY, polyX, polyY);
-            segs.add(edge);
-          }
-        else if (segType == PathIterator.SEG_LINETO)
-          {
-            PolyEdge edge = new PolyEdge(segX, segY, seg[0], seg[1]);
-            segs.add(edge);
-            segX = seg[0];
-            segY = seg[1];
-          }
-        path.next();
-      }
+    Rectangle2D userBounds = s.getBounds2D();
+    Rectangle2D deviceBounds = new Rectangle2D.Double();
+    ArrayList segs = getSegments(s, transform, deviceBounds, false, offs);
+    Rectangle2D clipBounds = new Rectangle2D.Double();
+    ArrayList clipSegs = getSegments(clip, transform, clipBounds, true, offs);
+    segs.addAll(clipSegs);
+    Rectangle2D inclClipBounds = new Rectangle2D.Double();
+    Rectangle2D.union(clipBounds, deviceBounds, inclClipBounds);
     if (segs.size() > 0)
       {
         if (antialias)
-          fillShapeAntialias(segs, minX, minY, maxX, maxY, userBounds);
+          fillShapeAntialias(segs, deviceBounds, userBounds, inclClipBounds);
         else
-          rawFillShape(segs, minX, minY, maxX, maxY, userBounds);
+          fillShapeImpl(segs, deviceBounds, userBounds, inclClipBounds);
       }
   }
 
   /**
-   * Draws one pixel in the target coordinate space. This method draws the
-   * specified pixel by getting the painting pixel for that coordinate
-   * from the paintContext and compositing the pixel with the compositeContext.
-   * The resulting pixel is then set by calling {@link #rawSetPixel}.
+   * Returns the color model of this Graphics object.
    *
-   * @param x the x coordinate
-   * @param y the y coordinate
+   * @return the color model of this Graphics object
    */
-  protected void drawPixel(int x, int y)
-  {
-    // FIXME: Implement efficient compositing.
-    if (! (paint instanceof Color))
-      {
-        int[] paintPixel = paintRaster.getPixel(x, y, pixel);
-        Color c = new Color(paintPixel[0], paintPixel[1], paintPixel[2]);
-        rawSetForeground(c);
-      }
-    rawSetPixel(x, y);
-  }
+  protected abstract ColorModel getColorModel();
 
   /**
-   * Draws a pixel in the target coordinate space using the specified color.
-   * 
-   * @param x the x coordinate
-   * @param y the y coordinate
+   * Returns the bounds of the target.
+   *
+   * @return the bounds of the target
    */
-  protected void rawSetPixel(int x, int y)
+  protected Rectangle getDeviceBounds()
   {
-    // FIXME: Provide default implementation or remove method.
+    return destinationRaster.getBounds();
   }
 
   /**
-   * Sets the foreground color for drawing.
+   * Draws a line in optimization mode. The implementation should respect the
+   * clip and translation. It can assume that the clip is a rectangle and that
+   * the transform is only a translating transform.
    *
-   * @param c the color to set
+   * @param x0 the starting point, X coordinate
+   * @param y0 the starting point, Y coordinate
+   * @param x1 the end point, X coordinate 
+   * @param y1 the end point, Y coordinate
    */
-  protected void rawSetForeground(Color c)
-  {
-    // Probably remove method.
-  }
-
-  protected void rawSetForeground(int r, int g, int b)
+  protected void rawDrawLine(int x0, int y0, int x1, int y1)
   {
-    rawSetForeground(new Color(r, g, b));
+    draw(new Line2D.Float(x0, y0, x1, y1));
   }
 
   /**
-   * Returns the color model of this Graphics object.
+   * Draws a string in optimization mode. The implementation should respect the
+   * clip and translation. It can assume that the clip is a rectangle and that
+   * the transform is only a translating transform.
    *
-   * @return the color model of this Graphics object
+   * @param text the string to be drawn
+   * @param x the start of the baseline, X coordinate
+   * @param y the start of the baseline, Y coordinate
    */
-  protected abstract ColorModel getColorModel();
+  protected void rawDrawString(String text, int x, int y)
+  {
+    FontRenderContext ctx = getFontRenderContext();
+    GlyphVector gv = font.createGlyphVector(ctx, text.toCharArray());
+    drawGlyphVector(gv, x, y);
+  }
 
   /**
-   * Returns the bounds of the target.
+   * Clears a rectangle in optimization mode. The implementation should respect the
+   * clip and translation. It can assume that the clip is a rectangle and that
+   * the transform is only a translating transform.
    *
-   * @return the bounds of the target
+   * @param x the upper left corner, X coordinate
+   * @param y the upper left corner, Y coordinate
+   * @param w the width
+   * @param h the height
    */
-  protected Rectangle getDeviceBounds()
+  protected void rawClearRect(int x, int y, int w, int h)
   {
-    return destinationRaster.getBounds();
+    Paint savedForeground = getPaint();
+    setPaint(getBackground());
+    rawFillRect(x, y, w, h);
+    setPaint(savedForeground);
   }
 
   /**
-   * Returns the bounds of the drawing area in user space.
+   * Fills a rectangle in optimization mode. The implementation should respect
+   * the clip but can assume that it is a rectangle.
    *
-   * @return the bounds of the drawing area in user space
+   * @param x the upper left corner, X coordinate
+   * @param y the upper left corner, Y coordinate
+   * @param w the width
+   * @param h the height
    */
-  protected Rectangle2D getUserBounds()
+  protected void rawFillRect(int x, int y, int w, int h)
   {
-    PathIterator pathIter = getDeviceBounds().getPathIterator(getTransform());
-    GeneralPath path = new GeneralPath();
-    path.append(pathIter, true);
-    return path.getBounds();
-
+    fill(new Rectangle(x, y, w, h));
   }
+
   /**
-   * Draws a line in optimization mode. The implementation should respect the
-   * clip but can assume that it is a rectangle.
+   * Draws an image in optimization mode. The implementation should respect
+   * the clip but can assume that it is a rectangle.
    *
-   * @param x0 the starting point, X coordinate
-   * @param y0 the starting point, Y coordinate
-   * @param x1 the end point, X coordinate 
-   * @param y1 the end point, Y coordinate
+   * @param image the image to be painted
+   * @param x the location, X coordinate
+   * @param y the location, Y coordinate
+   * @param obs the image observer to be notified
+   *
+   * @return <code>true</code> when the image is painted completely,
+   *         <code>false</code> if it is still rendered
    */
-  protected void rawDrawLine(int x0, int y0, int x1, int y1)
+  protected boolean rawDrawImage(Image image, int x, int y, ImageObserver obs)
   {
-    // This is an implementation of Bresenham's line drawing algorithm.
-    int dy = y1 - y0;
-    int dx = x1 - x0;
-    int stepx, stepy;
-
-    if (dy < 0)
-      {
-        dy = -dy;
-        stepy = -1;
-      }
-    else
-      {
-        stepy = 1;
-      }
-    if (dx < 0)
-      {
-        dx = -dx;
-        stepx = -1;
-        }
-    else
-      {
-        stepx = 1;
-      }
-    dy <<= 1;
-    dx <<= 1;
-
-    drawPixel(x0, y0);
-    if (dx > dy)
-      {
-        int fraction = dy - (dx >> 1); // same as 2*dy - dx
-        while (x0 != x1)
-          {
-            if (fraction >= 0)
-              {
-                y0 += stepy;
-                fraction -= dx;
-              }
-            x0 += stepx;
-            fraction += dy;
-            drawPixel(x0, y0);
-          }
-      }
-    else
-      {
-        int fraction = dx - (dy >> 1);
-        while (y0 != y1)
-          {
-            if (fraction >= 0)
-              {
-                x0 += stepx;
-                fraction -= dy;
-              }
-            y0 += stepy;
-            fraction += dx;
-            drawPixel(x0, y0);
-          }
-      }
+    AffineTransform t = new AffineTransform();
+    t.translate(x, y);
+    return drawImage(image, t, obs);
   }
 
   /**
-   * Fills a rectangle in optimization mode. The implementation should respect
-   * the clip but can assume that it is a rectangle.
+   * Copies a rectangular region to another location.
    *
    * @param x the upper left corner, X coordinate
    * @param y the upper left corner, Y coordinate
    * @param w the width
    * @param h the height
+   * @param dx
+   * @param dy
    */
-  protected void rawFillRect(int x, int y, int w, int h)
+  protected void rawCopyArea(int x, int y, int w, int h, int dx, int dy)
   {
-    int x2 = x + w;
-    int y2 = y + h;
-    for (int xc = x; xc < x2; xc++)
-      {
-        for (int yc = y; yc < y2; yc++)
-          {
-            drawPixel(xc, yc);
-          }
-      }
+    copyAreaImpl(x, y, w, h, dx, dy);
+  }
+
+  // Private implementation methods.
+
+  /**
+   * Copies a rectangular area of the target raster to a different location.
+   */
+  private void copyAreaImpl(int x, int y, int w, int h, int dx, int dy)
+  {
+    // FIXME: Implement this properly.
+    throw new UnsupportedOperationException("Not implemented yet.");
   }
 
   /**
@@ -1403,8 +1626,9 @@ public abstract class AbstractGraphics2D
    *
    * The polygon is already clipped when this method is called.
    */
-  protected void rawFillShape(ArrayList segs, double minX, double minY,
-                              double maxX, double maxY, Rectangle2D userBounds)
+  private void fillShapeImpl(ArrayList segs, Rectangle2D deviceBounds2D,
+                             Rectangle2D userBounds,
+                             Rectangle2D inclClipBounds)
   {
     // This is an implementation of a polygon scanline conversion algorithm
     // described here:
@@ -1413,19 +1637,25 @@ public abstract class AbstractGraphics2D
     // Create table of all edges.
     // The edge buckets, sorted and indexed by their Y values.
 
+    double minX = deviceBounds2D.getMinX();
+    double minY = deviceBounds2D.getMinY();
+    double maxX = deviceBounds2D.getMaxX();
+    double maxY = deviceBounds2D.getMaxY();
+    double icMinY = inclClipBounds.getMinY();
+    double icMaxY = inclClipBounds.getMaxY();
     Rectangle deviceBounds = new Rectangle((int) minX, (int) minY,
                                            (int) Math.ceil(maxX) - (int) minX,
                                            (int) Math.ceil(maxY) - (int) minY);
     PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds,
                                             userBounds, transform, renderingHints);
 
-    ArrayList[] edgeTable = new ArrayList[(int) Math.ceil(maxY)
-                                          - (int) Math.ceil(minY) + 1];
+    ArrayList[] edgeTable = new ArrayList[(int) Math.ceil(icMaxY)
+                                          - (int) Math.ceil(icMinY) + 1];
 
     for (Iterator i = segs.iterator(); i.hasNext();)
       {
         PolyEdge edge = (PolyEdge) i.next();
-        int yindex = (int) ((int) Math.ceil(edge.y0) - (int) Math.ceil(minY));
+        int yindex = (int) ((int) Math.ceil(edge.y0) - (int) Math.ceil(icMinY));
         if (edgeTable[yindex] == null) // Create bucket when needed.
           edgeTable[yindex] = new ArrayList();
         edgeTable[yindex].add(edge); // Add edge to the bucket of its line.
@@ -1445,7 +1675,7 @@ public abstract class AbstractGraphics2D
     PolyEdgeComparator comparator = new PolyEdgeComparator();
 
     // Scan all relevant lines.
-    int minYInt = (int) Math.ceil(minY);
+    int minYInt = (int) Math.ceil(icMinY);
     for (int y = minYInt; y <= maxY; y++)
       {
         ArrayList bucket = edgeTable[y - minYInt];
@@ -1496,35 +1726,30 @@ public abstract class AbstractGraphics2D
         // Now draw all pixels inside the polygon.
         // This is the last edge that intersected the scanline.
         PolyEdge previous = null; // Gets initialized below.
-        boolean active = false;
+        boolean insideShape = false;
+        boolean insideClip = false;
         //System.err.println("scanline: " + y);
         for (Iterator i = activeEdges.iterator(); i.hasNext();)
           {
             PolyEdge edge = (PolyEdge) i.next();
-            // Only fill scanline, if the current edge actually intersects
-            // the scanline. There may be edges that lie completely
-            // within the current scanline.
-            //System.err.println("previous: " + previous);
-            //System.err.println("edge: " + edge);
-            if (active)
+            if (edge.y1 <= y)
+              continue;
+
+            // Draw scanline when we are inside the shape AND inside the
+            // clip.
+            if (insideClip && insideShape)
               {
-                if (edge.y1 > y)
-                  {
-                    int x0 = (int) previous.xIntersection;
-                    int x1 = (int) edge.xIntersection;
-                    fillScanline(pCtx, x0, x1, y);
-                    previous = edge;
-                    active = false;
-                  }
+                int x0 = (int) previous.xIntersection;
+                int x1 = (int) edge.xIntersection;
+                if (x0 < x1)
+                  fillScanline(pCtx, x0, x1, y);
               }
+            // Update state.
+            previous = edge;
+            if (edge.isClip)
+              insideClip = ! insideClip;
             else
-              {
-                if (edge.y1 > y)
-                  {
-                    previous = edge;
-                    active = true;
-                  }
-              }
+              insideShape = ! insideShape;
           }
       }
     pCtx.dispose();
@@ -1544,7 +1769,8 @@ public abstract class AbstractGraphics2D
     CompositeContext cCtx = composite.createContext(paintColorModel,
                                                     getColorModel(),
                                                     renderingHints);
-    cCtx.compose(paintRaster, destinationRaster, destinationRaster);
+    WritableRaster targetChild = destinationRaster.createWritableTranslatedChild(-x0,- y);
+    cCtx.compose(paintRaster, targetChild, targetChild);
     updateRaster(destinationRaster, x0, y, x1 - x0, 1);
     cCtx.dispose();
   }
@@ -1553,14 +1779,10 @@ public abstract class AbstractGraphics2D
    * Fills arbitrary shapes in an anti-aliased fashion.
    *
    * @param segs the line segments which define the shape which is to be filled
-   * @param minX the bounding box, left X
-   * @param minY the bounding box, upper Y
-   * @param maxX the bounding box, right X
-   * @param maxY the bounding box, lower Y
    */
-  private void fillShapeAntialias(ArrayList segs, double minX, double minY,
-                                  double maxX, double maxY,
-                                  Rectangle2D userBounds)
+  private void fillShapeAntialias(ArrayList segs, Rectangle2D deviceBounds2D,
+                                  Rectangle2D userBounds,
+                                  Rectangle2D inclClipBounds)
   {
     // This is an implementation of a polygon scanline conversion algorithm
     // described here:
@@ -1568,23 +1790,32 @@ public abstract class AbstractGraphics2D
     // The antialiasing is implemented using a sampling technique, we do
     // not scan whole lines but fractions of the line.
 
+    double minX = deviceBounds2D.getMinX();
+    double minY = deviceBounds2D.getMinY();
+    double maxX = deviceBounds2D.getMaxX();
+    double maxY = deviceBounds2D.getMaxY();
+    double icMinY = inclClipBounds.getMinY();
+    double icMaxY = inclClipBounds.getMaxY();
+    double icMinX = inclClipBounds.getMinX();
+    double icMaxX = inclClipBounds.getMaxX();
     Rectangle deviceBounds = new Rectangle((int) minX, (int) minY,
                                            (int) Math.ceil(maxX) - (int) minX,
                                            (int) Math.ceil(maxY) - (int) minY);
-    PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds,
+    PaintContext pCtx = paint.createContext(ColorModel.getRGBdefault(),
+                                            deviceBounds,
                                             userBounds, transform,
                                             renderingHints);
 
     // This array will contain the oversampled transparency values for
     // each pixel in the scanline.
-    int numScanlines = (int) Math.ceil(maxY) - (int) minY;
-    int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1;
+    int numScanlines = (int) Math.ceil(icMaxY) - (int) icMinY;
+    int numScanlinePixels = (int) Math.ceil(icMaxX) - (int) icMinX + 1;
     if (alpha == null || alpha.length < (numScanlinePixels + 1))
       alpha = new int[numScanlinePixels + 1];
     
-    int firstLine = (int) minY;
+    int firstLine = (int) icMinY;
     //System.err.println("minY: " + minY);
-    int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING));
+    int firstSubline = (int) (Math.ceil((icMinY - Math.floor(icMinY)) * AA_SAMPLING));
     double firstLineDouble = firstLine + firstSubline / (double) AA_SAMPLING;
     //System.err.println("firstSubline: " + firstSubline);
 
@@ -1629,8 +1860,11 @@ public abstract class AbstractGraphics2D
     // Scan all lines.
     int yindex = 0;
     //System.err.println("firstLine: " + firstLine + ", maxY: " + maxY + ", firstSubline: " + firstSubline);
-    for (int y = firstLine; y <= maxY; y++)
+    for (int y = firstLine; y <= icMaxY; y++)
       {
+        int leftX = (int) icMaxX;
+        int rightX = (int) icMinX;
+        boolean emptyScanline = true;
         for (int subY = firstSubline; subY < AA_SAMPLING; subY++)
           {
             //System.err.println("scanline: " + y + ", subScanline: " + subY);
@@ -1687,17 +1921,16 @@ public abstract class AbstractGraphics2D
             // Now draw all pixels inside the polygon.
             // This is the last edge that intersected the scanline.
             PolyEdge previous = null; // Gets initialized below.
-            boolean active = false;
+            boolean insideClip = false;
+            boolean insideShape = false;
             //System.err.println("scanline: " + y + ", subscanline: " + subY);
             for (Iterator i = activeEdges.iterator(); i.hasNext();)
               {
                 PolyEdge edge = (PolyEdge) i.next();
-                // Only fill scanline, if the current edge actually intersects
-                // the scanline. There may be edges that lie completely
-                // within the current scanline.
-                //System.err.println("previous: " + previous);
-                //System.err.println("edge: " + edge);
-                if (active)
+                if (edge.y1 <= (y + (subY / (double) AA_SAMPLING)))
+                  continue;
+
+                if (insideClip && insideShape)
                   {
                     // TODO: Use integer arithmetics here.
                     if (edge.y1 > (y + (subY / (double) AA_SAMPLING)))
@@ -1708,32 +1941,30 @@ public abstract class AbstractGraphics2D
                         int x1 = (int) Math.min(Math.max(edge.xIntersection, minX), maxX);
                         //System.err.println("minX: " + minX + ", x0: " + x0 + ", x1: " + x1 + ", maxX: " + maxX);
                         // TODO: Pull out cast.
-                        alpha[x0 - (int) minX]++;
-                        alpha[x1 - (int) minX + 1]--;
-                        previous = edge;
-                        active = false;
+                        int left = x0 - (int) minX;
+                        int right = x1 - (int) minX + 1; 
+                        alpha[left]++;
+                        alpha[right]--;
+                        leftX = Math.min(x0, leftX);
+                        rightX = Math.max(x1+2, rightX);
+                        emptyScanline = false;
                       }
                   }
+                previous = edge;
+                if (edge.isClip)
+                  insideClip = ! insideClip;
                 else
-                  {
-                    // TODO: Use integer arithmetics here.
-                    if (edge.y1 > (y + (subY / (double) AA_SAMPLING)))
-                      {
-                        //System.err.println(edge);
-                        previous = edge;
-                        active = true;
-                      }
-                  }
+                  insideShape = ! insideShape;
               }
             yindex++;
           }
         firstSubline = 0;
         // Render full scanline.
         //System.err.println("scanline: " + y);
-        fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx);
+        if (! emptyScanline)
+          fillScanlineAA(alpha, leftX, (int) y, rightX - leftX, pCtx,
+                         (int) minX);
       }
-    if (paint instanceof Color && composite == AlphaComposite.SrcOver)
-      rawSetForeground((Color) paint);
 
     pCtx.dispose();
   }
@@ -1747,40 +1978,54 @@ public abstract class AbstractGraphics2D
    * @param x0 the beginning of the scanline
    * @param y the y coordinate of the line
    */
-  private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels,
-                              PaintContext pCtx)
+  private void fillScanlineAA(int[] alpha, int x0, int yy, int numPixels,
+                              PaintContext pCtx, int offs)
   {
-    // FIXME: This doesn't work. Fixit.
     CompositeContext cCtx = composite.createContext(pCtx.getColorModel(),
                                                     getColorModel(),
                                                     renderingHints);
-    Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1);
-    System.err.println("paintColorModel: " + pCtx.getColorModel());
+    Raster paintRaster = pCtx.getRaster(x0, yy, numPixels, 1);
+    //System.err.println("paintColorModel: " + pCtx.getColorModel());
     WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster();
     int numBands = paintRaster.getNumBands();
-    int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()];
-    pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels);
     ColorModel cm = pCtx.getColorModel();
-    
     double lastAlpha = 0.;
     int lastAlphaInt = 0;
-    int[] components = new int[4];
-    
-    for (int i = 0; i < pixels.length; i++)
+
+    Object pixel = null;
+    int[] comps = null;
+    int x1 = x0 + numPixels;
+    for (int x = x0; x < x1; x++)
       {
+        int i = x - offs;
         if (alpha[i] != 0)
           {
             lastAlphaInt += alpha[i];
-            lastAlpha = lastAlphaInt / AA_SAMPLING;
+            lastAlpha = (double) lastAlphaInt / (double) AA_SAMPLING;
+            alpha[i] = 0;
           }
-        components = cm.getComponents(pixel[i], components, 0);
-        components[0] = (int) (components[0] * lastAlpha);
-        pixel[i] = cm.getDataElement(components, 0);
+        pixel = paintRaster.getDataElements(x - x0, 0, pixel);
+        comps = cm.getComponents(pixel, comps, 0);
+        if (cm.hasAlpha() && ! cm.isAlphaPremultiplied())
+          comps[comps.length - 1] *= lastAlpha;
+        else
+          {
+            int max;
+            if (cm.hasAlpha())
+              max = comps.length - 2;
+            else
+              max = comps.length - 1;
+            for (int j = 0; j < max; j++) 
+              comps[j] *= lastAlpha;
+          }
+        pixel = cm.getDataElements(comps, 0, pixel);
+        aaRaster.setDataElements(x - x0, 0, pixel);
       }
 
-    aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels);
-    cCtx.compose(aaRaster, destinationRaster, destinationRaster);
-    updateRaster(destinationRaster, x0, y, numScanlinePixels, 1);
+    WritableRaster targetChild =
+      destinationRaster.createWritableTranslatedChild(-x0, -yy);
+    cCtx.compose(aaRaster, targetChild, targetChild);
+    updateRaster(destinationRaster, x0, yy, numPixels, 1);
 
     cCtx.dispose();
   }
@@ -1798,8 +2043,8 @@ public abstract class AbstractGraphics2D
 
     // FIXME: Should not be necessary. A clip of null should mean
     // 'clip against device bounds.
-    clip = getDeviceBounds();
     destinationRaster = getDestinationRaster();
+    clip = getDeviceBounds();
   }
 
   /**
@@ -1912,40 +2157,77 @@ public abstract class AbstractGraphics2D
   }
 
   /**
-   * Clips the specified shape using the current clip. If the resulting shape
-   * is empty, this will return <code>null</code>.
+   * Converts the specified shape into a list of segments.
    *
-   * @param s the shape to clip
+   * @param s the shape to convert
+   * @param t the transformation to apply before converting
+   * @param deviceBounds an output parameter; holds the bounding rectangle of
+   *        s in device space after return
+   * @param isClip true when the shape is a clip, false for normal shapes;
+   *        this influences the settings in the created PolyEdge instances.
    *
-   * @return the clipped shape or <code>null</code> if the result is empty
+   * @return a list of PolyEdge that form the shape in device space
    */
-  private Shape clipShape(Shape s)
+  private ArrayList getSegments(Shape s, AffineTransform t,
+                                Rectangle2D deviceBounds, boolean isClip,
+                                double offs)
   {
-    Shape clipped = null;
+    // Flatten the path. TODO: Determine the best flattening factor
+    // wrt to speed and quality.
+    PathIterator path = s.getPathIterator(getTransform(), 1.0);
 
-    // Clip the shape if necessary.
-    if (clip != null)
-      {
-        Area a;
-        if (! (s instanceof Area))
-          a = new Area(s);
-        else
-          a = (Area) s;
+    // Build up polygons and let the native backend render this using
+    // rawFillShape() which would provide a default implementation for
+    // drawPixel using a PolyScan algorithm.
+    double[] seg = new double[6];
 
-        Area clipArea;
-        if (! (clip instanceof Area))
-          clipArea = new Area(clip);
-        else
-          clipArea = (Area) clip;
+    // TODO: Use ArrayList<PolyEdge> here when availble.
+    ArrayList segs = new ArrayList();
+    double segX = 0.; // The start point of the current edge.
+    double segY = 0.; 
+    double polyX = 0.; // The start point of the current polygon.
+    double polyY = 0.;
 
-        a.intersect(clipArea);
-        if (! a.isEmpty())
-          clipped = a;
-      }
-    else
+    double minX = Integer.MAX_VALUE;
+    double maxX = Integer.MIN_VALUE;
+    double minY = Integer.MAX_VALUE;
+    double maxY = Integer.MIN_VALUE;
+
+    //System.err.println("fill polygon");
+    while (! path.isDone())
       {
-        clipped = s;
+        int segType = path.currentSegment(seg);
+        minX = Math.min(minX, seg[0]);
+        maxX = Math.max(maxX, seg[0]);
+        minY = Math.min(minY, seg[1]);
+        maxY = Math.max(maxY, seg[1]);
+
+        //System.err.println("segment: " + segType + ", " + seg[0] + ", " + seg[1]);
+        if (segType == PathIterator.SEG_MOVETO)
+          {
+            segX = seg[0];
+            segY = seg[1];
+            polyX = seg[0];
+            polyY = seg[1];
+          }
+        else if (segType == PathIterator.SEG_CLOSE)
+          {
+            // Close the polyline.
+            PolyEdge edge = new PolyEdge(segX, segY - offs,
+                                         polyX, polyY - offs, isClip);
+            segs.add(edge);
+          }
+        else if (segType == PathIterator.SEG_LINETO)
+          {
+            PolyEdge edge = new PolyEdge(segX, segY - offs,
+                                         seg[0], seg[1] - offs, isClip);
+            segs.add(edge);
+            segX = seg[0];
+            segY = seg[1];
+          }
+        path.next();
       }
-    return clipped;
+    deviceBounds.setRect(minX, minY, maxX - minX, maxY - minY);
+    return segs;
   }
 }
diff --git a/libjava/classpath/gnu/java/awt/java2d/AlphaCompositeContext.java b/libjava/classpath/gnu/java/awt/java2d/AlphaCompositeContext.java
index e67c92148fbf..2e3690d8348e 100644
--- a/libjava/classpath/gnu/java/awt/java2d/AlphaCompositeContext.java
+++ b/libjava/classpath/gnu/java/awt/java2d/AlphaCompositeContext.java
@@ -236,7 +236,7 @@ public class AlphaCompositeContext
               }
             else
               {
-                for (int i = srcComponentsLength - 1; i >= 0; i--)
+                for (int i = srcComponentsLength - 2; i >= 0; i--)
                   srcComponents[i] *= srcComponents[srcComponentsLength - 1];
               }
             if (! dstColorModel.isAlphaPremultiplied())
diff --git a/libjava/classpath/gnu/java/awt/java2d/ImagePaint.java b/libjava/classpath/gnu/java/awt/java2d/ImagePaint.java
new file mode 100644
index 000000000000..7e5fb56388ed
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/java2d/ImagePaint.java
@@ -0,0 +1,192 @@
+/* ImagePaint.java -- Supplies the pixels for image rendering
+   Copyright (C) 2006 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 gnu.java.awt.java2d;
+
+import java.awt.Paint;
+import java.awt.PaintContext;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Transparency;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.WritableRaster;
+
+/**
+ * This class is used as a temporary Paint object to supply the pixel values
+ * for image rendering using the normal scanline conversion implementation.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class ImagePaint
+  implements Paint
+{
+
+  /**
+   * The PaintContext implementation for the ImagePaint.
+   */
+  private class ImagePaintContext
+    implements PaintContext
+  {
+
+    /**
+     * The target raster.
+     */
+    private WritableRaster target;
+
+    /**
+     * Nothing to do here.
+     */
+    public void dispose()
+    {
+      // Nothing to do here.
+    }
+
+    /**
+     * Returns the color model.
+     *
+     * @return the color model
+     */
+    public ColorModel getColorModel()
+    {
+      return image.getColorModel();
+    }
+
+    /**
+     * Supplies the pixel to be rendered.
+     *
+     * @see PaintContext#getRaster(int, int, int, int)
+     */
+    public Raster getRaster(int x1, int y1, int w, int h)
+    {
+      ensureRasterSize(w, h);
+      int x2 = x1 + w;
+      int y2 = y1 + h;
+      float[] src = new float[2];
+      float[] dest = new float[2];
+      Raster source = image.getData();
+      int minX = source.getMinX();
+      int maxX = source.getWidth() + minX;
+      int minY = source.getMinY();
+      int maxY = source.getHeight() + minY;
+      Object pixel = null;
+      for (int y = y1; y < y2; y++)
+        {
+          for (int x = x1; x < x2; x++)
+            {
+              src[0] = x;
+              src[1] = y;
+              transform.transform(src, 0, dest, 0, 1);
+              int dx = (int) dest[0];
+              int dy = (int) dest[1];
+              // Pixels outside the source image are not of interest, skip
+              // them.
+              if (dx >= minX && dx < maxX && dy >= minY && dy < maxY)
+                {
+                  pixel = source.getDataElements(dx, dy, pixel);
+                  target.setDataElements(x - x1, y - y1, pixel);
+                }
+            }
+        }
+      return target;
+    }
+
+    /**
+     * Ensures that the target raster exists and has at least the specified
+     * size.
+     *
+     * @param w the requested target width
+     * @param h the requested target height
+     */
+    private void ensureRasterSize(int w, int h)
+    {
+      if (target == null || target.getWidth() < w || target.getHeight() < h)
+        {
+          Raster s = image.getData();
+          target = s.createCompatibleWritableRaster(w, h);
+        }
+    }
+  }
+
+  /**
+   * The image to render.
+   */
+  RenderedImage image;
+
+  /**
+   * The transform from image space to device space. This is the inversed
+   * transform of the concatenated
+   * transform image space -> user space -> device space transform.
+   */
+  AffineTransform transform;
+
+  /**
+   * Creates a new ImagePaint for rendering the specified image using the
+   * specified device space -> image space transform. This transform
+   * is the inversed transform of the usual image space -> user space -> device
+   * space transform.
+   *
+   * The ImagePaint will only render the image in the specified area of
+   * interest (which is specified in image space).
+   *
+   * @param i the image to render
+   * @param t the device space to user space transform
+   */
+  ImagePaint(RenderedImage i, AffineTransform t)
+  {
+    image = i;
+    transform = t;
+  }
+
+  public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
+                                    Rectangle2D userBounds,
+                                    AffineTransform xform,
+                                    RenderingHints hints)
+  {
+    return new ImagePaintContext();
+  }
+
+  public int getTransparency()
+  {
+    return Transparency.OPAQUE;
+  }
+
+}
diff --git a/libjava/classpath/gnu/java/awt/java2d/PolyEdge.java b/libjava/classpath/gnu/java/awt/java2d/PolyEdge.java
index 621bd3ad8200..8dbdbabcb94a 100644
--- a/libjava/classpath/gnu/java/awt/java2d/PolyEdge.java
+++ b/libjava/classpath/gnu/java/awt/java2d/PolyEdge.java
@@ -64,6 +64,11 @@ public class PolyEdge
    */
   double xIntersection;
 
+  /**
+   * Indicates whether this edge is from the clip or from the target shape.
+   */
+  boolean isClip;
+
   /**
    * Creates a new PolyEdge with the specified coordinates.
    *
@@ -72,8 +77,9 @@ public class PolyEdge
    * @param x1 the end point, x coordinate
    * @param y1 the end point, y coordinate
    */
-  PolyEdge(double x0, double y0, double x1, double y1)
+  PolyEdge(double x0, double y0, double x1, double y1, boolean clip)
   {
+    isClip = clip;
     if (y0 < y1)
       {
         this.x0 = x0;
diff --git a/libjava/classpath/gnu/java/awt/java2d/RasterGraphics.java b/libjava/classpath/gnu/java/awt/java2d/RasterGraphics.java
index 4de8035c6927..98d47b406aab 100644
--- a/libjava/classpath/gnu/java/awt/java2d/RasterGraphics.java
+++ b/libjava/classpath/gnu/java/awt/java2d/RasterGraphics.java
@@ -65,8 +65,10 @@ public class RasterGraphics
 
   public RasterGraphics(WritableRaster r, ColorModel cm)
   {
+    super();
     raster = r;
     colorModel = cm;
+    init();
   }
 
   /**
diff --git a/libjava/classpath/gnu/java/awt/java2d/TexturePaintContext.java b/libjava/classpath/gnu/java/awt/java2d/TexturePaintContext.java
new file mode 100644
index 000000000000..1a782ce07e31
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/java2d/TexturePaintContext.java
@@ -0,0 +1,205 @@
+/* TexturePaintContext.java -- PaintContext impl for TexturePaint
+   Copyright (C) 2006 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 gnu.java.awt.java2d;
+
+import java.awt.AWTError;
+import java.awt.PaintContext;
+import java.awt.Rectangle;
+import java.awt.TexturePaint;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+/**
+ * A {@link PaintContext} implementation for {@link TexturePaint}, done in
+ * pure Java.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class TexturePaintContext
+  implements PaintContext
+{
+
+  /**
+   * The TexturePaint object.
+   */
+  private BufferedImage image;
+
+  /**
+   * The Raster that holds the texture.
+   */
+  private WritableRaster paintRaster;
+
+  /**
+   * The transform from userspace into device space.
+   */
+  private AffineTransform transform;
+
+  /**
+   * Creates a new TexturePaintContext for the specified TexturePaint object.
+   * This initializes the Raster which is returned by
+   * {@link #getRaster(int, int, int, int)}.
+   *
+   * @param t the texture paint object
+   * @param db the bounds of the target raster in device space
+   * @param ub the bounds of the target raster in user space
+   * @param xform the transformation from user space to device space
+   */
+  public TexturePaintContext(TexturePaint t, Rectangle db,
+                             Rectangle2D ub, AffineTransform xform)
+  {
+    image = t.getImage();
+
+    try
+      {
+        // Prepare transform for mapping from device space into image space.
+        // In order to achieve this we take the transform for userspace->
+        // devicespace, append the correct scale and translation according
+        // to the anchor (which gives us the image->userspace->devicespace
+        // transform), and invert that (which gives use the device->user->image
+        // transform).
+        Rectangle2D anchor = t.getAnchorRect();
+        BufferedImage image = t.getImage();
+        double scaleX = anchor.getWidth() / image.getWidth();
+        double scaleY = anchor.getHeight() / image.getHeight();
+        transform = (AffineTransform) xform.clone();
+        transform.scale(scaleX, scaleY);
+        transform.translate(-anchor.getMinX(), -anchor.getMaxX());
+        transform = transform.createInverse();
+      }
+    catch (NoninvertibleTransformException ex)
+      {
+        AWTError err =
+          new AWTError("Unexpected NoninvertibleTransformException");
+        err.initCause(ex);
+        throw err;
+      }
+  }
+
+  /**
+   * Disposes the PaintContext. Nothing is to do here, since we don't use
+   * any native resources in that implementation.
+   */
+  public void dispose()
+  {
+    // Nothing to do here.
+  }
+
+  /**
+   * Returns the color model of this PaintContext. This implementation returnes
+   * the color model used by the BufferedImage in the TexturePaint object,
+   * this avoids costly color model transformations (at least at this point).
+   *
+   * @return the color model of this PaintContext
+   */
+  public ColorModel getColorModel()
+  {
+    return image.getColorModel();
+  }
+
+  /**
+   * Returns the Raster that is used for painting.
+   *
+   * @param x1 the x location of the raster inside the user bounds of this paint
+   *        context
+   * @param y1 the y location of the raster inside the user bounds of this paint
+   *        context
+   * @param w the width
+   * @param h the height
+   *
+   * @return the Raster that is used for painting
+   * 
+   */
+  public Raster getRaster(int x1, int y1, int w, int h)
+  {
+    ensureRasterSize(w, h);
+    int x2 = x1 + w;
+    int y2 = y1 + h;
+    float[] src = new float[2];
+    float[] dest = new float[2];
+    Raster source = image.getData();
+    int minX = source.getMinX();
+    int width = source.getWidth();
+    int minY = source.getMinY();
+    int height = source.getHeight();
+    Object pixel = null;
+    for (int y = y1; y < y2; y++)
+      {
+        for (int x = x1; x < x2; x++)
+          {
+            // Transform the coordinates from device space into image space.
+            src[0] = x;
+            src[1] = y;
+            transform.transform(src, 0, dest, 0, 1);
+            int dx = (int) dest[0];
+            int dy = (int) dest[1];
+
+            // The modulo operation gives us the replication effect.
+            dx = ((dx - minX) % width) + minX;  
+            dy = ((dy - minY) % height) + minY;
+
+            // Copy the pixel.
+            pixel = source.getDataElements(dx, dy, pixel);
+            paintRaster.setDataElements(x - x1, y - y1, pixel);
+          }
+      }
+    return paintRaster;
+  }
+
+  /**
+   * Ensures that the target raster exists and has at least the specified
+   * size.
+   *
+   * @param w the requested target width
+   * @param h the requested target height
+   */
+  private void ensureRasterSize(int w, int h)
+  {
+    if (paintRaster == null || paintRaster.getWidth() < w
+        || paintRaster.getHeight() < h)
+      {
+        Raster s = image.getData();
+        paintRaster = s.createCompatibleWritableRaster(w, h);
+      }
+  }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
new file mode 100644
index 000000000000..d9d300d9103a
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
@@ -0,0 +1,258 @@
+/* BufferedImageGraphics.java
+   Copyright (C) 2006 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 gnu.java.awt.peer.gtk;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.RenderedImage;
+import java.awt.image.ImageObserver;
+import java.util.WeakHashMap;
+
+/**
+ * Implementation of Graphics2D on a Cairo surface.
+ *
+ * Simutanously maintains a CairoSurface and updates the 
+ * BufferedImage from that after each drawing operation.
+ */
+public class BufferedImageGraphics extends CairoGraphics2D
+{
+  /**
+   * the buffered Image.
+   */
+  private BufferedImage image;
+
+  /**
+   * Image size.
+   */
+  private int imageWidth, imageHeight;
+
+  /**
+   * The cairo surface that we actually draw on.
+   */
+  CairoSurface surface;
+
+  /**
+   * Cache BufferedImageGraphics surfaces.
+   */
+  static WeakHashMap bufferedImages = new WeakHashMap();
+
+  /**
+   * Its corresponding cairo_t.
+   */
+  private long cairo_t;
+
+  /**
+   * Colormodels we recognize for fast copying.
+   */  
+  static ColorModel rgb32 = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF);
+  static ColorModel argb32 = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF,
+						  0xFF000000);
+  private boolean hasFastCM;
+  private boolean hasAlpha;
+
+
+  public BufferedImageGraphics(BufferedImage bi)
+  {
+    this.image = bi;
+    imageWidth = bi.getWidth();
+    imageHeight = bi.getHeight();
+    if(bi.getColorModel().equals(rgb32))
+      {
+	hasFastCM = true;
+	hasAlpha = false;
+      }
+    else if(bi.getColorModel().equals(argb32))
+      {
+	hasFastCM = true;
+	hasAlpha = false;
+      }
+    else
+      hasFastCM = false;
+
+    // Cache surfaces.
+    if( bufferedImages.get( bi ) != null )
+      surface = (CairoSurface)bufferedImages.get( bi );
+    else
+      {
+	surface = new CairoSurface( imageWidth, imageHeight );
+	bufferedImages.put(bi, surface);
+      }
+
+    cairo_t = surface.newCairoContext();
+
+    DataBuffer db = bi.getRaster().getDataBuffer();
+    int[] pixels;
+    // get pixels
+
+    if(db instanceof CairoSurface)
+      pixels = ((CairoSurface)db).getPixels(imageWidth * imageHeight);
+    else
+      {
+	if( hasFastCM )
+	  {
+	    pixels = ((DataBufferInt)db).getData();
+	    if( !hasAlpha )
+	      for(int i = 0; i < pixels.length; i++)
+		pixels[i] &= 0xFFFFFFFF;
+	  }
+	else
+	  {
+	    pixels = CairoGraphics2D.findSimpleIntegerArray
+	      (image.getColorModel(),image.getData());
+	  }
+      }
+    surface.setPixels( pixels );
+
+    setup( cairo_t );
+    setClip(0, 0, imageWidth, imageHeight);
+  }
+  
+  BufferedImageGraphics(BufferedImageGraphics copyFrom)
+  {
+    surface = copyFrom.surface;
+    cairo_t = surface.newCairoContext();
+    imageWidth = copyFrom.imageWidth;
+    imageHeight = copyFrom.imageHeight;
+    copy( copyFrom, cairo_t );
+    setClip(0, 0, surface.width, surface.height);
+  }
+
+  /**
+   * Update a rectangle of the bufferedImage. This can be improved upon a lot.
+   */
+  private void updateBufferedImage(int x, int y, int width, int height)
+  {  
+    int[] pixels = surface.getPixels(imageWidth * imageHeight);
+
+    if( x > imageWidth || y > imageHeight )
+      return;
+    // Clip edges.
+    if( x < 0 ){ width = width + x; x = 0; }
+    if( y < 0 ){ height = height + y; y = 0; }
+    if( x + width > imageWidth ) 
+      width = imageWidth - x;
+    if( y + height > imageHeight ) 
+      height = imageHeight - y;
+
+    if( !hasFastCM )
+      image.setRGB(x, y, width, height, pixels, 
+		   x + y * imageWidth, imageWidth);
+    else
+      System.arraycopy(pixels, y * imageWidth, 
+		       ((DataBufferInt)image.getRaster().getDataBuffer()).
+		       getData(), y * imageWidth, height * imageWidth);
+  }
+
+  /**
+   * Abstract methods.
+   */  
+  public Graphics create()
+  {
+    return new BufferedImageGraphics(this);
+  }
+  
+  public GraphicsConfiguration getDeviceConfiguration()
+  {
+    return null;
+  }
+
+  protected Rectangle2D getRealBounds()
+  {
+    return new Rectangle2D.Double(0.0, 0.0, imageWidth, imageHeight);
+  }
+  
+  public void copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
+  {
+    surface.copyAreaNative(x, y, width, height, dx, dy, surface.width);
+    updateBufferedImage(x + dx, y + dy, width, height);
+  }
+
+  /**
+   * Overloaded methods that do actual drawing need to enter the gdk threads 
+   * and also do certain things before and after.
+   */
+  public void draw(Shape s)
+  {
+    super.draw(s);
+    Rectangle r = s.getBounds();
+    updateBufferedImage(r.x, r.y, r.width, r.height);
+  }
+
+  public void fill(Shape s)
+  {
+    super.fill(s);
+    Rectangle r = s.getBounds();
+    updateBufferedImage(r.x, r.y, r.width, r.height);
+  }
+
+  public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+  {
+    super.drawRenderedImage(image, xform);
+    updateBufferedImage(0, 0, imageWidth, imageHeight);
+  }
+
+  protected boolean drawImage(Image img, AffineTransform xform,
+			      Color bgcolor, ImageObserver obs)
+  {
+    boolean rv = super.drawImage(img, xform, bgcolor, obs);
+    updateBufferedImage(0, 0, imageWidth, imageHeight);
+    return rv;
+  }
+
+  public void drawGlyphVector(GlyphVector gv, float x, float y)
+  {
+    super.drawGlyphVector(gv, x, y);
+    updateBufferedImage(0, 0, imageWidth, imageHeight);
+  }
+}
+
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java
similarity index 57%
rename from libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java
rename to libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java
index dcebc2fd52be..3179d3379b90 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java
@@ -1,5 +1,5 @@
-/* GdkGraphics2D.java --
-   Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
+/* CairoGraphics2D.java --
+   Copyright (C) 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -58,17 +58,21 @@ import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.Shape;
 import java.awt.Stroke;
+import java.awt.Polygon;
 import java.awt.TexturePaint;
 import java.awt.Toolkit;
 import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Arc2D;
+import java.awt.geom.Area;
+import java.awt.geom.Line2D;
 import java.awt.geom.GeneralPath;
 import java.awt.geom.NoninvertibleTransformException;
 import java.awt.geom.PathIterator;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
 import java.awt.image.AffineTransformOp;
 import java.awt.image.BufferedImage;
 import java.awt.image.BufferedImageOp;
@@ -92,92 +96,141 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Stack;
 
-public class GdkGraphics2D extends Graphics2D
+/**
+ * This is an abstract implementation of Graphics2D on Cairo. 
+ *
+ * It should be subclassed for different Cairo contexts.
+ *
+ * Note for subclassers: Apart from the constructor (see comments below),
+ * The following abstract methods must be implemented:
+ *
+ * Graphics create()
+ * GraphicsConfiguration getDeviceConfiguration()
+ * copyArea(int x, int y, int width, int height, int dx, int dy)
+ *
+ * Also, dispose() must be overloaded to free any native datastructures 
+ * used by subclass and in addition call super.dispose() to free the
+ * native cairographics2d structure and cairo_t.
+ *
+ * @author Sven de Marothy
+ */
+public abstract class CairoGraphics2D extends Graphics2D
 {
-  //////////////////////////////////////
-  ////// State Management Methods //////
-  //////////////////////////////////////
-
   static 
   {
-    if (! Configuration.GTK_CAIRO_ENABLED)
-      throw new Error("Graphics2D not implemented. "
-		      + "Cairo was not found or disabled at configure time");
-
     System.loadLibrary("gtkpeer");
-
-    initStaticState();
   }
-  
-  static native void initStaticState();
-  
-  private final int native_state = GtkGenericPeer.getUniqueInteger();  
 
-  // These are package-private to avoid accessor methods.
+  /**
+   * Important: This is a pointer to the native cairographics2d structure
+   *
+   * DO NOT CHANGE WITHOUT CHANGING NATIVE CODE.
+   */
+  long nativePointer;
+
+  // Drawing state variables
+  /**
+   * The current paint
+   */
   Paint paint;
+
+  /**
+   * The current stroke
+   */
   Stroke stroke;
-  Color fg;
-  Color bg;
+
+  /*
+   * Current foreground and background color.
+   */
+  Color fg, bg;
+
+  /**
+   * Current clip shape.
+   */
   Shape clip;
+
+  /**
+   * Current transform.
+   */
   AffineTransform transform;
-  private GtkComponentPeer component;
-  // This is package-private to avoid an accessor method.
+
+  /**
+   * Current font.
+   */
   Font font;
-  private RenderingHints hints;
-  private BufferedImage bimage;
-  private boolean pixelConversionRequired;
-  private int[] pixelBuffer;
-  // This is package-private to avoid an accessor method.
+
+  /**
+   * The current compositing context, if any.
+   */
   Composite comp;
-  private Stack stateStack;
-
-  private native void initStateUnlocked(GtkComponentPeer component);
-  private native void initState(GtkComponentPeer component);
-  private native void initState(int width, int height);
-  private native void initState(int[] pixes, int width, int height);
-  private native void copyState(GdkGraphics2D g);
-  public native void dispose();
-  private native void cairoSurfaceSetFilter(int filter);
-  private native void cairoSurfaceSetFilterUnlocked(int filter);
-  native void connectSignals(GtkComponentPeer component);
 
-  public void finalize()
-  {
-    dispose();
-  }
+  /**
+   * Rendering hint map.
+   */
+  private RenderingHints hints;
 
-  public Graphics create()
-  {
-    return new GdkGraphics2D(this);
-  }
+  /**
+   * Some operations (drawing rather than filling) require that their
+   * coords be shifted to land on 0.5-pixel boundaries, in order to land on
+   * "middle of pixel" coordinates and light up complete pixels. 
+   */
+  private boolean shiftDrawCalls = false;
+
+  /**
+   * Keep track if the first clip to be set, which is restored on setClip(null);
+   */
+  private boolean firstClip = true;
+  private Shape originalClip;
+
+  /**
+   * Stroke used for 3DRects
+   */
+  private static BasicStroke draw3DRectStroke = new BasicStroke();
+
+  static ColorModel rgb32 = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF);
+  static ColorModel argb32 = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 
+						  0xFF000000);
 
-  public Graphics create(int x, int y, int width, int height)
+  /**
+   * Constructor does nothing.
+   */
+  public CairoGraphics2D()
   {
-    return new GdkGraphics2D(this, x, y, width, height);
   }
 
-  private void fail_g2d ()
-  {
-    System.err.println ("Attempted to instantiate GdkGraphics2D"
-			+ " but Graphics2D not enabled.  Try again with"
-			+ " -Dgnu.java.awt.peer.gtk.Graphics=Graphics2D");
-    System.exit (1);
+  /**
+   * Sets up the default values and allocates the native cairographics2d structure
+   * @param cairo_t_pointer, a native pointer to a cairo_t of the context.
+   */
+  public void setup(long cairo_t_pointer)
+  { 
+    nativePointer = init(cairo_t_pointer);
+    setRenderingHints(new RenderingHints(getDefaultHints()));
+    font = new Font("SansSerif", Font.PLAIN, 12);
+    setColor(Color.black);
+    setBackground(Color.white);
+    setPaint(Color.black);
+    setStroke(new BasicStroke());
+    setTransform(new AffineTransform());
   }
 
-  GdkGraphics2D(GdkGraphics2D g)
+  /**
+   * Same as above, but copies the state of another CairoGraphics2D.
+   */
+  public void copy(CairoGraphics2D g, long cairo_t_pointer)
   {
-    if (!GtkToolkit.useGraphics2D ())
-      fail_g2d ();
-
+    nativePointer = init(cairo_t_pointer);
     paint = g.paint;
     stroke = g.stroke;
     setRenderingHints(g.hints);
+    
+    Color foreground;
 
     if (g.fg.getAlpha() != -1)
-      fg = new Color(g.fg.getRed(), g.fg.getGreen(), g.fg.getBlue(),
+      foreground = new Color(g.fg.getRed(), g.fg.getGreen(), g.fg.getBlue(),
                      g.fg.getAlpha());
     else
-      fg = new Color(g.fg.getRGB());
+      foreground = new Color(g.fg.getRGB());
 
     if (g.bg != null)
       {
@@ -199,496 +252,319 @@ public class GdkGraphics2D extends Graphics2D
       transform = new AffineTransform(g.transform);
 
     font = g.font;
-    component = g.component;
-    copyState(g);
 
-    setColor(fg);
+    setColor(foreground);
     setBackground(bg);
     setPaint(paint);
     setStroke(stroke);
     setTransform(transform);
-    setClip(clip);
-    stateStack = new Stack();
   }
 
-  GdkGraphics2D(GdkGraphics2D g, int x, int y, int widht, int height)
-  {
-    this(g);
-    translate(x, y);
-    clipRect(0, 0, widht, height);
-  }
-
-  GdkGraphics2D(int width, int height)
-  {
-    if (!GtkToolkit.useGraphics2D ())
-      fail_g2d ();
-
-    initState(width, height);
-
-    setColor(Color.black);
-    setBackground(new Color(0, 0, 0, 0));
-    setPaint(getColor());
-    setFont(new Font("SansSerif", Font.PLAIN, 12));
-    setTransform(new AffineTransform());
-    setStroke(new BasicStroke());
-    setRenderingHints(getDefaultHints());
-
-    stateStack = new Stack();
-  }
-
-  GdkGraphics2D(GtkComponentPeer component)
+  /**
+   * Generic destructor - call the native dispose() method.
+   */
+  public void finalize()
   {
-    if (!GtkToolkit.useGraphics2D ())
-      fail_g2d ();
-
-    this.component = component;
-    
-    if (component.isRealized())
-      initComponentGraphics2D();
-    else
-      connectSignals(component);
+    dispose();
   }
 
-  void initComponentGraphics2D()
-  {
-    initState(component);
-
-    setColor(component.awtComponent.getForeground());
-    setBackground(component.awtComponent.getBackground());
-    setPaint(getColor());
-    setTransform(new AffineTransform());
-    setStroke(new BasicStroke());
-    setRenderingHints(getDefaultHints());
-    setFont(new Font("SansSerif", Font.PLAIN, 12));
-
-    stateStack = new Stack();
+  /**
+   * Disposes the native cairographics2d structure, including the 
+   * cairo_t and any gradient stuff, if allocated. 
+   * Subclasses should of course overload and call this if 
+   * they have additional native structures.
+   */
+  public void dispose()
+  {    
+    disposeNative();
+    nativePointer = 0;
   }
 
-  void initComponentGraphics2DUnlocked()
-  {
-    initStateUnlocked(component);
-
-    setColorUnlocked(component.awtComponent.getForeground());
-    setBackgroundUnlocked(component.awtComponent.getBackground());
-    setPaintUnlocked(getColorUnlocked());
-    setTransformUnlocked(new AffineTransform());
-    setStrokeUnlocked(new BasicStroke());
-    setRenderingHintsUnlocked(getDefaultHints());
-    setFontUnlocked(new Font("SansSerif", Font.PLAIN, 12));
+  /**
+   * Allocate the cairographics2d structure and set the cairo_t pointer in it.
+   * @param pointer - a cairo_t pointer, casted to a long.
+   */
+  private native long init(long pointer);
 
-    stateStack = new Stack();
-  }
-
-  GdkGraphics2D(BufferedImage bimage)
-  {
-    this.bimage = bimage;
-    this.pixelBuffer = findSimpleIntegerArray(bimage.getColorModel(),
-                                              bimage.getRaster());
-    if (this.pixelBuffer == null)
-      {
-	this.pixelBuffer = new int[bimage.getRaster().getWidth() * bimage.getRaster()
-	                                                                 .getHeight()];
-	this.pixelConversionRequired = true;
-      }
-    else
-      {
-        this.pixelConversionRequired = false;
-      }
+  /**
+   * These are declared abstract as there may be context-specific issues.
+   */
+  public abstract Graphics create();
 
-    initState(this.pixelBuffer, bimage.getWidth(), bimage.getHeight());
+  public abstract GraphicsConfiguration getDeviceConfiguration();
 
-    setColor(Color.black);
-    setBackground(new Color(0, 0, 0, 0));
-    setPaint(getColor());
-    setFont(new Font("SansSerif", Font.PLAIN, 12));
-    setTransform(new AffineTransform());
-    setStroke(new BasicStroke());
-    setRenderingHints(getDefaultHints());
+  protected abstract void copyAreaImpl(int x, int y, 
+				       int width, int height, int dx, int dy);
 
-    stateStack = new Stack();
 
-    // draw current buffered image to the pixmap associated 
-    // with it, if the image is not equal to our paint buffer.
-    if (pixelConversionRequired)
-      drawImage(bimage, new AffineTransform(1, 0, 0, 1, 0, 0), bg, null);
-  }
+  protected abstract Rectangle2D getRealBounds();
 
-  ////////////////////////////////////
-  ////// Native Drawing Methods //////
-  ////////////////////////////////////
+  ////// Native Methods ////////////////////////////////////////////////////
 
-  // GDK drawing methods
-  private native void gdkDrawDrawable(GdkGraphics2D other, int x, int y);
+  /**
+   * Dispose of allocate native resouces.
+   */
+  public native void disposeNative();
 
-  // drawing utility methods
+  /**
+   * Draw pixels as an RGBA int matrix
+   * @param w, h - width and height
+   * @param stride - stride of the array width
+   * @param i2u - affine transform array
+   */
   private native void drawPixels(int[] pixels, int w, int h, int stride,
                                  double[] i2u);
-  private native void setTexturePixelsUnlocked(int[] pixels, int w, int h, int stride);
-  private native void setTexturePixels(int[] pixels, int w, int h, int stride);
+
   private native void setGradient(double x1, double y1, double x2, double y2,
                                   int r1, int g1, int b1, int a1, int r2,
                                   int g2, int b2, int a2, boolean cyclic);
-  private native void setGradientUnlocked(double x1, double y1, double x2, double y2,
-                                  int r1, int g1, int b1, int a1, int r2,
-                                  int g2, int b2, int a2, boolean cyclic);
+  
+  private native void setTexturePixels(int[] pixels, int w, int h, int stride);
 
-  // simple passthroughs to cairo
-  private native void cairoSave();
-  private native void cairoRestore();
+  /**
+   * Set the current transform matrix
+   */
   private native void cairoSetMatrix(double[] m);
-  private native void cairoSetMatrixUnlocked(double[] m);
+
+  /**
+   * Set the compositing operator
+   */
   private native void cairoSetOperator(int cairoOperator);
+
+  /**
+   * Sets the current color in RGBA as a 0.0-1.0 double
+   */
   private native void cairoSetRGBAColor(double red, double green,
                                         double blue, double alpha);
-  private native void cairoSetRGBAColorUnlocked(double red, double green,
-                                        double blue, double alpha);
-  private native void cairoSetFillRule(int cairoFillRule);
-  private native void cairoSetLineWidth(double width);
-  private native void cairoSetLineWidthUnlocked(double width);
-  private native void cairoSetLineCap(int cairoLineCap);
-  private native void cairoSetLineCapUnlocked(int cairoLineCap);
-  private native void cairoSetLineJoin(int cairoLineJoin);
-  private native void cairoSetLineJoinUnlocked(int cairoLineJoin);
-  private native void cairoSetDash(double[] dashes, int ndash, double offset);
-  private native void cairoSetDashUnlocked(double[] dashes, int ndash, double offset);
-
-  private native void cairoSetMiterLimit(double limit);
-  private native void cairoSetMiterLimitUnlocked(double limit);
-  private native void cairoNewPath();
-  private native void cairoMoveTo(double x, double y);
-  private native void cairoLineTo(double x, double y);
-  private native void cairoCurveTo(double x1, double y1, double x2, double y2,
-                                   double x3, double y3);
-  private native void cairoRelMoveTo(double dx, double dy);
-  private native void cairoRelLineTo(double dx, double dy);
-  private native void cairoRelCurveTo(double dx1, double dy1, double dx2,
-                                      double dy2, double dx3, double dy3);
-  private native void cairoRectangle(double x, double y, double width,
-                                     double height);
-  private native void cairoClosePath();
-  private native void cairoStroke();
-  private native void cairoFill();
-  private native void cairoClip();
-
-  /////////////////////////////////////////////
-  ////// General Drawing Support Methods //////
-  /////////////////////////////////////////////
-
-  private class DrawState
-  {
-    private Paint paint;
-    private Stroke stroke;
-    private Color fg;
-    private Color bg;
-    private Shape clip;
-    private AffineTransform transform;
-    private Font font;
-    private Composite comp;
-
-    DrawState(GdkGraphics2D g)
-    {
-      this.paint = g.paint;
-      this.stroke = g.stroke;
-      this.fg = g.fg;
-      this.bg = g.bg;
-      this.clip = g.clip;
-      if (g.transform != null)
-	this.transform = (AffineTransform) g.transform.clone();
-      this.font = g.font;
-      this.comp = g.comp;
-    }
-
-    public void restore(GdkGraphics2D g)
-    {
-      g.paint = this.paint;
-      g.stroke = this.stroke;
-      g.fg = this.fg;
-      g.bg = this.bg;
-      g.clip = this.clip;
-      g.transform = this.transform;
-      g.font = this.font;
-      g.comp = this.comp;
-    }
-  }
-
-  private void stateSave()
-  {
-    stateStack.push(new DrawState(this));
-    cairoSave();
-  }
-
-  private void stateRestore()
-  {
-    ((DrawState) (stateStack.pop())).restore(this);
-    cairoRestore();
-  }
-
-  // Some operations (drawing rather than filling) require that their
-  // coords be shifted to land on 0.5-pixel boundaries, in order to land on
-  // "middle of pixel" coordinates and light up complete pixels.
-  private boolean shiftDrawCalls = false;
-
-  private double shifted(double coord, boolean doShift)
-  {
-    if (doShift)
-      return Math.floor(coord) + 0.5;
-    else
-      return coord;
-  }
-
-  private void walkPath(PathIterator p, boolean doShift)
-  {
-    double x = 0;
-    double y = 0;
-    double[] coords = new double[6];
-
-    cairoSetFillRule(p.getWindingRule());
-    for (; ! p.isDone(); p.next())
-      {
-	int seg = p.currentSegment(coords);
-	switch (seg)
-	  {
-	  case PathIterator.SEG_MOVETO:
-	    x = shifted(coords[0], doShift);
-	    y = shifted(coords[1], doShift);
-	    cairoMoveTo(x, y);
-	    break;
-	  case PathIterator.SEG_LINETO:
-	    x = shifted(coords[0], doShift);
-	    y = shifted(coords[1], doShift);
-	    cairoLineTo(x, y);
-	    break;
-	  case PathIterator.SEG_QUADTO:
-	    // splitting a quadratic bezier into a cubic:
-	    // see: http://pfaedit.sourceforge.net/bezier.html
-	    double x1 = x + (2.0 / 3.0) * (shifted(coords[0], doShift) - x);
-	    double y1 = y + (2.0 / 3.0) * (shifted(coords[1], doShift) - y);
-
-	    double x2 = x1 + (1.0 / 3.0) * (shifted(coords[2], doShift) - x);
-	    double y2 = y1 + (1.0 / 3.0) * (shifted(coords[3], doShift) - y);
 
-	    x = shifted(coords[2], doShift);
-	    y = shifted(coords[3], doShift);
-	    cairoCurveTo(x1, y1, x2, y2, x, y);
-	    break;
-	  case PathIterator.SEG_CUBICTO:
-	    x = shifted(coords[4], doShift);
-	    y = shifted(coords[5], doShift);
-	    cairoCurveTo(shifted(coords[0], doShift),
-	                 shifted(coords[1], doShift),
-	                 shifted(coords[2], doShift),
-	                 shifted(coords[3], doShift), x, y);
-	    break;
-	  case PathIterator.SEG_CLOSE:
-	    cairoClosePath();
-	    break;
-	  }
-      }
-  }
+  /**
+   * Sets the current winding rule in Cairo
+   */
+  private native void cairoSetFillRule(int cairoFillRule);
 
-  private Map getDefaultHints()
-  {
-    HashMap defaultHints = new HashMap();
+  /**
+   * Set the line style, cap, join and miter limit.
+   * Cap and join parameters are in the BasicStroke enumerations.
+   */
+  private native void cairoSetLine(double width, int cap, int join, double miterLimit);
 
-    defaultHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
-                     RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
+  /**
+   * Set the dash style
+   */
+  private native void cairoSetDash(double[] dashes, int ndash, double offset);
 
-    defaultHints.put(RenderingHints.KEY_STROKE_CONTROL,
-                     RenderingHints.VALUE_STROKE_DEFAULT);
+  /*
+   * Draws a Glyph Vector
+   */
+  native void cairoDrawGlyphVector(GdkFontPeer font, 
+                                   float x, float y, int n, 
+                                   int[] codes, float[] positions);
 
-    defaultHints.put(RenderingHints.KEY_FRACTIONALMETRICS,
-                     RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
 
-    defaultHints.put(RenderingHints.KEY_ANTIALIASING,
-                     RenderingHints.VALUE_ANTIALIAS_OFF);
+  private native void cairoRelCurveTo(double dx1, double dy1, double dx2,
+                                      double dy2, double dx3, double dy3);
 
-    defaultHints.put(RenderingHints.KEY_RENDERING,
-                     RenderingHints.VALUE_RENDER_DEFAULT);
+  /**
+   * Appends a rectangle to the current path
+   */
+  private native void cairoRectangle(double x, double y, double width,
+                                     double height);
 
-    return defaultHints;
-  }
+  /**
+   * New current path
+   */
+  private native void cairoNewPath();
 
-  public static int[] findSimpleIntegerArray (ColorModel cm, Raster raster)
-  {
-    if (cm == null || raster == null)
-      return null;
+  /** 
+   * Close current path
+   */
+  private native void cairoClosePath();
 
-    if (! cm.getColorSpace().isCS_sRGB())
-      return null;
+  /** moveTo */
+  private native void cairoMoveTo(double x, double y);
 
-    if (! (cm instanceof DirectColorModel))
-      return null;
+  /** relative moveTo */
+  private native void cairoRelMoveTo(double dx, double dy);
 
-    DirectColorModel dcm = (DirectColorModel) cm;
+  /** lineTo */
+  private native void cairoLineTo(double x, double y);
 
-    if (dcm.getRedMask() != 0x00FF0000 || dcm.getGreenMask() != 0x0000FF00
-        || dcm.getBlueMask() != 0x000000FF)
-      return null;
+  /** relative lineTo */
+  private native void cairoRelLineTo(double dx, double dy);
 
-    if (! (raster instanceof WritableRaster))
-      return null;
+  /** Cubic curve-to */
+  private native void cairoCurveTo(double x1, double y1, double x2, double y2,
+                                   double x3, double y3);
 
-    if (raster.getSampleModel().getDataType() != DataBuffer.TYPE_INT)
-      return null;
+  /**
+   * Stroke current path
+   */
+  private native void cairoStroke();
 
-    if (! (raster.getDataBuffer() instanceof DataBufferInt))
-      return null;
+  /**
+   * Fill current path
+   */
+  private native void cairoFill();
 
-    DataBufferInt db = (DataBufferInt) raster.getDataBuffer();
+  /** 
+   * Clip current path
+   */
+  private native void cairoClip();
 
-    if (db.getNumBanks() != 1)
-      return null;
+  /** 
+   * Save clip
+   */
+  private native void cairoPreserveClip();
 
-    // Finally, we have determined that this is a single bank, [A]RGB-int
-    // buffer in sRGB space. It's worth checking all this, because it means
-    // that cairo can paint directly into the data buffer, which is very
-    // fast compared to all the normal copying and converting.
+  /** 
+   * Save clip
+   */
+  private native void cairoResetClip();
 
-    return db.getData();
-  }
+  /**
+   * Set interpolation types
+   */
+  private native void cairoSurfaceSetFilter(int filter);
 
-  private void updateBufferedImage()
+  ///////////////////////// TRANSFORMS ///////////////////////////////////
+  /**
+   * Set the current transform
+   */ 
+  public void setTransform(AffineTransform tx)
   {
-    if (bimage != null && pixelConversionRequired)
+    transform = tx;
+    if (transform != null)
       {
-        int height = bimage.getHeight();
-        int width = bimage.getWidth();
-        int index = 0;
-        for (int y = 0; y < height; ++y)
-          for (int x = 0; x < width; ++x)
-            bimage.setRGB(x, y, pixelBuffer[index++]);
+	double[] m = new double[6];
+	transform.getMatrix(m);
+	cairoSetMatrix(m);
       }
   }
-
-  private boolean drawImage(Image img, AffineTransform xform,
-                            Color bgcolor, ImageObserver obs)
+  
+  public void transform(AffineTransform tx)
   {
-    if (img == null)
-      return false;
-
-    // FIXME: I'll fix this, /Sven
-//     if (img instanceof GtkOffScreenImage
-//         && img.getGraphics() instanceof GdkGraphics2D
-//         && (xform == null || xform.getType() == AffineTransform.TYPE_IDENTITY
-//         || xform.getType() == AffineTransform.TYPE_TRANSLATION))
-//       {
-// 	// we are being asked to flush a double buffer from Gdk
-// 	GdkGraphics2D g2 = (GdkGraphics2D) img.getGraphics();
-// 	gdkDrawDrawable(g2, (int) xform.getTranslateX(),
-// 	                (int) xform.getTranslateY());
-
-// 	updateBufferedImage();
-
-// 	return true;
-//       }
-//     else
+    if (transform == null)
+      transform = new AffineTransform(tx);
+    else
+      transform.concatenate(tx);
+    setTransform(transform);
+    if (clip != null)
       {
-	// In this case, xform is an AffineTransform that transforms bounding
-	// box of the specified image from image space to user space. However
-	// when we pass this transform to cairo, cairo will use this transform
-	// to map "user coordinates" to "pixel" coordinates, which is the 
-	// other way around. Therefore to get the "user -> pixel" transform 
-	// that cairo wants from "image -> user" transform that we currently
-	// have, we will need to invert the transformation matrix.
-	AffineTransform invertedXform = new AffineTransform();
-
+	// FIXME: this should actuall try to transform the shape
+	// rather than degrade to bounds.
+	Rectangle2D r = clip.getBounds2D();
+	double[] coords = new double[]
+	  {
+	    r.getX(), r.getY(), r.getX() + r.getWidth(),
+	    r.getY() + r.getHeight()
+	  };
 	try
 	  {
-	    invertedXform = xform.createInverse();
-	    if (img instanceof BufferedImage)
-	      {
-		// draw an image which has actually been loaded 
-		// into memory fully
-		BufferedImage b = (BufferedImage) img;
-		return drawRaster(b.getColorModel(), b.getTile(0, 0),
-		                  invertedXform, bgcolor);
-	      }
-	    else
-	      return this.drawImage(GdkPixbufDecoder.createBufferedImage(img
-	                                                                 .getSource()),
-	                            xform, bgcolor, obs);
+	    tx.createInverse().transform(coords, 0, coords, 0, 2);
+	    r.setRect(coords[0], coords[1], coords[2] - coords[0],
+	              coords[3] - coords[1]);
+	    clip = r;
 	  }
-	catch (NoninvertibleTransformException e)
+	catch (java.awt.geom.NoninvertibleTransformException e)
 	  {
-	    throw new ImagingOpException("Unable to invert transform "
-	                                 + xform.toString());
 	  }
       }
   }
 
-  //////////////////////////////////////////////////
-  ////// Implementation of Graphics2D Methods //////
-  //////////////////////////////////////////////////
+  public void rotate(double theta)
+  {
+    transform(AffineTransform.getRotateInstance(theta));
+  }
 
-  public void draw(Shape s)
+  public void rotate(double theta, double x, double y)
   {
-    if (stroke != null && ! (stroke instanceof BasicStroke))
-      {
-	fill(stroke.createStrokedShape(s));
-	return;
-      }
-
-    cairoNewPath();
-
-    if (s instanceof Rectangle2D)
-      {
-	Rectangle2D r = (Rectangle2D) s;
-	cairoRectangle(shifted(r.getX(), shiftDrawCalls),
-	               shifted(r.getY(), shiftDrawCalls), r.getWidth(),
-	               r.getHeight());
-      }
-    else
-      walkPath(s.getPathIterator(null), shiftDrawCalls);
-    cairoStroke();
+    transform(AffineTransform.getRotateInstance(theta, x, y));
+  }
 
-    updateBufferedImage();
+  public void scale(double sx, double sy)
+  {
+    transform(AffineTransform.getScaleInstance(sx, sy));
   }
 
-  public void fill(Shape s)
+  /**
+   * Translate the system of the co-ordinates. As translation is a frequent
+   * operation, it is done in an optimised way, unlike scaling and rotating.
+   */
+  public void translate(double tx, double ty)
   {
-    cairoNewPath();
-    if (s instanceof Rectangle2D)
+    if (transform != null)
+      transform.translate(tx, ty);
+    else
+      transform = AffineTransform.getTranslateInstance(tx, ty);
+
+    if (clip != null)
       {
-	Rectangle2D r = (Rectangle2D) s;
-	cairoRectangle(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+        // FIXME: this should actuall try to transform the shape
+        // rather than degrade to bounds.
+        Rectangle2D r;
+
+        if (clip instanceof Rectangle2D)
+          r = (Rectangle2D) clip;
+        else
+          r = clip.getBounds2D();
+
+        r.setRect(r.getX() - tx, r.getY() - ty, r.getWidth(), r.getHeight());
+        clip = r;
       }
-    else
-      walkPath(s.getPathIterator(null), false);
 
-    cairoFill();
+    setTransform(transform);
+  }
+  
+  public void translate(int x, int y)
+  {
+    translate((double) x, (double) y);
+  }
 
-    updateBufferedImage();
+  public void shear(double shearX, double shearY)
+  {
+    transform(AffineTransform.getShearInstance(shearX, shearY));
   }
 
+  ///////////////////////// DRAWING STATE ///////////////////////////////////
+
   public void clip(Shape s)
   {
-    // update it
-    if (clip == null || s == null)
-      clip = s;
-    else if (s instanceof Rectangle2D && clip instanceof Rectangle2D)
-      {
-	Rectangle2D r = (Rectangle2D) s;
-	Rectangle2D curr = (Rectangle2D) clip;
-	clip = curr.createIntersection(r);
-      }
-    else
-      throw new UnsupportedOperationException();
+    // Do not touch clip when s == null.
+    if (s == null)
+      return;
 
-    // draw it
-    if (clip != null)
+    // If the current clip is still null, initialize it.
+    if (clip == null)
+      clip = originalClip;
+    
+    // This is so common, let's optimize this. 
+    else if (clip instanceof Rectangle2D && s instanceof Rectangle2D)
       {
-	cairoNewPath();
-	if (clip instanceof Rectangle2D)
-	  {
-	    Rectangle2D r = (Rectangle2D) clip;
-	    cairoRectangle(r.getX(), r.getY(), r.getWidth(), r.getHeight());
-	  }
-	else
-	  walkPath(clip.getPathIterator(null), false);
-
-	// cairoClosePath ();
-	cairoClip();
+        Rectangle2D clipRect = (Rectangle2D) clip;
+        Rectangle2D r = (Rectangle2D) s;
+        Rectangle2D.intersect(clipRect, r, clipRect);
+        // Call setClip so that subclasses get notified.
+        setClip(clipRect);
       }
+   else
+     {
+       Area current;
+       if (clip instanceof Area)
+         current = (Area) clip;
+       else
+         current = new Area(clip);
+
+       Area intersect;
+       if (s instanceof Area)
+         intersect = (Area) s;
+       else
+         intersect = new Area(s);
+
+       current.intersect(intersect);
+       clip = current;
+       // Call setClip so that the native side gets notified.
+       setClip(clip);
+     }
   }
 
   public Paint getPaint()
@@ -720,8 +596,8 @@ public class GdkGraphics2D extends Graphics2D
 	int width = (int) tp.getAnchorRect().getWidth();
 	int height = (int) tp.getAnchorRect().getHeight();
 
-	double scaleX = width / (double) img.getWidth();
-	double scaleY = width / (double) img.getHeight();
+	double scaleX = (width+1) / (double) img.getWidth();
+	double scaleY = (height+1) / (double) img.getHeight();
 
 	AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
 	AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
@@ -744,131 +620,6 @@ public class GdkGraphics2D extends Graphics2D
       throw new java.lang.UnsupportedOperationException();
   }
 
-  public void setPaintUnlocked(Paint p)
-  {
-    if (paint == null)
-      return;
-
-    paint = p;
-    if (paint instanceof Color)
-      {
-        setColorUnlocked((Color) paint);
-      }
-    else if (paint instanceof TexturePaint)
-      {
-	TexturePaint tp = (TexturePaint) paint;
-	BufferedImage img = tp.getImage();
-
-	// map the image to the anchor rectangle  
-	int width = (int) tp.getAnchorRect().getWidth();
-	int height = (int) tp.getAnchorRect().getHeight();
-
-	double scaleX = width / (double) img.getWidth();
-	double scaleY = width / (double) img.getHeight();
-
-	AffineTransform at = new AffineTransform(scaleX, 0, 0, scaleY, 0, 0);
-	AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
-	BufferedImage texture = op.filter(img, null);
-	int[] pixels = texture.getRGB(0, 0, width, height, null, 0, width);
-	setTexturePixelsUnlocked(pixels, width, height, width);
-      }
-    else if (paint instanceof GradientPaint)
-      {
-	GradientPaint gp = (GradientPaint) paint;
-	Point2D p1 = gp.getPoint1();
-	Point2D p2 = gp.getPoint2();
-	Color c1 = gp.getColor1();
-	Color c2 = gp.getColor2();
-	setGradientUnlocked(p1.getX(), p1.getY(), p2.getX(), p2.getY(), c1.getRed(),
-	            c1.getGreen(), c1.getBlue(), c1.getAlpha(), c2.getRed(),
-	            c2.getGreen(), c2.getBlue(), c2.getAlpha(), gp.isCyclic());
-      }
-    else
-      throw new java.lang.UnsupportedOperationException();
-  }
-
-  public void setTransform(AffineTransform tx)
-  {
-    transform = tx;
-    if (transform != null)
-      {
-	double[] m = new double[6];
-	transform.getMatrix(m);
-	cairoSetMatrix(m);
-      }
-  }
-
-  public void setTransformUnlocked(AffineTransform tx)
-  {
-    transform = tx;
-    if (transform != null)
-      {
-	double[] m = new double[6];
-	transform.getMatrix(m);
-	cairoSetMatrixUnlocked(m);
-      }
-  }
-
-  public void transform(AffineTransform tx)
-  {
-    if (transform == null)
-      transform = new AffineTransform(tx);
-    else
-      transform.concatenate(tx);
-    setTransform(transform);
-    if (clip != null)
-      {
-	// FIXME: this should actuall try to transform the shape
-	// rather than degrade to bounds.
-	Rectangle2D r = clip.getBounds2D();
-	double[] coords = new double[]
-	                  {
-	                    r.getX(), r.getY(), r.getX() + r.getWidth(),
-	                    r.getY() + r.getHeight()
-	                  };
-	try
-	  {
-	    tx.createInverse().transform(coords, 0, coords, 0, 2);
-	    r.setRect(coords[0], coords[1], coords[2] - coords[0],
-	              coords[3] - coords[1]);
-	    clip = r;
-	  }
-	catch (java.awt.geom.NoninvertibleTransformException e)
-	  {
-	  }
-      }
-  }
-
-  public void rotate(double theta)
-  {
-    transform(AffineTransform.getRotateInstance(theta));
-  }
-
-  public void rotate(double theta, double x, double y)
-  {
-    transform(AffineTransform.getRotateInstance(theta, x, y));
-  }
-
-  public void scale(double sx, double sy)
-  {
-    transform(AffineTransform.getScaleInstance(sx, sy));
-  }
-
-  public void translate(double tx, double ty)
-  {
-    transform(AffineTransform.getTranslateInstance(tx, ty));
-  }
-
-  public void translate(int x, int y)
-  {
-    translate((double) x, (double) y);
-  }
-
-  public void shear(double shearX, double shearY)
-  {
-    transform(AffineTransform.getShearInstance(shearX, shearY));
-  }
-
   public Stroke getStroke()
   {
     return stroke;
@@ -880,10 +631,9 @@ public class GdkGraphics2D extends Graphics2D
     if (stroke instanceof BasicStroke)
       {
 	BasicStroke bs = (BasicStroke) stroke;
-	cairoSetLineCap(bs.getEndCap());
-	cairoSetLineWidth(bs.getLineWidth());
-	cairoSetLineJoin(bs.getLineJoin());
-	cairoSetMiterLimit(bs.getMiterLimit());
+	cairoSetLine(bs.getLineWidth(), bs.getEndCap(), 
+		     bs.getLineJoin(), bs.getMiterLimit());
+
 	float[] dashes = bs.getDashArray();
 	if (dashes != null)
 	  {
@@ -898,42 +648,14 @@ public class GdkGraphics2D extends Graphics2D
       }
   }
 
-  public void setStrokeUnlocked(Stroke st)
-  {
-    stroke = st;
-    if (stroke instanceof BasicStroke)
-      {
-	BasicStroke bs = (BasicStroke) stroke;
-	cairoSetLineCapUnlocked(bs.getEndCap());
-	cairoSetLineWidthUnlocked(bs.getLineWidth());
-	cairoSetLineJoinUnlocked(bs.getLineJoin());
-	cairoSetMiterLimitUnlocked(bs.getMiterLimit());
-	float[] dashes = bs.getDashArray();
-	if (dashes != null)
-	  {
-	    double[] double_dashes = new double[dashes.length];
-	    for (int i = 0; i < dashes.length; i++)
-	      double_dashes[i] = dashes[i];
-	    cairoSetDashUnlocked(double_dashes, double_dashes.length,
-                                 (double) bs.getDashPhase());
-	  }
-	else
-	  cairoSetDashUnlocked(new double[0], 0, 0.0);
-      }
-  }
-
-  ////////////////////////////////////////////////
-  ////// Implementation of Graphics Methods //////
-  ////////////////////////////////////////////////
-
   public void setPaintMode()
   {
-    setComposite(java.awt.AlphaComposite.SrcOver);
+    setComposite(AlphaComposite.SrcOver);
   }
 
   public void setXORMode(Color c)
   {
-    setComposite(new gnu.java.awt.BitwiseXORComposite(c));
+    // FIXME: implement
   }
 
   public void setColor(Color c)
@@ -943,18 +665,17 @@ public class GdkGraphics2D extends Graphics2D
 
     fg = c;
     paint = c;
-    cairoSetRGBAColor(fg.getRed() / 255.0, fg.getGreen() / 255.0,
-                      fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
+    updateColor();
   }
-
-  public void setColorUnlocked(Color c)
+  
+  /**
+   * Set the current fg value as the cairo color.
+   */
+  void updateColor()
   {
-    if (c == null)
-      c = Color.BLACK;
-
-    fg = c;
-    paint = c;
-    cairoSetRGBAColorUnlocked(fg.getRed() / 255.0, fg.getGreen() / 255.0,
+    if (fg == null)
+      fg = Color.BLACK;
+    cairoSetRGBAColor(fg.getRed() / 255.0, fg.getGreen() / 255.0,
                       fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
   }
 
@@ -963,11 +684,6 @@ public class GdkGraphics2D extends Graphics2D
     return fg;
   }
 
-  public Color getColorUnlocked()
-  {
-    return getColor();
-  }
-
   public void clipRect(int x, int y, int width, int height)
   {
     clip(new Rectangle(x, y, width, height));
@@ -1011,81 +727,41 @@ public class GdkGraphics2D extends Graphics2D
 
   public void setClip(int x, int y, int width, int height)
   {
-    setClip(new Rectangle2D.Double((double) x, (double) y, (double) width,
-                                   (double) height));
+    if( width < 0 || height < 0 )
+      return;
+
+    setClip(new Rectangle2D.Double(x, y, width, height));
   }
 
   public void setClip(Shape s)
-  {
-    clip = s;
-    if (clip == null)
-      {
-	// Reset clipping.
-        if (component != null)
-          {
-            Dimension d = component.awtComponent.getSize();
-            setClip(0, 0, d.width, d.height);
-          }
-      }
-    else
+  {    
+    // The first time the clip is set, save it as the original clip 
+    // to reset to on s == null. We can rely on this being non-null 
+    // because the constructor in subclasses is expected to set the 
+    // initial clip properly.
+    if( firstClip )
       {
-	cairoNewPath();
-	if (s instanceof Rectangle2D)
-	  {
-	    Rectangle2D r = (Rectangle2D) s;
-	    cairoRectangle(r.getX(), r.getY(), r.getWidth(), r.getHeight());
-	  }
-	else
-	  walkPath(s.getPathIterator(null), false);
-
-	// cairoClosePath ();
-	cairoClip();
+	originalClip = s;
+	firstClip = false;
       }
-  }
-
-  private static BasicStroke draw3DRectStroke = new BasicStroke();
-
-  public void draw3DRect(int x, int y, int width, int height, boolean raised)
-  {
-    Stroke tmp = stroke;
-    setStroke(draw3DRectStroke);
-    super.draw3DRect(x, y, width, height, raised);
-    setStroke(tmp);
-    updateBufferedImage();
-  }
-
-  public void fill3DRect(int x, int y, int width, int height, boolean raised)
-  {
-    Stroke tmp = stroke;
-    setStroke(draw3DRectStroke);
-    super.fill3DRect(x, y, width, height, raised);
-    setStroke(tmp);
-    updateBufferedImage();
-  }
 
-  public void drawRect(int x, int y, int width, int height)
-  {
-    draw(new Rectangle(x, y, width, height));
-  }
+    if (s == null)
+      clip = originalClip;
+    else
+      clip = s;
 
-  public void fillRect(int x, int y, int width, int height)
-  {
-    cairoNewPath();
-    cairoRectangle(x, y, width, height);
-    cairoFill();
-  }
+    cairoResetClip();
 
-  public void clearRect(int x, int y, int width, int height)
-  {
-    if (bg != null)
-      cairoSetRGBAColor(bg.getRed() / 255.0, bg.getGreen() / 255.0,
-			bg.getBlue() / 255.0, 1.0);
     cairoNewPath();
-    cairoRectangle(x, y, width, height);
-    cairoFill();
-    setColor(fg);
-
-    updateBufferedImage();
+    if (clip instanceof Rectangle2D)
+      {
+	Rectangle2D r = (Rectangle2D) clip;
+	cairoRectangle(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+      }
+    else
+      walkPath(clip.getPathIterator(null), false);
+    
+    cairoClip();
   }
 
   public void setBackground(Color c)
@@ -1095,203 +771,232 @@ public class GdkGraphics2D extends Graphics2D
     bg = c;
   }
 
-  public void setBackgroundUnlocked(Color c)
+  public Color getBackground()
   {
-    setBackground(c);
+    return bg;
   }
 
-  public Color getBackground()
+  /**
+   * Return the current composite.
+   */
+  public Composite getComposite()
   {
-    return bg;
+    if (comp == null)
+      return AlphaComposite.SrcOver;
+    else
+      return comp;
   }
 
-  private void doPolygon(int[] xPoints, int[] yPoints, int nPoints,
-                         boolean close, boolean fill)
+  /**
+   * Sets the current composite context.
+   */
+  public void setComposite(Composite comp)
   {
-    if (nPoints < 1)
-      return;
-    GeneralPath gp = new GeneralPath(PathIterator.WIND_EVEN_ODD);
-    gp.moveTo((float) xPoints[0], (float) yPoints[0]);
-    for (int i = 1; i < nPoints; i++)
-      gp.lineTo((float) xPoints[i], (float) yPoints[i]);
-
-    if (close)
-      gp.closePath();
+    this.comp = comp;
 
-    Shape sh = gp;
-    if (fill == false && stroke != null && ! (stroke instanceof BasicStroke))
+    if (comp instanceof AlphaComposite)
       {
-	sh = stroke.createStrokedShape(gp);
-	fill = true;
+	AlphaComposite a = (AlphaComposite) comp;
+	cairoSetOperator(a.getRule());
+	Color c = getColor();
+	setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(),
+	                   (int) (a.getAlpha() * ((float) c.getAlpha()))));
       }
-
-    if (fill)
-      fill(sh);
     else
-      draw(sh);
+      {
+        // FIXME: implement general Composite support
+        throw new java.lang.UnsupportedOperationException();
+      }
   }
 
-  public void drawLine(int x1, int y1, int x2, int y2)
+  ///////////////////////// DRAWING PRIMITIVES ///////////////////////////////////
+
+  public void draw(Shape s)
   {
-    int[] xp = new int[2];
-    int[] yp = new int[2];
+    if (stroke != null && ! (stroke instanceof BasicStroke))
+      {
+	fill(stroke.createStrokedShape(s));
+	return;
+      }
 
-    xp[0] = x1;
-    xp[1] = x2;
-    yp[0] = y1;
-    yp[1] = y2;
+    cairoNewPath();
 
-    doPolygon(xp, yp, 2, false, false);
+    if (s instanceof Rectangle2D)
+      {
+	Rectangle2D r = (Rectangle2D) s;
+	cairoRectangle(shifted(r.getX(), shiftDrawCalls),
+	               shifted(r.getY(), shiftDrawCalls), r.getWidth(),
+	               r.getHeight());
+      }
+    else
+      walkPath(s.getPathIterator(null), shiftDrawCalls);
+    cairoStroke();
   }
 
-  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
+  public void fill(Shape s)
   {
-    doPolygon(xPoints, yPoints, nPoints, true, true);
+    cairoNewPath();
+    if (s instanceof Rectangle2D)
+      {
+	Rectangle2D r = (Rectangle2D) s;
+	cairoRectangle(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+      }
+    else
+      walkPath(s.getPathIterator(null), false);
+
+    cairoFill();
   }
 
-  public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
+  /**
+   * Note that the rest of the drawing methods go via fill() or draw() for the drawing,
+   * although subclasses may with to overload these methods where context-specific 
+   * optimizations are possible (e.g. bitmaps and fillRect(int, int, int, int)
+   */
+
+  public void clearRect(int x, int y, int width, int height)
   {
-    doPolygon(xPoints, yPoints, nPoints, true, false);
+    if (bg != null)
+      cairoSetRGBAColor(bg.getRed() / 255.0, bg.getGreen() / 255.0,
+			bg.getBlue() / 255.0, 1.0);
+    fillRect(x, y, width, height);
+    updateColor();
   }
 
-  public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
+  public void draw3DRect(int x, int y, int width, int height, boolean raised)
   {
-    doPolygon(xPoints, yPoints, nPoints, false, false);
+    Stroke tmp = stroke;
+    setStroke(draw3DRectStroke);
+    super.draw3DRect(x, y, width, height, raised);
+    setStroke(tmp);
   }
 
-  private boolean drawRaster(ColorModel cm, Raster r,
-                             AffineTransform imageToUser, Color bgcolor)
+  public void drawArc(int x, int y, int width, int height, int startAngle,
+                      int arcAngle)
   {
-    if (r == null)
-      return false;
-
-    SampleModel sm = r.getSampleModel();
-    DataBuffer db = r.getDataBuffer();
-
-    if (db == null || sm == null)
-      return false;
-
-    if (cm == null)
-      cm = ColorModel.getRGBdefault();
-
-    double[] i2u = new double[6];
-    if (imageToUser != null)
-      imageToUser.getMatrix(i2u);
-    else
-      {
-	i2u[0] = 1;
-	i2u[1] = 0;
-	i2u[2] = 0;
-	i2u[3] = 1;
-	i2u[4] = 0;
-	i2u[5] = 0;
-      }
-
-    int[] pixels = findSimpleIntegerArray(cm, r);
-
-    if (pixels == null)
-      {
-	// FIXME: I don't think this code will work correctly with a non-RGB
-	// MultiPixelPackedSampleModel. Although this entire method should 
-	// probably be rewritten to better utilize Cairo's different supported
-	// data formats.
-	if (sm instanceof MultiPixelPackedSampleModel)
-	  {
-	    pixels = r.getPixels(0, 0, r.getWidth(), r.getHeight(), pixels);
-	    for (int i = 0; i < pixels.length; i++)
-	      pixels[i] = cm.getRGB(pixels[i]);
-	  }
-	else
-	  {
-	    pixels = new int[r.getWidth() * r.getHeight()];
-	    for (int i = 0; i < pixels.length; i++)
-	      pixels[i] = cm.getRGB(db.getElem(i));
-	  }
-      }
-
-    // Change all transparent pixels in the image to the specified bgcolor,
-    // or (if there's no alpha) fill in an alpha channel so that it paints
-    // correctly.
-    if (cm.hasAlpha())
-      {
-	if (bgcolor != null && cm.hasAlpha())
-	  for (int i = 0; i < pixels.length; i++)
-	    {
-	      if (cm.getAlpha(pixels[i]) == 0)
-		pixels[i] = bgcolor.getRGB();
-	    }
-      }
-    else
-      for (int i = 0; i < pixels.length; i++)
-	pixels[i] |= 0xFF000000;
+    draw(new Arc2D.Double((double) x, (double) y, (double) width,
+                          (double) height, (double) startAngle,
+                          (double) arcAngle, Arc2D.OPEN));
+  }
 
-    drawPixels(pixels, r.getWidth(), r.getHeight(), r.getWidth(), i2u);
+  public void drawLine(int x1, int y1, int x2, int y2)
+  {
+    draw(new Line2D.Double(x1, y1, x2, y2));
+  }
 
-    updateBufferedImage();
-    
-    // Cairo seems loosing the current color.
-    setColor(fg);
-    
-    return true;
+  public void drawRect(int x, int y, int width, int height)
+  {
+    draw(new Rectangle(x, y, width, height));
   }
 
-  public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+  public void fillArc(int x, int y, int width, int height, int startAngle,
+                      int arcAngle)
   {
-    drawRaster(image.getColorModel(), image.getData(), xform, bg);
+    fill(new Arc2D.Double((double) x, (double) y, (double) width,
+                          (double) height, (double) startAngle,
+                          (double) arcAngle, Arc2D.OPEN));
   }
 
-  public void drawRenderableImage(RenderableImage image, AffineTransform xform)
+  public void fillRect(int x, int y, int width, int height)
   {
-    drawRenderedImage(image.createRendering(new RenderContext(xform)), xform);
+    fill(new Rectangle(x, y, width, height));
   }
 
-  public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
+  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
   {
-    return drawImage(img, xform, bg, obs);
+    fill(new Polygon(xPoints, yPoints, nPoints));
   }
 
-  public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
+  public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
   {
-    Image filtered = op.filter(image, null);
-    drawImage(filtered, new AffineTransform(1f, 0f, 0f, 1f, x, y), bg, null);
+    draw(new Polygon(xPoints, yPoints, nPoints));
   }
 
-  public boolean drawImage(Image img, int x, int y, ImageObserver observer)
+  public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
   {
-    return drawImage(img, new AffineTransform(1f, 0f, 0f, 1f, x, y), bg,
-                     observer);
+    draw(new Polygon(xPoints, yPoints, nPoints));
   }
 
-  ///////////////////////////////////////////////
-  ////// Unimplemented Stubs and Overloads //////
-  ///////////////////////////////////////////////
+  public void drawOval(int x, int y, int width, int height)
+  {
+    drawArc(x, y, width, height, 0, 360);
+  }
 
-  public boolean hit(Rectangle rect, Shape text, boolean onStroke)
+  public void drawRoundRect(int x, int y, int width, int height, int arcWidth,
+                            int arcHeight)
   {
-    throw new java.lang.UnsupportedOperationException();
+    draw(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight));
   }
 
-  public GraphicsConfiguration getDeviceConfiguration()
+  public void fillOval(int x, int y, int width, int height)
   {
-    throw new java.lang.UnsupportedOperationException();
+    fillArc(x, y, width, height, 0, 360);
   }
 
-  public void setComposite(Composite comp)
+  public void fillRoundRect(int x, int y, int width, int height, int arcWidth,
+                            int arcHeight)
   {
-    this.comp = comp;
+    fill(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight));
+  }
+
+  /**
+   * CopyArea - performs clipping to the native surface as a convenience 
+   * (requires getRealBounds). Then calls copyAreaImpl.
+   */
+  public void copyArea(int ox, int oy, int owidth, int oheight, 
+		       int odx, int ody)
+  {
+    Point2D pos = transform.transform(new Point2D.Double(ox, oy),
+				      (Point2D) null);
+    Point2D dim = transform.transform(new Point2D.Double(ox + owidth, 
+							 oy + oheight),
+				      (Point2D) null);
+    Point2D p2 = transform.transform(new Point2D.Double(ox + odx, oy + ody),
+				     (Point2D) null);
+    int x = (int)pos.getX();
+    int y = (int)pos.getY();
+    int width = (int)(dim.getX() - pos.getX());
+    int height = (int)(dim.getY() - pos.getY());
+    int dx = (int)(p2.getX() - pos.getX());
+    int dy = (int)(p2.getY() - pos.getY());
+
+    Rectangle2D r = getRealBounds();
+
+    if( width < 0 || height < 0 )
+      return;
+    // Return if outside the surface
+    if( x + dx > r.getWidth() || y + dy > r.getHeight() )
+      return;
 
-    if (comp instanceof AlphaComposite)
+    if( x + dx + width < r.getX() || y + dy + height < r.getY() )
+      return;
+
+    // Clip edges if necessary 
+    if( x + dx < r.getX() ) // left
       {
-	AlphaComposite a = (AlphaComposite) comp;
-	cairoSetOperator(a.getRule());
-	Color c = getColor();
-	setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(),
-	                   (int) (a.getAlpha() * ((float) c.getAlpha()))));
+	width = x + dx + width;
+	x = (int)r.getX() - dx;
       }
-    else
-      throw new java.lang.UnsupportedOperationException();
+
+    if( y + dy < r.getY() ) // top
+      {
+	height = y + dy + height;
+	y = (int)r.getY() - dy;
+      }
+
+    if( x + dx + width >= r.getWidth() ) // right
+      width = (int)r.getWidth() - dx - x;
+
+    if( y + dy + height >= r.getHeight() ) // bottom
+      height = (int)r.getHeight() - dy - y;
+
+    copyAreaImpl(x, y, width, height, dx, dy);
   }
 
+  ///////////////////////// RENDERING HINTS ///////////////////////////////////
+
+  /**
+   * FIXME- support better
+   */
   public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
   {
     hints.put(hintKey, hintValue);
@@ -1316,7 +1021,7 @@ public class GdkGraphics2D extends Graphics2D
       }
 
     shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
-                     || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
+      || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
   }
 
   public Object getRenderingHint(RenderingHints.Key hintKey)
@@ -1351,74 +1056,137 @@ public class GdkGraphics2D extends Graphics2D
       }
 
     shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
-                     || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
+      || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
   }
 
-  public void setRenderingHintsUnlocked(Map hints)
+  public void addRenderingHints(Map hints)
   {
-    this.hints = new RenderingHints(getDefaultHints());
     this.hints.add(new RenderingHints(hints));
+  }
 
-    if (hints.containsKey(RenderingHints.KEY_INTERPOLATION))
-      {
-	if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR))
-	  cairoSurfaceSetFilterUnlocked(0);
+  public RenderingHints getRenderingHints()
+  {
+    return hints;
+  }
 
-	else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR))
-	  cairoSurfaceSetFilterUnlocked(1);
+  ///////////////////////// IMAGE. METHODS ///////////////////////////////////
+
+  protected boolean drawImage(Image img, AffineTransform xform,
+                            Color bgcolor, ImageObserver obs)
+  {
+    if (img == null)
+      return false;
+
+    // In this case, xform is an AffineTransform that transforms bounding
+    // box of the specified image from image space to user space. However
+    // when we pass this transform to cairo, cairo will use this transform
+    // to map "user coordinates" to "pixel" coordinates, which is the 
+    // other way around. Therefore to get the "user -> pixel" transform 
+    // that cairo wants from "image -> user" transform that we currently
+    // have, we will need to invert the transformation matrix.
+    AffineTransform invertedXform = new AffineTransform();
+
+    try
+      {
+	invertedXform = xform.createInverse();
+      }
+    catch (NoninvertibleTransformException e)
+      {
+	throw new ImagingOpException("Unable to invert transform "
+				     + xform.toString());
       }
 
-    if (hints.containsKey(RenderingHints.KEY_ALPHA_INTERPOLATION))
+    // Unrecognized image - convert to a BufferedImage and come back.
+    if( !(img instanceof BufferedImage) )
+      return this.drawImage(Toolkit.getDefaultToolkit().
+			    createImage(img.getSource()),
+			    xform, bgcolor, obs);
+
+    BufferedImage b = (BufferedImage) img;
+    DataBuffer db;
+    double[] i2u = new double[6];
+    int width = b.getWidth();
+    int height = b.getHeight();
+
+    // If this BufferedImage has a BufferedImageGraphics object, 
+    // use the cached CairoSurface that BIG is drawing onto
+    if( BufferedImageGraphics.bufferedImages.get( b ) != null )
+      db = (DataBuffer)BufferedImageGraphics.bufferedImages.get( b );
+    else
+      db = b.getRaster().getDataBuffer();
+
+    invertedXform.getMatrix(i2u);
+
+    if(db instanceof CairoSurface)
       {
-	if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED))
-	  cairoSurfaceSetFilterUnlocked(2);
+	((CairoSurface)db).drawSurface(this, i2u);
+	return true;
+      }
+	    
+    if( bgcolor != null )
+      {
+	// Fill a rectangle with the background color 
+	// to composite the image onto.
+	Paint oldPaint = paint;
+	AffineTransform oldTransform = transform;
+	setPaint( bgcolor );
+	setTransform( invertedXform );
+	fillRect(0, 0, width, height);
+	setTransform( oldTransform );
+	setPaint( oldPaint );
+      }
 
-	else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY))
-	  cairoSurfaceSetFilterUnlocked(3);
+    int[] pixels;
 
-	else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT))
-	  cairoSurfaceSetFilterUnlocked(4);
+    // Shortcut for easy color models.
+    if( b.getColorModel().equals(rgb32) )
+      {
+	pixels = ((DataBufferInt)db).getData();
+	for(int i = 0; i < pixels.length; i++)
+	  pixels[i] |= 0xFF000000;
+      }
+    else if( b.getColorModel().equals(argb32) )
+      {
+	pixels = ((DataBufferInt)db).getData();
+      }
+    else
+      {
+	pixels = b.getRGB(0, 0, width, height,
+			  null, 0, width);
       }
 
-    shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
-                     || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
+    drawPixels(pixels, width, height, width, i2u);
+
+    // Cairo seems to lose the current color which must be restored.
+    updateColor();
+    return true;
   }
 
-  public void addRenderingHints(Map hints)
+  public void drawRenderedImage(RenderedImage image, AffineTransform xform)
   {
-    this.hints.add(new RenderingHints(hints));
+    drawRaster(image.getColorModel(), image.getData(), xform, null);
   }
 
-  public RenderingHints getRenderingHints()
+  public void drawRenderableImage(RenderableImage image, AffineTransform xform)
   {
-    return hints;
+    drawRenderedImage(image.createRendering(new RenderContext(xform)), xform);
   }
 
-  public Composite getComposite()
+  public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
   {
-    if (comp == null)
-      return AlphaComposite.SrcOver;
-    else
-      return comp;
+    return drawImage(img, xform, null, obs);
   }
 
-  public FontRenderContext getFontRenderContext()
+  public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
   {
-    return new FontRenderContext(transform, true, true);
+    Image filtered = op.filter(image, null);
+    drawImage(filtered, new AffineTransform(1f, 0f, 0f, 1f, x, y), null, null);
   }
 
-  public void copyArea(int x, int y, int width, int height, int dx, int dy)
+  public boolean drawImage(Image img, int x, int y, ImageObserver observer)
   {
-    GdkGraphics2D g = (GdkGraphics2D) create(x, y, width, height);
-    gdkDrawDrawable(g, x + dx, y + dy);
-  }
-
-  public void drawArc(int x, int y, int width, int height, int startAngle,
-                      int arcAngle)
-  {
-    draw(new Arc2D.Double((double) x, (double) y, (double) width,
-                          (double) height, (double) startAngle,
-                          (double) arcAngle, Arc2D.OPEN));
+    return drawImage(img, new AffineTransform(1f, 0f, 0f, 1f, x, y), null,
+                     observer);
   }
 
   public boolean drawImage(Image img, int x, int y, Color bgcolor,
@@ -1433,6 +1201,8 @@ public class GdkGraphics2D extends Graphics2D
   {
     double scaleX = width / (double) img.getWidth(observer);
     double scaleY = height / (double) img.getHeight(observer);
+    if( scaleX == 0 || scaleY == 0 )
+      return true;
 
     return drawImage(img, new AffineTransform(scaleX, 0f, 0f, scaleY, x, y),
                      bgcolor, observer);
@@ -1441,7 +1211,7 @@ public class GdkGraphics2D extends Graphics2D
   public boolean drawImage(Image img, int x, int y, int width, int height,
                            ImageObserver observer)
   {
-    return drawImage(img, x, y, width, height, bg, observer);
+    return drawImage(img, x, y, width, height, null, observer);
   }
 
   public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
@@ -1451,101 +1221,51 @@ public class GdkGraphics2D extends Graphics2D
     if (img == null)
       return false;
 
-    Image subImage;
-
     int sourceWidth = sx2 - sx1;
     int sourceHeight = sy2 - sy1;
 
     int destWidth = dx2 - dx1;
     int destHeight = dy2 - dy1;
 
+    if(destWidth == 0 || destHeight == 0 || sourceWidth == 0 || 
+       sourceHeight == 0)
+      return true;
+
     double scaleX = destWidth / (double) sourceWidth;
     double scaleY = destHeight / (double) sourceHeight;
 
-    // Get the subimage of the source enclosed in the 
-    // rectangle specified by sx1, sy1, sx2, sy2
-	
-    if (img instanceof BufferedImage)
-      {
-	BufferedImage b = (BufferedImage) img;
-	subImage = b.getSubimage(sx1, sy1, sx2, sy2);
-      }
+    // FIXME: Avoid using an AT if possible here - it's at least twice as slow.
+    
+    Shape oldClip = getClip();
+    int cx, cy, cw, ch;
+    if( dx1 < dx2 ) 
+      { cx = dx1; cw = dx2 - dx1; }
     else
-      {
-	// FIXME: This code currently doesn't work. Null Pointer 
-	// exception is thrown in this case. This happens 
-	// because img.getSource() always returns null, since source gets 
-	// never initialized when it is created with the help of 
-	// createImage(int width, int height). 
-	CropImageFilter filter = new CropImageFilter(sx1, sx2, sx2, sy2);
-	FilteredImageSource src = new FilteredImageSource(img.getSource(),
-	                                                  filter);
-
-	subImage = Toolkit.getDefaultToolkit().createImage(src);
-      }
+      { cx = dx2; cw = dx1 - dx2; }
+    if( dy1 < dy2 ) 
+      { cy = dy1; ch = dy2 - dy1; }
+    else
+      { cy = dy2; ch = dy1 - dy2; }
+    
+    setClip( cx, cy, cw, ch );
 
-    return drawImage(subImage,
-                     new AffineTransform(scaleX, 0, 0, scaleY, dx1, dy1),
-                     bgcolor, observer);
+    AffineTransform tx = new AffineTransform();
+    tx.translate( dx1 - sx1*scaleX, dy1 - sy1*scaleY );
+    tx.scale( scaleX, scaleY );
+
+    boolean retval = drawImage(img, tx, bgcolor, observer);
+    setClip( oldClip );
+    return retval;
   }
 
   public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
                            int sx1, int sy1, int sx2, int sy2,
                            ImageObserver observer)
   {
-    return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bg, observer);
-  }
-
-  public void drawOval(int x, int y, int width, int height)
-  {
-    drawArc(x, y, width, height, 0, 360);
-  }
-
-  public void drawRoundRect(int x, int y, int width, int height, int arcWidth,
-                            int arcHeight)
-  {
-    if (arcWidth > width)
-      arcWidth = width;
-    if (arcHeight > height)
-      arcHeight = height;
-
-    int xx = x + width - arcWidth;
-    int yy = y + height - arcHeight;
-
-    drawArc(x, y, arcWidth, arcHeight, 90, 90);
-    drawArc(xx, y, arcWidth, arcHeight, 0, 90);
-    drawArc(xx, yy, arcWidth, arcHeight, 270, 90);
-    drawArc(x, yy, arcWidth, arcHeight, 180, 90);
-
-    int y1 = y + arcHeight / 2;
-    int y2 = y + height - arcHeight / 2;
-    drawLine(x, y1, x, y2);
-    drawLine(x + width, y1, x + width, y2);
-
-    int x1 = x + arcWidth / 2;
-    int x2 = x + width - arcWidth / 2;
-    drawLine(x1, y, x2, y);
-    drawLine(x1, y + height, x2, y + height);
-  }
-
-  // these are the most accelerated painting paths
-  native void cairoDrawGlyphVector(GdkFontPeer font, 
-                                   float x, float y, int n, 
-                                   int[] codes, float[] positions);
-
-  native void cairoDrawGdkTextLayout(GdkTextLayout gl, 
-                                     float x, float y);
-
-  GdkFontPeer getFontPeer()
-  {
-    return (GdkFontPeer) getFont().getPeer();
+    return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null, observer);
   }
 
-  public void drawGdkTextLayout(GdkTextLayout gl, float x, float y)
-  {
-    cairoDrawGdkTextLayout (gl, x, y);
-    updateBufferedImage ();
-  }
+  ///////////////////////// TEXT METHODS ////////////////////////////////////
 
   public void drawString(String str, float x, float y)
   {
@@ -1553,7 +1273,6 @@ public class GdkGraphics2D extends Graphics2D
       return;
 
     drawGlyphVector(getFont().createGlyphVector(null, str), x, y);
-    updateBufferedImage ();
   }
 
   public void drawString(String str, int x, int y)
@@ -1573,8 +1292,7 @@ public class GdkGraphics2D extends Graphics2D
     float[] positions = gv.getGlyphPositions (0, n, null);
     
     setFont (gv.getFont ());
-    cairoDrawGlyphVector (getFontPeer(), x, y, n, codes, positions);
-    updateBufferedImage ();
+    cairoDrawGlyphVector( (GdkFontPeer)getFont().getPeer(), x, y, n, codes, positions);
   }
 
   public void drawString(AttributedCharacterIterator ci, float x, float y)
@@ -1583,52 +1301,19 @@ public class GdkGraphics2D extends Graphics2D
     drawGlyphVector(gv, x, y);
   }
 
-  public void fillArc(int x, int y, int width, int height, int startAngle,
-                      int arcAngle)
-  {
-    fill(new Arc2D.Double((double) x, (double) y, (double) width,
-                          (double) height, (double) startAngle,
-                          (double) arcAngle, Arc2D.OPEN));
-  }
-
-  public void fillOval(int x, int y, int width, int height)
-  {
-    fillArc(x, y, width, height, 0, 360);
-  }
-
-  public void fillRoundRect(int x, int y, int width, int height, int arcWidth,
-                            int arcHeight)
-  {
-    if (arcWidth > width)
-      arcWidth = width;
-    if (arcHeight > height)
-      arcHeight = height;
-
-    int xx = x + width - arcWidth;
-    int yy = y + height - arcHeight;
-
-    fillArc(x, y, arcWidth, arcHeight, 90, 90);
-    fillArc(xx, y, arcWidth, arcHeight, 0, 90);
-    fillArc(xx, yy, arcWidth, arcHeight, 270, 90);
-    fillArc(x, yy, arcWidth, arcHeight, 180, 90);
-
-    fillRect(x, y + arcHeight / 2, width, height - arcHeight + 1);
-    fillRect(x + arcWidth / 2, y, width - arcWidth + 1, height);
-  }
-
-  public Font getFont()
+  /**
+   * Should perhaps be contexct dependent, but this is left for now as an 
+   * overloadable default implementation.
+   */
+  public FontRenderContext getFontRenderContext()
   {
-    if (font == null)
-      return new Font("SansSerif", Font.PLAIN, 12);
-    return font;
+    return new FontRenderContext(transform, true, true);
   }
 
   // Until such time as pango is happy to talk directly to cairo, we
   // actually need to redirect some calls from the GtkFontPeer and
   // GtkFontMetrics into the drawing kit and ask cairo ourselves.
 
-  static native void releasePeerGraphicsResource(GdkFontPeer f);
-
   public FontMetrics getFontMetrics()
   {
     return getFontMetrics(getFont());
@@ -1656,9 +1341,25 @@ public class GdkGraphics2D extends Graphics2D
         .getFont(f.getName(), f.getAttributes());    
   }
 
-  public void setFontUnlocked(Font f)
+  public Font getFont()
   {
-    setFont (f);
+    if (font == null)
+      return new Font("SansSerif", Font.PLAIN, 12);
+    return font;
+  }
+
+  /////////////////////// MISC. PUBLIC METHODS /////////////////////////////////
+
+  public boolean hit(Rectangle rect, Shape s, boolean onStroke)
+  {
+    if( onStroke )
+      {
+	Shape stroked = stroke.createStrokedShape( s );
+	return stroked.intersects( (double)rect.x, (double)rect.y, 
+				   (double)rect.width, (double)rect.height );
+      }
+    return s.intersects( (double)rect.x, (double)rect.y, 
+			 (double)rect.width, (double)rect.height );
   }
 
   public String toString()
@@ -1668,4 +1369,218 @@ public class GdkGraphics2D extends Graphics2D
              + ",color=" + fg.toString()
 	     + "]");
   }
+
+  ///////////////////////// PRIVATE METHODS ///////////////////////////////////
+
+  /**
+   * All the drawImage() methods eventually get delegated here if the image
+   * is not a Cairo surface.
+   *
+   * @param bgcolor - if non-null draws the background color before 
+   * drawing the image.
+   */
+  private boolean drawRaster(ColorModel cm, Raster r,
+                             AffineTransform imageToUser, Color bgcolor)
+  {
+    if (r == null)
+      return false;
+
+    SampleModel sm = r.getSampleModel();
+    DataBuffer db = r.getDataBuffer();
+
+    if (db == null || sm == null)
+      return false;
+
+    if (cm == null)
+      cm = ColorModel.getRGBdefault();
+
+    double[] i2u = new double[6];
+    if (imageToUser != null)
+      imageToUser.getMatrix(i2u);
+    else
+      {
+	i2u[0] = 1;
+	i2u[1] = 0;
+	i2u[2] = 0;
+	i2u[3] = 1;
+	i2u[4] = 0;
+	i2u[5] = 0;
+      }
+
+    int[] pixels = findSimpleIntegerArray(cm, r);
+
+    if (pixels == null)
+      {
+	// FIXME: I don't think this code will work correctly with a non-RGB
+	// MultiPixelPackedSampleModel. Although this entire method should 
+	// probably be rewritten to better utilize Cairo's different supported
+	// data formats.
+	if (sm instanceof MultiPixelPackedSampleModel)
+	  {
+	    pixels = r.getPixels(0, 0, r.getWidth(), r.getHeight(), pixels);
+	    for (int i = 0; i < pixels.length; i++)
+	      pixels[i] = cm.getRGB(pixels[i]);
+	  }
+	else
+	  {
+	    pixels = new int[r.getWidth() * r.getHeight()];
+	    for (int i = 0; i < pixels.length; i++)
+	      pixels[i] = cm.getRGB(db.getElem(i));
+	  }
+      }
+
+    // Change all transparent pixels in the image to the specified bgcolor,
+    // or (if there's no alpha) fill in an alpha channel so that it paints
+    // correctly.
+    if (cm.hasAlpha())
+      {
+	if (bgcolor != null && cm.hasAlpha())
+	  for (int i = 0; i < pixels.length; i++)
+	    {
+	      if (cm.getAlpha(pixels[i]) == 0)
+		pixels[i] = bgcolor.getRGB();
+	    }
+      }
+    else
+      for (int i = 0; i < pixels.length; i++)
+	pixels[i] |= 0xFF000000;
+
+    drawPixels(pixels, r.getWidth(), r.getHeight(), r.getWidth(), i2u);
+
+    // Cairo seems to lose the current color which must be restored.
+    updateColor();
+    
+    return true;
+  }
+
+  /**
+   * Shifts coordinates by 0.5.
+   */
+  private double shifted(double coord, boolean doShift)
+  {
+    if (doShift)
+      return Math.floor(coord) + 0.5;
+    else
+      return coord;
+  }
+
+  /**
+   * Adds a pathIterator to the current Cairo path, also sets the cairo winding rule.
+   */
+  private void walkPath(PathIterator p, boolean doShift)
+  {
+    double x = 0;
+    double y = 0;
+    double[] coords = new double[6];
+
+    cairoSetFillRule(p.getWindingRule());
+    for (; ! p.isDone(); p.next())
+      {
+	int seg = p.currentSegment(coords);
+	switch (seg)
+	  {
+	  case PathIterator.SEG_MOVETO:
+	    x = shifted(coords[0], doShift);
+	    y = shifted(coords[1], doShift);
+	    cairoMoveTo(x, y);
+	    break;
+	  case PathIterator.SEG_LINETO:
+	    x = shifted(coords[0], doShift);
+	    y = shifted(coords[1], doShift);
+	    cairoLineTo(x, y);
+	    break;
+	  case PathIterator.SEG_QUADTO:
+	    // splitting a quadratic bezier into a cubic:
+	    // see: http://pfaedit.sourceforge.net/bezier.html
+	    double x1 = x + (2.0 / 3.0) * (shifted(coords[0], doShift) - x);
+	    double y1 = y + (2.0 / 3.0) * (shifted(coords[1], doShift) - y);
+
+	    double x2 = x1 + (1.0 / 3.0) * (shifted(coords[2], doShift) - x);
+	    double y2 = y1 + (1.0 / 3.0) * (shifted(coords[3], doShift) - y);
+
+	    x = shifted(coords[2], doShift);
+	    y = shifted(coords[3], doShift);
+	    cairoCurveTo(x1, y1, x2, y2, x, y);
+	    break;
+	  case PathIterator.SEG_CUBICTO:
+	    x = shifted(coords[4], doShift);
+	    y = shifted(coords[5], doShift);
+	    cairoCurveTo(shifted(coords[0], doShift),
+	                 shifted(coords[1], doShift),
+	                 shifted(coords[2], doShift),
+	                 shifted(coords[3], doShift), x, y);
+	    break;
+	  case PathIterator.SEG_CLOSE:
+	    cairoClosePath();
+	    break;
+	  }
+      }
+  }
+
+  /**
+   * Used by setRenderingHints()
+   */
+  private Map getDefaultHints()
+  {
+    HashMap defaultHints = new HashMap();
+
+    defaultHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
+                     RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
+
+    defaultHints.put(RenderingHints.KEY_STROKE_CONTROL,
+                     RenderingHints.VALUE_STROKE_DEFAULT);
+
+    defaultHints.put(RenderingHints.KEY_FRACTIONALMETRICS,
+                     RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
+
+    defaultHints.put(RenderingHints.KEY_ANTIALIASING,
+                     RenderingHints.VALUE_ANTIALIAS_OFF);
+
+    defaultHints.put(RenderingHints.KEY_RENDERING,
+                     RenderingHints.VALUE_RENDER_DEFAULT);
+
+    return defaultHints;
+  }
+
+  /**
+   * Used by drawRaster and GdkPixbufDecoder
+   */
+  public static int[] findSimpleIntegerArray (ColorModel cm, Raster raster)
+  {
+    if (cm == null || raster == null)
+      return null;
+
+    if (! cm.getColorSpace().isCS_sRGB())
+      return null;
+
+    if (! (cm instanceof DirectColorModel))
+      return null;
+
+    DirectColorModel dcm = (DirectColorModel) cm;
+
+    if (dcm.getRedMask() != 0x00FF0000 || dcm.getGreenMask() != 0x0000FF00
+        || dcm.getBlueMask() != 0x000000FF)
+      return null;
+
+    if (! (raster instanceof WritableRaster))
+      return null;
+
+    if (raster.getSampleModel().getDataType() != DataBuffer.TYPE_INT)
+      return null;
+
+    if (! (raster.getDataBuffer() instanceof DataBufferInt))
+      return null;
+
+    DataBufferInt db = (DataBufferInt) raster.getDataBuffer();
+
+    if (db.getNumBanks() != 1)
+      return null;
+
+    // Finally, we have determined that this is a single bank, [A]RGB-int
+    // buffer in sRGB space. It's worth checking all this, because it means
+    // that cairo can paint directly into the data buffer, which is very
+    // fast compared to all the normal copying and converting.
+
+    return db.getData();
+  }
 }
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java
new file mode 100644
index 000000000000..e19c9b992536
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurface.java
@@ -0,0 +1,288 @@
+/* CairoSurface.java
+   Copyright (C) 2006 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 gnu.java.awt.peer.gtk;
+
+import java.awt.Graphics;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.io.File;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Vector;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedInputStream;
+import java.net.URL;
+import gnu.classpath.Pointer;
+
+/**
+ * CairoSurface - wraps a Cairo surface.
+ *
+ * @author Sven de Marothy
+ */
+public class CairoSurface extends DataBuffer
+{
+  int width = -1, height = -1;
+
+  /**
+   * The native pointer to the Cairo surface. 
+   */
+  long surfacePointer;
+
+  /**
+   * The native pointer to the image's data buffer
+   */
+  long bufferPointer;
+
+
+  static ColorModel nativeModel = new DirectColorModel(32, 
+						       0x000000FF,
+						       0x0000FF00,
+						       0x00FF0000,
+						       0xFF000000);
+
+  /**
+   * Allocates and clears the buffer and creates the cairo surface.
+   * @param width, height - the image size
+   * @param stride - the buffer row stride.
+   */
+  private native void create(int width, int height, int stride);
+
+  /**
+   * Destroys the cairo surface and frees the buffer.
+   */
+  private native void destroy();
+
+  /**
+   * Gets buffer elements
+   */
+  private native int nativeGetElem(int i);
+  
+  /**
+   * Sets buffer elements.
+   */
+  private native void nativeSetElem(int i, int val);
+
+  /**
+   * Draws this image to a given CairoGraphics context, 
+   * with an affine transform given by i2u.
+   */
+  public native void drawSurface(CairoGraphics2D context, double[] i2u);
+
+  /**
+   * getPixels -return the pixels as a java array.
+   */
+  native int[] getPixels(int size);
+
+  /**
+   * getPixels -return the pixels as a java array.
+   */
+  native void setPixels(int[] pixels);
+
+  native long getFlippedBuffer(int size);
+
+  /**
+   * Create a cairo_surface_t with specified width and height.
+   * The format will be ARGB32 with premultiplied alpha and native bit 
+   * and word ordering.
+   */
+  CairoSurface(int width, int height)
+  {
+    super(DataBuffer.TYPE_INT, width * height);
+
+    if(width <= 0 || height <= 0)
+      throw new IllegalArgumentException("Image must be at least 1x1 pixels.");
+
+    this.width = width;
+    this.height = height;
+
+    create(width, height, width * 4);
+
+    if(surfacePointer == 0 || bufferPointer == 0)
+      throw new Error("Could not allocate bitmap.");
+  }
+
+  /**
+   * Create a cairo_surface_t from a GtkImage instance.
+   * (data is copied, not shared)
+   */
+  CairoSurface(GtkImage image)
+  {
+    super(DataBuffer.TYPE_INT, image.width * image.height);
+
+    if(image.width <= 0 || image.height <= 0)
+      throw new IllegalArgumentException("Image must be at least 1x1 pixels.");
+
+    width = image.width;
+    height = image.height;
+
+    create(width, height, width * 4);
+    
+    if(surfacePointer == 0 || bufferPointer == 0)
+      throw new Error("Could not allocate bitmap.");
+    
+    // Copy the pixel data from the GtkImage.
+    int[] data = image.getPixels();
+
+    // Swap ordering from GdkPixbuf to Cairo
+    for(int i = 0; i < data.length; i++ )
+      {
+	int alpha = (data[i] & 0xFF000000) >> 24;
+	if( alpha == 0 ) // I do not know why we need this, but it works.
+	  data[i] = 0;
+	else
+	  {
+	    int r = (((data[i] & 0x00FF0000) >> 16) );
+	    int g = (((data[i] & 0x0000FF00) >> 8) );
+	    int b = ((data[i] & 0x000000FF) );
+	    data[i] = (( alpha << 24 ) & 0xFF000000) 
+	      | (( b << 16 ) & 0x00FF0000)
+	      | (( g << 8 )  & 0x0000FF00)
+	      | ( r  & 0x000000FF);
+	  }
+      }
+
+    setPixels( data );
+  }
+
+  /**
+   * Dispose of the native data.
+   */
+  public void dispose()
+  {
+    if(surfacePointer != 0)
+      destroy();
+  }
+
+  /**
+   * Call dispose() to clean up any native resources allocated.
+   */
+  protected void finalize()
+  {
+    dispose();
+  }
+
+  /**
+   * Return a GtkImage from this Cairo surface.
+   */
+  public GtkImage getGtkImage()
+  {
+    return new GtkImage( width, height, getFlippedBuffer( width * height ));
+  }
+
+  /**
+   * Returns a BufferedImage backed by a Cairo surface.
+   */    
+  public static BufferedImage getBufferedImage(int width, int height)
+  {
+    return getBufferedImage(new CairoSurface(width, height));
+  }
+
+  /**
+   * Returns a BufferedImage backed by a Cairo surface, 
+   * created from a GtkImage.
+   */    
+  public static BufferedImage getBufferedImage(GtkImage image)
+  {
+    return getBufferedImage(new CairoSurface(image));
+  }
+
+  /**
+   * Returns a BufferedImage backed by a Cairo surface.
+   */    
+  public static BufferedImage getBufferedImage(CairoSurface surface)
+  {
+    WritableRaster raster = Raster.createPackedRaster
+      (surface, surface.width, surface.height, surface.width, 
+       new int[]{ 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 },
+       new Point(0,0));
+
+    return new BufferedImage(nativeModel, raster, true, new Hashtable());
+  }
+
+  /**
+   * DataBank.getElem implementation
+   */
+  public int getElem(int bank, int i)
+  {
+    if(bank != 0 || i < 0 || i >= width*height)
+      throw new IndexOutOfBoundsException(i+" size: "+width*height);
+    return nativeGetElem(i);
+  }
+  
+  /**
+   * DataBank.setElem implementation
+   */
+  public void setElem(int bank, int i, int val)
+  {
+    if(bank != 0 || i < 0 || i >= width*height)
+      throw new IndexOutOfBoundsException(i+" size: "+width*height);
+    nativeSetElem(i, val);
+  }
+
+  /**
+   * Return a Graphics2D drawing to the CairoSurface.
+   */
+  public Graphics2D getGraphics()
+  {
+    return new CairoSurfaceGraphics(this);
+  } 
+
+  ///// Methods used by CairoSurfaceGraphics /////
+  /**
+   * Creates a cairo_t drawing context, returns the pointer as a long.
+   * Used by CairoSurfaceGraphics.
+   */
+  native long newCairoContext();
+
+  /**
+   * Copy an area of the surface. Expects parameters must be within bounds. 
+   * Count on a segfault otherwise.
+   */
+  native void copyAreaNative(int x, int y, int width, int height, 
+			     int dx, int dy, int stride);
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
new file mode 100644
index 000000000000..38c549d1de52
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java
@@ -0,0 +1,100 @@
+/* CairoSurfaceGraphics.java
+   Copyright (C) 2006 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 gnu.java.awt.peer.gtk;
+
+import java.awt.Graphics;
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.*;
+
+/**
+ * Implementation of Graphics2D on a Cairo surface.
+ */
+public class CairoSurfaceGraphics extends CairoGraphics2D
+{
+  protected CairoSurface surface;
+  private long cairo_t;
+  
+  /**
+   * Create a graphics context from a cairo surface
+   */
+  public CairoSurfaceGraphics(CairoSurface surface)
+  {
+    this.surface = surface;
+    cairo_t = surface.newCairoContext();
+    setup( cairo_t );
+    setClip(0, 0, surface.width, surface.height);
+  }
+
+  /**
+   * Creates another context from a surface.
+   * Used by create().
+   */ 
+  private CairoSurfaceGraphics(CairoSurfaceGraphics copyFrom)
+  {
+    surface = copyFrom.surface;
+    cairo_t = surface.newCairoContext();
+    copy( copyFrom, cairo_t );
+    setClip(0, 0, surface.width, surface.height);
+  }
+  
+  public Graphics create()
+  {
+    return new CairoSurfaceGraphics(this);
+  }
+  
+  public GraphicsConfiguration getDeviceConfiguration()
+  {
+    throw new UnsupportedOperationException();
+  }
+  
+  protected Rectangle2D getRealBounds()
+  {
+    return new Rectangle2D.Double(0.0, 0.0, surface.width, surface.height);
+  }
+
+  public void copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
+  {
+    surface.copyAreaNative(x, y, width, height, dx, dy, surface.width);
+  }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java
new file mode 100644
index 000000000000..c6cf4948c009
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java
@@ -0,0 +1,243 @@
+/* ComponentGraphics.java --
+   Copyright (C) 2006  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 gnu.java.awt.peer.gtk;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.Point;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImagingOpException;
+import java.awt.image.RenderedImage;
+
+/**
+ * ComponentGraphics - context for drawing directly to a component,
+ * as this is an X drawable, it requires that we use GTK locks.
+ *
+ * This context draws directly to the drawable and requires xrender.
+ */
+public class ComponentGraphics extends CairoGraphics2D
+{
+  private GtkComponentPeer component;
+  protected long cairo_t;
+
+  ComponentGraphics()
+  {
+  }
+  
+  private ComponentGraphics(GtkComponentPeer component)
+  {
+    this.component = component;
+    cairo_t = initState(component);
+    setup( cairo_t );
+    Rectangle bounds = component.awtComponent.getBounds();
+    setClip( new Rectangle( 0, 0, bounds.width, bounds.height) );
+    setBackground(component.awtComponent.getBackground());
+    setColor(component.awtComponent.getForeground());
+  }
+
+  private ComponentGraphics(ComponentGraphics cg)
+  {
+    component = cg.component;
+    cairo_t = initState(component);
+    copy( cg, cairo_t );
+    Rectangle bounds = component.awtComponent.getBounds();
+    setClip( new Rectangle( 0, 0, bounds.width, bounds.height) );
+    setBackground(component.awtComponent.getBackground());
+    setColor(component.awtComponent.getForeground());
+  }
+
+  /**
+   * Creates a cairo_t for the component surface and return it.
+   */
+  private native long initState(GtkComponentPeer component);
+
+  /**
+   * Destroys the component surface and calls dispose on the cairo
+   * graphics2d to destroy any super class resources.
+   */
+  public void dispose()
+  {
+    disposeSurface(nativePointer);
+    super.dispose();
+  }
+
+  /**
+   * Destroys the component surface.
+   */
+  private native void disposeSurface(long nativePointer);
+
+  /**
+   * Creates a cairo_t for a volatile image
+   */
+  protected native long initFromVolatile( long pixmapPtr, int width, int height);
+
+  /**
+   * Grab lock
+   */
+  private native void start_gdk_drawing();
+
+  /**
+   * Release lock
+   */
+  private native void end_gdk_drawing();
+
+  /**
+   * Query if the system has the XRender extension.
+   */
+  public static native boolean hasXRender();
+
+
+  private native void copyAreaNative(GtkComponentPeer component, int x, int y, 
+				     int width, int height, int dx, int dy);
+
+  private native void drawVolatile(GtkComponentPeer component,
+				   Image vimg, int x, int y, 
+				   int width, int height);
+
+  /**
+   * Returns a Graphics2D object for a component, either an instance of this 
+   * class (if xrender is supported), or a context which copies.
+   */
+  public static Graphics2D getComponentGraphics(GtkComponentPeer component)
+  {
+    if( hasXRender() )
+      return new ComponentGraphics(component);
+
+    Rectangle r = component.awtComponent.getBounds();
+    return new ComponentGraphicsCopy(r.width, r.height, component);
+  }
+
+  public GraphicsConfiguration getDeviceConfiguration()
+  {
+    return component.getGraphicsConfiguration();
+  }
+
+  public Graphics create()
+  {
+    return new ComponentGraphics(this);
+  }
+  
+  protected Rectangle2D getRealBounds()
+  {
+    return component.awtComponent.getBounds();
+  }
+
+  public void copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
+  {
+    copyAreaNative(component, x, y, width, height, dx, dy);
+  }
+
+  /**
+   * Overloaded methods that do actual drawing need to enter the gdk threads 
+   * and also do certain things before and after.
+   */
+  public void draw(Shape s)
+  {
+    start_gdk_drawing();
+    super.draw(s);
+    end_gdk_drawing();
+  }
+
+  public void fill(Shape s)
+  {
+    start_gdk_drawing();
+    super.fill(s);
+    end_gdk_drawing();
+  }
+
+  public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+  {
+    start_gdk_drawing();
+    super.drawRenderedImage(image, xform);
+    end_gdk_drawing();
+  }
+
+  protected boolean drawImage(Image img, AffineTransform xform,
+			      Color bgcolor, ImageObserver obs)
+  {
+    start_gdk_drawing();
+    boolean rv = super.drawImage(img, xform, bgcolor, obs);
+    end_gdk_drawing();
+    return rv;
+  }
+
+  public void drawGlyphVector(GlyphVector gv, float x, float y)
+  {
+    start_gdk_drawing();
+    super.drawGlyphVector(gv, x, y);
+    end_gdk_drawing();
+  }
+  
+  public boolean drawImage(Image img, int x, int y, ImageObserver observer)
+  {
+    if( img instanceof GtkVolatileImage )
+      {
+	drawVolatile( component, img, x, y - 20,
+		      ((GtkVolatileImage)img).width, 
+		      ((GtkVolatileImage)img).height );
+	return true;
+      }      
+    return super.drawImage( img, x, y, observer );
+  }
+  
+  public boolean drawImage(Image img, int x, int y, int width, int height,
+                           ImageObserver observer)
+  {
+    if( img instanceof GtkVolatileImage )
+      {
+	drawVolatile( component, img, x, y - 20, 
+		      width, height );
+	return true;
+      }      
+    return super.drawImage( img, x, y, width, height, observer );
+  }
+
+}
+
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
new file mode 100644
index 000000000000..286fbeac0602
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java
@@ -0,0 +1,129 @@
+/* ComponentGraphicsCopy.java
+   Copyright (C) 2006 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 gnu.java.awt.peer.gtk;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.RenderedImage;
+import java.awt.image.ImageObserver;
+
+/**
+ * Implementation of Graphics2D for Components for servers which 
+ * do not have xrender.
+ *
+ * A mirrored GtkImage of the component is stored in memory
+ * and copied back. Yay.
+ */
+public class ComponentGraphicsCopy extends CairoSurfaceGraphics
+{
+  private GtkComponentPeer component;
+
+  /**
+   * GtkImage sharing its data buffer with this Cairo surface.
+   */
+  private GtkImage gtkimage;
+  
+  private int width, height;
+
+  native void getPixbuf( GtkComponentPeer component, GtkImage image );
+
+  native void copyPixbuf( GtkComponentPeer component, GtkImage image, 
+			  int x, int y, int w, int h );
+
+  public ComponentGraphicsCopy(int width, int height, 
+			       GtkComponentPeer component)
+  { 
+    super( new CairoSurface( width, height ) );
+    this.component = component;
+    this.width = width;
+    this.height = height;
+    gtkimage = surface.getGtkImage();
+    getPixbuf( component, gtkimage );
+  }
+
+  /**
+   * Overloaded methods that do actual drawing need to enter the gdk threads 
+   * and also do certain things before and after.
+   */
+  public void draw(Shape s)
+  {
+    super.draw(s);
+    Rectangle r = s.getBounds();
+    copyPixbuf(component, gtkimage, r.x, r.y, r.width, r.height);
+  }
+
+  public void fill(Shape s)
+  {
+    super.fill(s);
+    Rectangle r = s.getBounds();
+    copyPixbuf(component, gtkimage, r.x, r.y, r.width, r.height);
+  }
+
+  public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+  {
+    super.drawRenderedImage(image, xform);
+    copyPixbuf(component, gtkimage, 0, 0, width, height);
+  }
+
+  protected boolean drawImage(Image img, AffineTransform xform,
+			      Color bgcolor, ImageObserver obs)
+  {
+    boolean rv = super.drawImage(img, xform, bgcolor, obs);
+    copyPixbuf(component, gtkimage, 0, 0, width, height);
+    return rv;
+  }
+
+  public void drawGlyphVector(GlyphVector gv, float x, float y)
+  {
+    super.drawGlyphVector(gv, x, y);
+    Rectangle r = gv.getPixelBounds(getFontRenderContext(), x , y);
+    copyPixbuf(component, gtkimage, r.x, r.y, r.width, r.height);
+  }
+}
+
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java b/libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
new file mode 100644
index 000000000000..0f8ce6dadef8
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
@@ -0,0 +1,392 @@
+/* FreetypeGlyphVector.java
+   Copyright (C) 2006  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 gnu.java.awt.peer.gtk;
+
+import java.awt.Font;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.GeneralPath;
+import java.awt.font.GlyphJustificationInfo;
+import java.awt.font.GlyphMetrics;
+import java.awt.font.GlyphVector;
+import java.awt.font.FontRenderContext;
+
+public class FreetypeGlyphVector extends GlyphVector
+{
+  /**
+   * The associated font and its peer.
+   */
+  private Font font;
+  private GdkFontPeer peer; // ATTN: Accessed from native code.
+
+  /**
+   * The string represented by this GlyphVector.
+   */
+  private String s;
+
+  /**
+   * The font render context
+   */
+  private FontRenderContext frc;
+
+  /**
+   * The total # of glyphs.
+   */
+  private int nGlyphs;
+
+  /**
+   * The glyph codes
+   */
+  private int[] glyphCodes;
+
+  /**
+   * Glyph transforms. (de facto only the translation is used)
+   */
+  private AffineTransform[] glyphTransforms;
+
+  /**
+   * Create a glyphvector from a given (Freetype) font and a String.
+   */
+  public FreetypeGlyphVector(Font f, String s, FontRenderContext frc)
+  {
+    this.s = s;
+    this.font = f;
+    this.frc = frc;
+    if( !(font.getPeer() instanceof GdkFontPeer ) )
+      throw new IllegalArgumentException("Not a valid font.");
+    peer = (GdkFontPeer)font.getPeer();
+
+    getGlyphs();
+    performDefaultLayout();
+  }
+
+  /**
+   * Create a glyphvector from a given set of glyph codes.
+   */
+  public FreetypeGlyphVector(Font f, int[] codes, FontRenderContext frc)
+  {
+    this.font = f;
+    this.frc = frc;
+    if( !(font.getPeer() instanceof GdkFontPeer ) )
+      throw new IllegalArgumentException("Not a valid font.");
+    peer = (GdkFontPeer)font.getPeer();
+
+    glyphCodes = new int[ codes.length ];
+    System.arraycopy(codes, 0, glyphCodes, 0, codes.length);
+    nGlyphs = glyphCodes.length;
+    performDefaultLayout();
+  }
+
+  /**
+   * Create the array of glyph codes.
+   */
+  private void getGlyphs()
+  {
+    nGlyphs = s.codePointCount( 0, s.length() );
+    glyphCodes = new int[ nGlyphs ];
+    int stringIndex = 0;
+    for(int i = 0; i < nGlyphs; i++)
+      {
+	glyphCodes[i] = getGlyph( s.codePointAt(stringIndex) );
+	// UTF32 surrogate handling
+	if( s.codePointAt( stringIndex ) != (int)s.charAt( stringIndex ) )
+	  stringIndex ++;
+	stringIndex ++;
+      }
+  }
+
+  /**
+   * Returns the glyph code within the font for a given character
+   */
+  public native int getGlyph(int codepoint);
+
+  /**
+   * Returns the kerning of a glyph pair
+   */
+  private native Point2D getKerning(int leftGlyph, int rightGlyph);
+
+  private native double[] getMetricsNative( int glyphCode );
+
+  private native GeneralPath getGlyphOutlineNative(int glyphIndex);
+
+  /**
+   * Duh, compares two instances.
+   */
+  public boolean equals(GlyphVector gv)
+  {
+    if( ! (gv instanceof FreetypeGlyphVector) )
+      return false;
+
+    return (((FreetypeGlyphVector)gv).font.equals(font) && 
+	    ((FreetypeGlyphVector)gv).frc.equals(frc)
+	    && ((FreetypeGlyphVector)gv).s.equals(s));
+  }
+
+  /**
+   * Returns the associated Font
+   */
+  public Font getFont()
+  {
+    return font;
+  }
+
+  /**
+   * Returns the associated FontRenderContext
+   */
+  public FontRenderContext getFontRenderContext()
+  {
+    return frc;
+  }
+
+  /**
+   * Layout the glyphs.
+   */
+  public void performDefaultLayout()
+  {
+    glyphTransforms = new AffineTransform[ nGlyphs ]; 
+    double x = 0;
+    for(int i = 0; i < nGlyphs; i++)
+      {
+	GlyphMetrics gm = getGlyphMetrics( i );
+	Rectangle2D r = gm.getBounds2D();
+	glyphTransforms[ i ] = AffineTransform.getTranslateInstance(x, 0);
+	x += gm.getAdvanceX();
+	if( i > 0 )
+	  {
+	    Point2D p = getKerning( glyphCodes[ i - 1 ], glyphCodes[ i ] );
+	    x += p.getX();
+	  }
+      }
+  }
+
+  /**
+   * Returns the code of the glyph at glyphIndex;
+   */
+  public int getGlyphCode(int glyphIndex)
+  {
+    return glyphCodes[ glyphIndex ];
+  }
+
+  /**
+   * Returns multiple glyphcodes.
+   */
+  public int[] getGlyphCodes(int beginGlyphIndex, int numEntries, 
+			     int[] codeReturn)
+  {
+    int[] rval;
+
+    if( codeReturn == null )
+      rval = new int[ numEntries ];
+    else
+      rval = codeReturn;
+    
+    System.arraycopy(glyphCodes, beginGlyphIndex, rval, 0, numEntries);
+
+    return rval;
+  }
+
+  /**
+   * FIXME: Implement me.
+   */
+  public Shape getGlyphLogicalBounds(int glyphIndex)
+  {
+    GlyphMetrics gm = getGlyphMetrics( glyphIndex );
+    if( gm == null )
+      return null; 
+    Rectangle2D r = gm.getBounds2D();
+    return new Rectangle2D.Double( r.getX() - gm.getLSB(), r.getY(),
+				   gm.getAdvanceX(), r.getHeight() );
+  }
+
+  /**
+   * Returns the metrics of a single glyph.
+   */
+  public GlyphMetrics getGlyphMetrics(int glyphIndex)
+  {
+    double[] val = getMetricsNative( glyphCodes[ glyphIndex ] );
+    if( val == null )
+      return null;
+    
+    return new GlyphMetrics( true, (float)val[1], (float)val[2], 
+			     new Rectangle2D.Double( val[3], val[4], 
+						     val[5], val[6] ),
+			     GlyphMetrics.STANDARD );
+  }
+
+  /**
+   * Returns the outline of a single glyph.
+   */
+  public Shape getGlyphOutline(int glyphIndex)
+  {
+    GeneralPath gp = getGlyphOutlineNative( glyphCodes[ glyphIndex ] );
+    gp.transform( glyphTransforms[ glyphIndex ] );
+    return gp;
+  }
+
+  /**
+   * Returns the position of a single glyph.
+   */
+  public Point2D getGlyphPosition(int glyphIndex)
+  {
+    return glyphTransforms[ glyphIndex ].transform( new Point2D.Double(0, 0),
+						   null );
+  }
+
+  /**
+   * Returns the positions of multiple glyphs.
+   */
+  public float[] getGlyphPositions(int beginGlyphIndex, int numEntries, 
+				   float[] positionReturn)
+  {
+    float[] rval;
+
+    if( positionReturn == null )
+      rval = new float[2 * numEntries];
+    else
+      rval = positionReturn;
+
+    for( int i = beginGlyphIndex; i < numEntries; i++ )
+      {
+	Point2D p = getGlyphPosition( i );
+	rval[i * 2] = (float)p.getX();
+	rval[i * 2 + 1] = (float)p.getY();
+      }
+
+    return rval;
+  }
+
+  /**
+   * Returns the transform of a glyph.
+   */
+  public AffineTransform getGlyphTransform(int glyphIndex)
+  {
+    return new AffineTransform( glyphTransforms[ glyphIndex ] );
+  }
+
+  /**
+   * Returns the visual bounds of a glyph
+   * May be off by a pixel or two due to hinting/rasterization.
+   */
+  public Shape getGlyphVisualBounds(int glyphIndex)
+  {
+    return getGlyphOutline( glyphIndex ).getBounds2D();
+  }
+
+  /**
+   * Return the logical bounds of the whole thing.
+   */
+  public Rectangle2D getLogicalBounds()
+  {
+    if( nGlyphs == 0 )
+      return new Rectangle2D.Double(0, 0, 0, 0);
+
+    Rectangle2D rect = (Rectangle2D)getGlyphLogicalBounds( 0 );
+    for( int i = 1; i < nGlyphs; i++ )
+      rect = rect.createUnion( (Rectangle2D)getGlyphLogicalBounds( i ) );
+
+    return rect;
+  }
+
+  /**
+   * Returns the number of glyphs.
+   */
+  public int getNumGlyphs()
+  {
+    return glyphCodes.length;
+  }
+
+  /**
+   * Returns the outline of the entire GlyphVector.
+   */
+  public Shape getOutline()
+  {
+    GeneralPath path = new GeneralPath();
+    for( int i = 0; i < getNumGlyphs(); i++ )
+      path.append( getGlyphOutline( i ), false );
+    return path;
+  }
+
+  /**
+   * TODO: 
+   * FreeType does not currently have an API for the JSTF table. We should 
+   * probably get the table ourselves from FT and pass it to some parser 
+   * which the native font peers will need.
+   */
+  public GlyphJustificationInfo getGlyphJustificationInfo(int glyphIndex)
+  {
+    return null;
+  }
+
+  /**
+   * Returns the outline of the entire vector, drawn at (x,y).
+   */
+  public Shape getOutline(float x, float y)
+  {
+    AffineTransform tx = AffineTransform.getTranslateInstance( x, y );
+    return tx.createTransformedShape( getOutline() );
+  }
+
+  /**
+   * Returns the visual bounds of the entire GlyphVector.
+   * May be off by a pixel or two due to hinting/rasterization.
+   */
+  public Rectangle2D getVisualBounds()
+  {
+    return getOutline().getBounds2D();
+  }
+
+  /**
+   * Sets the position of a glyph.
+   */
+  public void setGlyphPosition(int glyphIndex, Point2D newPos)
+  {
+    // FIXME: Scaling, etc.?
+    glyphTransforms[ glyphIndex ].setToTranslation( newPos.getX(), 
+						    newPos.getY() );
+  }
+
+  /**
+   * Sets the transform of a single glyph.
+   */
+  public void setGlyphTransform(int glyphIndex, AffineTransform newTX)
+  {
+    glyphTransforms[ glyphIndex ].setTransform( newTX );
+  }
+}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java
index 36986d571d24..7aa5e7a1271f 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java
@@ -40,19 +40,23 @@ package gnu.java.awt.peer.gtk;
 
 import gnu.classpath.Configuration;
 import gnu.java.awt.peer.ClasspathFontPeer;
+import gnu.java.awt.font.opentype.NameDecoder;
 
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Toolkit;
 import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
+import java.awt.font.GlyphMetrics;
 import java.awt.font.LineMetrics;
 import java.awt.geom.Rectangle2D;
+import java.awt.geom.Point2D;
 import java.text.CharacterIterator;
 import java.text.StringCharacterIterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
+import java.nio.ByteBuffer;
 
 public class GdkFontPeer extends ClasspathFontPeer
 {
@@ -76,17 +80,21 @@ public class GdkFontPeer extends ClasspathFontPeer
       }
   }
 
+  private ByteBuffer nameTable = null;
+
   private native void initState ();
   private native void dispose ();
-  private native void setFont (String family, int style, int size, boolean useGraphics2D);
+  private native void setFont (String family, int style, int size);
 
   native void getFontMetrics(double [] metrics);
   native void getTextMetrics(String str, double [] metrics);
 
+  native void releasePeerGraphicsResource();
+
+
   protected void finalize ()
   {
-    if (GtkToolkit.useGraphics2D ())
-      GdkGraphics2D.releasePeerGraphicsResource(this);
+    releasePeerGraphicsResource();
     dispose ();
   }
 
@@ -136,26 +144,84 @@ public class GdkFontPeer extends ClasspathFontPeer
   {  
     super(name, style, size);    
     initState ();
-    setFont (this.familyName, this.style, (int)this.size, 
-             GtkToolkit.useGraphics2D());
+    setFont (this.familyName, this.style, (int)this.size);
   }
 
   public GdkFontPeer (String name, Map attributes)
   {
     super(name, attributes);
     initState ();
-    setFont (this.familyName, this.style, (int)this.size,
-             GtkToolkit.useGraphics2D());
+    setFont (this.familyName, this.style, (int)this.size);
   }
-  
+
+  /**
+   * Unneeded, but implemented anyway.
+   */  
   public String getSubFamilyName(Font font, Locale locale)
   {
-    return null;
+    String name;
+    
+    if (locale == null)
+      locale = Locale.getDefault();
+    
+    name = getName(NameDecoder.NAME_SUBFAMILY, locale);
+    if (name == null)
+      {
+	name = getName(NameDecoder.NAME_SUBFAMILY, Locale.ENGLISH);
+	if ("Regular".equals(name))
+	  name = null;
+      }
+
+    return name;
   }
 
+  /**
+   * Returns the bytes belonging to a TrueType/OpenType table,
+   * Parameters n,a,m,e identify the 4-byte ASCII tag of the table.
+   *
+   * Returns null if the font is not TT, the table is nonexistant, 
+   * or if some other unexpected error occured.
+   *
+   */
+  private native byte[] getTrueTypeTable(byte n, byte a, byte m, byte e);
+
+  /**
+   * Returns the PostScript name of the font, defaults to the familyName if 
+   * a PS name could not be retrieved.
+   */
   public String getPostScriptName(Font font)
   {
-    return this.familyName;
+    String name = getName(NameDecoder.NAME_POSTSCRIPT, 
+			  /* any language */ null);
+    if( name == null )
+      return this.familyName;
+
+    return name;
+  }
+
+  /**
+   * Extracts a String from the font&#x2019;s name table.
+   *
+   * @param name the numeric TrueType or OpenType name ID.
+   *
+   * @param locale the locale for which names shall be localized, or
+   * <code>null</code> if the locale does mot matter because the name
+   * is known to be language-independent (for example, because it is
+   * the PostScript name).
+   */
+  private String getName(int name, Locale locale)
+  {
+    if (nameTable == null)
+      {
+	byte[] data = getTrueTypeTable((byte)'n', (byte) 'a', 
+				       (byte) 'm', (byte) 'e');
+	if( data == null )
+	  return null;
+
+	nameTable = ByteBuffer.wrap( data );
+      }
+
+    return NameDecoder.getName(nameTable, name, locale);
   }
 
   public boolean canDisplay (Font font, char c)
@@ -170,23 +236,18 @@ public class GdkFontPeer extends ClasspathFontPeer
     return -1;
   }
   
-  private native GdkGlyphVector getGlyphVector(String txt, 
-                                               Font f, 
-                                               FontRenderContext ctx);
-
   public GlyphVector createGlyphVector (Font font, 
                                         FontRenderContext ctx, 
                                         CharacterIterator i)
   {
-    return getGlyphVector(buildString (i), font, ctx);
+    return new FreetypeGlyphVector(font, buildString (i), ctx);
   }
 
   public GlyphVector createGlyphVector (Font font, 
                                         FontRenderContext ctx, 
                                         int[] glyphCodes)
   {
-    return null;
-    //    return new GdkGlyphVector (font, this, ctx, glyphCodes);
+    return new FreetypeGlyphVector(font, glyphCodes, ctx);
   }
 
   public byte getBaselineFor (Font font, char c)
@@ -262,13 +323,21 @@ public class GdkFontPeer extends ClasspathFontPeer
 
   public int getNumGlyphs (Font font)
   {
-    throw new UnsupportedOperationException ();
+    byte[] data = getTrueTypeTable((byte)'m', (byte) 'a', 
+				   (byte)'x', (byte) 'p');
+    if( data == null )
+      return -1;
+
+    ByteBuffer buf = ByteBuffer.wrap( data );       
+    return buf.getShort(4);
   }
 
   public Rectangle2D getStringBounds (Font font, CharacterIterator ci, 
                                       int begin, int limit, FontRenderContext frc)
   {
-    GdkGlyphVector gv = getGlyphVector(buildString (ci, begin, limit), font, frc);
+    GlyphVector gv = new FreetypeGlyphVector( font, 
+					      buildString(ci, begin, limit),
+					      frc);
     return gv.getVisualBounds();
   }
 
@@ -303,5 +372,4 @@ public class GdkFontPeer extends ClasspathFontPeer
     // the metrics cache.
     return Toolkit.getDefaultToolkit().getFontMetrics (font);
   }
-
 }
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java
deleted file mode 100644
index f0ddea43a12f..000000000000
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/* GdkGlyphVector.java -- Glyph vector object
-   Copyright (C) 2003, 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 gnu.java.awt.peer.gtk;
-
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.awt.Shape;
-import java.awt.font.FontRenderContext;
-import java.awt.font.GlyphJustificationInfo;
-import java.awt.font.GlyphMetrics;
-import java.awt.font.GlyphVector;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-
-public class GdkGlyphVector extends GlyphVector
-{
-
-  /* We use a simple representation for glyph vectors here. Glyph i
-   * consumes 8 doubles:
-   *
-   *      logical x: extents[ 10*i     ]
-   *      logical y: extents[ 10*i + 1 ]
-   *  logical width: extents[ 10*i + 2 ]
-   * logical height: extents[ 10*i + 3 ]
-   *
-   *       visual x: extents[ 10*i + 4 ]
-   *       visual y: extents[ 10*i + 5 ]
-   *   visual width: extents[ 10*i + 6 ]
-   *  visual height: extents[ 10*i + 7 ]
-   *
-   *   origin pos x: extents[ 10*i + 8 ]
-   *   origin pos y: extents[ 10*i + 9 ]
-   * 
-   * as well as one int, code[i], representing the glyph code in the font.
-   */
-
-  double [] extents;
-  int [] codes;
-
-  Font font;
-  FontRenderContext fontRenderContext;
-
-  Rectangle2D allLogical;
-  Rectangle2D allVisual;
-
-  public GdkGlyphVector(double[] extents, int[] codes, Font font, FontRenderContext frc)
-  {
-    this.extents = extents;
-    this.codes = codes;
-    this.font = font;
-    this.fontRenderContext = frc;
-
-    allLogical = new Rectangle2D.Double();
-    allVisual = new Rectangle2D.Double();
-    
-    for (int i = 0; i < codes.length; ++i)
-      {
-        allLogical.add (new Rectangle2D.Double(extents[10*i    ] + extents[10*i + 8],
-                                               extents[10*i + 1] + extents[10*i + 9],
-                                               extents[10*i + 2],
-                                               extents[10*i + 3]));
-
-        allVisual.add (new Rectangle2D.Double(extents[10*i + 4] + extents[10*i + 8],
-                                              extents[10*i + 5] + extents[10*i + 9],
-                                              extents[10*i + 6],
-                                              extents[10*i + 7]));
-      }
-  }
-
-  /* 
-     geometric notes:
-
-     the FRC contains a mapping from points -> pixels.
-
-     typographics points are typically 1/72 of an inch.
-
-     pixel displays are often around 72 dpi.
-
-     so the FRC can get away with using an identity transform on a screen,
-     often. behavior is documented by sun to fall back to an identity
-     transform if the internal transformation is null.
-
-     coordinates coming up from pango are expressed as floats -- in device
-     space, so basically pixels-with-fractional-bits -- derived from their
-     storage format in pango (1024ths of pixels). 
-
-     it is not clear from the javadocs whether the results of methods like
-     getGlyphPositions ought to return coordinates in device space, or
-     "point" space, or what. for now I'm returning them in device space.
-     
-   */
-
-  public double[] getExtents() 
-  {
-    return extents;
-  }
-
-  public int[] getCodes()
-  {
-    return codes;
-  }
-
-  public Font getFont () 
-  { 
-    return font; 
-  }
-
-  public FontRenderContext getFontRenderContext () 
-  { 
-    return fontRenderContext; 
-  }
-
-  public int getGlyphCharIndex (int glyphIndex) 
-  { 
-    // FIXME: currently pango does not provide glyph-by-glyph
-    // reverse mapping information, so we assume a broken 1:1
-    // glyph model here. This is plainly wrong.
-    return glyphIndex;
-  }
-
-  public int[] getGlyphCharIndices (int beginGlyphIndex, 
-                                    int numEntries,
-                                    int[] codeReturn)
-  {
-    int ix[] = codeReturn;
-    if (ix == null)
-      ix = new int[numEntries];
-
-    for (int i = 0; i < numEntries; i++)
-      ix[i] = getGlyphCharIndex (beginGlyphIndex + i);
-    return ix;
-  }
-
-  public int getGlyphCode (int glyphIndex) 
-  { 
-    return codes[glyphIndex];
-  }
-
-  public int[] getGlyphCodes (int beginGlyphIndex, int numEntries,
-                              int[] codeReturn)
-  {
-    if (codeReturn == null)
-      codeReturn = new int[numEntries];
-
-    System.arraycopy(codes, beginGlyphIndex, codeReturn, 0, numEntries);
-    return codeReturn;
-  }
-
-  public Shape getGlyphLogicalBounds (int i)
-  {
-    return new Rectangle2D.Double (extents[8*i], extents[8*i + 1],
-                                   extents[8*i + 2], extents[8*i + 3]);
-  }
-    
-  public GlyphMetrics getGlyphMetrics (int i)
-  {
-    // FIXME: pango does not yield vertical layout information at the
-    // moment.
-
-    boolean is_horizontal = true;
-    double advanceX = extents[8*i + 2]; // "logical width" == advanceX 
-    double advanceY = 0; 
-   
-    return new GlyphMetrics (is_horizontal, 
-                             (float) advanceX, (float) advanceY, 
-                             (Rectangle2D) getGlyphVisualBounds(i), 
-                             GlyphMetrics.STANDARD);
-  }
-
-  public Shape getGlyphOutline (int glyphIndex)
-  {
-    throw new UnsupportedOperationException ();      
-  }
-
-  public Shape getGlyphOutline (int glyphIndex, float x, float y)
-  {
-    throw new UnsupportedOperationException ();
-  }
-
-  public Rectangle getGlyphPixelBounds (int i, 
-                                        FontRenderContext renderFRC,
-                                        float x, float y)
-  {
-    return new Rectangle((int) x, (int) y,
-                         (int) extents[8*i + 6], (int) extents[8*i + 7]);
-  }
-    
-  public Point2D getGlyphPosition (int i)
-  {
-    return new Point2D.Double (extents[10*i + 8], 
-                               extents[10*i + 9]);
-  }
-
-  public float[] getGlyphPositions (int beginGlyphIndex,
-                                    int numEntries,
-                                    float[] positionReturn)
-  {
-    float fx[] = positionReturn;
-    if (fx == null)
-      fx = new float[numEntries * 2];
-
-    for (int i = 0; i < numEntries; ++i)
-      {
-        fx[2*i    ] = (float) extents[10*i + 8];
-        fx[2*i + 1] = (float) extents[10*i + 9];
-      }
-    return fx;
-  }
-
-  public AffineTransform getGlyphTransform (int glyphIndex)
-  {
-    // Glyphs don't have independent transforms in these simple glyph
-    // vectors; docs specify null is an ok return here.
-    return null;  
-  }
-    
-  public Shape getGlyphVisualBounds (int i)
-  {
-    return new Rectangle2D.Double(extents[8*i + 4], extents[8*i + 5],
-                                  extents[8*i + 6], extents[8*i + 7]);
-  }
-    
-  public int getLayoutFlags ()
-  {
-    return 0;
-  }
-
-  public Rectangle2D getLogicalBounds ()
-  {
-    return allLogical;
-  }
-
-  public int getNumGlyphs ()
-  {
-    return codes.length;
-  }
-
-  public Shape getOutline ()
-  {
-    throw new UnsupportedOperationException ();      
-  }
-
-  public Rectangle getPixelBounds (FontRenderContext renderFRC,
-                                   float x, float y)
-  {
-    return new Rectangle((int)x, 
-                         (int)y, 
-                         (int) allVisual.getWidth(),
-                         (int) allVisual.getHeight());
-  }
-    
-  public Rectangle2D getVisualBounds ()
-  {
-    return allVisual;
-  }
-
-  public void performDefaultLayout ()
-  {
-  }
-    
-  public void setGlyphPosition (int i, Point2D newPos)
-  {
-    extents[8*i    ] = newPos.getX();
-    extents[8*i + 1] = newPos.getY();
-
-    extents[8*i + 4] = newPos.getX();
-    extents[8*i + 5] = newPos.getY();
-  }
-
-  public void setGlyphTransform (int glyphIndex,
-                                 AffineTransform newTX)
-  {
-    // not yet.. maybe not ever?
-    throw new UnsupportedOperationException ();      
-  }
-
-  public boolean equals(GlyphVector gv)
-  {
-    if (gv == null)
-      return false;
-
-    if (! (gv instanceof GdkGlyphVector))
-      return false;
-
-    GdkGlyphVector ggv = (GdkGlyphVector) gv;
-
-    if ((ggv.codes.length != this.codes.length)
-        || (ggv.extents.length != this.extents.length))
-      return false;
-    
-    if ((ggv.font == null && this.font != null)
-        || (ggv.font != null && this.font == null)
-        || (!ggv.font.equals(this.font)))
-      return false;
-
-    if ((ggv.fontRenderContext == null && this.fontRenderContext != null)
-        || (ggv.fontRenderContext != null && this.fontRenderContext == null)
-        || (!ggv.fontRenderContext.equals(this.fontRenderContext)))
-      return false;
-
-    for (int i = 0; i < ggv.codes.length; ++i)
-      if (ggv.codes[i] != this.codes[i])
-        return false;
-
-    for (int i = 0; i < ggv.extents.length; ++i)
-      if (ggv.extents[i] != this.extents[i])
-        return false;
-
-    return true;
-  }
-
-  public GlyphJustificationInfo getGlyphJustificationInfo(int idx)
-  {
-    throw new UnsupportedOperationException ();      
-  }
-
-  public Shape getOutline(float x, float y)    
-  {
-    throw new UnsupportedOperationException ();      
-  }
-
-}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java
deleted file mode 100644
index 50066ff1bd54..000000000000
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/* GdkGraphics.java
-   Copyright (C) 1998, 1999, 2002, 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 gnu.java.awt.peer.gtk;
-
-import gnu.classpath.Configuration;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.Rectangle;
-import java.awt.Shape;
-import java.awt.Toolkit;
-import java.awt.image.ImageObserver;
-import java.text.AttributedCharacterIterator;
-
-public class GdkGraphics extends Graphics
-{
-  static 
-  {
-    System.loadLibrary("gtkpeer");
-
-    initStaticState ();
-  }
-  
-  static native void initStaticState();
-  private final int native_state = GtkGenericPeer.getUniqueInteger ();
-
-  Color color, xorColor;
-  GtkComponentPeer component;
-  Font font = new Font ("Dialog", Font.PLAIN, 12);
-  Rectangle clip;
-  GtkImage image; 
-
-  int xOffset = 0;
-  int yOffset = 0;
-
-  static final int GDK_COPY = 0, GDK_XOR = 2;
-
-  native void initState (GtkComponentPeer component);
-  native void initStateUnlocked (GtkComponentPeer component);
-  native void initState (int width, int height);
-  native void initFromImage (GtkImage image);
-  native void nativeCopyState (GdkGraphics g);
-
-  /**
-   * A cached instance that is used by {@link #create} in order to avoid
-   * massive allocation of graphics contexts.
-   */
-  GdkGraphics cached = null;
-
-  /**
-   * A link to the parent context. This is used in {@link #dispose} to put
-   * this graphics context into the cache.
-   */
-  GdkGraphics parent = null;
-
-  GdkGraphics (GdkGraphics g)
-  {
-    parent = g;
-    copyState (g);
-  }
-
-  GdkGraphics (int width, int height)
-  {
-    initState (width, height);
-    color = Color.black;
-    clip = new Rectangle (0, 0, width, height);
-    font = new Font ("Dialog", Font.PLAIN, 12);
-  }
-
-  GdkGraphics (GtkImage image)
-  {
-    this.image = image;
-    initFromImage (image);
-    color = Color.black;
-    clip = new Rectangle (0, 0, 
-			  image.getWidth(null), image.getHeight(null));
-    font = new Font ("Dialog", Font.PLAIN, 12);
-  }
-
-  GdkGraphics (GtkComponentPeer component)
-  {
-    this.component = component;
-    color = Color.black;
-
-    if (component.isRealized ())
-      initComponentGraphics ();
-    else
-      connectSignals (component);
-  }
-
-  void initComponentGraphics ()
-  {
-    initState (component);
-    color = component.awtComponent.getForeground ();
-    if (color == null)
-      color = Color.BLACK;
-    Dimension d = component.awtComponent.getSize ();
-    clip = new Rectangle (0, 0, d.width, d.height);
-  }
-
-  // called back by native side: realize_cb
-  void initComponentGraphicsUnlocked ()
-  {
-    initStateUnlocked (component);
-    color = component.awtComponent.getForeground ();
-    if (color == null)
-      color = Color.BLACK;
-    Dimension d = component.awtComponent.getSize ();
-    clip = new Rectangle (0, 0, d.width, d.height);
-  }
-
-  native void connectSignals (GtkComponentPeer component);
-
-  public native void clearRect(int x, int y, int width, int height);
-
-  public void clipRect (int x, int y, int width, int height)
-  {
-    if (component != null && ! component.isRealized ())
-      return;
-
-    clip = clip.intersection (new Rectangle (x, y, width, height));
-    setClipRectangle (clip.x, clip.y, clip.width, clip.height);
-  }
-
-  public native void copyArea(int x, int y, int width, int height, 
-			      int dx, int dy);
-
-  /**
-   * Creates a copy of this GdkGraphics instance. This implementation can
-   * reuse a cached instance to avoid massive instantiation of Graphics objects
-   * during painting.
-   *
-   * @return a copy of this graphics context
-   */
-  public Graphics create()
-  {
-    GdkGraphics copy = cached;
-    if (copy == null)
-      copy = new GdkGraphics(this);
-    else
-      {
-        copy.copyState(this);
-        cached = null;
-      }
-    return copy;
-  }
-
-  public native void nativeDispose();
-
-  /**
-   * Disposes this graphics object. This puts this graphics context into the
-   * cache of its parent graphics if there is one.
-   */
-  public void dispose()
-  {
-    if (parent != null)
-      {
-        parent.cached = this;
-        parent = null;
-      }
-    else
-      nativeDispose();
-  }
-
-  /**
-   * This is called when this object gets finalized by the garbage collector.
-   * In addition to {@link Graphics#finalize()} this calls nativeDispose() to
-   * make sure the native resources are freed before the graphics context is
-   * thrown away.
-   */
-  public void finalize()
-  {
-    super.finalize();
-    nativeDispose();
-  }
-
-  public boolean drawImage (Image img, int x, int y, 
-			    Color bgcolor, ImageObserver observer)
-  {
-    if (img != null)
-      return drawImage(img, x, y, img.getWidth(null), img.getHeight(null),
-                       bgcolor, observer);
-    return false;
-  }
-
-  public boolean drawImage (Image img, int x, int y, ImageObserver observer)
-  {
-    return drawImage (img, x, y, null, observer);
-  }
-
-  public boolean drawImage(Image img, int x, int y, int width, int height,
-                           Color bgcolor, ImageObserver observer)
-  {
-    if (img != null)
-      {
-        if (img instanceof GtkImage)
-          return ((GtkImage) img).drawImage(this, x, y, width, height, bgcolor,
-                                            observer);
-        return (new GtkImage(img.getSource())).drawImage(this, x, y, width,
-                                                         height, bgcolor,
-                                                         observer);
-      }
-    return false;
-  }
-
-  public boolean drawImage (Image img, int x, int y, int width, int height, 
-			    ImageObserver observer)
-  {
-    return drawImage (img, x, y, width, height,  null, observer);
-  }
-
-  public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, 
-			    int sx1, int sy1, int sx2, int sy2, 
-			    Color bgcolor, ImageObserver observer)
-  {
-    if (img != null)
-      {
-        if (img instanceof GtkImage)
-          return ((GtkImage) img).drawImage(this, dx1, dy1, dx2, dy2, sx1, sy1,
-                                            sx2, sy2, bgcolor, observer);
-        return (new GtkImage(img.getSource())).drawImage(this, dx1, dy1, dx2,
-                                                         dy2, sx1, sy1, sx2,
-                                                         sy2, bgcolor, observer);
-      }
-    return false;
-  }
-
-  public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2, 
-			    int sx1, int sy1, int sx2, int sy2, 
-			    ImageObserver observer) 
-  {
-    return drawImage (img, dx1, dy1, dx2, dy2, 
-		      sx1, sy1, sx2, sy2, 
-		      null, observer);
-  }
-
-  public native void drawLine(int x1, int y1, int x2, int y2);
-
-  public native void drawArc(int x, int y, int width, int height,
-			     int startAngle, int arcAngle);
-  public native void fillArc(int x, int y, int width, int height, 
-			     int startAngle, int arcAngle);
-  public native void drawOval(int x, int y, int width, int height);
-  public native void fillOval(int x, int y, int width, int height);
-
-  public native void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
-  public native void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
-
-  public native void drawPolyline(int[] xPoints, int[] yPoints, int nPoints);
-
-  public native void drawRect(int x, int y, int width, int height);
-  public native void fillRect(int x, int y, int width, int height);
-
-  GdkFontPeer getFontPeer() 
-  {
-    return (GdkFontPeer) getFont().getPeer(); 
-  }
-
-  native void drawString (GdkFontPeer f, String str, int x, int y);
-  public void drawString (String str, int x, int y)
-  {
-    drawString(getFontPeer(), str, x, y);
-  }  
-  
-  public void drawString (AttributedCharacterIterator ci, int x, int y)
-  {
-    throw new Error ("not implemented");
-  }
-
-  public void drawRoundRect(int x, int y, int width, int height, 
-			    int arcWidth, int arcHeight)
-  {
-    if (arcWidth > width)
-      arcWidth = width;
-    if (arcHeight > height)
-      arcHeight = height;
-
-    int xx = x + width - arcWidth;
-    int yy = y + height - arcHeight;
-
-    drawArc (x, y, arcWidth, arcHeight, 90, 90);
-    drawArc (xx, y, arcWidth, arcHeight, 0, 90);
-    drawArc (xx, yy, arcWidth, arcHeight, 270, 90);
-    drawArc (x, yy, arcWidth, arcHeight, 180, 90);
-
-    int y1 = y + arcHeight / 2;
-    int y2 = y + height - arcHeight / 2;
-    drawLine (x, y1, x, y2);
-    drawLine (x + width, y1, x + width, y2);
-
-    int x1 = x + arcWidth / 2;
-    int x2 = x + width - arcWidth / 2;
-    drawLine (x1, y, x2, y);
-    drawLine (x1, y + height, x2, y + height);
-  }
-
-  public void fillRoundRect (int x, int y, int width, int height, 
-			     int arcWidth, int arcHeight)
-  {
-    if (arcWidth > width)
-      arcWidth = width;
-    if (arcHeight > height)
-      arcHeight = height;
-
-    int xx = x + width - arcWidth;
-    int yy = y + height - arcHeight;
-
-    fillArc (x, y, arcWidth, arcHeight, 90, 90);
-    fillArc (xx, y, arcWidth, arcHeight, 0, 90);
-    fillArc (xx, yy, arcWidth, arcHeight, 270, 90);
-    fillArc (x, yy, arcWidth, arcHeight, 180, 90);
-
-    fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1);
-    fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height);
-  }
-
-  public Shape getClip ()
-  {
-    return getClipBounds ();
-  }
-
-  public Rectangle getClipBounds ()
-  {
-    if (clip == null)
-      return null;
-    else
-      return clip.getBounds();
-  }
-
-  public Color getColor ()
-  {
-    return color;
-  }
-
-  public Font getFont ()
-  {
-    return font;
-  }
-
-  public FontMetrics getFontMetrics (Font font)
-  {
-    // Get the font metrics through GtkToolkit to take advantage of
-    // the metrics cache.
-    return Toolkit.getDefaultToolkit().getFontMetrics (font);
-  }
-
-  native void setClipRectangle (int x, int y, int width, int height);
-
-  public void setClip (int x, int y, int width, int height)
-  {
-    if ((component != null && ! component.isRealized ())
-        || clip == null)
-      return;
-
-    clip.x = x;
-    clip.y = y;
-    clip.width = width;
-    clip.height = height;
-    
-    setClipRectangle (x, y, width, height);
-  }
-
-  public void setClip (Rectangle clip)
-  {
-    setClip (clip.x, clip.y, clip.width, clip.height);
-  }
-
-  public void setClip (Shape clip)
-  {
-    if (clip == null)
-      {
-	// Reset clipping.
-	Dimension d = component.awtComponent.getSize();
-	setClip(new Rectangle (0, 0, d.width, d.height));
-      }
-    else
-      setClip(clip.getBounds());
-  }
-
-  private native void setFGColor(int red, int green, int blue);
-
-  public void setColor (Color c)
-  {
-    if (c == null)
-      color = Color.BLACK;
-    else
-      color = c;
-
-    if (xorColor == null) /* paint mode */
-      setFGColor (color.getRed (), color.getGreen (), color.getBlue ());
-    else		  /* xor mode */
-      setFGColor (color.getRed   () ^ xorColor.getRed (),
-		  color.getGreen () ^ xorColor.getGreen (),
-		  color.getBlue  () ^ xorColor.getBlue ());
-  }
-  
-  public void setFont (Font font)
-  {
-    if (font != null)
-      this.font = font;
-  }
-
-  native void setFunction (int gdk_func);
-
-  public void setPaintMode ()
-  {
-    xorColor = null;
-
-    setFunction (GDK_COPY);
-    setFGColor (color.getRed (), color.getGreen (), color.getBlue ());
-  }
-
-  public void setXORMode (Color c)
-  {
-    xorColor = c;
-
-    setFunction (GDK_XOR);
-    setFGColor (color.getRed   () ^ xorColor.getRed (),
-		color.getGreen () ^ xorColor.getGreen (),
-		color.getBlue  () ^ xorColor.getBlue ());
-  }
-
-  public native void translateNative(int x, int y);
-
-  public void translate (int x, int y)
-  {
-    if (component != null && ! component.isRealized ())
-      return;
-
-    clip.x -= x;
-    clip.y -= y;
-
-    translateNative (x, y);
-  }
-
-  /**
-   * Copies over the state of another GdkGraphics to this instance. This is
-   * used by the {@link #GdkGraphics(GdkGraphics)} constructor and the
-   * {@link #create()} method.
-   *
-   * @param g the GdkGraphics object to copy the state from
-   */
-  private void copyState(GdkGraphics g)
-  {
-    color = g.color;
-    xorColor = g.xorColor;
-    font = g.font;
-    if (font == null)
-      font = new Font ("Dialog", Font.PLAIN, 12);
-    clip = new Rectangle (g.clip);
-    component = g.component;
-    nativeCopyState(g);
-  }
-}
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
index 6cf7310a550f..147f8f3e6752 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
@@ -1,5 +1,5 @@
 /* GdkGraphicsConfiguration.java -- describes characteristics of graphics
-   Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -42,26 +42,33 @@ import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
 import java.awt.ImageCapabilities;
 import java.awt.Rectangle;
-import java.awt.Toolkit;
+import java.awt.Transparency;
 
 import java.awt.geom.AffineTransform;
 
 import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
 import java.awt.image.VolatileImage;
 
 public class GdkGraphicsConfiguration 
   extends GraphicsConfiguration
 {
   GdkScreenGraphicsDevice gdkScreenGraphicsDevice;
-  ColorModel cm;
-  Rectangle bounds;
+  
+  ColorModel opaqueColorModel;
 
+  ColorModel bitmaskColorModel;
+
+  ColorModel translucentColorModel;
+  
   public GdkGraphicsConfiguration(GdkScreenGraphicsDevice dev)
   {
-    this.gdkScreenGraphicsDevice = dev;
-    cm = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).getColorModel();
-    bounds = ((GtkToolkit) Toolkit.getDefaultToolkit()).getBounds();
+    gdkScreenGraphicsDevice = dev;
+    
+    opaqueColorModel = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 0);
+    bitmaskColorModel = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 0x1000000);
+    translucentColorModel = new DirectColorModel(32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000);
   }
 
   public GraphicsDevice getDevice()
@@ -94,12 +101,21 @@ public class GdkGraphicsConfiguration
 
   public ColorModel getColorModel()
   {
-    return cm;
+    return opaqueColorModel;
   }
 
   public ColorModel getColorModel(int transparency)
   {
-    return getColorModel();
+    switch (transparency)
+    {
+      case Transparency.OPAQUE:
+        return opaqueColorModel;
+      case Transparency.BITMASK:
+        return bitmaskColorModel;
+      default:
+      case Transparency.TRANSLUCENT:
+        return translucentColorModel;
+    }
   }
 
   public AffineTransform getDefaultTransform()
@@ -116,7 +132,7 @@ public class GdkGraphicsConfiguration
 
   public Rectangle getBounds()
   {
-    return bounds;
+    return gdkScreenGraphicsDevice.getBounds();
   }
 
   public BufferCapabilities getBufferCapabilities()
@@ -133,8 +149,8 @@ public class GdkGraphicsConfiguration
 
   public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency)
   {
-      // FIXME: implement
-    return null;
+      // FIXME: support the transparency argument
+    return new GtkVolatileImage(width, height);
   }
 
 }
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
index 4b0b5d30893d..e1c076c042a5 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
@@ -1,5 +1,5 @@
 /* GdkGraphicsEnvironment.java -- information about the graphics environment
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -43,33 +43,80 @@ import java.awt.Graphics2D;
 import java.awt.GraphicsDevice;
 import java.awt.GraphicsEnvironment;
 import java.awt.HeadlessException;
-import java.awt.Toolkit;
 import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
 import java.util.Locale;
 
 public class GdkGraphicsEnvironment extends GraphicsEnvironment
 {
+  private final int native_state = GtkGenericPeer.getUniqueInteger ();
+  
+  private GdkScreenGraphicsDevice defaultDevice;
+  
+  private GdkScreenGraphicsDevice[] devices;
+  
+  static
+  {
+    System.loadLibrary("gtkpeer");
+
+    initStaticState ();
+  }
+  
+  static native void initStaticState();
+  
   public GdkGraphicsEnvironment ()
   {
+    nativeInitState();
   }
+  
+  native void nativeInitState();
 
   public GraphicsDevice[] getScreenDevices ()
   {
-    // FIXME: Support multiple screens, since GDK can.
-    return new GraphicsDevice[] { new GdkScreenGraphicsDevice (this) };
+    if (devices == null)
+      {
+        devices = nativeGetScreenDevices();
+      }
+    
+    return (GraphicsDevice[]) devices.clone();
   }
+  
+  private native GdkScreenGraphicsDevice[] nativeGetScreenDevices();
 
   public GraphicsDevice getDefaultScreenDevice ()
   {
     if (GraphicsEnvironment.isHeadless ())
       throw new HeadlessException ();
-
-    return new GdkScreenGraphicsDevice (this);
+    
+    // GCJ LOCAL: workaround a GCJ problem accessing
+    // GdkGraphicsEnvironment.class
+    try
+      {
+    synchronized (Class.forName ("gnu.java.awt.peer.gtk.GdkGraphicsEnvironment"))
+      {
+        if (defaultDevice == null)
+          {
+            defaultDevice = nativeGetDefaultScreenDevice();
+          }
+      }
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+    
+    return defaultDevice;
   }
+  
+  private native GdkScreenGraphicsDevice nativeGetDefaultScreenDevice();
 
   public Graphics2D createGraphics (BufferedImage image)
   {
-    return new GdkGraphics2D (image);
+    DataBuffer db = image.getRaster().getDataBuffer();
+    if(db instanceof CairoSurface)
+      return ((CairoSurface)db).getGraphics();
+
+    return new BufferedImageGraphics( image );
   }
   
   private native int nativeGetNumFontFamilies();
@@ -80,20 +127,21 @@ public class GdkGraphicsEnvironment extends GraphicsEnvironment
     throw new java.lang.UnsupportedOperationException ();
   }
 
-    public String[] getAvailableFontFamilyNames ()
-    {
-	String[] family_names;
-	int array_size;
+  public String[] getAvailableFontFamilyNames ()
+  {
+    String[] family_names;
+    int array_size;
 
-	array_size = nativeGetNumFontFamilies();
-	family_names = new String[array_size];
+    array_size = nativeGetNumFontFamilies();
+    family_names = new String[array_size];
 
-	nativeGetFontFamilies(family_names);
-	return family_names;
-    }
+    nativeGetFontFamilies(family_names);
+    return family_names;
+  }
 
   public String[] getAvailableFontFamilyNames (Locale l)
   {
     throw new java.lang.UnsupportedOperationException ();
   }
+  
 }
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
index 2e3eee4c193c..58b2decc5277 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
@@ -247,12 +247,23 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
   public static ImageFormatSpec registerFormat(String name, boolean writable) 
   {
     ImageFormatSpec ifs = new ImageFormatSpec(name, writable);
-    synchronized(GdkPixbufDecoder.class)
+
+    // GCJ LOCAL: workaround a GCJ problem accessing
+    // GdkPixbufDecoder.class
+    try
+      {
+    synchronized(Class.forName ("gnu.java.awt.peer.gtk.GdkPixbufDecoder"))
       {
         if (imageFormatSpecs == null)
           imageFormatSpecs = new ArrayList();
         imageFormatSpecs.add(ifs);
       }
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+    
     return ifs;
   }
 
@@ -502,19 +513,19 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
       int width = ras.getWidth();
       int height = ras.getHeight();
       ColorModel model = image.getColorModel();
-      int[] pixels = GdkGraphics2D.findSimpleIntegerArray (image.getColorModel(), ras);
+      int[] pixels = CairoGraphics2D.findSimpleIntegerArray (image.getColorModel(), ras);
       
       if (pixels == null)
         {
-          BufferedImage img = new BufferedImage(width, height, 
-                                                (model != null && model.hasAlpha() ? 
-                                                 BufferedImage.TYPE_INT_ARGB
-                                                 : BufferedImage.TYPE_INT_RGB));
+	  BufferedImage img;
+	  if(model != null && model.hasAlpha())
+	    img = CairoSurface.getBufferedImage(width, height);
+	  img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
           int[] pix = new int[4];
           for (int y = 0; y < height; ++y)
             for (int x = 0; x < width; ++x)
               img.setRGB(x, y, model.getRGB(ras.getPixel(x, y, pix)));
-          pixels = GdkGraphics2D.findSimpleIntegerArray (img.getColorModel(), 
+          pixels = CairoGraphics2D.findSimpleIntegerArray (img.getColorModel(), 
                                                          img.getRaster());
           model = img.getColorModel();
         }
@@ -584,9 +595,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
       
       if (bufferedImage == null)
         {
-          bufferedImage = new BufferedImage (width, height, (model != null && model.hasAlpha() ? 
-                                                             BufferedImage.TYPE_INT_ARGB
-                                                             : BufferedImage.TYPE_INT_RGB));
+	  if(model != null && model.hasAlpha())
+	    bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB);
+	  else
+	    bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
         }
 
       int pixels2[];
@@ -680,43 +692,4 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
       return getBufferedImage ();
     }
   }
-
-  // remaining helper class and static method is a convenience for the Gtk
-  // peers, for loading a BufferedImage in off a disk file without going
-  // through the whole imageio system. 
-
-  public static BufferedImage createBufferedImage (String filename)
-  {
-    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), 
-                                             "png", // reader auto-detects, doesn't matter
-                                             new GdkPixbufDecoder (filename));
-    return r.getBufferedImage ();
-  }
-
-  public static BufferedImage createBufferedImage (URL u)
-  {
-    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), 
-                                             "png", // reader auto-detects, doesn't matter
-                                             new GdkPixbufDecoder (u));
-    return r.getBufferedImage ();
-  }
-
-  public static BufferedImage createBufferedImage (byte[] imagedata, int imageoffset,
-                                                   int imagelength)
-  {
-    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), 
-                                             "png", // reader auto-detects, doesn't matter
-                                             new GdkPixbufDecoder (imagedata,
-                                                                   imageoffset,
-                                                                   imagelength));
-    return r.getBufferedImage ();
-  }
-  
-  public static BufferedImage createBufferedImage (ImageProducer producer)
-  {
-    GdkPixbufReader r = new GdkPixbufReader (getReaderSpi(), "png" /* ignored */, null);
-    producer.startProduction(r);
-    return r.getBufferedImage ();
-  }
-
 }
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java
index b5d1237a45d3..62116a3226cf 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice.java
@@ -1,5 +1,5 @@
 /* GdkScreenGraphicsDevice.java -- information about a screen device
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,44 +38,110 @@ exception statement from your version. */
 
 package gnu.java.awt.peer.gtk;
 
-import java.awt.Dimension;
 import java.awt.DisplayMode;
+import java.awt.Frame;
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
-import java.awt.Toolkit;
+import java.awt.Rectangle;
+import java.awt.Window;
+import java.util.ArrayList;
 
-public class GdkScreenGraphicsDevice extends GraphicsDevice
+class GdkScreenGraphicsDevice extends GraphicsDevice
 {
+  private final int native_state = GtkGenericPeer.getUniqueInteger ();
+  
+  private Window fullscreenWindow;
+  
+  private boolean oldWindowDecorationState;
+  
+  private Rectangle oldWindowBounds;
+  
+  private Rectangle bounds;
+  
+  private GdkGraphicsConfiguration[] configurations;
+  
+  /** The <code>GdkGraphicsEnvironment</code> instance that created this
+   * <code>GdkScreenGraphicsDevice</code>. This is only needed for native
+   * methods which need to access the 'native_state' field storing a pointer
+   * to a GdkDisplay object.
+   */ 
   GdkGraphicsEnvironment env;
+  
+  /** An identifier that is created by Gdk
+   */
+  String idString;
+  
+  /** The display modes supported by this <code>GdkScreenGraphicsDevice</code>.
+   * If the array is <code>null</code> <code>nativeGetDisplayModes</code> has
+   * to be called.
+   */
+  X11DisplayMode[] displayModes;
 
-  public GdkScreenGraphicsDevice (GdkGraphicsEnvironment e)
-  {    
-    super ();
+  /** The non-changeable display mode of this <code>GdkScreenGraphicsDevice
+   * </code>. This field gets initialized by the {@link #init()} method. If it
+   * is still <code>null</code> afterwards, the XRandR extension is available
+   * and display mode changes are possible. If it is non-null XRandR is not
+   * available, no display mode changes are possible and no other native
+   * method must be called. 
+   */
+  DisplayMode fixedDisplayMode;
+  
+  static
+  {
+    System.loadLibrary("gtkpeer");
+
+    initStaticState ();
+  }
+  
+  static native void initStaticState();
+  
+  GdkScreenGraphicsDevice (GdkGraphicsEnvironment e)
+  {
+    super();
     env = e;
+    
+    configurations = new GdkGraphicsConfiguration[1];
+    configurations[0] = new GdkGraphicsConfiguration(this);
   }
 
+  /** This method is called from the native side immediately after
+   * the constructor is run.
+   */
+  void init()
+  {
+    fixedDisplayMode = nativeGetFixedDisplayMode(env);
+  }
+  
+  /** Depending on the availability of the XRandR extension the method returns
+   * the screens' non-changeable display mode or null, meaning that XRandR can
+   * handle display mode changes.
+   */
+  native DisplayMode nativeGetFixedDisplayMode(GdkGraphicsEnvironment env);
+  
   public int getType ()
   {
+    // Gdk manages only raster screens.
     return GraphicsDevice.TYPE_RASTER_SCREEN;
   }
 
   public String getIDstring ()
   {
-    // FIXME: query X for this string
-    return "default GDK device ID string";
+    if (idString == null)
+      idString = nativeGetIDString();
+    
+    return idString;
   }
+  
+  private native String nativeGetIDString(); 
 
   public GraphicsConfiguration[] getConfigurations ()
   {
-    // FIXME: query X for the list of possible configurations
-    return new GraphicsConfiguration [] { new GdkGraphicsConfiguration(this) };
+    return (GraphicsConfiguration[]) configurations.clone();
   }
-
+  
   public GraphicsConfiguration getDefaultConfiguration ()
   {
-    
-    // FIXME: query X for default configuration
-    return new GdkGraphicsConfiguration(this);
+    return configurations[0];
   }
 
 
@@ -89,23 +155,193 @@ public class GdkScreenGraphicsDevice extends GraphicsDevice
    */
   public DisplayMode getDisplayMode()
   {
-    // determine display mode
-    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
-    DisplayMode mode = new DisplayMode(dim.width, dim.height, 0,
-				       DisplayMode.REFRESH_RATE_UNKNOWN);
-    return mode;
+    if (fixedDisplayMode != null)
+      return fixedDisplayMode;
+    
+    synchronized (this)
+      {
+        if (displayModes == null)
+          displayModes = nativeGetDisplayModes(env);
+      }
+
+    int index = nativeGetDisplayModeIndex(env);
+    int rate = nativeGetDisplayModeRate(env);
+    
+    return new DisplayMode(displayModes[index].width,
+                           displayModes[index].height,
+                           DisplayMode.BIT_DEPTH_MULTI,
+                           rate);
+  }
+  
+  native int nativeGetDisplayModeIndex(GdkGraphicsEnvironment env);
+  
+  native int nativeGetDisplayModeRate(GdkGraphicsEnvironment env);
+  
+  public DisplayMode[] getDisplayModes()
+  {
+    if (fixedDisplayMode != null)
+      return new DisplayMode[] { fixedDisplayMode };
+    
+    synchronized (this)
+      {
+        if (displayModes == null)
+          displayModes = nativeGetDisplayModes(env);
+      }
+    
+    ArrayList list = new ArrayList();
+    for(int i=0;i<displayModes.length;i++)
+      for(int j=0;j<displayModes[i].rates.length;j++)
+        list.add(new DisplayMode(displayModes[i].width,
+                                 displayModes[i].height,
+                                 DisplayMode.BIT_DEPTH_MULTI,
+                                 displayModes[i].rates[j]));
+    
+    return (DisplayMode[]) list.toArray(new DisplayMode[list.size()]);
   }
+  
+  native X11DisplayMode[] nativeGetDisplayModes(GdkGraphicsEnvironment env);
 
   /**
-   * This device does not yet support fullscreen exclusive mode, so this
-   * returns <code>false</code>.
+   * Real fullscreen exclusive mode is not supported.
    *
    * @return <code>false</code>
    * @since 1.4
    */
   public boolean isFullScreenSupported()
   {
-    return false;
+    return true;
+  }
+  
+  public boolean isDisplayChangeSupported()
+  {
+    return fixedDisplayMode == null;
+  }
+
+  public void setDisplayMode(DisplayMode dm)
+  {
+    if (fixedDisplayMode != null)
+      throw new UnsupportedOperationException("Cannnot change display mode.");
+    
+    if (dm == null)
+      throw new IllegalArgumentException("DisplayMode must not be null.");
+    
+    synchronized (this)
+      {
+        if (displayModes == null)
+          displayModes = nativeGetDisplayModes(env);
+      }
+    
+    for (int i=0; i<displayModes.length; i++)
+      if (displayModes[i].width == dm.getWidth()
+          && displayModes[i].height == dm.getHeight())
+        {
+          synchronized (this)
+          {
+            nativeSetDisplayMode(env,
+                                 i,
+                                 (short) dm.getRefreshRate());
+          
+            bounds = null;
+          }
+          
+          return;
+        }
+    
+    throw new IllegalArgumentException("Mode not supported by this device.");
+  }
+  
+  native void nativeSetDisplayMode(GdkGraphicsEnvironment env,
+                                int index, short rate);
+  
+  /** A class that simply encapsulates the X11 display mode data.
+   */
+  static class X11DisplayMode
+  {
+    short[] rates;
+    int width;
+    int height;
+    
+    X11DisplayMode(int width, int height, short[] rates)
+    {
+      this.width = width;
+      this.height = height;
+      this.rates = rates;
+    }
+    
+  }
+  
+  public void setFullScreenWindow(Window w)
+  {
+    // Bring old fullscreen window back into its original state.
+    if (fullscreenWindow != null && w != fullscreenWindow)
+      {
+        if (fullscreenWindow instanceof Frame)
+          {
+            // Decoration state can only be switched when the peer is
+            // non-existent. That means we have to dispose the 
+            // Frame.
+            Frame f = (Frame) fullscreenWindow;
+            if (oldWindowDecorationState != f.isUndecorated())
+              {
+                f.dispose();
+                f.setUndecorated(oldWindowDecorationState);
+              }
+          }
+        
+        fullscreenWindow.setBounds(oldWindowBounds);
+
+        if (!fullscreenWindow.isVisible())
+          fullscreenWindow.setVisible(true);
+      }
+    
+    // If applicable remove decoration, then maximize the window and
+    // bring it to the foreground.
+    if (w != null)
+      {
+        if (w instanceof Frame)
+          {
+            Frame f = (Frame) w;
+            oldWindowDecorationState = f.isUndecorated();
+            if (!oldWindowDecorationState)
+              {
+                f.dispose();
+                f.setUndecorated(true);
+              }
+          }
+        
+        oldWindowBounds = w.getBounds();
+    
+        DisplayMode dm = getDisplayMode();
+    
+        w.setBounds(0, 0, dm.getWidth(), dm.getHeight());
+        
+        if (!w.isVisible())
+          w.setVisible(true);
+        
+        w.requestFocus();
+        w.toFront();
+        
+      }
+    
+    fullscreenWindow = w;
+  }
+  
+  public Window getFullScreenWindow()
+  {
+   return fullscreenWindow; 
+  }
+
+  Rectangle getBounds()
+  {
+   synchronized(this)
+     {
+       if (bounds == null)
+         bounds = nativeGetBounds();
+     }
+   
+   return bounds;
   }
+  
+  native Rectangle nativeGetBounds();
 
 }
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java
index c5e751f68efb..d6b3de8c07f7 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java
@@ -75,13 +75,21 @@ public class GdkTextLayout
     initStaticState ();
   }
   private native void setText(String str);
+  private native void setFont(GdkFontPeer font);
   private native void getExtents(double[] inkExtents,
                                  double[] logExtents);
   private native void indexToPos(int idx, double[] pos);
+
   private native void initState ();
+
   private native void dispose ();
+
+  private native void cairoDrawGdkTextLayout(CairoGraphics2D g, float x, float y);
+
   static native void initStaticState();
+
   private final int native_state = GtkGenericPeer.getUniqueInteger ();
+
   protected void finalize ()
   {
     dispose ();
@@ -97,6 +105,15 @@ public class GdkTextLayout
     initState();
     attributedString = str;
     fontRenderContext = frc;
+    AttributedCharacterIterator aci = str.getIterator();
+    char[] chars = new char[aci.getEndIndex() - aci.getBeginIndex()];
+    for(int i = aci.getBeginIndex(); i < aci.getEndIndex(); i++)
+      chars[i] = aci.setIndex(i);    
+    setText(new String(chars));
+
+    Object fnt = aci.getAttribute(TextAttribute.FONT);
+    if (fnt != null && fnt instanceof Font) 	 
+      setFont( (GdkFontPeer) ((Font)fnt).getPeer() );
   }
 
   protected class CharacterIteratorProxy 
@@ -199,60 +216,7 @@ public class GdkTextLayout
 
   public void draw (Graphics2D g2, float x, float y)
   {
-    if (g2 instanceof GdkGraphics2D)
-      {
-        // we share pango structures directly with GdkGraphics2D 
-        // when legal
-        GdkGraphics2D gg2 = (GdkGraphics2D) g2;
-        gg2.drawGdkTextLayout(this, x, y);
-      }
-    else 
-      {
-        // falling back to a rather tedious layout algorithm when
-        // not legal
-        AttributedCharacterIterator ci = attributedString.getIterator ();
-        CharacterIteratorProxy proxy = new CharacterIteratorProxy (ci);
-        Font defFont = g2.getFont ();
-
-        /* Note: this implementation currently only interprets FONT text
-         * attributes. There is a reasonable argument to be made for some
-         * attributes being interpreted out here, where we have control of the
-         * Graphics2D and can construct or derive new fonts, and some
-         * attributes being interpreted by the GlyphVector itself. So far, for
-         * all attributes except FONT we do neither.
-         */
-
-        for (char c = ci.first ();
-             c != CharacterIterator.DONE;
-             c = ci.next ())
-          {                
-            proxy.begin = ci.getIndex ();
-            proxy.limit = ci.getRunLimit(TextAttribute.FONT);
-            if (proxy.limit <= proxy.begin)
-              continue;
-
-            proxy.index = proxy.begin;
-
-            Object fnt = ci.getAttribute(TextAttribute.FONT);
-            GlyphVector gv;
-            if (fnt instanceof Font)
-              gv = ((Font)fnt).createGlyphVector (fontRenderContext, proxy);
-            else
-              gv = defFont.createGlyphVector (fontRenderContext, proxy);
-
-            g2.drawGlyphVector (gv, x, y);
-
-            int n = gv.getNumGlyphs ();
-            for (int i = 0; i < n; ++i)
-              {
-                GlyphMetrics gm = gv.getGlyphMetrics (i);
-                if (gm.getAdvanceX() == gm.getAdvance ())
-                  x += gm.getAdvanceX ();
-                else
-                  y += gm.getAdvanceY ();
-              }
-          }
-      }
+    cairoDrawGdkTextLayout((CairoGraphics2D)g2, x, y);
   }
 
   public TextHitInfo getStrongCaret (TextHitInfo hit1, 
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
index 797d653d226d..edfc9ceee9c0 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
@@ -45,7 +45,6 @@ import java.awt.peer.CanvasPeer;
 public class GtkCanvasPeer extends GtkComponentPeer implements CanvasPeer
 {
   native void create ();
-  native void realize ();
 
   public GtkCanvasPeer (Canvas c)
   {
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index 1a85de5fe49c..625855f01176 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -109,14 +109,7 @@ public class GtkComponentPeer extends GtkGenericPeer
   native void gtkWidgetRequestFocus ();
   native void gtkWidgetDispatchKeyEvent (int id, long when, int mods,
                                          int keyCode, int keyLocation);
-
-  native boolean isRealized ();
-
-  void realize ()
-  {
-    // Default implementation does nothing
-  }
-
+  native void realize();
   native void setNativeEventMask ();
 
   void create ()
@@ -149,6 +142,9 @@ public class GtkComponentPeer extends GtkGenericPeer
 
     setNativeEventMask ();
 
+    // This peer is guaranteed to have an X window upon construction.
+    // That is, native methods such as those in GdkGraphics can rely
+    // on this component's widget->window field being non-null.
     realize ();
 
     if (awtComponent.isCursorSet())
@@ -211,16 +207,7 @@ public class GtkComponentPeer extends GtkGenericPeer
 
   public Image createImage (int width, int height)
   {
-    Image image;
-    if (GtkToolkit.useGraphics2D ())
-      image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
-    else
-      image = new GtkImage (width, height);
-
-    Graphics g = image.getGraphics();
-    g.setColor(getBackground());
-    g.fillRect(0, 0, width, height);
-    return image;
+    return CairoSurface.getBufferedImage(width, height);
   }
 
   public void disable () 
@@ -247,10 +234,7 @@ public class GtkComponentPeer extends GtkGenericPeer
   // never return null.
   public Graphics getGraphics ()
   {
-    if (GtkToolkit.useGraphics2D ())
-        return new GdkGraphics2D (this);
-    else
-        return new GdkGraphics (this);
+    return ComponentGraphics.getComponentGraphics(this);
   }
 
   public Point getLocationOnScreen () 
@@ -713,7 +697,7 @@ public class GtkComponentPeer extends GtkGenericPeer
   // on which this component is displayed.
   public VolatileImage createVolatileImage (int width, int height)
   {
-    return new GtkVolatileImage (width, height);
+    return new GtkVolatileImage (this, width, height, null);
   }
 
   // Creates buffers used in a buffering strategy.
@@ -723,7 +707,7 @@ public class GtkComponentPeer extends GtkGenericPeer
     // numBuffers == 2 implies double-buffering, meaning one back
     // buffer and one front buffer.
     if (numBuffers == 2)
-      backBuffer = new GtkVolatileImage(awtComponent.getWidth(),
+      backBuffer = new GtkVolatileImage(this, awtComponent.getWidth(),
 					awtComponent.getHeight(),
 					caps.getBackBufferCapabilities());
     else
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java
index 5e5f1de01134..ef96518a1c01 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkImage.java
@@ -57,14 +57,7 @@ import java.net.URL;
 import gnu.classpath.Pointer;
 
 /**
- * GtkImage - wraps a GdkPixbuf or GdkPixmap.
- *
- * The constructor GtkImage(int, int) creates an 'off-screen' GdkPixmap,
- * this can be drawn to (it's a GdkDrawable), and correspondingly, you can
- * create a GdkGraphics object for it. 
- *
- * This corresponds to the Image implementation returned by 
- * Component.createImage(int, int). 
+ * GtkImage - wraps a GdkPixbuf.
  *
  * A GdkPixbuf is 'on-screen' and the gdk cannot draw to it,
  * this is used for the other constructors (and other createImage methods), and
@@ -88,20 +81,16 @@ public class GtkImage extends Image
   boolean isLoaded;
 
   /**
-   * Pointer to the GdkPixbuf
+   * Pointer to the GdkPixbuf - 
+   * don't change the name without changing the native code.
    */
-  Pointer pixmap;
+  Pointer pixbuf;
 
   /**
    * Observer queue.
    */
   Vector observers;
 
-  /**
-   * If offScreen is set, a GdkBitmap is wrapped and not a Pixbuf.
-   */
-  boolean offScreen;
-
   /**
    * Error flag for loading.
    */
@@ -121,72 +110,65 @@ public class GtkImage extends Image
 						       0x00FF0000,
 						       0xFF000000);
 
+  /**
+   * The singleton GtkImage that is returned on errors by GtkToolkit.
+   */
+  private static GtkImage errorImage;
+
+  /**
+   * Lock that should be held for all gdkpixbuf operations. We don't use
+   * the global gdk_threads_enter/leave functions in most places since
+   * most gdkpixbuf operations can be done in parallel to drawing and 
+   * manipulating gtk widgets.
+   */
+  static Object pixbufLock = new Object();
+
+  /**
+   * Allocate a PixBuf from a given ARGB32 buffer pointer.
+   */
+  private native void initFromBuffer( long bufferPointer );
+
   /**
    * Returns a copy of the pixel data as a java array.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
+   * Should be called with the pixbufLock held.
    */
-  private native int[] getPixels();
+  native int[] getPixels();
 
   /**
    * Sets the pixel data from a java array.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
+   * Should be called with the pixbufLock held.
    */
   private native void setPixels(int[] pixels);
 
   /**
    * Loads an image using gdk-pixbuf from a file.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
+   * Should be called with the pixbufLock held.
    */
   private native boolean loadPixbuf(String name);
 
   /**
    * Loads an image using gdk-pixbuf from data.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
+   * Should be called with the pixbufLock held.
    */
   private native boolean loadImageFromData(byte[] data);
 
   /**
-   * Allocates a Gtk Pixbuf or pixmap
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
+   * Allocates a Gtk Pixbuf
+   * Should be called with the pixbufLock held.
    */
-  private native void createPixmap();
+  private native void createPixbuf();
 
   /**
    * Frees the above.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
-   */
-  private native void freePixmap();
-
-  /**
-   * Sets the pixmap to scaled copy of src image. hints are rendering hints.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
-   */
-  private native void createScaledPixmap(GtkImage src, int hints);
-
-  /**
-   * Draws the image, optionally scaled and composited.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
-   * Also acquires global gdk lock for drawing.
+   * Should be called with the pixbufLock held.
    */
-  private native void drawPixelsScaled (GdkGraphics gc, 
-					int bg_red, int bg_green, int bg_blue, 
-					int x, int y, int width, int height, 
-					boolean composite);
+  private native void freePixbuf();
 
   /**
-   * Draws the image, optionally scaled flipped and composited.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
-   * Also acquires global gdk lock for drawing.
+   * Sets the pixbuf to scaled copy of src image. hints are rendering hints.
+   * Should be called with the pixbufLock held.
    */
-  private native void drawPixelsScaledFlipped (GdkGraphics gc, 
-					       int bg_red, int bg_green, 
-					       int bg_blue, 
-					       boolean flipX, boolean flipY,
-					       int srcX, int srcY,
-					       int srcWidth, int srcHeight,
-					       int dstX, int dstY,
-					       int dstWidth, int dstHeight,
-					       boolean composite);
+  private native void createScaledPixbuf(GtkImage src, int hints);
 
   /**
    * Constructs a GtkImage from an ImageProducer. Asynchronity is handled in
@@ -202,7 +184,6 @@ public class GtkImage extends Image
     source = producer;
     errorLoading = false;
     source.startProduction(new GtkImageConsumer(this, source));
-    offScreen = false;
   }
 
   /**
@@ -215,7 +196,6 @@ public class GtkImage extends Image
   {
     isLoaded = true;
     observers = null;
-    offScreen = false;
     props = new Hashtable();
     errorLoading = false;
   }
@@ -231,7 +211,7 @@ public class GtkImage extends Image
     try
       {
 	String path = f.getCanonicalPath();
-	synchronized(GdkPixbufDecoder.pixbufLock)
+	synchronized(pixbufLock)
 	  {
 	    if (loadPixbuf(f.getCanonicalPath()) != true)
 	      throw new IllegalArgumentException("Couldn't load image: "
@@ -249,7 +229,6 @@ public class GtkImage extends Image
 
     isLoaded = true;
     observers = null;
-    offScreen = false;
     props = new Hashtable();
   }
 
@@ -261,7 +240,7 @@ public class GtkImage extends Image
    */
   public GtkImage (byte[] data)
   {
-    synchronized(GdkPixbufDecoder.pixbufLock)
+    synchronized(pixbufLock)
       {
 	if (loadImageFromData (data) != true)
 	  throw new IllegalArgumentException ("Couldn't load image.");
@@ -269,7 +248,6 @@ public class GtkImage extends Image
 
     isLoaded = true;
     observers = null;
-    offScreen = false;
     props = new Hashtable();
     errorLoading = false;
   }
@@ -301,7 +279,7 @@ public class GtkImage extends Image
 	throw new IllegalArgumentException ("Couldn't load image.");
       }
     byte[] array = baos.toByteArray();
-    synchronized(GdkPixbufDecoder.pixbufLock)
+    synchronized(pixbufLock)
       {
 	if (loadImageFromData(array) != true)
 	  throw new IllegalArgumentException ("Couldn't load image.");
@@ -312,23 +290,6 @@ public class GtkImage extends Image
     props = new Hashtable();
   }
 
-  /**
-   * Constructs an empty GtkImage.
-   */
-  public GtkImage (int width, int height)
-  {
-    this.width = width;
-    this.height = height;
-    props = new Hashtable();
-    isLoaded = true;
-    observers = null;
-    offScreen = true;
-    synchronized(GdkPixbufDecoder.pixbufLock)
-      {
-	createPixmap();
-      }
-  }
-
   /**
    * Constructs a scaled version of the src bitmap, using the GDK.
    */
@@ -339,12 +300,11 @@ public class GtkImage extends Image
     props = new Hashtable();
     isLoaded = true;
     observers = null;
-    offScreen = false;
 
     // Use the GDK scaling method.
-    synchronized(GdkPixbufDecoder.pixbufLock)
+    synchronized(pixbufLock)
       {
-	createScaledPixmap(src, hints);
+	createScaledPixbuf(src, hints);
       }
   }
 
@@ -354,19 +314,30 @@ public class GtkImage extends Image
    */
   GtkImage (Pointer pixbuf)
   {
-    pixmap = pixbuf;
-    synchronized(GdkPixbufDecoder.pixbufLock)
+    this.pixbuf = pixbuf;
+    synchronized(pixbufLock)
       {
 	createFromPixbuf();
       }
     isLoaded = true;
     observers = null;
-    offScreen = false;
     props = new Hashtable();
   }
 
-  // The singleton GtkImage that is returned on errors by GtkToolkit.
-  private static GtkImage errorImage;
+  /**
+   * Wraps a buffer with a GtkImage.
+   *
+   * @param bufferPointer a pointer to an ARGB32 buffer
+   */
+  GtkImage(int width, int height, long bufferPointer)
+  {
+    this.width = width;
+    this.height = height;
+    props = new Hashtable();
+    isLoaded = true;
+    observers = null;
+    initFromBuffer( bufferPointer );
+  }
 
   /**
    * Returns an empty GtkImage with the errorLoading flag set.
@@ -385,7 +356,7 @@ public class GtkImage extends Image
 
   /**
    * Native helper function for constructor that takes a pixbuf Pointer.
-   * Should be called with the GdkPixbufDecoder.pixbufLock held.
+   * Should be called with the pixbufLock held.
    */
   private native void createFromPixbuf();
 
@@ -407,9 +378,9 @@ public class GtkImage extends Image
 
     isLoaded = true;
     deliver();
-    synchronized(GdkPixbufDecoder.pixbufLock)
+    synchronized(pixbufLock)
       {
-	createPixmap();
+	createPixbuf();
 	setPixels(pixels);
       }
   }
@@ -450,30 +421,28 @@ public class GtkImage extends Image
       return null;
 
     int[] pixels;
-    synchronized(GdkPixbufDecoder.pixbufLock)
+    synchronized (pixbufLock)
       {
-	pixels = getPixels();
+        if (!errorLoading)
+          pixels = getPixels();
+        else
+          return null;
       }
     return new MemoryImageSource(width, height, nativeModel, pixels, 
 				 0, width);
   }
 
   /**
-   * Creates a GdkGraphics context for this pixmap.
+   * Does nothing. Should not be called.
    */
   public Graphics getGraphics ()
   {
-    if (!isLoaded) 
-      return null;
-    if (offScreen)
-      return new GdkGraphics(this);
-    else
-      throw new IllegalAccessError("This method only works for off-screen"
-				   +" Images.");
+    throw new IllegalAccessError("This method only works for off-screen"
+				 +" Images.");
   }
   
   /**
-   * Returns a scaled instance of this pixmap.
+   * Returns a scaled instance of this pixbuf.
    */
   public Image getScaledInstance(int width,
 				 int height,
@@ -500,9 +469,9 @@ public class GtkImage extends Image
       {
 	observers = new Vector();
 	isLoaded = false;
-	synchronized(GdkPixbufDecoder.pixbufLock)
+	synchronized(pixbufLock)
 	  {
-	    freePixmap();
+	    freePixbuf();
 	  }
 	source.startProduction(new GtkImageConsumer(this, source));
       }
@@ -512,9 +481,9 @@ public class GtkImage extends Image
   {
     if (isLoaded)
       {
-	synchronized(GdkPixbufDecoder.pixbufLock)
+	synchronized(pixbufLock)
 	  {
-	    freePixmap();
+	    freePixbuf();
 	  }
       }
   }
@@ -535,104 +504,6 @@ public class GtkImage extends Image
     return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
   }
 
-  // Drawing methods ////////////////////////////////////////////////
-
-  /**
-   * Draws an image with eventual scaling/transforming.
-   */
-  public boolean drawImage (GdkGraphics g, int dx1, int dy1, int dx2, int dy2, 
-			    int sx1, int sy1, int sx2, int sy2, 
-			    Color bgcolor, ImageObserver observer)
-  {
-    if (addObserver(observer))
-      return false;
-
-    boolean flipX = (dx1 > dx2)^(sx1 > sx2);
-    boolean flipY = (dy1 > dy2)^(sy1 > sy2);
-    int dstWidth = Math.abs (dx2 - dx1);
-    int dstHeight = Math.abs (dy2 - dy1);
-    int srcWidth = Math.abs (sx2 - sx1);
-    int srcHeight = Math.abs (sy2 - sy1);
-    int srcX = (sx1 < sx2) ? sx1 : sx2;
-    int srcY = (sy1 < sy2) ? sy1 : sy2;
-    int dstX = (dx1 < dx2) ? dx1 : dx2;
-    int dstY = (dy1 < dy2) ? dy1 : dy2;
-
-    // Clipping. This requires the dst to be scaled as well, 
-    if (srcWidth > width)
-      {
-	dstWidth = (int)((double)dstWidth*((double)width/(double)srcWidth));
-	srcWidth = width - srcX;
-      }
-
-    if (srcHeight > height) 
-      {
-	dstHeight = (int)((double)dstHeight*((double)height/(double)srcHeight));
-	srcHeight = height - srcY;
-      }
-
-    if (srcWidth + srcX > width)
-      {
-	dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
-	srcWidth = width - srcX;
-      }
-
-    if (srcHeight + srcY > height)
-      {
-	dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
-	srcHeight = height - srcY;
-      }
-
-    if ( this.width <= 0 || this.height <= 0 )
-      return true;
-
-    if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0)
-      return true;
-
-    synchronized(GdkPixbufDecoder.pixbufLock)
-      {
-	if(bgcolor != null)
-	  drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (), 
-				   bgcolor.getBlue (), 
-				   flipX, flipY,
-				   srcX, srcY,
-				   srcWidth, srcHeight,
-				   dstX,  dstY,
-				   dstWidth, dstHeight,
-				   true);
-	else
-	  drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY,
-				   srcX, srcY, srcWidth, srcHeight,
-				   dstX,  dstY, dstWidth, dstHeight,
-				   false);
-      }
-    return true;
-  }
-
-  /**
-   * Draws an image to the GdkGraphics context, at (x,y) scaled to 
-   * width and height, with optional compositing with a background color.
-   */
-  public boolean drawImage (GdkGraphics g, int x, int y, int width, int height,
-			    Color bgcolor, ImageObserver observer)
-  {
-    if (addObserver(observer))
-      return false;
-
-    if ( this.width <= 0 || this.height <= 0 )
-      return true;
-
-    synchronized(GdkPixbufDecoder.pixbufLock)
-      {
-	if(bgcolor != null)
-	  drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (), 
-			   bgcolor.getBlue (), x, y, width, height, true);
-	else
-	  drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false);
-      }
-
-    return true;
-  }
 
   // Private methods ////////////////////////////////////////////////
 
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java
index 4c41f97b183e..688af00e445d 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -78,31 +78,12 @@ import javax.imageio.spi.IIORegistry;
    this class.  If getPeer() ever goes away, we can implement a hash table
    that will keep up with every window's peer, but for now this is faster. */
 
-/**
- * This class accesses a system property called
- * <tt>gnu.java.awt.peer.gtk.Graphics</tt>.  If the property is defined and
- * equal to "Graphics2D", the cairo-based GdkGraphics2D will be used in
- * drawing contexts. Any other value will cause the older GdkGraphics
- * object to be used.
- */
 public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
 {
   Hashtable containers = new Hashtable();
   static EventQueue q;
-  static boolean useGraphics2dSet;
-  static boolean useGraphics2d;
   static Thread mainThread;
 
-  public static boolean useGraphics2D()
-  {
-    if (useGraphics2dSet)
-      return useGraphics2d;
-    useGraphics2d = System.getProperty("gnu.java.awt.peer.gtk.Graphics", 
-                                       "Graphics").equals("Graphics2D");
-    useGraphics2dSet = true;
-    return useGraphics2d;
-  }
-
   static native void gtkInit(int portableNativeSync);
 
   static
@@ -178,10 +159,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
     Image image;
     try
       {
-	if (useGraphics2D())
-	  image = GdkPixbufDecoder.createBufferedImage(filename);
-	else
-	  image = new GtkImage(filename);
+	image = CairoSurface.getBufferedImage( new GtkImage( filename ) );
       }
     catch (IllegalArgumentException iae)
       {
@@ -195,10 +173,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
     Image image;
     try
       {
-	if (useGraphics2D())
-	  image = GdkPixbufDecoder.createBufferedImage(url);
-	else
-	  image = new GtkImage(url);
+	image = CairoSurface.getBufferedImage( new GtkImage( url ) );
       }
     catch (IllegalArgumentException iae)
       {
@@ -209,13 +184,13 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
 
   public Image createImage (ImageProducer producer) 
   {
+    if (producer == null)
+      return null;
+      
     Image image;
     try
       {
-	if (useGraphics2D())
-	  image = GdkPixbufDecoder.createBufferedImage(producer);
-	else
-	  image = new GtkImage(producer);
+	image = CairoSurface.getBufferedImage( new GtkImage( producer ) );
       }
     catch (IllegalArgumentException iae)
       {
@@ -230,16 +205,9 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
     Image image;
     try
       {
-	if (useGraphics2D())
-	  image = GdkPixbufDecoder.createBufferedImage(imagedata,
-						       imageoffset, 
-						       imagelength);
-	else
-	  {
-	    byte[] datacopy = new byte[imagelength];
-	    System.arraycopy(imagedata, imageoffset, datacopy, 0, imagelength);
-	    return new GtkImage(datacopy);
-	  }
+	byte[] data = new byte[ imagelength ];
+	System.arraycopy(imagedata, imageoffset, data, 0, imagelength);
+	image = CairoSurface.getBufferedImage( new GtkImage( data ) );
       }
     catch (IllegalArgumentException iae)
       {
@@ -256,7 +224,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
    */  
   public ImageProducer createImageProducer(URL url)
   {
-    return new GdkPixbufDecoder(url);  
+    return createImage( url ).getSource();
   }
 
   /**
@@ -568,13 +536,23 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
 
   protected EventQueue getSystemEventQueueImpl() 
   {
-    synchronized (GtkToolkit.class)
+    // GCJ LOCAL: workaround a GCJ problem accessing
+    // GtkToolkit.class
+    try
+      {
+    synchronized (Class.forName ("gnu.java.awt.peer.gtk.GtkToolkit"))
       {
         if (q == null)
           {
             q = new EventQueue();
           }
       }    
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+    
     return q;
   }
 
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java
index 496090a09401..53bcd739d9e8 100644
--- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java
@@ -1,4 +1,4 @@
-/* GtkVolatileImage.java -- a hardware-accelerated image buffer
+/* GtkVolatileImage.java -- wraps an X pixmap
    Copyright (C) 2005  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
 package gnu.java.awt.peer.gtk;
 
 import java.awt.ImageCapabilities;
+import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.GraphicsConfiguration;
 import java.awt.image.BufferedImage;
@@ -46,44 +47,68 @@ import java.awt.image.VolatileImage;
 
 public class GtkVolatileImage extends VolatileImage
 {
-  private int width;
-  private int height;
+  int width, height;
   private ImageCapabilities caps;
 
-  public GtkVolatileImage(int width, int height)
-  {
-    this(width, height, null);
-  }
+  /**
+   * Don't touch, accessed from native code.
+   */
+  long nativePointer;
 
-  public GtkVolatileImage(int width, int height, ImageCapabilities caps)
+  native long init(GtkComponentPeer component, int width, int height);
+
+  native void destroy();
+
+  native int[] getPixels();
+
+  native void copyArea( int x, int y, int w, int h, int dx, int dy );
+
+  native void drawVolatile( long ptr, int x, int y, int w, int h );
+  
+  public GtkVolatileImage(GtkComponentPeer component, 
+			  int width, int height, ImageCapabilities caps)
   {
     this.width = width;
     this.height = height;
     this.caps = caps;
+    nativePointer = init( component, width, height );
   }
 
-  // FIXME: should return a buffered image snapshot of the accelerated
-  // visual
-  public BufferedImage getSnapshot()
+  public GtkVolatileImage(int width, int height, ImageCapabilities caps)
   {
-    return null;
+    this(null, width, height, caps);
   }
 
-  public int getWidth()
+  public GtkVolatileImage(int width, int height)
   {
-    return width;
+    this(null, width, height, null);
   }
 
-  public int getHeight()
+  public void finalize()
   {
-    return height;
+    dispose();
+  }
+
+  public void dispose()
+  {
+    destroy();
+  }
+
+  public BufferedImage getSnapshot()
+  {
+    CairoSurface cs = new CairoSurface( width, height );
+    cs.setPixels( getPixels() );
+    return CairoSurface.getBufferedImage( cs );
+  }
+
+  public Graphics getGraphics()
+  {
+    return createGraphics();
   }
 
-  // FIXME: should return a graphics wrapper around this image's
-  // visual
   public Graphics2D createGraphics()
   {
-    return null;
+    return new VolatileImageGraphics( this );
   }
 
   public int validate(GraphicsConfiguration gc)
@@ -101,18 +126,28 @@ public class GtkVolatileImage extends VolatileImage
     return caps;
   }
 
-  public synchronized Object getProperty (String name, ImageObserver observer)
+  public int getWidth()
   {
-    return null;
+    return width;
+  }
+
+  public int getHeight()
+  {
+    return height;
   }
 
-  public synchronized int getWidth (ImageObserver observer)
+  public int getWidth(java.awt.image.ImageObserver observer)
   {
     return width;
   }
   
-  public synchronized int getHeight (ImageObserver observer)
+  public int getHeight(java.awt.image.ImageObserver observer)
   {
     return height;
   }
+
+  public Object getProperty(String name, ImageObserver observer)
+  {
+    return null;
+  }
 }
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java b/libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
new file mode 100644
index 000000000000..d5adfcf77579
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
@@ -0,0 +1,122 @@
+/* VolatileImageGraphics.java
+   Copyright (C) 2006 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 gnu.java.awt.peer.gtk;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.RenderedImage;
+import java.awt.image.ImageObserver;
+import java.util.WeakHashMap;
+
+public class VolatileImageGraphics extends ComponentGraphics
+{
+  private GtkVolatileImage owner;
+
+  public VolatileImageGraphics(GtkVolatileImage img)
+  {
+    this.owner = img;
+    cairo_t = initFromVolatile( owner.nativePointer, img.width, img.height );
+    setup( cairo_t );
+    setClip( new Rectangle( 0, 0, img.width, img.height) );
+  }
+
+  private VolatileImageGraphics(VolatileImageGraphics copy)
+  {
+    this.owner = copy.owner;
+    initFromVolatile( owner.nativePointer, owner.width, owner.height );
+    setClip( new Rectangle( 0, 0, owner.width, owner.height) );
+    copy( copy, cairo_t );
+  }
+
+  public void copyAreaImpl(int x, int y, int width, int height, int dx, int dy)
+  {
+    owner.copyArea(x, y, width, height, dx, dy);
+  }
+
+  public GraphicsConfiguration getDeviceConfiguration()
+  {
+    return null;
+  }
+
+  public Graphics create()
+  {
+    return new VolatileImageGraphics( this );
+  }
+
+
+  public boolean drawImage(Image img, int x, int y, ImageObserver observer)
+  {
+    if( img instanceof GtkVolatileImage )
+      {
+	owner.drawVolatile( ((GtkVolatileImage)img).nativePointer, 
+			    x, y,
+			    ((GtkVolatileImage)img).width, 
+			    ((GtkVolatileImage)img).height );
+	return true;
+      }      
+    return super.drawImage( img, x, y, observer );
+  }
+  
+  public boolean drawImage(Image img, int x, int y, int width, int height,
+                           ImageObserver observer)
+  {
+    if( img instanceof GtkVolatileImage )
+      {
+	owner.drawVolatile( ((GtkVolatileImage)img).nativePointer, 
+			    x, y, width, height );
+	return true;
+      }      
+    return super.drawImage( img, x, y, width, height, observer );
+  }
+}
+
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingComponent.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingComponent.java
index 04ca7294f78d..a51b758adf0a 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingComponent.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingComponent.java
@@ -62,7 +62,7 @@ public interface SwingComponent
 
   /**
    * Handles a mouse event. This is usually forwarded to
-   * {@link Component#processMouseMotionEvent(MouseEvent)} of the swing
+   * {@link java.awt.Component#processMouseMotionEvent(MouseEvent)} of the swing
    * component.
    *
    * @param ev the mouse event
@@ -71,7 +71,7 @@ public interface SwingComponent
 
   /**
    * Handles a mouse motion event. This is usually forwarded to
-   * {@link Component#processMouseEvent(MouseEvent)} of the swing
+   * {@link java.awt.Component#processMouseEvent(MouseEvent)} of the swing
    * component.
    *
    * @param ev the mouse motion event
@@ -80,7 +80,7 @@ public interface SwingComponent
 
   /**
    * Handles a key event. This is usually forwarded to
-   * {@link Component#processKeyEvent(KeyEvent)} of the swing
+   * {@link java.awt.Component#processKeyEvent(KeyEvent)} of the swing
    * component.
    *
    * @param ev the key event
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java
index 5d484e021b28..f60c8e96c1d1 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingComponentPeer.java
@@ -48,6 +48,8 @@ import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics;
 import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.Image;
 import java.awt.Point;
 import java.awt.Rectangle;
@@ -98,8 +100,9 @@ public class SwingComponentPeer
 
   /**
    * Creates a SwingComponentPeer instance. Subclasses are expected to call
-   * this constructor and thereafter call {@link #init(Component, JComponent)}
-   * in order to setup the AWT and Swing components properly.
+   * this constructor and thereafter call
+   * {@link #init(Component, SwingComponent)} in order to setup the AWT and
+   * Swing components properly.
    */
   protected SwingComponentPeer()
   {
@@ -164,9 +167,12 @@ public class SwingComponentPeer
    */
   public Image createImage(int width, int height)
   {
-    Component parent = awtComponent.getParent();
-    ComponentPeer parentPeer = parent.getPeer();
-    return parentPeer.createImage(width, height);
+    GraphicsEnvironment graphicsEnv =
+      GraphicsEnvironment.getLocalGraphicsEnvironment();
+    GraphicsDevice dev = graphicsEnv.getDefaultScreenDevice();
+    GraphicsConfiguration conf = dev.getDefaultConfiguration();
+    Image image = conf.createCompatibleImage(width, height);
+    return image;
   }
 
   /**
@@ -442,20 +448,6 @@ public class SwingComponentPeer
     return retVal;
   }
 
-  /**
-   * Prepares an image for rendering on this component. This is called by
-   * {@link Component#prepareImage(Image, int, int, ImageObserver)}.
-   *
-   * @param img the image to prepare
-   * @param width the desired width of the rendered image
-   * @param height the desired height of the rendered image
-   * @param ob the image observer to be notified of updates in the preparation
-   *        process
-   *
-   * @return <code>true</code> if the image has been fully prepared,
-   *         <code>false</code> otherwise (in which case the image observer
-   *         receives updates)
-   */
   public void paint(Graphics graphics)
   {
     // FIXME: I don't know what this method is supposed to do.
@@ -478,8 +470,17 @@ public class SwingComponentPeer
   public boolean prepareImage(Image img, int width, int height, ImageObserver ob)
   {
     Component parent = awtComponent.getParent();
-    ComponentPeer parentPeer = parent.getPeer();
-    return parentPeer.prepareImage(img, width, height, ob);
+    boolean res;
+    if(parent != null)
+      {
+        ComponentPeer parentPeer = parent.getPeer();
+        res = parentPeer.prepareImage(img, width, height, ob);
+      }
+    else
+      {
+        res = Toolkit.getDefaultToolkit().prepareImage(img, width, height, ob);
+      }
+    return res;
   }
 
   public void print(Graphics graphics)
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingContainerPeer.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingContainerPeer.java
index 0b2fb992fb99..f433e1b5c2d2 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingContainerPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingContainerPeer.java
@@ -92,7 +92,12 @@ public class SwingContainerPeer
    */
   public Insets getInsets()
   {
-    return insets();
+    Insets retVal;
+    if (swingComponent != null)
+      retVal = swingComponent.getJComponent().getInsets();
+    else
+      retVal = new Insets(0, 0, 0, 0);
+    return retVal;
   }
 
   /**
@@ -209,6 +214,8 @@ public class SwingContainerPeer
   protected void handleMouseEvent(MouseEvent ev)
   {
     Component comp = awtComponent.getComponentAt(ev.getPoint());
+    if(comp == null)
+      comp = awtComponent;
     if (comp != null)
       {
         ComponentPeer peer = comp.getPeer();
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingFramePeer.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingFramePeer.java
index fea1b504a6a9..0d5a02d78f67 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingFramePeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingFramePeer.java
@@ -53,9 +53,9 @@ import java.awt.peer.FramePeer;
  * As a minimum, a subclass must implement all the remaining abstract methods
  * as well as the following methods:
  * <ul>
- * <li>{@link ComponentPeer#getLocationOnScreen()}</li>
- * <li>{@link ComponentPeer#getGraphics()}</li>
- * <li>{@link ComponentPeer#createImage(int, int)}</li>
+ * <li>{@link java.awt.peer.ComponentPeer#getLocationOnScreen()}</li>
+ * <li>{@link java.awt.peer.ComponentPeer#getGraphics()}</li>
+ * <li>{@link java.awt.peer.ComponentPeer#createImage(int, int)}</li>
  * </ul>
  *
  * @author Roman Kennke (kennke@aicas.com)
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingMenuBarPeer.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingMenuBarPeer.java
index bd9dcd77aaa3..0033efb025f7 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingMenuBarPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingMenuBarPeer.java
@@ -174,7 +174,7 @@ public class SwingMenuBarPeer
   /**
    * Adds a help menu to the menu bar.
    *
-   * @param m the menu to add
+   * @param menu the menu to add
    */
   public void addHelpMenu(Menu menu)
   {
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java
index a4c6d82d2cd7..0c3b4e726034 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingTextFieldPeer.java
@@ -283,7 +283,7 @@ public class SwingTextFieldPeer
    * @param startPos the start index of the selection
    * @param endPos the start index of the selection
    */
-  public void select(int start_pos, int endPos)
+  public void select(int startPos, int endPos)
   {
     // TODO: Must be implemented.
   }
diff --git a/libjava/classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java b/libjava/classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java
index 2f89795ca4f8..43a509b957d2 100644
--- a/libjava/classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java
+++ b/libjava/classpath/gnu/java/awt/peer/swing/SwingWindowPeer.java
@@ -48,9 +48,9 @@ import java.awt.peer.WindowPeer;
  * As a minimum, a subclass must implement all the remaining abstract methods
  * as well as the following methods:
  * <ul>
- * <li>{@link ComponentPeer#getLocationOnScreen()}</li>
- * <li>{@link ComponentPeer#getGraphics()}</li>
- * <li>{@link ComponentPeer#createImage(int, int)}</li>
+ * <li>{@link java.awt.peer.ComponentPeer#getLocationOnScreen()}</li>
+ * <li>{@link java.awt.peer.ComponentPeer#getGraphics()}</li>
+ * <li>{@link java.awt.peer.ComponentPeer#createImage(int, int)}</li>
  * </ul>
  *
  * @author Roman Kennke (kennke@aicas.com)
diff --git a/libjava/classpath/gnu/java/awt/print/JavaPrinterGraphics.java b/libjava/classpath/gnu/java/awt/print/JavaPrinterGraphics.java
new file mode 100644
index 000000000000..9a3db0125838
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/print/JavaPrinterGraphics.java
@@ -0,0 +1,518 @@
+/* JavaPrinterGraphics.java -- AWT printer rendering class.
+   Copyright (C) 2006  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 gnu.java.awt.print;
+
+import gnu.java.awt.peer.gtk.CairoSurface;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.image.ImageObserver;
+import java.awt.image.PixelGrabber;
+import java.awt.print.PageFormat;
+import java.awt.print.Pageable;
+import java.awt.print.Paper;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterGraphics;
+import java.awt.print.PrinterJob;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.text.AttributedCharacterIterator;
+
+/**
+ * Graphics context to draw to PostScript.
+ *
+ * @author Sven de Marothy
+ */
+public class JavaPrinterGraphics extends Graphics implements PrinterGraphics
+{
+
+  /**
+   * The used graphics context.
+   */
+  private Graphics g;
+
+  /**
+   * The associated printer job.
+   */
+  private PrinterJob printerJob;
+
+  /**
+   * Rendering resolution
+   */
+  private static final double DPI = 72.0;
+
+  /**
+   * Rendered image size.
+   */
+  private int xSize, ySize;
+
+  /**
+   * The image to render to.
+   */
+  private Image image;
+
+  public JavaPrinterGraphics( PrinterJob printerJob )
+  {
+    this.printerJob = printerJob;
+  }
+
+  /**
+   * Spool a document to PostScript.
+   * If Pageable is non-null, it will print that, otherwise it will use
+   * the supplied printable and pageFormat.
+   */
+  public SpooledDocument spoolPostScript(Printable printable, 
+					 PageFormat pageFormat,
+					 Pageable pageable)
+    throws PrinterException
+  {
+    try 
+      {
+	// spool to a temporary file
+	File temp = File.createTempFile("cpspool", ".ps");
+	temp.deleteOnExit();
+	
+	PrintWriter out = new PrintWriter
+	  (new BufferedWriter
+	    (new OutputStreamWriter
+	     (new FileOutputStream(temp), "ISO8859_1"), 1000000));
+
+	writePSHeader(out);
+	
+	if(pageable != null)
+	  {
+	    for(int index = 0; index < pageable.getNumberOfPages(); index++)
+	      spoolPage(out, pageable.getPrintable(index),
+			pageable.getPageFormat(index), index);
+	  }
+	else
+	  {
+	    int index = 0;
+	    while(spoolPage(out, printable, pageFormat, index++) ==
+		  Printable.PAGE_EXISTS);
+	  }
+	 out.println("%%Trailer");
+	 out.println("%%EOF");
+	 out.close();
+	 return new SpooledDocument( temp );
+       } 
+    catch (IOException e) 
+      {
+	PrinterException pe = new PrinterException();
+	pe.initCause(e);
+	throw pe;
+      }
+  }
+
+  /**
+   * Spools a single page, returns NO_SUCH_PAGE unsuccessful,
+   * PAGE_EXISTS if it was.
+   */
+  public int spoolPage(PrintWriter out,
+		       Printable printable, 
+		       PageFormat pageFormat, 
+		       int index) throws IOException, PrinterException
+  {
+    initImage( pageFormat );
+    if(printable.print(this, pageFormat, index) == Printable.NO_SUCH_PAGE)
+      return Printable.NO_SUCH_PAGE;
+    g.dispose();
+    g = null;
+    writePage( out, pageFormat );
+    return Printable.PAGE_EXISTS;
+  }
+  
+  private void initImage(PageFormat pageFormat)
+  {
+    // Create a really big image and draw to that.
+    xSize = (int)(DPI*pageFormat.getWidth()/72.0);
+    ySize = (int)(DPI*pageFormat.getHeight()/72.0);
+    
+    // Swap X and Y sizes if it's a Landscape page.
+    if( pageFormat.getOrientation() != PageFormat.PORTRAIT )
+      {
+	int t = xSize;
+	xSize = ySize;
+	ySize = t;
+      }
+
+    // FIXME: This should at least be BufferedImage. 
+    // Fix once we have a working B.I.
+    // Graphics2D should also be supported of course.
+    image = CairoSurface.getBufferedImage(xSize, ySize);
+
+    g = image.getGraphics();
+    setColor(Color.white);
+    fillRect(0, 0, xSize, ySize);
+    setColor(Color.black);
+  }
+
+  private void writePSHeader(PrintWriter out)
+  {
+    out.println("%!PS-Adobe-3.0");      
+    out.println("%%Title: "+printerJob.getJobName());
+    out.println("%%Creator: GNU Classpath ");
+    out.println("%%DocumentData: Clean8Bit");
+
+    out.println("%%DocumentNeededResources: font Times-Roman Helvetica Courier");
+    //    out.println("%%Pages: "+);  // FIXME # pages.
+    out.println("%%EndComments");
+    
+    out.println("%%BeginProlog");
+    out.println("%%EndProlog");
+    out.println("%%BeginSetup");
+    
+    // FIXME: Paper name
+    // E.g. "A4" "Letter"
+    //    out.println("%%BeginFeature: *PageSize A4");
+    
+    out.println("%%EndFeature");
+
+    out.println("%%EndSetup");
+    
+    //    out.println("%%Page: 1 1");
+  }
+
+  private void writePage(PrintWriter out, PageFormat pageFormat)
+  {
+    out.println("%%BeginPageSetup");
+
+    Paper p = pageFormat.getPaper();
+    double pWidth = p.getWidth();
+    double pHeight = p.getHeight();
+
+    if( pageFormat.getOrientation() == PageFormat.PORTRAIT )
+      out.println( "%%Orientation: Portrait" );
+    else
+      {
+	out.println( "%%Orientation: Landscape" );
+	double t = pWidth;
+	pWidth = pHeight;
+	pHeight = t;
+      }
+      
+    out.println("gsave % first save");
+    
+    // 595x842; 612x792 respectively
+    out.println("<< /PageSize [" +pWidth + " "+pHeight+ "] >> setpagedevice");
+
+    // invert the Y axis so that we get screen-like coordinates instead.
+    AffineTransform pageTransform = new AffineTransform();
+    if( pageFormat.getOrientation() == PageFormat.REVERSE_LANDSCAPE )
+      {
+	pageTransform.translate(pWidth, pHeight);
+	pageTransform.scale(-1.0, -1.0);
+      }
+    concatCTM(out, pageTransform);
+    out.println("%%EndPageSetup");
+
+    out.println("gsave");
+
+
+    // Draw the image
+    out.println(xSize+" "+ySize+" 8 [1 0 0 -1 0 "+ySize+" ]"); 
+    out.println("{currentfile 3 string readhexstring pop} bind");
+    out.println("false 3 colorimage");
+    int[] pixels = new int[xSize * ySize];
+    PixelGrabber pg = new PixelGrabber(image, 0, 0, xSize, ySize, pixels, 0, xSize);
+
+    try {
+      pg.grabPixels();
+    } catch (InterruptedException e) {
+      out.println("% Bug getting pixels!");
+    }
+
+    int n = 0;
+    for (int j = 0; j < ySize; j++) {
+      for (int i = 0; i < xSize; i++) {
+	out.print( colorTripleHex(pixels[j * xSize + i]) );
+	if(((++n)%11) == 0) out.println();
+      }
+    }
+    
+    out.println();
+    out.println("%%EOF");
+    out.println("grestore");
+    out.println("showpage");
+  }
+  
+  /**
+   * Get a nonsperated hex RGB triple, e.g. FFFFFF = white 
+   */
+  private String colorTripleHex(int num){
+    String s = "";
+
+    try {
+      s = Integer.toHexString( ( num & 0x00FFFFFF ) );
+      if( s.length() < 6 )
+	{
+	  s = "000000"+s;
+	  return s.substring(s.length()-6);
+	}
+    } catch (Exception e){
+      s = "FFFFFF";
+    }
+
+    return s;
+  }
+
+  private void concatCTM(PrintWriter out, AffineTransform Tx){
+    double[] matrixElements = new double[6];
+    Tx.getMatrix(matrixElements);
+    
+    out.print("[ ");
+    for(int i=0;i<6;i++)
+      out.print(matrixElements[i]+" ");
+    out.println("] concat");
+  }
+
+  //-----------------------------------------------------------------------------
+  /**
+   * PrinterGraphics method - Returns the printer job associated with this object.
+   */
+  public PrinterJob getPrinterJob()
+  {
+    return printerJob;
+  }
+
+  /**
+   * The rest of the methods here are just pass-throughs to g.
+   */
+  public void clearRect(int x, int y, int width, int height)
+  {
+    g.clearRect(x, y, width, height);
+  }
+
+  public void clipRect(int x, int y, int width, int height)
+  {
+    g.clipRect(x, y, width, height);
+  }
+
+  public void copyArea(int x, int y, int width, int height, int dx, int dy)
+  {
+    g.copyArea(x, y, width, height, dx, dy);
+  }
+
+  public Graphics create()
+  {
+    return g.create();
+  }
+
+  public void dispose()
+  {
+  }
+
+  public void drawArc(int x, int y, int width, int height, int startAngle, 
+		      int arcAngle)
+  {
+    g.drawArc(x, y, width, height, startAngle, arcAngle);
+  }
+
+  public boolean drawImage(Image img, int x, int y, Color bgcolor, 
+			   ImageObserver observer)
+  {
+    return g.drawImage(img, x, y, bgcolor, observer);
+  }
+
+  public boolean drawImage(Image img, int x, int y, ImageObserver observer)
+  {
+    return g.drawImage(img, x, y, observer);
+  }
+
+  public boolean drawImage(Image img, int x, int y, int width, int height, 
+			   Color bgcolor, ImageObserver observer)
+  {
+    return g.drawImage(img, x, y, width, height, bgcolor, observer);
+  }
+
+  public boolean drawImage(Image img, int x, int y, int width, int height, 
+			   ImageObserver observer)
+  {
+    return g.drawImage(img, x, y, width, height, observer);
+  }
+
+  public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, 
+			   int sx1, int sy1, int sx2, int sy2, Color bgcolor, 
+			   ImageObserver observer)
+  {
+    return g.drawImage(img, dx1,  dy1,  dx2,  dy2,  
+		     sx1,  sy1,  sx2,  sy2, bgcolor, observer);
+  }
+
+  public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, 
+			   int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
+  {
+    return g.drawImage(img, dx1,  dy1,  dx2,  dy2,  
+		     sx1,  sy1,  sx2,  sy2, observer);
+  }
+
+  public void drawLine(int x1, int y1, int x2, int y2)
+  {
+    g.drawLine(x1, y1, x2, y2);
+  }
+
+  public void drawOval(int x, int y, int width, int height)
+  {
+    g.drawOval(x, y, width, height);
+  }
+
+  public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
+  {
+    g.drawPolygon(xPoints, yPoints, nPoints);
+  }
+
+  public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
+  {
+    g.drawPolyline(xPoints, yPoints, nPoints);
+  }
+
+  public void drawRoundRect(int x, int y, int width, int height, 
+			    int arcWidth, int arcHeight)
+  {
+    g.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
+  }
+
+  public void drawString(AttributedCharacterIterator iterator, int x, int y)
+  {
+    g.drawString(iterator, x, y);
+  }
+
+  public void drawString(String str, int x, int y)
+  {
+    g.drawString(str, x, y);
+  }
+
+  public void fillArc(int x, int y, int width, int height, 
+		      int startAngle, int arcAngle)
+  {
+    g.fillArc(x, y, width, height, startAngle, arcAngle);
+  }
+
+  public void fillOval(int x, int y, int width, int height)
+  {
+    g.fillOval(x, y, width, height);
+  }
+
+  public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
+  {
+    g.fillPolygon(xPoints, yPoints, nPoints);
+  }
+
+  public void fillRect(int x, int y, int width, int height)
+  {
+    g.fillRect(x, y, width, height);
+  }
+
+  public void fillRoundRect(int x, int y, int width, int height, 
+			    int arcWidth, int arcHeight)
+  {
+    g.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
+  }
+
+  public Shape getClip()
+  {
+    return g.getClip();
+  }
+
+  public Rectangle getClipBounds()
+  {
+    return g.getClipBounds();
+  }
+
+  public Color getColor()
+  {
+    return g.getColor();
+  }
+
+  public Font getFont()
+  {
+    return g.getFont();
+  }
+
+  public FontMetrics getFontMetrics(Font f)
+  {
+    return g.getFontMetrics(f);
+  }
+
+  public void setClip(int x, int y, int width, int height)
+  {
+    g.setClip(x, y, width, height);
+  }
+
+  public void setClip(Shape clip)
+  {
+    g.setClip(clip);
+  }
+
+  public void setColor(Color c)
+  {
+    g.setColor(c);
+  }
+
+  public void setFont(Font font)
+  {
+    g.setFont(font);
+  }
+
+  public void setPaintMode()
+  {
+    g.setPaintMode();
+  }
+
+  public void setXORMode(Color c1)
+  {
+    g.setXORMode(c1);
+  }
+
+  public void translate(int x, int y)
+  {
+    g.translate(x, y);
+  }
+}
+
diff --git a/libjava/classpath/gnu/java/awt/print/JavaPrinterJob.java b/libjava/classpath/gnu/java/awt/print/JavaPrinterJob.java
new file mode 100644
index 000000000000..adeeba04a1da
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/print/JavaPrinterJob.java
@@ -0,0 +1,403 @@
+/* JavaPrinterJob.java -- AWT printing implemented on javax.print.
+   Copyright (C) 2006  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 gnu.java.awt.print;
+
+import java.awt.HeadlessException;
+import java.awt.print.PageFormat;
+import java.awt.print.Pageable;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import java.util.Locale;
+
+import javax.print.CancelablePrintJob;
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.ServiceUI;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.IntegerSyntax;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.TextSyntax;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.JobName;
+import javax.print.attribute.standard.OrientationRequested;
+import javax.print.attribute.standard.RequestingUserName;
+
+/**
+ * This is the default implementation of PrinterJob
+ *
+ * @author Sven de Marothy
+ */
+public class JavaPrinterJob extends PrinterJob
+{
+  /**
+   * The print service associated with this job
+   */
+  private PrintService printer = null;
+
+  /**
+   * Printing options;
+   */
+  private PrintRequestAttributeSet attributes;
+
+  /**
+   * Available print services
+   */
+  private static PrintService[] services;
+
+  /**
+   * The actual print job.
+   */
+  private DocPrintJob printJob;
+
+  /**
+   * The Printable object to print.
+   */
+  private Printable printable;
+
+  /**
+   * Page format.
+   */
+  private PageFormat pageFormat;
+
+  /**
+   * A pageable, or null
+   */
+  private Pageable pageable = null;
+
+  /**
+   * Cancelled or not
+   */
+  private boolean cancelled = false;
+
+  static
+  {
+    // lookup all services without any constraints
+    services = PrintServiceLookup.lookupPrintServices
+      (DocFlavor.INPUT_STREAM.POSTSCRIPT, null);   
+  }
+
+  private static final Class copyClass = (new Copies(1)).getClass();
+  private static final Class jobNameClass = (new JobName("", null)).getClass();
+  private static final Class userNameClass = (new RequestingUserName("", null)).getClass();
+  
+  /**
+   * Initializes a new instance of <code>PrinterJob</code>. 
+   */
+  public JavaPrinterJob()
+  {
+    attributes = new HashPrintRequestAttributeSet();
+    setCopies(1);
+    setJobName("Java Printing");
+    pageFormat = new PageFormat(); // default page format.
+  }
+
+  private void getPageAttributes()
+  {
+    OrientationRequested orientation = (OrientationRequested)
+      attributes.get( OrientationRequested.LANDSCAPE.getCategory() );
+    if( orientation == null)
+      return;
+
+    if( orientation.equals(OrientationRequested.PORTRAIT) )
+      pageFormat.setOrientation(PageFormat.PORTRAIT);
+    else if( orientation.equals(OrientationRequested.LANDSCAPE) )
+      pageFormat.setOrientation(PageFormat.LANDSCAPE);
+    else if( orientation.equals(OrientationRequested.REVERSE_LANDSCAPE) )
+	pageFormat.setOrientation(PageFormat.REVERSE_LANDSCAPE);
+  }
+
+  /**
+   * Returns the number of copies to be printed.
+   *
+   * @return The number of copies to be printed.
+   */
+  public int getCopies()
+  {
+    return ((IntegerSyntax)attributes.get( jobNameClass )).getValue();
+  }
+
+  /**
+   * Sets the number of copies to be printed.
+   *
+   * @param copies The number of copies to be printed.
+   */
+  public void setCopies(int copies)
+  {
+    attributes.add( new Copies( copies ) );
+  }
+
+  /**
+   * Returns the name of the print job.
+   *
+   * @return The name of the print job.
+   */
+  public String getJobName()
+  {
+    return ((TextSyntax)attributes.get( jobNameClass )).getValue();
+  }
+
+  /**
+   * Sets the name of the print job.
+   *
+   * @param job_name The name of the print job.
+   */
+  public void setJobName(String job_name)
+  {
+    attributes.add( new JobName(job_name, Locale.getDefault()) );
+  }
+
+  /**
+   * Returns the printing user name.
+   *
+   * @return The printing username.
+   */
+  public String getUserName()
+  {
+    return ((TextSyntax)attributes.get( userNameClass )).getValue();
+  }
+
+  /**
+   * Cancels an in progress print job.
+   */
+  public void cancel()
+  {
+    try
+      {
+	if(printJob != null && (printJob instanceof CancelablePrintJob))
+	  {
+	    ((CancelablePrintJob)printJob).cancel();
+	    cancelled = true;
+	  }
+      }
+    catch(PrintException pe)
+      {
+      }
+  }
+
+  /**
+   * Tests whether or not this job has been cancelled.
+   *
+   * @return <code>true</code> if this job has been cancelled, <code>false</code>
+   * otherwise.
+   */
+  public boolean isCancelled()
+  {
+    return cancelled;
+  }
+
+  /**
+   * Clones the specified <code>PageFormat</code> object then alters the
+   * clone so that it represents the default page format.
+   *
+   * @param page_format The <code>PageFormat</code> to clone.
+   *
+   * @return A new default page format.
+   */
+  public PageFormat defaultPage(PageFormat page_format)
+  {
+    return new PageFormat();
+  }
+
+  /**
+   * Displays a dialog box to the user which allows the page format
+   * attributes to be modified.
+   *
+   * @param page_format The <code>PageFormat</code> object to modify.
+   *
+   * @return The modified <code>PageFormat</code>.
+   */
+  public PageFormat pageDialog(PageFormat page_format)
+    throws HeadlessException
+  {
+    return defaultPage(null);
+  }
+
+  /**
+   * Prints the pages.
+   */
+  public void print() throws PrinterException
+  {
+    if( printable == null && pageable == null ) // nothing to print?
+      return;
+
+    PostScriptGraphics2D pg = new PostScriptGraphics2D( this );
+    SpooledDocument doc = pg.spoolPostScript( printable, pageFormat, 
+					      pageable );
+
+    cancelled = false;
+    printJob = printer.createPrintJob();
+    try
+      {
+	printJob.print(doc, attributes);
+      }
+    catch (PrintException pe) 
+      {
+	PrinterException p = new PrinterException();
+	p.initCause(pe);
+	throw p;
+      }
+    // no printjob active.
+    printJob = null;
+  }
+
+  /**
+   * Prints the page with given attributes.
+   */
+  public void print (PrintRequestAttributeSet attributes)
+    throws PrinterException
+  {
+    this.attributes = attributes;
+    print();
+  }
+
+  /**
+   * Displays a dialog box to the user which allows the print job
+   * attributes to be modified.
+   *
+   * @return <code>false</code> if the user cancels the dialog box,
+   * <code>true</code> otherwise.
+   */
+  public boolean printDialog() throws HeadlessException
+  {
+    return printDialog( attributes );
+  }
+
+  /**
+   * Displays a dialog box to the user which allows the print job
+   * attributes to be modified.
+   *
+   * @return <code>false</code> if the user cancels the dialog box,
+   * <code>true</code> otherwise.
+   */
+  public boolean printDialog(PrintRequestAttributeSet attributes)
+    throws HeadlessException
+  {
+    PrintService chosenPrinter = ServiceUI.printDialog
+      (null, 50, 50, services, null, 
+       DocFlavor.INPUT_STREAM.POSTSCRIPT, attributes);
+
+    getPageAttributes();
+
+    if( chosenPrinter != null )
+      {
+	try
+	  {
+	    setPrintService( chosenPrinter );
+	  }
+	catch(PrinterException pe)
+	  {
+	    // Should not happen.
+	  }
+	return true;
+      }
+    return false;
+  }
+
+  /**
+   * This sets the pages that are to be printed.
+   *
+   * @param pageable The pages to be printed, which may not be <code>null</code>.
+   */
+  public void setPageable(Pageable pageable)
+  {
+    if( pageable == null )
+      throw new NullPointerException("Pageable cannot be null.");
+    this.pageable = pageable;
+  }
+
+  /**
+   * Sets this specified <code>Printable</code> as the one to use for
+   * rendering the pages on the print device.
+   *
+   * @param printable The <code>Printable</code> for the print job.
+   */
+  public void setPrintable(Printable printable)
+  {
+    this.printable = printable;
+  }
+
+  /**
+   * Sets the <code>Printable</code> and the page format for the pages
+   * to be printed.
+   *
+   * @param printable The <code>Printable</code> for the print job.
+   * @param page_format The <code>PageFormat</code> for the print job.
+   */
+  public void setPrintable(Printable printable, PageFormat page_format)
+  {
+    this.printable = printable;
+    this.pageFormat = page_format;
+  }
+
+  /**
+   * Makes any alterations to the specified <code>PageFormat</code>
+   * necessary to make it work with the current printer.  The alterations
+   * are made to a clone of the input object, which is then returned.
+   *
+   * @param page_format The <code>PageFormat</code> to validate.
+   *
+   * @return The validated <code>PageFormat</code>.
+   */
+  public PageFormat validatePage(PageFormat page_format)
+  {
+    // FIXME
+    return page_format;
+  }
+
+  /**
+   * Change the printer for this print job to service.  Subclasses that
+   * support setting the print service override this method.  Throws
+   * PrinterException when the class doesn't support setting the printer,
+   * the service doesn't support Pageable or Printable interfaces for 2D
+   * print output.
+   * @param service The new printer to use.
+   * @throws PrinterException if service is not valid.
+   */
+  public void setPrintService(PrintService service)
+    throws PrinterException
+  {
+    if(!service.isDocFlavorSupported(DocFlavor.INPUT_STREAM.POSTSCRIPT))
+      throw new PrinterException("This printer service is not supported.");
+    printer = service;
+  }
+}
diff --git a/libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java b/libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java
new file mode 100644
index 000000000000..2303f44b7def
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/print/PostScriptGraphics2D.java
@@ -0,0 +1,1349 @@
+/* PostScriptGraphics2D.java -- AWT printer rendering class.
+   Copyright (C) 2006  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 gnu.java.awt.print;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Paint;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.font.TextLayout;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.renderable.RenderableImage;
+import java.awt.image.RenderedImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.PixelGrabber;
+import java.awt.print.PageFormat;
+import java.awt.print.Pageable;
+import java.awt.print.Paper;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterGraphics;
+import java.awt.print.PrinterJob;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.text.AttributedCharacterIterator;
+import java.util.Map;
+
+/**
+ * Class PostScriptGraphics2D - Class that implements the Graphics2D object,
+ * writing the output to a PostScript or EPS file
+ *
+ * @author Sven de Marothy
+ *
+ */
+class PostScriptGraphics2D extends Graphics2D
+{
+  /**
+   * The associated printer job.
+   */
+  private PrinterJob printerJob;
+
+  /**
+   * Output file.
+   */
+  private PrintWriter out;
+
+  // Graphics data
+  private AffineTransform currentTransform = new AffineTransform();
+  private AffineTransform pageTransform;
+  private RenderingHints renderingHints;
+  private Paint currentPaint = null;
+  private Shape clipShape = null;
+  private Font currentFont = null;
+  private Color currentColor = Color.black;
+  private Color backgroundColor = Color.white;
+  private Stroke currentStroke = null;
+  private static Stroke ordinaryStroke = new BasicStroke(0.0f,
+                                                         BasicStroke.CAP_BUTT,
+                                                         BasicStroke.JOIN_MITER);
+  private float cx; // current drawing position
+  private float cy; // current drawing position
+  private boolean currentFontIsPS; // set if currentFont is one of the above
+
+  // settings
+  private double pageX = 595;
+  private double pageY = 842;
+  private double Y = pageY;
+  private boolean gradientOn = false;
+
+  /** 
+   * Constructor
+   *
+   */
+  public PostScriptGraphics2D( PrinterJob pg )
+  {
+    printerJob = pg;
+    // create transform objects
+    pageTransform = new AffineTransform();
+    currentTransform = new AffineTransform();
+
+    /*
+      Create Rendering hints
+      No text aliasing
+      Quality color and rendering
+      Bicubic interpolation
+      Fractional metrics supported
+    */
+    renderingHints = new RenderingHints(null);
+    renderingHints.put(RenderingHints.KEY_RENDERING,
+                       RenderingHints.VALUE_RENDER_QUALITY);
+    renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING,
+                       RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
+    renderingHints.put(RenderingHints.KEY_INTERPOLATION,
+                       RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+    renderingHints.put(RenderingHints.KEY_FRACTIONALMETRICS,
+                       RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+    renderingHints.put(RenderingHints.KEY_COLOR_RENDERING,
+                       RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+  }
+
+  /**
+   * Spool a document to PostScript.
+   * If Pageable is non-null, it will print that, otherwise it will use
+   * the supplied printable and pageFormat.
+   */
+  public SpooledDocument spoolPostScript(Printable printable, 
+					 PageFormat pageFormat,
+					 Pageable pageable)
+    throws PrinterException
+  {
+    try 
+      {
+	// spool to a temporary file
+	File temp = File.createTempFile("cpspool", ".ps");
+	temp.deleteOnExit();
+	
+	out = new PrintWriter(new BufferedWriter
+			      (new OutputStreamWriter
+			       (new FileOutputStream(temp), 
+				"ISO8859_1"), 1000000));
+	
+	writePSHeader();
+	
+	if(pageable != null)
+	  {
+	    for(int index = 0; index < pageable.getNumberOfPages(); index++)
+	      spoolPage(out, pageable.getPrintable(index),
+			pageable.getPageFormat(index), index);
+	  }
+	else
+	  {
+	    int index = 0;
+	    while(spoolPage(out, printable, pageFormat, index++) ==
+		  Printable.PAGE_EXISTS);
+	  }
+	out.println("%%Trailer");
+	out.println("%%EOF");
+	out.close();
+	return new SpooledDocument( temp );
+      } 
+    catch (IOException e) 
+      {
+	PrinterException pe = new PrinterException();
+	pe.initCause(e);
+	throw pe;
+      }
+  }
+
+  //--------------------------------------------------------------------------
+
+  /** 
+   * Write the postscript file header,
+   * setup the page format and transforms. 
+   */
+  private void writePSHeader()
+  {
+    out.println("%!PS-Adobe-3.0");      
+    out.println("%%Title: "+printerJob.getJobName());
+    out.println("%%Creator: GNU Classpath ");
+    out.println("%%DocumentData: Clean8Bit");
+
+    out.println("%%DocumentNeededResources: font Times-Roman Helvetica Courier");
+    out.println("%%EndComments");
+    
+    out.println("%%BeginProlog");
+    out.println("%%EndProlog");
+    out.println("%%BeginSetup");
+    
+    out.println("%%EndFeature");
+    setupFonts();
+    out.println("%%EndSetup");
+ 
+    // set default fonts and colors
+    setFont( new Font("Dialog", Font.PLAIN, 12) );
+    currentColor = Color.white;
+    currentStroke = new BasicStroke();
+    setPaint(currentColor);
+    setStroke(currentStroke);
+  }
+
+  /**
+   * setupFonts - set up the font dictionaries for
+   * helvetica, times and courier
+   */
+  private void setupFonts()
+  {
+    out.println("/helveticaISO");
+    out.println("/Helvetica findfont dup length dict begin");
+    out.println("{ 1 index /FID eq { pop pop } { def } ifelse } forall");
+    out.println("/Encoding ISOLatin1Encoding def");
+    out.println("currentdict end definefont pop");
+
+    out.println("/timesISO");
+    out.println("/Times-Roman findfont dup length dict begin");
+    out.println("{ 1 index /FID eq { pop pop } { def } ifelse } forall");
+    out.println("/Encoding ISOLatin1Encoding def");
+    out.println("currentdict end definefont pop");
+
+    out.println("/courierISO");
+    out.println("/Courier findfont dup length dict begin");
+    out.println("{ 1 index /FID eq { pop pop } { def } ifelse } forall");
+    out.println("/Encoding ISOLatin1Encoding def");
+    out.println("currentdict end definefont pop");
+  }
+
+  /**
+   * Spools a single page, returns NO_SUCH_PAGE unsuccessful,
+   * PAGE_EXISTS if it was.
+   */
+  public int spoolPage(PrintWriter out,
+		       Printable printable, 
+		       PageFormat pageFormat, 
+		       int index) throws IOException, PrinterException
+  {
+    out.println("%%BeginPageSetup");
+
+    Paper p = pageFormat.getPaper();
+    pageX = p.getWidth();
+    pageY = p.getHeight();
+
+    if( pageFormat.getOrientation() == PageFormat.PORTRAIT )
+      out.println( "%%Orientation: Portrait" );
+    else
+      {
+	out.println( "%%Orientation: Landscape" );
+	double t = pageX;
+	pageX = pageY;
+	pageY = t;
+      }
+      
+    setClip(0, 0, (int)pageX, (int)pageY);
+
+    out.println("gsave % first save");
+    
+    // 595x842; 612x792 respectively
+    out.println("<< /PageSize [" +pageX + " "+pageY+ "] >> setpagedevice");
+
+    if( pageFormat.getOrientation() != PageFormat.LANDSCAPE )
+      {
+	pageTransform.translate(pageX, 0);
+	pageTransform.scale(-1.0, 1.0);
+      }
+
+    // save the original CTM
+    pushCTM();
+    concatCTM(pageTransform);
+    setTransform(new AffineTransform());
+
+    out.println("%%EndPageSetup");
+
+    out.println("gsave");
+
+    if( printable.print(this, pageFormat, index) == Printable.NO_SUCH_PAGE )
+      return Printable.NO_SUCH_PAGE;
+    
+    out.println("grestore");
+    out.println("showpage");
+
+    return Printable.PAGE_EXISTS;
+  }
+
+  /** push the Current Transformation Matrix onto the PS stack */
+  private void pushCTM()
+  {
+    out.println("matrix currentmatrix   % pushCTM()");
+  }
+
+  /** pop the Current Transformation Matrix from the PS stack */
+  private void popCTM()
+  {
+    out.println("setmatrix % restore CTM");
+  }
+
+  ///////////////////////////////////////////////////////////////////////////
+
+  public Graphics create()
+  {
+    return null;
+  }
+
+  public void drawOval(int x, int y, int width, int height)
+  {
+    out.println("% drawOval()");
+    setStroke(ordinaryStroke);
+    draw(new Ellipse2D.Double(x, y, width, height));
+    setStroke(currentStroke);
+  }
+
+  public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
+  {
+    if (nPoints <= 0 || xPoints.length < nPoints || yPoints.length < nPoints)
+      return;
+    out.println("newpath % drawPolyLine()");
+    out.println(xPoints[0] + " " + yPoints[0] + " moveto");
+    for (int i = 1; i < nPoints; i++)
+      out.println(xPoints[i] + " " + yPoints[i] + " lineto");
+    out.println("closepath");
+    out.println("stroke");
+  }
+
+  public void drawRoundRect(int x, int y, int width, int height, int arcWidth,
+                            int arcHeight)
+  {
+    out.println("% drawRoundRect()");
+    RoundRectangle2D.Double rr = new RoundRectangle2D.Double(x, y, width,
+                                                             height, arcWidth,
+                                                             arcHeight);
+    setStroke(ordinaryStroke);
+    draw(rr);
+    setStroke(currentStroke);
+  }
+
+  public void fillRoundRect(int x, int y, int width, int height, int arcWidth,
+                            int arcHeight)
+  {
+    out.println("% fillRoundRect()");
+    RoundRectangle2D.Double rr = new RoundRectangle2D.Double(x, y, width,
+                                                             height, arcWidth,
+                                                             arcHeight);
+    fill(rr);
+  }
+
+  public void drawArc(int x, int y, int width, int height, int startAngle,
+                      int arcAngle)
+  {
+    setStroke(ordinaryStroke);
+    draw(new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.OPEN));
+    setStroke(currentStroke);
+  }
+
+  public void fillArc(int x, int y, int width, int height, int startAngle,
+                      int arcAngle)
+  {
+    fill(new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.PIE));
+  }
+
+  public void fillOval(int x, int y, int width, int height)
+  {
+    out.println("% fillOval()");
+    fill( new Ellipse2D.Double(x, y, width, height) );
+  }
+
+  public void fillPolygon(int[] x, int[] y, int nPoints)
+  {
+    out.println("% fillPolygon()");
+    fill( new Polygon(x, y, nPoints) );
+  }
+
+  public void drawLine(int x1, int y1, int x2, int y2)
+  {
+    out.println("% drawLine()");
+    setStroke(ordinaryStroke);
+    out.println("newpath");
+    out.println(x1 + " " + (y1) + " moveto");
+    out.println(x2 + " " + (y2) + " lineto");
+    out.println("stroke");
+    setStroke(currentStroke);
+  }
+
+  //--------------- Image drawing ------------------------------------------   
+  public boolean drawImage(Image img, int x, int y, Color bgcolor,
+                           ImageObserver observer)
+  {
+    int w = img.getWidth(null);
+    int h = img.getHeight(null);
+
+    return drawImage(img, x, y, x + w, y + h, 0, 0, w - 1, h - 1, bgcolor,
+		     observer);
+  }
+
+  public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
+                           int sx1, int sy1, int sx2, int sy2, Color bgcolor,
+                           ImageObserver observer)
+  {
+    int n = 0;
+    boolean flipx = false;
+    boolean flipy = false;
+
+    // swap X and Y's
+    if (sx1 > sx2)
+      {
+	n = sx1;
+	sx1 = sx2;
+	sx2 = n;
+	flipx = ! flipx;
+      }
+    if (sy1 > sy2)
+      {
+	n = sy1;
+	sy1 = sy2;
+	sy2 = n;
+	flipy = ! flipy;
+      }
+    if (dx1 > dx2)
+      {
+	n = dx1;
+	dx1 = dx2;
+	dx2 = n;
+	flipx = ! flipx;
+      }
+    if (dy1 > dy2)
+      {
+	n = dy1;
+	dy1 = dy2;
+	dy2 = n;
+	flipy = ! flipy;
+      }
+    n = 0;
+    int sw = sx2 - sx1; // source width
+    int sh = sy2 - sy1; // source height
+    int[] pixels = new int[sw * sh]; // pixel buffer
+    int dw = dx2 - dx1; // destination width
+    int dh = dy2 - dy1; // destination height
+    double x_scale = ((double) dw) / ((double) sw);
+    double y_scale = ((double) dh) / ((double) sh);
+
+    out.println("% drawImage() 2");
+    out.println("gsave");
+    out.println(dx1 + " " + dy1 + " translate");
+    out.println(dw + " " + dh + " scale");
+    out.println(sw + " " + sh + " 8 [" + (flipx ? -sw : sw) + " 0 0 "
+                + (flipy ? -sh : sh) + " " + (flipx ? sw : 0) + " "
+                + (flipy ? sh : 0) + " ]");
+    out.println("{currentfile 3 string readhexstring pop} bind");
+    out.println("false 3 colorimage");
+
+    PixelGrabber pg = new PixelGrabber(img, sx1, sy1, sw, sh, pixels, 0, sw);
+    try
+      {
+	pg.grabPixels();
+      }
+    catch (InterruptedException e)
+      {
+	System.err.println("interrupted waiting for pixels!");
+	return (false);
+      }
+
+    if ((pg.getStatus() & ImageObserver.ABORT) != 0)
+      {
+	System.err.println("image fetch aborted or errored");
+	return (false);
+      }
+
+    for (int j = 0; j < sh; j++)
+      {
+	for (int i = 0; i < sw; i++)
+	  {
+	    out.print(colorTripleHex(new Color(pixels[j * sw + i])));
+	    if (((++n) % 11) == 0)
+	      out.println();
+	  }
+      }
+
+    out.println();
+    out.println("%%EOF");
+    out.println("grestore");
+    return true;
+  }
+
+  public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2,
+                           int sx1, int sy1, int sx2, int sy2,
+                           ImageObserver observer)
+  {
+    return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null,
+		     observer);
+  }
+
+  public boolean drawImage(Image img, int x, int y, ImageObserver observer)
+  {
+    return drawImage(img, x, y, null, observer);
+  }
+
+  public boolean drawImage(Image img, int x, int y, int width, int height,
+			   Color bgcolor, ImageObserver observer)
+  {
+    int sw = img.getWidth(null);
+    int sh = img.getHeight(null);
+    return drawImage(img, x, y, x + width, y + height, /* destination */
+		     0, 0, sw - 1, sh - 1, /* source */
+		     bgcolor, observer);
+    // correct?
+  }
+
+  public boolean drawImage(Image img, int x, int y, int width, int height,
+			   ImageObserver observer)
+  {
+    return drawImage(img, x, y, width, height, null, observer);
+  }
+
+  /** Renders a BufferedImage that is filtered with a BufferedImageOp. */
+  public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
+  {
+    BufferedImage result = op.filter(img, null);
+    drawImage(result, x, y, null);
+  }
+
+  /** Renders an image, applying a transform from image space
+      into user space before drawing. */
+  public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
+  {
+    AffineTransform oldTransform = new AffineTransform(currentTransform);
+    boolean ret;
+
+    transform(xform);
+    ret = drawImage(img, 0, 0, null, obs);
+    setTransform(oldTransform);
+
+    return ret;
+  }
+
+  /** Renders a RenderableImage, applying a transform from image
+      space into user space before drawing. */
+  public void drawRenderableImage(RenderableImage img, AffineTransform xform)
+  {
+    // FIXME
+  }
+
+  /** Renders a RenderedImage, applying a transform from
+      image space into user space before drawing. */
+  public void drawRenderedImage(RenderedImage img, AffineTransform xform)
+  {
+    // FIXME
+  }
+
+  //-------------------------------------------------------------------------
+  public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
+  {
+    setStroke(ordinaryStroke);
+    draw(new Polygon(xPoints, yPoints, nPoints));
+    setStroke(currentStroke);
+  }
+
+  public void drawString(String str, int x, int y)
+  {
+    drawString(str, (float) x, (float) y);
+  }
+
+  public void drawString(String str, float x, float y)
+  {
+    if( str.trim().equals("") )
+      return; // don't draw whitespace, silly!
+
+    if( currentFontIsPS )
+      {
+	drawStringPSFont(str, x, y);
+	return;
+      }
+
+    TextLayout text = new TextLayout(str, currentFont, getFontRenderContext());
+    Shape s = text.getOutline(AffineTransform.getTranslateInstance(x, y));
+    drawStringShape(s);
+  }
+
+  private void drawStringPSFont(String str, float x, float y)
+  {
+    out.println("% drawString PS font");
+    out.println(x + " " + y + " moveto");
+    saveAndInvertAxis();
+    out.println("(" + str + ") show");
+    restoreAxis();
+  }
+
+  private void saveAndInvertAxis()
+  {
+    // Invert the Y axis of the CTM.
+    popCTM();
+    pushCTM();
+
+    double[] test = 
+      {
+	pageTransform.getScaleX(), pageTransform.getShearY(),
+	pageTransform.getShearX(), pageTransform.getScaleY(),
+	pageTransform.getTranslateX(),
+	-pageTransform.getTranslateY() + pageY
+      };
+
+    double[] test2 = 
+      {
+	currentTransform.getScaleX(),
+	currentTransform.getShearY(),
+	-currentTransform.getShearX(),
+	-currentTransform.getScaleY(),
+	currentTransform.getTranslateX(),
+	currentTransform.getTranslateY()
+      };
+
+    AffineTransform total = new AffineTransform(test);
+    total.concatenate(new AffineTransform(test2));
+    concatCTM(total);
+  }
+
+  private void restoreAxis()
+  {
+    // reset the CTM
+    popCTM();
+    pushCTM();
+    AffineTransform total = new AffineTransform(pageTransform);
+    total.concatenate(currentTransform);
+    concatCTM(total);
+  }
+
+  /**
+   * special drawing routine for string shapes,
+   * which need to be drawn with the Y axis uninverted.
+   */
+  private void drawStringShape(Shape s)
+  {
+    saveAndInvertAxis();
+
+    // draw the shape s with an inverted Y axis.
+    PathIterator pi = s.getPathIterator(new AffineTransform());
+    float[] coords = new float[6];
+
+    while (! pi.isDone())
+      {
+	switch (pi.currentSegment(coords))
+	  {
+	  case PathIterator.SEG_MOVETO:
+	    out.println((coords[0]) + " " + (Y - coords[1]) + " moveto");
+	    cx = coords[0];
+	    cy = coords[1];
+	    break;
+	  case PathIterator.SEG_LINETO:
+	    out.println((coords[0]) + " " + (Y - coords[1]) + " lineto");
+	    cx = coords[0];
+	    cy = coords[1];
+	    break;
+	  case PathIterator.SEG_QUADTO:
+	    // convert to cubic bezier points
+	    float x1 = (cx + 2 * coords[0]) / 3;
+	    float y1 = (cy + 2 * coords[1]) / 3;
+	    float x2 = (2 * coords[2] + coords[0]) / 3;
+	    float y2 = (2 * coords[3] + coords[1]) / 3;
+
+	    out.print((x1) + " " + (Y - y1) + " ");
+	    out.print((x2) + " " + (Y - y2) + " ");
+	    out.println((coords[2]) + " " + (Y - coords[3]) + " curveto");
+	    cx = coords[2];
+	    cy = coords[3];
+	    break;
+	  case PathIterator.SEG_CUBICTO:
+	    out.print((coords[0]) + " " + (Y - coords[1]) + " ");
+	    out.print((coords[2]) + " " + (Y - coords[3]) + " ");
+	    out.println((coords[4]) + " " + (Y - coords[5]) + " curveto");
+	    cx = coords[4];
+	    cy = coords[5];
+	    break;
+	  case PathIterator.SEG_CLOSE:
+	    out.println("closepath");
+	    break;
+	  }
+	pi.next();
+      }
+    out.println("fill");
+
+    restoreAxis();
+  }
+
+  public void setColor(Color c)
+  {
+    /* don't set the color if it's already set */
+    if (c.equals(currentColor))
+      return;
+    gradientOn = false;
+    currentColor = c;
+    currentPaint = c; // Graphics2D extends colors to paint
+
+    out.println(colorTriple(c) + " setrgbcolor");
+  }
+
+  public void clearRect(int x, int y, int width, int height)
+  {
+    out.println("% clearRect");
+    Color c = currentColor;
+    setColor(backgroundColor);
+    fill(new Rectangle2D.Double(x, y, width, height));
+    setColor(c);
+  }
+
+  public void clipRect(int x, int y, int width, int height)
+  {
+    clip(new Rectangle2D.Double(x, y, width, height));
+  }
+
+  public void copyArea(int x, int y, int width, int height, int dx, int dy)
+  {
+    // FIXME
+  }
+
+  public void fillRect(int x, int y, int width, int height)
+  {
+    fill(new Rectangle2D.Double(x, y, width, height));
+  }
+
+  public void dispose()
+  {
+  }
+
+  public void setClip(int x, int y, int width, int height)
+  {
+    out.println("% setClip()");
+    setClip(new Rectangle2D.Double(x, y, width, height));
+  }
+
+  public void setClip(Shape s)
+  {
+    clip(s);
+  }
+
+  public Shape getClip()
+  {
+    return clipShape;
+  }
+
+  public Rectangle getClipBounds()
+  {
+    return clipShape.getBounds();
+  }
+
+  public Color getColor()
+  {
+    return currentColor;
+  }
+
+  public Font getFont()
+  {
+    return currentFont;
+  }
+
+  public FontMetrics getFontMetrics()
+  {
+    return getFontMetrics(currentFont);
+  }
+
+  public FontMetrics getFontMetrics(Font f)
+  {
+    // FIXME
+    return null;
+  }
+
+  public void setFont(Font font)
+  {
+    out.println("% setfont()");
+    if (font == null)
+      // use the default font
+      font = new Font("Dialog", Font.PLAIN, 12);
+    currentFont = font;
+    setPSFont(); // set up the PostScript fonts
+  }
+
+  /**
+   * Setup the postscript font if the current font is one
+   */
+  private void setPSFont()
+  {
+    currentFontIsPS = false;
+
+    String s = currentFont.getName();
+    out.println("% setPSFont: Fontname: " + s);
+    if (s.equalsIgnoreCase("Helvetica") || s.equalsIgnoreCase("SansSerif"))
+      out.print("/helveticaISO findfont ");
+    else if (s.equalsIgnoreCase("Times New Roman"))
+      out.print("/timesISO findfont ");
+    else if (s.equalsIgnoreCase("Courier"))
+      out.print("/courierISO findfont ");
+    else
+      return;
+
+    currentFontIsPS = true;
+
+    out.print(currentFont.getSize() + " scalefont ");
+    out.println("setfont");
+  }
+
+  /** XOR mode is not supported */
+  public void setPaintMode()
+  {
+  }
+
+  /** XOR mode is not supported */
+  public void setXORMode(Color c1)
+  {
+  }
+
+  public void close()
+  {
+    out.println("showpage");
+    out.println("%%Trailer");
+    out.println("grestore % restore original stuff");
+    out.println("%%EOF");
+
+    try
+      {
+	out.close();
+      }
+    catch (Exception e)
+      {
+      }
+    out = null;
+  }
+
+  //----------------------------------------------------------------
+  // Graphics2D stuff ----------------------------------------------
+
+  /**  Sets the values of an arbitrary number of
+       preferences for the rendering algorithms. */
+  public void addRenderingHints(Map hints)
+  {
+    /* rendering hint changes are disallowed */
+  }
+
+  /** write a shape to the file */
+  private void writeShape(Shape s)
+  {
+    PathIterator pi = s.getPathIterator(new AffineTransform());
+    float[] coords = new float[6];
+
+    while (! pi.isDone())
+      {
+	switch (pi.currentSegment(coords))
+	  {
+	  case PathIterator.SEG_MOVETO:
+	    out.println(coords[0] + " " + (coords[1]) + " moveto");
+	    cx = coords[0];
+	    cy = coords[1];
+	    break;
+	  case PathIterator.SEG_LINETO:
+	    out.println(coords[0] + " " + (coords[1]) + " lineto");
+	    cx = coords[0];
+	    cy = coords[1];
+	    break;
+	  case PathIterator.SEG_QUADTO:
+	    // convert to cubic bezier points
+	    float x1 = (cx + 2 * coords[0]) / 3;
+	    float y1 = (cy + 2 * coords[1]) / 3;
+	    float x2 = (2 * coords[2] + coords[0]) / 3;
+	    float y2 = (2 * coords[3] + coords[1]) / 3;
+
+	    out.print(x1 + " " + (Y - y1) + " ");
+	    out.print(x2 + " " + (Y - y2) + " ");
+	    out.println(coords[2] + " " + (Y - coords[3]) + " curveto");
+	    cx = coords[2];
+	    cy = coords[3];
+	    break;
+	  case PathIterator.SEG_CUBICTO:
+	    out.print(coords[0] + " " + coords[1] + " ");
+	    out.print(coords[2] + " " + coords[3] + " ");
+	    out.println(coords[4] + " " + coords[5] + " curveto");
+	    cx = coords[4];
+	    cy = coords[5];
+	    break;
+	  case PathIterator.SEG_CLOSE:
+	    out.println("closepath");
+	    break;
+	  }
+	pi.next();
+      }
+  }
+
+  /** Intersects the current Clip with the interior of
+      the specified Shape and sets the Clip to the resulting intersection. */
+  public void clip(Shape s)
+  {
+    clipShape = s;
+    out.println("% clip INACTIVE");
+    //	writeShape(s);
+    //	out.println("clip");
+  }
+
+  /** Strokes the outline of a Shape using the
+      settings of the current Graphics2D context.*/
+  public void draw(Shape s)
+  {
+    if(!(currentStroke instanceof BasicStroke))
+      fill(currentStroke.createStrokedShape(s));
+
+    out.println("% draw");
+    writeShape(s);
+    out.println("stroke");
+  }
+
+  /** Renders the text of the specified GlyphVector using the
+      Graphics2D context's rendering attributes. */
+  public void drawGlyphVector(GlyphVector gv, float x, float y)
+  {
+    out.println("% drawGlyphVector");
+    Shape s = gv.getOutline();
+    drawStringShape(AffineTransform.getTranslateInstance(x, y)
+		    .createTransformedShape(s));
+  }
+
+  /** Renders the text of the specified iterator,
+      using the Graphics2D context's current Paint.*/
+  public void drawString(AttributedCharacterIterator iterator, float x, float y)
+  {
+    TextLayout text = new TextLayout(iterator, getFontRenderContext());
+    Shape s = text.getOutline(AffineTransform.getTranslateInstance(x, y));
+    drawStringShape(s);
+  }
+
+  /** Renders the text of the specified iterator,
+      using the Graphics2D context's current Paint. */
+  public void drawString(AttributedCharacterIterator iterator, int x, int y)
+  {
+    drawString(iterator, (float) x, (float) y);
+  }
+
+  /** Fills the interior of a Shape using the settings of the Graphics2D context. */
+  public void fill(Shape s)
+  {
+    out.println("% fill");
+    if (! gradientOn)
+      {
+	writeShape(s);
+	out.println("fill");
+      }
+    else
+      {
+	out.println("gsave");
+	writeShape(s);
+	out.println("clip");
+	writeGradient();
+	out.println("shfill");
+	out.println("grestore");
+      }
+  }
+
+  /** Returns the background color used for clearing a region. */
+  public Color getBackground()
+  {
+    return backgroundColor;
+  }
+
+  /** Returns the current Composite in the Graphics2D context. */
+  public Composite getComposite()
+  {
+    // FIXME
+    return null;
+  }
+
+  /** Returns the device configuration associated with this Graphics2D. */
+  public GraphicsConfiguration getDeviceConfiguration()
+  {
+    // FIXME
+    out.println("% getDeviceConfiguration()");
+    return null;
+  }
+
+  /** Get the rendering context of the Font within this Graphics2D context. */
+  public FontRenderContext getFontRenderContext()
+  {
+    out.println("% getFontRenderContext()");
+
+    double[] scaling = 
+      {
+	pageTransform.getScaleX(), 0, 0,
+	-pageTransform.getScaleY(), 0, 0
+      };
+
+    return (new FontRenderContext(new AffineTransform(scaling), false, true));
+  }
+
+  /** Returns the current Paint of the Graphics2D context. */
+  public Paint getPaint()
+  {
+    return currentPaint;
+  }
+
+  /** Returns the value of a single preference for the rendering algorithms. */
+  public Object getRenderingHint(RenderingHints.Key hintKey)
+  {
+    return renderingHints.get(hintKey);
+  }
+
+  /** Gets the preferences for the rendering algorithms. */
+  public RenderingHints getRenderingHints()
+  {
+    return renderingHints;
+  }
+
+  /** Returns the current Stroke in the Graphics2D context. */
+  public Stroke getStroke()
+  {
+    return currentStroke;
+  }
+
+  /** Returns a copy of the current Transform in the Graphics2D context. */
+  public AffineTransform getTransform()
+  {
+    return currentTransform;
+  }
+
+  /** 
+   * Checks whether or not the specified Shape intersects 
+   * the specified Rectangle, which is in device space. 
+   */
+  public boolean hit(Rectangle rect, Shape s, boolean onStroke)
+  {
+    Rectangle2D.Double r = new Rectangle2D.Double(rect.getX(), rect.getY(),
+						  rect.getWidth(),
+						  rect.getHeight());
+    return s.intersects(r);
+  }
+
+  /** Sets the background color for the Graphics2D context.*/
+  public void setBackground(Color color)
+  {
+    out.println("% setBackground(" + color + ")");
+    backgroundColor = color;
+  }
+
+  /** Sets the Composite for the Graphics2D context.
+      Not supported. */
+  public void setComposite(Composite comp)
+  {
+  }
+
+  /** Sets the Paint attribute for the Graphics2D context.*/
+  public void setPaint(Paint paint)
+  {
+    currentPaint = paint;
+    gradientOn = false;
+    if (paint instanceof Color)
+      {
+	setColor((Color) paint);
+	return;
+      }
+    if (paint instanceof GradientPaint)
+      {
+	gradientOn = true;
+	return;
+      }
+  }
+
+  /* get a space seperated 0.0 - 1.0 color RGB triple */
+  private String colorTriple(Color c)
+  {
+    return (((double) c.getRed() / 255.0) + " "
+	    + ((double) c.getGreen() / 255.0) + " "
+	    + ((double) c.getBlue() / 255.0));
+  }
+
+  /**
+   * Get a nonsperated hex RGB triple, eg FFFFFF = white
+   * used by writeGradient and drawImage 
+   */
+  private String colorTripleHex(Color c)
+  {
+    String r = "00" + Integer.toHexString(c.getRed());
+    r = r.substring(r.length() - 2);
+    String g = "00" + Integer.toHexString(c.getGreen());
+    g = g.substring(g.length() - 2);
+    String b = "00" + Integer.toHexString(c.getBlue());
+    b = b.substring(b.length() - 2);
+    return r + g + b;
+  }
+
+  /* write the current gradient fill */
+  private void writeGradient()
+  {
+    GradientPaint paint = (GradientPaint) currentPaint;
+    out.println("% writeGradient()");
+
+    int n = 1;
+    double x;
+    double y;
+    double dx;
+    double dy;
+    Point2D p1 = currentTransform.transform(paint.getPoint1(), null);
+    Point2D p2 = currentTransform.transform(paint.getPoint2(), null);
+    x = p1.getX();
+    y = p1.getY();
+    dx = p2.getX() - x;
+    dy = p2.getY() - y;
+
+    // get number of repetitions
+    while (x + n * dx < pageY && y + n * dy < pageX && x + n * dx > 0
+	   && y + n * dy > 0)
+      n++;
+
+    out.println("<<"); // start
+    out.println("/ShadingType 2"); // gradient fill 
+    out.println("/ColorSpace [ /DeviceRGB ]"); // RGB colors
+    out.print("/Coords [");
+    out.print(x + " " + y + " " + (x + n * dx) + " " + (y + n * dy) + " ");
+    out.println("]"); // coordinates defining the axis
+    out.println("/Function <<");
+    out.println("/FunctionType 0");
+    out.println("/Order 1");
+    out.println("/Domain [ 0 1 ]");
+    out.println("/Range [ 0 1  0 1  0 1 ]");
+    out.println("/BitsPerSample 8");
+    out.println("/Size [ " + (1 + n) + " ]");
+    out.print("/DataSource < " + colorTripleHex(paint.getColor1()) + " "
+	      + colorTripleHex(paint.getColor2()) + " ");
+    for (; n > 1; n--)
+      if (paint.isCyclic())
+	{
+	  if ((n % 2) == 1)
+	    out.print(colorTripleHex(paint.getColor1()) + " ");
+	  else
+	    out.print(colorTripleHex(paint.getColor2()) + " ");
+	}
+      else
+	out.print(colorTripleHex(paint.getColor2()) + " ");
+    out.println(">");
+    out.println(">>");
+    out.println(">>");
+  }
+
+  /** Sets the value of a single preference for the rendering algorithms. */
+  public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
+  {
+    /* we don't allow the changing of rendering hints. */
+  }
+
+  /** Replaces the values of all preferences for the rendering algorithms
+      with the specified hints. */
+  public void setRenderingHints(Map hints)
+  {
+    /* we don't allow the changing of rendering hints. */
+  }
+
+  /** 
+   * Sets the Stroke for the Graphics2D context. BasicStroke fully implemented.
+   */
+  public void setStroke(Stroke s)
+  {
+    currentStroke = s;
+
+    if (! (s instanceof BasicStroke))
+      return;
+
+    BasicStroke bs = (BasicStroke) s;
+    out.println("% setStroke()");
+    try
+      {
+	// set the line width
+	out.println(bs.getLineWidth() + " setlinewidth");
+
+	// set the line dash
+	float[] dashArray = bs.getDashArray();
+	if (dashArray != null)
+	  {
+	    out.print("[ ");
+	    for (int i = 0; i < dashArray.length; i++)
+	      out.print(dashArray[i] + " ");
+	    out.println("] " + bs.getDashPhase() + " setdash");
+	  }
+	else
+	  out.println("[] 0 setdash"); // set solid
+
+	// set the line cap
+	switch (bs.getEndCap())
+	  {
+	  case BasicStroke.CAP_BUTT:
+	    out.println("0 setlinecap");
+	    break;
+	  case BasicStroke.CAP_ROUND:
+	    out.println("1 setlinecap");
+	    break;
+	  case BasicStroke.CAP_SQUARE:
+	    out.println("2 setlinecap");
+	    break;
+	  }
+
+	// set the line join
+	switch (bs.getLineJoin())
+	  {
+	  case BasicStroke.JOIN_BEVEL:
+	    out.println("2 setlinejoin");
+	    break;
+	  case BasicStroke.JOIN_MITER:
+	    out.println("0 setlinejoin");
+	    out.println(bs.getMiterLimit() + " setmiterlimit");
+	    break;
+	  case BasicStroke.JOIN_ROUND:
+	    out.println("1 setlinejoin");
+	    break;
+	  }
+      }
+    catch (Exception e)
+      {
+	out.println("% Exception in setStroke()");
+      }
+  }
+
+  //////////////////// TRANSFORM SETTING /////////////////////////////////////
+  private void concatCTM(AffineTransform Tx)
+  {
+    double[] matrixElements = new double[6];
+    Tx.getMatrix(matrixElements);
+
+    out.print("[ ");
+    for (int i = 0; i < 6; i++)
+      out.print(matrixElements[i] + " ");
+    out.println("] concat");
+  }
+
+  /** Sets the Transform in the Graphics2D context. */
+  public void setTransform(AffineTransform Tx)
+  {
+    // set the transformation matrix;
+    currentTransform = Tx;
+
+    // concatenate the current transform and the page transform
+    AffineTransform totalTransform = new AffineTransform(pageTransform);
+    totalTransform.concatenate(currentTransform);
+    out.println("% setTransform()");
+    out.println("% pageTransform:" + pageTransform);
+    out.println("% currentTransform:" + currentTransform);
+    out.println("% totalTransform:" + totalTransform);
+
+    popCTM();
+    pushCTM(); // set the CTM to it's original state
+    concatCTM(totalTransform); // apply our transforms
+  }
+
+  /** Composes an AffineTransform object with the Transform
+      in this Graphics2D according to the rule last-specified-first-applied. */
+  public void transform(AffineTransform Tx)
+  {
+    // concatenate the current transform
+    currentTransform.concatenate(Tx);
+    // and the PS CTM
+    concatCTM(Tx);
+  }
+
+  ////////////////////////// TRANSFORMS //////////////////////////////////////
+
+  /** shear transform */
+  public void shear(double shx, double shy)
+  {
+    out.println("% shear()");
+    AffineTransform Tx = new AffineTransform();
+    Tx.shear(shx, shy);
+    transform(Tx);
+  }
+
+  /** Translates the origin of the Graphics2D context
+      to the point (x, y) in the current coordinate system. */
+  public void translate(int x, int y)
+  {
+    out.println("% translate()");
+    AffineTransform Tx = new AffineTransform();
+    Tx.translate(x, y);
+    transform(Tx);
+  }
+
+  /** Translates the origin of the Graphics2D context
+      to the point (x, y) in the current coordinate system. */
+  public void translate(double x, double y)
+  {
+    out.println("% translate(" + x + ", " + y + ")");
+    AffineTransform Tx = new AffineTransform();
+    Tx.translate(x, y);
+    transform(Tx);
+  }
+
+  /** Concatenates the current Graphics2D Transform with a rotation transform.*/
+  public void rotate(double theta)
+  {
+    out.println("% rotate(" + theta + ")");
+    AffineTransform Tx = new AffineTransform();
+    Tx.rotate(theta);
+    transform(Tx);
+  }
+
+  /** Concatenates the current Graphics2D Transform with
+      a translated rotation transform.*/
+  public void rotate(double theta, double x, double y)
+  {
+    out.println("% rotate()");
+    AffineTransform Tx = new AffineTransform();
+    Tx.rotate(theta, x, y);
+    transform(Tx);
+  }
+
+  /** Concatenates the current Graphics2D Transform with a scaling
+      transformation Subsequent rendering is resized according to the
+      specified scaling factors relative to the previous scaling.*/
+  public void scale(double sx, double sy)
+  {
+    out.println("% scale(" + sx + ", " + sy + ")");
+    AffineTransform Tx = new AffineTransform();
+    Tx.scale(sx, sy);
+    transform(Tx);
+  }
+}
diff --git a/libjava/classpath/gnu/java/awt/print/SpooledDocument.java b/libjava/classpath/gnu/java/awt/print/SpooledDocument.java
new file mode 100644
index 000000000000..b606a2ef63ee
--- /dev/null
+++ b/libjava/classpath/gnu/java/awt/print/SpooledDocument.java
@@ -0,0 +1,91 @@
+/* SpooledDocument.java -- Reurgitate a spooled PostScript file
+   Copyright (C) 2006  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 gnu.java.awt.print;
+
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.attribute.DocAttributeSet;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.Reader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class SpooledDocument implements Doc
+{
+  private FileInputStream fis;
+
+  public SpooledDocument(File file)
+  {
+    try 
+      {
+	fis = new FileInputStream(file);
+      }
+    catch (FileNotFoundException ffne) 
+      {
+	// Shouldn't happen.
+      }
+  }
+
+  public DocAttributeSet getAttributes()
+  {
+    return null;
+  }
+
+  public DocFlavor getDocFlavor()
+  {
+    return DocFlavor.INPUT_STREAM.POSTSCRIPT;
+  }
+
+  public Object getPrintData()
+  {
+    return fis;
+  }
+  
+  public Reader getReaderForText()
+  {
+    return new InputStreamReader(fis);
+  }
+
+  public InputStream getStreamForBytes()
+  {
+    return fis;
+ }
+}
diff --git a/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java
new file mode 100644
index 000000000000..5f7309583ea0
--- /dev/null
+++ b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java
@@ -0,0 +1,192 @@
+/* CharacterAttributeTranslator.java -- 
+   Copyright (C) 2006  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 gnu.javax.swing.text.html;
+
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.html.HTML.Attribute;
+import javax.swing.text.html.HTML.Tag;
+
+/**
+ * This is a small utility class to translate HTML character attributes to
+ * Swing StyleConstants
+ */
+public class CharacterAttributeTranslator
+{
+  /**
+   * Maps color name to its hex encoding.
+   */
+  private static final HashMap colorMap = new HashMap();
+  static 
+  {
+    colorMap.put("aqua" , "#00FFFF");
+    colorMap.put("blue" , "#0000FF");
+    colorMap.put("black", "#000000");
+    colorMap.put("fuchsia" , "#FF00FF");
+    colorMap.put("gray" , "#808080");
+    colorMap.put("green" , "#008000");
+    colorMap.put("lime" , "#00FF00");
+    colorMap.put("maroon" , "#800000");
+    colorMap.put("navy" , "#000080");
+    colorMap.put("olive" , "#808000");
+    colorMap.put("purple" , "#800080");
+    colorMap.put("red" , "#FF0000");
+    colorMap.put("silver" , "#C0C0C0");
+    colorMap.put("teal" , "#008080");
+    colorMap.put("white" , "#FFFFFF");
+    colorMap.put("yellow" , "#FFFF00");
+  };
+  
+  /**
+   * Convert the color string represenation into java.awt.Color. The valid
+   * values are like "aqua" , "#00FFFF" or "rgb(1,6,44)".
+   * 
+   * @param colorName the color to convert.
+   * @return the matching java.awt.color
+   */
+  private static Color getColor(String colorName)
+  {
+    colorName = colorName.toLowerCase();
+    try
+      {
+        if (colorName.startsWith("rgb"))
+          {
+            // rgb(red, green, blue) notation.
+            StringTokenizer st = new StringTokenizer(colorName, " ,()");
+            String representation = st.nextToken();
+
+            // Return null if the representation is not supported.
+            if (! representation.equals("rgb"))
+              return null;
+            int red = Integer.parseInt(st.nextToken());
+            int green = Integer.parseInt(st.nextToken());
+            int blue = Integer.parseInt(st.nextToken());
+
+            return new Color(red, green, blue);
+          }
+        else
+          {
+            String s2 = (String) colorMap.get(colorName);
+            if (s2 == null)
+              s2 = colorName;
+            return Color.decode(s2);
+          }
+      }
+    catch (Exception nex)
+      {
+        // Can be either number format exception or illegal argument
+        // exception.
+        return null;
+      }
+  }
+  
+  /**
+   * Translate the HTML character attribute to the Swing style constant.
+   * 
+   * @param charAttr the character attributes of the html tag
+   * @param t the html tag itself
+   * @param a the attribute set where the translated attributes will be stored
+   * 
+   * @return true if some attributes were translated, false otherwise.
+   */
+  public static boolean translateTag(MutableAttributeSet charAttr, 
+				     Tag t, MutableAttributeSet a)
+  {
+    if(t == Tag.FONT)
+      {
+        Object color = a.getAttribute(Attribute.COLOR); 
+	if(color != null)
+	  {
+	    Color c = getColor(color.toString());
+	    if( c == null )
+	      return false;
+	    charAttr.addAttribute(StyleConstants.Foreground, c);
+	    return true;
+	  }
+
+	if(a.getAttribute(Attribute.SIZE) != null)
+	  {
+	    // FIXME
+	    //	    charAttr.addAttribute(StyleConstants.FontSize, 
+	    //				  new java.lang.Integer(72));
+	    return true;
+	  }
+      }
+
+    if( t == Tag.B )
+      {
+	charAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.I )
+      {
+	charAttr.addAttribute(StyleConstants.Italic, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.U )
+      {
+	charAttr.addAttribute(StyleConstants.Underline, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.STRIKE )
+      {
+	charAttr.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.SUP )
+      {
+	charAttr.addAttribute(StyleConstants.Superscript, Boolean.TRUE);
+	return true;
+      }
+
+    if( t == Tag.SUB )
+      {
+	charAttr.addAttribute(StyleConstants.Subscript, Boolean.TRUE);
+	return true;
+      }
+    return false;
+  }
+}
diff --git a/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java b/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java
new file mode 100644
index 000000000000..b1e3de604255
--- /dev/null
+++ b/libjava/classpath/gnu/javax/swing/text/html/CombinedAttributes.java
@@ -0,0 +1,213 @@
+/* CombinedAttributes.java -- A two combined sets of attributes
+   Copyright (C) 2006 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 gnu.javax.swing.text.html;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+
+/**
+ * Contains the two combined attribute sets what are searched subsequently.
+ * This is used to combine style sheet attributes with the HTML view attributes.
+ * The parent cannot be used as the view may have its own attribute hierarchy.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)  
+ */
+public class CombinedAttributes implements AttributeSet, Serializable
+{
+  /**
+   * Returns the elements from both enumerations.
+   */
+  class CombinedEnumeration implements Enumeration
+  {
+    /**
+     * Create a combined enumeration that enumerates over two enumerations.
+     * 
+     * @param first the first enumeration to enumerate
+     * @param second the second enumeration to enumerate
+     */
+    CombinedEnumeration(Enumeration first, Enumeration second)
+    {
+      a = first;
+      b = second;
+    }
+    
+    /**
+     * The first enumeration (elements returned first)
+     */
+    final Enumeration a;
+    
+    /**
+     * The second enumeration (elements returned later)
+     */
+    final Enumeration b;
+    
+    /** @inheritDoc */
+    public boolean hasMoreElements()
+    {
+      return a.hasMoreElements() || b.hasMoreElements();
+    }
+    
+    /** @inheritDoc */
+    public Object nextElement()
+    {
+      return a.hasMoreElements() ? a.nextElement():b.nextElement();
+    }
+  }
+  
+  
+  /**
+   * The first attribute set.
+   */
+  final AttributeSet a;
+  
+  /**
+   * The second attribute set.
+   */
+  final AttributeSet b;
+  
+  /**
+   * Create the CombinedAttributes what search in the two sets. If any of the
+   * two passed sets is null, another set is returned. Otherwise, the combined
+   * attribute set is returned.
+   * 
+   * @param primary the first set (searched first)
+   * @param secondary the second set (searched later).
+   */
+  public static AttributeSet combine(AttributeSet primary,
+                                     AttributeSet secondary)
+  {
+    if (primary == null)
+      return secondary;
+    else if (secondary == null)
+      return primary;
+    else
+      return new CombinedAttributes(primary, secondary);
+  }
+  
+  /**
+   * Create the CombinedAttributes what search in the two sets.
+   * 
+   * @param primary the first set (searched first)
+   * @param secondary the second set (searched later).
+   */
+  private CombinedAttributes(AttributeSet primary, AttributeSet secondary)
+  {
+    a = primary;
+    b = secondary;
+  }
+
+  /** @inheritDoc */
+  public boolean containsAttribute(Object name, Object value)
+  {
+    return a.containsAttribute(name, value) || b.containsAttribute(name, value);
+  }
+
+  /** @inheritDoc */
+  public boolean containsAttributes(AttributeSet attributes)
+  {
+    Enumeration names = attributes.getAttributeNames();
+    Object name;
+    while (names.hasMoreElements())
+      {
+        name = names.nextElement();
+        if (!containsAttribute(name, attributes.getAttribute(name)))
+          return false;
+      }
+    return true;
+  }
+
+  /** @inheritDoc */
+  public AttributeSet copyAttributes()
+  {
+    SimpleAttributeSet copy = new SimpleAttributeSet();
+    copy.addAttributes(a);
+    copy.addAttributes(b);
+    return copy;
+  }
+
+  /** @inheritDoc */
+  public Object getAttribute(Object key)
+  {
+    Object value = a.getAttribute(key);
+    if (value == null)
+      value = b.getAttribute(key);
+    
+    return value;
+  }
+
+  /** @inheritDoc */
+  public int getAttributeCount()
+  {
+    return a.getAttributeCount()+b.getAttributeCount();
+  }
+
+  /** @inheritDoc */
+  public Enumeration getAttributeNames()
+  {
+    return new CombinedEnumeration(a.getAttributeNames(), b.getAttributeNames());
+  }
+
+  /**
+   * There is no one.
+   * 
+   * @return null, always.
+   */
+  public AttributeSet getResolveParent()
+  {
+    return null;
+  }
+
+  /** @inheritDoc */
+  public boolean isDefined(Object attrName)
+  {
+    return a.isDefined(attrName) || b.isDefined(attrName);
+  }
+
+  /** @inheritDoc */
+  public boolean isEqual(AttributeSet attr)
+  {
+    if (attr.getAttributeCount() == getAttributeCount())
+      return containsAttributes(attr);
+    else
+      return false;
+  }
+}
diff --git a/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java b/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java
new file mode 100644
index 000000000000..862e690c9282
--- /dev/null
+++ b/libjava/classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java
@@ -0,0 +1,282 @@
+package gnu.javax.swing.text.html;
+
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * Creates icons for ImageView. The icons reflect the basic ideas of the Sun's
+ * icons as they would be described in the text (sheet of paper with image and
+ * broken sheet of paper with image). They are not pixel to pixel identical and
+ * contain elements from the metal icon factory.
+ * 
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class ImageViewIconFactory
+{
+  private static Icon noImageIcon;
+
+  private static Icon loadingImageIcon;
+  
+  /**
+   * This icon reflects the general concept (broken sheet of paper with
+   * image), but is currently not pixel to pixel identical with the Sun's 
+   * implementation.
+   */
+  public static class NoImageIcon implements Icon, Serializable
+  {
+    /**
+     * Creates a new icon.
+     */
+    public NoImageIcon()
+    {
+      // Nothing to do here.
+    }
+
+    /**
+     * Returns the width of the icon, in pixels.
+     * 
+     * @return The width of the icon.
+     */
+    public int getIconWidth()
+    {
+      return 38;
+    }
+
+    /**
+     * Returns the height of the icon, in pixels.
+     * 
+     * @return The height of the icon.
+     */
+    public int getIconHeight()
+    {
+      return 38;
+    }
+
+    /**
+     * Paints the icon using colors from the {@link MetalLookAndFeel}.
+     * 
+     * @param c
+     *          the component (ignored).
+     * @param g
+     *          the graphics device.
+     * @param x
+     *          the x-coordinate for the top-left of the icon.
+     * @param y
+     *          the y-coordinate for the top-left of the icon.
+     */
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+      // frame
+      Color savedColor = g.getColor();
+
+      g.setColor(MetalLookAndFeel.getBlack());
+
+      g.drawLine(x, y, x + 19, y);
+
+      g.drawLine(x, y + 1, x, y + 5);
+      g.drawLine(x, y + 13, x, y + 25);
+
+      g.drawLine(x, y + 25, x + 22, y + 25);
+
+      g.drawLine(x + 22, y + 25, x + 22, y + 21);
+      g.drawLine(x + 22, y + 13, x + 22, y + 6);
+
+      g.drawLine(x + 22, y + 6, x + 19, y);
+
+      g.drawLine(x + 17, y + 2, x + 21, y + 6);
+
+      g.drawLine(x + 18, y + 1, x + 19, y + 1);
+
+      g.setColor(MetalLookAndFeel.getControlShadow());
+
+      g.drawLine(x + 1, y + 1, x + 17, y + 1);
+
+      g.drawLine(x + 1, y + 1, x + 1, y + 5);
+      g.drawLine(x + 1, y + 13, x + 1, y + 24);
+
+      g.drawLine(x + 1, y + 24, x + 21, y + 24);
+
+      g.drawLine(x + 21, y + 24, x + 21, y + 21);
+      g.drawLine(x + 21, y + 13, x + 21, y + 7);
+
+      g.drawLine(x + 18, y + 2, x + 20, y + 4);
+
+      // Breaking line
+
+      // Shadow
+      g.drawLine(x + 1, y + 6, x + 20, y + 13);
+      g.drawLine(x + 1, y + 13, x + 20, y + 20);
+
+      // Edge
+      g.setColor(MetalLookAndFeel.getBlack());
+      g.drawLine(x, y + 6, x + 21, y + 14);
+      g.drawLine(x, y + 12, x + 21, y + 20);
+
+      // Picture
+
+      y += 1;
+      x += 3;
+
+      g.setColor(MetalLookAndFeel.getBlack());
+
+      // roof
+      g.drawLine(x + 4, y + 5, x + 8, y + 1);
+      g.drawLine(x + 8, y + 1, x + 15, y + 8);
+
+      // chimney
+      g.drawLine(x + 11, y + 2, x + 11, y + 4);
+      g.drawLine(x + 12, y + 2, x + 12, y + 5);
+
+      g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+      // roof paint
+      int xx = x + 8;
+      for (int i = 0; i < 4; i++)
+        g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i);
+      g.fillRect(x + 4, y + 6, 9, 2);
+
+      // base of house
+      g.drawLine(x + 3, y + 14, x + 3, y + 18);
+      g.drawLine(x + 3, y + 18, x + 13, y + 18);
+
+      g.setColor(savedColor);
+    }
+  }
+
+  /**
+   * This icon reflects the general concept (sheet of paper with image), but is
+   * currently not pixel to pixel identical with the Sun's implementation.
+   */
+  public static class LoadingImageIcon implements Icon, Serializable
+  {
+
+    /**
+     * Creates a new icon.
+     */
+    public LoadingImageIcon()
+    {
+      // Nothing to do here.
+    }
+
+    /**
+     * Returns the width of the icon, in pixels.
+     * 
+     * @return The width of the icon.
+     */
+    public int getIconWidth()
+    {
+      return 38;
+    }
+
+    /**
+     * Returns the height of the icon, in pixels.
+     * 
+     * @return The height of the icon.
+     */
+    public int getIconHeight()
+    {
+      return 38;
+    }
+
+    /**
+     * Paints the icon using colors from the {@link MetalLookAndFeel}.
+     * 
+     * @param c
+     *          the component (ignored).
+     * @param g
+     *          the graphics device.
+     * @param x
+     *          the x-coordinate for the top-left of the icon.
+     * @param y
+     *          the y-coordinate for the top-left of the icon.
+     */
+    public void paintIcon(Component c, Graphics g, int x, int y)
+    {
+      // frame
+      Color savedColor = g.getColor();
+
+      g.setColor(Color.black);
+      g.drawLine(x, y, x + 19, y);
+      g.drawLine(x, y + 1, x, y + 25);
+      g.drawLine(x, y + 25, x + 22, y + 25);
+      g.drawLine(x + 22, y + 25, x + 22, y + 6);
+      g.drawLine(x + 22, y + 6, x + 19, y);
+
+      g.drawLine(x + 17, y + 2, x + 21, y + 6);
+      g.drawLine(x + 18, y + 1, x + 19, y + 1);
+
+      g.setColor(new Color(204, 204, 255));
+
+      g.drawLine(x + 1, y + 1, x + 17, y + 1);
+      g.drawLine(x + 1, y + 1, x + 1, y + 24);
+      g.drawLine(x + 1, y + 24, x + 21, y + 24);
+      g.drawLine(x + 21, y + 24, x + 21, y + 7);
+      g.drawLine(x + 18, y + 2, x + 20, y + 4);
+
+      // Picture (house) 
+
+      y += 3;
+      x += 3;
+
+      g.setColor(MetalLookAndFeel.getBlack());
+
+      // roof
+      g.drawLine(x + 1, y + 8, x + 8, y + 1);
+      g.drawLine(x + 8, y + 1, x + 15, y + 8);
+
+      // base of house
+      g.drawLine(x + 3, y + 6, x + 3, y + 15);
+      g.drawLine(x + 3, y + 15, x + 13, y + 15);
+      g.drawLine(x + 13, y + 6, x + 13, y + 15);
+
+      // door frame
+      g.drawLine(x + 6, y + 9, x + 6, y + 15);
+      g.drawLine(x + 6, y + 9, x + 10, y + 9);
+      g.drawLine(x + 10, y + 9, x + 10, y + 15);
+
+      // chimney
+      g.drawLine(x + 11, y + 2, x + 11, y + 4);
+      g.drawLine(x + 12, y + 2, x + 12, y + 5);
+
+      g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+      // roof paint
+      int xx = x + 8;
+      for (int i = 0; i < 4; i++)
+        g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i);
+      g.fillRect(x + 4, y + 6, 9, 2);
+
+      // door knob
+      g.drawLine(x + 9, y + 12, x + 9, y + 12);
+
+      // house paint
+      g.setColor(MetalLookAndFeel.getPrimaryControl());
+      g.drawLine(x + 4, y + 8, x + 12, y + 8);
+      g.fillRect(x + 4, y + 9, 2, 6);
+      g.fillRect(x + 11, y + 9, 2, 6);
+
+      g.setColor(savedColor);
+    }
+  }
+
+  public static Icon getNoImageIcon()
+  {
+    if (noImageIcon == null)
+      noImageIcon = new NoImageIcon();
+    return noImageIcon;
+  }
+
+  public static Icon getLoadingImageIcon()
+  {
+    if (loadingImageIcon == null)
+      loadingImageIcon = new LoadingImageIcon();
+    return loadingImageIcon;
+  }
+
+}
diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
new file mode 100644
index 000000000000..45e1dce7b048
--- /dev/null
+++ b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java
@@ -0,0 +1,263 @@
+/* SmallHtmlAttributeSet.java -- Small fixed HTML attribute set
+   Copyright (C) 2006 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 gnu.javax.swing.text.html.parser;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.html.HTML.Attribute;
+import javax.swing.text.html.HTML.Tag;
+
+/**
+ * Small fixed HTML attribute set. The most of the HTML elements contain only
+ * several attributes. With four attributes, the number of operations in more
+ * complex algorithms is not larger than using the naive algorithm.
+ * 
+ * Same as HtmlAttributeSet, this set allows both strings and non-string as
+ * keys. The strings are case insensitive, the non strings are compared with
+ * .equals.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class SmallHtmlAttributeSet
+    implements AttributeSet, Cloneable, Serializable
+{
+  private static final long serialVersionUID = 1;
+  
+  /**
+   * The keys, stored in this attribute set.
+   */
+  final Object[] keys;
+
+  /**
+   * The values, stored in this attribute set.
+   */
+  final Object[] values;
+
+  /**
+   * The parent, used for resolving the values, not found in this set.
+   */
+  final AttributeSet parent;
+
+  /**
+   * Create a new small fixed attribute set that contains the unchangeable copy
+   * of the passed attribute set and inherits its parent.
+   * 
+   * @param copyFrom the attribute set, containing the attribute values to copy.
+   */
+  public SmallHtmlAttributeSet(AttributeSet copyFrom)
+  {
+    int n = copyFrom.getAttributeCount();
+
+    keys = new Object[n];
+    values = new Object[n];
+    parent = copyFrom.getResolveParent();
+
+    Enumeration en = copyFrom.getAttributeNames();
+    Object key;
+    Object value;
+
+    for (int i = 0; i < n; i++)
+      {
+        key = en.nextElement();
+        keys[i] = key;
+        value = copyFrom.getAttribute(key);
+        if (value instanceof String)
+          value = ((String) value).toLowerCase();
+        values[i] = value;
+      }
+  }
+
+  public boolean containsAttribute(Object name, Object value)
+  {
+    Object contains = getAttribute(name);
+    if (value == null)
+      return value == contains;
+    else
+      return value.equals(contains);
+  }
+
+  public boolean containsAttributes(AttributeSet attributes)
+  {
+    if (attributes == this)
+      return true;
+    Object v;
+    for (int i = 0; i < keys.length; i++)
+      {
+        v = attributes.getAttribute(keys[i]);
+        if (v != values[i])
+          {
+            if (values[i] == null)
+              return false;
+            else if (! values[i].equals(v))
+              return false;
+          }
+      }
+    return true;
+  }
+
+  /**
+   * THIS can be safely returned as the set is not mutable.
+   */
+  public AttributeSet copyAttributes()
+  {
+    return this;
+  }
+
+  /**
+   * Get the attribute value, matching this key. If not found in this set, the
+   * call is delegated to parent.
+   * 
+   * @return the value, matching key (or null if none).
+   */
+  public Object getAttribute(Object key)
+  {
+    // Null and HTML attributes or tags can be searched by direct comparison.
+    if (key == null || key instanceof Attribute || key instanceof Tag)
+      {
+        for (int i = 0; i < keys.length; i++)
+          {
+            if (keys[i] == key)
+              return values[i];
+          }
+      }
+
+    // Strings are case insensitive. Only string can be match the string.
+    else if (key instanceof String)
+      {
+        String ks = (String) key;
+        for (int i = 0; i < keys.length; i++)
+          {
+            if (keys[i] instanceof String)
+              if (ks.equalsIgnoreCase((String) keys[i]))
+                return values[i];
+          }
+      }
+
+    // Otherwise, defaults to .equals
+    else
+      {
+        for (int i = 0; i < keys.length; i++)
+          {
+            if (key.equals(keys[i]))
+              return values[i];
+          }
+      }
+
+    if (parent != null)
+      return parent.getAttribute(key);
+    else
+      return null;
+  }
+
+  /**
+   * Get the number of the stored attributes.
+   */
+  public int getAttributeCount()
+  {
+    return keys.length;
+  }
+
+  /**
+   * Get enumeration, containing the attribute names. No guard agains the
+   * concurent modification is required as the set is not mutable.
+   */
+  public Enumeration getAttributeNames()
+  {
+    return new Enumeration()
+    {
+      int p = 0;
+
+      public boolean hasMoreElements()
+      {
+        return p < keys.length;
+      }
+
+      public Object nextElement()
+      {
+        if (p < keys.length)
+          return keys[p++];
+        else
+          throw new NoSuchElementException();
+      }
+    };
+  }
+  
+  /**
+   * Get the parent that this set uses to resolve the not found attributes.
+   */
+  public AttributeSet getResolveParent()
+  {
+    return parent;
+  }
+  
+  /**
+   * Check if the given attribute is defined in this set (not in the parent).
+   */
+  public boolean isDefined(Object attrName)
+  {
+    if (attrName instanceof String)
+      attrName = ((String) attrName).toLowerCase();
+
+    for (int i = 0; i < keys.length; i++)
+      {
+        if (attrName.equals(keys[i]))
+          return true;
+      }
+    return false;
+  }
+  
+  /**
+   * Check this set and another set for equality by content.
+   */
+  public boolean isEqual(AttributeSet attr)
+  {
+    return keys.length == attr.getAttributeCount() && containsAttributes(attr);
+  }
+
+  /**
+   * It is safe to return THIS on cloning, if one happens.
+   */
+  protected Object clone()
+  {
+    return this;
+  }
+}
diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java b/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java
index a4e6f73c5237..b89eec619bb3 100644
--- a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java
+++ b/libjava/classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java
@@ -46,6 +46,7 @@ import javax.swing.text.html.HTML;
 
 /**
  * A set, adapted to store HTML attributes.
+ * 
  * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  */
 public class htmlAttributeSet
@@ -53,23 +54,34 @@ public class htmlAttributeSet
 {
   public static final htmlAttributeSet EMPTY_HTML_ATTRIBUTE_SET =
     new htmlAttributeSet();
+  
   AttributeSet parent;
 
   /**
-   * Looks in this set and, if not found, later looks in the parent set.
-   * Calls toString(), allowing to pass as HTML.Attribute, as String
-   * to this method.
-   * @param key A key to search for a value.
+   * Looks in this set and, if not found, later looks in the parent set. Calls
+   * toString(), allowing to pass as HTML.Attribute, as String to this method.
+   * 
+   * @param _key A key to search for a value.
    * @return The value, if one is defined.
    */
   public Object getAttribute(Object _key)
   {
+    Object v = super.getAttribute(_key);
+    if (v != null || _key == null)
+      return v;
+
     Object key = _key.toString().toLowerCase();
 
-    Object v = super.getAttribute(key);
+    v = super.getAttribute(key);
+    if (v != null)
+      return v;
+
+    key = HTML.getAttributeKey((String) key);
+    v = super.getAttribute(key);
     if (v != null)
       return v;
-    else if (parent != null)
+
+    if (parent != null)
       return parent.getAttribute(key);
     else
       return null;
@@ -85,26 +97,29 @@ public class htmlAttributeSet
     final Enumeration enumeration = super.getAttributeNames();
 
     return new Enumeration()
+    {
+      public boolean hasMoreElements()
+      {
+        return enumeration.hasMoreElements();
+      }
+
+      public Object nextElement()
       {
-        public boolean hasMoreElements()
-        {
-          return enumeration.hasMoreElements();
-        }
-
-        public Object nextElement()
-        {
-          Object key = enumeration.nextElement();
-          HTML.Attribute hKey = HTML.getAttributeKey((String) key);
-          if (hKey != null)
-            return hKey;
-          else
-            return key;
-        }
-      };
+        Object key = enumeration.nextElement();
+        if (key instanceof String)
+          {
+            HTML.Attribute hKey = HTML.getAttributeKey((String) key);
+            if (hKey != null)
+              return hKey;
+          }
+        return key;
+      }
+    };
   }
 
   /**
    * Set the parent set, containing the default values.
+   * 
    * @param a_parent
    */
   public void setResolveParent(AttributeSet a_parent)
@@ -114,7 +129,8 @@ public class htmlAttributeSet
 
   /**
    * Get the parent set, containing the default values.
-   * @return
+   * 
+   * @return the parent, used to resolve the attributes.
    */
   public AttributeSet getResolveParent()
   {
@@ -123,11 +139,45 @@ public class htmlAttributeSet
 
   /**
    * Add the attribute to this attribute set.
-   * @param key Attribute key (will be case insensitive)
+   * 
+   * @param key Attribute key (if string, it will be case insensitive)
    * @param value Attribute value
    */
   public void addAttribute(Object key, Object value)
   {
-    super.addAttribute(key.toString().toLowerCase(), value);
+    if (key instanceof String)
+      super.addAttribute(((String) key).toLowerCase(), value);
+    else
+      super.addAttribute(key, value);
   }
+
+  /**
+   * Copy attributes. The returned copy does not longer contains the extended
+   * features, needed to participate in the HTML parsing. The returned set may
+   * not be mutable.
+   */
+  public AttributeSet copyAttributes()
+  {
+    if (getAttributeCount() <= 8)
+      // For the small size, typical in HTML tags, the direct iteration is
+      // faster than more complex algorithms.
+      return new SmallHtmlAttributeSet(this);
+    else
+      return (AttributeSet) clone();
+  }   
+  
+  /**
+   * Returns a clone of the attribute set.
+   * 
+   * @return A clone of the attribute set.
+   */
+  public Object clone()
+  {
+    htmlAttributeSet set = new htmlAttributeSet();
+    set.addAttributes(this);
+    AttributeSet parent = getResolveParent();
+    if (parent != null)
+      set.setResolveParent(parent);
+    return set;
+  }  
 }
diff --git a/libjava/classpath/include/Makefile.in b/libjava/classpath/include/Makefile.in
index 514f5f636dd1..2d172d750190 100644
--- a/libjava/classpath/include/Makefile.in
+++ b/libjava/classpath/include/Makefile.in
@@ -65,8 +65,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -93,8 +91,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -117,6 +119,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -132,9 +136,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -156,6 +159,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -169,6 +173,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -182,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -201,11 +208,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/include/config.h.in b/libjava/classpath/include/config.h.in
index d1a898752bd5..dda8b58e96e5 100644
--- a/libjava/classpath/include/config.h.in
+++ b/libjava/classpath/include/config.h.in
@@ -9,9 +9,6 @@
 /* Define to enable support for local sockets. */
 #undef ENABLE_LOCAL_SOCKETS
 
-/* defined if cairo support was built in */
-#undef GTK_CAIRO
-
 /* Define to 1 if you have the `accept' function. */
 #undef HAVE_ACCEPT
 
@@ -99,9 +96,15 @@
 /* Define to 1 if you have the `lseek' function. */
 #undef HAVE_LSEEK
 
+/* Define to 1 if you have the `lstat' function. */
+#undef HAVE_LSTAT
+
 /* Define to 1 if you have the `madvise' function. */
 #undef HAVE_MADVISE
 
+/* Define to 1 if you have the <magic.h> header file. */
+#undef HAVE_MAGIC_H
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -132,6 +135,9 @@
 /* Define to 1 if you have the `read' function. */
 #undef HAVE_READ
 
+/* Define to 1 if you have the `readlink' function. */
+#undef HAVE_READLINK
+
 /* Define to 1 if you have the `recvfrom' function. */
 #undef HAVE_RECVFROM
 
@@ -230,6 +236,12 @@
 /* Define to 1 if you have the `write' function. */
 #undef HAVE_WRITE
 
+/* Define to 1 if you have libXrandr. */
+#undef HAVE_XRANDR
+
+/* Define to 1 if you have libXrender. */
+#undef HAVE_XRENDER
+
 /* Define if the host machine stores words of multi-word integers in
    big-endian order. */
 #undef HOST_WORDS_BIG_ENDIAN
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
new file mode 100644
index 000000000000..0ac6e4ad0518
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
@@ -0,0 +1,45 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_CairoGraphics2D__
+#define __gnu_java_awt_peer_gtk_CairoGraphics2D__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_init (JNIEnv *env, jobject, jlong);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_disposeNative (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels (JNIEnv *env, jobject, jintArray, jint, jint, jint, jdoubleArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setGradient (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setTexturePixels (JNIEnv *env, jobject, jintArray, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetMatrix (JNIEnv *env, jobject, jdoubleArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetOperator (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetRGBAColor (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFillRule (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetLine (JNIEnv *env, jobject, jdouble, jint, jint, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetDash (JNIEnv *env, jobject, jdoubleArray, jint, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector (JNIEnv *env, jobject, jobject, jfloat, jfloat, jint, jintArray, jfloatArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelCurveTo (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRectangle (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoNewPath (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClosePath (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoMoveTo (JNIEnv *env, jobject, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelMoveTo (JNIEnv *env, jobject, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoLineTo (JNIEnv *env, jobject, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelLineTo (JNIEnv *env, jobject, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoCurveTo (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoStroke (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFill (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClip (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoPreserveClip (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoResetClip (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter (JNIEnv *env, jobject, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_CairoGraphics2D__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoSurface.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoSurface.h
new file mode 100644
index 000000000000..3bc263ffd97d
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_CairoSurface.h
@@ -0,0 +1,28 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_CairoSurface__
+#define __gnu_java_awt_peer_gtk_CairoSurface__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_create (JNIEnv *env, jobject, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_destroy (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeGetElem (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeSetElem (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_drawSurface (JNIEnv *env, jobject, jobject, jdoubleArray);
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_getPixels (JNIEnv *env, jobject, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_setPixels (JNIEnv *env, jobject, jintArray);
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_getFlippedBuffer (JNIEnv *env, jobject, jint);
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_newCairoContext (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_copyAreaNative (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_CairoSurface__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
new file mode 100644
index 000000000000..e8ca711780e3
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h
@@ -0,0 +1,26 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_ComponentGraphics__
+#define __gnu_java_awt_peer_gtk_ComponentGraphics__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_disposeSurface (JNIEnv *env, jobject, jlong);
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVolatile (JNIEnv *env, jobject, jlong, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1drawing (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_end_1gdk_1drawing (JNIEnv *env, jobject);
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile (JNIEnv *env, jobject, jobject, jobject, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_ComponentGraphics__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h
new file mode 100644
index 000000000000..8e4b2cdb3cb7
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h
@@ -0,0 +1,20 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_ComponentGraphicsCopy__
+#define __gnu_java_awt_peer_gtk_ComponentGraphicsCopy__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_getPixbuf (JNIEnv *env, jobject, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_copyPixbuf (JNIEnv *env, jobject, jobject, jobject, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_ComponentGraphicsCopy__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
new file mode 100644
index 000000000000..8c8434b6e251
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
@@ -0,0 +1,22 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_FreetypeGlyphVector__
+#define __gnu_java_awt_peer_gtk_FreetypeGlyphVector__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyph (JNIEnv *env, jobject, jint);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT jdoubleArray JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getMetricsNative (JNIEnv *env, jobject, jint);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative (JNIEnv *env, jobject, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_FreetypeGlyphVector__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkFontPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
index 900146674c9c..3b9ddd44333c 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
@@ -13,10 +13,11 @@ extern "C"
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initStaticState (JNIEnv *env, jclass);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initState (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont (JNIEnv *env, jobject, jstring, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont (JNIEnv *env, jobject, jstring, jint, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics (JNIEnv *env, jobject, jdoubleArray);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTextMetrics (JNIEnv *env, jobject, jstring, jdoubleArray);
-JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector (JNIEnv *env, jobject, jstring, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_releasePeerGraphicsResource (JNIEnv *env, jobject);
+JNIEXPORT jbyteArray JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTrueTypeTable (JNIEnv *env, jobject, jbyte, jbyte, jbyte, jbyte);
 
 #ifdef __cplusplus
 }
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
index 60f7af423be3..2a619c609516 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
@@ -10,6 +10,10 @@ extern "C"
 {
 #endif
 
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState (JNIEnv *env, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState (JNIEnv *env, jobject);
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetScreenDevices (JNIEnv *env, jobject);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetDefaultScreenDevice (JNIEnv *env, jobject);
 JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetFontFamilies (JNIEnv *env, jobject, jobjectArray);
 
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h
new file mode 100644
index 000000000000..8037af0825ee
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h
@@ -0,0 +1,26 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__
+#define __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_initStaticState (JNIEnv *env, jclass);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetFixedDisplayMode (JNIEnv *env, jobject, jobject);
+JNIEXPORT jstring JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetIDString (JNIEnv *env, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeIndex (JNIEnv *env, jobject, jobject);
+JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeRate (JNIEnv *env, jobject, jobject);
+JNIEXPORT jobjectArray JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModes (JNIEnv *env, jobject, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeSetDisplayMode (JNIEnv *env, jobject, jobject, jint, jshort);
+JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetBounds (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice__ */
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
index c74a574e7192..680c4165f846 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GdkTextLayout.h
@@ -11,10 +11,12 @@ extern "C"
 #endif
 
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText (JNIEnv *env, jobject, jstring);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_setFont (JNIEnv *env, jobject, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_getExtents (JNIEnv *env, jobject, jdoubleArray, jdoubleArray);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos (JNIEnv *env, jobject, jint, jdoubleArray);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_initState (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_dispose (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_cairoDrawGdkTextLayout (JNIEnv *env, jobject, jobject, jfloat, jfloat);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_initStaticState (JNIEnv *env, jclass);
 JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_getOutline (JNIEnv *env, jobject, jobject);
 
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
index 44ab6870cfa7..e774713a7669 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
@@ -11,7 +11,6 @@ extern "C"
 #endif
 
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_realize (JNIEnv *env, jobject);
 
 #ifdef __cplusplus
 }
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
index 207e08d052de..f2014595fe8f 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
@@ -26,7 +26,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetS
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent (JNIEnv *env, jobject, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetRequestFocus (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetDispatchKeyEvent (JNIEnv *env, jobject, jint, jlong, jint, jint, jint);
-JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isRealized (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_realize (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeEventMask (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_connectSignals (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setNativeBounds (JNIEnv *env, jobject, jint, jint, jint, jint);
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkImage.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkImage.h
index 48940a1caf1c..0ea798bc2642 100644
--- a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkImage.h
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkImage.h
@@ -10,15 +10,14 @@ extern "C"
 {
 #endif
 
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_initFromBuffer (JNIEnv *env, jobject, jlong);
 JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_getPixels (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_setPixels (JNIEnv *env, jobject, jintArray);
 JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf (JNIEnv *env, jobject, jstring);
 JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_loadImageFromData (JNIEnv *env, jobject, jbyteArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap (JNIEnv *env, jobject, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jint, jint, jboolean);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped (JNIEnv *env, jobject, jobject, jint, jint, jint, jboolean, jboolean, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_createPixbuf (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_freePixbuf (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixbuf (JNIEnv *env, jobject, jobject, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_createFromPixbuf (JNIEnv *env, jobject);
 
 #ifdef __cplusplus
diff --git a/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
new file mode 100644
index 000000000000..3a0efd3a9e4c
--- /dev/null
+++ b/libjava/classpath/include/gnu_java_awt_peer_gtk_GtkVolatileImage.h
@@ -0,0 +1,23 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_GtkVolatileImage__
+#define __gnu_java_awt_peer_gtk_GtkVolatileImage__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_init (JNIEnv *env, jobject, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_destroy (JNIEnv *env, jobject);
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_getPixels (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_copyArea (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkVolatileImage_drawVolatile (JNIEnv *env, jobject, jlong, jint, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_GtkVolatileImage__ */
diff --git a/libjava/classpath/java/awt/BasicStroke.java b/libjava/classpath/java/awt/BasicStroke.java
index bf111d08050c..3e259216fa7c 100644
--- a/libjava/classpath/java/awt/BasicStroke.java
+++ b/libjava/classpath/java/awt/BasicStroke.java
@@ -363,7 +363,7 @@ public class BasicStroke implements Stroke
    * Compares this <code>BasicStroke</code> for equality with an arbitrary 
    * object.  This method returns <code>true</code> if and only if:
    * <ul>
-   * <li><code>o</code> is an instanceof <code>BasicStroke</code>;<li>
+   * <li><code>o</code> is an instanceof <code>BasicStroke</code>;</li>
    * <li>this object has the same width, line cap style, line join style,
    * miter limit, dash array and dash phase as <code>o</code>.</li>
    * </ul>
diff --git a/libjava/classpath/java/awt/ColorPaintContext.java b/libjava/classpath/java/awt/ColorPaintContext.java
index 82a78f63fb54..2996f899f170 100644
--- a/libjava/classpath/java/awt/ColorPaintContext.java
+++ b/libjava/classpath/java/awt/ColorPaintContext.java
@@ -117,7 +117,7 @@ class ColorPaintContext implements PaintContext
    {
      cachedRaster = new ColorRaster(colorModel, 0, 0, width, height, color);
    }
-   return cachedRaster.createChild(0 ,0 ,width ,height ,x ,y , null);
+   return cachedRaster.createChild(0 ,0 ,width ,height ,0 ,0 , null);
   }
   
   /**
@@ -138,13 +138,13 @@ class ColorPaintContext implements PaintContext
      * @param rgbPixel The RGB value of the color for this raster.
      */
     ColorRaster(ColorModel cm,int x, int y, int width, int height, int rgbPixel)
-    {         
+    {
       super(cm.createCompatibleSampleModel(width,height),new Point(x,y));
       Object pixel = cm.getDataElements(rgbPixel,null);
-      getSampleModel().setDataElements(0, 0,
-                                       width, height,
-                                       multiplyData(pixel,null,width*height),
-                                       dataBuffer);
+      int[] pixelComps = cm.getComponents(pixel, null, 0);
+      int[] d = (int[]) multiplyData(pixelComps,null,width*height);
+      getSampleModel().setPixels(0, 0, width, height, d,
+                                 dataBuffer);
     }
     
     
diff --git a/libjava/classpath/java/awt/Component.java b/libjava/classpath/java/awt/Component.java
index dbbec8ac1786..cc42d04f2745 100644
--- a/libjava/classpath/java/awt/Component.java
+++ b/libjava/classpath/java/awt/Component.java
@@ -2067,11 +2067,9 @@ public abstract class Component
    */
   public VolatileImage createVolatileImage(int width, int height)
   {
-    if (GraphicsEnvironment.isHeadless())
-      return null;
-    GraphicsConfiguration config = getGraphicsConfiguration();
-    return config == null ? null
-      : config.createCompatibleVolatileImage(width, height);
+    if (peer != null)
+      return peer.createVolatileImage(width, height);
+    return null;
   }
 
   /**
@@ -2090,11 +2088,9 @@ public abstract class Component
                                            ImageCapabilities caps)
     throws AWTException
   {
-    if (GraphicsEnvironment.isHeadless())
-      return null;
-    GraphicsConfiguration config = getGraphicsConfiguration();
-    return config == null ? null
-      : config.createCompatibleVolatileImage(width, height, caps);
+    if (peer != null)
+      return peer.createVolatileImage(width, height);
+    return null;
   }
 
   /**
@@ -4810,8 +4806,38 @@ p   * <li>the set of backward traversal keys
   {
     Object target = e.getSource ();
     Event translated = null;
+    
+    if (e instanceof WindowEvent)
+      {
+        WindowEvent we = (WindowEvent) e;
+        int id = we.id;
+        int newId = 0;
+        
+        switch (id)
+          {
+          case WindowEvent.WINDOW_DEICONIFIED:
+            newId = Event.WINDOW_DEICONIFY;
+            break;
+          case WindowEvent.WINDOW_CLOSED:
+          case WindowEvent.WINDOW_CLOSING:
+            newId = Event.WINDOW_DESTROY;
+            break;
+          case WindowEvent.WINDOW_ICONIFIED:
+            newId = Event.WINDOW_ICONIFY;
+            break;
+          case WindowEvent.WINDOW_GAINED_FOCUS:
+            newId = Event.GOT_FOCUS;
+            break;
+          case WindowEvent.WINDOW_LOST_FOCUS:
+            newId = Event.LOST_FOCUS;
+            break;
+          default:
+            return null;
+          }
 
-    if (e instanceof InputEvent)
+        translated = new Event(target, 0, newId, 0, 0, 0, 0);
+      }
+    else if (e instanceof InputEvent)
       {
         InputEvent ie = (InputEvent) e;
         long when = ie.getWhen ();
@@ -5052,7 +5078,12 @@ p   * <li>the set of backward traversal keys
                     .dispatchEvent(e))
                     return;
               case MouseEvent.MOUSE_PRESSED:
-                if (isLightweight() && !e.isConsumed())
+                // A mouse click on an enabled lightweight component
+                // which has not yet been marked as consumed by any
+                // other mouse listener results in a focus traversal
+                // to that component.
+                if (isLightweight()
+                    && isEnabled() && !e.isConsumed())
                     requestFocus();
                 break;
               }
diff --git a/libjava/classpath/java/awt/Container.java b/libjava/classpath/java/awt/Container.java
index 2419a7bd24ac..85a68ce13c2e 100644
--- a/libjava/classpath/java/awt/Container.java
+++ b/libjava/classpath/java/awt/Container.java
@@ -457,8 +457,44 @@ public class Container extends Component
   {
     synchronized (getTreeLock ())
       {
-        while (ncomponents > 0)
-          remove(0);
+        // In order to allow the same bad tricks to be used as in RI
+        // this code has to stay exactly that way: In a real-life app
+        // a Container subclass implemented its own vector for
+        // subcomponents, supplied additional addXYZ() methods
+        // and overrode remove(int) and removeAll (the latter calling
+        // super.removeAll() ).
+        // By doing it this way, user code cannot prevent the correct
+        // removal of components.
+        for ( int index = 0; index < ncomponents; index++)
+          {
+            Component r = component[index];
+
+            ComponentListener[] list = r.getComponentListeners();
+            for (int j = 0; j < list.length; j++)
+              r.removeComponentListener(list[j]);
+            
+            r.removeNotify();
+
+            if (layoutMgr != null)
+              layoutMgr.removeLayoutComponent(r);
+
+            r.parent = null;
+
+            if (isShowing ())
+              {
+                // Post event to notify of removing the component.
+                ContainerEvent ce
+                  = new ContainerEvent(this,
+                                       ContainerEvent.COMPONENT_REMOVED,
+                                       r);
+                
+                getToolkit().getSystemEventQueue().postEvent(ce);
+              }
+            }
+          
+          invalidate();
+        
+          ncomponents = 0;
       }
   }
 
diff --git a/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java b/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java
index 152482c887ba..23b4ac2e8d35 100644
--- a/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java
+++ b/libjava/classpath/java/awt/ContainerOrderFocusTraversalPolicy.java
@@ -111,14 +111,16 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
 	ancestor = current.getFocusCycleRootAncestor ();
 	if (ancestor == prevAncestor)
 	  {
-	    // We've reached the top focus cycle root ancestor.  Check
-	    // if it is root.
-	    if (ancestor != root)
+            // We've reached the top focus cycle root ancestor.  Check
+            // if it is root.
+            if (ancestor == null)
+              ancestor = root;
+            else if (ancestor != root)
 	      throw new IllegalArgumentException ("the given container is not"
 						  + " a focus cycle root of the"
 						  + " current component");
-	    else
-	      break;
+            else
+              break;
 	  }
 	prevAncestor = ancestor;
       }
@@ -136,7 +138,6 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
       return getFirstComponent ((Container) current);
 
     Container parent = current.getParent ();
-
     synchronized (parent.getTreeLock ())
       {
         Component[] components = parent.getComponents ();
@@ -146,47 +147,104 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
         // Find component's index.
         for (int i = 0; i < numComponents; i++)
           {
-            if (components[i] == current)
+            if (components[i].equals(current))
               componentIndex = i;
           }
 
-        // Search forward for the next acceptable component.
-        for (int i = componentIndex + 1; i < numComponents; i++)
-          {
-            if (accept (components[i]))
-              return components[i];
+        // Search forward for the next acceptable component.  
+        // Search through all components at least one time
+        // i.e. start at componentIndex + 1 --> nComponents -1 --> 0  ---> componentIndex
+        int i = componentIndex + 1;
+        int end = numComponents - 1;
+        Component next = getNextAvailableComponent(components, i, end);
+        if (next != null)
+          return next;
+        
+        // Now check remainder of components from 0 to componentIndex
+        i = 0;
+        end = componentIndex;
+        next = getNextAvailableComponent(components, i, end);
+        if (next != null)
+          return next; 
+        
+        // No focusable components after current in its Container.  So go
+        // to the next Component after current's Container (parent).
+        Component result = getComponentAfter (root, parent);
+        return result;
+      }
+  }
+  
+  /**
+   * Gets the next available component in the array between the given range.
+   * 
+   * @param components - the array of components.
+   * @param start - where to start
+   * @param end - where to end
+   * @return next component if found
+   */
+  private Component getNextAvailableComponent(Component[] components, int start, int end)
+  {
+    while (start <= end)
+      {
+        Component c = components[start];
+
+        if (c.visible && c.isDisplayable() && c.enabled && c.focusable)
+          return c;
 
-            if (components[i] instanceof Container)
-              {
-                Component result = getFirstComponent ((Container) components[i]);
+        if (c instanceof Container)
+          {
+            Component result = getFirstComponent((Container) c);
 
-                if (result != null
-                    && implicitDownCycleTraversal)
-                  return result;
-              }
+            if (result != null && implicitDownCycleTraversal && result.visible
+                && result.isDisplayable() && result.enabled && result.focusable)
+              return result;
           }
+        start++;
+      }
 
-        // No focusable components after current in its Container.  So go
-        // to the next Component after current's Container (parent).
-        Component result = getComponentAfter (root, parent);
+    return null;
+  }
 
-        return result;
+  /**
+   * Gets the previous available component in the array between the given range.
+   * 
+   * @param components - the array of components.
+   * @param start - where to start
+   * @param end - where to end
+   * @return previous component if found
+   */
+  Component getPrevAvailableComponent(Component[] components, int start, int end)
+  {
+    while (start >= end) 
+      {
+        Component c = components[start];
+        if (c.visible && c.isDisplayable() && c.enabled && c.focusable)
+          return c;
+
+        if (c instanceof Container)
+          {
+            Component result = getLastComponent((Container) c);
+
+            if (result != null
+                && (result.visible && result.isDisplayable() && result.enabled && result.focusable))
+              return result;
+          }
+        start--;
       }
+    return null;
   }
 
   /**
    * Returns the Component that should receive the focus before
-   * <code>current</code>.  <code>root</code> must be a focus cycle
-   * root of current.
-   *
+   * <code>current</code>. <code>root</code> must be a focus cycle root of
+   * current.
+   * 
    * @param root a focus cycle root of current
    * @param current a (possibly indirect) child of root, or root itself
-   *
-   * @return the previous Component in the focus traversal order for
-   * root, or null if no acceptable Component exists.
-   *
-   * @exception IllegalArgumentException If root is not a focus cycle
-   * root of current, or if either root or current is null.
+   * @return the previous Component in the focus traversal order for root, or
+   *         null if no acceptable Component exists.
+   * @exception IllegalArgumentException If root is not a focus cycle root of
+   *              current, or if either root or current is null.
    */
   public Component getComponentBefore (Container root, Component current)
   {
@@ -207,7 +265,9 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
 	  {
 	    // We've reached the top focus cycle root ancestor.  Check
 	    // if it is root.
-	    if (ancestor != root)
+            if (ancestor == null)
+              ancestor = root;
+            else if (ancestor != root)
 	      throw new IllegalArgumentException ("the given container is not"
 						  + " a focus cycle root of the"
 						  + " current component");
@@ -244,20 +304,20 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
               componentIndex = i;
           }
 
-        // Search backward for the next acceptable component.
-        for (int i = componentIndex - 1; i >= 0; i--)
-          {
-            if (accept (components[i]))
-              return components[i];
-
-            if (components[i] instanceof Container)
-              {
-                Component result = getLastComponent ((Container) components[i]);
-
-                if (result != null)
-                  return result;
-              }
-          }
+        // Search through all components at least one time
+        // i.e. start at componentIndex - 1 --> 0 --> numComponents -1  ---> componentIndex
+        int i = componentIndex - 1;
+        int end = 0;
+        Component prev = getPrevAvailableComponent(components, i, end);
+        if (prev != null)
+          return prev;
+        
+        // Now check remainder of components
+        i = numComponents -1;
+        end = componentIndex;
+        prev = getPrevAvailableComponent(components, i, end);
+        if (prev != null)
+          return prev; 
 
         // No focusable components before current in its Container.  So go
         // to the previous Component before current's Container (parent).
@@ -286,7 +346,8 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
         || !root.isDisplayable ())
       return null;
 
-    if (accept (root))
+    if (root.visible && root.isDisplayable() && root.enabled
+        && root.focusable)
       return root;
 
     Component[] componentArray = root.getComponents ();
@@ -295,14 +356,16 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
       {
         Component component = componentArray [i];
 	
-	if (accept (component))
+	if (component.visible && component.isDisplayable() && component.enabled
+            && component.focusable)
 	  return component;
 
         if (component instanceof Container)
           {
             Component result = getFirstComponent ((Container) component);
 
-            if (result != null)
+            if (result != null
+                && (result.visible && result.isDisplayable() && result.enabled && result.focusable))
               return result;
           }
       }
@@ -329,7 +392,8 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
         || !root.isDisplayable ())
       return null;
 
-    if (accept (root))
+    if (root.visible && root.isDisplayable() && root.enabled
+        && root.focusable)
       return root;
 
     Component[] componentArray = root.getComponents ();
@@ -338,14 +402,17 @@ public class ContainerOrderFocusTraversalPolicy extends FocusTraversalPolicy
       {
         Component component = componentArray [i];
 	
-	if (accept (component))
+	if (component.visible && component.isDisplayable() && component.enabled
+            && component.focusable)
 	  return component;
 
         if (component instanceof Container)
           {
             Component result = getLastComponent ((Container) component);
 
-            if (result != null)
+            if (result != null &&
+                result.visible && result.isDisplayable() && result.enabled
+                && result.focusable)
               return result;
           }
       }
diff --git a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
index a60cefd9c9dd..037cb834c40d 100644
--- a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
+++ b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java
@@ -274,10 +274,12 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
 
   public boolean dispatchKeyEvent (KeyEvent e)
   {
-    Component focusOwner = getGlobalPermanentFocusOwner ();
-
+    Component focusOwner = getFocusOwner();
+    if (focusOwner == null)
+      focusOwner = getFocusedWindow();
+    
     if (focusOwner != null)
-      redispatchEvent(focusOwner, e);
+      redispatchEvent(focusOwner, e);      
 
     // Loop through all registered KeyEventPostProcessors, giving
     // each a chance to process this event.
@@ -294,7 +296,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
     // MenuShortcut.
     if (postProcessKeyEvent (e))
       return true;
-
+    
     // Always return true.
     return true;
   }
diff --git a/libjava/classpath/java/awt/EventDispatchThread.java b/libjava/classpath/java/awt/EventDispatchThread.java
index a64cdae85675..7cb8af831bf9 100644
--- a/libjava/classpath/java/awt/EventDispatchThread.java
+++ b/libjava/classpath/java/awt/EventDispatchThread.java
@@ -43,6 +43,11 @@ package java.awt;
  */
 class EventDispatchThread extends Thread
 {
+  /**
+   * The default priority when no property has been set.
+   */
+  private static final int DEFAULT_PRIORITY = NORM_PRIORITY + 1;
+
   private static int dispatchThreadNum;
 
   private EventQueue queue;
@@ -52,7 +57,22 @@ class EventDispatchThread extends Thread
     super();
     setName("AWT-EventQueue-" + ++dispatchThreadNum);
     this.queue = queue;
-    setPriority(NORM_PRIORITY + 1);
+
+    int priority = DEFAULT_PRIORITY;
+    try
+      {
+        String priorityString =
+          System.getProperty("gnu.awt.dispatchthread.priority");
+        if (priorityString != null)
+          {
+            priority = Integer.parseInt(priorityString); 
+          }      
+      }
+    catch (NumberFormatException ex)
+      {
+        // Ignore and use default.
+      }
+    setPriority(priority);
   }
 
   public void run()
diff --git a/libjava/classpath/java/awt/Font.java b/libjava/classpath/java/awt/Font.java
index 2e4c9f61c689..a52f63408dab 100644
--- a/libjava/classpath/java/awt/Font.java
+++ b/libjava/classpath/java/awt/Font.java
@@ -1013,7 +1013,7 @@ public class Font implements Serializable
    */
   public int getNumGlyphs()
   {
-    return peer.getMissingGlyphCode(this);
+    return peer.getNumGlyphs(this);
   }
 
   /**
diff --git a/libjava/classpath/java/awt/Graphics2D.java b/libjava/classpath/java/awt/Graphics2D.java
index 3faa9dc0c662..b3ecbc58a984 100644
--- a/libjava/classpath/java/awt/Graphics2D.java
+++ b/libjava/classpath/java/awt/Graphics2D.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2004  Free Software Foundation
+/* Copyright (C) 2000, 2002, 2004, 2006,  Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -45,10 +45,35 @@ import java.awt.image.BufferedImageOp;
 import java.awt.image.ImageObserver;
 import java.awt.image.RenderedImage;
 import java.awt.image.renderable.RenderableImage;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
 import java.text.AttributedCharacterIterator;
 import java.util.Map;
 
 /**
+ * An abstract class defining a device independent two-dimensional vector 
+ * graphics API.  Concrete subclasses implement this API for output of 
+ * vector graphics to: (*)
+ * <p>
+ * <ul>
+ * <li>a {@link javax.swing.JComponent} - in the 
+ *     {@link javax.swing.JComponent#paint(Graphics)} method, the incoming 
+ *     {@link Graphics} should always be an instance of 
+ *     <code>Graphics2D</code> (*);</li> 
+ * <li>a {@link BufferedImage} - see 
+ *     {@link BufferedImage#createGraphics()} (*);</li>
+ * <li>a {@link java.awt.print.PrinterJob} - in the 
+ *     {@link Printable#print(Graphics, PageFormat, int)} method, the incoming
+ *     {@link Graphics} should always be an instance of <code>Graphics2D</code>
+ *     (*).</li>
+ * </ul>
+ * <p>
+ * (*) Support for this API is not fully implemented in GNU Classpath yet.
+ * <p>
+ * Third party libraries provide support for output to other formats via this 
+ * API, including encapsulated postscript (EPS), portable document format (PDF),
+ * and scalable vector graphics (SVG).
+ * 
  * @author Rolf W. Rasmussen (rolfwr@ii.uib.no)
  */
 public abstract class Graphics2D extends Graphics
@@ -70,6 +95,14 @@ public abstract class Graphics2D extends Graphics
     super.fill3DRect(x, y, width, height, raised);
   }
 
+  /**
+   * Draws an outline around a shape using the current stroke and paint.
+   * 
+   * @param shape  the shape (<code>null</code> not permitted).
+   * 
+   * @see #getStroke()
+   * @see #getPaint()
+   */
   public abstract void draw(Shape shape);
 
   public abstract boolean drawImage(Image image, AffineTransform xform,
@@ -86,18 +119,57 @@ public abstract class Graphics2D extends Graphics
   public abstract void drawRenderableImage(RenderableImage image,
                                            AffineTransform xform);
 
+  /**
+   * Draws a string at the specified location, using the current font.
+   * 
+   * @param text  the string to draw.
+   * @param x  the x-coordinate.
+   * @param y  the y-coordinate.
+   * 
+   * @see Graphics#setFont(Font)
+   */
   public abstract void drawString(String text, int x, int y);
 
+  /**
+   * Draws a string at the specified location, using the current font.
+   * 
+   * @param text  the string to draw.
+   * @param x  the x-coordinate.
+   * @param y  the y-coordinate.
+   * 
+   * @see Graphics#setFont(Font)
+   */
   public abstract void drawString(String text, float x, float y);
     
+  /**
+   * Draws an attributed string at the specified location.
+   * 
+   * @param iterator  the source of the attributed text.
+   * @param x  the x-coordinate.
+   * @param y  the y-coordinate.
+   */
   public abstract void drawString(AttributedCharacterIterator iterator,
                                   int x, int y);
 
+  /**
+   * Draws an attributed string at the specified location.
+   * 
+   * @param iterator  the source of the attributed text.
+   * @param x  the x-coordinate.
+   * @param y  the y-coordinate.
+   */
   public abstract void drawString(AttributedCharacterIterator iterator,
 				  float x, float y);
 
-  // public abstract void drawGlyphVector(GlyphVector g, float x, float y);
-
+  /**
+   * Fills the interior of the specified <code>shape</code> using the current
+   * paint.
+   * 
+   * @param shape  the shape to fill (<code>null</code> not permitted).
+   * 
+   * @see #draw(Shape)
+   * @see #getPaint()
+   */
   public abstract void fill(Shape shape);
     
   public abstract boolean hit(Rectangle rect, Shape text,
@@ -105,21 +177,72 @@ public abstract class Graphics2D extends Graphics
 
   public abstract GraphicsConfiguration getDeviceConfiguration();
 
+  /**
+   * Sets the current compositing rule.
+   * 
+   * @param comp  the composite.
+   * 
+   * @see #getComposite()
+   */
   public abstract void setComposite(Composite comp);
-    
+
+  /**
+   * Sets the paint to be used for subsequent drawing operations.
+   * 
+   * @param paint  the paint (<code>null</code> not permitted).
+   * 
+   * @see #getPaint()
+   */
   public abstract void setPaint(Paint paint);
 
+  /**
+   * Sets the stroke to be used for subsequent drawing operations.
+   * 
+   * @param stroke  the stroke (<code>null</code> not permitted).
+   * 
+   * @see #getStroke()
+   */
   public abstract void setStroke(Stroke stroke);
 
+  /**
+   * Adds or updates a hint in the current rendering hints table.
+   * 
+   * @param hintKey  the hint key.
+   * @param hintValue  the hint value.
+   */
   public abstract void setRenderingHint(RenderingHints.Key hintKey,
                                         Object hintValue);
 
+  /**
+   * Returns the current value of a rendering hint.
+   * 
+   * @param hintKey  the key for the hint.
+   * 
+   * @return The value for the specified hint.
+   */
   public abstract Object getRenderingHint(RenderingHints.Key hintKey);
   
+  /**
+   * Replaces the current rendering hints with the supplied hints.
+   * 
+   * @param hints  the hints.
+   * 
+   * @see #addRenderingHints(Map)
+   */
   public abstract void setRenderingHints(Map hints);
 
+  /**
+   * Adds/updates the rendering hint.
+   * 
+   * @param hints  the hints to add or update.
+   */
   public abstract void addRenderingHints(Map hints);
 
+  /**
+   * Returns the current rendering hints.
+   * 
+   * @return The current rendering hints.
+   */
   public abstract RenderingHints getRenderingHints();
 
   public abstract void translate(int x, int y);
@@ -134,25 +257,104 @@ public abstract class Graphics2D extends Graphics
 
   public abstract void shear(double shearX, double shearY);
 
-  public abstract void transform(AffineTransform Tx);
+  /**
+   * Sets the current transform to a concatenation of <code>transform</code>
+   * and the existing transform.
+   * 
+   * @param transform  the transform.
+   */
+  public abstract void transform(AffineTransform transform);
   
-  public abstract void setTransform(AffineTransform Tx);
-
+  /**
+   * Sets the current transform.  If the caller specifies a <code>null</code>
+   * transform, this method should set the current transform to the 
+   * identity transform.
+   * 
+   * @param transform  the transform (<code>null</code> permitted).
+   * 
+   * @see #getTransform()
+   */
+  public abstract void setTransform(AffineTransform transform);
+
+  /**
+   * Returns the current transform.
+   * 
+   * @return The current transform.
+   * 
+   * @see #setTransform(AffineTransform)
+   */
   public abstract AffineTransform getTransform();
 
+  /**
+   * Returns the current paint.
+   * 
+   * @return The current paint.
+   * 
+   * @see #setPaint(Paint)
+   */
   public abstract Paint getPaint();
 
+  /**
+   * Returns the current compositing rule.
+   * 
+   * @return The current compositing rule.
+   * 
+   * @see #setComposite(Composite)
+   */
   public abstract Composite getComposite();
 
+  /**
+   * Sets the background color (used by the 
+   * {@link Graphics#clearRect(int, int, int, int)} method).
+   * 
+   * @param color  the color.
+   * 
+   * @see #getBackground()
+   */
   public abstract void setBackground(Color color);
 
+  /**
+   * Returns the color used by the 
+   * {@link Graphics#clearRect(int, int, int, int)} method.
+   * 
+   * @return The background color.
+   * 
+   * @see #setBackground(Color)
+   */
   public abstract Color getBackground();
 
+  /**
+   * Returns the current stroke.
+   * 
+   * @return The current stroke.
+   * 
+   * @see #setStroke(Stroke)
+   */
   public abstract Stroke getStroke();    
 
+  /**
+   * Sets the clip region to the intersection of the current clipping region 
+   * and <code>s</code>.
+   * 
+   * @param s  the shape to intersect with the current clipping region.
+   * 
+   * @see Graphics#setClip(Shape)
+   */
   public abstract void clip(Shape s);
 
-  public abstract FontRenderContext getFontRenderContext ();
-
-  public abstract void drawGlyphVector (GlyphVector g, float x, float y);
+  /**
+   * Returns the font render context.
+   * 
+   * @return The font render context.
+   */
+  public abstract FontRenderContext getFontRenderContext();
+
+  /**
+   * Draws a glyph vector at the specified location.
+   * 
+   * @param g  the glyph vector.
+   * @param x  the x-coordinate.
+   * @param y  the y-coordinate.
+   */
+  public abstract void drawGlyphVector(GlyphVector g, float x, float y);
 }
diff --git a/libjava/classpath/java/awt/GraphicsConfiguration.java b/libjava/classpath/java/awt/GraphicsConfiguration.java
index f68a1e6ba4fe..792b2cc1b2bb 100644
--- a/libjava/classpath/java/awt/GraphicsConfiguration.java
+++ b/libjava/classpath/java/awt/GraphicsConfiguration.java
@@ -65,6 +65,13 @@ import java.awt.image.VolatileImage;
  */
 public abstract class GraphicsConfiguration
 {
+  
+  /** The cached image capabilities. */
+  private ImageCapabilities imageCapabilities;
+  
+  /** The cached buffer capabilities. */
+  private BufferCapabilities bufferCapabilities;
+  
   /**
    * The default constructor.
    *
@@ -218,9 +225,14 @@ public abstract class GraphicsConfiguration
    * @since 1.4
    */
   public BufferCapabilities getBufferCapabilities()
-    throws NotImplementedException
   {
-    throw new Error("not implemented");
+    if (imageCapabilities == null)
+      getImageCapabilities();
+    
+    if (bufferCapabilities == null)
+      bufferCapabilities = new BufferCapabilities(imageCapabilities,
+                                                  imageCapabilities, null);
+    return bufferCapabilities;
   }
 
   /**
@@ -230,8 +242,9 @@ public abstract class GraphicsConfiguration
    * @since 1.4
    */
   public ImageCapabilities getImageCapabilities()
-    throws NotImplementedException
   {
-    throw new Error("not implemented");
+    if (imageCapabilities == null)
+      imageCapabilities = new ImageCapabilities(false);
+    return imageCapabilities;
   }
 } // class GraphicsConfiguration
diff --git a/libjava/classpath/java/awt/LightweightDispatcher.java b/libjava/classpath/java/awt/LightweightDispatcher.java
index 860646402cc8..7e33bd4e9cec 100644
--- a/libjava/classpath/java/awt/LightweightDispatcher.java
+++ b/libjava/classpath/java/awt/LightweightDispatcher.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package java.awt;
 
-import gnu.java.awt.AWTUtilities;
-
 import java.awt.event.MouseEvent;
 import java.util.WeakHashMap;
 
@@ -67,6 +65,13 @@ class LightweightDispatcher
    * as well as the MOUSE_RELEASED event following the dragging.
    */
   private Component dragTarget;
+  
+  /**
+   * Stores the button number which started the drag operation. This is needed
+   * because we want to handle only one drag operation and only the button that
+   * started the dragging should be able to stop it (by a button release).
+   */
+  private int dragButton;
 
   /**
    * The last mouse event target. If the target changes, additional
@@ -121,15 +126,41 @@ class LightweightDispatcher
   /**
    * Handles all mouse events that are targetted at toplevel containers
    * (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 boolean handleMouseEvent(MouseEvent ev)
   {
     Window window = (Window) ev.getSource();
-    Component target = window.findComponentAt(ev.getX(), ev.getY());
-    target = findTarget(target);
+    // Find the target for the mouse event. We first seach the deepest
+    // component at the specified location. The we go up to its parent and
+    // try to find a neighbor of the deepest component that is suitable as
+    // mouse event target (it must be showing, at that location and have either
+    // a MouseListener or MouseMotionListener installed). If no such component
+    // is found, then we walk up the container hierarchy and find the next
+    // container that has a MouseListener or MouseMotionListener installed.
+    Component deepest = window.findComponentAt(ev.getX(), ev.getY());
+    if (deepest == null)
+      return false;
+    Container parent = deepest.getParent();
+    Point loc = ev.getPoint();
+    loc = convertPointToChild(window, loc, parent);
+    Component target = null;
+    if (parent != null)
+      {
+        target = findTarget(parent, loc);
+        while (target == null && parent != null)
+          {
+            if (parent.getMouseListeners().length > 0
+                || parent.getMouseMotionListeners().length > 0)
+              {
+                target = parent;
+              }
+            else
+              parent = parent.getParent();
+          }
+      }
     if (target == null || target.isLightweight())
       {
         // Dispatch additional MOUSE_EXITED and MOUSE_ENTERED if event target
@@ -138,18 +169,26 @@ class LightweightDispatcher
           {
             if (lastTarget != null)
               {
-                Point p1 = AWTUtilities.convertPoint(window, ev.getX(),
-                                                     ev.getY(), lastTarget);
+                Point p1 = convertPointToChild(window, ev.getPoint(),
+                                               lastTarget);
                 MouseEvent mouseExited =
                   new MouseEvent(lastTarget, MouseEvent.MOUSE_EXITED,
                                  ev.getWhen(), ev.getModifiers(), p1.x, p1.y,
                                  ev.getClickCount(), ev.isPopupTrigger());
                 lastTarget.dispatchEvent(mouseExited);
               }
-            if (target != null)
+            
+            // If a target exists dispatch the MOUSE_ENTERED event only if
+            // there is currently no component from which a drag operation
+            // started (dragTarget == null) or the target is that component
+            // (dragTarget == target)
+            // That way a user can click and hold on a button (putting it into
+            // the armed state), move the cursor above other buttons without
+            // affecting their rollover state and get back to the initial
+            // button.
+            if (target != null && (dragTarget == null || dragTarget == target))
               {
-                Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
-                                                    target);
+                Point p = convertPointToChild(window, ev.getPoint(), target);
                 MouseEvent mouseEntered =
                   new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
                                  ev.getModifiers(), p.x, p.y, ev.getClickCount(),
@@ -161,12 +200,30 @@ class LightweightDispatcher
         switch (ev.getID())
         {
           case MouseEvent.MOUSE_PRESSED:
-            dragTarget = target;
+            // Handle the start of a drag operation or discard the event if
+            // one is already in progress. This prevents focus changes with the
+            // other mouse buttons when one is used for dragging.
+            if (dragTarget == null)
+              {
+                lastTarget = dragTarget = target;
+                
+                // Save the button that started the drag operation.
+                dragButton = ev.getButton();
+              }
+            else
+              return false;
+            
             break;
           case MouseEvent.MOUSE_RELEASED:
-            if (dragTarget != null)
-              target = dragTarget;
-            dragTarget = null;
+            // Stop the drag operation only when the button that started
+            // it was released.
+            if (dragTarget != null && dragButton == ev.getButton())
+              {
+                target = dragTarget;
+                dragTarget = null;
+              }
+            
+            lastTarget = target;
             break;
           case MouseEvent.MOUSE_CLICKED:
             // When we receive a MOUSE_CLICKED, we set the target to the
@@ -174,27 +231,35 @@ class LightweightDispatcher
             // This is necessary for the case when the MOUSE_RELEASED has
             // caused the original target (like an internal component) go
             // away.
+            // This line is the reason why it is not possible to move the
+            // 'lastTarget = target' assignment before the switch-statement.
             target = lastTarget;
             break;
           case MouseEvent.MOUSE_DRAGGED:
+            // We consider only dragTarget for redispatching the event still
+            // we have to act in a way that the newly found target component
+            // was handled.
+            lastTarget = target;
             target = dragTarget;
             break;
           default:
-            // Do nothing in other cases.
+            // Only declare current target as the old value in all other
+            // cases.
+            lastTarget = target;
             break;
         }
 
-        lastTarget = target;
-
         if (target != null)
           {
-            Point targetCoordinates =
-              AWTUtilities.convertPoint(window, ev.getX(), ev.getY(), target);
+            Point targetCoordinates = convertPointToChild(window,
+                                                          ev.getPoint(),
+                                                          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);
@@ -209,20 +274,66 @@ class LightweightDispatcher
 
   /**
    * 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.
+   * This searches through the children of the container and finds the first
+   * one which is showing, at the location from the mouse event and has
+   * a MouseListener or MouseMotionListener attached. If no such child component
+   * is found, null is returned.
    *
-   * @param c the component to start searching from
+   * @param c the container to search through
+   * @param loc the mouse event point
    *
-   * @return the actual receiver of the mouse event
+   * @return the actual receiver of the mouse event, or null, if no such
+   *         component has been found
    */
-  private Component findTarget(Component c)
+  private Component findTarget(Container c, Point loc)
   {
-    Component target = c;
-    while (target != null && target.getMouseListeners().length == 0)
+    Component[] children = c.getComponents();
+    Component target = null;
+    if (c != null)
       {
-        target = target.getParent();
+        for (int i = 0; i < children.length; i++)
+          {
+            Component child = children[i];
+            if (child.isShowing())
+              {
+                if (child.contains(loc.x - child.getX(), loc.y - child.getY())
+                    && (child.getMouseListeners().length > 0 
+                        || child.getMouseMotionListeners().length > 0))
+                  {
+                    target = child;
+                    break;
+                  }
+              }
+          }
       }
     return target;
   }
+
+  /**
+   * Converts a point in the parent's coordinate system to a child coordinate
+   * system. The resulting point is stored in the same Point object and
+   * returned.
+   *
+   * @param parent the parent component
+   * @param p the point
+   * @param child the child component
+   *
+   * @return the translated point
+   */
+  private Point convertPointToChild(Component parent, Point p,
+                                   Component child)
+  {
+    int offX = 0;
+    int offY = 0;
+    Component comp = child;
+    while (comp != null && comp != parent)
+      {
+        offX += comp.getX();
+        offY += comp.getY();
+        comp = comp.getParent();
+      }
+    p.x -= offX;
+    p.y -= offY;
+    return p;
+  }
 }
diff --git a/libjava/classpath/java/awt/TexturePaint.java b/libjava/classpath/java/awt/TexturePaint.java
index 57d7574c3d46..387ccb0fd849 100644
--- a/libjava/classpath/java/awt/TexturePaint.java
+++ b/libjava/classpath/java/awt/TexturePaint.java
@@ -38,42 +38,81 @@ exception statement from your version. */
 
 package java.awt;
 
-import gnu.classpath.NotImplementedException;
+import gnu.java.awt.java2d.TexturePaintContext;
 
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
 
-/** STUB CLASS ONLY */
+/**
+ * This class provides a way to fill a Shape with a texture that is
+ * specified by a BufferedImage.
+ */
 public class TexturePaint implements Paint
 {
   private final BufferedImage texture;
   private final Rectangle2D anchor;
+  
+  /**
+   * Constructor.
+   * 
+   * @param texture - the texture
+   * @param anchor - the shape
+   */
   public TexturePaint(BufferedImage texture, Rectangle2D anchor)
   {
     this.texture = texture;
     this.anchor = anchor;
   }
+
+  /**
+   * Gets the texture image.
+   * 
+   * @return the texture
+   */
   public BufferedImage getImage()
   {
     return texture;
   }
+
+  /**
+   * Gets the shape anchor.
+   * 
+   * @return the shape anchor
+   */
   public Rectangle2D getAnchorRect()
   {
     return anchor;
   }
+
+  /**
+   * Creates the context used to paint the texture.
+   * 
+   * @param cm - the ColorModel that receives the Paint data. Used only as a hint.
+   * @param deviceBounds - the device space being rendered.
+   * @param userBounds - the user space being rendered
+   * @param xform - the AffineTransform from user space into device space
+   * @param hints - a RenderingHints object that is used to specify how the 
+   * pattern is rendered
+   * @return the paint context used to paint the texture
+   */
   public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
                                     Rectangle2D userBounds,
-                                    AffineTransform xform,
-                                    RenderingHints hints)
-    throws NotImplementedException
+                                    AffineTransform xform, RenderingHints hints)
   {
-    throw new Error("not implemented");
+    // TODO: Maybe add some hook for providing alternative/accelerated
+    // implementations of this.
+    return new TexturePaintContext(this, deviceBounds, userBounds, xform);
   }
+
+  /**
+   * Returns the transparency mode.
+   * 
+   * @return the transparency mode.
+   */
   public int getTransparency()
-    throws NotImplementedException
   {
-    throw new Error("not implemented");
+    return texture.getTransparency();
   }
 } // class TexturePaint
diff --git a/libjava/classpath/java/awt/Toolkit.java b/libjava/classpath/java/awt/Toolkit.java
index 16f1caf85df6..282e50d2c507 100644
--- a/libjava/classpath/java/awt/Toolkit.java
+++ b/libjava/classpath/java/awt/Toolkit.java
@@ -544,7 +544,7 @@ public abstract class Toolkit
                 return ClassLoader.getSystemClassLoader();
               }
           });
-        Class cls = cl.loadClass(toolkit_name);
+        Class cls = Class.forName(toolkit_name, true, cl);
         Object obj = cls.newInstance();
         if (!(obj instanceof Toolkit))
           throw new AWTError(toolkit_name + " is not a subclass of " +
diff --git a/libjava/classpath/java/awt/Window.java b/libjava/classpath/java/awt/Window.java
index d9e90c0ea4fc..8bc4715aed51 100644
--- a/libjava/classpath/java/awt/Window.java
+++ b/libjava/classpath/java/awt/Window.java
@@ -38,8 +38,6 @@ 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;
@@ -132,33 +130,7 @@ public class Window extends Container implements Accessible
     // cycle roots.
     focusCycleRoot = true;
     setLayout(new BorderLayout());
-
-    addWindowFocusListener (new WindowAdapter ()
-      {
-        public void windowGainedFocus (WindowEvent event)
-        {
-          if (windowFocusOwner != null)
-            {
-              // FIXME: move this section and the other similar
-              // sections in Component into a separate method.
-              EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
-              synchronized (eq)
-                {
-                  KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
-                  Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
-                  if (currentFocusOwner != null)
-                    {
-                      eq.postEvent (new FocusEvent (currentFocusOwner, FocusEvent.FOCUS_LOST,
-                                                    false, windowFocusOwner));
-                      eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED,
-                                                    false, currentFocusOwner));
-                    }
-                  else
-                    eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED, false));
-                }
-            }
-        }
-      });
+    addWindowFocusListener();
     
     GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
     graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration();
@@ -169,7 +141,68 @@ public class Window extends Container implements Accessible
     this();
     graphicsConfiguration = gc;
   }
+  
+  private void addWindowFocusListener()
+  {
+    addWindowFocusListener(new WindowAdapter()
+    {
+      public void windowGainedFocus(WindowEvent event)
+      {
+        EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+        if (windowFocusOwner != null)
+          {
+            synchronized (eq)
+              {
+                KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+                Component currentFocusOwner = manager.getGlobalPermanentFocusOwner();
+                if (currentFocusOwner != null)
+                  {
+                    eq.postEvent(new FocusEvent(currentFocusOwner,
+                                                FocusEvent.FOCUS_LOST, false,
+                                                windowFocusOwner));
+                    eq.postEvent(new FocusEvent(windowFocusOwner,
+                                                FocusEvent.FOCUS_GAINED, false,
+                                                currentFocusOwner));
+                  }
+                else
+                  eq.postEvent(new FocusEvent(windowFocusOwner,
+                                              FocusEvent.FOCUS_GAINED, false));
+              }
+          }
+        else
+          eq.postEvent(new FocusEvent(Window.this, FocusEvent.FOCUS_GAINED,
+                                      false));
+      }
 
+      public void windowLostFocus(WindowEvent event)
+      {
+        EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+        if (windowFocusOwner != null)
+          {
+            synchronized (eq)
+              {
+                KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+                Component currentFocusOwner = manager.getGlobalPermanentFocusOwner();
+                if (currentFocusOwner != null)
+                  {
+                    eq.postEvent(new FocusEvent(currentFocusOwner,
+                                                FocusEvent.FOCUS_GAINED, false,
+                                                windowFocusOwner));
+                    eq.postEvent(new FocusEvent(windowFocusOwner,
+                                                FocusEvent.FOCUS_LOST, false,
+                                                currentFocusOwner));
+                  }
+                else
+                  eq.postEvent(new FocusEvent(windowFocusOwner,
+                                              FocusEvent.FOCUS_LOST, false));
+              }
+          }
+        else
+          eq.postEvent(new FocusEvent(Window.this, FocusEvent.FOCUS_LOST, false));
+      }
+    });
+  }
+  
   /**
    * Initializes a new instance of <code>Window</code> with the specified
    * parent.  The window will initially be invisible.
@@ -1046,12 +1079,11 @@ public class Window extends Container implements Accessible
   /**
    * @since 1.2
    *
-   * @deprecated
+   * @deprecated replaced by Component.applyComponentOrientation.
    */
   public void applyResourceBundle(ResourceBundle rb)
-    throws NotImplementedException
   {
-    throw new Error ("Not implemented");
+    applyComponentOrientation(ComponentOrientation.getOrientation(rb));
   }
 
   /**
diff --git a/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java b/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
index 37fde9178365..145a24a38508 100644
--- a/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
+++ b/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
@@ -1,5 +1,5 @@
 /* DragGestureRecognizer.java --
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002,2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -130,7 +130,7 @@ public abstract class DragGestureRecognizer implements Serializable
   public void resetRecognizer()
     throws NotImplementedException
   {
-    throw new Error("not implemented");
+    events = new ArrayList();
   }
 
   /**
@@ -154,10 +154,15 @@ public abstract class DragGestureRecognizer implements Serializable
     dragGestureListener = null;
   }
 
+  /**
+   * Fires a <code>DragGestureEvent</code> to the DragGestureListener
+   * associated with this object, if there is one.
+   */
   protected void fireDragGestureRecognized(int dragAction, Point p)
-    throws NotImplementedException
   {
-    throw new Error("not implemented");
+    if(dragGestureListener != null)
+      dragGestureListener.dragGestureRecognized
+	(new DragGestureEvent(this, dragAction, p, events));
   }
 
   protected void appendEvent(InputEvent e)
diff --git a/libjava/classpath/java/awt/font/GlyphMetrics.java b/libjava/classpath/java/awt/font/GlyphMetrics.java
index 18aaedc71857..0a78d3052f66 100644
--- a/libjava/classpath/java/awt/font/GlyphMetrics.java
+++ b/libjava/classpath/java/awt/font/GlyphMetrics.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package java.awt.font;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.geom.Rectangle2D;
 
 /**
@@ -94,16 +92,18 @@ public final class GlyphMetrics
     return bounds;
   }
 
-  public float getLSB ()
-    throws NotImplementedException
+  public float getLSB()
   {
-    throw new Error ("not implemented");
+    if (horizontal)
+      return (float) bounds.getX();
+    return (float) bounds.getY();
   }
 
-  public float getRSB ()
-   throws NotImplementedException
+  public float getRSB()
   {
-    throw new Error ("not implemented");
+    if (horizontal)
+      return (float) (advanceX - (bounds.getX() + bounds.getWidth()));
+    return (float) (advanceY - (bounds.getY() + bounds.getHeight()));
   }
 
   public int getType ()
diff --git a/libjava/classpath/java/awt/font/GlyphVector.java b/libjava/classpath/java/awt/font/GlyphVector.java
index 8d8a51d6877d..f4cb01b95349 100644
--- a/libjava/classpath/java/awt/font/GlyphVector.java
+++ b/libjava/classpath/java/awt/font/GlyphVector.java
@@ -38,8 +38,6 @@ 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;
@@ -48,6 +46,7 @@ import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 
 /**
+ * @author Lillian Angel (langel at redhat dot com)
  * @author Michael Koch
  */
 public abstract class GlyphVector implements Cloneable
@@ -72,16 +71,22 @@ public abstract class GlyphVector implements Cloneable
   public abstract FontRenderContext getFontRenderContext ();
     
   public int getGlyphCharIndex (int glyphIndex)
-    throws NotImplementedException
   {
-    throw new Error ("not implemented");
+    return glyphIndex;
   }
     
-  public int[] getGlyphCharIndices (int beginGlyphIndex, int numEntries,
-                                    int[] codeReturn)
-    throws NotImplementedException
+  public int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries,
+                                   int[] codeReturn)
   {
-    throw new Error ("not implemented");
+    if (codeReturn == null)
+      codeReturn = new int[numEntries];
+
+    int i = 0;
+    int j = beginGlyphIndex;
+    while (j < numEntries)
+      codeReturn[i++] = getGlyphCharIndex(j++);
+    
+    return codeReturn;
   }
     
   public abstract int getGlyphCode (int glyphIndex);
@@ -98,17 +103,27 @@ public abstract class GlyphVector implements Cloneable
 
   public abstract Shape getGlyphOutline (int glyphIndex);
 
-  public Shape getGlyphOutline (int glyphIndex, float x, float y)
-    throws NotImplementedException
+  public Shape getGlyphOutline(int glyphIndex, float x, float y)
   {
-    throw new Error ("not implemented");
+    Shape s = getGlyphOutline(glyphIndex);
+    
+    // This is the only way to translate the origin of a shape
+    AffineTransform at = AffineTransform.getTranslateInstance(x, y);
+    return at.createTransformedShape(s);
   }
 
-  public Rectangle getGlyphPixelBounds (int index, FontRenderContext renderFRC,
-                                        float x, float y)
-    throws NotImplementedException
+  public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC,
+                                       float x, float y)
   {
-    throw new Error ("not implemented");
+    Rectangle bounds = new Rectangle();
+    Rectangle2D rect = getGlyphVisualBounds(index).getBounds2D();
+    
+    bounds.x = (int) (rect.getX() + x);
+    bounds.y = (int) (rect.getY() + y);
+    bounds.width = (int) rect.getMaxX() - bounds.x;
+    bounds.height = (int) rect.getMaxY() - bounds.y;
+    
+    return bounds;
   }
 
   public abstract Point2D getGlyphPosition (int glyphIndex);
@@ -121,10 +136,9 @@ public abstract class GlyphVector implements Cloneable
 
   public abstract Shape getGlyphVisualBounds (int glyphIndex);
 
-  public int getLayoutFlags ()
-    throws NotImplementedException
+  public int getLayoutFlags()
   {
-    throw new Error ("not implemented");
+    return 0;
   }
 
   public abstract Rectangle2D getLogicalBounds ();
@@ -137,9 +151,16 @@ public abstract class GlyphVector implements Cloneable
 
   public Rectangle getPixelBounds (FontRenderContext renderFRC,
                                    float x, float y)
-    throws NotImplementedException
   {
-    throw new Error ("not implemented");
+    Rectangle bounds = new Rectangle();
+    Rectangle2D rect = getVisualBounds();
+    
+    bounds.x = (int) (rect.getX() + x);
+    bounds.y = (int) (rect.getY() + y);
+    bounds.width = (int) rect.getMaxX() - bounds.x;
+    bounds.height = (int) rect.getMaxY() - bounds.y;
+    
+    return bounds;
   }
 
   public abstract Rectangle2D getVisualBounds ();
diff --git a/libjava/classpath/java/awt/font/GraphicAttribute.java b/libjava/classpath/java/awt/font/GraphicAttribute.java
index 107f16dcd180..19f781bcc29a 100644
--- a/libjava/classpath/java/awt/font/GraphicAttribute.java
+++ b/libjava/classpath/java/awt/font/GraphicAttribute.java
@@ -38,51 +38,100 @@ exception statement from your version. */
 
 package java.awt.font;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Graphics2D;
 import java.awt.geom.Rectangle2D;
 
 /**
+ * This class represents a graphic embedded in text.
+ * 
  * @author Michael Koch
+ * @author Lillian Angel (langel at redhat dot com)
  */
 public abstract class GraphicAttribute
 {
-  public static final int BOTTOM_ALIGNMENT = -2;
+  public static final int BOTTOM_ALIGNMENT = - 2;
   public static final int CENTER_BASELINE = 1;
   public static final int HANGING_BASELINE = 2;
   public static final int ROMAN_BASELINE = 0;
-  public static final int TOP_ALIGNMENT = -1;
+  public static final int TOP_ALIGNMENT = - 1;
 
   private int alignment;
-  
-  protected GraphicAttribute (int alignment)
+
+  /**
+   * Constructor.
+   * 
+   * @param alignment - the alignment to use for the graphic
+   */
+  protected GraphicAttribute(int alignment)
   {
+    if (alignment < BOTTOM_ALIGNMENT || alignment > HANGING_BASELINE)
+      throw new IllegalArgumentException("Invalid alignment");
     this.alignment = alignment;
   }
 
-  public abstract void draw (Graphics2D graphics, float x, float y);
-
-  public abstract float getAdvance ();
-
-  public final int getAlignment ()
+  /**
+   * Draws the graphic.
+   * 
+   * @param graphics - the graphics configuration to use
+   * @param x - the x location
+   * @param y - the y location
+   */
+  public abstract void draw(Graphics2D graphics, float x, float y);
+
+  /**
+   * Gets the distance from the origin of its graphic to the right side of the
+   * bounds of its graphic.
+   * 
+   * @return the advance
+   */
+  public abstract float getAdvance();
+
+  /**
+   * Gets the positive distance from the origin of its graphic to the top of
+   * bounds.
+   * 
+   * @return the ascent
+   */
+  public abstract float getAscent();
+
+  /**
+   * Gets the distance from the origin of its graphic to the bottom of the bounds.
+   * 
+   * @return the descent
+   */
+  public abstract float getDescent();
+
+  /**
+   * Gets the alignment.
+   * 
+   * @return the alignment
+   */
+  public final int getAlignment()
   {
     return alignment;
   }
 
-  public abstract float getAscent ();
-
-  public Rectangle2D getBounds ()
-    throws NotImplementedException
+  /**
+   * Returns a Rectangle2D that encloses the rendered area.
+   * Default bounds is the rectangle (0, -ascent, advance, ascent+descent).
+   * 
+   * @return the bounds of the rendered area
+   */
+  public Rectangle2D getBounds()
   {
-    throw new Error ("not implemented");
+    float asc = getAscent();
+    return new Rectangle2D.Float(0, - asc, getAdvance(), asc + getDescent());
   }
 
-  public abstract float getDescent ();
-
-  public GlyphJustificationInfo getJustificationInfo ()
-    throws NotImplementedException
+  /**
+   * Returns the justification information for this object.
+   * 
+   * @return the justification information
+   */
+  public GlyphJustificationInfo getJustificationInfo()
   {
-    throw new Error ("not implemented");
+    float adv = getAdvance();
+    return new GlyphJustificationInfo(adv, false, 2, adv / 3, adv / 3, false,
+                                      1, 0, 0);
   }
 }
diff --git a/libjava/classpath/java/awt/font/ImageGraphicAttribute.java b/libjava/classpath/java/awt/font/ImageGraphicAttribute.java
index c050255ee976..3e4fdcf733fe 100644
--- a/libjava/classpath/java/awt/font/ImageGraphicAttribute.java
+++ b/libjava/classpath/java/awt/font/ImageGraphicAttribute.java
@@ -38,82 +38,150 @@ 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;
 
 /**
+ * This is an implementation of GraphicAttribute which draws images in a
+ * TextLayout.
+ * 
+ * @author Lillian Angel
  * @author Michael Koch
  */
-public final class ImageGraphicAttribute extends GraphicAttribute
+public final class ImageGraphicAttribute
+    extends GraphicAttribute
 {
   private Image image;
-  
-  public ImageGraphicAttribute (Image image, int alignment)
+  private float originX;
+  private float originY;
+
+  /**
+   * Constucts an instance from the specified Image. The origin is at (0, 0).
+   * 
+   * @param image - image to construct from.
+   * @param alignment - the alignment
+   */
+  public ImageGraphicAttribute(Image image, int alignment)
   {
-    super (alignment);
-    this.image = image;
+    this(image, alignment, 0, 0);
   }
 
-  public ImageGraphicAttribute (Image image, int alignment, float originX,
-                                float originY)
-    throws NotImplementedException
+  /**
+   * Constucts an instance from the specified Image. The origin is at (originX,
+   * originY).
+   * 
+   * @param image - image to construct from
+   * @param alignment - the alignment
+   * @param originX - x point of origin
+   * @param originY - y point of origin
+   */
+  public ImageGraphicAttribute(Image image, int alignment, float originX,
+                               float originY)
   {
-    super (alignment);
+    super(alignment);
     this.image = image;
-    
-    throw new Error ("not implemented");
+    this.originX = originX;
+    this.originY = originY;
   }
 
-  public void draw (Graphics2D graphics, float x, float y)
-    throws NotImplementedException
+  /**
+   * Draws the image at the specified location, relative to the
+   * origin.
+   * 
+   * @param g - the graphics to use to render the image
+   * @param x - the x location
+   * @param y - the y location 
+   */
+  public void draw(Graphics2D g, float x, float y)
   {
-    throw new Error ("not implemented");
+    g.drawImage(image, (int) (x - originX), (int) (y - originY), null);
   }
 
-  public boolean equals (Object obj)
+  /**
+   * Compares this to the specified Object
+   * 
+   * @param obj - the object to compare
+   * @return true if the obj and this are equivalent
+   */
+  public boolean equals(Object obj)
   {
     if (! (obj instanceof ImageGraphicAttribute))
       return false;
 
-    return equals ((ImageGraphicAttribute) obj);
+    return equals((ImageGraphicAttribute) obj);
   }
 
-  public boolean equals (ImageGraphicAttribute rhs)
-    throws NotImplementedException
+  /**
+   * Compares this to the ImageGraphicAttribute given, by
+   * comparing all fields and values.
+   * 
+   * @param rhs - the ImageGraphicAttribute to compare
+   * @return true if the object given is equivalent to this
+   */
+  public boolean equals(ImageGraphicAttribute rhs)
   {
-    throw new Error ("not implemented");
+    return ((this == rhs) || ((this.getAscent() == rhs.getAscent())
+                              && (this.getAdvance() == rhs.getAdvance())
+                              && (this.getAlignment() == rhs.getAlignment())
+                              && (this.getBounds().equals(rhs.getBounds()))
+                              && (this.getDescent() == rhs.getDescent())
+                              && (this.hashCode() == rhs.hashCode())
+                              && (this.image.equals(rhs.image))
+                              && (this.originX == rhs.originX) 
+                              && (this.originY == rhs.originY)));
   }
 
-  public float getAdvance ()
-    throws NotImplementedException
+  /**
+   * Returns distance from the origin to the right edge of the image of this.
+   * 
+   * @return the advance
+   */
+  public float getAdvance()
   {
-    throw new Error ("not implemented");
+    return Math.max(0, image.getWidth(null) - originX);
   }
 
-  public float getAscent ()
-    throws NotImplementedException
+  /**
+   * Returns the the distance from the top of the image to the origin of this.
+   * 
+   * @return the ascent.
+   */
+  public float getAscent()
   {
-    throw new Error ("not implemented");
+    return Math.max(0, originY);
   }
 
-  public Rectangle2D getBounds ()
-    throws NotImplementedException
+  /**
+   * Gets the bounds of the object rendered, relative to the position.
+   * 
+   * @return the bounds of the object rendered, relative to the position.
+   */
+  public Rectangle2D getBounds()
   {
-    throw new Error ("not implemented");
+    // This is equivalent to what Sun's JDK returns.
+    // I am not entirely sure why the origin is negative.
+    return new Rectangle2D.Float(- originX, - originY, image.getWidth(null),
+                                 image.getHeight(null));
   }
 
-  public float getDescent ()
-    throws NotImplementedException
+  /**
+   * Returns the distance from the origin to the bottom of the image.
+   * 
+   * @return the descent
+   */
+  public float getDescent()
   {
-    throw new Error ("not implemented");
+    return Math.max(0, image.getHeight(null) - originY);
   }
 
-  public int hashCode ()
-    throws NotImplementedException
+  /**
+   * Gets the hash code for this image.
+   * 
+   * @return the hash code
+   */
+  public int hashCode()
   {
-    throw new Error ("not implemented");
+    return image.hashCode();
   }
 }
diff --git a/libjava/classpath/java/awt/font/ShapeGraphicAttribute.java b/libjava/classpath/java/awt/font/ShapeGraphicAttribute.java
index d5320854c385..06814972b068 100644
--- a/libjava/classpath/java/awt/font/ShapeGraphicAttribute.java
+++ b/libjava/classpath/java/awt/font/ShapeGraphicAttribute.java
@@ -38,74 +38,148 @@ 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;
 
+/**
+ * This is an implementation of GraphicAttribute that draws shapes in a TextLayout.
+ * 
+ * @author Lillian Angel (langel at redhat dot com)
+ */
 public final class ShapeGraphicAttribute extends GraphicAttribute
 {
+  /** True if the shape should be filled. */
   public static final boolean FILL = false;
+  
+  /** True if the shape should be stroked with a 1-pixel wide stroke. */
   public static final boolean STROKE = true;
 
   private Shape shape;
   private boolean stroke;
+  private Rectangle2D bounds;
   
-  public ShapeGraphicAttribute (Shape shape, int alignment, boolean stroke)
+  /**
+   * Constructor.
+   * 
+   * @param shape - the Shape to render. The Shape is rendered with its origin.
+   * @param alignment - the alignment
+   * @param stroke - true if the Shape should be stroked; false if the Shape
+   *          should be filled.
+   */
+  public ShapeGraphicAttribute(Shape shape, int alignment, boolean stroke)
   {
-    super (alignment);
+    super(alignment);
     this.shape = shape;
     this.stroke = stroke;
+    this.bounds = shape.getBounds2D();
   }
 
-  public void draw (Graphics2D graphics, float x, float y)
-    throws NotImplementedException
+  /**
+   * Draws the graphic at the given location.
+   * 
+   * @param graphics - the graphics to use.
+   * @param x - the x location to draw at.
+   * @param y - the y location to draw at.
+   */
+  public void draw(Graphics2D graphics, float x, float y)
   {
-    throw new Error ("not implemented");
+    graphics.translate(x, y);
+    if (stroke == STROKE)
+      graphics.draw(shape);
+    else
+      graphics.fill(shape);
+    graphics.translate(- x, - y);
   }
 
-  public boolean equals (Object obj)
+  /**
+   * Compares this ShapeGraphicAttribute to obj.
+   * 
+   * @param obj - the object to compare.
+   */
+  public boolean equals(Object obj)
   {
     if (! (obj instanceof ShapeGraphicAttribute))
       return false;
 
-    return equals ((ShapeGraphicAttribute) obj);
+    return equals((ShapeGraphicAttribute) obj);
   }
 
-  public boolean equals (ShapeGraphicAttribute rhs)
+  /**
+   * Compares this ShapeGraphicAttribute to rhs.
+   * 
+   * @param rhs - the ShapeGraphicAttribute to compare.
+   */
+  public boolean equals(ShapeGraphicAttribute rhs)
   {
-    return (shape.equals (rhs.shape)
-            && getAlignment () == rhs.getAlignment ()
-            && stroke == rhs.stroke);
+    return (this == rhs || (this.shape.equals(rhs.shape)
+                            && getAlignment() == rhs.getAlignment()
+                            && stroke == rhs.stroke
+                            && getAdvance() == rhs.getAdvance()
+                            && getAscent() == rhs.getAscent()
+                            && getBounds().equals(rhs.getBounds())
+                            && getDescent() == rhs.getDescent() 
+                            && hashCode() == rhs.hashCode()));
   }
 
-  public float getAdvance ()
-    throws NotImplementedException
+  /**
+   * Gets the distance from the origin of its Shape to the right side of the
+   * bounds of its Shape.
+   * 
+   * @return the advance
+   */
+  public float getAdvance()
   {
-    throw new Error ("not implemented");
+    return Math.max(0, (float) bounds.getMaxX());
   }
 
-  public float getAscent ()
-    throws NotImplementedException
+  /**
+   * Gets the positive distance from the origin of its Shape to the top of
+   * bounds.
+   * 
+   * @return the ascent
+   */
+  public float getAscent()
   {
-    throw new Error ("not implemented");
+    return Math.max(0, -(float) bounds.getMinY());
   }
 
-  public Rectangle2D getBounds ()
+  /**
+   * Gets the distance from the origin of its Shape to the bottom of the bounds.
+   * 
+   * @return the descent
+   */
+  public float getDescent()
   {
-    return shape.getBounds2D ();
+    return Math.max(0, (float) bounds.getMaxY());
   }
 
-  public float getDescent ()
-    throws NotImplementedException
+  /**
+   * Returns a Rectangle2D that encloses all of the bits drawn by this shape.
+   * 
+   * @return the bounds of the shape.
+   */
+  public Rectangle2D getBounds()
   {
-    throw new Error ("not implemented");
+    Rectangle2D.Float bounds = new Rectangle2D.Float();
+    bounds.setRect(this.bounds);
+
+    if (stroke == STROKE)
+      {
+        bounds.width++;
+        bounds.height++;
+      }
+    
+    return bounds;
   }
 
-  public int hashCode ()
+  /**
+   * Gets the hash code.
+   * 
+   * @return the hash code.
+   */
+  public int hashCode()
   {
-    // FIXME: Check what SUN does here
-    return shape.hashCode ();
+    return shape.hashCode();
   }
 }
diff --git a/libjava/classpath/java/awt/im/InputContext.java b/libjava/classpath/java/awt/im/InputContext.java
index 0bb107e36d19..3806736df3d4 100644
--- a/libjava/classpath/java/awt/im/InputContext.java
+++ b/libjava/classpath/java/awt/im/InputContext.java
@@ -103,8 +103,8 @@ public class InputContext
     while (e.hasMoreElements())
       {
         URL url = (URL) e.nextElement();
-        BufferedReader in = null;
-        String line = null;
+        BufferedReader in;
+        String line;
         try
           {
             in = new BufferedReader
diff --git a/libjava/classpath/java/awt/image/BufferedImage.java b/libjava/classpath/java/awt/image/BufferedImage.java
index 3cabfbde6926..16b0143850cd 100644
--- a/libjava/classpath/java/awt/image/BufferedImage.java
+++ b/libjava/classpath/java/awt/image/BufferedImage.java
@@ -80,7 +80,7 @@ public class BufferedImage extends Image
                           TYPE_BYTE_INDEXED   = 13;
   
   static final int[] bits3 = { 8, 8, 8 };
-  static final int[] bits4 = { 8, 8, 8 };
+  static final int[] bits4 = { 8, 8, 8, 8 };
   static final int[] bits1byte = { 8 };
   static final int[] bits1ushort = { 16 };
   
diff --git a/libjava/classpath/java/awt/image/ColorModel.java b/libjava/classpath/java/awt/image/ColorModel.java
index 40307f2b95d9..e2f5378b4da8 100644
--- a/libjava/classpath/java/awt/image/ColorModel.java
+++ b/libjava/classpath/java/awt/image/ColorModel.java
@@ -92,7 +92,12 @@ public abstract class ColorModel implements Transparency
   int transparency;
   boolean hasAlpha;
   boolean isAlphaPremultiplied;
-    
+
+  /**
+   * The standard color model for the common sRGB.
+   */
+  private static final ColorModel S_RGB_MODEL = new SRGBColorModel();
+
   static int[] nArray(int value, int times)
   {
     int[] array = new int[times];
@@ -196,7 +201,7 @@ public abstract class ColorModel implements Transparency
    */
   public static ColorModel getRGBdefault()
   {
-    return new DirectColorModel(32, 0xff0000, 0xff00, 0xff, 0xff000000);
+    return S_RGB_MODEL;
   }
 
   public final boolean hasAlpha()
@@ -761,4 +766,56 @@ public abstract class ColorModel implements Transparency
   {
     return getClass().getName() + "[" + stringParam() + "]";
   }
+
+  /**
+   * A color model optimized for standard sRGB.
+   */
+  private static class SRGBColorModel
+    extends DirectColorModel
+  {
+    
+    SRGBColorModel()
+    {
+      super(32,0x00FF0000,0x0000FF00,0x000000FF,0xFF000000);
+    }
+
+    public int getAlpha(Object inData)
+    {
+      return ((((int[]) inData)[0]) >> 24) & 0xFF;
+    }
+
+    public int getBlue(Object inData)
+    {
+      return ((((int[]) inData)[0])) & 0xFF;
+    }
+
+    public int getGreen(Object inData)
+    {
+      return ((((int[]) inData)[0]) >>  8) & 0xFF;
+    }
+
+    public int getRed(Object inData)
+    {
+      return ((((int[]) inData)[0]) >> 16) & 0xFF;
+    }
+
+    public int getRGB(Object inData)
+    {
+      return ((int[]) inData)[0];
+    }
+
+    public Object getDataElements(int rgb, Object pixel)
+    {
+      if(pixel == null)
+        {
+          pixel = new int[]{rgb};  
+        }
+      else
+        {
+          ((int[]) pixel)[0] = rgb;  
+        }
+      
+      return pixel;
+    }
+  }
 }
diff --git a/libjava/classpath/java/awt/print/PrinterJob.java b/libjava/classpath/java/awt/print/PrinterJob.java
index 7f67a6b048bd..8afada1675e4 100644
--- a/libjava/classpath/java/awt/print/PrinterJob.java
+++ b/libjava/classpath/java/awt/print/PrinterJob.java
@@ -38,9 +38,13 @@ exception statement from your version. */
 
 package java.awt.print;
 
-import java.awt.HeadlessException;
+import gnu.java.awt.print.JavaPrinterJob;
 
+import java.awt.HeadlessException;
 import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.DocFlavor;
+import javax.print.StreamPrintServiceFactory;
 import javax.print.attribute.PrintRequestAttributeSet;
 
 /**
@@ -60,8 +64,7 @@ public abstract class PrinterJob
    */
   public static PrinterJob getPrinterJob()
   {
-    // FIXME: Need to fix this to load a default implementation instance.
-    return new NoPrinterJob();
+    return new JavaPrinterJob();
   }
 
   /**
@@ -244,13 +247,11 @@ public abstract class PrinterJob
    */
   public static PrintService[] lookupPrintServices()
   {
-    return new PrintService[0];
-    // FIXME:
-    // Enable this when javax.print has this implemented.
-//    return PrintServiceLookup.lookupPrintServices(
-//          new DocFlavor("application/x-java-jvm-local-objectref",
-//                        "java.awt.print.Pageable"),
-//          null);
+    return PrintServiceLookup.lookupPrintServices
+      (
+       new DocFlavor("application/x-java-jvm-local-objectref",
+		     "java.awt.print.Pageable"),
+       null);
   }
 
   /**
@@ -263,8 +264,8 @@ public abstract class PrinterJob
    * @return Array of stream print services, could be empty.
    * @since 1.4
    */
-  	// FIXME:
-  	// Enable when javax.print has StreamPrintServiceFactory 
+  // FIXME:
+  // Enable when StreamPrintServiceFactory has lookupStreamServiceFactories
 //  public static StreamPrintServiceFactory[] lookupStreamPrintServices(String mimeType)
 //  {
 //    return StreamPrintServiceFactory.lookupStreamServiceFactories(
@@ -282,7 +283,7 @@ public abstract class PrinterJob
    */
   public PrintService getPrintService()
   {
-    return null;
+    return printer;
   }
 
   /**
@@ -297,6 +298,6 @@ public abstract class PrinterJob
   public void setPrintService(PrintService service)
     throws PrinterException
   {
-    throw new PrinterException();
+    printer = service;
   }
 }
diff --git a/libjava/classpath/java/text/NumberFormat.java b/libjava/classpath/java/text/NumberFormat.java
index 5fede9ee37a7..a42e9b3d9c83 100644
--- a/libjava/classpath/java/text/NumberFormat.java
+++ b/libjava/classpath/java/text/NumberFormat.java
@@ -481,7 +481,7 @@ public abstract class NumberFormat extends Format implements Cloneable
    */
   public static NumberFormat getIntegerInstance(Locale locale)
   {
-    NumberFormat format = computeInstance (locale, "numberFormat", "#,##0");
+    NumberFormat format = computeInstance (locale, "integerFormat", "#,##0");
     format.setMaximumFractionDigits(0);
     format.setParseIntegerOnly (true);
     return format;
diff --git a/libjava/classpath/java/text/SimpleDateFormat.java b/libjava/classpath/java/text/SimpleDateFormat.java
index 00c08507e811..2825c7bed24f 100644
--- a/libjava/classpath/java/text/SimpleDateFormat.java
+++ b/libjava/classpath/java/text/SimpleDateFormat.java
@@ -307,7 +307,7 @@ public class SimpleDateFormat extends DateFormat
 		// Not a valid letter
 		throw new IllegalArgumentException("Invalid letter "
 						   + thisChar +
-						   "encountered at character "
+						   " encountered at character "
 						   + i + ".");
 	      }
 	    else if (thisChar == '\'')
diff --git a/libjava/classpath/java/text/class-dependencies.conf b/libjava/classpath/java/text/class-dependencies.conf
new file mode 100644
index 000000000000..011b146ce10a
--- /dev/null
+++ b/libjava/classpath/java/text/class-dependencies.conf
@@ -0,0 +1,220 @@
+# 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
+
+# All locales supported are loaded via classes from java.text (see below)
+# from class gnu/java/locale/LocaleInformation_<locale_id>
+#
+# This introduces a dependency for all locales. To allow an easy selection
+# and addition of locales, the library variable {text_locales} can be set to 
+# the set of supported locales.
+#
+
+{text_locales}: \
+	af_ZA \
+	ar_AE \
+	ar_BH \
+	ar_DZ \
+	ar_EG \
+	ar_IN \
+	ar_IQ \
+	ar_JO \
+	ar_KW \
+	ar_LB \
+	ar_LY \
+	ar_MA \
+	ar_OM \
+	ar_QA \
+	ar_SD \
+	ar_SY \
+	ar_TN \
+	ar_YE \
+	be_BY \
+	bn_IN \
+	br_FR \
+	bs_BA \
+	ca_ES \
+	cs_CZ \
+	cy_GB \
+	da_DK \
+	de \
+	de_AT \
+	de_BE \
+	de_CH \
+	de_DE \
+	de_LU \
+	el_GR \
+	en \
+	en_AU \
+	en_BW \
+	en_CA \
+	en_DK \
+	en_GB \
+	en_HK \
+	en_IE \
+	en_IN \
+	en_NZ \
+	en_PH \
+	en_SG \
+	en_US \
+	en_ZA \
+	en_ZW \
+	es_AR \
+	es_BO \
+	es_CL \
+	es_CO \
+	es_CR \
+	es_DO \
+	es_EC \
+	es_ES \
+	es_GT \
+	es_HN \
+	es_MX \
+	es_NI \
+	es_PA \
+	es_PE \
+	es_PR \
+	es_PY \
+	es_SV \
+	es_US \
+	es_UY \
+	es_VE \
+	et_EE \
+	eu_ES \
+	fa_IR \
+	fi_FI \
+	fo_FO \
+	fr_BE \
+	fr_CA \
+	fr_CH \
+	fr_FR \
+	fr_LU \
+	ga_IE \
+	gd_GB \
+	gl_ES \
+	gv_GB \
+	he_IL \
+	hi_IN \
+	hr_HR \
+	hu_HU \
+	id_ID \
+	it_CH \
+	it_IT \
+	iw_IL \
+	ja_JP \
+	ka_GE \
+	kl_GL \
+	ko_KR \
+	kw_GB \
+	lt_LT \
+	lv_LV \
+	mi_NZ \
+	mk_MK \
+	mr_IN \
+	mt_MT \
+	nl \
+	nl_BE \
+	nl_NL \
+	nn_NO \
+	no_NO \
+	oc_FR \
+	pl_PL \
+	pt_BR \
+	pt_PT \
+	ro_RO \
+	ru_RU \
+	ru_UA \
+	se_NO \
+	sk_SK \
+	sl_SI \
+	sq_AL \
+	sr_YU \
+	sv_FI \
+	sv_SE \
+	ta_IN \
+	te_IN \
+	tg_TJ \
+	tl_PH \
+	tr_TR \
+	uk_UA \
+	ur_PK \
+	uz_UZ \
+	vi_VN \
+	yi_US \
+	zh_CN \
+	zh_HK \
+	zh_SG \
+	zh_TW 
+
+java/text/Collator.getInstance(Ljava/util/Locale;)Ljava/text/Collator;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/DateFormatSymbols.<init>(Ljava/util/Locale;)V: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/DecimalFormatSymbols.<init>(Ljava/util/Locale;)V: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/BreakIterator.getInstance(Ljava/lang/String;Ljava/util/Locale;)Ljava/text/BreakIterator;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/NumberFormat.computeInstance(Ljava/util/Locale;Ljava/lang/String;Ljava/lang/String;)Ljava/text/NumberFormat;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
+
+java/text/DateFormat.computeInstance(IILjava/util/Locale;ZZ)Ljava/text/DateFormat;: \
+	gnu/java/locale/LocaleInformation_{text_locales}.*
diff --git a/libjava/classpath/javax/swing/AbstractButton.java b/libjava/classpath/javax/swing/AbstractButton.java
index 348daece174e..9b2b526f30b4 100644
--- a/libjava/classpath/javax/swing/AbstractButton.java
+++ b/libjava/classpath/javax/swing/AbstractButton.java
@@ -1,5 +1,5 @@
 /* AbstractButton.java -- Provides basic button functionality.
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -274,7 +274,7 @@ public abstract class AbstractButton extends JComponent
   protected ChangeListener changeListener;
 
   /**
-   * The time in miliseconds in which clicks get coalesced into a single
+   * The time in milliseconds in which clicks get coalesced into a single
    * <code>ActionEvent</code>.
    */
   long multiClickThreshhold;
@@ -445,7 +445,7 @@ public abstract class AbstractButton extends JComponent
      * {@link AccessibleState#FOCUSED}, {@link AccessibleState#PRESSED} and
      * {@link AccessibleState#CHECKED}.
      *
-     * @return the curren state of this accessible object
+     * @return the current state of this accessible object
      */
     public AccessibleStateSet getAccessibleStateSet()
     {
@@ -651,8 +651,8 @@ public abstract class AbstractButton extends JComponent
      * Returns the minimum accessible value for the AccessibleAbstractButton,
      * which is <code>0</code>.
      *
-     * @return the maxinimum accessible value for the AccessibleAbstractButton,
-     *         which is <code>1</code>
+     * @return the minimimum accessible value for the AccessibleAbstractButton,
+     *         which is <code>0</code>
      */
     public Number getMinimumAccessibleValue()
     {
diff --git a/libjava/classpath/javax/swing/CellRendererPane.java b/libjava/classpath/javax/swing/CellRendererPane.java
index b3d6f6a7364d..764a4c500b5e 100644
--- a/libjava/classpath/javax/swing/CellRendererPane.java
+++ b/libjava/classpath/javax/swing/CellRendererPane.java
@@ -93,7 +93,7 @@ public class CellRendererPane extends Container implements Accessible
    */
   public CellRendererPane()
   {
-    // Nothing to do here.
+    setVisible(false);
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/DefaultButtonModel.java b/libjava/classpath/javax/swing/DefaultButtonModel.java
index 7ecf3b85fc68..2be18cc8aac8 100644
--- a/libjava/classpath/javax/swing/DefaultButtonModel.java
+++ b/libjava/classpath/javax/swing/DefaultButtonModel.java
@@ -1,5 +1,5 @@
 /* DefaultButtonModel.java --
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -63,7 +63,7 @@ import javax.swing.event.EventListenerList;
  * change to the "selected" property will trigger the firing of an ItemEvent
  * in addition to ChangeEvent. This is true whether the model is enabled or
  * not. One other state change is special: the transition from "enabled,
- * armed and pressd" to "enabled, armed and not-pressed". This is considered
+ * armed and pressed" to "enabled, armed and not-pressed". This is considered
  * the "trailing edge" of a successful mouse click, and therefore fires an
  * ActionEvent in addition to a ChangeEvent. In all other respects this class
  * is just a container of boolean flags.
@@ -371,7 +371,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable
     if (e)
       stateMask = stateMask | ENABLED;
     else
-      stateMask = stateMask & (~ENABLED);
+      stateMask = stateMask & (~ENABLED) & (~ARMED) & (~PRESSED);
 
     // notify interested ChangeListeners
     fireStateChanged();
@@ -555,21 +555,21 @@ public class DefaultButtonModel implements ButtonModel, Serializable
    * one model in a given group can have their "selected" property be
    * <code>true</code> at a time.
    *
-   * @param g The new "group" property
+   * @param g The new "group" property (<code>null</code> permitted).
+   * 
+   * @see #getGroup()
    */
   public void setGroup(ButtonGroup g)
   {
-    if (group != g)
-      {
-        group = g;
-        fireStateChanged();
-      }
+    group = g;
   }
 
   /**
    * Returns the current value of the model's "group" property.
    *
    * @return The value of the "group" property
+   * 
+   * @see #setGroup(ButtonGroup)
    */
   public ButtonGroup getGroup()
   {
diff --git a/libjava/classpath/javax/swing/DefaultCellEditor.java b/libjava/classpath/javax/swing/DefaultCellEditor.java
index 9c951d395302..16ed1ec6842a 100644
--- a/libjava/classpath/javax/swing/DefaultCellEditor.java
+++ b/libjava/classpath/javax/swing/DefaultCellEditor.java
@@ -313,7 +313,24 @@ public class DefaultCellEditor
     {
       JComboBox c = (JComboBox) editorComponent;
       return value = c.getSelectedItem();
-    }     
+    } 
+    
+    /**
+     * Returns true to indicate that the editing cell can be selected. If the
+     * check box is not editable, expands it. If it is editable, brings
+     * focus to the editor field.
+     * 
+     * @param event unused in default method
+     *
+     * @return true always
+     */
+    public boolean shouldSelectCell(EventObject event)
+    {
+      JComboBox c = (JComboBox) editorComponent;
+      if (!c.isEditable)
+        c.showPopup();
+      return true;
+    }    
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/DefaultDesktopManager.java b/libjava/classpath/javax/swing/DefaultDesktopManager.java
index 0304461ad4ec..11f03a715c41 100644
--- a/libjava/classpath/javax/swing/DefaultDesktopManager.java
+++ b/libjava/classpath/javax/swing/DefaultDesktopManager.java
@@ -400,8 +400,8 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
                           dragCache.width, dragCache.height);
         pane = null;
         dragCache = null;
+        component.repaint();        
       }
-    component.repaint();
   }
 
   /**
@@ -463,8 +463,8 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
                           dragCache.width, dragCache.height);
         pane = null;
         dragCache = null;
+        component.repaint();        
       }
-    component.repaint();
   }
 
   /**
@@ -481,13 +481,6 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
                                 int newWidth, int newHeight)
   {
     component.setBounds(newX, newY, newWidth, newHeight);
-    component.revalidate();
-
-    // If not null, I'd rather repaint the parent
-    if (component.getParent() != null)
-      component.getParent().repaint();
-    else
-      component.repaint();
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/JCheckBoxMenuItem.java b/libjava/classpath/javax/swing/JCheckBoxMenuItem.java
index 815244259be5..3222d189f370 100644
--- a/libjava/classpath/javax/swing/JCheckBoxMenuItem.java
+++ b/libjava/classpath/javax/swing/JCheckBoxMenuItem.java
@@ -1,5 +1,5 @@
 /* JCheckBoxMenuItem.java --
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -204,7 +204,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
   /**
     * This method overrides JComponent.requestFocus with an empty
     * implementation, since JCheckBoxMenuItems should not
-    * receve focus in general.
+    * receive focus in general.
     */
   public void requestFocus()
   {
@@ -212,16 +212,28 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
   }
 
   /**
-   * A string that describes this JCheckBoxMenuItem. Normally only used
-   * for debugging.
+   * Returns a string describing the attributes for the 
+   * <code>JCheckBoxMenuItem</code> component, for use in debugging.  The 
+   * return value is guaranteed to be non-<code>null</code>, but the format 
+   * of the string may vary between implementations.
    *
-   * @return A string describing this JCheckBoxMenuItem
+   * @return A string describing the attributes of the 
+   *     <code>JCheckBoxMenuItem</code>.
    */
   protected String paramString()
   {
-    return "JCheckBoxMenuItem";
+    // calling super seems to be sufficient to match the reference 
+    // implementation here...
+    return super.paramString();
   }
 
+  /**
+   * Returns the object that provides accessibility features for this
+   * <code>JCheckBoxMenuItem</code> component.
+   *
+   * @return The accessible context (an instance of 
+   *     {@link AccessibleJCheckBoxMenuItem}).
+   */
   public AccessibleContext getAccessibleContext()
   {
     if (accessibleContext == null)
@@ -231,20 +243,29 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
   }
 
   /**
-   * Accessibility support for <code>JCheckBoxMenuItem</code>.
+   * Provides the accessibility features for the <code>JCheckBoxMenuItem</code> 
+   * component.
+   * 
+   * @see JCheckBoxMenuItem#getAccessibleContext()
    */
   protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
   {
     private static final long serialVersionUID = 1079958073579370777L;
 
     /**
-     * Creates a new AccessibleJCheckBoxMenuItem object.
+     * Creates a new <code>AccessibleJCheckBoxMenuItem</code> instance.
      */
     protected AccessibleJCheckBoxMenuItem()
     {
       // Nothing to do here.
     }
 
+    /**
+     * Returns the accessible role for the <code>JCheckBoxMenuItem</code> 
+     * component.
+     *
+     * @return {@link AccessibleRole#CHECK_BOX}.
+     */
     public AccessibleRole getAccessibleRole()
     {
       return AccessibleRole.CHECK_BOX;
diff --git a/libjava/classpath/javax/swing/JComboBox.java b/libjava/classpath/javax/swing/JComboBox.java
index 175237a775ae..efb04592b505 100644
--- a/libjava/classpath/javax/swing/JComboBox.java
+++ b/libjava/classpath/javax/swing/JComboBox.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.ItemSelectable;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -60,6 +58,8 @@ import javax.swing.event.ListDataListener;
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
 import javax.swing.plaf.ComboBoxUI;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.ComboPopup;
 
 /**
  * A component that allows a user to select any item in its list and
@@ -675,7 +675,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
       }
     else
       throw new RuntimeException("Unable to remove the items because the data "
-                                 +"model it is not an instance of "
+                                 + "model it is not an instance of "
                                  + "MutableComboBoxModel.");
   }
 
@@ -848,7 +848,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
   {
     PopupMenuListener[] listeners = getPopupMenuListeners();
     PopupMenuEvent e = new PopupMenuEvent(this);
-    for(int i = 0; i < listeners.length; i++)
+    for (int i = 0; i < listeners.length; i++)
       listeners[i].popupMenuCanceled(e);
   }
 
@@ -862,7 +862,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
   {
     PopupMenuListener[] listeners = getPopupMenuListeners();
     PopupMenuEvent e = new PopupMenuEvent(this);
-    for(int i = 0; i < listeners.length; i++)
+    for (int i = 0; i < listeners.length; i++)
       listeners[i].popupMenuWillBecomeInvisible(e);
   }
 
@@ -876,7 +876,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
   {
     PopupMenuListener[] listeners = getPopupMenuListeners();
     PopupMenuEvent e = new PopupMenuEvent(this);
-    for(int i = 0; i < listeners.length; i++)
+    for (int i = 0; i < listeners.length; i++)
       listeners[i].popupMenuWillBecomeVisible(e);
   }
 
@@ -1246,34 +1246,102 @@ public class JComboBox extends JComponent implements ItemSelectable,
       // Nothing to do here.
     }
 
+    /**
+     * Returns the number of accessible children of this object. The
+     * implementation of AccessibleJComboBox delegates this call to the UI
+     * of the associated JComboBox.
+     *
+     * @return the number of accessible children of this object
+     *
+     * @see ComponentUI#getAccessibleChildrenCount(JComponent)
+     */
     public int getAccessibleChildrenCount()
-      throws NotImplementedException
     {
-      return 0;
+      ComponentUI ui = getUI();
+      int count;
+      if (ui != null)
+        count = ui.getAccessibleChildrenCount(JComboBox.this);
+      else
+        count = super.getAccessibleChildrenCount();
+      return count;
     }
 
-    public Accessible getAccessibleChild(int value0)
-      throws NotImplementedException
+    /**
+     * Returns the number of accessible children of this object. The
+     * implementation of AccessibleJComboBox delegates this call to the UI
+     * of the associated JComboBox.
+     *
+     * @param index the index of the accessible child to fetch
+     *
+     * @return the number of accessible children of this object
+     *
+     * @see ComponentUI#getAccessibleChild(JComponent, int)
+     */
+    public Accessible getAccessibleChild(int index)
     {
-      return null;
+      ComponentUI ui = getUI();
+      Accessible child = null;
+      if (ui != null)
+        child = ui.getAccessibleChild(JComboBox.this, index);
+      else
+        child = super.getAccessibleChild(index);
+      return child;
     }
 
+    /**
+     * Returns the AccessibleSelection object associated with this object.
+     * AccessibleJComboBoxes handle their selection themselves, so this
+     * always returns <code>this</code>.
+     *
+     * @return the AccessibleSelection object associated with this object
+     */
     public AccessibleSelection getAccessibleSelection()
-      throws NotImplementedException
     {
-      return null;
+      return this;
     }
 
-    public Accessible getAccessibleSelection(int value0)
-      throws NotImplementedException
+    /**
+     * Returns the accessible selection from this AccssibleJComboBox.
+     *
+     * @param index the index of the selected child to fetch
+     *
+     * @return the accessible selection from this AccssibleJComboBox
+     */
+    public Accessible getAccessibleSelection(int index)
     {
-      return null;
+      // Get hold of the actual popup.
+      Accessible popup = getUI().getAccessibleChild(JComboBox.this, 0);
+      Accessible selected = null;
+      if (popup != null && popup instanceof ComboPopup)
+        {
+          ComboPopup cPopup = (ComboPopup) popup;
+          // Query the list for the currently selected child.
+          JList l = cPopup.getList();
+          AccessibleContext listCtx = l.getAccessibleContext();
+          if (listCtx != null)
+            {
+              AccessibleSelection s = listCtx.getAccessibleSelection();
+              if (s != null)
+                {
+                  selected = s.getAccessibleSelection(index);
+                }
+            }
+        }
+      return selected;
     }
 
-    public boolean isAccessibleChildSelected(int value0)
-      throws NotImplementedException
+    /**
+     * Returns <code>true</code> if the accessible child with the specified
+     * <code>index</code> is selected, <code>false</code> otherwise.
+     *
+     * @param index the index of the accessible child
+     *
+     * @return <code>true</code> if the accessible child with the specified
+     *         <code>index</code> is selected, <code>false</code> otherwise
+     */
+    public boolean isAccessibleChildSelected(int index)
     {
-      return false;
+      return getSelectedIndex() == index;
     }
 
     /**
@@ -1286,58 +1354,121 @@ public class JComboBox extends JComponent implements ItemSelectable,
       return AccessibleRole.COMBO_BOX;
     }
 
+    /**
+     * Returns the accessible action associated to this accessible object.
+     * AccessibleJComboBox implements its own AccessibleAction, so this
+     * method returns <code>this</code>.
+     *
+     * @return the accessible action associated to this accessible object
+     */
     public AccessibleAction getAccessibleAction()
-      throws NotImplementedException
     {
-      return null;
+      return this;
     }
 
-    public String getAccessibleActionDescription(int value0)
-      throws NotImplementedException
+    /**
+     * Returns the description of the specified action. AccessibleJComboBox
+     * implements 1 action (toggle the popup menu) and thus returns
+     * <code>UIManager.getString("ComboBox.togglePopupText")</code>
+     *
+     * @param actionIndex the index of the action for which to return the
+     *        description
+     *
+     * @return the description of the specified action
+     */
+    public String getAccessibleActionDescription(int actionIndex)
     {
-      return null;
+      return UIManager.getString("ComboBox.togglePopupText");
     }
 
+    /**
+     * Returns the number of accessible actions that can be performed by
+     * this object. AccessibleJComboBox implement s one accessible action
+     * (toggle the popup menu), so this method always returns <code>1</code>.
+     *
+     * @return the number of accessible actions that can be performed by
+     *         this object
+     */
     public int getAccessibleActionCount()
-      throws NotImplementedException
     {
-      return 0;
+      return 1;
     }
 
-    public boolean doAccessibleAction(int value0)
-      throws NotImplementedException
+    /**
+     * Performs the accessible action with the specified index.
+     * AccessibleJComboBox has 1 accessible action
+     * (<code>actionIndex == 0</code>), which is to toggle the
+     * popup menu. All other action indices have no effect and return
+     * <code<>false</code>.
+     *
+     * @param actionIndex the index of the action to perform
+     *
+     * @return <code>true</code> if the action has been performed,
+     *         <code>false</code> otherwise
+     */
+    public boolean doAccessibleAction(int actionIndex)
     {
-      return false;
+      boolean actionPerformed = false;
+      if (actionIndex == 0)
+        {
+          setPopupVisible(! isPopupVisible());
+          actionPerformed = true;
+        }
+      return actionPerformed;
     }
 
+    /**
+     * Returns the number of selected accessible children of this object. This
+     * returns <code>1</code> if the combobox has a selected entry,
+     * <code>0</code> otherwise.
+     *
+     * @return the number of selected accessible children of this object
+     */
     public int getAccessibleSelectionCount()
-      throws NotImplementedException
     {
-      return 0;
+      Object sel = getSelectedItem();
+      int count = 0;
+      if (sel != null)
+        count = 1;
+      return count;
     }
 
-    public void addAccessibleSelection(int value0)
-      throws NotImplementedException
+    /**
+     * Sets the current selection to the specified <code>index</code>.
+     *
+     * @param index the index to set as selection
+     */
+    public void addAccessibleSelection(int index)
     {
-      // TODO: Implement this properly.
+      setSelectedIndex(index);
     }
 
-    public void removeAccessibleSelection(int value0)
-      throws NotImplementedException
+    /**
+     * Removes the specified index from the current selection.
+     *
+     * @param index the index to remove from the selection
+     */
+    public void removeAccessibleSelection(int index)
     {
-      // TODO: Implement this properly.
+      if (getSelectedIndex() == index)
+        clearAccessibleSelection();
     }
 
+    /**
+     * Clears the current selection.
+     */
     public void clearAccessibleSelection()
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      setSelectedIndex(-1);
     }
 
+    /**
+     * Multiple selection is not supported by AccessibleJComboBox, so this
+     * does nothing.
+     */
     public void selectAllAccessibleSelection()
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      // Nothing to do here.
     }
   }
 }
diff --git a/libjava/classpath/javax/swing/JComponent.java b/libjava/classpath/javax/swing/JComponent.java
index d916d05837e2..b217bc788671 100644
--- a/libjava/classpath/javax/swing/JComponent.java
+++ b/libjava/classpath/javax/swing/JComponent.java
@@ -759,13 +759,6 @@ public abstract class JComponent extends Container implements Serializable
    */
   public static final int WHEN_IN_FOCUSED_WINDOW = 2;
 
-  /**
-   * Indicates if this component is completely dirty or not. This is used
-   * by the RepaintManager's
-   * {@link RepaintManager#isCompletelyDirty(JComponent)} method.
-   */
-  boolean isCompletelyDirty = false;
-
   /**
    * Indicates if the opaque property has been set by a client program or by
    * the UI.
@@ -1763,11 +1756,6 @@ public abstract class JComponent extends Container implements Serializable
             paintComponent(g2);
             paintBorder(g2);
             paintChildren(g2);
-            Rectangle clip = g2.getClipBounds();
-            if (clip == null
-                || (clip.x == 0 && clip.y == 0 && clip.width == getWidth()
-                && clip.height == getHeight()))
-              RepaintManager.currentManager(this).markCompletelyClean(this);
           }
       }
   }
@@ -2373,6 +2361,19 @@ public abstract class JComponent extends Container implements Serializable
       }
   }
 
+  /**
+   * Returns the input map associated with this component for the given
+   * state/condition.
+   * 
+   * @param condition  the state (one of {@link #WHEN_FOCUSED}, 
+   *     {@link #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT} and 
+   *     {@link #WHEN_IN_FOCUSED_WINDOW}).
+   * 
+   * @return The input map.
+   * @throws IllegalArgumentException if <code>condition</code> is not one of 
+   *             the specified values.
+   * @since 1.3
+   */
   public final InputMap getInputMap(int condition)
   {
     enableEvents(AWTEvent.KEY_EVENT_MASK);
@@ -2395,10 +2396,20 @@ public abstract class JComponent extends Container implements Serializable
 
       case UNDEFINED_CONDITION:
       default:
-        return null;
+        throw new IllegalArgumentException("Invalid 'condition' argument: " 
+                                           + condition);
       }
   }
 
+  /**
+   * Returns the input map associated with this component for the 
+   * {@link #WHEN_FOCUSED} state.
+   * 
+   * @return The input map.
+   * 
+   * @since 1.3
+   * @see #getInputMap(int)
+   */
   public final InputMap getInputMap()
   {
     return getInputMap(WHEN_FOCUSED);
@@ -3554,6 +3565,7 @@ public abstract class JComponent extends Container implements Serializable
     Rectangle currentClip = clip;
     Component found = this;
     Container parent = this; 
+
     while (parent != null && !(parent instanceof Window))
       {
         Container newParent = parent.getParent();
@@ -3569,15 +3581,42 @@ public abstract class JComponent extends Container implements Serializable
             parent = newParent;
             continue;
           }
-        // If the parent is not optimizedDrawingEnabled, we must paint the
-        // parent.
+
+        // If the parent is not optimizedDrawingEnabled, we must check if the
+        // parent or some neighbor overlaps the current clip.
+
+        // This is the current clip converted to the parent's coordinate
+        // system. TODO: We can do this more efficiently by succesively
+        // cumulating the parent-child translations.
         Rectangle target = SwingUtilities.convertRectangle(found,
                                                            currentClip,
                                                            newParent);
-        found = newParent;
-        currentClip = target;
+
+        // We have an overlap if either:
+        // - The new parent itself doesn't completely cover the clip
+        //   (this can be the case with viewports).
+        // - If some higher-level (than the current) children of the new parent
+        //   intersect the target rectangle.
+        Rectangle parentRect = SwingUtilities.getLocalBounds(newParent);
+        boolean haveOverlap =
+          ! SwingUtilities.isRectangleContainingRectangle(parentRect, target);
+        if (! haveOverlap)
+          {
+            Component[] children = newParent.getComponents();
+            for (int i = 0; children[i] != parent && !haveOverlap; i++)
+              {
+                Rectangle childRect = children[i].getBounds();
+                haveOverlap = target.intersects(childRect);
+              }
+          }
+        if (haveOverlap)
+          {
+            found = newParent;
+            currentClip = target;
+          }
         parent = newParent;
       }
+    //System.err.println("overlapfree parent: " + found);
     return found;
   }
 
diff --git a/libjava/classpath/javax/swing/JEditorPane.java b/libjava/classpath/javax/swing/JEditorPane.java
index 73b775738de9..4ae3c5a1c6b0 100644
--- a/libjava/classpath/javax/swing/JEditorPane.java
+++ b/libjava/classpath/javax/swing/JEditorPane.java
@@ -1,5 +1,5 @@
 /* JEditorPane.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -538,8 +538,8 @@ public class JEditorPane extends JTextComponent
 
   public JEditorPane(URL url) throws IOException
   {
-    init ();
-    setEditorKit (createEditorKitForContentType("text/html"));;
+    init();
+    setEditorKit(createEditorKitForContentType("text/html"));;
     setPage(url);
   }
   
@@ -581,7 +581,7 @@ public class JEditorPane extends JTextComponent
     // TODO: Have to handle the case where a ClassLoader was specified
     // when the EditorKit was registered
     EditorKit e = null;
-    String className = (String)registerMap.get(type);
+    String className = (String) registerMap.get(type);
     if (className != null)
       {
         try
diff --git a/libjava/classpath/javax/swing/JFileChooser.java b/libjava/classpath/javax/swing/JFileChooser.java
index 7da3a132dbe4..64f9bd0f4e6c 100644
--- a/libjava/classpath/javax/swing/JFileChooser.java
+++ b/libjava/classpath/javax/swing/JFileChooser.java
@@ -1,5 +1,5 @@
 /* JFileChooser.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -37,10 +37,9 @@ exception statement from your version. */
 
 package javax.swing;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Component;
 import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
 import java.awt.HeadlessException;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -389,6 +388,13 @@ public class JFileChooser extends JComponent implements Accessible
    * @see #setSelectedFile(File)
    */
   private File selectedFile;
+  
+  /**
+   * The drag enabled property.
+   * @see #setDragEnabled(boolean)
+   * @see #getDragEnabled()
+   */
+  private boolean dragEnabled;
 
   /**
    * Creates a new <code>JFileChooser</code> object.
@@ -487,26 +493,31 @@ public class JFileChooser extends JComponent implements Accessible
   }
 
   /**
-   * DOCUMENT ME!
-   *
-   * @param b DOCUMENT ME!
+   * Sets the dragEnabled property, this disables/enables automatic drag
+   * handling (drag and drop) on this component. The default value of the
+   * dragEnabled property is false. 
+   * 
+   * Some look and feels might not support automatic drag and drop; they
+   * will ignore this property.
+   * 
+   * @param b - the new dragEnabled value
    */
   public void setDragEnabled(boolean b)
-    throws NotImplementedException
   {
-    // FIXME: Implement
+    if (b && GraphicsEnvironment.isHeadless())
+      throw new HeadlessException();
+    
+    dragEnabled = b;
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns true if dragging is enabled.
    *
-   * @return DOCUMENT ME!
+   * @return true if dragging is enabled.
    */
   public boolean getDragEnabled()
-    throws NotImplementedException
   {
-    // FIXME: Implement
-    return false;
+    return dragEnabled;
   }
 
   /**
@@ -1514,19 +1525,60 @@ public class JFileChooser extends JComponent implements Accessible
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns a string describing the attributes for the 
+   * <code>JFileChooser</code> component, for use in debugging.  The return 
+   * value is guaranteed to be non-<code>null</code>, but the format of the 
+   * string may vary between implementations.
    *
-   * @return DOCUMENT ME!
+   * @return A string describing the attributes of the 
+   *     <code>JFileChooser</code>.
    */
   protected String paramString()
   {
-    return "JFileChooser";
+    StringBuffer sb = new StringBuffer(super.paramString());
+    sb.append(",approveButtonText=");
+    if (approveButtonText != null)
+      sb.append(approveButtonText);
+    sb.append(",currentDirectory=");
+    if (currentDir != null)
+      sb.append(currentDir);
+    sb.append(",dialogTitle=");
+    if (dialogTitle != null)
+      sb.append(dialogTitle);
+    sb.append(",dialogType=");
+    if (dialogType == OPEN_DIALOG)
+      sb.append("OPEN_DIALOG");
+    if (dialogType == SAVE_DIALOG)
+      sb.append("SAVE_DIALOG");
+    if (dialogType == CUSTOM_DIALOG)
+      sb.append("CUSTOM_DIALOG");
+    sb.append(",fileSelectionMode=");
+    if (fileSelectionMode == FILES_ONLY)
+      sb.append("FILES_ONLY");
+    if (fileSelectionMode == DIRECTORIES_ONLY)
+      sb.append("DIRECTORIES_ONLY");
+    if (fileSelectionMode == FILES_AND_DIRECTORIES)
+      sb.append("FILES_AND_DIRECTORIES");
+    sb.append(",returnValue=");
+    if (retval == APPROVE_OPTION)
+      sb.append("APPROVE_OPTION");
+    if (retval == CANCEL_OPTION)
+      sb.append("CANCEL_OPTION");
+    if (retval == ERROR_OPTION)
+      sb.append("ERROR_OPTION");
+    sb.append(",selectedFile=");
+    if (selectedFile != null)
+      sb.append(selectedFile);
+    sb.append(",useFileHiding=").append(fileHiding);
+    return sb.toString();
   }
 
   /**
-   * Returns the accessible context.
+   * Returns the object that provides accessibility features for this
+   * <code>JFileChooser</code> component.
    *
-   * @return The accessible context.
+   * @return The accessible context (an instance of 
+   *     {@link AccessibleJFileChooser}).
    */
   public AccessibleContext getAccessibleContext()
   {
@@ -1536,16 +1588,26 @@ public class JFileChooser extends JComponent implements Accessible
   }
 
   /**
-   * Accessibility support for JFileChooser
+   * Provides the accessibility features for the <code>JFileChooser</code>
+   * component.
    */
   protected class AccessibleJFileChooser 
     extends JComponent.AccessibleJComponent
   {
+    /**
+     * Creates a new instance of <code>AccessibleJFileChooser</code>.
+     */
     protected AccessibleJFileChooser()
     {
       // Nothing to do here.
     }
     
+    /**
+     * Returns the accessible role for the <code>JFileChooser</code> 
+     * component.
+     *
+     * @return {@link AccessibleRole#FILE_CHOOSER}.
+     */
     public AccessibleRole getAccessibleRole()
     {
       return AccessibleRole.FILE_CHOOSER;
diff --git a/libjava/classpath/javax/swing/JFormattedTextField.java b/libjava/classpath/javax/swing/JFormattedTextField.java
index 761955d6dd91..054752550388 100644
--- a/libjava/classpath/javax/swing/JFormattedTextField.java
+++ b/libjava/classpath/javax/swing/JFormattedTextField.java
@@ -101,11 +101,11 @@ public class JFormattedTextField extends JTextField
      * @throws CloneNotSupportedException if the Object's class doesn't support
      * the {@link Cloneable} interface
      */
-    protected Object clone ()
+    protected Object clone()
       throws CloneNotSupportedException
     {
       // Clone this formatter.
-      AbstractFormatter newFormatter = (AbstractFormatter)super.clone();
+      AbstractFormatter newFormatter = (AbstractFormatter) super.clone();
       
       // And remove the association to the JFormattedTextField.
       newFormatter.textField = null;
@@ -119,7 +119,7 @@ public class JFormattedTextField extends JTextField
      * @return <code>null</code>.  Should be subclassed by formatters that want
      * to install custom Actions on the JFormattedTextField.
      */
-    protected Action[] getActions ()
+    protected Action[] getActions()
     {
       return null;
     }
@@ -132,7 +132,7 @@ public class JFormattedTextField extends JTextField
      * @return <code>null</code>.  Should be subclassed by formatters
      * that want to restrict Document mutations.
      */
-    protected DocumentFilter getDocumentFilter ()
+    protected DocumentFilter getDocumentFilter()
     {
       // Subclasses should override this if they want to install a 
       // DocumentFilter.
@@ -146,7 +146,7 @@ public class JFormattedTextField extends JTextField
      * @return the JFormattedTextField on which this formatter is currently
      * installed
      */
-    protected JFormattedTextField getFormattedTextField ()
+    protected JFormattedTextField getFormattedTextField()
     {
       return textField;
     }
@@ -159,7 +159,7 @@ public class JFormattedTextField extends JTextField
      * @return <code>null</code>.  Subclassed by formatters that want to restrict
      * cursor location within the JFormattedTextField.
      */
-    protected NavigationFilter getNavigationFilter ()
+    protected NavigationFilter getNavigationFilter()
     {
       // This should be subclassed if the formatter wants to install 
       // a NavigationFilter on the JFormattedTextField.
@@ -199,7 +199,7 @@ public class JFormattedTextField extends JTextField
             
             // Set the DocumentFilter for the field's Document.
             if (doc instanceof AbstractDocument)
-              ((AbstractDocument)doc).setDocumentFilter(getDocumentFilter());
+              ((AbstractDocument) doc).setDocumentFilter(getDocumentFilter());
             
             // Set the NavigationFilter.
             textField.setNavigationFilter(getNavigationFilter());
@@ -221,12 +221,12 @@ public class JFormattedTextField extends JTextField
      * This resets the DocumentFilter, NavigationFilter, and any additional 
      * Actions (returned by <code>getActions()</code>).     
      */
-    public void uninstall ()
+    public void uninstall()
     {
       // Set the DocumentFilter for the field's Document.
       Document doc = textField.getDocument();
       if (doc instanceof AbstractDocument)
-        ((AbstractDocument)doc).setDocumentFilter(null);
+        ((AbstractDocument) doc).setDocumentFilter(null);
       textField.setNavigationFilter(null);
       // FIXME: Have to remove the Actions from getActions()
       this.textField = null;
@@ -236,7 +236,7 @@ public class JFormattedTextField extends JTextField
      * Invoke this method when invalid values are entered.  This forwards the
      * call to the JFormattedTextField.     
      */
-    protected void invalidEdit ()
+    protected void invalidEdit()
     {
       textField.invalidEdit();
     }
@@ -247,7 +247,7 @@ public class JFormattedTextField extends JTextField
      * 
      * @param valid the new state for the <code>editValid</code> property
      */
-    protected void setEditValid (boolean valid)
+    protected void setEditValid(boolean valid)
     {
       textField.editValid = valid;
     }
@@ -259,7 +259,7 @@ public class JFormattedTextField extends JTextField
      * @return an Object that <code>text</code> represented
      * @throws ParseException if there is an error in the conversion
      */
-    public abstract Object stringToValue (String text)
+    public abstract Object stringToValue(String text)
       throws ParseException;
 
     /**
@@ -270,7 +270,7 @@ public class JFormattedTextField extends JTextField
      * @return a String to be displayed
      * @throws ParseException if there is an error in the conversion
      */
-    public abstract String valueToString (Object value)
+    public abstract String valueToString(Object value)
       throws ParseException;
   }
 
@@ -280,12 +280,12 @@ public class JFormattedTextField extends JTextField
    */
   public abstract static class AbstractFormatterFactory
   {
-    public AbstractFormatterFactory ()
+    public AbstractFormatterFactory()
     {
       // Do nothing here.
     }
 
-    public abstract AbstractFormatter getFormatter (JFormattedTextField tf);
+    public abstract AbstractFormatter getFormatter(JFormattedTextField tf);
   }
 
   /** The possible focusLostBehavior options **/
@@ -315,7 +315,7 @@ public class JFormattedTextField extends JTextField
    * properly configure this text field to edit a particular type
    * of value.
    */
-  public JFormattedTextField ()
+  public JFormattedTextField()
   {
     this((AbstractFormatterFactory) null, null);
   }
@@ -328,7 +328,7 @@ public class JFormattedTextField extends JTextField
    * @param format the Format that this JFormattedTextField should be able
    * to handle
    */
-  public JFormattedTextField (Format format)
+  public JFormattedTextField(Format format)
   {
     this ();
     setFormatterFactory(getAppropriateFormatterFactory(format));
@@ -341,9 +341,9 @@ public class JFormattedTextField extends JTextField
    * 
    * @param formatter the formatter to use for this JFormattedTextField
    */
-  public JFormattedTextField (AbstractFormatter formatter)
+  public JFormattedTextField(AbstractFormatter formatter)
   {
-    this(new DefaultFormatterFactory (formatter));
+    this(new DefaultFormatterFactory(formatter));
   }
 
   /**
@@ -351,7 +351,7 @@ public class JFormattedTextField extends JTextField
    * 
    * @param factory the formatter factory to use for this JFormattedTextField
    */
-  public JFormattedTextField (AbstractFormatterFactory factory)
+  public JFormattedTextField(AbstractFormatterFactory factory)
   {
     setFormatterFactory(factory);
   }
@@ -363,7 +363,7 @@ public class JFormattedTextField extends JTextField
    * @param factory the initial formatter factory for this JFormattedTextField
    * @param value the initial value for the text field
    */
-  public JFormattedTextField (AbstractFormatterFactory factory, Object value)
+  public JFormattedTextField(AbstractFormatterFactory factory, Object value)
   {    
     setFormatterFactory(factory);
     setValue(value);
@@ -375,7 +375,7 @@ public class JFormattedTextField extends JTextField
    * 
    * @param value the initial value for this JFormattedTextField
    */
-  public JFormattedTextField (Object value)
+  public JFormattedTextField(Object value)
   {
     setValue(value);
   }
@@ -387,13 +387,13 @@ public class JFormattedTextField extends JTextField
    * @return a DefaultFormatterFactory whose defaultFormatter is appropriate
    * for the given Format.
    */
-  private AbstractFormatterFactory getAppropriateFormatterFactory (Format format)
+  private AbstractFormatterFactory getAppropriateFormatterFactory(Format format)
   {
     AbstractFormatter newFormatter;
     if (format instanceof DateFormat)
-      newFormatter = new DateFormatter((DateFormat)format);
+      newFormatter = new DateFormatter((DateFormat) format);
     else if (format instanceof NumberFormat)
-      newFormatter = new NumberFormatter ((NumberFormat)format);
+      newFormatter = new NumberFormatter ((NumberFormat) format);
     else
       newFormatter = new InternationalFormatter(format);
     
@@ -406,7 +406,7 @@ public class JFormattedTextField extends JTextField
    * 
    * @throws ParseException if the formatter cannot format the current value
    */
-  public void commitEdit ()
+  public void commitEdit()
     throws ParseException
   {
     if (formatter == null)
@@ -427,7 +427,7 @@ public class JFormattedTextField extends JTextField
    * 
    * @return an array of Actions that this text field supports
    */
-  public Action[] getActions ()
+  public Action[] getActions()
   {
     // FIXME: Add JFormattedTextField specific actions
     // These are related to committing or cancelling edits.
@@ -449,7 +449,7 @@ public class JFormattedTextField extends JTextField
    * Returns the current formatter used for this JFormattedTextField.
    * @return the current formatter used for this JFormattedTextField
    */
-  public AbstractFormatter getFormatter ()
+  public AbstractFormatter getFormatter()
   {
     return formatter;
   }
@@ -459,12 +459,12 @@ public class JFormattedTextField extends JTextField
    * JFormattedTextField.
    * @return the factory currently used to generate formatters
    */
-  public AbstractFormatterFactory getFormatterFactory ()
+  public AbstractFormatterFactory getFormatterFactory()
   {
     return formatterFactory;
   }
 
-  public String getUIClassID ()
+  public String getUIClassID()
   {
     return "FormattedTextFieldUI";
   }
@@ -475,7 +475,7 @@ public class JFormattedTextField extends JTextField
    * valid edits and allows invalid input to be temporarily displayed.  
    * @return the last committed valid value
    */
-  public Object getValue ()
+  public Object getValue()
   {
     return value;
   }
@@ -484,7 +484,7 @@ public class JFormattedTextField extends JTextField
    * This method is used to provide feedback to the user when an invalid value
    * is input during editing.   
    */
-  protected void invalidEdit ()
+  protected void invalidEdit()
   {
     UIManager.getLookAndFeel().provideErrorFeedback(this);
   }
@@ -494,7 +494,7 @@ public class JFormattedTextField extends JTextField
    * managed by the current formatted.
    * @return true if the value being edited is valid.
    */
-  public boolean isEditValid ()
+  public boolean isEditValid()
   {
     return editValid;
   }
@@ -506,7 +506,7 @@ public class JFormattedTextField extends JTextField
    * 
    * @param evt the FocusEvent
    */
-  protected void processFocusEvent (FocusEvent evt)
+  protected void processFocusEvent(FocusEvent evt)
   {
     super.processFocusEvent(evt);
     // Let the formatterFactory change the formatter for this text field
@@ -561,7 +561,7 @@ public class JFormattedTextField extends JTextField
    * @param formatter the AbstractFormatter to use for formatting the value for
    * this JFormattedTextField
    */
-  protected void setFormatter (AbstractFormatter formatter)
+  protected void setFormatter(AbstractFormatter formatter)
   {
     AbstractFormatter oldFormatter = null;
     
@@ -585,7 +585,7 @@ public class JFormattedTextField extends JTextField
    * @param factory the AbstractFormatterFactory that will be used to generate
    * formatters for this JFormattedTextField
    */
-  public void setFormatterFactory (AbstractFormatterFactory factory)
+  public void setFormatterFactory(AbstractFormatterFactory factory)
   {
     if (formatterFactory == factory)
       return;
@@ -606,7 +606,7 @@ public class JFormattedTextField extends JTextField
    *   
    * @param newValue the value to be formatted and displayed
    */
-  public void setValue (Object newValue)
+  public void setValue(Object newValue)
   {
     if (value == newValue)
       return;
diff --git a/libjava/classpath/javax/swing/JFrame.java b/libjava/classpath/javax/swing/JFrame.java
index d2512056085e..1371525ddf2c 100644
--- a/libjava/classpath/javax/swing/JFrame.java
+++ b/libjava/classpath/javax/swing/JFrame.java
@@ -1,5 +1,5 @@
 /* JFrame.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -86,6 +86,8 @@ public class JFrame extends Frame
   /**
    * A flag for {@link #setDefaultCloseOperation(int)}, indicating that the
    * application should be exited, when this <code>JFrame</code> is closed.
+   * Note that in version 1.4, the equivalent constant has been added to
+   * {@link WindowConstants}.
    *
    * @since 1.3
    */
@@ -93,7 +95,7 @@ public class JFrame extends Frame
 
   private static final long serialVersionUID = -3362141868504252139L;
   private static boolean defaultLookAndFeelDecorated;
-  private int close_action = HIDE_ON_CLOSE;
+  private int closeAction = HIDE_ON_CLOSE;
   protected AccessibleContext accessibleContext;
   protected JRootPane rootPane;
   
@@ -102,12 +104,20 @@ public class JFrame extends Frame
    */
   protected boolean rootPaneCheckingEnabled = false;
 
+  /**
+   * Creates a new frame with an empty string for the title.
+   */
   public JFrame()
   {
-    super("JFrame");
+    super("");
     frameInit();
   }
 
+  /**
+   * Creates a new <code>JFrame</code> with the specified title.
+   * 
+   * @param title  the frame title (<code>null</code> permitted).
+   */
   public JFrame(String title)
   {
     super(title);
@@ -147,7 +157,8 @@ public class JFrame extends Frame
 
   protected void frameInit()
   {
-    super.setLayout(new BorderLayout(1, 1));
+    super.setLayout(new BorderLayout());
+    setBackground(UIManager.getDefaults().getColor("control"));
     enableEvents(AWTEvent.WINDOW_EVENT_MASK);
     getRootPane(); // will do set/create
 
@@ -289,6 +300,12 @@ public class JFrame extends Frame
     return defaultLookAndFeelDecorated;
   }
 
+  /**
+   * Returns the object that provides accessibility features for this 
+   * <code>JFrame</code>.
+   *
+   * @return The accessible context (an instance of {@link AccessibleJFrame}).
+   */
   public AccessibleContext getAccessibleContext()
   {
     if (accessibleContext == null)
@@ -296,14 +313,39 @@ public class JFrame extends Frame
     return accessibleContext;
   }
 
+  /**
+   * Returns a code for the default operation when the frame is closed.  The
+   * default value is {@link WindowConstants#HIDE_ON_CLOSE}.
+   * 
+   * @return One of: {@link WindowConstants#DO_NOTHING_ON_CLOSE},
+   *     {@link WindowConstants#HIDE_ON_CLOSE}, 
+   *     {@link WindowConstants#DISPOSE_ON_CLOSE}, {@link #EXIT_ON_CLOSE}.
+   * 
+   * @see #setDefaultCloseOperation(int)
+   */
   public int getDefaultCloseOperation()
   {
-    return close_action;
+    return closeAction;
   }
 
+  /**
+   * Returns a string describing the attributes for the <code>JFrame</code>,
+   * for use in debugging.  The return value is guaranteed to be 
+   * non-<code>null</code>, but the format may vary between implementations.
+   * 
+   * @return A string describing the attributes of the <code>JFrame</code>.
+   */
   protected String paramString()
   {
-    return "JFrame";
+    StringBuffer sb = new StringBuffer(super.paramString());
+    sb.append(",defaultCloseOperation=");
+    sb.append(SwingUtilities.convertWindowConstantToString(
+        getDefaultCloseOperation()));
+    sb.append(",rootPane=");
+    if (rootPane != null)
+      sb.append(rootPane);
+    sb.append(",rootPaneCheckingEnabled=").append(rootPaneCheckingEnabled);
+    return sb.toString();
   }
 
   protected void processWindowEvent(WindowEvent e)
@@ -313,7 +355,7 @@ public class JFrame extends Frame
       {
       case WindowEvent.WINDOW_CLOSING:
         {
-	  switch (close_action)
+	  switch (closeAction)
 	    {
 	    case EXIT_ON_CLOSE:
 	      {
@@ -346,17 +388,22 @@ public class JFrame extends Frame
   }
 
   /**
-   * Defines what happens when this frame is closed. Can be one off
-   * <code>EXIT_ON_CLOSE</code>,
-   * <code>DISPOSE_ON_CLOSE</code>,
-   * <code>HIDE_ON_CLOSE</code> or
-   * <code>DO_NOTHING_ON_CLOSE</code>.
-   * The default is <code>HIDE_ON_CLOSE</code>.
-   * When <code>EXIT_ON_CLOSE</code> is specified this method calls
+   * Sets the default operation that is performed when this frame is closed.
+   * The default is <code>HIDE_ON_CLOSE</code>.  When 
+   * <code>EXIT_ON_CLOSE</code> is specified this method calls
    * <code>SecurityManager.checkExit(0)</code> which might throw a
-   * <code>SecurityException</code>. When the specified operation is
-   * not one of the above a <code>IllegalArgumentException</code> is
-   * thrown.
+   * <code>SecurityException</code>.
+   * 
+   * @param operation  a code for the operation (one of: 
+   *     {@link WindowConstants#DO_NOTHING_ON_CLOSE}, 
+   *     {@link WindowConstants#HIDE_ON_CLOSE}, 
+   *     {@link WindowConstants#DISPOSE_ON_CLOSE} and 
+   *     {@link WindowConstants#EXIT_ON_CLOSE}).
+   * 
+   * @throws IllegalArgumentException if <code>operation</code> is not one of
+   *     the specified codes.
+   * 
+   * @see #getDefaultCloseOperation()
    */
   public void setDefaultCloseOperation(int operation)
   {
@@ -366,8 +413,9 @@ public class JFrame extends Frame
 
     if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE
         && operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE)
-      throw new IllegalArgumentException("defaultCloseOperation must be EXIT_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or DO_NOTHING_ON_CLOSE");
+      throw new IllegalArgumentException("operation must be EXIT_ON_CLOSE, " 
+          + "HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or DO_NOTHING_ON_CLOSE");
 
-    close_action = operation;
+    closeAction = operation;
   }
 }
diff --git a/libjava/classpath/javax/swing/JLabel.java b/libjava/classpath/javax/swing/JLabel.java
index a993fb8f3e0d..a5fe3ba1af0c 100644
--- a/libjava/classpath/javax/swing/JLabel.java
+++ b/libjava/classpath/javax/swing/JLabel.java
@@ -1,5 +1,5 @@
 /* JLabel.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -50,6 +50,7 @@ import java.awt.event.KeyEvent;
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleExtendedComponent;
+import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleText;
 import javax.swing.plaf.LabelUI;
 import javax.swing.text.AttributeSet;
@@ -62,12 +63,39 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
 {
 
   /**
-   * Accessibility support for JLabel.
+   * Provides the accessibility features for the <code>JLabel</code>
+   * component.
    */
   protected class AccessibleJLabel
     extends JComponent.AccessibleJComponent
     implements AccessibleText, AccessibleExtendedComponent
   {
+    
+    /**
+     * Returns the accessible name.
+     * 
+     * @return The accessible name.
+     */
+    public String getAccessibleName()
+    {
+      if (accessibleName != null)
+        return accessibleName;
+      if (text != null)
+        return text;
+      else
+        return super.getAccessibleName();
+    }
+    
+    /**
+     * Returns the accessible role for the <code>JLabel</code> component.
+     *
+     * @return {@link AccessibleRole#LABEL}.
+     */
+    public AccessibleRole getAccessibleRole()
+    {
+      return AccessibleRole.LABEL;
+    }
+    
     /**
      * Returns the selected text. This is null since JLabels
      * are not selectable.
@@ -297,7 +325,6 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
     }
   }
 
-  /** DOCUMENT ME! */
   private static final long serialVersionUID = 5496508283662221534L;
 
   static final String LABEL_PROPERTY = "labeledBy";
@@ -452,14 +479,42 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
   }
 
   /**
-   * This method is used primarily for debugging purposes and returns a string
-   * that can be used to represent this label.
+   * Returns a string describing the attributes for the <code>JLabel</code>
+   * component, for use in debugging.  The return value is guaranteed to be 
+   * non-<code>null</code>, but the format of the string may vary between
+   * implementations.
    *
-   * @return A string to represent this label.
+   * @return A string describing the attributes of the <code>JLabel</code>.
    */
   protected String paramString()
   {
-    return super.paramString();
+    StringBuffer sb = new StringBuffer(super.paramString());
+    sb.append(",defaultIcon=");
+    if (icon != null)
+      sb.append(icon);
+    sb.append(",disabledIcon=");
+    if (disabledIcon != null)
+      sb.append(disabledIcon);
+    sb.append(",horizontalAlignment=");
+    sb.append(SwingUtilities.convertHorizontalAlignmentCodeToString(
+        horizontalAlignment));
+    sb.append(",horizontalTextPosition=");
+    sb.append(SwingUtilities.convertHorizontalAlignmentCodeToString(
+        horizontalTextPosition));
+    sb.append(",iconTextGap=").append(iconTextGap);
+    sb.append(",labelFor=");
+    if (labelFor != null)
+      sb.append(labelFor);
+    sb.append(",text=");
+    if (text != null)
+      sb.append(text);
+    sb.append(",verticalAlignment=");
+    sb.append(SwingUtilities.convertVerticalAlignmentCodeToString(
+        verticalAlignment));
+    sb.append(",verticalTextPosition=");
+    sb.append(SwingUtilities.convertVerticalAlignmentCodeToString(
+        verticalTextPosition));
+    return sb.toString();
   }
 
   /**
@@ -868,24 +923,25 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
   {
     if (c != labelFor)
       {
+        Component oldLabelFor = labelFor;
+        labelFor = c;
+        firePropertyChange("labelFor", oldLabelFor, labelFor);
+
         // We put the label into the client properties for the labeled
         // component so that it can be read by the AccessibleJComponent.
         // The other option would be to reserve a default visible field
-        // in JComponent, but since this is relativly seldomly used, it
+        // in JComponent, but since this is relatively seldomly used, it
         // would be unnecessary waste of memory to do so.
-	Component oldLabelFor = labelFor;
         if (oldLabelFor instanceof JComponent)
           {
             ((JComponent) oldLabelFor).putClientProperty(LABEL_PROPERTY, null);
           }
 
-	labelFor = c;
-	if (labelFor instanceof JComponent)
+        if (labelFor instanceof JComponent)
           {
             ((JComponent) labelFor).putClientProperty(LABEL_PROPERTY, this);
           }
 
-	firePropertyChange("labelFor", oldLabelFor, labelFor);
       }
   }
 
@@ -902,9 +958,10 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns the object that provides accessibility features for this
+   * <code>JLabel</code> component.
    *
-   * @return The accessible context.
+   * @return The accessible context (an instance of {@link AccessibleJLabel}).
    */
   public AccessibleContext getAccessibleContext()
   {
diff --git a/libjava/classpath/javax/swing/JLayeredPane.java b/libjava/classpath/javax/swing/JLayeredPane.java
index f887c24506fd..11650e721d03 100644
--- a/libjava/classpath/javax/swing/JLayeredPane.java
+++ b/libjava/classpath/javax/swing/JLayeredPane.java
@@ -147,19 +147,19 @@ public class JLayeredPane extends JComponent implements Accessible
   
   public static final String LAYER_PROPERTY = "layeredContainerLayer";
 
-  public static final Integer FRAME_CONTENT_LAYER = new Integer (-30000);
+  public static final Integer FRAME_CONTENT_LAYER = new Integer(-30000);
 
-  public static final Integer DEFAULT_LAYER = new Integer (0);
-  public static final Integer PALETTE_LAYER = new Integer (100);
-  public static final Integer MODAL_LAYER   = new Integer (200);
-  public static final Integer POPUP_LAYER   = new Integer (300);
-  public static final Integer DRAG_LAYER    = new Integer (400);
+  public static final Integer DEFAULT_LAYER = new Integer(0);
+  public static final Integer PALETTE_LAYER = new Integer(100);
+  public static final Integer MODAL_LAYER   = new Integer(200);
+  public static final Integer POPUP_LAYER   = new Integer(300);
+  public static final Integer DRAG_LAYER    = new Integer(400);
 
   private Hashtable componentToLayer;   // Component -> Layer Number (Integer)
 
   public JLayeredPane()
   {
-    componentToLayer = new Hashtable ();
+    componentToLayer = new Hashtable();
     setLayout(null);
   }
 
diff --git a/libjava/classpath/javax/swing/JList.java b/libjava/classpath/javax/swing/JList.java
index 55978a4c695b..eab6be3c30c4 100644
--- a/libjava/classpath/javax/swing/JList.java
+++ b/libjava/classpath/javax/swing/JList.java
@@ -1475,19 +1475,18 @@ public class JList extends JComponent implements Accessible, Scrollable
   }
 
   /**
-   * Returns all the values in the list's {@link #model} property which
-   * are selected, according to the list's {@link #selectionModel} property.
-   *
+   * Returns all the values in the list's {@link #model} property which are
+   * selected, according to the list's {@link #selectionModel} property.
+   * 
    * @return An array containing all the selected values
-   *
    * @see #setSelectedValue
    */
   public Object[] getSelectedValues()
   {
-    int [] idx = getSelectedIndices();
-    Object [] v = new Object[idx.length];
+    int[] idx = getSelectedIndices();
+    Object[] v = new Object[idx.length];
     for (int i = 0; i < idx.length; ++i)
-      v[i] = getModel().getElementAt(i);
+      v[i] = getModel().getElementAt(idx[i]);
     return v;
   }
 
diff --git a/libjava/classpath/javax/swing/JMenu.java b/libjava/classpath/javax/swing/JMenu.java
index 37ed1485481c..02cb20eab57b 100644
--- a/libjava/classpath/javax/swing/JMenu.java
+++ b/libjava/classpath/javax/swing/JMenu.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Component;
 import java.awt.Point;
 import java.awt.event.KeyEvent;
@@ -48,6 +46,7 @@ import java.awt.event.WindowEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.EventListener;
 
 import javax.accessibility.Accessible;
@@ -811,7 +810,9 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
     return accessibleContext;
   }
 
-  // FIXME: This inner class is a complete stub and needs to be implemented.
+  /**
+   * Implements support for assisitive technologies for <code>JMenu</code>.
+   */
   protected class AccessibleJMenu extends AccessibleJMenuItem
     implements AccessibleSelection
   {
@@ -822,69 +823,245 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
       // Nothing to do here.
     }
 
+    /**
+     * Returns the number of accessible children of this object.
+     *
+     * @return the number of accessible children of this object
+     */
     public int getAccessibleChildrenCount()
-      throws NotImplementedException
     {
-      return 0;
+      Component[] children = getMenuComponents();
+      int count = 0;
+      for (int i = 0; i < children.length; i++)
+        {
+          if (children[i] instanceof Accessible)
+            count++;
+        }
+      return count;
     }
 
-    public Accessible getAccessibleChild(int value0)
-      throws NotImplementedException
+    /**
+     * Returns the accessible child with the specified <code>index</code>.
+     *
+     * @param index the index of the child to fetch
+     *
+     * @return the accessible child with the specified <code>index</code>
+     */
+    public Accessible getAccessibleChild(int index)
     {
-      return null;
+      Component[] children = getMenuComponents();
+      int count = 0;
+      Accessible found = null;
+      for (int i = 0; i < children.length; i++)
+        {
+          if (children[i] instanceof Accessible)
+            {
+              if (count == index)
+                {
+                  found = (Accessible) children[i];
+                  break;
+                }
+              count++;
+            }
+        }
+      return found;
     }
 
+    /**
+     * Returns the accessible selection of this object. AccessibleJMenus handle
+     * their selection themselves, so we always return <code>this</code> here.
+     *
+     * @return the accessible selection of this object
+     */
     public AccessibleSelection getAccessibleSelection()
-      throws NotImplementedException
     {
-      return null;
+      return this;
     }
 
-    public Accessible getAccessibleSelection(int value0)
-      throws NotImplementedException
+    /**
+     * Returns the selected accessible child with the specified
+     * <code>index</code>.
+     *
+     * @param index the index of the accessible selected child to return
+     *
+     * @return the selected accessible child with the specified
+     *         <code>index</code>
+     */
+    public Accessible getAccessibleSelection(int index)
     {
-      return null;
+      Accessible selected = null;
+      // Only one item can be selected, which must therefore have index == 0.
+      if (index == 0)
+        {
+          MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+          MenuElement[] me = msm.getSelectedPath();
+          if (me != null)
+            {
+              for (int i = 0; i < me.length; i++)
+                {
+                  if (me[i] == JMenu.this)
+                    {
+                      // This JMenu is selected, find and return the next
+                      // JMenuItem in the path.
+                      do
+                        {
+                          if (me[i] instanceof Accessible)
+                            {
+                              selected = (Accessible) me[i];
+                              break;
+                            }
+                          i++;
+                        } while (i < me.length);
+                    }
+                  if (selected != null)
+                    break;
+                }
+            }
+        }
+      return selected;
     }
 
-    public boolean isAccessibleChildSelected(int value0)
-      throws NotImplementedException
+    /**
+     * Returns <code>true</code> if the accessible child with the specified
+     * index is selected, <code>false</code> otherwise.
+     *
+     * @param index the index of the accessible child to check
+     *
+     * @return <code>true</code> if the accessible child with the specified
+     *         index is selected, <code>false</code> otherwise
+     */
+    public boolean isAccessibleChildSelected(int index)
     {
-      return false;
+      boolean selected = false;
+      MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+      MenuElement[] me = msm.getSelectedPath();
+      if (me != null)
+        {
+          Accessible toBeFound = getAccessibleChild(index);
+          for (int i = 0; i < me.length; i++)
+            {
+              if (me[i] == toBeFound)
+                {
+                  selected = true;
+                  break;
+                }
+            }
+        }
+      return selected;
     }
 
+    /**
+     * Returns the accessible role of this object, which is
+     * {@link AccessibleRole#MENU} for the AccessibleJMenu.
+     *
+     * @return the accessible role of this object
+     */
     public AccessibleRole getAccessibleRole()
     {
       return AccessibleRole.MENU;
     }
 
+    /**
+     * Returns the number of selected accessible children. This will be
+     * <code>0</code> if no item is selected, or <code>1</code> if an item
+     * is selected. AccessibleJMenu can have maximum 1 selected item.
+     *
+     * @return the number of selected accessible children
+     */
     public int getAccessibleSelectionCount()
-      throws NotImplementedException
     {
-      return 0;
+      int count = 0;
+      MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+      MenuElement[] me = msm.getSelectedPath();
+      if (me != null)
+        {
+          for (int i = 0; i < me.length; i++)
+            {
+              if (me[i] == JMenu.this)
+                {
+                  if (i + 1 < me.length)
+                    {
+                      count = 1;
+                      break;
+                    }
+                }
+            }
+        }
+      return count;
     }
 
-    public void addAccessibleSelection(int value0)
-      throws NotImplementedException
+    /**
+     * Selects the accessible child with the specified index.
+     *
+     * @param index the index of the accessible child to select
+     */
+    public void addAccessibleSelection(int index)
     {
-      // TODO: Implement this properly.
+      Accessible child = getAccessibleChild(index);
+      if (child != null && child instanceof JMenuItem)
+        {
+          JMenuItem mi = (JMenuItem) child;
+          MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+          msm.setSelectedPath(createPath(JMenu.this));
+        }
     }
 
-    public void removeAccessibleSelection(int value0)
-      throws NotImplementedException
+    /**
+     * Removes the item with the specified index from the selection.
+     *
+     * @param index the index of the selected item to remove from the selection
+     */
+    public void removeAccessibleSelection(int index)
     {
-      // TODO: Implement this properly.
+      Accessible child = getAccessibleChild(index);
+      if (child != null)
+        {
+          MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+          MenuElement[] oldSelection = msm.getSelectedPath();
+          for (int i = 0; i < oldSelection.length; i++)
+            {
+              if (oldSelection[i] == child)
+                {
+                  // Found the specified child in the selection. Remove it
+                  // from the selection.
+                  MenuElement[] newSel = new MenuElement[i - 1];
+                  System.arraycopy(oldSelection, 0, newSel, 0, i - 1);
+                  msm.setSelectedPath(newSel);
+                  break;
+                }
+            }
+        }
     }
 
+    /**
+     * Removes all possibly selected accessible children of this object from
+     * the selection.
+     */
     public void clearAccessibleSelection()
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      MenuSelectionManager msm = MenuSelectionManager.defaultManager();
+      MenuElement[] oldSelection = msm.getSelectedPath();
+      for (int i = 0; i < oldSelection.length; i++)
+        {
+          if (oldSelection[i] == JMenu.this)
+            {
+              // Found this menu in the selection. Remove all children from
+              // the selection.
+              MenuElement[] newSel = new MenuElement[i];
+              System.arraycopy(oldSelection, 0, newSel, 0, i);
+              msm.setSelectedPath(newSel);
+              break;
+            }
+        }
     }
 
+    /**
+     * AccessibleJMenu don't support multiple selection, so this method
+     * does nothing.
+     */
     public void selectAllAccessibleSelection()
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      // Nothing to do here.
     }
   }
 
@@ -939,4 +1116,44 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
     }
   }
 
+  /**
+   * Creates an array to be feeded as argument to
+   * {@link MenuSelectionManager#setSelectedPath(MenuElement[])} for the
+   * specified element. This has the effect of selecting the specified element
+   * and all its parents.
+   *
+   * @param leaf the leaf element for which to create the selected path
+   *
+   * @return the selected path array
+   */
+  MenuElement[] createPath(JMenu leaf)
+  {
+    ArrayList path = new ArrayList();
+    MenuElement[] array = null;
+    Component current = leaf.getPopupMenu();
+    while (true)
+      {
+        if (current instanceof JPopupMenu)
+          {
+            JPopupMenu popupMenu = (JPopupMenu) current;
+            path.add(0, popupMenu);
+            current = popupMenu.getInvoker();
+          }
+        else if (current instanceof JMenu)
+          {
+            JMenu menu = (JMenu) current;
+            path.add(0, menu);
+            current = menu.getParent();
+          }
+        else if (current instanceof JMenuBar)
+          {
+            JMenuBar menuBar = (JMenuBar) current;
+            path.add(0, menuBar);
+            array = new MenuElement[path.size()];
+            array = (MenuElement[]) path.toArray(array);
+            break;
+          }
+      }
+    return array;
+  }
 }
diff --git a/libjava/classpath/javax/swing/JMenuBar.java b/libjava/classpath/javax/swing/JMenuBar.java
index 18e47dcd96de..35f129377f1d 100644
--- a/libjava/classpath/javax/swing/JMenuBar.java
+++ b/libjava/classpath/javax/swing/JMenuBar.java
@@ -370,10 +370,30 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
   {
     MenuElement[] subElements = new MenuElement[getComponentCount()];
 
+    int j = 0;
+    boolean doResize = false;
+    MenuElement menu;
     for (int i = 0; i < getComponentCount(); i++)
-      subElements[i] = (MenuElement) getMenu(i);
+      {
+        menu = getMenu(i);
+        if (menu != null)
+          {
+            subElements[j++] = (MenuElement) menu;
+          }
+        else
+          doResize = true;
+      }
 
-    return subElements;
+    if (! doResize)
+      return subElements;
+    else
+      {
+        MenuElement[] subElements2 = new MenuElement[j];
+        for (int i = 0; i < j; i++)
+          subElements2[i] = subElements[i];
+
+        return subElements2;
+      }
   }
 
   /**
@@ -522,6 +542,9 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
                                          KeyEvent e, int condition,
                                          boolean pressed)
   {
+    if (menuElement == null)
+      return false;
+
     // First check the menuElement itself, if it's a JComponent
     if (menuElement instanceof JComponent
         && ((JComponent) menuElement).processKeyBinding(ks, e, condition,
diff --git a/libjava/classpath/javax/swing/JMenuItem.java b/libjava/classpath/javax/swing/JMenuItem.java
index 272c1cfe6ce8..90d54b1d30a5 100644
--- a/libjava/classpath/javax/swing/JMenuItem.java
+++ b/libjava/classpath/javax/swing/JMenuItem.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Component;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
@@ -51,6 +49,7 @@ import java.util.EventListener;
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.event.MenuDragMouseEvent;
@@ -673,7 +672,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
   }
 
   /**
-   * Returns a string describing the attributes for the <code>JToolTip</code>
+   * Returns a string describing the attributes for the <code>JMenuItem</code>
    * component, for use in debugging.  The return value is guaranteed to be 
    * non-<code>null</code>, but the format of the string may vary between
    * implementations.
@@ -696,7 +695,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
   public AccessibleContext getAccessibleContext()
   {
     if (accessibleContext == null)
-      accessibleContext = new AccessibleJMenuItem();
+      {
+        AccessibleJMenuItem ctx = new AccessibleJMenuItem(); 
+        addChangeListener(ctx);
+        accessibleContext = ctx;
+      }
 
     return accessibleContext;
   }
@@ -712,6 +715,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
   {
     private static final long serialVersionUID = 6748924232082076534L;
 
+    private boolean armed;
+    private boolean focusOwner;
+    private boolean pressed;
+    private boolean selected;
+
     /**
      * Creates a new <code>AccessibleJMenuItem</code> instance.
      */
@@ -720,10 +728,99 @@ public class JMenuItem extends AbstractButton implements Accessible,
       //super(component);
     }
 
+    /**
+     * Receives notification when the menu item's state changes and fires
+     * appropriate property change events to registered listeners.
+     *
+     * @param event the change event
+     */
     public void stateChanged(ChangeEvent event)
-      throws NotImplementedException
     {
-      // TODO: What should be done here, if anything?
+      // This is fired in all cases.
+      firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
+                         Boolean.FALSE, Boolean.TRUE);
+
+      ButtonModel model = getModel();
+
+      // Handle the armed property.
+      if (model.isArmed())
+        {
+          if (! armed)
+            {
+              armed = true;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 AccessibleState.ARMED, null);
+            }
+        }
+      else
+        {
+          if (armed)
+            {
+              armed = false;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 null, AccessibleState.ARMED);
+            }
+        }
+
+      // Handle the pressed property.
+      if (model.isPressed())
+        {
+          if (! pressed)
+            {
+              pressed = true;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 AccessibleState.PRESSED, null);
+            }
+        }
+      else
+        {
+          if (pressed)
+            {
+              pressed = false;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 null, AccessibleState.PRESSED);
+            }
+        }
+
+      // Handle the selected property.
+      if (model.isSelected())
+        {
+          if (! selected)
+            {
+              selected = true;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 AccessibleState.SELECTED, null);
+            }
+        }
+      else
+        {
+          if (selected)
+            {
+              selected = false;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 null, AccessibleState.SELECTED);
+            }
+        }
+
+      // Handle the focusOwner property.
+      if (isFocusOwner())
+        {
+          if (! focusOwner)
+            {
+              focusOwner = true;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 AccessibleState.FOCUSED, null);
+            }
+        }
+      else
+        {
+          if (focusOwner)
+            {
+              focusOwner = false;
+              firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+                                 null, AccessibleState.FOCUSED);
+            }
+        }
     }
 
     /**
diff --git a/libjava/classpath/javax/swing/JOptionPane.java b/libjava/classpath/javax/swing/JOptionPane.java
index 0bef12b61fc8..f9490553834f 100644
--- a/libjava/classpath/javax/swing/JOptionPane.java
+++ b/libjava/classpath/javax/swing/JOptionPane.java
@@ -1,5 +1,5 @@
 /* JOptionPane.java
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,14 +38,20 @@ exception statement from your version. */
 
 package javax.swing;
 
+import java.awt.AWTEvent;
+import java.awt.ActiveEvent;
 import java.awt.Component;
+import java.awt.Container;
+import java.awt.EventQueue;
 import java.awt.Frame;
+import java.awt.MenuComponent;
+import java.awt.Toolkit;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseMotionAdapter;
 
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
-import javax.swing.event.InternalFrameAdapter;
-import javax.swing.event.InternalFrameEvent;
 import javax.swing.plaf.OptionPaneUI;
 
 /**
@@ -57,17 +63,15 @@ import javax.swing.plaf.OptionPaneUI;
 public class JOptionPane extends JComponent implements Accessible
 {
   /**
-   * DOCUMENT ME!
+   * Provides the accessibility features for the <code>JOptionPane</code>
+   * component.
    */
-  // FIXME: This inner class is a complete stub and needs to be implemented
-  // properly.
   protected class AccessibleJOptionPane extends JComponent.AccessibleJComponent
   {
-    /** DOCUMENT ME! */
     private static final long serialVersionUID = 686071432213084821L;
     
     /**
-     * Creates a new AccessibleJOptionPane object.
+     * Creates a new <code>AccessibleJOptionPane</code> instance.
      */
     protected AccessibleJOptionPane()
     {
@@ -86,7 +90,6 @@ public class JOptionPane extends JComponent implements Accessible
     }
   }
 
-  /** DOCUMENT ME! */
   private static final long serialVersionUID = 5231143276678566796L;
 
   /** The value returned when cancel option is selected. */
@@ -431,9 +434,11 @@ public class JOptionPane extends JComponent implements Accessible
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns the object that provides accessibility features for this
+   * <code>JOptionPane</code> component.
    *
-   * @return DOCUMENT ME!
+   * @return The accessible context (an instance of 
+   *     {@link AccessibleJOptionPane}).
    */
   public AccessibleContext getAccessibleContext()
   {
@@ -1529,31 +1534,64 @@ public class JOptionPane extends JComponent implements Accessible
    */
   private static void startModal(JInternalFrame f)
   {
-    synchronized (f)
-    {
-      final JInternalFrame tmp = f;
-      tmp.toFront();
-
-      f.addInternalFrameListener(new InternalFrameAdapter()
-                                 {
-                                   public void internalFrameClosed(InternalFrameEvent e)
-                                   {
-                                     synchronized (tmp)
-                                     {
-                                       tmp.removeInternalFrameListener(this);
-                                       tmp.notifyAll();
-                                     }
-                                   }
-                                 });
-      try
-        {
-          while (! f.isClosed())
-            f.wait();
-        }
-      catch (InterruptedException ignored)
-        {
-          // Ignore this Exception.
-        }
-    }
+    // We need to add an additional glasspane-like component directly
+    // below the frame, which intercepts all mouse events that are not
+    // directed at the frame itself.
+    JPanel modalInterceptor = new JPanel();
+    modalInterceptor.setOpaque(false);
+    JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f);
+    lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue());
+    modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight());
+    modalInterceptor.addMouseListener(new MouseAdapter(){});
+    modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){});
+    lp.add(modalInterceptor);
+    f.toFront();
+
+    // We need to explicitly dispatch events when we are blocking the event
+    // dispatch thread.
+    EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
+    try
+      {
+        while (! f.isClosed())
+          {
+            if (EventQueue.isDispatchThread())
+              {
+                // The getNextEventMethod() issues wait() when no
+                // event is available, so we don't need do explicitly wait().
+                AWTEvent ev = queue.getNextEvent();
+                // This mimics EventQueue.dispatchEvent(). We can't use
+                // EventQueue.dispatchEvent() directly, because it is
+                // protected, unfortunately.
+                if (ev instanceof ActiveEvent)
+                  ((ActiveEvent) ev).dispatch();
+                else if (ev.getSource() instanceof Component)
+                  ((Component) ev.getSource()).dispatchEvent(ev);
+                else if (ev.getSource() instanceof MenuComponent)
+                  ((MenuComponent) ev.getSource()).dispatchEvent(ev);
+                // Other events are ignored as per spec in
+                // EventQueue.dispatchEvent
+              }
+            else
+              {
+                // Give other threads a chance to become active.
+                Thread.yield();
+              }
+          }
+      }
+    catch (InterruptedException ex)
+      {
+        // If we get interrupted, then leave the modal state.
+      }
+    finally
+      {
+        // Clean up the modal interceptor.
+        lp.remove(modalInterceptor);
+
+        // Remove the internal frame from its parent, so it is no longer
+        // lurking around and clogging memory.
+        Container parent = f.getParent();
+        if (parent != null)
+          parent.remove(f);
+      }
   }
 }
diff --git a/libjava/classpath/javax/swing/JPopupMenu.java b/libjava/classpath/javax/swing/JPopupMenu.java
index a54bd777fd4e..c7890ea0e1e4 100644
--- a/libjava/classpath/javax/swing/JPopupMenu.java
+++ b/libjava/classpath/javax/swing/JPopupMenu.java
@@ -52,6 +52,7 @@ import java.util.EventListener;
 import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
+import javax.swing.event.MenuKeyListener;
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
 import javax.swing.plaf.PopupMenuUI;
@@ -409,6 +410,36 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
     this.insert(new Separator(), -1);
   }
 
+  /**
+   * Adds a MenuKeyListener to the popup.
+   * 
+   * @param l - the listener to add.
+   */
+  public void addMenuKeyListener(MenuKeyListener l)
+  {
+    listenerList.add(MenuKeyListener.class, l);
+  }
+  
+  /**
+   * Removes a MenuKeyListener from the popup.
+   * 
+   * @param l - the listener to remove.
+   */
+  public void removeMenuKeyListener(MenuKeyListener l)
+  {
+    listenerList.remove(MenuKeyListener.class, l);
+  }
+  
+  /**
+   * Returns array of getMenuKeyListeners that are listening to JPopupMenu.
+   * 
+   * @return array of getMenuKeyListeners that are listening to JPopupMenu
+   */
+  public MenuKeyListener[] getMenuKeyListeners()
+  {
+    return ((MenuKeyListener[]) listenerList.getListeners(MenuKeyListener.class));
+  }
+  
   /**
    * Adds popupMenuListener to listen for PopupMenuEvents fired
    * by the JPopupMenu
diff --git a/libjava/classpath/javax/swing/JProgressBar.java b/libjava/classpath/javax/swing/JProgressBar.java
index db936f64a34f..ed2d0088d065 100644
--- a/libjava/classpath/javax/swing/JProgressBar.java
+++ b/libjava/classpath/javax/swing/JProgressBar.java
@@ -53,15 +53,14 @@ import javax.swing.event.ChangeListener;
 import javax.swing.plaf.ProgressBarUI;
 
 /**
- * The ProgressBar is a widget that displays in two modes. In 
- * determinate mode, it displays fills a percentage of its bar
- * based on its current value. In indeterminate mode, it creates
- * box and bounces it between its bounds.
- *
+ * A component that displays a visual indicator of the progress of a task. The
+ * component has two modes: determinate and indeterminate.  In determinate mode,
+ * the <code>JProgressBar</code> fills a percentage of its bar based on its 
+ * current value. In indeterminate mode, it creates box and bounces it between 
+ * its bounds.
  * <p>
- * JProgressBars have the following properties:
+ * This component has the following properties:
  * </p>
- * 
  * <table>
  * <tr><th> Property         </th><th> Stored in   </th><th> Bound? </th></tr>
  * <tr><td> borderPainted    </td><td> progressBar </td><td> yes    </td></tr>
@@ -193,33 +192,67 @@ public class JProgressBar extends JComponent implements SwingConstants,
 
   private static final long serialVersionUID = 1980046021813598781L;
   
-  /** Whether the ProgressBar is determinate. */
+  /** 
+   * A flag that determines the mode (<code>true</code> for indeterminate, 
+   * <code>false</code> for determinate).
+   */
   private transient boolean indeterminate = false;
 
-  /** The orientation of the ProgressBar. Always set by constructor. */
+  /** 
+   * The orientation of the <code>JProgressBar</code> 
+   * ({@link SwingConstants#HORIZONTAL} or {@link SwingConstants#VERTICAL}). 
+   * Defaults to {@link SwingConstants#HORIZONTAL}.
+   * @see #setOrientation(int)
+   */
   protected int orientation;
 
-  /** Whether borders should be painted. */
+  /** 
+   * A flag the controls whether or not the component's border is painted.
+   * The default is <code>true</code>. 
+   * @see #setBorderPainted(boolean)
+   */
   protected boolean paintBorder = true;
 
-  /** The model describing this ProgressBar. */
+  /** 
+   * The model defining the bounds and current value for the progress bar.
+   * @see #setModel(BoundedRangeModel) 
+   */
   protected BoundedRangeModel model;
 
-  /** The string that is displayed by the ProgressBar. */
+  /** 
+   * A custom string for display in the progress bar.  If this is 
+   * <code>null</code>, a default string will be generated. 
+   * @see #setString(String)
+   */
   protected String progressString;
 
-  /** Whether the string should be painted. */
+  /** 
+   * A flag that controls whether a string is displayed within the progress 
+   * bar. 
+   * @see #setStringPainted(boolean)
+   */
   protected boolean paintString = false;
 
-  /** The static changeEvent passed to all ChangeListeners. */
+  /** 
+   * A single change event reused for all events.
+   * @see #fireStateChanged() 
+   */
   protected transient ChangeEvent changeEvent;
 
-  /** The ChangeListener that listens to the model. */
+  /** 
+   * The listener that is registered with the model. */
   protected ChangeListener changeListener;
 
   /**
-   * Creates a new horizontally oriented JProgressBar object 
-   * with a minimum of 0 and a maximum of 100.
+   * Creates a new <code>JProgressBar</code> with default attributes.  The 
+   * following defaults are used:
+   * <p>
+   * <ul>
+   * <li><code>value</code>: 0;</li>
+   * <li><code>minimum</code>: 0;</li>
+   * <li><code>maximum</code>: 100;</li>
+   * <li><code>orientation</code>: {@link SwingConstants#HORIZONTAL}.</li>
+   * </ul>  
    */
   public JProgressBar()
   {
@@ -227,13 +260,20 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * Creates a new JProgressBar object with a minimum of 0,
-   * a maximum of 100, and the given orientation.
-   *
-   * @param orientation The orientation of the JProgressBar.
+   * Creates a new <code>JProgressBar</code> with the specified 
+   * <code>orientation</code>.  The following defaults are used:
+   * <p>
+   * <ul>
+   * <li><code>value</code>: 0;</li>
+   * <li><code>minimum</code>: 0;</li>
+   * <li><code>maximum</code>: 100;</li>
+   * </ul>  
    * 
-   * @throws IllegalArgumentException if <code>orientation</code> is not either
-   *         {@link #HORIZONTAL} or {@link #VERTICAL}.
+   * @param orientation  the orientation ({@link #HORIZONTAL} or 
+   *     {@link #VERTICAL}).
+   * 
+   * @throws IllegalArgumentException if <code>orientation</code> is not one of
+   *     the specified values.
    */
   public JProgressBar(int orientation)
   {
@@ -241,11 +281,16 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * Creates a new horizontally oriented JProgressBar object
-   * with the given minimum and maximum.
-   *
-   * @param minimum The minimum of the JProgressBar.
-   * @param maximum The maximum of the JProgressBar.
+   * Creates a new <code>JProgressBar</code> with the specified value range.
+   * The following defaults are used:
+   * <p>
+   * <ul>
+   * <li><code>value</code>: <code>minimum</code>;</li>
+   * <li><code>orientation</code>: {@link SwingConstants#HORIZONTAL}.</li>
+   * </ul>  
+   * 
+   * @param minimum  the lower bound of the value range.
+   * @param maximum  the upper bound of the value range.
    */
   public JProgressBar(int minimum, int maximum)
   {
@@ -253,15 +298,20 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * Creates a new JProgressBar object with the given minimum,
-   * maximum, and orientation.
-   *
-   * @param minimum The minimum of the JProgressBar.
-   * @param maximum The maximum of the JProgressBar.
-   * @param orientation The orientation of the JProgressBar.
+   * Creates a new <code>JProgressBar</code> with the specified range and
+   * orientation.  The following defaults are used:
+   * <p>
+   * <ul>
+   * <li><code>value</code>: <code>minimum</code>;</li>
+   * </ul>  
+   * 
+   * @param minimum  the lower bound of the value range.
+   * @param maximum  the upper bound of the value range.
+   * @param orientation  the orientation ({@link #HORIZONTAL} or 
+   *     {@link #VERTICAL}).
    * 
-   * @throws IllegalArgumentException if <code>orientation</code> is not either
-   *         {@link #HORIZONTAL} or {@link #VERTICAL}.
+   * @throws IllegalArgumentException if <code>orientation</code> is not one of
+   *     the specified values.
    */
   public JProgressBar(int orientation, int minimum, int maximum)
   {
@@ -276,10 +326,14 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * Creates a new horizontally oriented JProgressBar object 
-   * with the given model.
-   *
-   * @param model The model to be used with the JProgressBar.
+   * Creates a new <code>JProgressBar</code> with the specified model.  The
+   * following defaults are used:
+   * <p>
+   * <ul>
+   * <li><code>orientation</code>: {@link SwingConstants#HORIZONTAL}.</li>
+   * </ul>  
+   * 
+   * @param model  the model (<code>null</code> not permitted).
    */
   public JProgressBar(BoundedRangeModel model)
   {
@@ -291,9 +345,12 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method returns the current value of the JProgressBar.
+   * Returns the current value for the <code>JProgressBar</code>.  This value 
+   * is fetched from the model.
    *
-   * @return The current value of the JProgressBar.
+   * @return The current value.
+   * 
+   * @see #setValue(int)
    */
   public int getValue()
   {
@@ -301,9 +358,20 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method sets the value of the JProgressBar.
+   * Sets the current value for the <code>JProgressBar</code>.  The value is
+   * stored in the component's <code>model</code> (see {@link #getModel()}).  
+   * If the new value is different to the old value, a {@link ChangeEvent} is 
+   * sent to the model's registered listeners.  In turn, this triggers a call 
+   * to {@link #fireStateChanged()} which will send a <code>ChangeEvent</code> 
+   * to this component's registered listeners.
+   * <p>
+   * If <code>value</code> is outside the range <code>minimum</code> to 
+   * <code>maximum</code>, it will be set to the nearest of those boundary 
+   * values.
    *
-   * @param value The value of the JProgressBar.
+   * @param value  the new value.
+   * 
+   * @see #getValue()
    */
   public void setValue(int value)
   {
@@ -311,23 +379,29 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method paints the border of the JProgressBar
+   * Paints the component's border, but only if {@link #isBorderPainted()}
+   * returns <code>true</code>.
    *
-   * @param graphics The graphics object to paint with.
+   * @param graphics  the graphics object to paint with.
+   * 
+   * @see #setBorderPainted(boolean)
    */
   protected void paintBorder(Graphics graphics)
   {
     Border border = getBorder();
     if (paintBorder && border != null)
-      border.paintBorder(this, graphics, 0, 0,
-                         getWidth(),
-                         getHeight());
+      border.paintBorder(this, graphics, 0, 0, getWidth(), getHeight());
   }
 
   /**
-   * This method returns the orientation of the JProgressBar.
+   * Returns the orientation of the <code>JProgressBar</code> component, which
+   * is either {@link SwingConstants#HORIZONTAL} or 
+   * {@link SwingConstants#VERTICAL}.  The default orientation is 
+   * <code>HORIZONTAL</code>.
    *
-   * @return The orientation of the JProgressBar.
+   * @return The orientation.
+   * 
+   * @see #setOrientation(int)
    */
   public int getOrientation()
   {
@@ -335,12 +409,17 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method changes the orientation property. The orientation of the 
-   * JProgressBar can be either horizontal or vertical.
+   * Sets the orientation for this <code>JProgressBar</code> component and,
+   * if the value changes, sends a {@link PropertyChangeEvent} (with the 
+   * property name <code>"orientation"</code>) to all registered listeners.
    *
-   * @param orientation The orientation of the JProgressBar.
+   * @param orientation  the orientation ({@link #HORIZONTAL} or 
+   *     {@link #VERTICAL}).
+   * 
    * @throws IllegalArgumentException if <code>orientation</code> is not
-   *         either {@link #HORIZONTAL} or {@link #VERTICAL}.
+   *     one of the listed values.
+   *     
+   * @see #getOrientation()
    */
   public void setOrientation(int orientation)
   {
@@ -349,17 +428,21 @@ public class JProgressBar extends JComponent implements SwingConstants,
                                          + " is not a legal orientation");    
     if (this.orientation != orientation)
       {
-	int oldOrientation = this.orientation;
-	this.orientation = orientation;
-	firePropertyChange("orientation", oldOrientation,
-	                   this.orientation);
+        int oldOrientation = this.orientation;
+        this.orientation = orientation;
+        firePropertyChange("orientation", oldOrientation, this.orientation);
       }
   }
 
   /**
-   * This method returns whether the progressString will be painted.
+   * Returns the flag that controls whether or not the string returned by
+   * {@link #getString()} is displayed by the <code>JProgressBar</code> 
+   * component.
    *
-   * @return Whether the string is painted.
+   * @return <code>true</code> if the string should be displayed, and 
+   *     <code>false</code> otherwise.
+   * 
+   * @see #setStringPainted(boolean)
    */
   public boolean isStringPainted()
   {
@@ -367,28 +450,37 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method changes the stringPainted property.
+   * Sets the flag that controls whether or not the string returned by
+   * {@link #getString()} is displayed by the <code>JProgressBar</code> 
+   * component.  If the flag value changes, a {@link PropertyChangeEvent} (with 
+   * the property name <code>"stringPainted"</code>) is sent to all registered 
+   * listeners.
    *
-   * @param painted Whether the string is painted.
+   * @param painted  the new flag value.
+   * 
+   * @see #isStringPainted()
+   * @see #setString(String)
    */
   public void setStringPainted(boolean painted)
   {
     if (paintString != painted)
       {
-	boolean oldPainted = paintString;
-	paintString = painted;
-	firePropertyChange("stringPainted", oldPainted,
-	                   paintString);
+        boolean oldPainted = paintString;
+        paintString = painted;
+        firePropertyChange("stringPainted", oldPainted, paintString);
       }
   }
 
   /**
-   * This method returns the string that is painted if the 
-   * stringPainted property is set to true. If there is no
-   * string set, it will return a string containing the 
-   * JProgressBar's value as a percent.
+   * Returns the string that is painted on the <code>JProgressBar</code> if 
+   * {@link #isStringPainted()} returns <code>true</code>.  If no string has 
+   * been explicitly set, this method will return a string displaying the 
+   * value of {@link #getPercentComplete()}.
    *
-   * @return The string that is painted.
+   * @return The string.
+   * 
+   * @see #setString(String)
+   * @see #setStringPainted(boolean)
    */
   public String getString()
   {
@@ -399,12 +491,16 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method changes the string property. The string
-   * given will be the one painted. If you want to 
-   * revert to the default string given, set the
-   * string to null.
+   * Sets the string to display within the progress bar and, if the new value
+   * is different to the old value, sends a {@link PropertyChangeEvent} (with 
+   * the property name <code>"string"</code>) to all registered listeners. If 
+   * the string is set to <code>null</code>, {@link #getString()} will return
+   * a default string.
    *
-   * @param string The string to be painted.
+   * @param string  the string (<code>null</code> permitted).
+   * 
+   * @see #getString()
+   * @see #setStringPainted(boolean)
    */
   public void setString(String string)
   {
@@ -412,32 +508,35 @@ public class JProgressBar extends JComponent implements SwingConstants,
         string != progressString) || (string != null &&
 	! string.equals(progressString)))
       {
-	String oldString = progressString;
-	progressString = string;
-	firePropertyChange("string", oldString, progressString);
+        String oldString = progressString;
+        progressString = string;
+        firePropertyChange("string", oldString, progressString);
       }
   }
 
   /**
-   * This method returns the percent of the bar
-   * that is "complete". (This is the amount value / (max - min)).
+   * Returns the current value expressed as a percentage.  This is calculated 
+   * as <code>(value - min) / (max - min)</code>.
    *
-   * @return DOCUMENT ME!
+   * @return The percentage (a value in the range 0.0 to 1.0).
    */
   public double getPercentComplete()
   {
     if (getMaximum() == getMinimum())
       return 1.0;
     else
-      return (double) (model.getValue() - model.getMinimum()) / (model
-                                                                 .getMaximum()
-             - model.getMinimum());
+      return (double) (model.getValue() - model.getMinimum()) 
+          / (model.getMaximum() - model.getMinimum());
   }
 
   /**
-   * This method returns whether the border is painted.
+   * Returns a flag that controls whether or not the component's border is
+   * painted.  The default value is <code>true</code>.
    *
-   * @return Whether the border is painted.
+   * @return <code>true</code> if the component's border should be painted,
+   *     and <code>false</code> otherwise.
+   *     
+   * @see #setBorderPainted(boolean)
    */
   public boolean isBorderPainted()
   {
@@ -445,25 +544,30 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method changes the borderPainted property.
+   * Sets the flag that controls whether or not the component's border is
+   * painted.  If the flag value is changed, this method sends a 
+   * {@link PropertyChangeEvent} (with the property name "borderPainted") to 
+   * all registered listeners.
    *
-   * @param painted Whether the border is painted.
+   * @param painted  the new flag value.
+   * 
+   * @see #isBorderPainted()
+   * @see #paintBorder
    */
   public void setBorderPainted(boolean painted)
   {
     if (painted != paintBorder)
       {
-	boolean oldPainted = paintBorder;
-	paintBorder = painted;
-	firePropertyChange("borderPainted", oldPainted,
-	                   paintBorder);
+        boolean oldPainted = paintBorder;
+        paintBorder = painted;
+        firePropertyChange("borderPainted", oldPainted, paintBorder);
       }
   }
 
   /**
-   * This method returns the JProgressBar's UI delegate.
+   * Returns the UI delegate for this <code>JProgressBar</code>.
    *
-   * @return This JProgressBar's UI delegate.
+   * @return The UI delegate.
    */
   public ProgressBarUI getUI()
   {
@@ -471,9 +575,9 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method changes the UI property for this JProgressBar.
+   * Sets the UI delegate for this component.
    *
-   * @param ui The new UI delegate.
+   * @param ui  the new UI delegate.
    */
   public void setUI(ProgressBarUI ui)
   {
@@ -481,8 +585,8 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method reverts the UI delegate for this JProgressBar
-   * to the default for this Look and Feel.
+   * Sets this <code>JProgressBar</code>'s UI delegate to the default 
+   * (obtained from the {@link UIManager}) for the current look and feel.
    */
   public void updateUI()
   {
@@ -490,11 +594,11 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method returns the identifier to allow the UIManager
-   * to pick the correct class to act as the UI for
-   * this JProgressBar.
+   * Returns the suffix (<code>"ProgressBarUI"</code> in this case) used to 
+   * determine the class name for a UI delegate that can provide the look and 
+   * feel for a <code>JProgressBar</code>.
    *
-   * @return The UIClassID: "ProgressBarUI".
+   * @return <code>"ProgressBarUI"</code>.
    */
   public String getUIClassID()
   {
@@ -502,27 +606,33 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method returns a ChangeListener that gets registered
-   * model. By default, the ChangeListener, propagates the 
-   * ChangeEvents to the ChangeListeners of the JProgressBar.
+   * Creates a new {@link ChangeListener} that calls 
+   * {@link #fireStateChanged()} whenever it receives a {@link ChangeEvent}
+   * (typically from the component's <code>model</code>).  This listener is 
+   * registered with the progress bar's model, so that changes made to the 
+   * model directly will automatically result in the progress bar's listeners 
+   * being notified also.
    *
-   * @return A new ChangeListener.
+   * @return A new listener.
    */
   protected ChangeListener createChangeListener()
   {
     return new ChangeListener()
       {
-	public void stateChanged(ChangeEvent ce)
-	{
-	  fireStateChanged();
-	}
+        public void stateChanged(ChangeEvent ce)
+        {
+          fireStateChanged();
+	    }
       };
   }
 
   /**
-   * This method adds a ChangeListener to this JProgressBar.
+   * Registers a listener with this component so that it will receive 
+   * notification of component state changes.
    *
-   * @param listener The ChangeListener to add to this JProgressBar.
+   * @param listener  the listener.
+   * 
+   * @see #removeChangeListener(ChangeListener)
    */
   public void addChangeListener(ChangeListener listener)
   {
@@ -530,9 +640,12 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method removes a ChangeListener from this JProgressBar.
+   * Deregisters a listener so that it no longer receives notification of
+   * component state changes.
    *
-   * @param listener The ChangeListener to remove from this JProgressBar.
+   * @param listener  the listener.
+   * 
+   * @see #addChangeListener(ChangeListener)
    */
   public void removeChangeListener(ChangeListener listener)
   {
@@ -540,10 +653,12 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
   
   /**
-   * This method returns an array of all ChangeListeners listening to this
-   * progress bar.
+   * Returns an array of the listeners that are registered with this component.
+   * The array may be empty, but is never <code>null</code>.
    *
-   * @return An array of ChangeListeners listening to this progress bar.
+   * @return An array of listeners.
+   * 
+   * @since 1.4
    */
   public ChangeListener[] getChangeListeners()
   {
@@ -551,9 +666,10 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }  
 
   /**
-   * This method is called when the JProgressBar receives a ChangeEvent
-   * from its model. This simply propagates the event (changing the source
-   * to the JProgressBar) to the JProgressBar's listeners.
+   * Sends a {@link ChangeEvent} to all registered listeners to indicate that
+   * the state of the <code>JProgressBar</code> has changed.  
+   * 
+   * @see #createChangeListener()
    */
   protected void fireStateChanged()
   {
@@ -562,15 +678,17 @@ public class JProgressBar extends JComponent implements SwingConstants,
       changeEvent = new ChangeEvent(this);
     for (int i = changeListeners.length - 2; i >= 0; i -= 2)
       {
-	if (changeListeners[i] == ChangeListener.class)
-	  ((ChangeListener) changeListeners[i + 1]).stateChanged(changeEvent);
+        if (changeListeners[i] == ChangeListener.class)
+          ((ChangeListener) changeListeners[i + 1]).stateChanged(changeEvent);
       }
   }
 
   /**
-   * This method returns the model used with this JProgressBar.
+   * Returns the model for the <code>JProgressBar</code>.
    *
-   * @return The model used with this JProgressBar.
+   * @return The model (never <code>null</code>).
+   * 
+   * @see #setModel(BoundedRangeModel)
    */
   public BoundedRangeModel getModel()
   {
@@ -578,25 +696,32 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method changes the model property for this JProgressBar.
+   * Sets the model for the <code>JProgressBar</code> and sends a 
+   * {@link ChangeEvent} to all registered listeners.
    *
-   * @param model The model to use with this JProgressBar.
+   * @param model  the model (<code>null</code> not permitted).
+   * 
+   * @see #getModel()
    */
   public void setModel(BoundedRangeModel model)
   {
     if (model != this.model)
       {
         this.model.removeChangeListener(changeListener);
-	this.model = model;
-	this.model.addChangeListener(changeListener);
-	fireStateChanged();
+        this.model = model;
+        this.model.addChangeListener(changeListener);
+        fireStateChanged();
       }
   }
 
   /**
-   * This method returns the minimum value of this JProgressBar.
+   * Returns the minimum value for the <code>JProgressBar</code>. This defines 
+   * the lower bound for the current value, and is stored in the component's 
+   * <code>model</code>.
    *
-   * @return The minimum value of this JProgressBar.
+   * @return The minimum value.
+   * 
+   * @see #setMinimum(int)
    */
   public int getMinimum()
   {
@@ -604,9 +729,16 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method sets the minimum value of this JProgressBar.
-   *
-   * @param minimum The minimum value of this JProgressBar.
+   * Sets the minimum value for the <code>JProgressBar</code>.  The value is
+   * stored in the component's <code>model</code> (see {@link #getModel()}).  
+   * If the new value is different to the old value, a {@link ChangeEvent} is 
+   * sent to the model's registered listeners.  In turn, this triggers a call 
+   * to {@link #fireStateChanged()} which will send a <code>ChangeEvent</code> 
+   * to this component's registered listeners.
+   * 
+   * @param minimum  the minimum value.
+   * 
+   * @see #getMinimum()
    */
   public void setMinimum(int minimum)
   {
@@ -614,9 +746,13 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method returns the maximum value of this JProgressBar.
+   * Returns the maximum value for the <code>JProgressBar</code>.  This defines 
+   * the upper bound for the current value, and is stored in the component's 
+   * <code>model</code>.
    *
-   * @return The maximum value of this JProgressBar.
+   * @return The maximum value.
+   * 
+   * @see #setMaximum(int)
    */
   public int getMaximum()
   {
@@ -624,9 +760,16 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method sets the maximum value of this JProgressBar.
+   * Sets the maximum value for the <code>JProgressBar</code>.  The value is
+   * stored in the component's <code>model</code> (see {@link #getModel()}).  
+   * If the new value is different to the old value, a {@link ChangeEvent} is 
+   * sent to the model's registered listeners.  In turn, this triggers a call 
+   * to {@link #fireStateChanged()} which will send a <code>ChangeEvent</code> 
+   * to this component's registered listeners.
    *
-   * @param maximum The maximum value of this JProgressBar.
+   * @param maximum  the maximum value.
+   * 
+   * @see #getMaximum()
    */
   public void setMaximum(int maximum)
   {
@@ -659,29 +802,40 @@ public class JProgressBar extends JComponent implements SwingConstants,
   }
 
   /**
-   * This method changes the indeterminate property. If the
-   * JProgressBar is determinate, it paints a percentage
-   * of the bar described by its value. If it is indeterminate,
-   * it simply bounces a box between the ends of the bar; the 
-   * value of the JProgressBar is ignored.
+   * Sets the flag that controls the mode for this <code>JProgressBar</code>
+   * (<code>true</code> for indeterminate mode, and <code>false</code> for
+   * determinate mode).  If the flag value changes, this method sends a 
+   * {@link PropertyChangeEvent} (with the property name 
+   * <code>"indeterminate"</code>) to all registered listeners.
+   * <p>
+   * If the <code>JProgressBar</code> is determinate, it paints a percentage
+   * of the bar described by its value. If it is indeterminate, it simply 
+   * bounces a box between the ends of the bar; the value of the 
+   * <code>JProgressBar</code> is ignored.
    *
-   * @param newValue Whether the JProgressBar is indeterminate.
+   * @param flag  the new flag value.
+   * 
+   * @see #isIndeterminate()
+   * @since 1.4
    */
-  public void setIndeterminate(boolean newValue)
+  public void setIndeterminate(boolean flag)
   {
-    if (indeterminate != newValue)
+    if (indeterminate != flag)
       {
-	boolean olddeter = indeterminate;
-	indeterminate = newValue;
-	firePropertyChange("indeterminate", olddeter,
-	                   indeterminate);
+        indeterminate = flag;
+        firePropertyChange("indeterminate", !flag, indeterminate);
       }
   }
 
   /**
-   * This method returns whether the JProgressBar is indeterminate.
+   * Returns a flag that indicates the mode for this <code>JProgressBar</code>
+   * (<code>true</code> for indeterminate mode, and <code>false</code> for 
+   * determinate mode).  
    *
-   * @return Whether this JProgressBar is indeterminate.
+   * @return A flag indicating the mode for the <code>JProgressBar</code>.
+   * 
+   * @see #setIndeterminate(boolean)
+   * @since 1.4
    */
   public boolean isIndeterminate()
   {
diff --git a/libjava/classpath/javax/swing/JScrollBar.java b/libjava/classpath/javax/swing/JScrollBar.java
index bca2468738b2..bf0803ab5a10 100644
--- a/libjava/classpath/javax/swing/JScrollBar.java
+++ b/libjava/classpath/javax/swing/JScrollBar.java
@@ -643,14 +643,24 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
   }
 
   /**
-   * A string that describes this JScrollBar. Normally only used
-   * for debugging.
+   * Returns a string describing the attributes for the <code>JScrollBar</code>
+   * component, for use in debugging.  The return value is guaranteed to be 
+   * non-<code>null</code>, but the format of the string may vary between
+   * implementations.
    *
-   * @return A string describing this JScrollBar.
+   * @return A string describing the attributes of the <code>JScrollBar</code>.
    */
   protected String paramString()
   {
-    return "JScrollBar";
+    StringBuffer sb = new StringBuffer(super.paramString());
+    sb.append(",blockIncrement=").append(blockIncrement);
+    sb.append(",orientation=");
+    if (this.orientation == JScrollBar.HORIZONTAL)
+      sb.append("HORIZONTAL");
+    else 
+      sb.append("VERTICAL");
+    sb.append(",unitIncrement=").append(unitIncrement);
+    return sb.toString();
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/JScrollPane.java b/libjava/classpath/javax/swing/JScrollPane.java
index 09e37378be98..45df1d9190e5 100644
--- a/libjava/classpath/javax/swing/JScrollPane.java
+++ b/libjava/classpath/javax/swing/JScrollPane.java
@@ -170,7 +170,8 @@ public class JScrollPane extends JComponent
     return columnHeader;
   }
 
-  public Component getCorner(String key) {
+  public Component getCorner(String key) 
+  {
     if (getComponentOrientation() 
         == ComponentOrientation.LEFT_TO_RIGHT)
       {
@@ -247,7 +248,7 @@ public class JScrollPane extends JComponent
     if (viewportBorder == null)
       {
         if (getViewport() == null)
-          return new Rectangle(0,0,0,0);
+          return new Rectangle(0, 0, 0, 0);
         else
           return getViewport().getBounds();
       }
@@ -255,8 +256,7 @@ public class JScrollPane extends JComponent
       {
         Insets i = viewportBorder.getBorderInsets(getViewport());
         if (getViewport() == null)
-          return new Rectangle(0,0,
-                               i.left+i.right, i.top+i.bottom);
+          return new Rectangle(0, 0, i.left + i.right, i.top + i.bottom);
         else
           {
             Rectangle b = getViewport().getBounds();
diff --git a/libjava/classpath/javax/swing/JSlider.java b/libjava/classpath/javax/swing/JSlider.java
index ed94c4ecc197..8a06d4f0116c 100644
--- a/libjava/classpath/javax/swing/JSlider.java
+++ b/libjava/classpath/javax/swing/JSlider.java
@@ -227,13 +227,13 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
   }
 
   /** Whether or not this slider paints its ticks. */
-  private transient boolean paintTicks = false;
+  private transient boolean paintTicks;
 
   /** Whether or not this slider paints its track. */
   private transient boolean paintTrack = true;
 
   /** Whether or not this slider paints its labels. */
-  private transient boolean paintLabels = false;
+  private transient boolean paintLabels;
 
   /**
    * A dictionary of (Integer, Component) pairs where each Component is a
@@ -251,7 +251,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
   protected int minorTickSpacing;
 
   /** Whether the slider snaps its values to ticks. */
-  protected boolean snapToTicks = false;
+  protected boolean snapToTicks;
 
   /** The orientation (horizontal or vertical) of the slider. */
   protected int orientation = HORIZONTAL;
diff --git a/libjava/classpath/javax/swing/JSpinner.java b/libjava/classpath/javax/swing/JSpinner.java
index 70045ed53075..16a210600cd4 100644
--- a/libjava/classpath/javax/swing/JSpinner.java
+++ b/libjava/classpath/javax/swing/JSpinner.java
@@ -106,7 +106,7 @@ public class JSpinner extends JComponent
       add(ftf);
       ftf.setValue(spinner.getValue());
       ftf.addPropertyChangeListener(this);
-      if(getComponentOrientation().isLeftToRight())
+      if (getComponentOrientation().isLeftToRight())
 	ftf.setHorizontalAlignment(JTextField.RIGHT);
       else
 	ftf.setHorizontalAlignment(JTextField.LEFT);
diff --git a/libjava/classpath/javax/swing/JSplitPane.java b/libjava/classpath/javax/swing/JSplitPane.java
index c11512198546..2747686a31a0 100644
--- a/libjava/classpath/javax/swing/JSplitPane.java
+++ b/libjava/classpath/javax/swing/JSplitPane.java
@@ -108,7 +108,7 @@ public class JSplitPane extends JComponent implements Accessible
 
     /**
      * Returns an object that provides access to the current, minimum and 
-     * maximum values for the {@link JSlider}.  Since this class implements 
+     * maximum values for the {@link JSplitPane}.  Since this class implements 
      * {@link AccessibleValue}, it returns itself.
      *
      * @return The accessible value.
@@ -136,9 +136,9 @@ public class JSplitPane extends JComponent implements Accessible
      * listeners.  If the supplied value is <code>null</code>, this method 
      * does nothing and returns <code>false</code>.
      *
-     * @param value  the new slider value (<code>null</code> permitted).
+     * @param value  the new divider location (<code>null</code> permitted).
      *
-     * @return <code>true</code> if the slider value is updated, and 
+     * @return <code>true</code> if the divider location value is updated, and 
      *     <code>false</code> otherwise.
      */
     public boolean setCurrentAccessibleValue(Number value)
@@ -699,7 +699,8 @@ public class JSplitPane extends JComponent implements Accessible
    * @param proportionalLocation A double that describes the location of the
    *        divider.
    *
-   * @throws IllegalArgumentException DOCUMENT ME!
+   * @throws IllegalArgumentException if <code>proportionalLocation</code> is
+   *     not in the range from 0.0 to 1.0 inclusive.
    */
   public void setDividerLocation(double proportionalLocation)
   {
diff --git a/libjava/classpath/javax/swing/JTabbedPane.java b/libjava/classpath/javax/swing/JTabbedPane.java
index 34ab8eeaa66b..7e2864b8a441 100644
--- a/libjava/classpath/javax/swing/JTabbedPane.java
+++ b/libjava/classpath/javax/swing/JTabbedPane.java
@@ -1,5 +1,5 @@
 /* JTabbedPane.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Point;
@@ -53,6 +51,7 @@ import javax.accessibility.Accessible;
 import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleState;
 import javax.accessibility.AccessibleStateSet;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
@@ -79,8 +78,6 @@ public class JTabbedPane extends JComponent implements Serializable,
   /**
    * Accessibility support for <code>JTabbedPane</code>.
    */
-  // FIXME: This inner class is a complete stub and must be implemented
-  // properly.
   protected class AccessibleJTabbedPane extends JComponent.AccessibleJComponent
     implements AccessibleSelection, ChangeListener
   {
@@ -99,14 +96,17 @@ public class JTabbedPane extends JComponent implements Serializable,
 
     /**
      * Receives notification when the selection state of the
-     * <code>JTabbedPane</code> changes.
+     * <code>JTabbedPane</code> changes and fires appropriate property change
+     * events to interested listeners.
      *
      * @param e the change event describing the change
      */
     public void stateChanged(ChangeEvent e)
-      throws NotImplementedException
     {
-      // Implement this properly.
+      // I couldn't figure out what else should be done here.
+      Object source = e.getSource();
+      firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
+                         null, source);
     }
 
     /**
@@ -116,9 +116,8 @@ public class JTabbedPane extends JComponent implements Serializable,
      * @return the accessible role of the <code>JTabbedPane</code>
      */
     public AccessibleRole getAccessibleRole()
-      throws NotImplementedException
     {
-      return null;
+      return AccessibleRole.PAGE_TAB_LIST;
     }
 
     /**
@@ -129,9 +128,8 @@ public class JTabbedPane extends JComponent implements Serializable,
      *         <code>JTabbedPane</code>
      */
     public int getAccessibleChildrenCount()
-      throws NotImplementedException
     {
-      return 0;
+      return getTabCount();
     }
 
     /**
@@ -158,9 +156,8 @@ public class JTabbedPane extends JComponent implements Serializable,
      * @return the current selection state of the <code>JTabbedPane</code>
      */
     public AccessibleSelection getAccessibleSelection()
-      throws NotImplementedException
     {
-      return null;
+      return this;
     }
 
     /**
@@ -175,90 +172,99 @@ public class JTabbedPane extends JComponent implements Serializable,
      *         this location
      */
     public Accessible getAccessibleAt(Point p)
-      throws NotImplementedException
     {
-      return null;
+      int tabIndex = indexAtLocation(p.x, p.y);
+      if (tabIndex >= 0)
+        return getAccessibleChild(tabIndex);
+      else
+        return getAccessibleSelection(0);
     }
 
     /**
-     * The number of selected child components of the
-     * <code>JTabbedPane</code>. This will be <code>0</code> if the
-     * <code>JTabbedPane</code> has no children, or <code>1</code> otherwise,
-     * since there is always exactly one tab selected. 
+     * Returns the number of selected child components of the
+     * <code>JTabbedPane</code>. The reference implementation appears
+     * to return <code>1</code> always and we do the same. 
      *
-     * @return number of selected child components of the
-     *         <code>JTabbedPane</code>
+     * @return <code>1</code>
      */
     public int getAccessibleSelectionCount()
-      throws NotImplementedException
     {
-      return 0;
+      return 1;
     }
 
     /**
-     * DOCUMENT ME!
+     * Returns the selected tab, or <code>null</code> if there is no 
+     * selection.
      *
-     * @param i DOCUMENT ME!
+     * @param i  the selection index (ignored here).
      *
-     * @return DOCUMENT ME!
+     * @return The selected tab, or <code>null</code>.
      */
     public Accessible getAccessibleSelection(int i)
-      throws NotImplementedException
     {
-      return null;
+      Accessible result = null;
+      int selected = getSelectedIndex();
+      if (selected >= 0)
+        result = (Page) tabs.get(selected);
+      return result;
     }
 
     /**
-     * DOCUMENT ME!
+     * Returns <code>true</code> if the specified child is selected,
+     * and <code>false</code> otherwise.
      *
-     * @param i DOCUMENT ME!
+     * @param i the child index.
      *
-     * @return DOCUMENT ME!
+     * @return A boolean.
      */
     public boolean isAccessibleChildSelected(int i)
-      throws NotImplementedException
     {
-      return false;
+      return i == getSelectedIndex();
     }
 
     /**
-     * DOCUMENT ME!
+     * Selects the specified tab.
      *
-     * @param i DOCUMENT ME!
+     * @param i  the index of the item to select.
      */
     public void addAccessibleSelection(int i)
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      setSelectedIndex(i);
     }
 
     /**
-     * DOCUMENT ME!
+     * Does nothing - it makes no sense to remove a selection for a
+     * tabbed pane, since one tab must always be selected.
      *
-     * @param i DOCUMENT ME!
+     * @param i  the item index.
+     * 
+     * @see #addAccessibleSelection(int)
      */
     public void removeAccessibleSelection(int i)
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      // do nothing
     }
 
     /**
-     * DOCUMENT ME!
+     * Does nothing - it makes no sense to clear the selection for
+     * a tabbed pane, since one tab must always be selected.
+     * 
+     * @see #addAccessibleSelection(int)
      */
     public void clearAccessibleSelection()
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      // do nothing
     }
 
     /**
-     * DOCUMENT ME!
+     * Does nothing - it makes no sense to select all for a tabbed
+     * pane, since only one tab can be selected at a time.
+     * 
+     * @see #addAccessibleSelection(int)
      */
     public void selectAllAccessibleSelection()
-      throws NotImplementedException
     {
-      // TODO: Implement this properly.
+      // do nothing
     }
   }
 
@@ -267,7 +273,6 @@ public class JTabbedPane extends JComponent implements Serializable,
    */
   protected class ModelListener implements ChangeListener, Serializable
   {
-    /** DOCUMENT ME! */
     private static final long serialVersionUID = 497359819958114132L;
 
     /**
@@ -446,7 +451,6 @@ public class JTabbedPane extends JComponent implements Serializable,
       return title;
     }
 
-    /** DOCUMENT ME! */
     private static final long serialVersionUID = 1614381073220130939L;
 
     /**
@@ -597,6 +601,19 @@ public class JTabbedPane extends JComponent implements Serializable,
       return this;
     }
 
+    /**
+     * Returns the accessible name for this tab.
+     * 
+     * @return The accessible name.
+     */
+    public String getAccessibleName()
+    {
+      if (accessibleName != null)
+        return accessibleName;
+      else
+        return title;
+    }
+    
     /**
      * Returns the accessible role of this tab, which is always
      * {@link AccessibleRole#PAGE_TAB}.
@@ -608,18 +625,31 @@ public class JTabbedPane extends JComponent implements Serializable,
       return AccessibleRole.PAGE_TAB;
     }
 
+    /**
+     * Returns the accessible state set of this object.
+     *
+     * @return the accessible state set of this object
+     */
     public AccessibleStateSet getAccessibleStateSet()
-      throws NotImplementedException
     {
-      // FIXME: Implement this properly.
-      return null;
+      AccessibleContext parentCtx = JTabbedPane.this.getAccessibleContext(); 
+      AccessibleStateSet state = parentCtx.getAccessibleStateSet();
+      state.add(AccessibleState.SELECTABLE);
+      if (component == getSelectedComponent())
+        state.add(AccessibleState.SELECTED);
+      return state;
     }
 
+    /**
+     * Returns the index of this tab inside its parent.
+     *
+     * @return the index of this tab inside its parent
+     */
     public int getAccessibleIndexInParent()
-      throws NotImplementedException
     {
-      // FIXME: Implement this properly.
-      return 0;
+      // TODO: Not sure if the title is unambiguous, but I can't figure
+      // another way of doing this.
+      return indexOfTab(title);
     }
 
     /**
@@ -1623,25 +1653,45 @@ public class JTabbedPane extends JComponent implements Serializable,
   }
 
   /**
-   * This method returns a string representation of this JTabbedPane. It is
-   * mainly used for debugging purposes.
+   * Returns a string describing the attributes for the 
+   * <code>JTabbedPane</code> component, for use in debugging.  The return 
+   * value is guaranteed to be non-<code>null</code>, but the format of the 
+   * string may vary between implementations.
    *
-   * @return A string representation of this JTabbedPane.
+   * @return A string describing the attributes of the 
+   *     <code>JTabbedPane</code>.
    */
   protected String paramString()
   {
-    return "JTabbedPane";
+    StringBuffer sb = new StringBuffer(super.paramString());
+    sb.append(",tabPlacement=");
+    if (tabPlacement == TOP)
+      sb.append("TOP");
+    if (tabPlacement == BOTTOM)
+      sb.append("BOTTOM");
+    if (tabPlacement == LEFT)
+      sb.append("LEFT");
+    if (tabPlacement == RIGHT)
+      sb.append("RIGHT");
+    return sb.toString();
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns the object that provides accessibility features for this
+   * <code>JTabbedPane</code> component.
    *
-   * @return DOCUMENT ME!
+   * @return The accessible context (an instance of 
+   *         {@link AccessibleJTabbedPane}).
    */
   public AccessibleContext getAccessibleContext()
   {
     if (accessibleContext == null)
-      accessibleContext = new AccessibleJTabbedPane();
+      {
+        AccessibleJTabbedPane ctx = new AccessibleJTabbedPane();
+        addChangeListener(ctx);
+        accessibleContext = ctx;
+      }
+
     return accessibleContext;
   }
 }
diff --git a/libjava/classpath/javax/swing/JTable.java b/libjava/classpath/javax/swing/JTable.java
index 348534469a8e..855530881f5e 100644
--- a/libjava/classpath/javax/swing/JTable.java
+++ b/libjava/classpath/javax/swing/JTable.java
@@ -63,6 +63,7 @@ import javax.accessibility.AccessibleContext;
 import javax.accessibility.AccessibleExtendedTable;
 import javax.accessibility.AccessibleRole;
 import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleState;
 import javax.accessibility.AccessibleStateSet;
 import javax.accessibility.AccessibleTable;
 import javax.accessibility.AccessibleTableModelChange;
@@ -165,6 +166,8 @@ public class JTable
       public AccessibleRole getAccessibleRole()
       {
         // TODO: What is the role of the table cell?
+        // Seems like the RI returns UNKNOWN here for 'normal' cells, might
+        // be different for special renderers though (not tested yet).
         return AccessibleRole.UNKNOWN;
       }
 
@@ -175,8 +178,27 @@ public class JTable
        */
       public AccessibleStateSet getAccessibleStateSet()
       {
-        // TODO: What state shoiuld be returned here?
-        return new AccessibleStateSet();
+        AccessibleStateSet state = new AccessibleStateSet();
+
+        // Figure out the SHOWING state.
+        Rectangle visibleRect = getVisibleRect();
+        Rectangle cellRect = getCellRect(row, column, false);
+        if (visibleRect.intersects(cellRect))
+          state.add(AccessibleState.SHOWING);
+
+        // Figure out SELECTED state.
+        if (isCellSelected(row, column))
+          state.add(AccessibleState.SELECTED);
+
+        // Figure out ACTIVE state.
+        if (row == getSelectedRow() && column == getSelectedColumn())
+          state.add(AccessibleState.ACTIVE);
+
+        // TRANSIENT seems to be always set in the RI.
+        state.add(AccessibleState.TRANSIENT);
+
+        // TODO: Any other state to handle here?
+        return state;
       }
 
       /**
@@ -594,7 +616,504 @@ public class JTable
         return lastColumn;
       }
     }
-   
+
+    /**
+     * The RI returns an instance with this name in
+     * {@link #getAccessibleColumnHeader()}, this makes sense, so we do the
+     * same.
+     */
+    private class AccessibleTableHeader
+      implements AccessibleTable
+    {
+
+      /**
+       * The JTableHeader wrapped by this class.
+       */
+      private JTableHeader header;
+
+      /**
+       * Creates a new instance.
+       *
+       * @param h the JTableHeader to wrap
+       */
+      private AccessibleTableHeader(JTableHeader h)
+      {
+        header = h;
+      }
+
+      /**
+       * Returns the caption for the table header.
+       *
+       * @return the caption for the table header
+       */
+      public Accessible getAccessibleCaption()
+      {
+        // The RI seems to always return null here, so do we.
+        return null;
+      }
+
+      /**
+       * Sets the caption for the table header.
+       *
+       * @param caption the caption to set
+       */
+      public void setAccessibleCaption(Accessible caption)
+      {
+        // This seems to be a no-op in the RI, so we do the same.
+      }
+
+      /**
+       * Returns the caption for the table header.
+       *
+       * @return the caption for the table header
+       */
+      public Accessible getAccessibleSummary()
+      {
+        // The RI seems to always return null here, so do we.
+        return null;
+      }
+
+      /**
+       * Sets the summary for the table header.
+       *
+       * @param summary the caption to set
+       */
+      public void setAccessibleSummary(Accessible summary)
+      {
+        // This seems to be a no-op in the RI, so we do the same.
+      }
+
+      /**
+       * Returns the number of rows, which is always 1 for the table header.
+       *
+       * @return the number of rows
+       */
+      public int getAccessibleRowCount()
+      {
+        return 1;
+      }
+
+      /**
+       * Returns the number of columns in the table header.
+       *
+       * @return the number of columns in the table header
+       */
+      public int getAccessibleColumnCount()
+      {
+        return header.getColumnModel().getColumnCount();
+      }
+
+      /**
+       * Returns the accessible child at the specified row and column.
+       * The row number is ignored here, and we return an
+       * AccessibleJTableHeaderCell here with the renderer component as
+       * component.
+       *
+       * @param r the row number
+       * @param c the column number
+       *
+       * @return the accessible child at the specified row and column
+       */
+      public Accessible getAccessibleAt(int r, int c)
+      {
+        TableColumn column = header.getColumnModel().getColumn(c);
+        TableCellRenderer rend = column.getHeaderRenderer();
+        if (rend == null)
+          rend = header.getDefaultRenderer();
+        Component comp =
+          rend.getTableCellRendererComponent(header.getTable(),
+                                             column.getHeaderValue(), false,
+                                             false, -1, c);
+        return new AccessibleJTableHeaderCell(header, comp, r, c);
+      }
+
+      public int getAccessibleRowExtentAt(int r, int c)
+      {
+        // TODO Auto-generated method stub
+        return 0;
+      }
+
+      public int getAccessibleColumnExtentAt(int r, int c)
+      {
+        // TODO Auto-generated method stub
+        return 0;
+      }
+
+      public AccessibleTable getAccessibleRowHeader()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setAccessibleRowHeader(AccessibleTable header)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public AccessibleTable getAccessibleColumnHeader()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setAccessibleColumnHeader(AccessibleTable header)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Accessible getAccessibleRowDescription(int r)
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setAccessibleRowDescription(int r, Accessible description)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Accessible getAccessibleColumnDescription(int c)
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setAccessibleColumnDescription(int c, Accessible description)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public boolean isAccessibleSelected(int r, int c)
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public boolean isAccessibleRowSelected(int r)
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public boolean isAccessibleColumnSelected(int c)
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public int[] getSelectedAccessibleRows()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public int[] getSelectedAccessibleColumns()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+        
+    }
+
+    /**
+     * The RI returns an instance of such class for table header cells. This
+     * makes sense so I added this class. This still needs to be fully
+     * implemented, I just don't feel motivated enough to do so just now.
+     */
+    private class AccessibleJTableHeaderCell
+      extends AccessibleContext
+      implements Accessible, AccessibleComponent
+    {
+
+      JTableHeader header;
+      
+      int columnIndex;
+      
+      /**
+       * 
+       * @param h  the table header.
+       * @param comp
+       * @param r
+       * @param c  the column index.
+       */
+      private AccessibleJTableHeaderCell(JTableHeader h, Component comp, int r,
+                                         int c)
+      {
+        header = h;
+        columnIndex = c;
+      }
+
+      /**
+       * Returns the header renderer.
+       * 
+       * @return The header renderer.
+       */
+      Component getColumnHeaderRenderer()
+      {
+        TableColumn tc = header.getColumnModel().getColumn(columnIndex);
+        TableCellRenderer r = tc.getHeaderRenderer();
+        if (r == null)
+          r = header.getDefaultRenderer();
+        return r.getTableCellRendererComponent(header.getTable(), 
+            tc.getHeaderValue(), false, false, -1, columnIndex);
+      }
+      
+      /**
+       * Returns the accessible role for the table header cell.
+       * 
+       * @return The accessible role.
+       */
+      public AccessibleRole getAccessibleRole()
+      {
+        Component renderer = getColumnHeaderRenderer();
+        if (renderer instanceof Accessible)
+          {
+            Accessible ac = (Accessible) renderer;
+            return ac.getAccessibleContext().getAccessibleRole();
+          }
+        return null;
+      }
+
+      public AccessibleStateSet getAccessibleStateSet()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public int getAccessibleIndexInParent()
+      {
+        // TODO Auto-generated method stub
+        return 0;
+      }
+
+      public int getAccessibleChildrenCount()
+      {
+        // TODO Auto-generated method stub
+        return 0;
+      }
+
+      public Accessible getAccessibleChild(int i)
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public Locale getLocale()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      /**
+       * Returns the accessible context.
+       * 
+       * @return <code>this</code>.
+       */
+      public AccessibleContext getAccessibleContext()
+      {
+        return this;
+      }
+
+      public Color getBackground()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setBackground(Color color)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Color getForeground()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setForeground(Color color)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Cursor getCursor()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setCursor(Cursor cursor)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Font getFont()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setFont(Font font)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public FontMetrics getFontMetrics(Font font)
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public boolean isEnabled()
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public void setEnabled(boolean b)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public boolean isVisible()
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public void setVisible(boolean b)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public boolean isShowing()
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public boolean contains(Point point)
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public Point getLocationOnScreen()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public Point getLocation()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setLocation(Point point)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Rectangle getBounds()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setBounds(Rectangle rectangle)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Dimension getSize()
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public void setSize(Dimension dimension)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public Accessible getAccessibleAt(Point point)
+      {
+        // TODO Auto-generated method stub
+        return null;
+      }
+
+      public boolean isFocusTraversable()
+      {
+        // TODO Auto-generated method stub
+        return false;
+      }
+
+      public void requestFocus()
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public void addFocusListener(FocusListener listener)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+
+      public void removeFocusListener(FocusListener listener)
+      {
+        // TODO Auto-generated method stub
+        
+      }
+      
+    }
+
+    /**
+     * The last selected row. This is needed to track the selection in
+     * {@link #valueChanged(ListSelectionEvent)}.
+     */
+    private int lastSelectedRow;
+
+    /**
+     * The last selected column. This is needed to track the selection in
+     * {@link #valueChanged(ListSelectionEvent)}.
+     */
+    private int lastSelectedColumn;
+
+    /**
+     * The caption of the table.
+     */
+    private Accessible caption;
+
+    /**
+     * The summary of the table.
+     */
+    private Accessible summary;
+
+    /**
+     * Accessible descriptions for rows.
+     */
+    private Accessible[] rowDescriptions;
+
+    /**
+     * Accessible descriptions for columns.
+     */
+    private Accessible[] columnDescriptions;
+
     /**
      * Creates a new <code>AccessibleJTable</code>.
      *
@@ -605,9 +1124,33 @@ public class JTable
       getModel().addTableModelListener(this);
       getSelectionModel().addListSelectionListener(this);
       getColumnModel().addColumnModelListener(this);
-      getCellEditor().addCellEditorListener(this);
+      lastSelectedRow = getSelectedRow();
+      lastSelectedColumn = getSelectedColumn();
+      TableCellEditor editor = getCellEditor();
+      if (editor != null)
+        editor.addCellEditorListener(this);
     }
 
+    /**
+     * Returns the accessible role for the <code>JTable</code> component.
+     *
+     * @return {@link AccessibleRole#TABLE}.
+     */
+    public AccessibleRole getAccessibleRole()
+    {
+      return AccessibleRole.TABLE;
+    }
+    
+    /**
+     * Returns the accessible table.
+     * 
+     * @return <code>this</code>.
+     */
+    public AccessibleTable getAccessibleTable()
+    {
+      return this;
+    }
+    
     /**
      * Returns the number of selected items in this table.
      */
@@ -616,46 +1159,197 @@ public class JTable
       return getSelectedColumnCount();
     }
 
+    /**
+     * Returns the selected accessible object with the specified index
+     * <code>i</code>. This basically returns the i-th selected cell in the
+     * table when going though it row-wise, and inside the rows, column-wise.
+     *
+     * @param i the index of the selected object to find
+     *
+     * @return the selected accessible object with the specified index
+     *         <code>i</code>
+     */
     public Accessible getAccessibleSelection(int i)
     {
-      // TODO Auto-generated method stub
-      return null;
+      Accessible found = null;
+
+      int[] selectedRows = getSelectedRows();
+      int[] selectedColumns = getSelectedColumns();
+      int numCols = getColumnCount();
+      int numRows = getRowCount();
+
+      // We have to go through every selected row and column and count until we
+      // find the specified index. This is potentially inefficient, but I can't
+      // think of anything better atm.
+      if (getRowSelectionAllowed() && getColumnSelectionAllowed())
+        {
+          int current = -1;
+          int newIndex = current;
+          int lastSelectedRow = -1;
+          // Go through the selected rows array, don't forget the selected
+          // cells inside the not-selected rows' columns.
+          for (int j = 0; i < selectedRows.length; i++)
+            {
+              // Handle unselected rows between this selected and the last
+              // selected row, if any.
+              int selectedRow = selectedRows[j];
+              int r = -1;
+              int ci = -1;
+              for (r = lastSelectedRow + 1;
+                   r < selectedRow && current < i; r++)
+                {
+                  for (ci = 0; ci < selectedColumns.length && current < i;
+                       ci++)
+                    {
+                      current++;
+                    }
+                }
+              if (current == i)
+                {
+                  // We found the cell in the above loops, now get out of here.
+                  found = getAccessibleChild(r * numCols
+                                             + selectedColumns[ci]);
+                  break;
+                }
+
+              // If we're still here, handle the current selected row.
+              if (current < i && current + numCols >= i)
+                {
+                  // The cell must be in that row, which one is it?
+                  found = getAccessibleChild(r * numCols + (i - current));
+                  break;
+                }
+              current += numCols;
+            }
+          if (found == null)
+            {
+              // The cell can still be in the last couple of unselected rows.
+              int r = 0;
+              int ci = 0;
+              for (r = lastSelectedRow + 1;
+                   r < numRows && current < i; r++)
+                {
+                  for (ci = 0; ci < selectedColumns.length && current < i;
+                       ci++)
+                    {
+                      current++;
+                    }
+                }
+              if (current == i)
+                {
+                  // We found the cell in the above loops, now get out of here.
+                  found = getAccessibleChild(r * numCols
+                                             + selectedColumns[ci]);
+                }
+            }
+        }
+      // One or more rows can be completely selected.
+      else if (getRowSelectionAllowed())
+        {
+          int c = i % numCols;
+          int r = selectedRows[i / numCols];
+          found = getAccessibleChild(r * numCols + c);
+        }
+      // One or more columns can be completely selected.
+      else if (getRowSelectionAllowed())
+        {
+          int numSelectedColumns = selectedColumns.length;
+          int c = selectedColumns[i % numSelectedColumns];
+          int r = i / numSelectedColumns;
+          found = getAccessibleChild(r * numCols + c);
+        }
+
+      return found;
     }
 
+    /**
+     * Returns <code>true</code> if the accessible child with the index
+     * <code>i</code> is selected, <code>false</code> otherwise.
+     *
+     * @param i the index of the accessible to check
+     *
+     * @return <code>true</code> if the accessible child with the index
+     *         <code>i</code> is selected, <code>false</code> otherwise
+     */
     public boolean isAccessibleChildSelected(int i)
     {
-      // TODO Auto-generated method stub
-      return false;
+      int r = getAccessibleRowAtIndex(i);
+      int c = getAccessibleColumnAtIndex(i);
+      return isCellSelected(r, c);
     }
 
+    /**
+     * Adds the accessible child with the specified index <code>i</code> to the
+     * selection.
+     *
+     * @param i the index of the accessible child to add to the selection
+     */
     public void addAccessibleSelection(int i)
     {
-      // TODO Auto-generated method stub
-      
+      int r = getAccessibleRowAtIndex(i);
+      int c = getAccessibleColumnAtIndex(i);
+      changeSelection(r, c, true, false);
     }
 
+    /**
+     * Removes the accessible child with the specified index <code>i</code>
+     * from the current selection. This will only work on tables that have
+     * cell selection enabled (<code>rowSelectionAllowed == false &&
+     * columnSelectionAllowed == false</code>).
+     *
+     * @param i the index of the accessible to be removed from the selection
+     */
     public void removeAccessibleSelection(int i)
     {
-      // TODO Auto-generated method stub
-      
+      if (! getRowSelectionAllowed() && ! getColumnSelectionAllowed())
+        {
+          int r = getAccessibleRowAtIndex(i);
+          int c = getAccessibleColumnAtIndex(i);
+          removeRowSelectionInterval(r, r);
+          removeColumnSelectionInterval(c, c);
+        }
     }
 
+    /**
+     * Deselects all selected accessible children.
+     */
     public void clearAccessibleSelection()
     {
-      // TODO Auto-generated method stub
-      
+      clearSelection();
     }
 
+    /**
+     * Selects all accessible children that can be selected. This will only
+     * work on tables that support multiple selections and that have individual
+     * cell selection enabled.
+     */
     public void selectAllAccessibleSelection()
     {
-      // TODO Auto-generated method stub
-      
+      selectAll();
     }
 
+    /**
+     * Receives notification when the row selection changes and fires
+     * appropriate property change events.
+     *
+     * @param event the list selection event
+     */
     public void valueChanged(ListSelectionEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
+                         Boolean.FALSE, Boolean.TRUE);
+      int r = getSelectedRow();
+      int c = getSelectedColumn();
+      if (r != lastSelectedRow || c != lastSelectedColumn)
+        {
+          Accessible o = getAccessibleAt(lastSelectedRow,
+                                         lastSelectedColumn);
+          Accessible n = getAccessibleAt(r, c);
+          firePropertyChange(AccessibleContext
+                             .ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, o, n);
+          lastSelectedRow = r;
+          lastSelectedColumn = c;
+        }
     }
 
     /**
@@ -680,14 +1374,13 @@ public class JTable
 
     /**
      * Receives notification when one or more rows have been inserted into the
-     * table.
+     * table and fires appropriate property change events.
      *
      * @param event the table model event
      */
     public void tableRowsInserted(TableModelEvent event)
     {
-      // TODO: What to do here, if anything? This might be a hook method for
-      // subclasses...
+      handleRowChange(event);
     }
 
     /**
@@ -698,50 +1391,93 @@ public class JTable
      */
     public void tableRowsDeleted(TableModelEvent event)
     {
-      // TODO: What to do here, if anything? This might be a hook method for
-      // subclasses...
+      handleRowChange(event);
+    }
+
+    /**
+     * Fires a PropertyChangeEvent for inserted or deleted rows.
+     *
+     * @param event the table model event
+     */
+    private void handleRowChange(TableModelEvent event)
+    {
+      firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
+                         null, null);
+      int firstColumn = event.getColumn();
+      int lastColumn = event.getColumn();
+      if (firstColumn == TableModelEvent.ALL_COLUMNS)
+        {
+          firstColumn = 0;
+          lastColumn = getColumnCount() - 1;
+        }
+      AccessibleJTableModelChange change = new AccessibleJTableModelChange
+         (event.getType(), event.getFirstRow(), event.getLastRow(),
+          firstColumn, lastColumn);
+      firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
+                         null, change);
     }
 
     public void columnAdded(TableColumnModelEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
+                         null, null);
+      handleColumnChange(AccessibleTableModelChange.INSERT,
+                         event.getFromIndex(), event.getToIndex());
     }
 
-    public void columnMarginChanged(ChangeEvent event)
+    public void columnRemoved(TableColumnModelEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
+                         null, null);
+      handleColumnChange(AccessibleTableModelChange.DELETE,
+                         event.getFromIndex(), event.getToIndex());
     }
 
     public void columnMoved(TableColumnModelEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
+                         null, null);
+      handleColumnChange(AccessibleTableModelChange.DELETE,
+                         event.getFromIndex(), event.getFromIndex());
+      handleColumnChange(AccessibleTableModelChange.INSERT,
+                         event.getFromIndex(), event.getToIndex());
+    }
+
+    /**
+     * Fires a PropertyChangeEvent for inserted or deleted columns.
+     *
+     * @param type the type of change
+     * @param from the start of the change
+     * @param to the target of the change
+     */
+    private void handleColumnChange(int type, int from, int to)
+    {
+      AccessibleJTableModelChange change =
+        new AccessibleJTableModelChange(type, 0, 0, from, to);
+      firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
+                         null, change);
     }
 
-    public void columnRemoved(TableColumnModelEvent event)
+    public void columnMarginChanged(ChangeEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
+                         null, null);
     }
 
     public void columnSelectionChanged(ListSelectionEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      // AFAICS, nothing is done here.
     }
 
     public void editingCanceled(ChangeEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      // AFAICS, nothing is done here.
     }
 
     public void editingStopped(ChangeEvent event)
     {
-      // TODO Auto-generated method stub
-      
+      firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
+                         null, null);
     }
 
     /**
@@ -784,154 +1520,343 @@ public class JTable
         }
     }
 
+    /**
+     * Returns the row number of an accessible child (cell) with the specified
+     * index.
+     *
+     * @param index the index of the cell of which the row number is queried
+     * 
+     * @return the row number of an accessible child (cell) with the specified
+     *         index 
+     */
     public int getAccessibleRow(int index)
     {
-      // TODO Auto-generated method stub
-      return 0;
+      return getAccessibleRowAtIndex(index);
     }
 
+    /**
+     * Returns the column number of an accessible child (cell) with the
+     * specified index.
+     *
+     * @param index the index of the cell of which the column number is queried
+     * 
+     * @return the column number of an accessible child (cell) with the
+     *         specified index 
+     */
     public int getAccessibleColumn(int index)
     {
-      // TODO Auto-generated method stub
-      return 0;
+      return getAccessibleColumnAtIndex(index);
     }
 
+    /**
+     * Returns the index of the accessible child at the specified row and
+     * column.
+     *
+     * @param r the row number
+     * @param c the column number
+     *
+     * @return the index of the accessible child at the specified row and
+     *         column
+     */
     public int getAccessibleIndex(int r, int c)
     {
-      // TODO Auto-generated method stub
-      return 0;
+      return getAccessibleIndexAt(r, c);
     }
 
+    /**
+     * Returns the caption of the table.
+     *
+     * @return the caption of the table
+     *
+     * @see #setAccessibleCaption(Accessible)
+     */
     public Accessible getAccessibleCaption()
     {
-      // TODO Auto-generated method stub
-      return null;
+      return caption;
     }
 
-    public void setAccessibleCaption(Accessible caption)
+    /**
+     * Sets the caption for the table.
+     *
+     * @param c the caption to set
+     */
+    public void setAccessibleCaption(Accessible c)
     {
-      // TODO Auto-generated method stub
-      
+      caption = c;
     }
 
+    /**
+     * Returns the summary for the table.
+     *
+     * @return the summary for the table
+     */
     public Accessible getAccessibleSummary()
     {
-      // TODO Auto-generated method stub
-      return null;
+      return summary;
     }
 
-    public void setAccessibleSummary(Accessible summary)
+    /**
+     * Sets the summary for the table.
+     *
+     * @param s the summary to set
+     */
+    public void setAccessibleSummary(Accessible s)
     {
-      // TODO Auto-generated method stub
-      
+      summary = s;
     }
 
+    /**
+     * Returns the number of rows in the table.
+     *
+     * @return the number of rows in the table
+     */
     public int getAccessibleRowCount()
     {
-      // TODO Auto-generated method stub
-      return 0;
+      return getRowCount();
     }
 
+    /**
+     * Returns the number of columns in the table.
+     *
+     * @return the number of columns in the table
+     */
     public int getAccessibleColumnCount()
     {
-      // TODO Auto-generated method stub
-      return 0;
+      return getColumnCount();
     }
 
+    /**
+     * Returns the accessible child at the given index.
+     *
+     * @param index  the child index.
+     * 
+     * @return The accessible child.
+     */
+    public Accessible getAccessibleChild(int index)
+    {
+      int r = getAccessibleRow(index);
+      int c = getAccessibleColumn(index);
+      return getAccessibleAt(r, c);  
+    }
+    
+    /**
+     * Returns the accessible child (table cell) at the specified row and
+     * column.
+     *
+     * @param r the row number
+     * @param c the column number
+     *
+     * @return the accessible child (table cell) at the specified row and
+     *         column
+     */
     public Accessible getAccessibleAt(int r, int c)
     {
-      // TODO Auto-generated method stub
+      TableCellRenderer cellRenderer = getCellRenderer(r, c);
+      Component renderer = cellRenderer.getTableCellRendererComponent(
+          JTable.this, getValueAt(r, c), isCellSelected(r, c), false, r, c);
+      if (renderer instanceof Accessible)
+        return (Accessible) renderer;
       return null;
     }
 
+    /**
+     * Returns the number of rows that the specified cell occupies. The
+     * standard table cells only occupy one row, so we return <code>1</code>
+     * here.
+     *
+     * @param r the row number
+     * @param c the column number
+     *
+     * @return the number of rows that the specified cell occupies
+     */
     public int getAccessibleRowExtentAt(int r, int c)
     {
-      // TODO Auto-generated method stub
-      return 0;
+      return 1;
     }
 
+    /**
+     * Returns the number of columns that the specified cell occupies. The
+     * standard table cells only occupy one column, so we return <code>1</code>
+     * here.
+     *
+     * @param r the row number
+     * @param c the column number
+     *
+     * @return the number of rows that the specified cell occupies
+     */
     public int getAccessibleColumnExtentAt(int r, int c)
     {
-      // TODO Auto-generated method stub
-      return 0;
+      return 1;
     }
 
+    /**
+     * Returns the accessible row header.
+     *
+     * @return the accessible row header
+     */
     public AccessibleTable getAccessibleRowHeader()
     {
-      // TODO Auto-generated method stub
+      // The RI seems to always return null here, so do we.
       return null;
     }
 
+    /**
+     * Sets the accessible row header.
+     *
+     * @param header the header to set
+     */
     public void setAccessibleRowHeader(AccessibleTable header)
     {
-      // TODO Auto-generated method stub
-      
+      // In the RI this seems to be a no-op.    
     }
 
+    /**
+     * Returns the column header.
+     *
+     * @return the column header, or <code>null</code> if there is no column
+     *         header
+     */
     public AccessibleTable getAccessibleColumnHeader()
     {
-      // TODO Auto-generated method stub
-      return null;
+      JTableHeader h = getTableHeader();
+      AccessibleTable header = null;
+      if (h != null)
+        header = new AccessibleTableHeader(h);
+      return header;
     }
 
+    /**
+     * Sets the accessible column header. The default implementation doesn't
+     * allow changing the header this way, so this is a no-op.
+     *
+     * @param header the accessible column header to set
+     */
     public void setAccessibleColumnHeader(AccessibleTable header)
     {
-      // TODO Auto-generated method stub
-      
+      // The RI doesn't seem to do anything, so we also do nothing.
     }
 
+    /**
+     * Returns the accessible description for the row with the specified index,
+     * or <code>null</code> if no description has been set.
+     *
+     * @param r the row for which the description is queried
+     *
+     * @return the accessible description for the row with the specified index,
+     *         or <code>null</code> if no description has been set
+     */
     public Accessible getAccessibleRowDescription(int r)
     {
-      // TODO Auto-generated method stub
-      return null;
+      Accessible descr = null;
+      if (rowDescriptions != null)
+        descr = rowDescriptions[r];
+      return descr;
     }
 
+    /**
+     * Sets the accessible description for the row with the specified index.
+     *
+     * @param r the row number for which to set the description
+     * @param description the description to set
+     */
     public void setAccessibleRowDescription(int r, Accessible description)
     {
-      // TODO Auto-generated method stub
-      
+      if (rowDescriptions == null)
+        rowDescriptions = new Accessible[getAccessibleRowCount()];
+      rowDescriptions[r] = description;
     }
 
+    /**
+     * Returns the accessible description for the column with the specified
+     * index, or <code>null</code> if no description has been set.
+     *
+     * @param c the column for which the description is queried
+     *
+     * @return the accessible description for the column with the specified
+     *         index, or <code>null</code> if no description has been set
+     */
     public Accessible getAccessibleColumnDescription(int c)
     {
-      // TODO Auto-generated method stub
-      return null;
+      Accessible descr = null;
+      if (columnDescriptions != null)
+        descr = columnDescriptions[c];
+      return descr;
     }
 
+    /**
+     * Sets the accessible description for the column with the specified index.
+     *
+     * @param c the column number for which to set the description
+     * @param description the description to set
+     */
     public void setAccessibleColumnDescription(int c, Accessible description)
     {
-      // TODO Auto-generated method stub
-      
+      if (columnDescriptions == null)
+        columnDescriptions = new Accessible[getAccessibleRowCount()];
+      columnDescriptions[c] = description;
     }
 
+    /**
+     * Returns <code>true</code> if the accessible child at the specified
+     * row and column is selected, <code>false</code> otherwise.
+     *
+     * @param r the row number of the child
+     * @param c the column number of the child
+     *
+     * @return <code>true</code> if the accessible child at the specified
+     *         row and column is selected, <code>false</code> otherwise
+     */
     public boolean isAccessibleSelected(int r, int c)
     {
-      // TODO Auto-generated method stub
-      return false;
+      return isCellSelected(r, c);
     }
 
+    /**
+     * Returns <code>true</code> if the row with the specified index is
+     * selected, <code>false</code> otherwise.
+     *
+     * @param r the row number
+     *
+     * @return <code>true</code> if the row with the specified index is
+     *        selected, <code>false</code> otherwise
+     */
     public boolean isAccessibleRowSelected(int r)
     {
-      // TODO Auto-generated method stub
-      return false;
+      return isRowSelected(r);
     }
 
+    /**
+     * Returns <code>true</code> if the column with the specified index is
+     * selected, <code>false</code> otherwise.
+     *
+     * @param c the column number
+     *
+     * @return <code>true</code> if the column with the specified index is
+     *        selected, <code>false</code> otherwise
+     */
     public boolean isAccessibleColumnSelected(int c)
     {
-      // TODO Auto-generated method stub
-      return false;
+      return isColumnSelected(c);
     }
 
+    /**
+     * Returns the indices of all selected rows.
+     *
+     * @return the indices of all selected rows
+     */
     public int[] getSelectedAccessibleRows()
     {
-      // TODO Auto-generated method stub
-      return null;
+      return getSelectedRows();
     }
 
+    /**
+     * Returns the indices of all selected columns.
+     *
+     * @return the indices of all selected columns
+     */
     public int[] getSelectedAccessibleColumns()
     {
-      // TODO Auto-generated method stub
-      return null;
+      return getSelectedColumns();
     }
 
     /**
@@ -1017,7 +1942,17 @@ public class JTable
     /**
      * The CheckBox that is used for rendering.
      */
-    private final JCheckBox checkBox = new JCheckBox();
+    private final JCheckBox checkBox;
+    
+    /**
+     * Creates a new checkbox based boolean cell renderer. The checkbox is
+     * centered by default.
+     */
+    BooleanCellRenderer()
+    {
+       checkBox = new JCheckBox();
+       checkBox.setHorizontalAlignment(SwingConstants.CENTER);
+    }
    
     /**
      * Get the check box.
@@ -1223,6 +2158,12 @@ public class JTable
   private class IconCellRenderer
     extends DefaultTableCellRenderer
   {
+    IconCellRenderer()
+    {
+      setHorizontalAlignment(SwingConstants.CENTER);
+    }
+    
+    
     /**
      * Returns the component that is used for rendering the value.
      *
@@ -1272,17 +2213,6 @@ public class JTable
       {
         setBorder(BorderFactory.createLineBorder(getGridColor(), 2));
       }
-    
-      /**
-       * With not this method overridden, the scroll pane scrolls to the
-       * top left cornec (untranslated position of the caret) after the first
-       * keystroke. 
-       */
-      public void scrollRectToVisible(Rectangle r)
-      {
-        // Do nothing here. If the editing session starts outside the visible
-        // bounds, the editCellAt will scroll.
-      }
     }    
   
 
@@ -1335,14 +2265,14 @@ public class JTable
    * {@link TableCellEditor} objects. This table is consulted by the 
    * FIXME
    */
-  protected Hashtable defaultEditorsByColumnClass;
+  protected Hashtable defaultEditorsByColumnClass = new Hashtable();
 
   /**
    * A table mapping {@link java.lang.Class} objects to 
    * {@link TableCellEditor} objects. This table is consulted by the 
    * FIXME
    */
-  protected Hashtable defaultRenderersByColumnClass;
+  protected Hashtable defaultRenderersByColumnClass = new Hashtable();
 
   /**
    * The column that is edited, -1 if the table is not edited currently.
@@ -1587,6 +2517,27 @@ public class JTable
    */
   private boolean clientRowHeightSet = false;
 
+  /**
+   * Stores the sizes and positions of each row, when using non-uniform row
+   * heights. Initially the height of all rows is equal and stored in
+   * {link #rowHeight}. However, when an application calls
+   * {@link #setRowHeight(int,int)}, the table switches to non-uniform
+   * row height mode which stores the row heights in the SizeSequence
+   * object instead.
+   *
+   * @see #setRowHeight(int)
+   * @see #getRowHeight()
+   * @see #getRowHeight(int)
+   * @see #setRowHeight(int, int)
+   */
+  private SizeSequence rowHeights;
+  
+  /**
+   * This editor serves just a marker that the value must be simply changed to
+   * the opposite one instead of starting the editing session.
+   */
+  private transient TableCellEditor booleanInvertingEditor; 
+  
   /**
    * Creates a new <code>JTable</code> instance.
    */
@@ -1719,15 +2670,9 @@ public class JTable
     if (autoCreateColumnsFromModel)
       createDefaultColumnsFromModel();
     this.columnModel.addColumnModelListener(this);
-    
-    this.defaultRenderersByColumnClass = new Hashtable();
-    createDefaultRenderers();
-
-    this.defaultEditorsByColumnClass = new Hashtable();
-    createDefaultEditors();
 
     this.autoResizeMode = AUTO_RESIZE_SUBSEQUENT_COLUMNS;
-    this.rowHeight = 16;
+    setRowHeight(16);
     this.rowMargin = 1;
     this.rowSelectionAllowed = true;
     // this.accessibleContext = new AccessibleJTable();
@@ -1773,7 +2718,10 @@ public class JTable
   protected void createDefaultEditors()
   {
     JCheckBox box = new BooleanCellRenderer().getCheckBox();
-    setDefaultEditor(Boolean.class, new DefaultCellEditor(box));
+    box.setBorder(BorderFactory.createLineBorder(getGridColor(), 2));
+    box.setBorderPainted(true);
+    booleanInvertingEditor = new DefaultCellEditor(box);    
+    setDefaultEditor(Boolean.class, booleanInvertingEditor);
   }
   
   /**
@@ -1871,6 +2819,8 @@ public class JTable
    */
   public void columnMoved (TableColumnModelEvent event)
   {
+    if (isEditing())
+      editingCanceled(null);
     revalidate();
     repaint();
   }
@@ -1891,12 +2841,6 @@ public class JTable
    */
   public void columnSelectionChanged (ListSelectionEvent event)
   {
-    // Does not make sense for the table with the single column.
-    if (getColumnCount() < 2)
-      return;
-    
-    int x0 = 0;
-    
     // We must limit the indices to the bounds of the JTable's model, because
     // we might get values of -1 or greater then columnCount in the case
     // when columns get removed.
@@ -1904,17 +2848,39 @@ public class JTable
                                     event.getFirstIndex()));
     int idxn = Math.max(0, Math.min(getColumnCount() - 1,
                                     event.getLastIndex()));
-    int i;
 
-    for (i = 0; i < idx0; i++)
-      x0 += columnModel.getColumn(i).getWidth();
-    
-    int xn = x0;
-    
-    for (i = idx0; i <= idxn; i++)
-      xn += columnModel.getColumn(i).getWidth();
-    
-    repaint(x0, 0, xn-x0, getHeight());
+    int minRow = 0;
+    int maxRow = getRowCount() - 1;
+    if (getRowSelectionAllowed())
+      {
+        minRow = selectionModel.getMinSelectionIndex();
+        maxRow = selectionModel.getMaxSelectionIndex();
+        int leadRow = selectionModel.getLeadSelectionIndex();
+        if (minRow == -1 && maxRow == -1)
+          {
+            minRow = leadRow;
+            maxRow = leadRow;
+          }
+        else
+          {
+            // In this case we need to repaint also the range to leadRow, not
+            // only between min and max.
+            if (leadRow != -1)
+              {
+                minRow = Math.min(minRow, leadRow);
+                maxRow = Math.max(maxRow, leadRow);
+              }
+          }
+      }
+    if (minRow != -1 && maxRow != -1)
+      {
+        Rectangle first = getCellRect(minRow, idx0, false);
+        Rectangle last = getCellRect(maxRow, idxn, false);
+        Rectangle dirty = SwingUtilities.computeUnion(first.x, first.y,
+                                                      first.width,
+                                                      first.height, last);
+        repaint(dirty);
+      }
   }
  
   /**
@@ -1958,7 +2924,13 @@ public class JTable
     // changed and the flag autoCreateColumnsFromModel is set
     if ((event == null || (event.getFirstRow() == TableModelEvent.HEADER_ROW))
 	&& autoCreateColumnsFromModel)
-      createDefaultColumnsFromModel();
+      {
+        rowHeights = null;
+        if (getAutoCreateColumnsFromModel())
+          createDefaultColumnsFromModel();
+        resizeAndRepaint();
+        return;
+      }
 
     // If the structure changes, we need to revalidate, since that might
     // affect the size parameters of the JTable. Otherwise we only need
@@ -1975,6 +2947,8 @@ public class JTable
             if (last < 0)
               last = getRowCount() - 1;
             selectionModel.insertIndexInterval(first, last - first + 1, true);
+            if (rowHeights != null)
+              rowHeights.insertEntries(first, last - first + 1, rowHeight);
           }
         revalidate();
       }
@@ -1990,6 +2964,8 @@ public class JTable
             if (last < 0)
               last = getRowCount() - 1;
             selectionModel.removeIndexInterval(first, last);
+            if (rowHeights != null)
+              rowHeights.removeEntries(first, last - first + 1);
           }
         if (dataModel.getRowCount() == 0)
           clearSelection();
@@ -2004,14 +2980,19 @@ public class JTable
    */
   public void valueChanged (ListSelectionEvent event)
   {
-    // Does not make sense for the table with the single row.
-    if (getRowCount() < 2)
-      return;
+    // If we are in the editing process, end the editing session.
+    if (isEditing())
+      editingStopped(null);
     
-    int y_gap = rowMargin;
-    int y0 = (getRowHeight() + y_gap) * (event.getFirstIndex());
-    int yn = (getRowHeight() + y_gap) * (event.getLastIndex()+1);
-    repaint(0, y0, getWidth(), yn-y0);
+    // Repaint the changed region.
+    int first = Math.max(0, Math.min(getRowCount() - 1, event.getFirstIndex()));
+    int last = Math.max(0, Math.min(getRowCount() - 1, event.getLastIndex()));
+    Rectangle rect1 = getCellRect(first, 0, false);
+    Rectangle rect2 = getCellRect(last, getColumnCount() - 1, false);
+    Rectangle dirty = SwingUtilities.computeUnion(rect2.x, rect2.y,
+                                                  rect2.width, rect2.height,
+                                                  rect1);
+    repaint(dirty);
   }
 
  /**
@@ -2053,10 +3034,16 @@ public class JTable
     if (point != null)
       {
         int nrows = getRowCount();
-        int height = getRowHeight() + getRowMargin();
+        int r;
         int y = point.y;
+        if (rowHeights == null)
+          {
+            int height = getRowHeight();
+            r = y / height;
+          }
+        else
+          r = rowHeights.getIndex(y);
 
-        int r = y / height;
         if (r < 0 || r >= nrows)
           return -1;
         else
@@ -2086,27 +3073,70 @@ public class JTable
                                int column,
                                boolean includeSpacing)
   {
-    int height = getRowHeight(row);
-    int width = columnModel.getColumn(column).getWidth();
-    int x_gap = columnModel.getColumnMargin();
-    int y_gap = rowMargin;
+    Rectangle cellRect = new Rectangle(0, 0, 0, 0);
 
-    column = Math.max(0, Math.min(column, getColumnCount() - 1));
-    row = Math.max(0, Math.min(row, getRowCount() - 1));
-
-    int x = 0;
-    int y = (height + y_gap) * row;
+    // Check for valid range vertically.
+    if (row >= getRowCount())
+      {
+        cellRect.height = getHeight();
+      }
+    else if (row >= 0)
+      {
+        cellRect.height = getRowHeight(row);
+        if (rowHeights == null)
+          cellRect.y = row * cellRect.height;
+        else
+          cellRect.y = rowHeights.getPosition(row);
 
-    for (int i = 0; i < column; ++i)
-      x += columnModel.getColumn(i).getWidth();
-    
-    Rectangle rect = new Rectangle();
+        if (! includeSpacing)
+          {
+            // The rounding here is important.
+            int rMargin = getRowMargin();
+            cellRect.y += rMargin / 2;
+            cellRect.height -= rMargin;
+          }
+      }
+    // else row < 0, y = height = 0
 
-    if (includeSpacing)
-      rect.setBounds(x, y, width, height +y_gap);
+    // Check for valid range horizontally.
+    if (column < 0)
+      {
+        if (! getComponentOrientation().isLeftToRight())
+          {
+            cellRect.x = getWidth();
+          }
+      }
+    else if (column >= getColumnCount())
+      {
+        if (getComponentOrientation().isLeftToRight())
+          {
+            cellRect.x = getWidth();
+          }
+      }
     else
-      rect.setBounds(x, y, width - x_gap, height);
-    return rect;
+      {
+        TableColumnModel tcm = getColumnModel();
+        if (getComponentOrientation().isLeftToRight())
+          {
+            for (int i = 0; i < column; i++)
+              cellRect.x += tcm.getColumn(i).getWidth();
+          }
+        else
+          {
+            for (int i = tcm.getColumnCount() - 1; i > column; i--)
+              cellRect.x += tcm.getColumn(i).getWidth();
+          }
+        cellRect.width = tcm.getColumn(column).getWidth();
+        if (! includeSpacing)
+          {
+            // The rounding here is important.
+            int cMargin = tcm.getColumnMargin();
+            cellRect.x += cMargin / 2;
+            cellRect.width -= cMargin;
+          }
+      }
+
+    return cellRect;
   }
 
   public void clearSelection()
@@ -2354,7 +3384,6 @@ public class JTable
                                    int row,
                                    int column)
   {
-
     boolean rowSelAllowed = getRowSelectionAllowed();
     boolean colSelAllowed = getColumnSelectionAllowed();
     boolean isSel = false;
@@ -2418,9 +3447,10 @@ public class JTable
    */
   public int getRowHeight(int row)
   {
-    // FIXME: return the height of the specified row
-    // which may be different from the general rowHeight
-    return rowHeight;
+    int rh = rowHeight;
+    if (rowHeights != null)
+      rh = rowHeights.getSize(row);
+    return rh;
   }
 
 
@@ -2626,6 +3656,17 @@ public class JTable
    */
   public AccessibleContext getAccessibleContext()
   {
+    if (accessibleContext == null)
+      {
+        AccessibleJTable ctx = new AccessibleJTable();
+        addPropertyChangeListener(ctx);
+        TableColumnModel tcm = getColumnModel();
+        tcm.addColumnModelListener(ctx);
+        tcm.getSelectionModel().addListSelectionListener(ctx);
+        getSelectionModel().addListSelectionListener(ctx);
+        
+        accessibleContext = ctx;
+      }
     return accessibleContext;
   }
 
@@ -2780,9 +3821,14 @@ public class JTable
   }
 
   /**
-   * Set the value of the {@link #rowHeight} property.
+   * Sets the height for all rows in the table. If you want to change the
+   * height of a single row instead, use {@link #setRowHeight(int, int)}.
    *
-   * @param r The new value of the rowHeight property
+   * @param r the height to set for all rows
+   *
+   * @see #getRowHeight()
+   * @see #setRowHeight(int, int)
+   * @see #getRowHeight(int)
    */ 
   public void setRowHeight(int r)
   {
@@ -2792,21 +3838,24 @@ public class JTable
     clientRowHeightSet = true;
 
     rowHeight = r;
+    rowHeights = null;
     revalidate();
     repaint();
   }
   
   /**
-   * Sets the value of the rowHeight property for the specified
-   * row.
+   * Sets the height of a single row in the table.
    * 
-   * @param rh is the new rowHeight
-   * @param row is the row to change the rowHeight of
+   * @param rh the new row height
+   * @param row the row to change the height of
    */
   public void setRowHeight(int row, int rh)
   {
-     setRowHeight(rh);
-     // FIXME: not implemented
+    if (rowHeights == null)
+      {
+        rowHeights = new SizeSequence(getRowCount(), rowHeight);
+      }
+    rowHeights.setSize(row, rh);
   }
   
   /**
@@ -2878,6 +3927,10 @@ public class JTable
         // Add table as TableModelListener to new model.
         dataModel.addTableModelListener(this);
 
+        // Notify the tableChanged method.
+        tableChanged(new TableModelEvent(dataModel,
+                                         TableModelEvent.HEADER_ROW));
+
         // Automatically create columns.
         if (autoCreateColumnsFromModel)
           createDefaultColumnsFromModel();
@@ -3210,7 +4263,7 @@ public class JTable
   public void doLayout()
   {
     TableColumn resizingColumn = null;
-
+    
     int ncols = getColumnCount();
     if (ncols < 1)
       return;
@@ -3236,7 +4289,7 @@ public class JTable
       {
         TableColumn col;
         TableColumn [] cols;
-
+        
         switch (getAutoResizeMode())
           {
           case AUTO_RESIZE_LAST_COLUMN:
@@ -3298,20 +4351,44 @@ public class JTable
         TableColumn [] cols = new TableColumn[ncols];
         for (int i = 0; i < ncols; ++i)
           cols[i] = columnModel.getColumn(i);
-        distributeSpill(cols, spill);        
+        distributeSpill(cols, spill);
       }
     
     if (editorComp!=null)
       moveToCellBeingEdited(editorComp);
     
-    // Repaint fixes the invalid view after the first keystroke if the cell
-    // editing is started immediately after the program start or cell
-    // resizing. 
-    repaint();
-    if (tableHeader!=null)
-      tableHeader.repaint();
+    int leftBoundary = getLeftResizingBoundary();
+    int width = getWidth() - leftBoundary;
+    repaint(leftBoundary, 0, width, getHeight());
+    if (tableHeader != null)
+      tableHeader.repaint(leftBoundary, 0, width, tableHeader.getHeight());
+  }
+  
+  /**
+   * Get the left boundary of the rectangle which changes during the column
+   * resizing.
+   */
+  int getLeftResizingBoundary()
+  {
+    if (tableHeader == null || getAutoResizeMode() == AUTO_RESIZE_ALL_COLUMNS)
+      return 0;
+    else
+      {
+        TableColumn resizingColumn = tableHeader.getResizingColumn();
+        if (resizingColumn == null)
+          return 0;
+
+        int rc = convertColumnIndexToView(resizingColumn.getModelIndex());
+        int p = 0;
+
+        for (int i = 0; i < rc; i++)
+          p += columnModel.getColumn(i).getWidth();
+        
+        return p;
+      }
   }
   
+  
   /**
    * @deprecated Replaced by <code>doLayout()</code>
    */
@@ -3351,6 +4428,10 @@ public class JTable
   public void setUI(TableUI ui)
   {
     super.setUI(ui);
+    // The editors and renderers must be recreated because they constructors
+    // may use the look and feel properties.
+    createDefaultEditors();
+    createDefaultRenderers();
   }
 
   public void updateUI()
@@ -3567,6 +4648,10 @@ public class JTable
    */
   public void selectAll()
   {
+    // The table is empty - nothing to do!
+    if (getRowCount() == 0 || getColumnCount() == 0)
+      return;
+    
     // rowLead and colLead store the current lead selection indices
     int rowLead = selectionModel.getLeadSelectionIndex();
     int colLead = getColumnModel().getSelectionModel().getLeadSelectionIndex();
@@ -3716,30 +4801,47 @@ public class JTable
 
   /**
    * Programmatically starts editing the specified cell.
-   *
+   * 
    * @param row the row of the cell to edit.
    * @param column the column of the cell to edit.
    */
-  public boolean editCellAt (int row, int column)
+  public boolean editCellAt(int row, int column)
   {
     // Complete the previous editing session, if still active.
     if (isEditing())
       editingStopped(new ChangeEvent("editingStopped"));
-    
-    editingRow = row;
-    editingColumn = column;
 
-    setCellEditor(getCellEditor(row, column));
-    editorComp = prepareEditor(cellEditor, row, column);
+    TableCellEditor editor = getCellEditor(row, column);
     
-    // Remove the previous editor components, if present. Only one
-    // editor component at time is allowed in the table.
-    removeAll();
-    add(editorComp);    
-    moveToCellBeingEdited(editorComp);
-    scrollRectToVisible(editorComp.getBounds());
-    editorComp.requestFocusInWindow();
-    return true;
+    // The boolean values are inverted by the single click without the
+    // real editing session.
+    if (editor == booleanInvertingEditor && isCellEditable(row, column))
+      {
+        if (Boolean.TRUE.equals(getValueAt(row, column)))
+          setValueAt(Boolean.FALSE, row, column);
+        else
+          setValueAt(Boolean.TRUE, row, column);
+        return false;
+      }
+    else
+      {
+        editingRow = row;
+        editingColumn = column;
+
+        setCellEditor(editor);
+        editorComp = prepareEditor(cellEditor, row, column);
+
+        // Remove the previous editor components, if present. Only one
+        // editor component at time is allowed in the table.
+        removeAll();
+        add(editorComp);
+        moveToCellBeingEdited(editorComp);
+        scrollRectToVisible(editorComp.getBounds());
+        editorComp.requestFocusInWindow();
+        
+        // Deliver the should select event.
+        return editor.shouldSelectCell(null);        
+      }
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/JToolBar.java b/libjava/classpath/javax/swing/JToolBar.java
index b576b4f2a31b..fe4d2ae20463 100644
--- a/libjava/classpath/javax/swing/JToolBar.java
+++ b/libjava/classpath/javax/swing/JToolBar.java
@@ -1,5 +1,5 @@
 /* JToolBar.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -757,14 +757,28 @@ public class JToolBar extends JComponent implements SwingConstants, Accessible
   } // addImpl()
 
   /**
-   * This method returns a String description of the JToolBar.
+   * Returns a string describing the attributes for the <code>JToolBar</code>
+   * component, for use in debugging.  The return value is guaranteed to be 
+   * non-<code>null</code>, but the format of the string may vary between
+   * implementations.
    *
-   * @return A String description of the JToolBar.
+   * @return A string describing the attributes of the <code>JToolBar</code>.
    */
   protected String paramString()
   {
-    return "JToolBar";
-  } // paramString()
+    StringBuffer sb = new StringBuffer(super.paramString());
+    sb.append(",floatable=").append(floatable);
+    sb.append(",margin=");
+    if (margin != null)
+      sb.append(margin);
+    sb.append(",orientation=");
+    if (orientation == HORIZONTAL)
+      sb.append("HORIZONTAL");
+    else
+      sb.append(VERTICAL);
+    sb.append(",paintBorder=").append(paintBorder);
+    return sb.toString();
+  }
 
   /**
    * Returns the object that provides accessibility features for this
diff --git a/libjava/classpath/javax/swing/JTree.java b/libjava/classpath/javax/swing/JTree.java
index e3b8b7e7ca59..f7583ad69e26 100644
--- a/libjava/classpath/javax/swing/JTree.java
+++ b/libjava/classpath/javax/swing/JTree.java
@@ -1142,9 +1142,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
 
     public boolean isLeaf()
     {
-      return (childValue == null || !(childValue instanceof Hashtable
-          || childValue instanceof Vector || childValue.getClass()
-          .isArray()));
+      return childValue == null || !(childValue instanceof Hashtable
+          || childValue instanceof Vector 
+          || childValue.getClass().isArray());
     }
 
     public static void createChildren(DefaultMutableTreeNode parent,
@@ -1478,7 +1478,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
    */
   public JTree()
   {
-    this(createTreeModel(null));
+    this(getDefaultTreeModel());
   }
 
   /**
@@ -1509,13 +1509,18 @@ public class JTree extends JComponent implements Scrollable, Accessible
   public JTree(TreeModel model)
   {
     setRootVisible(true);
-    // The setModel also calls the updateUI
-    setModel(model);
     setSelectionModel(new EmptySelectionModel());
     selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
     
     // The root node appears expanded by default.
-    nodeStates.put(new TreePath(model.getRoot()), EXPANDED);
+    nodeStates = new Hashtable();
+
+    // Install the UI before installing the model. This way we avoid double
+    // initialization of lots of UI and model stuff inside the UI and related
+    // classes. The necessary UI updates are performed via property change
+    // events to the UI.
+    updateUI();
+    setModel(model);
   }
 
   /**
@@ -1897,6 +1902,10 @@ public class JTree extends JComponent implements Scrollable, Accessible
     if (treeModel == model)
       return;
 
+    // Remove listeners from old model.
+    if (treeModel != null && treeModelListener != null)
+      treeModel.removeTreeModelListener(treeModelListener);
+
     // add treeModelListener to the new model
     if (treeModelListener == null)
       treeModelListener = createTreeModelListener();
@@ -1905,9 +1914,22 @@ public class JTree extends JComponent implements Scrollable, Accessible
 
     TreeModel oldValue = treeModel;
     treeModel = model;
+    clearToggledPaths();
+
+    if (treeModel != null)
+      {
+        if (treeModelListener == null)
+          treeModelListener = createTreeModelListener();
+        if (treeModelListener != null)
+          treeModel.addTreeModelListener(treeModelListener);
+        Object root = treeModel.getRoot();
+        if (root != null && !treeModel.isLeaf(root))
+          {
+            nodeStates.put(new TreePath(root), Boolean.TRUE);
+          }
+      }
 
     firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
-    updateUI();
   }
 
   /**
@@ -2316,7 +2338,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
             selectionModel.addSelectionPath(path);
           }
         
-        if (oldValue!=null)
+        if (oldValue != null)
           repaint(getPathBounds(oldValue));
         
         firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, path);
diff --git a/libjava/classpath/javax/swing/JViewport.java b/libjava/classpath/javax/swing/JViewport.java
index 2b5d1cd5a2fe..7cf393996c37 100644
--- a/libjava/classpath/javax/swing/JViewport.java
+++ b/libjava/classpath/javax/swing/JViewport.java
@@ -877,7 +877,7 @@ public class JViewport extends JComponent implements Accessible
           {
             // If the image has not been scrolled at all, only the changed
             // clip must be updated in the buffer.
-            if (dx==0 && dy==0)
+            if (dx == 0 && dy == 0)
               g2.setClip(g.getClip());
             
             paintSimple(g2);
diff --git a/libjava/classpath/javax/swing/KeyboardManager.java b/libjava/classpath/javax/swing/KeyboardManager.java
index 4f778f7330fc..f7ac9496c30b 100644
--- a/libjava/classpath/javax/swing/KeyboardManager.java
+++ b/libjava/classpath/javax/swing/KeyboardManager.java
@@ -46,6 +46,7 @@ import java.awt.event.KeyEvent;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Vector;
+import java.util.WeakHashMap;
 
 /**
  * This class maintains a mapping from top-level containers to a 
@@ -65,7 +66,7 @@ class KeyboardManager
    * A mapping between top level containers and Hashtables that 
    * map KeyStrokes to Components.
    */
-  Hashtable topLevelLookup = new Hashtable();  
+  WeakHashMap topLevelLookup = new WeakHashMap();  
   
   /**
    * A mapping between top level containers and Vectors of JMenuBars
diff --git a/libjava/classpath/javax/swing/ListSelectionModel.java b/libjava/classpath/javax/swing/ListSelectionModel.java
index 324c056431b8..499362d045bf 100644
--- a/libjava/classpath/javax/swing/ListSelectionModel.java
+++ b/libjava/classpath/javax/swing/ListSelectionModel.java
@@ -1,5 +1,5 @@
 /* ListSelectionModel.java -- 
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,59 +38,295 @@ exception statement from your version. */
 
 package javax.swing;
 
+import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 
 /**
- * The model that is used in {@link JList} to define the selected/not-selected
- * cells of that list.
+ * A model that tracks the selection status of a list of items.  Each item in 
+ * the list is identified by a zero-based index only, so the model can be used
+ * to track the selection status of any type of list.  The model 
+ * supports three modes:
+ * <ul>
+ * <li><code>SINGLE_SELECTION</code> - only one item in the list may be 
+ *     selected;</li>
+ * <li><code>SINGLE_INTERVAL_SELECTION</code> - only one interval in the list 
+ *     may be selected;</li>
+ * <li><code>MULTIPLE_INTERVAL_SELECTION</code> - any combination of items in 
+ *     the list may be selected.</li>
+ * </ul>
+ * The model uses an event notification mechanism to notify listeners (see 
+ * {@link ListSelectionListener}) about updates to the selection model.
+ * <p>
+ * This model is used to track row selections in the {@link JList} component,
+ * and row and column selections in the {@link JTable} component.
  */
 public interface ListSelectionModel
 {
-
+  
+  /**
+   * A selection mode in which only one item can be selected.
+   * 
+   * @see #setSelectionMode(int)
+   */
   int SINGLE_SELECTION = 0;
 
+  /**
+   * A selection mode in which a single interval can be selected (an interval
+   * is a range containing one or more contiguous items).
+   * 
+   * @see #setSelectionMode(int)
+   */
   int SINGLE_INTERVAL_SELECTION = 1;
 
+  /**
+   * A selection mode in which any combination of items can be selected.
+   * 
+   * @see #setSelectionMode(int)
+   */
   int MULTIPLE_INTERVAL_SELECTION = 2;
 
-  void setSelectionMode(int a);
-
+  /**
+   * Sets the selection mode.
+   * <p>
+   * FIXME: The spec is silent about what happens to existing selections, for
+   * example when changing from an interval selection to single selection.
+   * 
+   * @param mode  one of {@link #SINGLE_SELECTION}, 
+   *     {@link #SINGLE_INTERVAL_SELECTION} and 
+   *     {@link #MULTIPLE_INTERVAL_SELECTION}.
+   *     
+   * @see #getSelectionMode()
+   * 
+   * @throws IllegalArgumentException if <code>mode</code> is not one of the
+   *     specified values.
+   */
+  void setSelectionMode(int mode);
+
+  /**
+   * Returns the selection mode, which is one of {@link #SINGLE_SELECTION}, 
+   * {@link #SINGLE_INTERVAL_SELECTION} and 
+   * {@link #MULTIPLE_INTERVAL_SELECTION}.
+   * 
+   * @return The selection mode.
+   * 
+   * @see #setSelectionMode(int)
+   */
   int getSelectionMode();
 
+  /**
+   * Clears the current selection from the model.  If the selection state 
+   * changes (that is, the existing selection is non-empty) a 
+   * {@link ListSelectionEvent} should be sent to all registered listeners.
+   * <p>
+   * FIXME: what happens to the anchor and lead selection indices (the spec
+   * is silent about this)?  See:
+   * <p>
+   * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4334792
+   */
   void clearSelection();
 
+  /**
+   * Returns the lowest selected index, or <code>-1</code> if there is no 
+   * selection.
+   * 
+   * @return The lowest selected index.
+   * 
+   * @see #getMaxSelectionIndex()
+   */
   int getMinSelectionIndex();
 
+  /**
+   * Returns the highest selected index, or <code>-1</code> if there is no
+   * selection.
+   * 
+   * @return The highest selected index.
+   * 
+   * @see #getMinSelectionIndex()
+   */
   int getMaxSelectionIndex();
 
-  boolean isSelectedIndex(int a);
-
+  /**
+   * Returns <code>true</code> if the specified item is selected, and 
+   * <code>false</code> otherwise.  Special note: if <code>index</code> is 
+   * negative, this method should return <code>false</code> (no exception 
+   * should be thrown).
+   * 
+   * @param index  the item index (zero-based).
+   * 
+   * @return <code>true</code> if the specified item is selected, and 
+   *     <code>false</code> otherwise.
+   */
+  boolean isSelectedIndex(int index);
+
+  /**
+   * Returns <code>true</code> if there is no selection, and <code>false</code>
+   * otherwise.
+   * 
+   * @return  <code>true</code> if there is no selection, and 
+   *     <code>false</code> otherwise.
+   */
   boolean isSelectionEmpty();
 
-  void setSelectionInterval(int index0, int index1);
-
-  void addSelectionInterval(int index0, int index1);
-
-  void removeSelectionInterval(int index0, int index1);
-
+  /**
+   * Sets the selection interval to the specified range (note that 
+   * <code>anchor</code> can be less than, equal to, or greater than 
+   * <code>lead</code>).  If this results in the selection being changed, 
+   * a {@link ListSelectionEvent} is sent to all registered listeners.
+   * <p>
+   * If the selection mode is {@link #SINGLE_SELECTION}, only the 
+   * <code>lead</code> item is selected.
+   * 
+   * @param anchor  the anchor index.
+   * @param lead  the lead index.
+   */
+  void setSelectionInterval(int anchor, int lead);
+
+  /**
+   * Marks the items in the specified interval as selected.  The behaviour of 
+   * this method depends on the selection mode:
+   * <ul>
+   * <li><code>SINGLE_SELECTION</code> - only the <code>lead</code> item is 
+   *     selected;</li>
+   * <li><code>SINGLE_INTERVAL_SELECTION</code> - the existing selection 
+   *     interval is replaced by the specified interval;</li>
+   * <li><code>MULTIPLE_INTERVAL_SELECTION</code> - the specified interval is 
+   *     merged into the currently selected intervals.</li>
+   * </ul>
+   * Note that <code>anchor</code> can be less than, equal to, or greater than 
+   * <code>lead</code>.
+   * 
+   * @param anchor  the index of the anchor item
+   * @param lead  the index of the lead item.
+   */
+  void addSelectionInterval(int anchor, int lead);
+
+  /**
+   * Marks the items in the specified interval as not selected.  The behaviour 
+   * of this method depends on the selection mode:
+   * <ul>
+   * <li><code>SINGLE_SELECTION</code> - XXX;</li>
+   * <li><code>SINGLE_INTERVAL_SELECTION</code> - XXX;</li>
+   * <li><code>MULTIPLE_INTERVAL_SELECTION</code> - XXX.</li>
+   * </ul>
+   * Note that <code>anchor</code> can be less than, equal to, or greater than 
+   * <code>lead</code>.
+   * 
+   * @param anchor  the index of the anchor item
+   * @param lead  the index of the lead item.
+   */
+  void removeSelectionInterval(int anchor, int lead);
+
+  /**
+   * Inserts a new interval containing <code>length</code> items at the
+   * specified <code>index</code> (the <code>before</code> flag indicates
+   * whether the range is inserted before or after the existing item at
+   * <code>index</code>).
+   * 
+   * FIXME: What is the selection status of the new items? Bug 4870694.
+   * FIXME: What event is generated?
+   * 
+   * @param index  the index of the item. 
+   * @param length  the number of items in the interval to be inserted.
+   * @param before  if <code>true</code>, the interval should be inserted 
+   *     before <code>index</code>, otherwise it is inserted after.
+   *     
+   * @see #removeIndexInterval(int, int)
+   */
   void insertIndexInterval(int index, int length, boolean before);
 
+  /**
+   * Removes the items in the specified range (inclusive) from the selection
+   * model.  This method should be called when an interval is deleted from 
+   * the underlying list.
+   * 
+   * FIXME: what happens to the lead and anchor indices if they are part of 
+   * the range that is removed? 
+   * FIXME: what event is generated
+   * 
+   * @param index0  XXX
+   * @param index1  XXX
+   * 
+   * @see #insertIndexInterval(int, int, boolean)
+   */
   void removeIndexInterval(int index0, int index1);
 
+  /**
+   * Returns the index of the anchor item. 
+   * 
+   * @return The index of the anchor item.
+   * 
+   * @see #setAnchorSelectionIndex(int)
+   */
   int getAnchorSelectionIndex();
 
+  /**
+   * Sets the index of the anchor item.
+   * 
+   * @param index  the item index.
+   * 
+   * @see #getAnchorSelectionIndex()
+   */
   void setAnchorSelectionIndex(int index);
 
+  /**
+   * Returns the index of the lead item.
+   * 
+   * @return The index of the lead item.
+   * 
+   * @see #setLeadSelectionIndex(int)
+   */
   int getLeadSelectionIndex();
 
+  /**
+   * Sets the index of the lead item.
+   * 
+   * @param index  the item index.
+   * 
+   * @see #getLeadSelectionIndex()
+   */
   void setLeadSelectionIndex(int index);
 
+  /**
+   * Sets the flag that is passed to listeners for each change notification.
+   * If a sequence of changes is made to the selection model, this flag should
+   * be set to <code>true</code> at the start of the sequence, and 
+   * <code>false</code> for the last change - this gives listeners the option
+   * to ignore interim changes if that is more efficient.
+   * 
+   * @param valueIsAdjusting  the flag value.
+   * 
+   * @see #getValueIsAdjusting()
+   */
   void setValueIsAdjusting(boolean valueIsAdjusting);
 
+  /**
+   * Returns a flag that is passed to registered listeners when changes are
+   * made to the model.  See the description for 
+   * {@link #setValueIsAdjusting(boolean)} for more information.
+   *  
+   * @return The flag.
+   */
   boolean getValueIsAdjusting();
 
+  /**
+   * Registers a listener with the model so that it receives notification
+   * of changes to the model.
+   * 
+   * @param listener  the listener (<code>null</code> ignored).
+   * 
+   * @see #removeListSelectionListener(ListSelectionListener)
+   */
   void addListSelectionListener(ListSelectionListener listener);
 
+  /**
+   * Deregisters a listener so that it no longer receives notification of
+   * changes to the model.  If the specified listener is not registered with
+   * the model, or is <code>null</code>, this method does nothing.
+   * 
+   * @param listener  the listener (<code>null</code> ignored).
+   * 
+   * @see #addListSelectionListener(ListSelectionListener)
+   */
   void removeListSelectionListener(ListSelectionListener listener);
 
 }
diff --git a/libjava/classpath/javax/swing/MenuSelectionManager.java b/libjava/classpath/javax/swing/MenuSelectionManager.java
index df7b42037dba..beafbf442027 100644
--- a/libjava/classpath/javax/swing/MenuSelectionManager.java
+++ b/libjava/classpath/javax/swing/MenuSelectionManager.java
@@ -258,6 +258,9 @@ public class MenuSelectionManager
   {
     MenuElement[] selection = (MenuElement[])
                     selectedPath.toArray(new MenuElement[selectedPath.size()]);
+    if (selection.length == 0)
+      return;
+
     MenuElement[] path;
     for (int index = selection.length - 1; index >= 0; index--)
       {
diff --git a/libjava/classpath/javax/swing/ProgressMonitor.java b/libjava/classpath/javax/swing/ProgressMonitor.java
index 73e36b9ca21a..28d22e8a63e2 100644
--- a/libjava/classpath/javax/swing/ProgressMonitor.java
+++ b/libjava/classpath/javax/swing/ProgressMonitor.java
@@ -38,8 +38,10 @@ exception statement from your version. */
 package javax.swing;
 
 import java.awt.Component;
-import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.accessibility.AccessibleContext;
 
 /**
  * <p>Using this class you can easily monitor tasks where you cannot
@@ -62,6 +64,12 @@ import java.awt.event.ActionEvent;
  */
 public class ProgressMonitor
 {
+  
+  /**
+   * The accessible content for this component
+   */
+  protected AccessibleContext accessibleContext;
+  
   /**
    * parentComponent
    */
@@ -439,5 +447,14 @@ public class ProgressMonitor
       timestamp = now;
     }
   }
-
+  
+  /**
+   * Gets the accessible context.
+   * 
+   * @return the accessible context.
+   */
+  public AccessibleContext getAccessibleContext()
+  {
+    return accessibleContext;
+  }
 }
diff --git a/libjava/classpath/javax/swing/RepaintManager.java b/libjava/classpath/javax/swing/RepaintManager.java
index 345c348db52c..4a0581c0e499 100644
--- a/libjava/classpath/javax/swing/RepaintManager.java
+++ b/libjava/classpath/javax/swing/RepaintManager.java
@@ -47,9 +47,8 @@ import java.awt.Rectangle;
 import java.awt.Window;
 import java.awt.image.VolatileImage;
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
@@ -63,19 +62,20 @@ import java.util.WeakHashMap;
  * double buffer surface is used by root components to paint
  * themselves.</p>
  *
- * <p>In general, painting is very confusing in swing. see <a
+ * <p>See <a
  * href="http://java.sun.com/products/jfc/tsc/articles/painting/index.html">this
  * document</a> for more details.</p>
  *
  * @author Roman Kennke (kennke@aicas.com)
  * @author Graydon Hoare (graydon@redhat.com)
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
  */
 public class RepaintManager
 {
   /**
    * The current repaint managers, indexed by their ThreadGroups.
    */
-  private static WeakHashMap currentRepaintManagers;
+  static WeakHashMap currentRepaintManagers;
 
   /**
    * A rectangle object to be reused in damaged regions calculation.
@@ -134,44 +134,6 @@ public class RepaintManager
 
   }
 
-  /**
-   * Compares two components using their depths in the component hierarchy.
-   * A component with a lesser depth (higher level components) are sorted
-   * before components with a deeper depth (low level components). This is used
-   * to order paint requests, so that the higher level components are painted
-   * before the low level components get painted.
-   *
-   * @author Roman Kennke (kennke@aicas.com)
-   */
-  private class ComponentComparator implements Comparator
-  {
-
-    /**
-     * Compares two components.
-     *
-     * @param o1 the first component
-     * @param o2 the second component
-     *
-     * @return a negative integer, if <code>o1</code> is bigger in than
-     *         <code>o2</code>, zero, if both are at the same size and a
-     *         positive integer, if <code>o1</code> is smaller than
-     *         <code>o2</code> 
-     */
-    public int compare(Object o1, Object o2)
-    {
-      if (o1 instanceof JComponent && o2 instanceof JComponent)
-        {
-          JComponent c1 = (JComponent) o1;
-          Rectangle d1 = (Rectangle) dirtyComponentsWork.get(c1);
-          JComponent c2 = (JComponent) o2;
-          Rectangle d2 = (Rectangle) dirtyComponentsWork.get(c2);
-          return d2.width * d2.height - d1.width * d1.height;
-        }
-      throw new ClassCastException("This comparator can only be used with "
-                                   + "JComponents");
-    }
-  }
-
   /** 
    * A table storing the dirty regions of components.  The keys of this
    * table are components, the values are rectangles. Each component maps
@@ -187,18 +149,13 @@ public class RepaintManager
    * @see #markCompletelyClean
    * @see #markCompletelyDirty
    */
-  HashMap dirtyComponents;
+  private HashMap dirtyComponents;
 
   /**
    * The dirtyComponents which is used in paintDiryRegions to avoid unnecessary
    * locking.
    */
-  HashMap dirtyComponentsWork;
-
-  /**
-   * The comparator used for ordered inserting into the repaintOrder list. 
-   */
-  private transient Comparator comparator;
+  private HashMap dirtyComponentsWork;
 
   /**
    * A single, shared instance of the helper class. Any methods which mark
@@ -422,6 +379,9 @@ public class RepaintManager
   {
     if (w <= 0 || h <= 0 || !component.isShowing())
       return;
+    
+    Component parent = component.getParent();
+    
     component.computeVisibleRect(rectCache);
     SwingUtilities.computeIntersection(x, y, w, h, rectCache);
 
@@ -485,8 +445,7 @@ public class RepaintManager
   public void markCompletelyDirty(JComponent component)
   {
     Rectangle r = component.getBounds();
-    addDirtyRegion(component, r.x, r.y, r.width, r.height);
-    component.isCompletelyDirty = true;
+    addDirtyRegion(component, 0, 0, r.width, r.height);
   }
 
   /**
@@ -506,7 +465,6 @@ public class RepaintManager
       {
         dirtyComponents.remove(component);
       }
-    component.isCompletelyDirty = false;
   }
 
   /**
@@ -525,9 +483,13 @@ public class RepaintManager
    */
   public boolean isCompletelyDirty(JComponent component)
   {
-    if (! dirtyComponents.containsKey(component))
-      return false;
-    return component.isCompletelyDirty;
+    boolean retVal = false;
+    if (dirtyComponents.containsKey(component))
+      {
+        Rectangle dirtyRegion = (Rectangle) dirtyComponents.get(component);
+        retVal = dirtyRegion.equals(SwingUtilities.getLocalBounds(component));
+      }
+    return retVal;
   }
 
   /**
@@ -554,8 +516,8 @@ public class RepaintManager
   }
 
   /**
-   * Repaint all regions of all components which have been marked dirty in
-   * the {@link #dirtyComponents} table.
+   * Repaint all regions of all components which have been marked dirty in the
+   * {@link #dirtyComponents} table.
    */
   public void paintDirtyRegions()
   {
@@ -571,29 +533,76 @@ public class RepaintManager
         dirtyComponentsWork = swap;
       }
 
-    ArrayList repaintOrder = new ArrayList(dirtyComponentsWork.size());;
-    // We sort the components by their size here. This way we have a good
-    // chance that painting the bigger components also paints the smaller
-    // components and we don't need to paint them twice.
-    repaintOrder.addAll(dirtyComponentsWork.keySet());
+    // Compile a set of repaint roots.
+    HashSet repaintRoots = new HashSet();
+    Set components = dirtyComponentsWork.keySet();
+    for (Iterator i = components.iterator(); i.hasNext();)
+      {
+        JComponent dirty = (JComponent) i.next();
+        compileRepaintRoots(dirtyComponentsWork, dirty, repaintRoots);
+      }
 
-    if (comparator == null)
-      comparator = new ComponentComparator();
-    Collections.sort(repaintOrder, comparator);
     repaintUnderway = true;
-    for (Iterator i = repaintOrder.iterator(); i.hasNext();)
+    for (Iterator i = repaintRoots.iterator(); i.hasNext();)
       {
         JComponent comp = (JComponent) i.next();
-        // If a component is marked completely clean in the meantime, then skip
-        // it.
         Rectangle damaged = (Rectangle) dirtyComponentsWork.remove(comp);
         if (damaged == null || damaged.isEmpty())
           continue;
         comp.paintImmediately(damaged);
       }
+    dirtyComponentsWork.clear();
     repaintUnderway = false;
     commitRemainingBuffers();
   }
+  
+  /**
+   * Compiles a list of components that really get repainted. This is called
+   * once for each component in the dirtyComponents HashMap, each time with
+   * another <code>dirty</code> parameter. This searches up the component
+   * hierarchy of <code>dirty</code> to find the highest parent that is also
+   * marked dirty and merges the dirty regions.
+   *
+   * @param dirtyRegions the dirty regions 
+   * @param dirty the component for which to find the repaint root
+   * @param roots the list to which new repaint roots get appended
+   */
+  private void compileRepaintRoots(HashMap dirtyRegions, JComponent dirty,
+                                   HashSet roots)
+  {
+    Component current = dirty;
+    Component root = dirty;
+
+    // Search the highest component that is also marked dirty.
+    Component parent;
+    while (true)
+      {
+        parent = current.getParent();
+        if (parent == null || !(parent instanceof JComponent))
+          break;
+
+        current = parent;
+        // We can skip to the next up when this parent is not dirty.
+        if (dirtyRegions.containsKey(parent))
+          {
+            root = current;
+          }
+      }
+
+    // Merge the rectangles of the root and the requested component if
+    // the are different.
+    if (root != dirty)
+      {
+        Rectangle dirtyRect = (Rectangle) dirtyRegions.get(dirty);
+        dirtyRect = SwingUtilities.convertRectangle(dirty, dirtyRect, root);
+        Rectangle rootRect = (Rectangle) dirtyRegions.get(root);
+        SwingUtilities.computeUnion(dirtyRect.x, dirtyRect.y, dirtyRect.width,
+                                    dirtyRect.height, rootRect);
+      }
+
+    // Adds the root to the roots set.
+    roots.add(root);
+  }
 
   /**
    * Get an offscreen buffer for painting a component's image. This image
diff --git a/libjava/classpath/javax/swing/SwingUtilities.java b/libjava/classpath/javax/swing/SwingUtilities.java
index 9d8e8df38f53..5d02d9bb3967 100644
--- a/libjava/classpath/javax/swing/SwingUtilities.java
+++ b/libjava/classpath/javax/swing/SwingUtilities.java
@@ -1446,4 +1446,157 @@ public class SwingUtilities
     KeyboardManager km = KeyboardManager.getManager();
     return km.processKeyStroke(c, s, ev);
   }
+  
+  /**
+   * Returns a string representing one of the horizontal alignment codes
+   * defined in the {@link SwingConstants} interface.  The following table
+   * lists the constants and return values:
+   * <p>
+   * <table border="0">
+   * <tr>
+   *   <th>Code:</th><th>Returned String:</th>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#CENTER}</td>
+   *   <td><code>"CENTER"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#LEFT}</td>
+   *   <td><code>"LEFT"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#RIGHT}</td>
+   *   <td><code>"RIGHT"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#LEADING}</td>
+   *   <td><code>"LEADING"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#TRAILING}</td>
+   *   <td><code>"TRAILING"</code></td>
+   * </tr>
+   * </table>
+   * </p>
+   * If the supplied code is not one of those listed, this methods will throw
+   * an {@link IllegalArgumentException}.
+   * 
+   * @param code  the code.
+   * 
+   * @return A string representing the given code.
+   */
+  static String convertHorizontalAlignmentCodeToString(int code)
+  {
+    switch (code) 
+    {
+      case SwingConstants.CENTER: 
+        return "CENTER";
+      case SwingConstants.LEFT:
+        return "LEFT";
+      case SwingConstants.RIGHT:
+        return "RIGHT";
+      case SwingConstants.LEADING:
+        return "LEADING";
+      case SwingConstants.TRAILING:
+        return "TRAILING";
+      default:
+        throw new IllegalArgumentException("Unrecognised code: " + code);
+    }
+  }
+  
+  /**
+   * Returns a string representing one of the vertical alignment codes
+   * defined in the {@link SwingConstants} interface.  The following table
+   * lists the constants and return values:
+   * <p>
+   * <table border="0">
+   * <tr>
+   *   <th>Code:</th><th>Returned String:</th>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#CENTER}</td>
+   *   <td><code>"CENTER"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#TOP}</td>
+   *   <td><code>"TOP"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link SwingConstants#BOTTOM}</td>
+   *   <td><code>"BOTTOM"</code></td>
+   * </tr>
+   * </table>
+   * </p>
+   * If the supplied code is not one of those listed, this methods will throw
+   * an {@link IllegalArgumentException}.
+   * 
+   * @param code  the code.
+   * 
+   * @return A string representing the given code.
+   */
+  static String convertVerticalAlignmentCodeToString(int code)
+  {
+    switch (code)
+    {
+      case SwingConstants.CENTER:
+        return "CENTER";
+      case SwingConstants.TOP:
+        return "TOP";
+      case SwingConstants.BOTTOM:
+        return "BOTTOM";
+      default:
+        throw new IllegalArgumentException("Unrecognised code: " + code);
+    }
+  }
+  
+  /**
+   * Returns a string representing one of the default operation codes
+   * defined in the {@link WindowConstants} interface.  The following table
+   * lists the constants and return values:
+   * <p>
+   * <table border="0">
+   * <tr>
+   *   <th>Code:</th><th>Returned String:</th>
+   * </tr>
+   * <tr>
+   *   <td>{@link WindowConstants#DO_NOTHING_ON_CLOSE}</td>
+   *   <td><code>"DO_NOTHING_ON_CLOSE"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link WindowConstants#HIDE_ON_CLOSE}</td>
+   *   <td><code>"HIDE_ON_CLOSE"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link WindowConstants#DISPOSE_ON_CLOSE}</td>
+   *   <td><code>"DISPOSE_ON_CLOSE"</code></td>
+   * </tr>
+   * <tr>
+   *   <td>{@link WindowConstants#EXIT_ON_CLOSE}</td>
+   *   <td><code>"EXIT_ON_CLOSE"</code></td>
+   * </tr>
+   * </table>
+   * </p>
+   * If the supplied code is not one of those listed, this method will throw
+   * an {@link IllegalArgumentException}.
+   * 
+   * @param code  the code.
+   * 
+   * @return A string representing the given code.
+   */
+  static String convertWindowConstantToString(int code) 
+  {
+    switch (code)
+    {
+      case WindowConstants.DO_NOTHING_ON_CLOSE:
+        return "DO_NOTHING_ON_CLOSE";
+      case WindowConstants.HIDE_ON_CLOSE:
+        return "HIDE_ON_CLOSE";
+      case WindowConstants.DISPOSE_ON_CLOSE:
+        return "DISPOSE_ON_CLOSE";
+      case WindowConstants.EXIT_ON_CLOSE:
+        return "EXIT_ON_CLOSE";
+      default:
+        throw new IllegalArgumentException("Unrecognised code: " + code);
+    }
+  }
 }
diff --git a/libjava/classpath/javax/swing/TransferHandler.java b/libjava/classpath/javax/swing/TransferHandler.java
index 830feee83326..40a36b27d24f 100644
--- a/libjava/classpath/javax/swing/TransferHandler.java
+++ b/libjava/classpath/javax/swing/TransferHandler.java
@@ -1,5 +1,5 @@
 /* TransferHandler.java --
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,12 +38,14 @@ exception statement from your version. */
 
 package javax.swing;
 
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Toolkit;
 import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.DataFlavor;
 import java.awt.datatransfer.Transferable;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
-import java.awt.Toolkit;
 import java.io.Serializable;
 
 public class TransferHandler implements Serializable
@@ -147,42 +149,48 @@ public class TransferHandler implements Serializable
     this.sourceActions = property != null ? COPY : NONE;
   }
 
-  public boolean canImport (JComponent c, DataFlavor[] flavors)
+  public boolean canImport(JComponent c, DataFlavor[] flavors)
+    throws NotImplementedException
   {
     return false;
   }
 
   protected Transferable createTransferable(JComponent c) 
+    throws NotImplementedException
   {
     return null;
   }
 
-  public void exportAsDrag (JComponent c, InputEvent e, int action) 
+  public void exportAsDrag(JComponent c, InputEvent e, int action) 
+    throws NotImplementedException
   {
     // TODO: Implement this properly
   }
 
-  protected void exportDone (JComponent c, Transferable data, int action) 
+  protected void exportDone(JComponent c, Transferable data, int action) 
+    throws NotImplementedException
   {
     // TODO: Implement this properly
   }
 
   public void exportToClipboard(JComponent c, Clipboard clip, int action) 
+    throws NotImplementedException
   {
     // TODO: Implement this properly
   } 
 
-  public int getSourceActions (JComponent c)
+  public int getSourceActions(JComponent c)
   {
     return sourceActions;
   }
 
-  public Icon getVisualRepresentation (Transferable t)
+  public Icon getVisualRepresentation(Transferable t)
   {
     return visualRepresentation;
   }
 
-  public boolean importData (JComponent c, Transferable t) 
+  public boolean importData(JComponent c, Transferable t) 
+    throws NotImplementedException
   {
     return false;
   }
diff --git a/libjava/classpath/javax/swing/UIDefaults.java b/libjava/classpath/javax/swing/UIDefaults.java
index 00d9700d0d25..bf5242f65523 100644
--- a/libjava/classpath/javax/swing/UIDefaults.java
+++ b/libjava/classpath/javax/swing/UIDefaults.java
@@ -96,15 +96,15 @@ public class UIDefaults extends Hashtable
     }
     public Object createValue(UIDefaults table)
     {
-      InputMapUIResource im = new InputMapUIResource ();
-      for (int i = 0; 2*i+1 < bind.length; ++i)
+      InputMapUIResource im = new InputMapUIResource();
+      for (int i = 0; 2 * i + 1 < bind.length; ++i)
         {
-          Object curr = bind[2*i];
+          Object curr = bind[2 * i];
           if (curr instanceof KeyStroke)
-            im.put((KeyStroke) curr, bind[2*i+1]);
+            im.put((KeyStroke) curr, bind[2 * i + 1]);
           else
             im.put(KeyStroke.getKeyStroke((String) curr),
-                  bind[2*i+1]);
+                  bind[2 * i + 1]);
         }
       return im;
     }
@@ -128,9 +128,9 @@ public class UIDefaults extends Hashtable
     public ProxyLazyValue(String s)
     {
       final String className = s;
-      inner = new LazyValue ()
+      inner = new LazyValue()
         { 
-          public Object createValue (UIDefaults table) 
+          public Object createValue(UIDefaults table) 
           {
             try
               {
@@ -151,16 +151,16 @@ public class UIDefaults extends Hashtable
     {
       final String className = c;
       final String methodName = m;
-      inner = new LazyValue ()
+      inner = new LazyValue()
         { 
-          public Object createValue (UIDefaults table) 
+          public Object createValue(UIDefaults table) 
           {
             try 
               {                
                 return Class
-                  .forName (className)
-                  .getMethod (methodName, new Class[] {})
-                  .invoke (null, new Object[] {});
+                  .forName(className)
+                  .getMethod(methodName, new Class[] {})
+                  .invoke(null, new Object[] {});
               }
             catch (Exception e)
               {
@@ -674,7 +674,7 @@ public class UIDefaults extends Hashtable
    */
   public Class getUIClass(String id, ClassLoader loader)
   {
-    String className = (String) get (id);
+    String className = (String) get(id);
     if (className == null)
       return null;
     try 
diff --git a/libjava/classpath/javax/swing/UIManager.java b/libjava/classpath/javax/swing/UIManager.java
index e1ee28b3f1a5..e6f801163210 100644
--- a/libjava/classpath/javax/swing/UIManager.java
+++ b/libjava/classpath/javax/swing/UIManager.java
@@ -145,18 +145,19 @@ public class UIManager implements Serializable
   static
   {
     String defaultlaf = System.getProperty("swing.defaultlaf");
-    try {
-      if (defaultlaf != null)
-        {
-          Class lafClass = Class.forName(defaultlaf);
-          LookAndFeel laf = (LookAndFeel) lafClass.newInstance();
-          setLookAndFeel(laf);
-        }
-      else
-        {
-          setLookAndFeel(new MetalLookAndFeel());
-        }
-    }
+    try 
+      {
+        if (defaultlaf != null)
+          {
+            Class lafClass = Class.forName(defaultlaf);
+            LookAndFeel laf = (LookAndFeel) lafClass.newInstance();
+            setLookAndFeel(laf);
+          }
+        else
+          {
+            setLookAndFeel(new MetalLookAndFeel());
+          }
+      }
     catch (Exception ex)
       {
         System.err.println("cannot initialize Look and Feel: " + defaultlaf);
@@ -455,7 +456,7 @@ public class UIManager implements Serializable
    */
   public static Font getFont(Object key, Locale locale)
   {
-    return (Font) get(key ,locale);
+    return (Font) get(key, locale);
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/WindowConstants.java b/libjava/classpath/javax/swing/WindowConstants.java
index aaa0cb9a3ab2..598a61e149bd 100644
--- a/libjava/classpath/javax/swing/WindowConstants.java
+++ b/libjava/classpath/javax/swing/WindowConstants.java
@@ -1,5 +1,5 @@
 /* WindowConstants.java --
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,31 +38,42 @@ exception statement from your version. */
 package javax.swing;
 
 /**
- * Defines some constants that are used in Swing's top-level
- * containers.
- *
+ * Defines some constants that are used in Swing's top-level containers.  See 
+ * the following methods:
+ * <ul>
+ * <li>{@link JFrame#setDefaultCloseOperation(int)};</li>
+ * <li>{@link JInternalFrame#setDefaultCloseOperation(int)};</li>
+ * <li>{@link JDialog#setDefaultCloseOperation(int)};</li>
+ * </ul>
+ * 
  * @author Andrew Selkirk
  */
 public interface WindowConstants
 {
   /**
-   * DO_NOTHING_ON_CLOSE
+   * Do nothing when the container is closed.
    */
   int DO_NOTHING_ON_CLOSE = 0;
 
   /**
-   * HIDE_ON_CLOSE
+   * Hide the container when it is closed.
    */
   int HIDE_ON_CLOSE = 1;
 
   /**
-   * DISPOSE_ON_CLOSE
+   * Dispose the container when it is closed.
+   * 
+   * @see Window#dispose()
    */
   int DISPOSE_ON_CLOSE = 2;
 
   /**
-   * EXIT_ON_CLOSE
+   * Exit the application when the container is closed.
+   * 
+   * @see System#exit(int)
+   * 
+   * @since 1.4
    */
-  int EXIT_ON_CLOSE =3;
+  int EXIT_ON_CLOSE = 3;
 
 }
diff --git a/libjava/classpath/javax/swing/border/AbstractBorder.java b/libjava/classpath/javax/swing/border/AbstractBorder.java
index c995de1c2029..16bb238c3743 100644
--- a/libjava/classpath/javax/swing/border/AbstractBorder.java
+++ b/libjava/classpath/javax/swing/border/AbstractBorder.java
@@ -194,6 +194,6 @@ public abstract class AbstractBorder implements Border, Serializable
       height -= borderInsets.top + borderInsets.bottom;
     }
 
-    return new Rectangle (x, y, width, height);
+    return new Rectangle(x, y, width, height);
   }
 }
diff --git a/libjava/classpath/javax/swing/border/BevelBorder.java b/libjava/classpath/javax/swing/border/BevelBorder.java
index 403c35c045e6..5b4761e9ec89 100644
--- a/libjava/classpath/javax/swing/border/BevelBorder.java
+++ b/libjava/classpath/javax/swing/border/BevelBorder.java
@@ -479,7 +479,7 @@ public class BevelBorder extends AbstractBorder
       ((highlightOuter == null) || (highlightOuter.getAlpha() == 255))
       && ((highlightInner == null) || (highlightInner.getAlpha() == 255))
       && ((shadowInner == null) || (shadowInner.getAlpha() == 255))
-      && ((shadowOuter == null) ||(shadowOuter.getAlpha() == 255));
+      && ((shadowOuter == null) || (shadowOuter.getAlpha() == 255));
   }
 
 
diff --git a/libjava/classpath/javax/swing/border/CompoundBorder.java b/libjava/classpath/javax/swing/border/CompoundBorder.java
index a69c5e20aeba..2ee639cf9a34 100644
--- a/libjava/classpath/javax/swing/border/CompoundBorder.java
+++ b/libjava/classpath/javax/swing/border/CompoundBorder.java
@@ -178,7 +178,7 @@ public class CompoundBorder extends AbstractBorder
     Insets borderInsets;
 
     if (insets == null)
-      insets = new Insets (0,0,0,0);
+      insets = new Insets(0, 0, 0, 0);
     else
       insets.left = insets.right = insets.top = insets.bottom = 0;
 
@@ -217,7 +217,7 @@ public class CompoundBorder extends AbstractBorder
     // the implementation from AbstractBorder. However, we want
     // to be compatible with the API specification, which overrides
     // the getBorderInsets(Component) method.
-    return getBorderInsets (c, null);
+    return getBorderInsets(c, null);
   }
 
   /**
@@ -239,7 +239,7 @@ public class CompoundBorder extends AbstractBorder
    * 
    * @return The inside border (possibly <code>null</code>).
    */
-  public Border getInsideBorder ()
+  public Border getInsideBorder()
   {
     return insideBorder;
   }
diff --git a/libjava/classpath/javax/swing/border/MatteBorder.java b/libjava/classpath/javax/swing/border/MatteBorder.java
index 114cac62338f..944cd2866db6 100644
--- a/libjava/classpath/javax/swing/border/MatteBorder.java
+++ b/libjava/classpath/javax/swing/border/MatteBorder.java
@@ -1,5 +1,5 @@
 /* MatteBorder.java -- 
-   Copyright (C) 2003, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -147,9 +147,6 @@ public class MatteBorder extends EmptyBorder
   {
     super(top, left, bottom, right);
 
-    if (tileIcon == null)
-      throw new IllegalArgumentException();
-
     this.tileIcon = tileIcon;
   }
 
@@ -375,6 +372,10 @@ public class MatteBorder extends EmptyBorder
       }
       return;
     }
+    
+    // If this border has no icon end painting here.
+    if (tileIcon == null)
+      return;
 
     /* Determine the width and height of the icon. Some icons return
      * -1 if it is an image whose dimensions have not yet been
diff --git a/libjava/classpath/javax/swing/border/TitledBorder.java b/libjava/classpath/javax/swing/border/TitledBorder.java
index 38b575423343..56146e01d1b7 100644
--- a/libjava/classpath/javax/swing/border/TitledBorder.java
+++ b/libjava/classpath/javax/swing/border/TitledBorder.java
@@ -45,11 +45,10 @@ import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics;
 import java.awt.Insets;
-import java.awt.Shape;
-import java.awt.font.FontRenderContext;
-import java.awt.font.LineMetrics;
-import java.awt.geom.AffineTransform;
+import java.awt.Point;
+import java.awt.Rectangle;
 
+import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 
 
@@ -464,191 +463,238 @@ public class TitledBorder extends AbstractBorder
   public void paintBorder(Component c, Graphics  g, 
                           int x, int y, int width, int height)
   {
-    Measurements mes = getMeasurements(c);
-    Font oldFont = g.getFont();
-    Color oldColor = g.getColor();
-
-    /**
-     * A local helper class for painting the border without changing
-     * any pixels inside the rectangle of the title text.
-     */
-    class BorderPainter
-    {
-      private Component c;
-      private Border b;
-      private int x, y, width, height;
-
-      /**
-       * Constructs a BorderPainter.
-       *
-       * @param c the component whose border is being painted.
-       * @param b the border object.
-       * @param x the x coordinate of the rectangle delimiting the border.
-       * @param y the y coordinate of the rectangle delimiting the border.
-       * @param width the width of the rectangle delimiting the border.
-       * @param height the width of the rectangle delimiting the border.
-       */
-      public BorderPainter(Component c, Border b,
-                           int x, int y, int width, int height)
-      {
-        this.c = c;
-        this.b = b;
-        this.x = x;
-        this.y = y;
-        this.width = width;
-        this.height = height;
-      }
+    Rectangle borderRect = new Rectangle(x + EDGE_SPACING, y + EDGE_SPACING,
+                                         width - (EDGE_SPACING * 2),
+                                         height - (EDGE_SPACING * 2));
+    Point textLoc = new Point();
+
+    // Save color and font.
+    Color savedColor = g.getColor();
+    Font savedFont = g.getFont();
+
+    // The font metrics.
+    Font font = getFont(c);
+    g.setFont(font);
+    FontMetrics fm = c.getFontMetrics(font);
+
+    layoutBorderWithTitle(c, fm, borderRect, textLoc);
+    paintBorderWithTitle(c, g, x, y, width, height, borderRect, textLoc, fm);
+
+    g.setColor(getTitleColor());
+    g.drawString(getTitle(), textLoc.x, textLoc.y);
+    g.setFont(savedFont);
+    g.setColor(savedColor);
+  }
 
+  /**
+   * Calculates the bounding box of the inner border and the location of the
+   * title string.
+   *
+   * @param c the component on which to paint the border
+   * @param fm the font metrics
+   * @param borderRect output parameter, holds the bounding box of the inner
+   *        border on method exit
+   * @param textLoc output parameter, holds the location of the title text
+   *        on method exit
+   */
+  private void layoutBorderWithTitle(Component c, FontMetrics fm,
+                                     Rectangle borderRect,
+                                     Point textLoc)
+  {
+    Border b = getBorder();
+
+    // The font metrics.
+    int fontHeight = fm.getHeight();
+    int fontDescent = fm.getDescent();
+    int fontAscent = fm.getAscent();
+    int titleWidth = fm.stringWidth(getTitle());
+
+    // The base insets.
+    Insets insets;
+    if (b == null)
+      insets = new Insets(0, 0, 0, 0);
+    else
+      insets = b.getBorderInsets(c);
 
-      /**
-       * Paints the entire border.
-       */
-      public void paint(Graphics g)
-      {
-        if (b != null)
-          b.paintBorder(c, g, x, y, width, height);
-      }
+    // The offset of the border rectangle, dependend on the title placement.
+    int offset;
 
+    // Layout border and text vertically.
+    int titlePosition = getTitlePosition();
+    switch (titlePosition)
+    {
+      case ABOVE_BOTTOM:
+        textLoc.y = borderRect.y + borderRect.height - insets.bottom
+                     - fontDescent - TEXT_SPACING;
+        break;
+      case BOTTOM:
+        borderRect.height -= fontHeight / 2;
+        textLoc.y = borderRect.y + borderRect.height - fontDescent
+                     + (fontAscent + fontDescent - insets.bottom) / 2;
+        break;
+      case BELOW_BOTTOM:
+        borderRect.height -=  fontHeight;
+        textLoc.y = borderRect.y + borderRect.height + fontAscent
+                     + TEXT_SPACING;
+        break;
+      case ABOVE_TOP:
+        offset = fontAscent + fontDescent
+                 + Math.max(EDGE_SPACING, TEXT_SPACING * 2) - EDGE_SPACING;
+        borderRect.y += offset;
+        borderRect.height -= offset;
+        textLoc.y = borderRect.y - (fontDescent + TEXT_SPACING);
+        break;
+      case BELOW_TOP:
+        textLoc.y = borderRect.y + insets.top + fontAscent + TEXT_SPACING;
+        break;
+      case TOP:
+      case DEFAULT_POSITION:
+      default:
+        offset = Math.max(0, ((fontAscent / 2) + TEXT_SPACING) - EDGE_SPACING);
+        borderRect.y += offset;
+        borderRect.height -= offset;
+        textLoc.y = borderRect.y - fontDescent
+                     + (insets.top + fontAscent + fontDescent) / 2;
+        break;
+    }
 
-      /**
-       * Paints the border, clipping the drawing operation to a
-       * given rectangular area.
-       */
-      private void paint(Graphics g,
-                         int clipX, int clipY, int clipWidth, int clipHeight)
+    // Layout border and text horizontally.
+    int justification = getTitleJustification();
+    // Adjust justification for LEADING and TRAILING depending on the direction
+    // of the component.
+    if (c.getComponentOrientation().isLeftToRight())
       {
-        Shape oldClip = g.getClip();
-        try
-        {
-          g.clipRect(clipX, clipY, clipWidth, clipHeight);
-          paint(g);
-        }
-        finally
-        {
-          g.setClip(oldClip);
-        }
+        if (justification == LEADING || justification == DEFAULT_JUSTIFICATION)
+          justification = LEFT;
+        else if (justification == TRAILING)
+          justification = RIGHT;
       }
-
-
-      /**
-       * Paints the border without affecting a given rectangular area.
-       * This is used for painting the border without drawing anything
-       * underneath the title text.
-       *
-       * <p>Since we do not want to introduce unnecessary dependencies
-       * on Java 2D, we perform the clipping without constructive geometry
-       * (provided by java.awt.geom.Area). Instead, the border&#x2019;s
-       * bounding rectangle is split into smaller parts, which are then
-       * clipped and painted individually.:
-       *
-       * <p><pre>
-       *    +--------------------+          +--------------------+
-       *    |                    |          |        1           |
-       *    |   +--------+       |          +---+--------+-------+
-       *    |   | hole   |       |  |====>  | 2 | hole   |   3   |
-       *    |   +--------+       |          |---+--------+-------+
-       *    |                    |          |        4           |
-       *    +--------------------+          +--------------------+</pre>
-       *
-       */
-      public void paintExcept(Graphics g,
-                              int holeX, int holeY, int holeWidth, int holeHeight)
+    else
       {
-        int stripeHeight;
-
-        stripeHeight = holeY - y;
-        if (stripeHeight > 0)
-          paint(g, x, y, width, stripeHeight);   // patch #1 in the image above
-
-        stripeHeight = holeHeight;
-        if (stripeHeight > 0)
-        {
-          paint(g, x, holeY, holeX - x, stripeHeight);  // patches #2 and #3
-          paint(g, holeX + holeWidth, holeY, x + width - (holeX + holeWidth), stripeHeight);
-        }
-
-        stripeHeight = height - (holeY - y + holeHeight);
-        if (stripeHeight > 0)
-          paint(g, x, y + height - stripeHeight, width, stripeHeight); // #4
+        if (justification == LEADING || justification == DEFAULT_JUSTIFICATION)
+          justification = RIGHT;
+        else if (justification == TRAILING)
+          justification = LEFT;
       }
-    };
-
-    BorderPainter bp;
-    int textX, textY, borderWidth, borderHeight;
-
-    borderWidth = width - (mes.outerSpacing.left + mes.outerSpacing.right);
-    borderHeight = height - (mes.outerSpacing.top + mes.outerSpacing.bottom);
-    bp = new BorderPainter(c, getBorder(),
-                           x + mes.outerSpacing.left, y + mes.outerSpacing.top,
-                           borderWidth, borderHeight);
 
-    switch (getRealTitleJustification(c))
+    switch (justification)
     {
-    case LEFT:
-      textX = x + EDGE_SPACING + TEXT_INSET_H;
-      break;
-
-    case CENTER:
-      textX = x + (borderWidth - mes.textWidth) / 2;
-      break;
-
-    case RIGHT:
-      textX = x + borderWidth - (mes.textWidth + TEXT_INSET_H);
-      break;
-
-    default:
-      throw new IllegalStateException();
+      case CENTER:
+        textLoc.x = borderRect.x + (borderRect.width - titleWidth) / 2;
+        break;
+      case RIGHT:
+        textLoc.x = borderRect.x + borderRect.width - titleWidth
+                     - TEXT_INSET_H - insets.right;
+        break;
+      case LEFT:
+      default:
+        textLoc.x = borderRect.x + TEXT_INSET_H + insets.left;
     }
+  }
 
-    switch (titlePosition)
-    {
-    case ABOVE_TOP:
-      textY = y + EDGE_SPACING;
-      break;
-
-    case TOP:
-    case DEFAULT_POSITION:
-    default:
-      textY = y + mes.outerSpacing.top + mes.borderInsets.top - mes.textAscent
-              + mes.lineHeight;
-      break;
-
-    case BELOW_TOP:
-      textY = y + mes.outerSpacing.top + mes.borderInsets.top + TEXT_SPACING;
-      break;
-
-    case ABOVE_BOTTOM:
-      textY = y + height - mes.outerSpacing.bottom - mes.borderInsets.bottom
-        - TEXT_SPACING - (mes.textAscent + mes.textDescent);
-      break;
-
-    case BOTTOM:
-    case BELOW_BOTTOM:
-      textY = y + height - (mes.textAscent + mes.textDescent);
-      break;
-    }
+  /**
+   * Paints the border with the title.
+   *
+   * @param c the component to paint on
+   * @param g the graphics context used for paintin
+   * @param x the upper left corner of the whole border
+   * @param y the upper left corner of the whole border
+   * @param width the width of the whole border
+   * @param height the width of the whole border
+   * @param borderRect the bounding box of the inner border
+   * @param textLoc the location of the border title
+   * @param fm the font metrics of the title
+   */
+  private void paintBorderWithTitle(Component c, Graphics g, int x, int y,
+                                    int width, int height,
+                                    Rectangle borderRect, Point textLoc,
+                                    FontMetrics fm)
+  {
+    Border b = getBorder();
+    int fontDescent = fm.getDescent();
+    int fontAscent = fm.getAscent();
+    int titleWidth = fm.stringWidth(getTitle());
 
-    if (mes.trimmedText == null)
-      bp.paint(g);
-    else
-    {
-      try
+    if (b != null)
       {
-        g.setFont(mes.font);
-        g.setColor(getTitleColor());
-        g.drawString(mes.trimmedText, textX, textY + mes.textAscent);
+        // Paint border in segments, when the title is painted above the
+        // border.
+        if (((titlePosition == TOP || titlePosition == DEFAULT_POSITION)
+            && (borderRect.y > textLoc.y - fontAscent))
+            || (titlePosition == BOTTOM
+                && borderRect.y + borderRect.height < textLoc.y + fontDescent))
+          {
+            Rectangle clip = new Rectangle();
+            Rectangle saved = g.getClipBounds();
+
+            // Paint border left from the text.
+            clip.setBounds(saved);
+            SwingUtilities.computeIntersection(x, y, textLoc.x - x - 1,
+                                               height, clip);
+            if (! clip.isEmpty())
+              {
+                g.setClip(clip);
+                b.paintBorder(c, g, borderRect.x, borderRect.y,
+                              borderRect.width,
+                              borderRect.height);
+              }
+            // Paint border right from the text.
+            clip.setBounds(saved);
+            SwingUtilities.computeIntersection(textLoc.x + titleWidth + 1, y,
+                x + width - (textLoc.x + titleWidth + 1), height, clip);
+            if (! clip.isEmpty())
+              {
+                g.setClip(clip);
+                b.paintBorder(c, g, borderRect.x, borderRect.y,
+                              borderRect.width,
+                              borderRect.height);
+              }
+
+            if (titlePosition == TOP || titlePosition == DEFAULT_POSITION)
+              {
+                // Paint border below the text.
+                clip.setBounds(saved);
+                SwingUtilities.computeIntersection(textLoc.x - 1,
+                                                   textLoc.y + fontDescent,
+                                                   titleWidth + 2,
+                                                   y + height - textLoc.y - fontDescent,
+                                                   clip);
+                if (! clip.isEmpty())
+                  {
+                    g.setClip(clip);
+                    b.paintBorder(c, g, borderRect.x, borderRect.y,
+                                  borderRect.width,
+                                  borderRect.height);
+                  }
+	                
+              }
+            else
+              {
+                // Paint border above the text.
+                clip.setBounds(saved);
+                SwingUtilities.computeIntersection(textLoc.x - 1, y,
+                                                   titleWidth + 2,
+                                                   textLoc.y - fontDescent - y,
+                                                   clip);
+                if (! clip.isEmpty())
+                  {
+                    g.setClip(clip);
+                    b.paintBorder(c, g, borderRect.x, borderRect.y,
+                                  borderRect.width,
+                                  borderRect.height);
+                  }
+	                
+              }
+            g.setClip(saved);
+          }
+        else
+          {
+            b.paintBorder(c, g, borderRect.x, borderRect.y, borderRect.width,
+                          borderRect.height);
+          }
       }
-      finally
-      {
-        g.setFont(oldFont);
-        g.setColor(oldColor);
-      }
-      bp.paintExcept(g, textX, textY,
-                     mes.textWidth, mes.textAscent + mes.textDescent);
-    }
   }
-  
-  
+
   /**
    * Measures the width of this border.
    *
@@ -682,7 +728,72 @@ public class TitledBorder extends AbstractBorder
    */
   public Insets getBorderInsets(Component c, Insets insets)
   {
-    return getMeasurements(c).getContentInsets(insets);
+    // Initialize insets with the insets from our border.
+    Border border = getBorder();
+    if (border != null)
+      {
+        if (border instanceof AbstractBorder)
+          {
+            AbstractBorder aBorder = (AbstractBorder) border;
+            aBorder.getBorderInsets(c, insets);
+          }
+        else
+          {
+            Insets i = border.getBorderInsets(c);
+            insets.top = i.top;
+            insets.bottom = i.bottom;
+            insets.left = i.left;
+            insets.right = i.right;
+          }
+      }
+    else
+      {
+        insets.top = 0;
+        insets.bottom = 0;
+        insets.left = 0;
+        insets.right = 0;
+      }
+
+    // Add spacing.
+    insets.top += EDGE_SPACING + TEXT_SPACING;
+    insets.bottom += EDGE_SPACING + TEXT_SPACING;
+    insets.left += EDGE_SPACING + TEXT_SPACING;
+    insets.right += EDGE_SPACING + TEXT_SPACING;
+
+    String title = getTitle();
+    if (c != null && title != null && !title.equals(""))
+      {
+        Font font = getFont(c);
+        FontMetrics fm = c.getFontMetrics(font);
+        int ascent = fm.getAscent();
+        int descent = fm.getDescent();
+        int height = fm.getHeight();
+        switch (getTitlePosition())
+        {
+          case ABOVE_BOTTOM:
+            insets.bottom += ascent + descent + TEXT_SPACING;
+            break;
+          case BOTTOM:
+            insets.bottom += ascent + descent;
+            break;
+          case BELOW_BOTTOM:
+            insets.bottom += height;
+            break;
+          case ABOVE_TOP:
+            insets.top += ascent + descent +
+                          Math.max(EDGE_SPACING, TEXT_SPACING * 2)
+                          - EDGE_SPACING;
+            break;
+          case BELOW_TOP:
+            insets.top += ascent + descent + TEXT_SPACING;
+            break;
+          case TOP:
+          case DEFAULT_POSITION:
+          default:
+            insets.top += ascent + descent;
+        }
+      }
+    return insets;
   }
   
   
@@ -919,7 +1030,26 @@ public class TitledBorder extends AbstractBorder
    */
   public Dimension getMinimumSize(Component c)
   {
-    return getMeasurements(c).getMinimumSize();
+    Insets i = getBorderInsets(c);
+    Dimension minSize = new Dimension(i.left + i.right, i.top + i.bottom);
+    Font font = getFont(c);
+    FontMetrics fm = c.getFontMetrics(font);
+    int titleWidth = fm.stringWidth(getTitle());
+    switch (getTitlePosition())
+    {
+      case ABOVE_TOP:
+      case BELOW_BOTTOM:
+        minSize.width = Math.max(minSize.width, titleWidth);
+        break;
+      case BELOW_TOP:
+      case ABOVE_BOTTOM:
+      case TOP:
+      case BOTTOM:
+      case DEFAULT_POSITION:
+      default:
+        minSize.width += titleWidth;
+    }
+    return minSize;
   }
 
 
@@ -943,253 +1073,4 @@ public class TitledBorder extends AbstractBorder
     return new Font("Dialog", Font.PLAIN, 12);
   }
 
-
-  /**
-   * Returns the horizontal alignment of the title text in relation to
-   * the border, mapping the component-dependent alignment constants
-   * {@link #LEADING}, {@link #TRAILING} and {@link #DEFAULT_JUSTIFICATION}
-   * to the correct value according to the embedded component&#x2019;s
-   * orientation.
-   *
-   * @param c the Component for which this TitledBorder is the border.
-   *
-   * @return one of the values {@link #LEFT}, {@link #CENTER}, or {@link
-   *         #RIGHT}.
-   */
-  private int getRealTitleJustification(Component c)
-  {
-    switch (titleJustification)
-    {
-    case DEFAULT_JUSTIFICATION:
-    case LEADING:
-      if ((c == null) || c.getComponentOrientation().isLeftToRight())
-        return LEFT;
-      else
-        return RIGHT;
-
-    case TRAILING:
-      if ((c == null) || c.getComponentOrientation().isLeftToRight())
-        return RIGHT;
-      else
-        return LEFT;
-
-    default:
-      return titleJustification;
-    }
-  }
-
-
-  /**
-   * Performs various measurements for the current state of this TitledBorder
-   * and the given Component.
-   * 
-   * @param c  the component (<code>null</code> not permitted).
-   * 
-   * @return Various measurements.
-   */
-  private Measurements getMeasurements(Component c)
-  {
-    Measurements m = new Measurements();
-    FontMetrics fmet;
-
-    m.font = getFont(c);
-    fmet = c.getFontMetrics(m.font);
-    m.border = getBorder();
-    if (m.border != null)
-      m.borderInsets = m.border.getBorderInsets(c);
-    else
-      m.borderInsets = new Insets(0, 0, 0, 0);
-
-    if (title != null)
-    {
-      m.trimmedText = title.trim();
-      if (m.trimmedText.length() == 0)
-        m.trimmedText = null;
-    }
-    
-    if (m.trimmedText != null)
-      {
-        m.textAscent = fmet.getAscent();
-        m.textDescent = fmet.getDescent() + fmet.getLeading();
-
-        FontRenderContext frc = new FontRenderContext(new AffineTransform(), 
-            false, false);
-        LineMetrics lmet = m.font.getLineMetrics(m.trimmedText, 0,
-            m.trimmedText.length(), frc);
-        m.lineHeight = (int) lmet.getStrikethroughOffset();
-        
-        // Fallback in case that LineMetrics is not available/working.
-        if (m.lineHeight == 0)
-          m.lineHeight = (int) (0.3333 * (double) m.textAscent);
-        m.textWidth = fmet.stringWidth(m.trimmedText) + 3;
-      }
-    else
-      {
-        m.textAscent = 0;
-        m.textDescent = 0;
-      }
-
-    m.innerSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, 
-            EDGE_SPACING);
-    m.outerSpacing = new Insets(EDGE_SPACING, EDGE_SPACING, EDGE_SPACING, 
-            EDGE_SPACING);
-
-    switch (titlePosition)
-    {
-    case ABOVE_TOP:
-      m.outerSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING;
-      break;
-
-    case TOP:
-      m.outerSpacing.top += m.textDescent + m.lineHeight;
-      m.innerSpacing.top += m.textAscent - m.lineHeight;
-      break;
-      
-    case BELOW_TOP:
-      m.innerSpacing.top += m.textAscent + m.textDescent + TEXT_SPACING;
-      break;
-
-    case ABOVE_BOTTOM:
-      m.innerSpacing.bottom += m.textAscent + m.textDescent + TEXT_SPACING;
-      break;
-
-    case BOTTOM:
-      m.innerSpacing.bottom += Math.max(m.textAscent - m.lineHeight, 0);
-      m.outerSpacing.bottom += m.textDescent + m.lineHeight;
-      break;
-
-    case BELOW_BOTTOM:
-      m.outerSpacing.bottom += m.textAscent + m.textDescent;
-      break;
-
-    default:
-      m.outerSpacing.top += m.textAscent;
-    }
-
-    return m;
-  }
-
-
-  /**
-   * A private helper class for holding the result of measuring the
-   * distances of a TitledBorder.  While it would be possible to cache
-   * these objects, it does not seem to be worth the effort. Note that
-   * invalidating the cache would be tricky, especially since there is
-   * no notification mechanism that would inform the cache when
-   * border has changed, so it would return different insets.
-   */
-  private static class Measurements
-  {
-    /**
-     * The font used for displaying the title text. Note that it can
-     * well be that the TitledBorder&#x2019;s font is <code>null</code>,
-     * which means that the font is to be retrieved from the current
-     * LookAndFeel. In this case, this <code>font</code> field will
-     * contain the result of the retrieval. Therefore, it is safe
-     * to assume that this <code>font</code> field will never have
-     * a <code>null</code> value.
-     */
-    Font font;
-
-
-    /**
-     * The number of pixels between the base line and the top of the
-     * text box.
-     */
-    int textAscent;
-
-
-    /**
-     * The number of pixels between the base line and the bottom of
-     * the text box.
-     */
-    int textDescent;
-
-    /**
-     * The number of pixels between the base line and the height where
-     * a strike-through would be drawn.
-     */
-    int lineHeight;
-
-    /**
-     * The title text after removing leading and trailing white space
-     * characters. If the title consists only of white space, the
-     * value of <code>trimmedText</code> will be <code>null</code>.
-     */
-    String trimmedText;
-
-
-    /**
-     * The width of the trimmed title text in pixels.
-     */
-    int textWidth;
-
-
-    /**
-     * The border that constitutes the interior border
-     * underneath the title text.
-     */
-    Border border;
-
-
-    /**
-     * The distance between the TitledBorder and the interior border.
-     */
-    Insets outerSpacing;
-    
-    /**
-     * The width of the interior border, as returned by
-     * <code>border.getBorderInsets()</code>.
-     */
-    Insets borderInsets;
-
-    
-    /**
-     * The distance between the interior border and the nested
-     * Component for which this TitledBorder is a border.
-     */
-    Insets innerSpacing;
-
-
-    /**
-     * Determines the insets of the nested component when it has a
-     * TitledBorder as its border. Used by {@link
-     * TitledBorder#getBorderInsets(Component, Insets)}.
-     *
-     * @param i an Insets object for storing the results into, or
-     *        <code>null</code> to cause the creation of a
-     *        new instance.
-     *
-     * @return the <code>i</code> object, or a new Insets object
-     *         if <code>null</code> was passed for <code>i</code>.
-     */
-    public Insets getContentInsets(Insets i)
-    {
-      if (i == null)
-        i = new Insets(0, 0, 0, 0);
-      i.left = outerSpacing.left + borderInsets.left + innerSpacing.left;
-      i.right = outerSpacing.right + borderInsets.right + innerSpacing.right;
-      i.top = outerSpacing.top + borderInsets.top + innerSpacing.top;
-      i.bottom = outerSpacing.bottom + borderInsets.bottom + innerSpacing.bottom;
-      return i;
-    }
-
-
-    /**
-     * Calculates the minimum size needed for displaying the border
-     * and its title. Used by {@link TitledBorder#getMinimumSize(Component)}.
-     * 
-     * @return The minimum size.
-     */
-    public Dimension getMinimumSize()
-    {
-      int width;
-      Insets insets;
-
-      insets = getContentInsets(null);
-      width = Math.max(insets.left + insets.right, textWidth + 2 
-              * TEXT_INSET_H);
-      return new Dimension(width, insets.top + insets.bottom);
-    }
-  }
 }
diff --git a/libjava/classpath/javax/swing/event/EventListenerList.java b/libjava/classpath/javax/swing/event/EventListenerList.java
index a7fbec44d369..6a2f34ebb3de 100644
--- a/libjava/classpath/javax/swing/event/EventListenerList.java
+++ b/libjava/classpath/javax/swing/event/EventListenerList.java
@@ -1,5 +1,5 @@
 /* EventListenerList.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -187,11 +187,15 @@ public class EventListenerList
 
 
   /**
-   * Get a list of listenerType/listener pairs
-   * @return Listener list
+   * Returns an array containing a sequence of listenerType/listener pairs, one
+   * for each listener.
+   * 
+   * @return An array containing the listener types and references.
    */
   public Object[] getListenerList()
   {
+    // returning the internal storage is a bad idea, but tests show that the
+    // reference implementation does this...
     return listenerList;
   }
 
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
index 7dbcb91467e0..0a537c4bdd81 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
@@ -72,7 +72,7 @@ public class BasicButtonUI extends ButtonUI
    * A constant added to the defaultTextIconGap to adjust the text
    * within this particular button.
    */
-  protected int defaultTextShiftOffset = 0;
+  protected int defaultTextShiftOffset;
 
   private int textShiftOffset;
 
@@ -268,10 +268,9 @@ public class BasicButtonUI extends ButtonUI
    */
   public Dimension getPreferredSize(JComponent c) 
   {
-    AbstractButton b = (AbstractButton)c;
-    Dimension d = 
-      BasicGraphicsUtils.getPreferredButtonSize
-      (b, defaultTextIconGap + defaultTextShiftOffset);
+    AbstractButton b = (AbstractButton) c;
+    Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b, 
+        defaultTextIconGap + defaultTextShiftOffset);
     return d;
   }
 
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
index 14dadb85cf91..1010139b8fc8 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
@@ -1,5 +1,5 @@
 /* BasicCheckBoxUI.java
-   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,25 +38,32 @@ exception statement from your version. */
 
 package javax.swing.plaf.basic;
 
-import javax.swing.Icon;
+import javax.swing.JCheckBox;
 import javax.swing.JComponent;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 
+/**
+ * A UI delegate for the {@link JCheckBox} component.
+ */
 public class BasicCheckBoxUI extends BasicRadioButtonUI
 {  
   
-  public static ComponentUI createUI(final JComponent c)  {
+  /**
+   * Returns a UI delegate (that is, an instance of this class) for the 
+   * specified component.
+   * 
+   * @param c  the component (this should be a {@link JCheckBox}).
+   *     
+   * @return A new instance of <code>BasicCheckBoxUI</code>.
+   */
+  public static ComponentUI createUI(JComponent c)  {
     return new BasicCheckBoxUI();
   }
 
-  public Icon getDefaultIcon()
-  {
-    return UIManager.getIcon("CheckBox.icon");
-  }
-  
   /**
-   * Returns the prefix for entries in the {@link UIManager} defaults table.
+   * Returns the prefix for entries in the {@link UIManager} defaults table 
+   * (<code>"CheckBox."</code> in this case).
    *
    * @return "CheckBox."
    */
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
index 557eea93f070..ea6f98504351 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -1,5 +1,5 @@
 /* BasicComboBoxUI.java --
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -66,12 +66,14 @@ import javax.swing.CellRendererPane;
 import javax.swing.ComboBoxEditor;
 import javax.swing.ComboBoxModel;
 import javax.swing.DefaultListCellRenderer;
+import javax.swing.InputMap;
 import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JList;
 import javax.swing.ListCellRenderer;
 import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.event.ListDataEvent;
 import javax.swing.event.ListDataListener;
@@ -546,7 +548,7 @@ public class BasicComboBoxUI extends ComboBoxUI
   }
 
   /**
-   * Unconfigures the editor for this combo nox.  This method is not implemented.
+   * Unconfigures the editor for this combo box. 
    */
   protected void unconfigureEditor()
   {
@@ -711,12 +713,14 @@ public class BasicComboBoxUI extends ComboBoxUI
   }
 
   public int getAccessibleChildrenCount(JComponent c)
+    throws NotImplementedException
   {
     // FIXME: Need to implement
     return 0;
   }
 
   public Accessible getAccessibleChild(JComponent c, int i)
+    throws NotImplementedException
   {
     // FIXME: Need to implement
     return null;
@@ -731,7 +735,9 @@ public class BasicComboBoxUI extends ComboBoxUI
    * @return true if the specified key is a navigation key and false otherwis
    */
   protected boolean isNavigationKey(int keyCode)
+    throws NotImplementedException
   {
+    // FIXME: Need to implement
     return false;
   }
 
@@ -780,9 +786,7 @@ public class BasicComboBoxUI extends ComboBoxUI
     Insets i = comboBox.getInsets();
     int arrowSize = h - (i.top + i.bottom);
     if (arrowButton != null)
-      {
-        arrowSize = arrowButton.getWidth();
-      }
+      arrowSize = arrowButton.getWidth();
     return new Rectangle(i.left, i.top, w - (i.left + i.right + arrowSize),
                          h - (i.top + i.left));
   }
@@ -822,14 +826,12 @@ public class BasicComboBoxUI extends ComboBoxUI
         if (hasFocus && ! isPopupVisible(comboBox))
           {
             comp = renderer.getListCellRendererComponent(listBox,
-                                                 comboBox.getSelectedItem(),
-                                                         -1, true, false);
+                comboBox.getSelectedItem(), -1, true, false);
           }
         else
           {
             comp = renderer.getListCellRendererComponent(listBox,
-                                                 comboBox.getSelectedItem(),
-                                                         -1, false, false);
+                comboBox.getSelectedItem(), -1, false, false);
             Color bg = UIManager.getColor("ComboBox.disabledForeground");
             comp.setBackground(bg);
           }
@@ -871,13 +873,9 @@ public class BasicComboBoxUI extends ComboBoxUI
   {
     Color saved = g.getColor();
     if (comboBox.isEnabled())
-      {
-        g.setColor(UIManager.getColor("UIManager.background"));
-      }
+      g.setColor(UIManager.getColor("UIManager.background"));
     else
-      {
-        g.setColor(UIManager.getColor("UIManager.disabledBackground"));
-      }
+      g.setColor(UIManager.getColor("UIManager.disabledBackground"));
     g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
     g.setColor(saved);
   }
@@ -897,9 +895,7 @@ public class BasicComboBoxUI extends ComboBoxUI
   protected Dimension getDefaultSize()
   {
     Component comp = DEFAULT_RENDERER.getListCellRendererComponent(listBox,
-                                                                   " ", -1,
-                                                                   false,
-                                                                   false);
+        " ", -1, false, false);
     currentValuePane.add(comp);
     comp.setFont(comboBox.getFont());
     Dimension d = comp.getPreferredSize();
@@ -974,19 +970,22 @@ public class BasicComboBoxUI extends ComboBoxUI
    * by the look and feel.
    */
   protected void installKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: Need to implement.
+    SwingUtilities.replaceUIInputMap(comboBox,
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+        (InputMap) UIManager.get("ComboBox.ancestorInputMap"));
+    // Install any action maps here.
   }
-
+  
   /**
    * Uninstalls the keyboard actions for the {@link JComboBox} there were
    * installed by in {@link #installListeners}.
    */
   protected void uninstallKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: Need to implement.
+    SwingUtilities.replaceUIInputMap(comboBox,
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+    // Uninstall any action maps here.
   }
 
   /**
@@ -1145,9 +1144,7 @@ public class BasicComboBoxUI extends ComboBoxUI
       ComboBoxModel model = comboBox.getModel();
       Object v = model.getSelectedItem();
       if (editor != null)
-        {
-          comboBox.configureEditor(comboBox.getEditor(), v);
-        }
+        comboBox.configureEditor(comboBox.getEditor(), v);
       comboBox.repaint();
     }
   }
@@ -1166,9 +1163,10 @@ public class BasicComboBoxUI extends ComboBoxUI
      * Invoked whenever key is pressed while JComboBox is in focus.
      */
     public void keyPressed(KeyEvent e)
+      throws NotImplementedException
     {
-      // FIXME: This method calls JComboBox.selectWithKeyChar if the key that was 
-      // pressed is not a navigation key. 
+      // FIXME: This method calls JComboBox.selectWithKeyChar if the key that 
+      // was pressed is not a navigation key. 
     }
   }
 
@@ -1198,10 +1196,8 @@ public class BasicComboBoxUI extends ComboBoxUI
           comboBox.revalidate();
         }
       if (editor != null)
-        {
-          comboBox.configureEditor(comboBox.getEditor(),
-                                   comboBox.getSelectedItem());
-        }
+        comboBox.configureEditor(comboBox.getEditor(),
+            comboBox.getSelectedItem());
       comboBox.repaint();
     }
 
@@ -1215,9 +1211,7 @@ public class BasicComboBoxUI extends ComboBoxUI
       int start = e.getIndex0();
       int end = e.getIndex1();
       if (start == 0 && comboBox.getItemCount() - (end - start + 1) == 0)
-        {
-          contentsChanged(e);
-        }
+        contentsChanged(e);
       else if (start != -1  || end != -1)
         {
           ListCellRenderer renderer = comboBox.getRenderer();
@@ -1227,10 +1221,8 @@ public class BasicComboBoxUI extends ComboBoxUI
           // TODO: Optimize using prototype here.
           for (int i = start; i <= end; ++i)
             {
-              Component comp =
-                renderer.getListCellRendererComponent(listBox,
-                                                      model.getElementAt(i),
-                                                      -1, false, false);
+              Component comp = renderer.getListCellRendererComponent(listBox,
+                  model.getElementAt(i), -1, false, false);
               currentValuePane.add(comp);
               comp.setFont(comboBox.getFont());
               Dimension dim = comp.getPreferredSize();
@@ -1241,13 +1233,9 @@ public class BasicComboBoxUI extends ComboBoxUI
           if (displaySize.width < w || displaySize.height < h)
             {
               if (displaySize.width < w)
-                {
-                  displaySize.width = w;
-                }
+                displaySize.width = w;
               if (displaySize.height < h)
-                {
-                  displaySize.height = h;
-                }
+                displaySize.height = h;
               comboBox.revalidate();
               if (editor != null)
                 {
@@ -1297,37 +1285,37 @@ public class BasicComboBoxUI extends ComboBoxUI
 
       if (e.getPropertyName().equals("enabled"))
         {
-	  arrowButton.setEnabled(comboBox.isEnabled());
+          arrowButton.setEnabled(comboBox.isEnabled());
 
-	  if (comboBox.isEditable())
-	    comboBox.getEditor().getEditorComponent().setEnabled(comboBox
-	                                                         .isEnabled());
+          if (comboBox.isEditable())
+            comboBox.getEditor().getEditorComponent().setEnabled(
+                comboBox.isEnabled());
         }
       else if (e.getPropertyName().equals("editable"))
         {
-	  if (comboBox.isEditable())
-	    {
-	      configureEditor();
-	      addEditor();
-	    }
-	  else
-	    {
-	      unconfigureEditor();
-	      removeEditor();
-	    }
-
-	  comboBox.revalidate();
-	  comboBox.repaint();
+          if (comboBox.isEditable())
+            {
+              configureEditor();
+              addEditor();
+            }
+          else
+            {
+              unconfigureEditor();
+              removeEditor();
+            }
+
+          comboBox.revalidate();
+          comboBox.repaint();
         }
       else if (e.getPropertyName().equals("dataModel"))
         {
-	  // remove ListDataListener from old model and add it to new model
-	  ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue();
-	  if (oldModel != null)
-	    oldModel.removeListDataListener(listDataListener);
+          // remove ListDataListener from old model and add it to new model
+          ComboBoxModel oldModel = (ComboBoxModel) e.getOldValue();
+          if (oldModel != null)
+            oldModel.removeListDataListener(listDataListener);
 
-	  if ((ComboBoxModel) e.getNewValue() != null)
-	    comboBox.getModel().addListDataListener(listDataListener);
+          if ((ComboBoxModel) e.getNewValue() != null)
+            comboBox.getModel().addListDataListener(listDataListener);
         }
       else if (e.getPropertyName().equals("font"))
         {
@@ -1339,7 +1327,7 @@ public class BasicComboBoxUI extends ComboBoxUI
           comboBox.repaint();
         }
 
-      // FIXME: Need to handle changes in other bound properties.	
+      // FIXME: Need to handle changes in other bound properties.       
     }
   }
 
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java
index d4eabc602644..0d822955bbc7 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing.plaf.basic;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Dimension;
@@ -294,9 +292,8 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
    * This method uninstalls keyboard actions installed by the UI.
    */
   protected void uninstallKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: Need to implement
+    // Nothing to do here.
   }
 
   /**
@@ -559,12 +556,11 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup
   }
 
   /**
-   * DOCUMENT ME!
+   * Installs the keyboard actions.
    */
   protected void installKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: Need to implement
+    // Nothing to do here
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java b/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java
index a694f3280492..ef7a880c2ac2 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java
@@ -227,16 +227,16 @@ public class BasicDirectoryModel extends AbstractListModel
 
     if (aTrav == bTrav)
       {
-	String aname = a.getName().toLowerCase();
-	String bname = b.getName().toLowerCase();
-	return ((aname.compareTo(bname) < 0) ? true : false);
+        String aname = a.getName().toLowerCase();
+        String bname = b.getName().toLowerCase();
+        return (aname.compareTo(bname) < 0) ? true : false;
       }
     else
       {
-	if (aTrav)
-	  return true;
-	else
-	  return false;
+        if (aTrav)
+          return true;
+        else
+          return false;
       }
   }
 
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
index daa977083900..9adb0c642ba7 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -365,10 +365,10 @@ public class BasicFileChooserUI extends FileChooserUI
   {
 
     /** DOCUMENT ME! */
-    private Object lastSelected = null;
+    private Object lastSelected;
 
     /** DOCUMENT ME! */
-    private JList list = null;
+    private JList list;
 
     /**
      * Creates a new DoubleClickListener object.
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java b/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java
index 6debd6495094..cad0d0e8abe9 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicIconFactory.java
@@ -56,8 +56,14 @@ public class BasicIconFactory implements Serializable
   private static class DummyIcon 
     implements Icon
   {    
-    public int getIconHeight() { return 10; }
-    public int getIconWidth() { return 10; }
+    public int getIconHeight() 
+    { 
+      return 10; 
+    }
+    public int getIconWidth() 
+    { 
+      return 10; 
+    }
     public void paintIcon(Component c, Graphics g, int x, int y)
     {
       Color save = g.getColor();
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 7ec3aa074bdc..6beac6c971b1 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -1,5 +1,5 @@
 /* BasicInternalFrameUI.java --
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing.plaf.basic;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.AWTEvent;
 import java.awt.Color;
 import java.awt.Component;
@@ -52,12 +50,16 @@ import java.awt.LayoutManager;
 import java.awt.LayoutManager2;
 import java.awt.Point;
 import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
 
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
 import javax.swing.DefaultDesktopManager;
 import javax.swing.DesktopManager;
 import javax.swing.JComponent;
@@ -73,6 +75,7 @@ import javax.swing.event.InternalFrameEvent;
 import javax.swing.event.InternalFrameListener;
 import javax.swing.event.MouseInputAdapter;
 import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.ActionMapUIResource;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.InternalFrameUI;
 import javax.swing.plaf.UIResource;
@@ -168,10 +171,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
     implements SwingConstants
   {
     /**
-     * If true, the cursor is being already shown in the alternative "resize"
-     * shape. 
+     * The current shape of the cursor. 
      */
-    transient boolean showingResizeCursor;
+    transient int showingCursor;
     
     /** FIXME: Use for something. */
     protected final int RESIZE_NONE = 0;
@@ -187,7 +189,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
 
     /** Cache rectangle that can be reused. */
     private transient Rectangle cacheRect = new Rectangle();
-
+    
     /**
      * This method is called when the mouse is clicked.
      *
@@ -195,6 +197,20 @@ public class BasicInternalFrameUI extends InternalFrameUI
      */
     public void mouseClicked(MouseEvent e)
     {
+      // Do minimization/maximization when double-clicking in the title pane.
+      if (e.getSource() == titlePane && e.getClickCount() == 2)
+        try
+          {
+            if (frame.isMaximizable() && ! frame.isMaximum())
+              frame.setMaximum(true);
+            else if (frame.isMaximum())
+              frame.setMaximum(false);
+          }
+        catch (PropertyVetoException pve)
+          {
+            // We do nothing if the attempt has been vetoed.
+          }
+        
       // There is nothing to do when the mouse is clicked
       // on the border.
     }
@@ -223,34 +239,34 @@ public class BasicInternalFrameUI extends InternalFrameUI
         {
           switch (direction)
             {
-            case NORTH:
+            case Cursor.N_RESIZE_CURSOR:
               cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
                                                          - min.height),
                                   b.width, b.height - y);
               break;
-            case NORTH_EAST:
+            case Cursor.NE_RESIZE_CURSOR:
               cacheRect.setBounds(b.x, Math.min(b.y + y, b.y + b.height
-                                                         - min.height), x,
+                                                         - min.height), x + 1,
                                   b.height - y);
               break;
-            case EAST:
-              cacheRect.setBounds(b.x, b.y, x, b.height);
+            case Cursor.E_RESIZE_CURSOR:
+              cacheRect.setBounds(b.x, b.y, x + 1, b.height);
               break;
-            case SOUTH_EAST:
-              cacheRect.setBounds(b.x, b.y, x, y);
+            case Cursor.SE_RESIZE_CURSOR:
+              cacheRect.setBounds(b.x, b.y, x + 1, y + 1);
               break;
-            case SOUTH:
-              cacheRect.setBounds(b.x, b.y, b.width, y);
+            case Cursor.S_RESIZE_CURSOR:
+              cacheRect.setBounds(b.x, b.y, b.width, y + 1);
               break;
-            case SOUTH_WEST:
+            case Cursor.SW_RESIZE_CURSOR:
               cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
-                                  b.y, b.width - x, y);
+                                  b.y, b.width - x, y + 1);
               break;
-            case WEST:
+            case Cursor.W_RESIZE_CURSOR:
               cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
                                   b.y, b.width - x, b.height);
               break;
-            case NORTH_WEST:
+            case Cursor.NW_RESIZE_CURSOR:
               cacheRect.setBounds(
                                   Math.min(b.x + x, b.x + b.width - min.width),
                                   Math.min(b.y + y, b.y + b.height - min.height),
@@ -260,6 +276,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
           dm.resizeFrame(frame, cacheRect.x, cacheRect.y,
                          Math.max(min.width, cacheRect.width),
                          Math.max(min.height, cacheRect.height));
+          setCursor(e);
         }
       else if (e.getSource() == titlePane)
         {
@@ -277,11 +294,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
      */
     public void mouseExited(MouseEvent e)
     {
-      // Reset the cursor shape.
-      if (showingResizeCursor)
+      if (showingCursor != Cursor.DEFAULT_CURSOR)
         {
           frame.setCursor(Cursor.getDefaultCursor());
-          showingResizeCursor = false;
+          showingCursor = Cursor.DEFAULT_CURSOR;
         }
     }
 
@@ -293,53 +309,36 @@ public class BasicInternalFrameUI extends InternalFrameUI
     public void mouseMoved(MouseEvent e)
     {
       // Turn off the resize cursor if we are in the frame header.
-      if (showingResizeCursor && e.getSource() != frame)
+      if (showingCursor != Cursor.DEFAULT_CURSOR && e.getSource() != frame)
         {
           frame.setCursor(Cursor.getDefaultCursor());
-          showingResizeCursor = false;
+          showingCursor = Cursor.DEFAULT_CURSOR;
         }
       else if (e.getSource()==frame && frame.isResizable())
         {
-          int cursor;
-          switch (sectionOfClick(e.getX(), e.getY()))
-            {
-            case NORTH:
-              cursor = Cursor.N_RESIZE_CURSOR;
-              break;
-            case NORTH_EAST:
-              cursor = Cursor.NE_RESIZE_CURSOR;
-              break;
-            case EAST:
-              cursor = Cursor.E_RESIZE_CURSOR;
-              break;
-            case SOUTH_EAST:
-              cursor = Cursor.SE_RESIZE_CURSOR;
-              break;
-            case SOUTH:
-              cursor = Cursor.S_RESIZE_CURSOR;
-              break;
-            case SOUTH_WEST:
-              cursor = Cursor.SW_RESIZE_CURSOR;
-              break;
-            case WEST:
-              cursor = Cursor.W_RESIZE_CURSOR;
-              break;
-            case NORTH_WEST:
-              cursor = Cursor.NW_RESIZE_CURSOR;
-              break;
-            default:
-              cursor = Cursor.DEFAULT_CURSOR;
-            }
-
+          setCursor(e);
+        }
+    }
+    
+    /**
+     * Set the mouse cursor, how applicable.
+     * 
+     * @param e the current mouse event.
+     */
+    void setCursor(MouseEvent e)
+    {
+      int cursor = sectionOfClick(e.getX(), e.getY());
+      if (cursor != showingCursor)
+        {
           Cursor resize = Cursor.getPredefinedCursor(cursor);
           frame.setCursor(resize);
-          showingResizeCursor = true;
+          showingCursor = cursor;
         }
     }
 
     /**
      * This method is called when the mouse is pressed.
-     *
+     * 
      * @param e The MouseEvent.
      */
     public void mousePressed(MouseEvent e)
@@ -383,6 +382,8 @@ public class BasicInternalFrameUI extends InternalFrameUI
           dm.endDraggingFrame(frame);
           frame.putClientProperty("bufferedDragging", null);
         }
+      
+      setCursor(e);
     }
 
     /**
@@ -392,30 +393,31 @@ public class BasicInternalFrameUI extends InternalFrameUI
      * @param x The x coordinate of the MouseEvent.
      * @param y The y coordinate of the MouseEvent.
      *
-     * @return The direction of the resize (a SwingConstant direction).
+     * @return The cursor constant, determining the resizing direction.
      */
     private int sectionOfClick(int x, int y)
     {
-      Insets insets = frame.getInsets();
       Rectangle b = frame.getBounds();
-      if (x < insets.left && y < insets.top)
-        return NORTH_WEST;
-      else if (x > b.width - insets.right && y < insets.top)
-        return NORTH_EAST;
-      else if (x > b.width - insets.right && y > b.height - insets.bottom)
-        return SOUTH_EAST;
-      else if (x < insets.left && y > b.height - insets.bottom)
-        return SOUTH_WEST;
-      else if (y < insets.top)
-        return NORTH;
-      else if (x < insets.left)
-        return WEST;
-      else if (y > b.height - insets.bottom)
-        return SOUTH;
-      else if (x > b.width - insets.right)
-        return EAST;
-
-      return -1;
+      int corner = InternalFrameBorder.cornerSize;
+      
+      if (x < corner && y < corner)
+        return Cursor.NW_RESIZE_CURSOR;
+      else if (x > b.width - corner && y < corner)
+        return Cursor.NE_RESIZE_CURSOR;
+      else if (x > b.width - corner && y > b.height - corner)
+        return Cursor.SE_RESIZE_CURSOR;
+      else if (x < corner && y > b.height - corner)
+        return Cursor.SW_RESIZE_CURSOR;
+      else if (y < corner)
+        return Cursor.N_RESIZE_CURSOR;
+      else if (x < corner)
+        return Cursor.W_RESIZE_CURSOR;
+      else if (y > b.height - corner)
+        return Cursor.S_RESIZE_CURSOR;
+      else if (x > b.width - corner)
+        return Cursor.E_RESIZE_CURSOR;
+
+      return Cursor.DEFAULT_CURSOR;
     }
   }
 
@@ -992,14 +994,18 @@ public class BasicInternalFrameUI extends InternalFrameUI
   /**
    * This helper class is the border for the JInternalFrame.
    */
-  private class InternalFrameBorder extends AbstractBorder implements
+  class InternalFrameBorder extends AbstractBorder implements
       UIResource
   {
-    /** The width of the border. */
-    private static final int bSize = 5;
+    /** 
+     * The width of the border. 
+     */
+    static final int bSize = 5;
 
-    /** The size of the corners. */
-    private static final int offset = 10;
+    /**
+     * The size of the corners (also used by the mouse listener).
+     */
+    static final int cornerSize = 10;
 
     /**
      * This method returns whether the border is opaque.
@@ -1069,16 +1075,35 @@ public class BasicInternalFrameUI extends InternalFrameUI
       g.fillRect(0, y3, b.width, bSize);
       g.fillRect(x3, 0, bSize, b.height);
 
-      g.fill3DRect(0, offset, bSize, b.height - 2 * offset, false);
-      g.fill3DRect(offset, 0, b.width - 2 * offset, bSize, false);
-      g.fill3DRect(offset, b.height - bSize, b.width - 2 * offset, bSize, false);
-      g.fill3DRect(b.width - bSize, offset, bSize, b.height - 2 * offset, false);
+      g.fill3DRect(0, cornerSize, bSize, b.height - 2 * cornerSize, false);
+      g.fill3DRect(cornerSize, 0, b.width - 2 * cornerSize, bSize, false);
+      g.fill3DRect(cornerSize, b.height - bSize, b.width - 2 * cornerSize, 
+                   bSize, false);
+      g.fill3DRect(b.width - bSize, cornerSize, bSize, 
+                   b.height - 2 * cornerSize, false);
 
       g.translate(-x, -y);
       g.setColor(saved);
     }
   }
 
+  /**
+   * This action triggers the system menu.
+   *
+   * @author Roman Kennke (kennke@aicas.com)
+   */
+  private class ShowSystemMenuAction
+    extends AbstractAction
+  {
+    public void actionPerformed(ActionEvent e)
+    {
+      if (titlePane != null)
+        {
+          titlePane.showSystemMenu();
+        }
+    }
+  }
+
   /**
    * The MouseListener that is responsible for dragging and resizing the
    * JInternalFrame in response to MouseEvents.
@@ -1220,9 +1245,17 @@ public class BasicInternalFrameUI extends InternalFrameUI
    * This method installs the keyboard actions for the JInternalFrame.
    */
   protected void installKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: Implement.
+    ActionMapUIResource am = new ActionMapUIResource();
+    am.put("showSystemMenu", new ShowSystemMenuAction());
+
+    // The RI impl installs the audio actions as parent of the UI action map,
+    // so do we.
+    BasicLookAndFeel blaf = (BasicLookAndFeel) UIManager.getLookAndFeel();
+    ActionMap audioActionMap = blaf.getAudioActionMap();
+    am.setParent(audioActionMap);
+
+    SwingUtilities.replaceUIActionMap(frame, am);
   }
 
   /**
@@ -1303,9 +1336,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
    * This method uninstalls the keyboard actions for the JInternalFrame.
    */
   protected void uninstallKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: Implement.
+    SwingUtilities.replaceUIActionMap(frame, null);
+    SwingUtilities.replaceUIInputMap(frame, JComponent.WHEN_IN_FOCUSED_WINDOW,
+                                     null);
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
index d9bc0676dd9f..44f6a4089843 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
@@ -218,11 +218,12 @@ public class BasicListUI extends ListUI
   
   class ListAction extends AbstractAction
   {
-    public void actionPerformed (ActionEvent e)
+    public void actionPerformed(ActionEvent e)
     {
       int lead = list.getLeadSelectionIndex();
       int max = list.getModel().getSize() - 1;
-      DefaultListSelectionModel selModel = (DefaultListSelectionModel)list.getSelectionModel();
+      DefaultListSelectionModel selModel 
+          = (DefaultListSelectionModel) list.getSelectionModel();
       String command = e.getActionCommand();
       // Do nothing if list is empty
       if (max == -1)
@@ -260,9 +261,8 @@ public class BasicListUI extends ListUI
           int target;
           if (lead == list.getLastVisibleIndex())
             {
-              target = Math.min
-                (max, lead + (list.getLastVisibleIndex() -
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.min(max, lead + (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getLastVisibleIndex();
@@ -273,9 +273,8 @@ public class BasicListUI extends ListUI
           int target;
           if (lead == list.getLastVisibleIndex())
             {
-              target = Math.min
-                (max, lead + (list.getLastVisibleIndex() -
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.min(max, lead + (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getLastVisibleIndex();
@@ -286,9 +285,8 @@ public class BasicListUI extends ListUI
           int target;
           if (lead == list.getFirstVisibleIndex())
             {
-              target = Math.max 
-                (0, lead - (list.getLastVisibleIndex() - 
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.max(0, lead - (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getFirstVisibleIndex();
@@ -299,9 +297,8 @@ public class BasicListUI extends ListUI
           int target;
           if (lead == list.getFirstVisibleIndex())
             {
-              target = Math.max 
-                (0, lead - (list.getLastVisibleIndex() - 
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.max(0, lead - (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getFirstVisibleIndex();
@@ -309,32 +306,31 @@ public class BasicListUI extends ListUI
         }
       else if (command.equals("selectNextRowExtendSelection"))
         {
-          selModel.setLeadSelectionIndex(Math.min(lead + 1,max));
+          selModel.setLeadSelectionIndex(Math.min(lead + 1, max));
         }
       else if (command.equals("selectFirstRow"))
         {
           list.setSelectedIndex(0);
         }
       else if (command.equals("selectFirstRowChangeLead"))
-          {
-            selModel.moveLeadSelectionIndex(0);
-          }
+        {
+          selModel.moveLeadSelectionIndex(0);
+        }
       else if (command.equals("selectFirstRowExtendSelection"))
         {
           selModel.setLeadSelectionIndex(0);
         }
       else if (command.equals("selectPreviousRowExtendSelection"))
         {
-          selModel.setLeadSelectionIndex(Math.max(0,lead - 1));
+          selModel.setLeadSelectionIndex(Math.max(0, lead - 1));
         }
       else if (command.equals("scrollUp"))
         {
           int target;
           if (lead == list.getFirstVisibleIndex())
             {
-              target = Math.max 
-                (0, lead - (list.getLastVisibleIndex() - 
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.max(0, lead - (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getFirstVisibleIndex();
@@ -349,9 +345,8 @@ public class BasicListUI extends ListUI
           int target;
           if (lead == list.getLastVisibleIndex())
             {
-              target = Math.min
-                (max, lead + (list.getLastVisibleIndex() -
-                    list.getFirstVisibleIndex() + 1));
+              target = Math.min(max, lead + (list.getLastVisibleIndex() 
+                  - list.getFirstVisibleIndex() + 1));
             }
           else
             target = list.getLastVisibleIndex();
@@ -451,9 +446,9 @@ public class BasicListUI extends ListUI
           if (list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)
             list.setSelectedIndex(index);
           else if (list.isSelectedIndex(index))
-            list.removeSelectionInterval(index,index);
+            list.removeSelectionInterval(index, index);
           else
-            list.addSelectionInterval(index,index);
+            list.addSelectionInterval(index, index);
         }
       else
         list.setSelectedIndex(index);
@@ -1006,14 +1001,14 @@ public class BasicListUI extends ListUI
     // Register key bindings in the UI InputMap-ActionMap pair
     for (int i = 0; i < keys.length; i++)
       {
-        KeyStroke stroke = (KeyStroke)keys[i];
+        KeyStroke stroke = (KeyStroke) keys[i];
         String actionString = (String) focusInputMap.get(stroke);
         parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(),
                                                   stroke.getModifiers()),
                            actionString);
 
-        parentActionMap.put (actionString, 
-                             new ActionListenerProxy(action, actionString));
+        parentActionMap.put(actionString, 
+                            new ActionListenerProxy(action, actionString));
       }
     // Register the new InputMap-ActionMap as the parents of the list's
     // InputMap and ActionMap
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
index 78c16ef08ae1..5a08b2a39823 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -1,5 +1,5 @@
 /* BasicLookAndFeel.java --
-   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -1147,14 +1147,16 @@ public abstract class BasicLookAndFeel extends LookAndFeel
         "F8",  "startResize",
         "END",  "selectMax",
         "HOME",  "selectMin",
-        "LEFT",  "negativeIncremnent",
+        "LEFT",  "negativeIncrement",
         "KP_UP", "negativeIncrement",
         "KP_DOWN", "positiveIncrement",
         "UP",  "negativeIncrement",
         "RIGHT", "positiveIncrement",
         "KP_LEFT", "negativeIncrement",
         "DOWN",  "positiveIncrement",
-        "KP_RIGHT", "positiveIncrement"
+        "KP_RIGHT", "positiveIncrement",
+        "shift ctrl pressed TAB", "focusOutBackward",
+        "ctrl pressed TAB", "focusOutForward"
       }),
       "SplitPane.background", new ColorUIResource(light),
       "SplitPane.border", new BasicBorders.SplitPaneBorder(null, null),
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
index 88bca3b53ce8..91bf614340dd 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -977,7 +977,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
       case JOptionPane.OK_CANCEL_OPTION:
 	return new Object[] { OK_STRING, CANCEL_STRING };
       case JOptionPane.DEFAULT_OPTION:
-        return (optionPane.getWantsInput() ) ?
+        return (optionPane.getWantsInput()) ?
                new Object[] { OK_STRING, CANCEL_STRING } :
                ( optionPane.getMessageType() == JOptionPane.QUESTION_MESSAGE ) ?
                new Object[] { YES_STRING, NO_STRING, CANCEL_STRING } :
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java
index 4f535f653ccd..458f10204f08 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicPanelUI.java
@@ -1,5 +1,5 @@
 /* BasicPanelUI.java
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -44,33 +44,68 @@ import javax.swing.LookAndFeel;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.PanelUI;
 
+/**
+ * A UI delegate for the {@link JPanel} component.
+ */
 public class BasicPanelUI extends PanelUI
 {
-  public static ComponentUI createUI(JComponent x) 
+  /**
+   * A UI delegate that can be shared by all panels (because the delegate is
+   * stateless).
+   */
+  static BasicPanelUI sharedUI;
+  
+  /**
+   * Returns a UI delegate for the specified component.
+   * 
+   * @param panel  the panel.
+   */
+  public static ComponentUI createUI(JComponent panel) 
   {
-    return new BasicPanelUI();
+    if (sharedUI == null)
+      sharedUI = new BasicPanelUI();
+    return sharedUI;
   }
 
+  /**
+   * Installs this UI delegate in the specified component.
+   * 
+   * @param c  the component (should be a {@link JPanel}, <code>null</code> not
+   *     permitted).
+   */
   public void installUI(JComponent c)
   {
     super.installUI(c);
     if (c instanceof JPanel)
       {
-	JPanel p = (JPanel) c;
-	installDefaults(p);
+        JPanel p = (JPanel) c;
+        installDefaults(p);
       }
   }
 
+  /**
+   * Installs the defaults for this UI delegate in the specified panel.
+   * 
+   * @param p  the panel (<code>null</code> not permitted).
+   */
   protected void installDefaults(JPanel p)
   {
     LookAndFeel.installColorsAndFont(p, "Panel.background", "Panel.foreground",
                                      "Panel.font");
+    
+    // A test against the reference implementation shows that this method will
+    // install a border if one is defined in the UIDefaults table (even though
+    // the BasicLookAndFeel doesn't actually define a "Panel.border").  This
+    // test was written after discovering that a null argument to 
+    // uninstallDefaults throws a NullPointerException in 
+    // LookAndFeel.uninstallBorder()...
+    LookAndFeel.installBorder(p, "Panel.border");
   }
 
   /**
-   * Uninstalls this UI from the JPanel.
+   * Uninstalls this UI delegate from the specified component.
    *
-   * @param c the JPanel from which to uninstall this UI
+   * @param c the component (<code>null</code> not permitted).
    */
   public void uninstallUI(JComponent c)
   {
@@ -78,13 +113,20 @@ public class BasicPanelUI extends PanelUI
   }
 
   /**
-   * Uninstalls the UI defaults that have been install through
-   * {@link #installDefaults}.
+   * Uninstalls the UI defaults for the specified panel.
    *
-   * @param p the panel from which to uninstall the UI defaults
+   * @param p  the panel (<code>null</code> not permitted).
    */
   protected void uninstallDefaults(JPanel p)
   {
-    // Nothing to do here.
+    // Tests on the reference implementation showed this method:
+    // (1) doesn't actually remove the installed colors and font installed
+    //     by installDefaults(), it isn't necessary;
+    // (2) throws a NullPointerException in LookAndFeel.uninstallBorder() if
+    //     p is null.  Strangely, no border is installed by the 
+    //     BasicLookAndFeel - perhaps this is needed by another LAF?
+    
+    LookAndFeel.uninstallBorder(p);
   }
+  
 }
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
index d3674664d4cc..2518a91997aa 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -52,6 +52,7 @@ import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
+import java.awt.geom.AffineTransform;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
@@ -725,26 +726,22 @@ public class BasicProgressBarUI extends ProgressBarUI
   protected void paintString(Graphics g, int x, int y, int width, int height,
                              int amountFull, Insets b)
   {
-    // FIXME: We do not support vertical text painting because Java2D is needed
-    // for this.
-    if (progressBar.getOrientation() == JProgressBar.VERTICAL)
-      return;
-
-    // We want to place in the exact center of the bar.
+    String str = progressBar.getString();
+    int full = getAmountFull(b, width, height);
     Point placement = getStringPlacement(g, progressBar.getString(),
-                                         x + b.left, y + b.top,
+                                         x + b.left, y + b.top, 
                                          width - b.left - b.right,
                                          height - b.top - b.bottom);
-
     Color savedColor = g.getColor();
     Shape savedClip = g.getClip();
     FontMetrics fm = g.getFontMetrics(progressBar.getFont());
-    int full = getAmountFull(b, width, height);
-    String str = progressBar.getString();
-
-    // We draw this string two times with different clips so that the text
-    // over the filled area is painted with selectionForeground and over
-    // the clear area with selectionBackground.
+    
+    if (progressBar.getOrientation() == JProgressBar.VERTICAL)
+      {
+        AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2);
+        g.setFont(progressBar.getFont().deriveFont(rotate));
+      }
+    
     g.setColor(getSelectionForeground());
     g.setClip(0, 0, full + b.left, height);
     g.drawString(str, placement.x, placement.y + fm.getAscent());
@@ -756,9 +753,9 @@ public class BasicProgressBarUI extends ProgressBarUI
   }
 
   /**
-   * This method sets the current animation index. If the index
-   * is greater than the number of frames, it resets to 0.
-   *
+   * This method sets the current animation index. If the index is greater than
+   * the number of frames, it resets to 0.
+   * 
    * @param newValue The new animation index.
    */
   protected void setAnimationIndex(int newValue)
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
index a66fa28e6101..64a1deca5727 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -1,5 +1,5 @@
 /* BasicRadioButtonUI.java
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -167,9 +167,8 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
       }
     if (text != null)
       paintText(g, b, tr, text);
-    // TODO: Figure out what is the size parameter?
     if (b.hasFocus() && b.isFocusPainted() && m.isEnabled())
-      paintFocus(g, tr, null);
+      paintFocus(g, tr, c.getSize());
   }
 
   /**
@@ -177,9 +176,8 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
    *
    * @param g the graphics context
    * @param tr the rectangle for the text label
-   * @param size the size (??)
+   * @param size the size of the <code>JRadioButton</code> component.
    */
-  // TODO: Figure out what for is the size parameter.
   protected void paintFocus(Graphics g, Rectangle tr, Dimension size)
   {
     Color focusColor = UIManager.getColor(getPropertyPrefix() + ".focus");
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicRootPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicRootPaneUI.java
index 933db4c6bc21..e20bc2bb3db4 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicRootPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicRootPaneUI.java
@@ -215,9 +215,8 @@ public class BasicRootPaneUI extends RootPaneUI
                                        JComponent.WHEN_IN_FOCUSED_WINDOW);
         if (newValue != null)
           {
-            Object[] keybindings =
-              (Object[]) UIManager.get
-              ("RootPane.defaultButtonWindowKeyBindings");
+            Object[] keybindings = (Object[]) UIManager.get(
+                "RootPane.defaultButtonWindowKeyBindings");
             LookAndFeel.loadKeyBindings(im, keybindings);
           }
         else
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java
index e6a4eaf4fc1a..03fb2255e887 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -1,5 +1,5 @@
 /* BasicScrollPaneUI.java
-   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -45,6 +45,7 @@ import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.Point;
 import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
 import java.awt.event.ContainerEvent;
 import java.awt.event.ContainerListener;
 import java.awt.event.MouseWheelEvent;
@@ -52,20 +53,31 @@ import java.awt.event.MouseWheelListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
 import javax.swing.JComponent;
 import javax.swing.JScrollBar;
 import javax.swing.JScrollPane;
+import javax.swing.JSlider;
 import javax.swing.JViewport;
 import javax.swing.LookAndFeel;
 import javax.swing.ScrollPaneConstants;
 import javax.swing.ScrollPaneLayout;
 import javax.swing.Scrollable;
 import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+import javax.swing.plaf.ActionMapUIResource;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.ScrollPaneUI;
 
+/**
+ * A UI delegate for the {@link JScrollPane} component.
+ */
 public class BasicScrollPaneUI extends ScrollPaneUI
   implements ScrollPaneConstants
 {
@@ -236,7 +248,7 @@ public class BasicScrollPaneUI extends ScrollPaneUI
     final Rectangle rect = new Rectangle();
 
     /**
-     * Scroll with the mouse whell.
+     * Scroll with the mouse wheel.
      * 
      * @author Audrius Meskauskas (audriusa@Bioinformatics.org)
      */
@@ -311,7 +323,11 @@ public class BasicScrollPaneUI extends ScrollPaneUI
     }
     
     /**
-     * Get the scroll bar value or null if there is no such scroll bar.
+     * Get the scroll bar value or 0 if there is no such scroll bar.
+     * 
+     * @param bar  the scroll bar (<code>null</code> permitted).
+     * 
+     * @return The scroll bar value, or 0.
      */
     final int getValue(JScrollBar bar)
     {
@@ -478,6 +494,197 @@ public class BasicScrollPaneUI extends ScrollPaneUI
       v.getComponent(i).addMouseWheelListener(mouseWheelListener);
   }
 
+  InputMap getInputMap(int condition) 
+  {
+    if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+      return (InputMap) UIManager.get("ScrollPane.ancestorInputMap");
+    return null;
+  }
+
+  /**
+   * Returns the action map for the {@link JScrollPane}.  All scroll panes 
+   * share a single action map which is created the first time this method is 
+   * called, then stored in the UIDefaults table for subsequent access.
+   * 
+   * @return The shared action map.
+   */
+  ActionMap getActionMap() 
+  {
+    ActionMap map = (ActionMap) UIManager.get("ScrollPane.actionMap");
+
+    if (map == null) // first time here
+      {
+        map = createActionMap();
+        if (map != null)
+          UIManager.put("Slider.actionMap", map);
+      }
+    return map;
+  }
+
+  /**
+   * Creates the action map shared by all {@link JSlider} instances.
+   * This method is called once by {@link #getActionMap()} when it 
+   * finds no action map in the UIDefaults table...after the map is 
+   * created, it gets added to the defaults table so that subsequent 
+   * calls to {@link #getActionMap()} will return the same shared 
+   * instance.
+   * 
+   * @return The action map.
+   */
+  ActionMap createActionMap()
+  {
+    ActionMap map = new ActionMapUIResource();
+    map.put("scrollLeft", 
+            new AbstractAction("scrollLeft") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getHorizontalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getBlockIncrement(-1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    map.put("scrollEnd", 
+            new AbstractAction("scrollEnd") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb1 = sp.getHorizontalScrollBar();
+                if (sb1.isVisible()) 
+                  {
+                    sb1.setValue(sb1.getMaximum());
+                  }
+                JScrollBar sb2 = sp.getVerticalScrollBar();
+                if (sb2.isVisible()) 
+                  {
+                    sb2.setValue(sb2.getMaximum());
+                  }
+              }
+            }
+    );
+    map.put("unitScrollUp", 
+            new AbstractAction("unitScrollUp") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getVerticalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getUnitIncrement(-1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    map.put("unitScrollLeft", 
+            new AbstractAction("unitScrollLeft") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getHorizontalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getUnitIncrement(-1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    map.put("scrollUp", 
+            new AbstractAction("scrollUp") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getVerticalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getBlockIncrement(-1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    map.put("scrollRight", 
+            new AbstractAction("scrollRight") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getHorizontalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getBlockIncrement(1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    map.put("scrollHome", 
+            new AbstractAction("scrollHome") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb1 = sp.getHorizontalScrollBar();
+                if (sb1.isVisible()) 
+                  {
+                    sb1.setValue(sb1.getMinimum());
+                  }
+                JScrollBar sb2 = sp.getVerticalScrollBar();
+                if (sb2.isVisible()) 
+                  {
+                    sb2.setValue(sb2.getMinimum());
+                  }
+              }
+            }
+    );
+    map.put("scrollDown", 
+            new AbstractAction("scrollDown") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getVerticalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getBlockIncrement(1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    map.put("unitScrollDown", 
+            new AbstractAction("unitScrollDown") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getVerticalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getUnitIncrement(1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    map.put("unitScrollRight", 
+            new AbstractAction("unitScrollRight") {
+              public void actionPerformed(ActionEvent event)
+              {
+                JScrollPane sp = (JScrollPane) event.getSource();
+                JScrollBar sb = sp.getHorizontalScrollBar();
+                if (sb.isVisible()) 
+                  {
+                    int delta = sb.getUnitIncrement(1);
+                    sb.setValue(sb.getValue() + delta);
+                  }
+              }
+            }
+    );
+    return map;
+  }
+  
   /**
    * Installs additional keyboard actions on the scrollpane. This is a hook
    * method provided to subclasses in order to install their own keyboard
@@ -486,12 +693,29 @@ public class BasicScrollPaneUI extends ScrollPaneUI
    * @param sp the scrollpane to install keyboard actions on
    */
   protected void installKeyboardActions(JScrollPane sp)
-    throws NotImplementedException
   {
-    // TODO: Is this only a hook method or should we actually do something
-    // here? If the latter, than figure out what and implement this.
+    InputMap keyMap = getInputMap(
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+    SwingUtilities.replaceUIInputMap(sp, 
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, keyMap);
+    ActionMap map = getActionMap();
+    SwingUtilities.replaceUIActionMap(sp, map);
   }
 
+  /**
+   * Uninstalls all keyboard actions from the JScrollPane that have been
+   * installed by {@link #installKeyboardActions}. This is a hook method
+   * provided to subclasses to add their own keyboard actions.
+   *
+   * @param sp the scrollpane to uninstall keyboard actions from
+   */
+  protected void uninstallKeyboardActions(JScrollPane sp)
+  {
+    SwingUtilities.replaceUIActionMap(sp, null);
+    SwingUtilities.replaceUIInputMap(sp, 
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+  }
+  
   /**
    * Creates and returns the change listener for the horizontal scrollbar.
    *
@@ -536,6 +760,8 @@ public class BasicScrollPaneUI extends ScrollPaneUI
    * Creates and returns the mouse wheel listener for the scrollpane.
    *
    * @return the mouse wheel listener for the scrollpane
+   * 
+   * @since 1.4
    */
   protected MouseWheelListener createMouseWheelListener()
   {
@@ -545,7 +771,7 @@ public class BasicScrollPaneUI extends ScrollPaneUI
   public void uninstallUI(final JComponent c) 
   {
     super.uninstallUI(c);
-    this.uninstallDefaults((JScrollPane)c);
+    this.uninstallDefaults((JScrollPane) c);
     uninstallListeners((JScrollPane) c);
     installKeyboardActions((JScrollPane) c);
   }
@@ -574,23 +800,9 @@ public class BasicScrollPaneUI extends ScrollPaneUI
 
   }
 
-  /**
-   * Uninstalls all keyboard actions from the JScrollPane that have been
-   * installed by {@link #installKeyboardActions}. This is a hook method
-   * provided to subclasses to add their own keyboard actions.
-   *
-   * @param sp the scrollpane to uninstall keyboard actions from
-   */
-  protected void uninstallKeyboardActions(JScrollPane sp)
-    throws NotImplementedException
-  {
-    // TODO: Is this only a hook method or should we actually do something
-    // here? If the latter, than figure out what and implement this.
-  }
-
   public Dimension getMinimumSize(JComponent c) 
   {
-    JScrollPane p = (JScrollPane ) c;
+    JScrollPane p = (JScrollPane) c;
     ScrollPaneLayout sl = (ScrollPaneLayout) p.getLayout();
     return sl.minimumLayoutSize(c);
   }
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java
index 137ab55a6079..0569768a6276 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing.plaf.basic;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.ComponentOrientation;
@@ -70,6 +68,7 @@ import javax.swing.JComponent;
 import javax.swing.JLabel;
 import javax.swing.JSlider;
 import javax.swing.LookAndFeel;
+import javax.swing.RepaintManager;
 import javax.swing.SwingUtilities;
 import javax.swing.Timer;
 import javax.swing.UIManager;
@@ -209,9 +208,9 @@ public class BasicSliderUI extends SliderUI
      * @param e A {@link FocusEvent}.
      */
     public void focusGained(FocusEvent e)
-      throws NotImplementedException
     {
-      // FIXME: implement.
+      slider.repaint();
+      hasFocus = true;
     }
 
     /**
@@ -221,9 +220,9 @@ public class BasicSliderUI extends SliderUI
      * @param e A {@link FocusEvent}.
      */
     public void focusLost(FocusEvent e)
-      throws NotImplementedException
     {
-      // FIXME: implement.
+      slider.repaint();
+      hasFocus = false;
     }
   }
 
@@ -592,6 +591,9 @@ public class BasicSliderUI extends SliderUI
 
   /** The focus color. */
   private transient Color focusColor;
+  
+  /** True if the slider has focus. */
+  private transient boolean hasFocus;
 
   /**
    * Creates a new Basic look and feel Slider UI.
@@ -1548,9 +1550,11 @@ public class BasicSliderUI extends SliderUI
       paintTicks(g);
     if (slider.getPaintLabels())
       paintLabels(g);
-
-    //FIXME: Paint focus.
+    
     paintThumb(g);
+    
+    if (hasFocus)
+      paintFocus(g);
   }
 
   /**
@@ -1602,7 +1606,7 @@ public class BasicSliderUI extends SliderUI
     Color saved_color = g.getColor();
 
     g.setColor(getFocusColor());
-
+    
     g.drawRect(focusRect.x, focusRect.y, focusRect.width, focusRect.height);
 
     g.setColor(saved_color);
@@ -1989,7 +1993,7 @@ public class BasicSliderUI extends SliderUI
   public void paintThumb(Graphics g)
   {
     Color saved_color = g.getColor();
-    
+
     Point a = new Point(thumbRect.x, thumbRect.y);
     Point b = new Point(a);
     Point c = new Point(a);
@@ -1997,11 +2001,11 @@ public class BasicSliderUI extends SliderUI
     Point e = new Point(a);
 
     Polygon bright;
-    Polygon light;  // light shadow
-    Polygon dark;   // dark shadow
+    Polygon light; // light shadow
+    Polygon dark; // dark shadow
     Polygon all;
 
-    // This will be in X-dimension if the slider is inverted and y if it isn't.           
+    // This will be in X-dimension if the slider is inverted and y if it isn't.
     int turnPoint;
 
     if (slider.getOrientation() == JSlider.HORIZONTAL)
@@ -2016,13 +2020,15 @@ public class BasicSliderUI extends SliderUI
         bright = new Polygon(new int[] { b.x - 1, a.x, e.x, d.x },
                              new int[] { b.y, a.y, e.y, d.y }, 4);
 
-        dark = new Polygon(new int[] { b.x, c.x, d.x + 1 },
-                           new int[] { b.y, c.y - 1, d.y }, 3);
-    
-    light = new Polygon(new int[] { b.x - 1, c.x - 1, d.x + 1 },
-                        new int[] { b.y + 1, c.y - 1, d.y - 1 }, 3);
-    
-        all = new Polygon(new int[] { a.x + 1, b.x - 2, c.x - 2, d.x, e.x + 1 },
+        dark = new Polygon(new int[] { b.x, c.x, d.x + 1 }, new int[] { b.y,
+                                                                       c.y - 1,
+                                                                       d.y }, 3);
+
+        light = new Polygon(new int[] { b.x - 1, c.x - 1, d.x + 1 },
+                            new int[] { b.y + 1, c.y - 1, d.y - 1 }, 3);
+
+        all = new Polygon(
+                          new int[] { a.x + 1, b.x - 2, c.x - 2, d.x, e.x + 1 },
                           new int[] { a.y + 1, b.y + 1, c.y - 1, d.y - 1, e.y },
                           5);
       }
@@ -2038,15 +2044,16 @@ public class BasicSliderUI extends SliderUI
         bright = new Polygon(new int[] { c.x - 1, b.x, a.x, e.x },
                              new int[] { c.y - 1, b.y, a.y, e.y - 1 }, 4);
 
-        dark = new Polygon(new int[] { c.x, d.x, e.x },
-                           new int[] { c.y, d.y, e.y }, 3);
+        dark = new Polygon(new int[] { c.x, d.x, e.x }, new int[] { c.y, d.y,
+                                                                   e.y }, 3);
 
-    light = new Polygon(new int[] { c.x - 1, d.x, e.x + 1},
-                       new int[] { c.y, d.y - 1, e.y - 1}, 3);
-        all = new Polygon(new int[] { a.x + 1, b.x, c.x - 2, c.x - 2, d.x, 
-                                      e.x + 1 },
-                          new int[] { a.y + 1, b.y + 1, c.y - 1, c.y, d.y - 2, 
-                                      e.y - 2 }, 6);
+        light = new Polygon(new int[] { c.x - 1, d.x, e.x + 1 },
+                            new int[] { c.y, d.y - 1, e.y - 1 }, 3);
+        all = new Polygon(new int[] { a.x + 1, b.x, c.x - 2, c.x - 2, d.x,
+                                     e.x + 1 }, new int[] { a.y + 1, b.y + 1,
+                                                           c.y - 1, c.y,
+                                                           d.y - 2, e.y - 2 },
+                          6);
       }
 
     g.setColor(Color.WHITE);
@@ -2057,7 +2064,7 @@ public class BasicSliderUI extends SliderUI
 
     g.setColor(Color.GRAY);
     g.drawPolyline(light.xpoints, light.ypoints, light.npoints);
-    
+
     g.setColor(Color.LIGHT_GRAY);
     g.drawPolyline(all.xpoints, all.ypoints, all.npoints);
     g.fillPolygon(all);
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicSpinnerUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicSpinnerUI.java
index 465374bfda9f..254a9a4fa2ba 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicSpinnerUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicSpinnerUI.java
@@ -220,7 +220,7 @@ public class BasicSpinnerUI extends SpinnerUI
 	      BasicSpinnerUI.this.spinner.getModel().setValue(next);
 	  }
 
-	  volatile boolean mouseDown = false;
+	  volatile boolean mouseDown;
 	  Timer timer = new Timer(50,
 	                          new ActionListener()
 	      {
@@ -260,7 +260,7 @@ public class BasicSpinnerUI extends SpinnerUI
 	      BasicSpinnerUI.this.spinner.getModel().setValue(prev);
 	  }
 
-	  volatile boolean mouseDown = false;
+	  volatile boolean mouseDown;
 	  Timer timer = new Timer(50,
 	                          new ActionListener()
 	      {
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
index 694baaddade2..2d5955974240 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -1,5 +1,5 @@
 /* BasicSplitPaneUI.java --
-   Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing.plaf.basic;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Canvas;
 import java.awt.Color;
 import java.awt.Component;
@@ -57,11 +55,17 @@ import java.awt.event.FocusListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
+import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
 import javax.swing.JComponent;
+import javax.swing.JSlider;
 import javax.swing.JSplitPane;
 import javax.swing.KeyStroke;
 import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
+import javax.swing.plaf.ActionMapUIResource;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.SplitPaneUI;
 import javax.swing.plaf.UIResource;
@@ -676,7 +680,9 @@ public class BasicSplitPaneUI extends SplitPaneUI
      */
     public void focusGained(FocusEvent ev)
     {
-      // FIXME: implement.
+      // repaint the divider because its background color may change due to
+      // the focus state...
+      divider.repaint();
     }
 
     /**
@@ -686,7 +692,9 @@ public class BasicSplitPaneUI extends SplitPaneUI
      */
     public void focusLost(FocusEvent ev)
     {
-      // FIXME: implement.
+      // repaint the divider because its background color may change due to
+      // the focus state...
+      divider.repaint();
     }
   }
 
@@ -1046,21 +1054,143 @@ public class BasicSplitPaneUI extends SplitPaneUI
   }
 
   /**
-   * This method installs the keyboard actions for the JSplitPane.
+   * Returns the input map for the specified condition.
+   * 
+   * @param condition  the condition.
+   * 
+   * @return The input map.
+   */
+  InputMap getInputMap(int condition) 
+  {
+    if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
+      return (InputMap) UIManager.get("SplitPane.ancestorInputMap");
+    return null;
+  }
+
+  /**
+   * Returns the action map for the {@link JSplitPane}.  All sliders share
+   * a single action map which is created the first time this method is 
+   * called, then stored in the UIDefaults table for subsequent access.
+   * 
+   * @return The shared action map.
+   */
+  ActionMap getActionMap() 
+  {
+    ActionMap map = (ActionMap) UIManager.get("SplitPane.actionMap");
+
+    if (map == null) // first time here
+      {
+        map = createActionMap();
+        if (map != null)
+          UIManager.put("SplitPane.actionMap", map);
+      }
+    return map;
+  }
+
+  /**
+   * Creates the action map shared by all {@link JSlider} instances.
+   * This method is called once by {@link #getActionMap()} when it 
+   * finds no action map in the UIDefaults table...after the map is 
+   * created, it gets added to the defaults table so that subsequent 
+   * calls to {@link #getActionMap()} will return the same shared 
+   * instance.
+   * 
+   * @return The action map.
+   */
+  ActionMap createActionMap()
+  {
+    ActionMap map = new ActionMapUIResource();
+    map.put("toggleFocus", 
+            new AbstractAction("toggleFocus") {
+              public void actionPerformed(ActionEvent event)
+              {
+                // FIXME: What to do here?
+              }
+            }
+    );
+    map.put("startResize", 
+            new AbstractAction("startResize") {
+              public void actionPerformed(ActionEvent event)
+              {
+                splitPane.requestFocus();
+              }
+            }
+    );
+    map.put("selectMax", 
+            new AbstractAction("selectMax") {
+              public void actionPerformed(ActionEvent event)
+              {
+                splitPane.setDividerLocation(1.0);
+              }
+            }
+    );
+    map.put("selectMin", 
+            new AbstractAction("selectMin") {
+              public void actionPerformed(ActionEvent event)
+              {
+                splitPane.setDividerLocation(0.0);
+              }
+            }
+    );
+    map.put("negativeIncrement", 
+            new AbstractAction("negativeIncrement") {
+              public void actionPerformed(ActionEvent event)
+              {
+                setDividerLocation(splitPane, Math.max(dividerLocation 
+                    - KEYBOARD_DIVIDER_MOVE_OFFSET, 0));
+              }
+            }
+    );
+    map.put("positiveIncrement", 
+            new AbstractAction("positiveIncrement") {
+              public void actionPerformed(ActionEvent event)
+              {
+                setDividerLocation(splitPane, dividerLocation 
+                    + KEYBOARD_DIVIDER_MOVE_OFFSET);
+              }
+            }
+    );
+    map.put("focusOutBackward",
+            new AbstractAction("focusOutBackward") {
+              public void actionPerformed(ActionEvent event)
+              {
+                // FIXME: implement this
+              }
+            }
+    );    
+    map.put("focusOutForward",
+            new AbstractAction("focusOutForward") {
+              public void actionPerformed(ActionEvent event)
+              {
+                // FIXME: implement this
+              }
+            }
+    );    
+    return map;
+  }
+
+  /**
+   * Installs any keyboard actions. The list of keys that need to be bound are
+   * listed in Basic look and feel's defaults.
    */
   protected void installKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: implement.
+    InputMap keyMap = getInputMap(
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+    SwingUtilities.replaceUIInputMap(splitPane, 
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, keyMap);
+    ActionMap map = getActionMap();
+    SwingUtilities.replaceUIActionMap(splitPane, map);
   }
 
   /**
    * This method reverses the work done in installKeyboardActions.
    */
   protected void uninstallKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: implement.
+    SwingUtilities.replaceUIActionMap(splitPane, null);
+    SwingUtilities.replaceUIInputMap(splitPane, 
+        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
index 6d9bed331cb1..1b5249770ec6 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -286,7 +286,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
           width = Math.max(min, width);
           int tabAreaHeight = preferredTabAreaHeight(tabPlacement,
                                                      width - tabAreaInsets.left
-                                                     -tabAreaInsets.right);
+                                                     - tabAreaInsets.right);
           height += tabAreaHeight;
         }
       else
@@ -476,7 +476,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
           else
             nextIndex = i + 1;
           int next = tabRuns[nextIndex];
-          int end = (next != 0 ? next - 1 : tabCount - 1);
+          int end = next != 0 ? next - 1 : tabCount - 1;
           if (tabPlacement == SwingConstants.TOP
               || tabPlacement == SwingConstants.BOTTOM)
             {
@@ -491,9 +491,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
                   padTabRun(tabPlacement, start, end, breakAt);
                 }
               if (tabPlacement == BOTTOM)
-                y -= (maxTabHeight - tabRunOverlay);
+                y -= maxTabHeight - tabRunOverlay;
               else
-                y += (maxTabHeight - tabRunOverlay);
+                y += maxTabHeight - tabRunOverlay;
             }
           else
             {
@@ -508,9 +508,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
                   padTabRun(tabPlacement, start, end, breakAt);
                 }
               if (tabPlacement == RIGHT)
-                x -= (maxTabWidth - tabRunOverlay);
+                x -= maxTabWidth - tabRunOverlay;
               else
-                x += (maxTabWidth - tabRunOverlay);
+                x += maxTabWidth - tabRunOverlay;
               
             }
         }
@@ -1818,7 +1818,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
           next = tabRuns[0];
         else
           next = tabRuns[i + 1];
-        int end = (next != 0 ? next - 1 : tabCount - 1);
+        int end = next != 0 ? next - 1 : tabCount - 1;
         for (int j = start; j <= end; ++j)
           {
             if (j != selectedIndex)
@@ -2194,7 +2194,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
     {
     case LEFT:
       x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
-      w -= (x - insets.left);
+      w -= x - insets.left;
       break;
     case RIGHT:
       w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
@@ -2205,7 +2205,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
     case TOP:
     default:
       y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
-      h -= (y - insets.top);
+      h -= y - insets.top;
     }
 
     // Fill background if necessary.
@@ -2410,6 +2410,9 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
    */
   public Rectangle getTabBounds(JTabbedPane pane, int i)
   {
+    // Need to re-layout container if tab does not exist.
+    if (i >= rects.length)
+      layoutManager.layoutContainer(pane);
     return rects[i];
   }
 
@@ -3015,7 +3018,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
   {
     int currRun = getRunForTab(tabCount, tabIndex);
     int offset;
-    int nextRun = (forward) ? getNextTabRun(currRun) : getPreviousTabRun(currRun);
+    int nextRun = forward ? getNextTabRun(currRun) : getPreviousTabRun(currRun);
     if (tabPlacement == SwingConstants.TOP
         || tabPlacement == SwingConstants.BOTTOM)
       offset = rects[lastTabInRun(tabCount, nextRun)].y
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java
index cfbebda21497..ce8846ff8afb 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java
@@ -199,10 +199,7 @@ public class BasicTableHeaderUI extends TableHeaderUI
      */
     public void mouseExited(MouseEvent e)
     {
-      if (header.getResizingColumn() != null && header.getResizingAllowed())
-        endResizing();
-      if (header.getDraggedColumn() != null && header.getReorderingAllowed())
-        endDragging(null);
+      // Nothing to do.
     }
 
     /**
@@ -363,25 +360,20 @@ public class BasicTableHeaderUI extends TableHeaderUI
     void endDragging(MouseEvent e)
     {
       header.setDraggedColumn(null);
-
-      // Return if the mouse have left the header area while pressed.
-      if (e == null)
-        {
-          header.repaint(draggingHeaderRect);
-          draggingHeaderRect = null;
-          return;
-        }
-      else
-        draggingHeaderRect = null;
+      draggingHeaderRect = null;
 
       TableColumnModel model = header.getColumnModel();
 
       // Find where have we dragged the column.
       int x = e.getX();
       int p = 0;
-      int col = - 1;
+      
+      int col = model.getColumnCount()-1;
       int n = model.getColumnCount();
 
+      // This loop does not find the column if the mouse if out of the 
+      // right boundary of the table header. Then we make this column the
+      // rightmost column.
       Scan: for (int i = 0; i < n; i++)
         {
           p += model.getColumn(i).getWidth();
@@ -391,8 +383,8 @@ public class BasicTableHeaderUI extends TableHeaderUI
               break Scan;
             }
         }
-      if (col >= 0)
-        header.getTable().moveColumn(draggingColumnNumber, col);
+
+      header.getTable().moveColumn(draggingColumnNumber, col);
     }
   }
  
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
index ef491cbf1c64..d3abba217cde 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
@@ -78,6 +78,7 @@ import javax.swing.plaf.InputMapUIResource;
 import javax.swing.plaf.TableUI;
 import javax.swing.table.TableCellEditor;
 import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
 import javax.swing.table.TableColumnModel;
 import javax.swing.table.TableModel;
 
@@ -228,8 +229,6 @@ public class BasicTableUI extends TableUI
               if (e.getClickCount() < ce.getClickCountToStart())
                 return;
             }
-          else if (e.getClickCount() < 2)
-            return;
           table.editCellAt(row, col);
         }
     }
@@ -387,10 +386,8 @@ public class BasicTableUI extends TableUI
     int maxTotalColumnWidth = 0;
     for (int i = 0; i < table.getColumnCount(); i++)
       maxTotalColumnWidth += table.getColumnModel().getColumn(i).getMaxWidth();
-    if (maxTotalColumnWidth == 0 || table.getRowCount() == 0)
-      return null;
-    return new Dimension(maxTotalColumnWidth, table.getRowCount()*
-                         (table.getRowHeight()+table.getRowMargin()));
+
+    return new Dimension(maxTotalColumnWidth, getHeight());
   }
 
   /**
@@ -408,16 +405,45 @@ public class BasicTableUI extends TableUI
     int minTotalColumnWidth = 0;
     for (int i = 0; i < table.getColumnCount(); i++)
       minTotalColumnWidth += table.getColumnModel().getColumn(i).getMinWidth();
-    if (minTotalColumnWidth == 0 || table.getRowCount() == 0)
-      return null;
-    return new Dimension(minTotalColumnWidth, table.getRowCount()*table.getRowHeight());
+
+    return new Dimension(minTotalColumnWidth, getHeight());
   }
 
+  /**
+   * Returns the preferred size for the table of that UI.
+   *
+   * @param comp ignored, the <code>table</code> field is used instead
+   *
+   * @return the preferred size for the table of that UI
+   */
   public Dimension getPreferredSize(JComponent comp) 
   {
-    int width = table.getColumnModel().getTotalColumnWidth();
-    int height = table.getRowCount() * (table.getRowHeight()+table.getRowMargin());
-    return new Dimension(width, height);
+    int prefTotalColumnWidth = 0;
+    for (int i = 0; i < table.getColumnCount(); i++)
+      {
+        TableColumn col = table.getColumnModel().getColumn(i);
+        prefTotalColumnWidth += col.getPreferredWidth();
+      }
+    return new Dimension(prefTotalColumnWidth, getHeight());
+  }
+
+  /**
+   * Returns the table height. This helper method is used by
+   * {@link #getMinimumSize(JComponent)}, {@link #getPreferredSize(JComponent)}
+   * and {@link #getMaximumSize(JComponent)} to determine the table height.
+   *
+   * @return the table height
+   */
+  private int getHeight()
+  {
+    int height = 0;
+    int rowCount = table.getRowCount(); 
+    if (rowCount > 0 && table.getColumnCount() > 0)
+      {
+        Rectangle r = table.getCellRect(rowCount - 1, 0, true);
+        height = r.y + r.height;
+      }
+    return height;
   }
 
   protected void installDefaults() 
@@ -428,7 +454,6 @@ public class BasicTableUI extends TableUI
     table.setSelectionForeground(UIManager.getColor("Table.selectionForeground"));
     table.setSelectionBackground(UIManager.getColor("Table.selectionBackground"));
     table.setOpaque(true);
-    rendererPane = new CellRendererPane();
   }
 
   protected void installKeyboardActions() 
@@ -1188,6 +1213,9 @@ public class BasicTableUI extends TableUI
   public void installUI(JComponent comp) 
   {
     table = (JTable)comp;
+    rendererPane = new CellRendererPane();
+    table.add(rendererPane);
+
     installDefaults();
     installKeyboardActions();
     installListeners();
@@ -1197,7 +1225,11 @@ public class BasicTableUI extends TableUI
   {
     uninstallListeners();
     uninstallKeyboardActions();
-    uninstallDefaults();    
+    uninstallDefaults(); 
+
+    table.remove(rendererPane);
+    rendererPane = null;
+    table = null;
   }
 
   /**
@@ -1257,7 +1289,6 @@ public class BasicTableUI extends TableUI
       }
     
     Rectangle bounds = table.getCellRect(r0, c0, false);
-
     // The left boundary of the area being repainted.
     int left = bounds.x;
     
@@ -1278,9 +1309,9 @@ public class BasicTableUI extends TableUI
             bounds.x += widths[c] + columnMargin;
           }
         bounds.x = left;
-        bounds.y += table.getRowHeight(r) + rowMargin;
+        bounds.y += table.getRowHeight(r);
         // Update row height for tables with custom heights.
-        bounds.height = table.getRowHeight(r + 1);
+        bounds.height = table.getRowHeight(r + 1) - rowMargin;
       }
     
     bottom = bounds.y - rowMargin;
@@ -1311,7 +1342,7 @@ public class BasicTableUI extends TableUI
           {
             // The horizontal grid is draw below the cells, so we 
             // add before drawing.
-            y += table.getRowHeight(r) + rowMargin;
+            y += table.getRowHeight(r);
             gfx.drawLine(left, y, p2.x, y);
           }
         gfx.setColor(save);
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTextAreaUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTextAreaUI.java
index 93e119b31fa6..3f5aa27cf401 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTextAreaUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTextAreaUI.java
@@ -73,7 +73,7 @@ public class BasicTextAreaUI extends BasicTextUI
    */
   public View create(Element elem)
   {
-    JTextArea comp = (JTextArea)getComponent();
+    JTextArea comp = (JTextArea) getComponent();
     if (comp.getLineWrap())
       {
         if (comp.getWrapStyleWord())
@@ -105,7 +105,7 @@ public class BasicTextAreaUI extends BasicTextUI
    */
   protected void propertyChange(PropertyChangeEvent ev)
   {
-    JTextArea comp = (JTextArea)getComponent();
+    JTextArea comp = (JTextArea) getComponent();
     if (ev.getPropertyName() == "lineWrap"
         || ev.getPropertyName() == "wrapStyleWord")
       {
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
index 3b620f049893..b058175a4540 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing.plaf.basic;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Color;
 import java.awt.Container;
 import java.awt.Dimension;
@@ -64,10 +62,12 @@ import javax.swing.JComponent;
 import javax.swing.LookAndFeel;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
+import javax.swing.TransferHandler;
 import javax.swing.UIManager;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.plaf.ActionMapUIResource;
+import javax.swing.plaf.InputMapUIResource;
 import javax.swing.plaf.TextUI;
 import javax.swing.plaf.UIResource;
 import javax.swing.text.AbstractDocument;
@@ -734,18 +734,8 @@ public abstract class BasicTextUI extends TextUI
 
     // load any bindings for the newer InputMap / ActionMap interface
     SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED,
-                                     getInputMap(JComponent.WHEN_FOCUSED));
-    SwingUtilities.replaceUIActionMap(textComponent, createActionMap());
-    
-    ActionMap parentActionMap = new ActionMapUIResource();
-    Action[] actions = textComponent.getActions();
-    for (int j = 0; j < actions.length; j++)
-      {
-        Action currAction = actions[j];
-        parentActionMap.put(currAction.getValue(Action.NAME), currAction);
-      }
-    
-    SwingUtilities.replaceUIActionMap(textComponent, parentActionMap);
+                                     getInputMap());
+    SwingUtilities.replaceUIActionMap(textComponent, getActionMap());
   }
   
   /**
@@ -753,40 +743,71 @@ public abstract class BasicTextUI extends TextUI
    * 
    * @return an ActionMap to be installed on the text component
    */
-  ActionMap createActionMap()
+  private ActionMap getActionMap()
+  {
+    // Note: There are no .actionMap entries in the standard L&Fs. However,
+    // with the RI it is possible to install action maps via such keys, so
+    // we must load them too. It can be observed that when there is no
+    // .actionMap entry in the UIManager, one gets installed after a text
+    // component of that type has been loaded.
+    String prefix = getPropertyPrefix();
+    String amName = prefix + ".actionMap";
+    ActionMap am = (ActionMap) UIManager.get(amName);
+    if (am == null)
+      {
+        am = createActionMap();
+        UIManager.put(amName, am);
+      }
+
+    ActionMap map = new ActionMapUIResource();
+    map.setParent(am);
+
+    return map;
+  }
+
+  /**
+   * Creates a default ActionMap for text components that have no UI default
+   * for this (the standard for the built-in L&Fs). The ActionMap is copied
+   * from the text component's getActions() method.
+   *
+   * @returna default ActionMap
+   */
+  private ActionMap createActionMap()
   {
-    Action[] actions = textComponent.getActions();
     ActionMap am = new ActionMapUIResource();
-    for (int i = 0; i < actions.length; ++i)
+    Action[] actions = textComponent.getActions();
+    for (int i = actions.length - 1; i >= 0; i--)
       {
-        String name = (String) actions[i].getValue(Action.NAME);
-        if (name != null)
-          am.put(name, actions[i]);
+        Action action = actions[i];
+        am.put(action.getValue(Action.NAME), action);
       }
+    // Add TransferHandler's actions here. They don't seem to be in the
+    // JTextComponent's default actions, and I can't make up a better place
+    // to add them.
+    Action copyAction = TransferHandler.getCopyAction();
+    am.put(copyAction.getValue(Action.NAME), copyAction);
+    Action cutAction = TransferHandler.getCutAction();
+    am.put(cutAction.getValue(Action.NAME), cutAction);
+    Action pasteAction = TransferHandler.getPasteAction();
+    am.put(pasteAction.getValue(Action.NAME), pasteAction);
+
     return am;
   }
 
   /**
    * Gets the input map for the specified <code>condition</code>.
    *
-   * @param condition the condition for the InputMap
-   *
    * @return the InputMap for the specified condition
    */
-  InputMap getInputMap(int condition)
+  private InputMap getInputMap()
   {
+    InputMap im = new InputMapUIResource();
     String prefix = getPropertyPrefix();
-    switch (condition)
-      {
-      case JComponent.WHEN_IN_FOCUSED_WINDOW:
-        // FIXME: is this the right string? nobody seems to use it.
-        return (InputMap) UIManager.get(prefix + ".windowInputMap"); 
-      case JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT:
-        return (InputMap) UIManager.get(prefix + ".ancestorInputMap");
-      default:
-      case JComponent.WHEN_FOCUSED:
-        return (InputMap) UIManager.get(prefix + ".focusInputMap");
-      }
+    InputMap shared =
+      (InputMap) SharedUIDefaults.get(prefix + ".focusInputMap");
+    if (shared != null)
+      im.setParent(shared);
+    return im;
   }
 
   /**
@@ -831,9 +852,9 @@ public abstract class BasicTextUI extends TextUI
    * this UI.
    */
   protected void uninstallKeyboardActions()
-    throws NotImplementedException
   {
-    // FIXME: Uninstall keyboard actions here.
+    SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED, null);
+    SwingUtilities.replaceUIActionMap(textComponent, null);
   }
 
   /**
@@ -1041,7 +1062,12 @@ public abstract class BasicTextUI extends TextUI
 
         Rectangle l1 = modelToView(t, p0, firstBias);
         Rectangle l2 = modelToView(t, p1, secondBias);
-        if (l1.y == l2.y)
+        if (l1 == null || l2 == null)
+          {
+            // Unable to determine the start or end of the selection.
+            t.repaint();
+          }
+        else if (l1.y == l2.y)
           {
             SwingUtilities.computeUnion(l2.x, l2.y, l2.width, l2.height, l1);
             t.repaint(l1);
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java
index 896ea0c89dc9..921648670df8 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java
@@ -1,5 +1,5 @@
 /* BasicToggleButtonUI.java
-   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -44,21 +44,35 @@ import java.awt.Rectangle;
 
 import javax.swing.AbstractButton;
 import javax.swing.JComponent;
+import javax.swing.JToggleButton;
 import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 
+/**
+ * A UI delegate for the {@link JToggleButton} component.
+ */
 public class BasicToggleButtonUI extends BasicButtonUI
 {
-  public static ComponentUI createUI(final JComponent component)
+  
+  /**
+   * Returns a UI delegate for the specified component.
+   * 
+   * @param component  the component (should be an instance of 
+   *     {@link JToggleButton}).
+   *     
+   * @return An instance of <code>BasicToggleButtonUI</code>.
+   */
+  public static ComponentUI createUI(JComponent component)
   {
     return new BasicToggleButtonUI();
   }    
 
   /**
-   * Returns the prefix for the UI defaults property for this UI class.
-   * This is &apos;ToggleButton&apos; for this class.
+   * Returns the prefix for entries in the {@link UIManager} defaults table 
+   * (<code>"ToggleButton."</code> in this case).
    *
-   * @return the prefix for the UI defaults property
+   * @return <code>"ToggleButton."</code>
    */
   protected String getPropertyPrefix()
   {
@@ -89,15 +103,10 @@ public class BasicToggleButtonUI extends BasicButtonUI
     else
       vr = SwingUtilities.getLocalBounds(b);
     String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), 
-                                                     b.getText(),
-                                                     currentIcon(b),
-                                                     b.getVerticalAlignment(), 
-                                                     b.getHorizontalAlignment(),
-                                                     b.getVerticalTextPosition(), 
-                                                     b.getHorizontalTextPosition(),
-                                                     vr, ir, tr, 
-                                                     b.getIconTextGap() 
-                                                     + defaultTextShiftOffset);
+        b.getText(), currentIcon(b), b.getVerticalAlignment(), 
+        b.getHorizontalAlignment(), b.getVerticalTextPosition(), 
+        b.getHorizontalTextPosition(), vr, ir, tr, b.getIconTextGap() 
+        + defaultTextShiftOffset);
 
     if ((b.getModel().isArmed() && b.getModel().isPressed()) 
         || b.isSelected())
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
index 80fec6a775a1..eabac1570363 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -1,5 +1,5 @@
 /* BasicToolBarUI.java --
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -75,11 +75,12 @@ import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.border.Border;
-import javax.swing.border.EtchedBorder;
+import javax.swing.border.CompoundBorder;
 import javax.swing.event.MouseInputListener;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.ToolBarUI;
 import javax.swing.plaf.UIResource;
+import javax.swing.plaf.basic.BasicBorders.ButtonBorder;
 
 /**
  * This is the Basic Look and Feel UI class for JToolBar.
@@ -310,8 +311,19 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
    */
   protected Border createNonRolloverBorder()
   {
-    return new EtchedBorder();
-  }
+    Border b = UIManager.getBorder("ToolBar.nonrolloverBorder");
+    
+    if (b == null)
+      {
+        b = new CompoundBorder(
+            new ButtonBorder(UIManager.getColor("Button.shadow"),
+                             UIManager.getColor("Button.darkShadow"),
+                             UIManager.getColor("Button.light"),
+                             UIManager.getColor("Button.highlight")),
+            BasicBorders.getMarginBorder());
+      }
+    
+    return b;  }
 
   /**
    * This method creates a new PropertyChangeListener for the JToolBar.
@@ -331,18 +343,19 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
    */
   protected Border createRolloverBorder()
   {
-    return new EtchedBorder()
+    Border b = UIManager.getBorder("ToolBar.rolloverBorder");
+    
+    if (b == null)
       {
-	public void paintBorder(Component c, Graphics g, int x, int y,
-	                        int width, int height)
-	{
-	  if (c instanceof JButton)
-	    {
-	      if (((JButton) c).getModel().isRollover())
-		super.paintBorder(c, g, x, y, width, height);
-	    }
-	}
-      };
+        b = new CompoundBorder(
+            new ButtonBorder(UIManager.getColor("Button.shadow"),
+                             UIManager.getColor("Button.darkShadow"),
+                             UIManager.getColor("Button.light"),
+                             UIManager.getColor("Button.highlight")),
+            BasicBorders.getMarginBorder());
+      }
+    
+    return b;
   }
 
   /**
@@ -745,6 +758,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
    * @param direction The direction to give focus to.
    */
   protected void navigateFocusedComp(int direction)
+    throws NotImplementedException
   {
     // FIXME: Implement.
   }
@@ -761,6 +775,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
       {
 	AbstractButton b = (AbstractButton) c;
 	b.setRolloverEnabled(false);
+
+        // Save old border in hashtable.
+        borders.put(b, b.getBorder());
+        
 	b.setBorder(nonRolloverBorder);
       }
   }
@@ -772,11 +790,11 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
    */
   protected void setBorderToNormal(Component c)
   {
-    if (c instanceof JButton)
+    if (c instanceof AbstractButton)
       {
-	JButton b = (JButton) c;
-	Border border = (Border) borders.get(b);
-	b.setBorder(border);
+        AbstractButton b = (AbstractButton) c;
+        b.setRolloverEnabled(true);
+        b.setBorder((Border) borders.remove(b));
       }
   }
 
@@ -787,11 +805,15 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
    */
   protected void setBorderToRollover(Component c)
   {
-    if (c instanceof JButton)
+    if (c instanceof AbstractButton)
       {
-	JButton b = (JButton) c;
-	b.setRolloverEnabled(true);
-	b.setBorder(rolloverBorder);
+        AbstractButton b = (AbstractButton) c;
+        b.setRolloverEnabled(false);
+        
+        // Save old border in hashtable.
+        borders.put(b, b.getBorder());
+        
+        b.setBorder(rolloverBorder);
       }
   }
 
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
index be61ccaec22f..8cbea7f592d9 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
@@ -38,6 +38,7 @@
 
 package javax.swing.plaf.basic;
 
+import gnu.classpath.NotImplementedException;
 import gnu.javax.swing.tree.GnuPath;
 
 import java.awt.Color;
@@ -48,7 +49,6 @@ import java.awt.FontMetrics;
 import java.awt.Graphics;
 import java.awt.Insets;
 import java.awt.Label;
-import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -80,7 +80,6 @@ import javax.swing.JComponent;
 import javax.swing.JScrollBar;
 import javax.swing.JScrollPane;
 import javax.swing.JTree;
-import javax.swing.KeyStroke;
 import javax.swing.LookAndFeel;
 import javax.swing.SwingUtilities;
 import javax.swing.Timer;
@@ -96,7 +95,6 @@ import javax.swing.event.TreeSelectionEvent;
 import javax.swing.event.TreeSelectionListener;
 import javax.swing.plaf.ActionMapUIResource;
 import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.InputMapUIResource;
 import javax.swing.plaf.TreeUI;
 import javax.swing.tree.AbstractLayoutCache;
 import javax.swing.tree.DefaultTreeCellEditor;
@@ -251,6 +249,9 @@ public class BasicTreeUI
 
   /** The max height of the nodes in the tree. */
   int maxHeight = 0;
+  
+  /** The hash color. */
+  Color hashColor;
 
   /** Listeners */
   PropertyChangeListener propertyChangeListener;
@@ -279,6 +280,11 @@ public class BasicTreeUI
    * not the double mouse click) on the selected tree node.
    */
   Timer startEditTimer;
+  
+  /**
+   * The zero size icon, used for expand controls, if they are not visible.
+   */
+  static Icon nullIcon;
 
   /**
    * The special value of the mouse event is sent indicating that this is not
@@ -298,17 +304,6 @@ public class BasicTreeUI
     nodeDimensions = createNodeDimensions();
     configureLayoutCache();
 
-    propertyChangeListener = createPropertyChangeListener();
-    focusListener = createFocusListener();
-    treeSelectionListener = createTreeSelectionListener();
-    mouseListener = createMouseListener();
-    keyListener = createKeyListener();
-    selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener();
-    componentListener = createComponentListener();
-    cellEditorListener = createCellEditorListener();
-    treeExpansionListener = createTreeExpansionListener();
-    treeModelListener = createTreeModelListener();
-
     editingRow = - 1;
     lastSelectedRow = - 1;
   }
@@ -331,7 +326,7 @@ public class BasicTreeUI
    */
   protected Color getHashColor()
   {
-    return UIManager.getColor("Tree.hash");
+    return hashColor;
   }
 
   /**
@@ -341,8 +336,7 @@ public class BasicTreeUI
    */
   protected void setHashColor(Color color)
   {
-    // FIXME: Putting something in the UIDefaults map is certainly wrong.
-    UIManager.put("Tree.hash", color);
+    hashColor = color;
   }
 
   /**
@@ -505,9 +499,22 @@ public class BasicTreeUI
    */
   protected void setModel(TreeModel model)
   {
-    tree.setModel(model);
+    completeEditing();
+
+    if (treeModel != null && treeModelListener != null)
+      treeModel.removeTreeModelListener(treeModelListener);
+
     treeModel = tree.getModel();
-    treeState.setModel(treeModel);
+
+    if (treeModel != null && treeModelListener != null)
+      treeModel.addTreeModelListener(treeModelListener);
+
+    if (treeState != null)
+      {
+        treeState.setModel(treeModel);
+        updateLayoutCacheExpandedNodes();
+        updateSize();
+      }
   }
 
   /**
@@ -547,7 +554,13 @@ public class BasicTreeUI
    */
   protected void setShowsRootHandles(boolean newValue)
   {
-    tree.setShowsRootHandles(newValue);
+    completeEditing();
+    updateDepthOffset();
+    if (treeState != null)
+      {
+        treeState.invalidateSizes();
+        updateSize();
+      }
   }
 
   /**
@@ -673,6 +686,20 @@ public class BasicTreeUI
     treeState.setRowHeight(maxHeight);
     return maxHeight;
   }
+  
+  /**
+   * Get the tree node icon.
+   */
+  Icon getNodeIcon(TreePath path)
+  {
+    Object node = path.getLastPathComponent();
+    if (treeModel.isLeaf(node))
+      return UIManager.getIcon("Tree.leafIcon");
+    else if (treeState.getExpandedState(path))
+      return UIManager.getIcon("Tree.openIcon");
+    else
+      return UIManager.getIcon("Tree.closedIcon");
+  }
 
   /**
    * Returns the path for passed in row. If row is not visible null is returned.
@@ -801,7 +828,11 @@ public class BasicTreeUI
    */
   protected void prepareForUIInstall()
   {
-    // TODO: Implement this properly.
+    lastSelectedRow = -1;
+    preferredSize = new Dimension();
+    largeModel = tree.isLargeModel();
+    preferredSize = new Dimension();
+    setModel(tree.getModel());
   }
 
   /**
@@ -810,7 +841,14 @@ public class BasicTreeUI
    */
   protected void completeUIInstall()
   {
-    // TODO: Implement this properly.
+    setShowsRootHandles(tree.getShowsRootHandles());
+    updateRenderer();
+    updateDepthOffset();
+    setSelectionModel(tree.getSelectionModel());
+    treeState = createLayoutCache();
+    treeSelectionModel.setRowMapper(treeState);
+    configureLayoutCache();
+    updateSize();
   }
 
   /**
@@ -819,7 +857,7 @@ public class BasicTreeUI
    */
   protected void completeUIUninstall()
   {
-    // TODO: Implement this properly.
+    tree = null;
   }
 
   /**
@@ -972,15 +1010,14 @@ public class BasicTreeUI
    */
   protected TreeCellEditor createDefaultCellEditor()
   {
-    if (currentCellRenderer != null)
-      return new DefaultTreeCellEditor(
-                                       tree,
-                                       (DefaultTreeCellRenderer) currentCellRenderer,
-                                       cellEditor);
-    return new DefaultTreeCellEditor(
-                                     tree,
-                                     (DefaultTreeCellRenderer) createDefaultCellRenderer(),
-                                     cellEditor);
+    DefaultTreeCellEditor ed;
+    if (currentCellRenderer != null
+        && currentCellRenderer instanceof DefaultTreeCellRenderer)
+      ed = new DefaultTreeCellEditor(tree,
+                                (DefaultTreeCellRenderer) currentCellRenderer);
+    else
+      ed = new DefaultTreeCellEditor(tree, null);
+    return ed;
   }
 
   /**
@@ -1077,7 +1114,7 @@ public class BasicTreeUI
    */
   protected void updateLayoutCacheExpandedNodes()
   {
-    if (treeModel != null)
+    if (treeModel != null && treeModel.getRoot() != null)
       updateExpandedDescendants(new TreePath(treeModel.getRoot()));
   }
 
@@ -1132,14 +1169,12 @@ public class BasicTreeUI
   protected void updateRenderer()
   {
     if (tree != null)
-      {
-        if (tree.getCellRenderer() == null)
-          {
-            if (currentCellRenderer == null)
-              currentCellRenderer = createDefaultCellRenderer();
-            tree.setCellRenderer(currentCellRenderer);
-          }
-      }
+      currentCellRenderer = tree.getCellRenderer();
+
+    if (currentCellRenderer == null)
+      currentCellRenderer = createDefaultCellRenderer();
+
+    updateCellEditor();
   }
 
   /**
@@ -1206,6 +1241,7 @@ public class BasicTreeUI
 
     rightChildIndent = UIManager.getInt("Tree.rightChildIndent");
     leftChildIndent = UIManager.getInt("Tree.leftChildIndent");
+    totalChildIndent = rightChildIndent + leftChildIndent;
     setRowHeight(UIManager.getInt("Tree.rowHeight"));
     tree.setRowHeight(getRowHeight());
     tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand"));
@@ -1218,40 +1254,103 @@ public class BasicTreeUI
    */
   protected void installKeyboardActions()
   {
-    InputMap focusInputMap = (InputMap) UIManager.get("Tree.focusInputMap");
-    InputMapUIResource parentInputMap = new InputMapUIResource();
-    ActionMap parentActionMap = new ActionMapUIResource();
+    InputMap focusInputMap =
+      (InputMap) SharedUIDefaults.get("Tree.focusInputMap");
+    SwingUtilities.replaceUIInputMap(tree, JComponent.WHEN_FOCUSED,
+                                     focusInputMap);
+    InputMap ancestorInputMap =
+      (InputMap) SharedUIDefaults.get("Tree.ancestorInputMap");
+    SwingUtilities.replaceUIInputMap(tree,
+                                 JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+                                 ancestorInputMap);
+
     action = new TreeAction();
-    Object keys[] = focusInputMap.allKeys();
 
-    for (int i = 0; i < keys.length; i++)
-      {
-        parentInputMap.put(
-                           KeyStroke.getKeyStroke(
-                                                  ((KeyStroke) keys[i]).getKeyCode(),
-                                                  convertModifiers(((KeyStroke) keys[i]).getModifiers())),
-                           (String) focusInputMap.get((KeyStroke) keys[i]));
-
-        parentInputMap.put(
-                           KeyStroke.getKeyStroke(
-                                                  ((KeyStroke) keys[i]).getKeyCode(),
-                                                  ((KeyStroke) keys[i]).getModifiers()),
-                           (String) focusInputMap.get((KeyStroke) keys[i]));
-
-        parentActionMap.put(
-                            (String) focusInputMap.get((KeyStroke) keys[i]),
-                            new ActionListenerProxy(
-                                                    action,
-                                                    (String) focusInputMap.get((KeyStroke) keys[i])));
+    SwingUtilities.replaceUIActionMap(tree, getActionMap());
+  }
 
+  /**
+   * Creates and returns the shared action map for JTrees.
+   *
+   * @return the shared action map for JTrees
+   */
+  private ActionMap getActionMap()
+  {
+    ActionMap am = (ActionMap) UIManager.get("Tree.actionMap");
+    if (am == null)
+      {
+        am = createDefaultActions();
+        UIManager.getLookAndFeelDefaults().put("Tree.actionMap", am);
       }
+    return am;
+  }
+
+  /**
+   * Creates the default actions when there are none specified by the L&F.
+   *
+   * @return the default actions
+   */
+  private ActionMap createDefaultActions()
+  {
+    ActionMapUIResource am = new ActionMapUIResource();
+    Action action;
+
+    action= new TreeAction();
+    am.put(action.getValue(Action.NAME), action);
+
+    // TreeHomeAction.
+    action= new TreeHomeAction(-1, "selectFirst");
+    am.put(action.getValue(Action.NAME), action);
+    action= new TreeHomeAction(-1, "selectFirstChangeLead");
+    am.put(action.getValue(Action.NAME), action);
+    action= new TreeHomeAction(-1, "selectFirstExtendSelection");
+    am.put(action.getValue(Action.NAME), action);
+    action= new TreeHomeAction(1, "selectLast");
+    am.put(action.getValue(Action.NAME), action);
+    action= new TreeHomeAction(1, "selectLastChangeLead");
+    am.put(action.getValue(Action.NAME), action);
+    action= new TreeHomeAction(1, "selectLastExtendSelection");
+    am.put(action.getValue(Action.NAME), action);
+
+    // TreeIncrementAction.
+    action = new TreeIncrementAction(-1, "selectPrevious");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreeIncrementAction(-1, "selectPreviousExtendSelection");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreeIncrementAction(-1, "selectPreviousChangeLead");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreeIncrementAction(1, "selectNext");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreeIncrementAction(1, "selectNextExtendSelection");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreeIncrementAction(1, "selectNextChangeLead");
+    am.put(action.getValue(Action.NAME), action);
+
+    // TreeTraverseAction.
+    action = new TreeTraverseAction(-1, "selectParent");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreeTraverseAction(1, "selectChild");
+    am.put(action.getValue(Action.NAME), action);
+    
+    // TreeToggleAction.
+    action = new TreeToggleAction("toggleAndAnchor");
+    am.put(action.getValue(Action.NAME), action);
 
-    parentInputMap.setParent(tree.getInputMap(
-                                              JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent());
-    parentActionMap.setParent(tree.getActionMap().getParent());
-    tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(
-                                                                              parentInputMap);
-    tree.getActionMap().setParent(parentActionMap);
+    // TreePageAction.
+    action = new TreePageAction(-1, "scrollUpChangeSelection");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreePageAction(-1, "scrollUpExtendSelection");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreePageAction(-1, "scrollUpChangeLead");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreePageAction(1, "scrollDownChangeSelection");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreePageAction(1, "scrollDownExtendSelection");
+    am.put(action.getValue(Action.NAME), action);
+    action = new TreePageAction(1, "scrollDownChangeLead");
+    am.put(action.getValue(Action.NAME), action);
+
+    return am;
   }
 
   /**
@@ -1295,16 +1394,41 @@ public class BasicTreeUI
    */
   protected void installListeners()
   {
+    propertyChangeListener = createPropertyChangeListener();
     tree.addPropertyChangeListener(propertyChangeListener);
+
+    focusListener = createFocusListener();
     tree.addFocusListener(focusListener);
+
+    treeSelectionListener = createTreeSelectionListener();
     tree.addTreeSelectionListener(treeSelectionListener);
+
+    mouseListener = createMouseListener();
     tree.addMouseListener(mouseListener);
+
+    keyListener = createKeyListener();
     tree.addKeyListener(keyListener);
-    tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
+
+    selectionModelPropertyChangeListener =
+      createSelectionModelPropertyChangeListener();
+    if (treeSelectionModel != null
+        && selectionModelPropertyChangeListener != null)
+      {
+        treeSelectionModel.addPropertyChangeListener
+                                        (selectionModelPropertyChangeListener);
+      }
+
+    componentListener = createComponentListener();
     tree.addComponentListener(componentListener);
+
+    treeExpansionListener = createTreeExpansionListener();
     tree.addTreeExpansionListener(treeExpansionListener);
+
+    treeModelListener = createTreeModelListener();
     if (treeModel != null)
       treeModel.addTreeModelListener(treeModelListener);
+
+    cellEditorListener = createCellEditorListener();
   }
 
   /**
@@ -1315,27 +1439,15 @@ public class BasicTreeUI
   public void installUI(JComponent c)
   {
     tree = (JTree) c;
-    treeModel = tree.getModel();
 
     prepareForUIInstall();
-    super.installUI(c);
     installDefaults();
     installComponents();
     installKeyboardActions();
     installListeners();
-
-    setCellEditor(createDefaultCellEditor());
-    createdCellEditor = true;
-    isEditing = false;
-
-    setModel(tree.getModel());
-    treeSelectionModel = tree.getSelectionModel();
-    setRootVisible(tree.isRootVisible());
-    treeState.setRootVisible(tree.isRootVisible());
-
     completeUIInstall();
   }
-
+  
   /**
    * Uninstall the defaults for the tree
    */
@@ -1353,11 +1465,12 @@ public class BasicTreeUI
    */
   public void uninstallUI(JComponent c)
   {
+    completeEditing();
+
     prepareForUIUninstall();
     uninstallDefaults();
     uninstallKeyboardActions();
     uninstallListeners();
-    tree = null;
     uninstallComponents();
     completeUIUninstall();
   }
@@ -1590,6 +1703,9 @@ public class BasicTreeUI
   protected void completeEditing(boolean messageStop, boolean messageCancel,
                                  boolean messageTree)
   {
+    if (! stopEditingInCompleteEditing || editingComponent == null)
+      return;
+
     if (messageStop)
       {
         getCellEditor().stopCellEditing();
@@ -1675,7 +1791,7 @@ public class BasicTreeUI
                                               int mouseY)
   {
     if (isLocationInExpandControl(path, mouseX, mouseY))
-      toggleExpandState(path);
+      handleExpandControlClick(path, mouseX, mouseY);
   }
 
   /**
@@ -1694,16 +1810,17 @@ public class BasicTreeUI
                                               int mouseY)
   {
     boolean cntlClick = false;
-    int row = getRowForPath(tree, path);
-
-    if (! isLeaf(row))
+    if (! treeModel.isLeaf(path.getLastPathComponent()))
       {
-        Rectangle bounds = getPathBounds(tree, path);
-
-        if (hasControlIcons()
-            && (mouseX < bounds.x)
-            && (mouseX > (bounds.x - getCurrentControlIcon(path).getIconWidth() - gap)))
-          cntlClick = true;
+        int width = 8; // Only guessing.
+        Icon expandedIcon = getExpandedIcon();
+        if (expandedIcon != null)
+          width = expandedIcon.getIconWidth();
+
+        Insets i = tree.getInsets();
+        int left = getRowX(tree.getRowForPath(path), path.getPathCount() - 1)
+                   -getRightChildIndent() - width / 2 + i.left;
+        cntlClick = mouseX >= left && mouseX <= left + width;
       }
     return cntlClick;
   }
@@ -1786,7 +1903,14 @@ public class BasicTreeUI
    */
   protected boolean isToggleEvent(MouseEvent event)
   {
-    return true;
+    boolean toggle = false;
+    if (SwingUtilities.isLeftMouseButton(event))
+      {
+        int clickCount = tree.getToggleClickCount();
+        if (clickCount > 0 && event.getClickCount() == clickCount)
+          toggle = true;
+      }
+    return toggle;
   }
 
   /**
@@ -1831,7 +1955,8 @@ public class BasicTreeUI
       {
         // This is an ordinary event that just selects the clicked row.
         tree.setSelectionPath(path);
-        tree.setAnchorSelectionPath(path);
+        if (isToggleEvent(event))
+          toggleExpandState(path);
       }
   }
 
@@ -1969,7 +2094,32 @@ public class BasicTreeUI
      */
     public void componentMoved(ComponentEvent e)
     {
-      // TODO: What should be done here, if anything?
+      if (timer == null)
+        {
+          JScrollPane scrollPane = getScrollPane();
+          if (scrollPane == null)
+            updateSize();
+          else
+            {
+              // Determine the scrollbar that is adjusting, if any, and
+              // start the timer for that. If no scrollbar is adjusting,
+              // we simply call updateSize().
+              scrollBar = scrollPane.getVerticalScrollBar();
+              if (scrollBar == null || !scrollBar.getValueIsAdjusting())
+                {
+                  // It's not the vertical scrollbar, try the horizontal one.
+                  scrollBar = scrollPane.getHorizontalScrollBar();
+                  if (scrollBar != null && scrollBar.getValueIsAdjusting())
+                    startTimer();
+                  else
+                    updateSize();
+                }
+              else
+                {
+                  startTimer();
+                }
+            }
+        }
     }
 
     /**
@@ -1978,7 +2128,12 @@ public class BasicTreeUI
      */
     protected void startTimer()
     {
-      // TODO: Implement this properly.
+      if (timer == null)
+        {
+          timer = new Timer(200, this);
+          timer.setRepeats(true);
+        }
+      timer.start();
     }
 
     /**
@@ -1988,7 +2143,13 @@ public class BasicTreeUI
      */
     protected JScrollPane getScrollPane()
     {
-      return null;
+      JScrollPane found = null;
+      Component p = tree.getParent();
+      while (p != null && !(p instanceof JScrollPane))
+        p = p.getParent();
+      if (p instanceof JScrollPane)
+        found = (JScrollPane) p;
+      return found;
     }
 
     /**
@@ -1999,7 +2160,14 @@ public class BasicTreeUI
      */
     public void actionPerformed(ActionEvent ae)
     {
-      // TODO: Implement this properly.
+      if (scrollBar == null || !scrollBar.getValueIsAdjusting())
+        {
+          if (timer != null)
+            timer.stop();
+          updateSize();
+          timer = null;
+          scrollBar = null;
+        }
     }
   }
 
@@ -2080,7 +2248,7 @@ public class BasicTreeUI
     {
       repaintLeadRow();
     }
-    
+
     /**
      * Repaint the lead row.
      */
@@ -2122,6 +2290,7 @@ public class BasicTreeUI
      * @param e the key typed
      */
     public void keyTyped(KeyEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2132,6 +2301,7 @@ public class BasicTreeUI
      * @param e the key pressed
      */
     public void keyPressed(KeyEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2142,6 +2312,7 @@ public class BasicTreeUI
      * @param e the key released
      */
     public void keyReleased(KeyEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2170,94 +2341,29 @@ public class BasicTreeUI
      */
     public void mousePressed(MouseEvent e)
     {
-      // Any mouse click cancels the previous waiting edit action, initiated
-      // by the single click on the selected node.
-      if (startEditTimer != null)
-        {
-          startEditTimer.stop();
-          startEditTimer = null;
-        }
-
-      Point click = e.getPoint();
-      TreePath path = getClosestPathForLocation(tree, click.x, click.y);
 
-      if (path != null)
+      if (tree != null && tree.isEnabled())
         {
-          Rectangle bounds = getPathBounds(tree, path);
-          int row = getRowForPath(tree, path);
-          
-          // Cancel the editing session if clicked on the different row.
-          if (tree.isEditing() && row != editingRow)
-            cancelEditing(tree);
-          
-          boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);
-
-          boolean isLeaf = isLeaf(row);
-
-          TreeCellRenderer tcr = getCellRenderer();
-          Icon icon;
-          if (isLeaf)
-            icon = UIManager.getIcon("Tree.leafIcon");
-          else if (tree.isExpanded(path))
-            icon = UIManager.getIcon("Tree.openIcon");
-          else
-            icon = UIManager.getIcon("Tree.closedIcon");
-
-          if (tcr instanceof DefaultTreeCellRenderer)
-            {
-              Icon tmp = ((DefaultTreeCellRenderer) tcr).getIcon();
-              if (tmp != null)
-                icon = tmp;
-            }
+          // Maybe stop editing and return.
+          if (isEditing(tree) && tree.getInvokesStopCellEditing()
+              && !stopEditing(tree))
+            return;
 
-          // add gap*2 for the space before and after the text
-          if (icon != null)
-            bounds.width += icon.getIconWidth() + gap * 2;
+          int x = e.getX();
+          int y = e.getY();
+          TreePath path = getClosestPathForLocation(tree, x, y);
 
-          boolean inBounds = bounds.contains(click.x, click.y);
-          if ((inBounds || cntlClick) && tree.isVisible(path))
+          if (path != null)
             {
-              if (inBounds)
-                {
-                  TreePath currentLead = tree.getLeadSelectionPath();
-                  if (currentLead != null && currentLead.equals(path)
-                      && e.getClickCount() == 1 && tree.isEditable())
-                    {
-                      // Schedule the editing session.
-                      final TreePath editPath = path;
-
-                      if (startEditTimer != null)
-                        startEditTimer.stop();
-
-                      startEditTimer = new Timer(WAIT_TILL_EDITING,
-                        new ActionListener()
-                          {
-                            public void actionPerformed(ActionEvent e)
-                              {
-                                startEditing(editPath, EDIT);
-                              }
-                          });
-                      startEditTimer.setRepeats(false);
-                      startEditTimer.start();
-                    }
-                  else
-                    {
-                      if (e.getClickCount() == 2 && ! isLeaf(row))
-                        toggleExpandState(path);
-                      else
-                        selectPathForEvent(path, e);
-                    }
-                }
+              Rectangle bounds = getPathBounds(tree, path);
+              if (SwingUtilities.isLeftMouseButton(e))
+                checkForClickInExpandControl(path, x, y);
 
-              if (cntlClick)
+              if (x > bounds.x && x <= (bounds.x + bounds.width))
                 {
-                  handleExpandControlClick(path, click.x, click.y);
-                  if (cellEditor != null)
-                    cellEditor.cancelCellEditing();
-                  tree.scrollPathToVisible(path);
+                  if (! startEditing(path, e))
+                    selectPathForEvent(path, e);
                 }
-              else if (tree.isEditable())
-                startEditing(path, e);
             }
         }
     }
@@ -2271,6 +2377,7 @@ public class BasicTreeUI
      * @param e is the mouse event that occured
      */
     public void mouseDragged(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2282,6 +2389,7 @@ public class BasicTreeUI
      * @param e the mouse event that occured
      */
     public void mouseMoved(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2292,6 +2400,7 @@ public class BasicTreeUI
      * @param e is the mouse event that occured
      */
     public void mouseReleased(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2332,6 +2441,7 @@ public class BasicTreeUI
      * @param e mouse event that occured
      */
     public void mouseClicked(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2342,6 +2452,7 @@ public class BasicTreeUI
      * @param e mouse event that occured
      */
     public void mousePressed(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2352,6 +2463,7 @@ public class BasicTreeUI
      * @param e mouse event that occured
      */
     public void mouseReleased(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2362,6 +2474,7 @@ public class BasicTreeUI
      * @param e mouse event that occured
      */
     public void mouseEntered(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2372,6 +2485,7 @@ public class BasicTreeUI
      * @param e mouse event that occured
      */
     public void mouseExited(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2385,6 +2499,7 @@ public class BasicTreeUI
      * @param e mouse event that occured
      */
     public void mouseDragged(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2396,6 +2511,7 @@ public class BasicTreeUI
      * @param e mouse event that occured
      */
     public void mouseMoved(MouseEvent e)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
@@ -2404,6 +2520,7 @@ public class BasicTreeUI
      * Removes event from the source
      */
     protected void removeFromSource()
+    throws NotImplementedException
     {
       // TODO: Implement this properly.
     }
@@ -2450,10 +2567,11 @@ public class BasicTreeUI
 
       if (s != null)
         {
+          TreePath path = treeState.getPathForRow(row);
           size.x = getRowX(row, depth);
           size.width = SwingUtilities.computeStringWidth(fm, s);
-          size.width = size.width + getCurrentControlIcon(null).getIconWidth()
-                       + gap;
+          size.width = size.width + getCurrentControlIcon(path).getIconWidth()
+                       + gap + getNodeIcon(path).getIconWidth();
           size.height = getMaxHeight(tree);
           size.y = size.height * row;
         }
@@ -2468,8 +2586,7 @@ public class BasicTreeUI
      */
     protected int getRowX(int row, int depth)
     {
-      int iw = getCurrentControlIcon(null).getIconWidth();
-      return depth * (rightChildIndent + iw/2);
+      return BasicTreeUI.this.getRowX(row, depth);
     }
   }// NodeDimensionsHandler
 
@@ -2511,8 +2628,14 @@ public class BasicTreeUI
         }
       else if (property.equals(JTree.TREE_MODEL_PROPERTY))
         {
-          treeModel = tree.getModel();
-          treeModel.addTreeModelListener(treeModelListener);
+          setModel(tree.getModel());
+        }
+      else if (property.equals(JTree.CELL_RENDERER_PROPERTY))
+        {
+          setCellRenderer(tree.getCellRenderer());
+          // Update layout.
+          if (treeState != null)
+            treeState.invalidateSizes();
         }
     }
   }
@@ -2540,45 +2663,38 @@ public class BasicTreeUI
      *          the property that has changed.
      */
     public void propertyChange(PropertyChangeEvent event)
+    throws NotImplementedException
     {
       // TODO: What should be done here, if anything?
     }
   }
 
   /**
-   * ActionListener that invokes cancelEditing when action performed.
+   * The action to cancel editing on this tree.
    */
   public class TreeCancelEditingAction
       extends AbstractAction
   {
-
     /**
-     * Constructor
+     * Creates the new tree cancel editing action.
+     * 
+     * @param name the name of the action (used in toString).
      */
     public TreeCancelEditingAction(String name)
     {
-      // TODO: Implement this properly.
+      super(name);
     }
 
     /**
-     * Invoked when an action occurs.
+     * Invoked when an action occurs, cancels the cell editing (if the
+     * tree cell is being edited). 
      * 
      * @param e event that occured
      */
     public void actionPerformed(ActionEvent e)
     {
-      // TODO: Implement this properly.
-    }
-
-    /**
-     * Returns true if the action is enabled.
-     * 
-     * @return true if the action is enabled, false otherwise
-     */
-    public boolean isEnabled()
-    {
-      // TODO: Implement this properly.
-      return false;
+      if (isEnabled() && tree.isEditing())
+        tree.cancelEditing();
     }
   }
 
@@ -2606,6 +2722,8 @@ public class BasicTreeUI
     {
       validCachedPreferredSize = false;
       treeState.setExpandedState(event.getPath(), true);
+      // The maximal cell height may change
+      maxHeight = 0;
       tree.revalidate();
       tree.repaint();
     }
@@ -2619,6 +2737,8 @@ public class BasicTreeUI
     {
       validCachedPreferredSize = false;
       treeState.setExpandedState(event.getPath(), false);
+      // The maximal cell height may change
+      maxHeight = 0;
       tree.revalidate();
       tree.repaint();
     }
@@ -2636,14 +2756,16 @@ public class BasicTreeUI
     protected int direction;
 
     /**
-     * Constructor
+     * Creates a new TreeHomeAction instance.
      * 
-     * @param direction - it is home or end
-     * @param name is the name of the direction
+     * @param dir the direction to go to, <code>-1</code> for home,
+     *        <code>1</code> for end
+     * @param name the name of the action
      */
-    public TreeHomeAction(int direction, String name)
+    public TreeHomeAction(int dir, String name)
     {
-      // TODO: Implement this properly
+      direction = dir;
+      putValue(Action.NAME, name);
     }
 
     /**
@@ -2653,7 +2775,61 @@ public class BasicTreeUI
      */
     public void actionPerformed(ActionEvent e)
     {
-      // TODO: Implement this properly
+      if (tree != null)
+        {
+          String command = (String) getValue(Action.NAME);
+          if (command.equals("selectFirst"))
+            {
+              ensureRowsAreVisible(0, 0);
+              tree.setSelectionInterval(0, 0);
+            }
+          if (command.equals("selectFirstChangeLead"))
+            {
+              ensureRowsAreVisible(0, 0);
+              tree.setLeadSelectionPath(getPathForRow(tree, 0));
+            }
+          if (command.equals("selectFirstExtendSelection"))
+            {
+              ensureRowsAreVisible(0, 0);
+              TreePath anchorPath = tree.getAnchorSelectionPath();
+              if (anchorPath == null)
+                tree.setSelectionInterval(0, 0);
+              else
+                {
+                  int anchorRow = getRowForPath(tree, anchorPath);
+                  tree.setSelectionInterval(0, anchorRow);
+                  tree.setAnchorSelectionPath(anchorPath);
+                  tree.setLeadSelectionPath(getPathForRow(tree, 0));
+                }
+            }
+          else if (command.equals("selectLast"))
+            {
+              int end = getRowCount(tree) - 1;
+              ensureRowsAreVisible(end, end);
+              tree.setSelectionInterval(end, end);
+            }
+          else if (command.equals("selectLastChangeLead"))
+            {
+              int end = getRowCount(tree) - 1;
+              ensureRowsAreVisible(end, end);
+              tree.setLeadSelectionPath(getPathForRow(tree, end));
+            }
+          else if (command.equals("selectLastExtendSelection"))
+            {
+              int end = getRowCount(tree) - 1;
+              ensureRowsAreVisible(end, end);
+              TreePath anchorPath = tree.getAnchorSelectionPath();
+              if (anchorPath == null)
+                tree.setSelectionInterval(end, end);
+              else
+                {
+                  int anchorRow = getRowForPath(tree, anchorPath);
+                  tree.setSelectionInterval(end, anchorRow);
+                  tree.setAnchorSelectionPath(anchorPath);
+                  tree.setLeadSelectionPath(getPathForRow(tree, end));
+                }
+            }
+        }
     }
 
     /**
@@ -2663,8 +2839,7 @@ public class BasicTreeUI
      */
     public boolean isEnabled()
     {
-      // TODO: Implement this properly
-      return false;
+      return (tree != null) && tree.isEnabled();
     }
   }
 
@@ -2673,21 +2848,24 @@ public class BasicTreeUI
    * up or down based on direction.
    */
   public class TreeIncrementAction
-      extends AbstractAction
+    extends AbstractAction
   {
 
-    /** Specifies the direction to adjust the selection by. */
+    /**
+     * Specifies the direction to adjust the selection by.
+     */
     protected int direction;
 
     /**
-     * Constructor
+     * Creates a new TreeIncrementAction.
      * 
-     * @param direction up or down
+     * @param dir up or down, <code>-1</code> for up, <code>1</code> for down
      * @param name is the name of the direction
      */
-    public TreeIncrementAction(int direction, String name)
+    public TreeIncrementAction(int dir, String name)
     {
-      // TODO: Implement this properly
+      direction = dir;
+      putValue(Action.NAME, name);
     }
 
     /**
@@ -2712,7 +2890,7 @@ public class BasicTreeUI
       boolean hasNext = nextRow < rows;
       boolean hasPrev = prevRow >= 0 && rows > 0;
       TreePath newPath;
-      String command = e.getActionCommand();
+      String command = (String) getValue(Action.NAME);
 
       if (command.equals("selectPreviousChangeLead") && hasPrev)
         {
@@ -2776,8 +2954,7 @@ public class BasicTreeUI
      */
     public boolean isEnabled()
     {
-      // TODO: Implement this properly
-      return false;
+      return (tree != null) && tree.isEnabled();
     }
   }
 
@@ -2883,6 +3060,7 @@ public class BasicTreeUI
     public TreePageAction(int direction, String name)
     {
       this.direction = direction;
+      putValue(Action.NAME, name);
     }
 
     /**
@@ -2892,7 +3070,94 @@ public class BasicTreeUI
      */
     public void actionPerformed(ActionEvent e)
     {
-      // TODO: Implement this properly.
+      String command = (String) getValue(Action.NAME);
+      boolean extendSelection = command.equals("scrollUpExtendSelection")
+                                || command.equals("scrollDownExtendSelection");
+      boolean changeSelection = command.equals("scrollUpChangeSelection")
+                                || command.equals("scrollDownChangeSelection");
+
+      // Disable change lead, unless we are in discontinuous mode.
+      if (!extendSelection && !changeSelection
+          && tree.getSelectionModel().getSelectionMode() !=
+            TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
+        {
+          changeSelection = true;
+        }
+
+      int rowCount = getRowCount(tree);
+      if (rowCount > 0 && treeSelectionModel != null)
+        {
+          Dimension maxSize = tree.getSize();
+          TreePath lead = tree.getLeadSelectionPath();
+          TreePath newPath = null;
+          Rectangle visible = tree.getVisibleRect();
+          if (direction == -1) // The RI handles -1 as up.
+            {
+              newPath = getClosestPathForLocation(tree, visible.x, visible.y);
+              if (newPath.equals(lead)) // Corner case, adjust one page up.
+                {
+                  visible.y = Math.max(0, visible.y - visible.height);
+                  newPath = getClosestPathForLocation(tree, visible.x,
+                                                      visible.y);
+                }
+            }
+          else // +1 is down.
+            {
+              visible.y = Math.min(maxSize.height,
+                                   visible.y + visible.height - 1);
+              newPath = getClosestPathForLocation(tree, visible.x, visible.y);
+              if (newPath.equals(lead)) // Corner case, adjust one page down.
+                {
+                  visible.y = Math.min(maxSize.height,
+                                       visible.y + visible.height - 1);
+                  newPath = getClosestPathForLocation(tree, visible.x,
+                                                      visible.y);
+                }
+            }
+
+          // Determine new visible rect.
+          Rectangle newVisible = getPathBounds(tree, newPath);
+          newVisible.x = visible.x;
+          newVisible.width = visible.width;
+          if (direction == -1)
+            {
+              newVisible.height = visible.height;
+            }
+          else
+            {
+              newVisible.y -= (visible.height - newVisible.height);
+              newVisible.height = visible.height;
+            }
+
+          if (extendSelection)
+            {
+              // Extend selection.
+              TreePath anchorPath = tree.getAnchorSelectionPath();
+              if (anchorPath == null)
+                {
+                  tree.setSelectionPath(newPath);
+                }
+              else
+                {
+                  int newIndex = getRowForPath(tree, newPath);
+                  int anchorIndex = getRowForPath(tree, anchorPath);
+                  tree.setSelectionInterval(Math.min(anchorIndex, newIndex),
+                                            Math.max(anchorIndex, newIndex));
+                  tree.setAnchorSelectionPath(anchorPath);
+                  tree.setLeadSelectionPath(newPath);
+                }
+            }
+          else if (changeSelection)
+            {
+              tree.setSelectionPath(newPath);
+            }
+          else // Change lead.
+            {
+              tree.setLeadSelectionPath(newPath);
+            }
+
+          tree.scrollRectToVisible(newVisible);
+        }
     }
 
     /**
@@ -2902,7 +3167,7 @@ public class BasicTreeUI
      */
     public boolean isEnabled()
     {
-      return false;
+      return (tree != null) && tree.isEnabled();
     }
   }// TreePageAction
 
@@ -2958,13 +3223,13 @@ public class BasicTreeUI
       extends AbstractAction
   {
     /**
-     * Constructor
+     * Creates a new TreeToggleAction.
      * 
      * @param name is the name of <code>Action</code> field
      */
     public TreeToggleAction(String name)
     {
-      // Nothing to do here.
+      putValue(Action.NAME, name);
     }
 
     /**
@@ -2974,7 +3239,17 @@ public class BasicTreeUI
      */
     public void actionPerformed(ActionEvent e)
     {
-      // TODO: Implement this properly.
+      int selected = tree.getLeadSelectionRow();
+      if (selected != -1 && isLeaf(selected))
+        {
+          TreePath anchorPath = tree.getAnchorSelectionPath();
+          TreePath leadPath = tree.getLeadSelectionPath();
+          toggleExpandState(getPathForRow(tree, selected));
+          // Need to do this, so that the toggling doesn't mess up the lead
+          // and anchor.
+          tree.setLeadSelectionPath(leadPath);
+          tree.setAnchorSelectionPath(anchorPath);
+        }
     }
 
     /**
@@ -2984,7 +3259,7 @@ public class BasicTreeUI
      */
     public boolean isEnabled()
     {
-      return false;
+      return (tree != null) && tree.isEnabled();
     }
   } // TreeToggleAction
 
@@ -3009,6 +3284,7 @@ public class BasicTreeUI
     public TreeTraverseAction(int direction, String name)
     {
       this.direction = direction;
+      putValue(Action.NAME, name);
     }
 
     /**
@@ -3022,7 +3298,8 @@ public class BasicTreeUI
       if (current == null)
         return;
 
-      if (e.getActionCommand().equals("selectParent"))
+      String command = (String) getValue(Action.NAME);
+      if (command.equals("selectParent"))
         {
           if (current == null)
             return;
@@ -3042,7 +3319,7 @@ public class BasicTreeUI
                 tree.setSelectionPath(parent);
             }
         }
-      else if (e.getActionCommand().equals("selectChild"))
+      else if (command.equals("selectChild"))
         {
           Object node = current.getLastPathComponent();
           int nc = treeModel.getChildCount(node);
@@ -3068,8 +3345,7 @@ public class BasicTreeUI
      */
     public boolean isEnabled()
     {
-      // TODO: Implement this properly
-      return false;
+      return (tree != null) && tree.isEnabled();
     }
   }
 
@@ -3094,9 +3370,35 @@ public class BasicTreeUI
    */
   Icon getCurrentControlIcon(TreePath path)
   {
-    if (tree.isExpanded(path))
-      return expandedIcon;
-    return collapsedIcon;
+    if (hasControlIcons())
+      {
+        if (tree.isExpanded(path))
+          return expandedIcon;
+        else
+          return collapsedIcon;
+      }
+    else
+      {
+        if (nullIcon == null)
+          nullIcon = new Icon()
+          {
+            public int getIconHeight()
+            {
+              return 0;
+            }
+
+            public int getIconWidth()
+            {
+              return 0;
+            }
+
+            public void paintIcon(Component c, Graphics g, int x, int y)
+            {
+              // No action here.
+            }
+          };
+        return nullIcon;
+      }
   }
 
   /**
@@ -3323,10 +3625,8 @@ public class BasicTreeUI
   {
     if (row != 0)
       {
-        Icon icon = getCurrentControlIcon(path);
-        int iconW = icon.getIconWidth();
         paintHorizontalLine(g, tree, bounds.y + bounds.height / 2,
-                            bounds.x - iconW/2 - gap, bounds.x - gap);
+                            bounds.x - leftChildIndent - gap, bounds.x - gap);
       }
   }
 
@@ -3379,15 +3679,13 @@ public class BasicTreeUI
     paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded,
                        hasBeenExpanded, isLeaf);
 
-    TreeCellRenderer dtcr = tree.getCellRenderer();
-    if (dtcr == null)
-      dtcr = createDefaultCellRenderer();
+    TreeCellRenderer dtcr = currentCellRenderer;
 
     boolean focused = false;
-    if (treeSelectionModel!= null)
-      focused = treeSelectionModel.getLeadSelectionRow() == row 
-        && tree.isFocusOwner();
-    
+    if (treeSelectionModel != null)
+      focused = treeSelectionModel.getLeadSelectionRow() == row
+                && tree.isFocusOwner();
+
     Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
                                                     isExpanded, isLeaf, row,
                                                     focused);
@@ -3400,7 +3698,7 @@ public class BasicTreeUI
    */
   protected void prepareForUIUninstall()
   {
-    // TODO: Implement this properly.
+    // Nothing to do here yet.
   }
 
   /**
@@ -3440,4 +3738,14 @@ public class BasicTreeUI
     editingComponent = null;
     tree.requestFocus();
   }
+  
+  /**
+   * Returns the amount to indent the given row
+   * 
+   * @return amount to indent the given row.
+   */
+  protected int getRowX(int row, int depth)
+  {
+    return depth * totalChildIndent;
+  }
 } // BasicTreeUI
diff --git a/libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java b/libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java
new file mode 100644
index 000000000000..478764911606
--- /dev/null
+++ b/libjava/classpath/javax/swing/plaf/basic/SharedUIDefaults.java
@@ -0,0 +1,78 @@
+/* SharedUIDefaults.java -- Manages shared instances for UIDefaults
+   Copyright (C) 2006 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 javax.swing.plaf.basic;
+
+import java.util.HashMap;
+
+import javax.swing.UIManager;
+
+/**
+ * Manages shared instances for UI defaults. For example, all Swing components
+ * of one type usually share one InputMap/ActionMap pair. In order to avoid
+ * duplication of such objects we store them in a Map here.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class SharedUIDefaults
+{
+
+  /**
+   * Stores the shared instances, indexed by their UI names
+   * (i.e. "TextField.InputMap").
+   */
+  private static HashMap sharedDefaults = new HashMap();
+
+  /**
+   * Returns a shared UI defaults object.
+   *
+   * @param key the key for the shared object
+   *
+   * @return a shared UI defaults object for the specified key
+   */
+  static Object get(String key)
+  {
+    Object o = sharedDefaults.get(key);
+    if (o == null)
+      {
+        o = UIManager.get(key);
+        sharedDefaults.put(key, o);
+      }
+    return o;
+  }
+}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java b/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java
index 98a00ee0a0e6..7c41180aeae5 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java
@@ -103,7 +103,16 @@ public class MetalBorders
   private static BasicBorders.MarginBorder marginBorder;
 
   /**
-   * A border used for {@link JButton} components.
+   * <p>A border used for {@link JButton} components.</p>
+   * 
+   * <p>This {@link Border} implementation can handle only instances of
+   * {@link AbstractButton} and their subclasses.</p>
+   * 
+   * <p>If the Metal Look and Feel's current theme is 'Ocean' the border
+   * will be painted with a special highlight when the mouse cursor if
+   * over the button (ie. the property <code>rollover</code> of the
+   * button's model is <code>true</code>) and is not a <b>direct</b>
+   * child of a {@link JToolBar}.</p> 
    */
   public static class ButtonBorder extends AbstractBorder implements UIResource
   {
@@ -157,8 +166,14 @@ public class MetalBorders
     {
       ButtonModel bmodel = null;
 
+      // The RI will fail with a ClassCastException in such a situation.
+      // This code tries to be more helpful.
       if (c instanceof AbstractButton)
         bmodel = ((AbstractButton) c).getModel();
+      else
+        throw new IllegalStateException("A ButtonBorder is supposed to work "
+                                        + "only with AbstractButton and"
+                                        + "subclasses.");
 
       Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
       Color shadow = MetalLookAndFeel.getControlShadow();
@@ -191,7 +206,7 @@ public class MetalBorders
             {
               // The normal border. This is used when the button is not
               // pressed or the button is not armed.
-              if (! (bmodel.isPressed() && bmodel.isArmed()) )
+              if (! (bmodel.isPressed() && bmodel.isArmed()))
                 {
                   // draw light border
                   g.setColor(light);
@@ -246,8 +261,14 @@ public class MetalBorders
     {
       ButtonModel bmodel = null;
       
+      // The RI will fail with a ClassCastException in such a situation.
+      // This code tries to be more helpful.
       if (c instanceof AbstractButton)
         bmodel = ((AbstractButton) c).getModel();
+      else
+        throw new IllegalStateException("A ButtonBorder is supposed to work "
+                                        + "only with AbstractButton and"
+                                        + "subclasses.");
 
       Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
       Color shadow = MetalLookAndFeel.getControlShadow();
@@ -267,8 +288,10 @@ public class MetalBorders
               g.drawRect(x, y, w - 1, h - 1);
               g.drawRect(x + 1, y + 1, w - 3, h - 3);
             }
-          else if (bmodel.isRollover())
+          else if (bmodel.isRollover() && !(c.getParent() instanceof JToolBar))
             {
+              // Paint a bigger border when the mouse is over the button but
+              // only if it is *not* part of a JToolBar.
               g.setColor(shadow);
               g.drawRect(x, y, w - 1, h - 1);
               g.drawRect(x + 2, y + 2, w - 5, h - 5);
@@ -568,12 +591,12 @@ public class MetalBorders
     {
       boolean enabledTextBorder;
       if (c instanceof JTextComponent)
-	{
-	  JTextComponent tc = (JTextComponent) c;
-	  enabledTextBorder = tc.isEnabled() && tc.isEditable();
-	}
+        {
+          JTextComponent tc = (JTextComponent) c;
+          enabledTextBorder = tc.isEnabled() && tc.isEditable();
+        }
       else
-	enabledTextBorder = false;
+        enabledTextBorder = false;
 
       if (enabledTextBorder)
         super.paintBorder(c, g, x, y, w, h);
@@ -829,35 +852,36 @@ public class MetalBorders
     {
       Color dark = MetalLookAndFeel.getPrimaryControlDarkShadow();
       Color light = MetalLookAndFeel.getPrimaryControlHighlight();
-      if (c instanceof JMenu) {
-        JMenu menu = (JMenu) c;
-        if (menu.isSelected())
+      if (c instanceof JMenu) 
         {
-          g.setColor(dark);
-          g.drawLine(x, y, x, y + h);
-          g.drawLine(x, y, x + w, y);
-          g.drawLine(x + w - 2, y + 1, x + w - 2, y + h);
-          g.setColor(light);
-          g.drawLine(x + w - 1, y + 1, x + w - 1, y + h);
+          JMenu menu = (JMenu) c;
+          if (menu.isSelected())
+            {
+              g.setColor(dark);
+              g.drawLine(x, y, x, y + h);
+              g.drawLine(x, y, x + w, y);
+              g.drawLine(x + w - 2, y + 1, x + w - 2, y + h);
+              g.setColor(light);
+              g.drawLine(x + w - 1, y + 1, x + w - 1, y + h);
+            }
         }
-      }
       else if (c instanceof JMenuItem)
-      {
-        JMenuItem item = (JMenuItem) c;
-        if (item.isArmed()) 
-          {
-            g.setColor(dark);
-            g.drawLine(x, y, x + w, y);
-            g.setColor(light);
-            g.drawLine(x, y + h - 1, x + w, y + h - 1);
-          }
-        else
-          {
-            // Normally we draw a light line on the left.
-            g.setColor(light);
-            g.drawLine(x, y, x, y + h);
-          }
-      }
+        {
+          JMenuItem item = (JMenuItem) c;
+          if (item.isArmed()) 
+            {
+              g.setColor(dark);
+              g.drawLine(x, y, x + w, y);
+              g.setColor(light);
+              g.drawLine(x, y + h - 1, x + w, y + h - 1);
+            }
+          else
+            {
+              // Normally we draw a light line on the left.
+              g.setColor(light);
+              g.drawLine(x, y, x, y + h);
+            }
+        }
     }
     
     /**
@@ -1469,8 +1493,8 @@ public class MetalBorders
       {
         Border outer = new ButtonBorder();
         Border inner = getMarginBorder();
-        buttonBorder = new BorderUIResource.CompoundBorderUIResource
-            (outer, inner);
+        buttonBorder = new BorderUIResource.CompoundBorderUIResource(outer, 
+            inner);
       }
     return buttonBorder;
   }
@@ -1488,8 +1512,8 @@ public class MetalBorders
       {
         Border outer = new ToggleButtonBorder();
         Border inner = getMarginBorder();
-        toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource
-            (outer, inner);
+        toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource(
+            outer, inner);
       }
     return toggleButtonBorder;
   }
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java
index 83cd33662156..d6cc1bc07f96 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java
@@ -39,6 +39,7 @@ exception statement from your version. */
 package javax.swing.plaf.metal;
 
 import java.awt.Color;
+import java.awt.Container;
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics;
@@ -48,7 +49,9 @@ import javax.swing.AbstractButton;
 import javax.swing.ButtonModel;
 import javax.swing.JButton;
 import javax.swing.JComponent;
+import javax.swing.JToolBar;
 import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.UIResource;
@@ -121,7 +124,8 @@ public class MetalButtonUI
    * 
    * @return A new instance of <code>MetalButtonUI</code>.
    */
-  public static ComponentUI createUI(JComponent c) {
+  public static ComponentUI createUI(JComponent c) 
+  {
     return new MetalButtonUI();
   }
 
@@ -187,7 +191,8 @@ public class MetalButtonUI
    * @param iconRect  the icon bounds.
    */
   protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
-          Rectangle textRect, Rectangle iconRect) {
+          Rectangle textRect, Rectangle iconRect) 
+  {
     if (b.isEnabled() && b.hasFocus() && b.isFocusPainted())
     {
       Color savedColor = g.getColor();
@@ -235,19 +240,63 @@ public class MetalButtonUI
   public void update(Graphics g, JComponent c)
   {
     AbstractButton b = (AbstractButton) c;
-    ButtonModel m = b.getModel();
     if (b.isContentAreaFilled()
         && (UIManager.get(getPropertyPrefix() + "gradient") != null)
-        && ! m.isPressed() && ! m.isArmed()
         && b.isEnabled()
         && (b.getBackground() instanceof UIResource))
+      updateWidthGradient(g, b, b.getParent());
+    else
+      super.update(g, c);
+  }
+  
+  private void updateWidthGradient(Graphics g, AbstractButton b, Container parent)
+  {
+    ButtonModel m = b.getModel();
+    String gradientPropertyName = getPropertyPrefix() + "gradient";
+
+    // Gradient painting behavior depends on whether the button is part of a
+    // JToolBar.
+    if (parent instanceof JToolBar)
+      {
+        if (! m.isPressed() && ! m.isArmed())
+          {
+            if (m.isRollover())
+              {
+                // Paint the gradient when the mouse cursor hovers over the
+                // button but is not pressed down.
+                MetalUtils.paintGradient(g, 0, 0, b.getWidth(), b.getHeight(),
+                                         SwingConstants.VERTICAL,
+                                         gradientPropertyName);
+              }
+            else
+              {
+                // If mouse does not hover over the button let the JToolBar
+                // paint itself at the location where the button is (the button
+                // is transparent).
+                
+                // There where cases where the button was not repainted and
+                // therefore showed its old state. With this statement it does
+                // not happen.
+                b.repaint();
+                
+                Rectangle area = new Rectangle();
+                SwingUtilities.calculateInnerArea(b, area);
+                SwingUtilities.convertRectangle(b, area, b.getParent());
+                b.getParent().repaint(area.x, area.y, area.width, area.height);
+              }
+          }
+        
+      }
+    else if (! m.isPressed() && ! m.isArmed())
       {
-        MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+        // When the button is not part of a JToolBar just paint itself with a
+        // gradient and everything is fine.
+        MetalUtils.paintGradient(g, 0, 0, b.getWidth(), b.getHeight(),
                                  SwingConstants.VERTICAL,
-                                 getPropertyPrefix() + "gradient");
-        paint(g, c);
+                                 gradientPropertyName);
       }
-    else
-      super.update(g, c);
+    
+    paint(g, b);
   }
+  
 }
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxUI.java
index b4f6f0a56cdc..c7941642e678 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxUI.java
@@ -52,7 +52,7 @@ public class MetalCheckBoxUI
 
   // FIXME: maybe replace by a Map of instances when this becomes stateful
   /** The shared UI instance for JCheckBoxes. */
-  private static MetalCheckBoxUI instance = null;
+  private static MetalCheckBoxUI instance;
 
   /**
    * Constructs a new instance of MetalCheckBoxUI.
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java
index 3787a98c3a9e..6a528de2b6bc 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxButton.java
@@ -256,9 +256,8 @@ public class MetalComboBoxButton
           {
             ListCellRenderer renderer = comboBox.getRenderer();
             boolean pressed = this.getModel().isPressed();
-            Component comp= renderer.getListCellRendererComponent(listBox,
-                                                    comboBox.getSelectedItem(),
-                                                    -1, false, false);
+            Component comp = renderer.getListCellRendererComponent(listBox,
+                comboBox.getSelectedItem(), -1, false, false);
             comp.setFont(rendererPane.getFont());
             if (model.isArmed() && model.isPressed())
               {
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxIcon.java b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxIcon.java
index f21c5af61367..944ce394405f 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxIcon.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalComboBoxIcon.java
@@ -48,7 +48,8 @@ import javax.swing.Icon;
 /**
  * An icon used by the {@link MetalComboBoxUI} class.
  */
-public class MetalComboBoxIcon implements Icon, Serializable {
+public class MetalComboBoxIcon implements Icon, Serializable 
+{
   
   /**
    * Creates a new icon.
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java
index cb94c87b8468..1219ad9fd111 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalFileChooserUI.java
@@ -52,12 +52,13 @@ import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
-import java.text.NumberFormat;
-
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-
 import java.io.File;
+import java.sql.Date;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.util.List;
 
 import javax.swing.AbstractAction;
 import javax.swing.AbstractListModel;
@@ -79,7 +80,6 @@ import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.JToggleButton;
-import javax.swing.JViewport;
 import javax.swing.ListModel;
 import javax.swing.ListSelectionModel;
 import javax.swing.SwingUtilities;
@@ -94,12 +94,6 @@ import javax.swing.plaf.basic.BasicFileChooserUI;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
-import java.sql.Date;
-
-import java.text.DateFormat;
-
-import java.util.List;
-
 
 /**
  * A UI delegate for the {@link JFileChooser} component.  This class is only
@@ -350,7 +344,7 @@ public class MetalFileChooserUI
           setDirectorySelected(false);
           File currentDirectory = filechooser.getCurrentDirectory();
           setDirectory(currentDirectory);
-          boolean hasParent = (currentDirectory.getParentFile() != null);
+          boolean hasParent = currentDirectory.getParentFile() != null;
           getChangeToParentDirectoryAction().setEnabled(hasParent);
         }
       
@@ -648,15 +642,15 @@ public class MetalFileChooserUI
       FileView v = getFileView(getFileChooser());
       File f = (File) value;
       if (f != null)
-	{
-	  setText(v.getName(f));
-	  setIcon(v.getIcon(f));
-	}
+        {
+          setText(v.getName(f));
+          setIcon(v.getIcon(f));
+        }
       else
-	{
-	  setText("");
-	  setIcon(null);
-	}
+        {
+          setText("");
+          setIcon(null);
+        }
       setOpaque(true);
       if (isSelected)
         {
@@ -962,10 +956,9 @@ public class MetalFileChooserUI
         {
           String text = editField.getText();
           if (text != null && text != "" && !text.equals(fc.getName(editFile)))
-              if (editFile.renameTo
-                  (fc.getFileSystemView().createFileObject
-                   (fc.getCurrentDirectory(), text)))
-                  rescanCurrentDirectory(fc);
+              if (editFile.renameTo(fc.getFileSystemView().createFileObject(
+                  fc.getCurrentDirectory(), text)))
+                rescanCurrentDirectory(fc);
           list.remove(editField);
         }
       startEditing = false;
@@ -1018,7 +1011,7 @@ public class MetalFileChooserUI
     JFileChooser fc;
 
     /** The last selected file. */
-    Object lastSelected = null;
+    Object lastSelected;
     
     /** 
      * Stores the current file that is being edited.
@@ -1032,10 +1025,8 @@ public class MetalFileChooserUI
     /**
      * Creates a new listener.
      * 
-     * @param table
-     *          the directory/file table
-     * @param fc
-     *          the JFileChooser
+     * @param table the directory/file table
+     * @param fc the JFileChooser
      */
     public TableClickListener(JTable table, JFileChooser fc)
     {
@@ -1051,8 +1042,7 @@ public class MetalFileChooserUI
     /**
      * Receives notification of a mouse click event.
      * 
-     * @param e
-     *          the event.
+     * @param e the event.
      */
     public void mouseClicked(MouseEvent e)
     {
@@ -1156,10 +1146,9 @@ public class MetalFileChooserUI
         {
           String text = editField.getText();
           if (text != null && text != "" && !text.equals(fc.getName(editFile)))
-              if (editFile.renameTo
-                  (fc.getFileSystemView().createFileObject
-                   (fc.getCurrentDirectory(), text)))
-                  rescanCurrentDirectory(fc);
+              if (editFile.renameTo(fc.getFileSystemView().createFileObject(
+                  fc.getCurrentDirectory(), text)))
+                rescanCurrentDirectory(fc);
           table.remove(editField);
         }
       startEditing = false;
@@ -1636,8 +1625,7 @@ public class MetalFileChooserUI
   /**
    * Formats bytes into the appropriate size.
    * 
-   * @param bytes -
-   *          the number of bytes to convert
+   * @param bytes the number of bytes to convert
    * @return a string representation of the size
    */
   private String formatSize(long bytes)
@@ -1838,7 +1826,7 @@ public class MetalFileChooserUI
   /**
    * Updates the current directory.
    * 
-   * @param the file chooser to update.
+   * @param fc  the file chooser to update.
    */
   public void rescanCurrentDirectory(JFileChooser fc)
   {
@@ -1966,7 +1954,8 @@ public class MetalFileChooserUI
      * 
      * @param component  the component.
      */
-    public void removeLayoutComponent(Component component) {
+    public void removeLayoutComponent(Component component) 
+    {
       // do nothing
     }
   }
@@ -2072,7 +2061,8 @@ public class MetalFileChooserUI
      * 
      * @param component  the component.
      */
-    public void removeLayoutComponent(Component component) {
+    public void removeLayoutComponent(Component component) 
+    {
       // do nothing
     }
   }
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
index d24a0526232a..4e4c863c9797 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
@@ -617,7 +617,8 @@ public class MetalIconFactory implements Serializable
      * 
      * @return The width of the icon.
      */
-    public int getIconWidth() {
+    public int getIconWidth() 
+    {
       return 16;
     }
     
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java b/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
index f74828e566e5..dd0c486396be 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
@@ -95,7 +95,7 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
       String propName = e.getPropertyName();
       if (e.getPropertyName().equals(JInternalFrame.FRAME_ICON_PROPERTY))
         {
-	  title.setIcon( frame.getFrameIcon() );
+          title.setIcon(frame.getFrameIcon());
         }
       else if (propName.equals("JInternalFrame.isPalette"))
         {
@@ -387,8 +387,8 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
       paintPalette(g);
     else
       {
-	paintTitleBackground(g);
-	paintChildren(g);
+        paintTitleBackground(g);
+        paintChildren(g);
         Dimension d = getSize();
         if (frame.isSelected())
           g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
@@ -421,7 +421,8 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
           endX = Math.max(closeButton.getX(), endX);
         endX -= 7;
         if (endX > startX)
-          MetalUtils.fillMetalPattern(this, g, startX, 3, endX - startX, getHeight() - 6, Color.white, Color.gray);
+          MetalUtils.fillMetalPattern(this, g, startX, 3, endX - startX, 
+              getHeight() - 6, Color.white, Color.gray);
       }
     g.setColor(savedColor);
   }
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java
index 6be573f4bace..abe6a2817e16 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameUI.java
@@ -41,8 +41,10 @@ package javax.swing.plaf.metal;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
+import javax.swing.ActionMap;
 import javax.swing.JComponent;
 import javax.swing.JInternalFrame;
+import javax.swing.SwingUtilities;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicInternalFrameUI;
 
@@ -162,4 +164,20 @@ public class MetalInternalFrameUI
     frame.removePropertyChangeListener(IS_PALETTE, paletteListener);
     paletteListener = null;
   }
+
+  /**
+   * Installs keyboard actions. This is overridden to remove the
+   * <code>showSystemMenu</code> Action that is installed by the
+   * <code>BasicInternalFrameUI</code>, since Metal JInternalFrames don't have
+   * a system menu.
+   */
+  protected void installKeyboardActions()
+  {
+    super.installKeyboardActions();
+    ActionMap am = SwingUtilities.getUIActionMap(frame);
+    if (am != null)
+      {
+        am.remove("showSystemMenu");
+      }
+  }
 }
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
index 7a973d46eeff..09eafd40fe95 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -67,7 +67,7 @@ import javax.swing.plaf.basic.BasicLookAndFeel;
  * }</pre>
  */
 public class MetalLookAndFeel extends BasicLookAndFeel
-{	   
+{          
   private static final long serialVersionUID = 6680646159193457980L;
   
   /** The current theme. */
@@ -888,11 +888,9 @@ public class MetalLookAndFeel extends BasicLookAndFeel
       "CheckBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
       "CheckBox.foreground", getControlTextColor(),
       "CheckBox.icon",
-      new UIDefaults.ProxyLazyValue
-          ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
+      new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
       "CheckBox.checkIcon",
-      new UIDefaults.ProxyLazyValue
-      ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
+      new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
       "Checkbox.select", getControlShadow(),
 
       "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 10),
@@ -964,7 +962,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
       "FileChooser.detailsViewIcon", 
           MetalIconFactory.getFileChooserDetailViewIcon(),
       "FileChooser.fileNameLabelMnemonic", new Integer(78),
-      "FileChooser.filesOfTypeLabelMnemonic",new Integer(84),
+      "FileChooser.filesOfTypeLabelMnemonic", new Integer(84),
       "FileChooser.lookInLabelMnemonic", new Integer(73),
       "FileView.computerIcon", MetalIconFactory.getTreeComputerIcon(),
       "FileView.directoryIcon", MetalIconFactory.getTreeFolderIcon(),
@@ -1273,6 +1271,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
       "ToolBar.light", getControlHighlight(),
       "ToolBar.shadow", getControlShadow(),
       "ToolBar.border", new MetalBorders.ToolBarBorder(),
+      "ToolBar.rolloverBorder", MetalBorders.getToolbarButtonBorder(),
+      "ToolBar.nonrolloverBorder", MetalBorders.getToolbarButtonBorder(),
 
       "ToolTip.background", getPrimaryControl(),
       "ToolTip.backgroundInactive", getControl(),
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
index 44a2d3bcd6ab..7c580f90f394 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
@@ -51,7 +51,7 @@ public class MetalPopupMenuSeparatorUI
 
   // FIXME: maybe replace by a Map of instances when this becomes stateful
   /** The shared UI instance for MetalPopupMenuSeparatorUIs */
-  private static MetalPopupMenuSeparatorUI instance = null;
+  private static MetalPopupMenuSeparatorUI instance;
 
   /**
    * Constructs a new instance of <code>MetalPopupMenuSeparatorUI</code>.
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
index 9fb960f68b98..046e4942ee15 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
@@ -1,5 +1,5 @@
 /* MetalRadioButtonUI.java
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -95,9 +95,10 @@ public class MetalRadioButtonUI
   public void installDefaults(AbstractButton b)
   {
     super.installDefaults(b);
-    disabledTextColor = UIManager.getColor("RadioButton.disabledText");
-    focusColor = UIManager.getColor("RadioButton.focus");
-    selectColor = UIManager.getColor("RadioButton.select");
+    String prefix = getPropertyPrefix();
+    disabledTextColor = UIManager.getColor(prefix + "disabledText");
+    focusColor = UIManager.getColor(prefix + "focus");
+    selectColor = UIManager.getColor(prefix + "select");
   }
   
   /**
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java
index 6cabc7e86913..eaee5bf929e2 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalRootPaneUI.java
@@ -958,7 +958,7 @@ public class MetalRootPaneUI
   /**
    * The shared UI instance for MetalRootPaneUIs.
    */
-  private static MetalRootPaneUI instance = null;
+  private static MetalRootPaneUI instance;
 
   /**
    * Constructs a shared instance of <code>MetalRootPaneUI</code>.
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
index c7dfd11e48c3..75f2750ae9c7 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
@@ -90,14 +90,14 @@ public class MetalScrollBarUI extends BasicScrollBarUI
       if (e.getPropertyName().equals(FREE_STANDING_PROP))
         {
           Boolean prop = (Boolean) e.getNewValue();
-          isFreeStanding = (prop == null ? true : prop.booleanValue());
-	  if (increaseButton != null)
-	    increaseButton.setFreeStanding(isFreeStanding);
-	  if (decreaseButton != null)
-	    decreaseButton.setFreeStanding(isFreeStanding);
+          isFreeStanding = prop == null ? true : prop.booleanValue();
+          if (increaseButton != null)
+            increaseButton.setFreeStanding(isFreeStanding);
+          if (decreaseButton != null)
+            decreaseButton.setFreeStanding(isFreeStanding);
         }
       else
-	super.propertyChange(e);
+        super.propertyChange(e);
     }
   }
   
@@ -167,7 +167,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
     // createDecreaseButton() are called (unless there is somewhere earlier
     // that we can do this).
     Boolean prop = (Boolean) scrollbar.getClientProperty(FREE_STANDING_PROP);
-    isFreeStanding = (prop == null ? true : prop.booleanValue());
+    isFreeStanding = prop == null ? true : prop.booleanValue();
     scrollBarShadowColor = UIManager.getColor("ScrollBar.shadow");
     super.installDefaults();
   }
@@ -401,7 +401,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
       {
         g.drawLine(x, y, x + w - 1, y);
         g.drawLine(x, y, x, y + h - 1);
-        g.drawLine(x + w - 1, y, x + w - 1, y + h -1);
+        g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
       }
     
     // then the highlight
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java
index 1d48e9be2b0d..6d7818f8b223 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalSeparatorUI.java
@@ -58,7 +58,7 @@ public class MetalSeparatorUI
 
   // FIXME: maybe replace by a Map of instances when this becomes stateful
   /** The shared UI instance for MetalSeparatorUIs */
-  private static MetalSeparatorUI instance = null;
+  private static MetalSeparatorUI instance;
 
   /**
    * Constructs a new instance of <code>MetalSeparatorUI</code>.
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java
index f97717f31e08..0f824418c5df 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalSliderUI.java
@@ -192,10 +192,13 @@ public class MetalSliderUI extends BasicSliderUI
    */
   public void paintThumb(Graphics g) 
   {
+    Color save = g.getColor();
+    g.setColor(thumbColor);
     if (slider.getOrientation() == JSlider.HORIZONTAL)
       horizThumbIcon.paintIcon(slider, g, thumbRect.x, thumbRect.y);
     else
       vertThumbIcon.paintIcon(slider, g, thumbRect.x, thumbRect.y);
+    g.setColor(save);
   }
   
   /**
@@ -229,9 +232,9 @@ public class MetalSliderUI extends BasicSliderUI
             if (slider.isEnabled())
               {
                 int xPos = xPositionForValue(slider.getValue());
-                int x = (slider.getInverted() ? xPos : trackRect.x);
-                int w = (slider.getInverted() ? trackX + trackW - xPos 
-                                              : xPos - trackRect.x);
+                int x = slider.getInverted() ? xPos : trackRect.x;
+                int w = slider.getInverted() ? trackX + trackW - xPos 
+                                             : xPos - trackRect.x;
                 g.setColor(MetalLookAndFeel.getWhite());
                 g.drawLine(x + 1, trackY + 1, x + w - 3, trackY + 1);
                 g.setColor(UIManager.getColor("Slider.altTrackColor"));
@@ -245,9 +248,9 @@ public class MetalSliderUI extends BasicSliderUI
         else if (filledSlider) 
           {
             int xPos = xPositionForValue(slider.getValue());
-            int x = (slider.getInverted() ? xPos : trackRect.x);
-            int w = (slider.getInverted() ? trackX + trackW - xPos 
-                                          : xPos - trackRect.x);
+            int x = slider.getInverted() ? xPos : trackRect.x;
+            int w = slider.getInverted() ? trackX + trackW - xPos 
+                                         : xPos - trackRect.x;
             g.setColor(MetalLookAndFeel.getControlShadow());
             g.fillRect(x + 1, trackY + 1, w - 3, getTrackWidth() - 3);
             if (slider.isEnabled())
@@ -280,9 +283,9 @@ public class MetalSliderUI extends BasicSliderUI
             if (slider.isEnabled())
               {
                 int yPos = yPositionForValue(slider.getValue());
-                int y = (slider.getInverted() ? trackY : yPos);
-                int h = (slider.getInverted() ? yPos - trackY 
-                        : trackY + trackH - yPos);
+                int y = slider.getInverted() ? trackY : yPos;
+                int h = slider.getInverted() ? yPos - trackY 
+                        : trackY + trackH - yPos;
                 
                 g.setColor(MetalLookAndFeel.getWhite());
                 g.drawLine(trackX + 1, y + 1, trackX + 1, y + h - 3);
@@ -297,9 +300,9 @@ public class MetalSliderUI extends BasicSliderUI
         else if (filledSlider) 
           {
           int yPos = yPositionForValue(slider.getValue());
-          int y = (slider.getInverted() ? trackY : yPos);
-          int h = (slider.getInverted() ? yPos - trackY 
-                  : trackY + trackH - yPos);
+          int y = slider.getInverted() ? trackY : yPos;
+          int h = slider.getInverted() ? yPos - trackY 
+                  : trackY + trackH - yPos;
           g.setColor(MetalLookAndFeel.getControlShadow());
           g.fillRect(trackX + 1, y + 1, getTrackWidth() - 3, h - 3);
           if (slider.isEnabled())
@@ -323,7 +326,8 @@ public class MetalSliderUI extends BasicSliderUI
    */
   public void paintFocus(Graphics g)
   {
-    // do nothing as focus is shown by different color on thumb control
+    thumbColor = getFocusColor();
+    paintThumb(g);
   }
   
   /**
@@ -368,8 +372,8 @@ public class MetalSliderUI extends BasicSliderUI
    */
   protected int getTrackLength()
   {
-    return (slider.getOrientation() == JSlider.HORIZONTAL 
-            ? tickRect.width : tickRect.height);
+    return slider.getOrientation() == JSlider.HORIZONTAL 
+           ? tickRect.width : tickRect.height;
   }
   
   /**
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java b/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java
index 9c592bd5116d..6081c355c376 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java
@@ -1,5 +1,5 @@
 /* MetalSplitPaneDivider.java
-Copyright (C) 2005 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -42,21 +42,20 @@ import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Graphics;
-import java.awt.Insets;
 import java.awt.LayoutManager;
 import java.awt.Point;
 
 import javax.swing.JSplitPane;
 import javax.swing.SwingConstants;
+import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.plaf.basic.BasicArrowButton;
 import javax.swing.plaf.basic.BasicSplitPaneDivider;
 
 /**
- * The divider that is used by the MetalSplitPaneUI.
+ * The divider that is used by the {@link MetalSplitPaneUI}.
  *
  * @author Roman Kennke (roman@kennke.org)
- *
  */
 class MetalSplitPaneDivider extends BasicSplitPaneDivider
 {
@@ -73,7 +72,7 @@ class MetalSplitPaneDivider extends BasicSplitPaneDivider
   int orientation;
   
   /**
-   * Creates a new instance of MetalSplitPaneDivider.
+   * Creates a new instance of <code>MetalSplitPaneDivider</code>.
    *
    * @param ui the <code>MetalSplitPaneUI</code> that uses this divider
    */
@@ -96,6 +95,12 @@ class MetalSplitPaneDivider extends BasicSplitPaneDivider
   {
     Dimension s = getSize();
 
+    if (splitPane.hasFocus())
+      {
+        g.setColor(UIManager.getColor("SplitPane.dividerFocusColor"));
+        g.fillRect(0, 0, s.width, s.height);
+      }
+    
     // Paint border if one exists.
     Border border = getBorder();
     if (border != null)
@@ -159,8 +164,8 @@ class MetalSplitPaneDivider extends BasicSplitPaneDivider
               if ((c1 instanceof BasicArrowButton)
                   && (c2 instanceof BasicArrowButton))
                 {
-                  lb = ((BasicArrowButton) c1);
-                  rb = ((BasicArrowButton) c2);
+                  lb = (BasicArrowButton) c1;
+                  rb = (BasicArrowButton) c2;
                 }
             }
           if (rb != null && lb != null)
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java
index 39dec3d663f7..c49abe832e44 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalTabbedPaneUI.java
@@ -607,11 +607,11 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
       }
     else
       {
-        if (isOcean && tabIndex == tabPane.getSelectedIndex()+ 1)
+        if (isOcean && tabIndex == tabPane.getSelectedIndex() + 1)
           {
             g.setColor(oceanSelectedBorder);
           }
-        if (tabIndex != tabRuns[runCount- 1])
+        if (tabIndex != tabRuns[runCount - 1])
           {
             g.drawLine(0, 0, 0, bottom);
           }
@@ -856,7 +856,7 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI
     // run directly above the content or the selected tab is not visible,
     // then we draw an unbroken line.
     if (tabPlacement != TOP || selectedIndex < 0
-        || rect.y  + rect.height + 1 < y || rect.x < x ||rect.x > x + w)
+        || rect.y  + rect.height + 1 < y || rect.x < x || rect.x > x + w)
       {
         g.drawLine(x, y, x + w - 2, y);
         if (isOcean && tabPlacement == TOP)
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
index f183ed5a1496..d1040347fc61 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
@@ -75,7 +75,7 @@ public class MetalToolTipUI
   public static final int padSpaceBetweenStrings = 12;
 
   /** The shared UI instance. */
-  private static MetalToolTipUI instance = null;
+  private static MetalToolTipUI instance;
   
   /** A flag controlling the visibility of the accelerator (if there is one). */
   private boolean isAcceleratorHidden;
@@ -256,8 +256,8 @@ public class MetalToolTipUI
         g.setColor(acceleratorForeground);
         fm = t.getFontMetrics(acceleratorFont);
         int width = fm.stringWidth(acceleratorString);
-        g.drawString(acceleratorString, vr.x + vr.width - width - padSpaceBetweenStrings/2, 
-                vr.y + vr.height - fm.getDescent());
+        g.drawString(acceleratorString, vr.x + vr.width - width 
+            - padSpaceBetweenStrings / 2, vr.y + vr.height - fm.getDescent());
       }
 
     g.setColor(saved);   
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
index 03617aa40998..72cbb34a6dc4 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
@@ -104,7 +104,7 @@ class MetalUtils
             else
               g.setColor(dark);
 
-            for (int mX = x + (xOff); mX < (x + w); mX += 4)
+            for (int mX = x + xOff; mX < (x + w); mX += 4)
               {
                 g.drawLine(mX, mY, mX, mY);
               }
diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java
index 05279d7d654a..33b432152bfa 100644
--- a/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java
+++ b/libjava/classpath/javax/swing/plaf/multi/MultiComboBoxUI.java
@@ -357,7 +357,8 @@ public class MultiComboBoxUI extends ComboBoxUI
    * @param c  the component.
    * @param visible  the visible state.
    */
-  public void setPopupVisible(JComboBox c, boolean visible) {
+  public void setPopupVisible(JComboBox c, boolean visible) 
+  {
     Iterator iterator = uis.iterator();
     while (iterator.hasNext())
     {
@@ -376,7 +377,8 @@ public class MultiComboBoxUI extends ComboBoxUI
    * 
    * @return The result for the UI delegate from the primary look and feel.  
    */
-  public boolean isPopupVisible(JComboBox c) {
+  public boolean isPopupVisible(JComboBox c) 
+  {
     boolean result = false;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -406,7 +408,8 @@ public class MultiComboBoxUI extends ComboBoxUI
    *         UI delegate in the primary look and feel, and <code>false</code> 
    *         otherwise. 
    */
-  public boolean isFocusTraversable(JComboBox c) {
+  public boolean isFocusTraversable(JComboBox c) 
+  {
     boolean result = false;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java
index 6f88260101c3..719f04374973 100644
--- a/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java
+++ b/libjava/classpath/javax/swing/plaf/multi/MultiFileChooserUI.java
@@ -364,7 +364,8 @@ public class MultiFileChooserUI extends FileChooserUI
    * @return The filter returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public FileFilter getAcceptAllFileFilter(JFileChooser chooser) {
+  public FileFilter getAcceptAllFileFilter(JFileChooser chooser) 
+  {
     FileFilter result = null;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -393,7 +394,8 @@ public class MultiFileChooserUI extends FileChooserUI
    * @return The view returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public FileView getFileView(JFileChooser chooser) {
+  public FileView getFileView(JFileChooser chooser) 
+  {
     FileView result = null;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -422,7 +424,8 @@ public class MultiFileChooserUI extends FileChooserUI
    * @return The text returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public String getApproveButtonText(JFileChooser chooser) {
+  public String getApproveButtonText(JFileChooser chooser) 
+  {
     String result = null;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -451,7 +454,8 @@ public class MultiFileChooserUI extends FileChooserUI
    * @return The title returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public String getDialogTitle(JFileChooser chooser) {
+  public String getDialogTitle(JFileChooser chooser) 
+  {
     String result = null;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -476,7 +480,8 @@ public class MultiFileChooserUI extends FileChooserUI
    * 
    * @param chooser  the file chooser.
    */
-  public void rescanCurrentDirectory(JFileChooser chooser) {
+  public void rescanCurrentDirectory(JFileChooser chooser) 
+  {
     Iterator iterator = uis.iterator();
     while (iterator.hasNext())
     {
@@ -493,7 +498,8 @@ public class MultiFileChooserUI extends FileChooserUI
    * @param chooser  the file chooser.
    * @param file  the file.
    */
-  public void ensureFileIsVisible(JFileChooser chooser, File file) {
+  public void ensureFileIsVisible(JFileChooser chooser, File file) 
+  {
     Iterator iterator = uis.iterator();
     while (iterator.hasNext())
     {
diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java
index 7350b4541159..78c22419f342 100644
--- a/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java
+++ b/libjava/classpath/javax/swing/plaf/multi/MultiListUI.java
@@ -364,7 +364,8 @@ public class MultiListUI extends ListUI
    * @return The index returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public int locationToIndex(JList list, Point location) {
+  public int locationToIndex(JList list, Point location) 
+  {
     int result = 0;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -394,7 +395,8 @@ public class MultiListUI extends ListUI
    * @return The location returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public Point indexToLocation(JList list, int index) {
+  public Point indexToLocation(JList list, int index) 
+  {
     Point result = null;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -425,7 +427,8 @@ public class MultiListUI extends ListUI
    * @return The bounds returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public Rectangle getCellBounds(JList list, int index1, int index2) {
+  public Rectangle getCellBounds(JList list, int index1, int index2) 
+  {
     Rectangle result = null;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java b/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java
index 2bd358dd01e5..12351655a045 100644
--- a/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java
+++ b/libjava/classpath/javax/swing/plaf/multi/MultiLookAndFeel.java
@@ -49,7 +49,8 @@ import javax.swing.plaf.ComponentUI;
  * A look and feel that provides the ability to use auxiliary look and feels
  * in addition to the primary look and feel.
  */
-public class MultiLookAndFeel extends LookAndFeel {
+public class MultiLookAndFeel extends LookAndFeel 
+{
 
   /**
    * Creates a new instance of the look and feel.
diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java
index c5cb913a0680..8d6f3861cff7 100644
--- a/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/multi/MultiOptionPaneUI.java
@@ -356,7 +356,8 @@ public class MultiOptionPaneUI extends OptionPaneUI
    * 
    * @param pane  the option pane.
    */
-  public void selectInitialValue(JOptionPane pane) {
+  public void selectInitialValue(JOptionPane pane) 
+  {
     Iterator iterator = uis.iterator();
     while (iterator.hasNext())
     {
@@ -375,7 +376,8 @@ public class MultiOptionPaneUI extends OptionPaneUI
    * 
    * @return The result for the UI delegate from the primary look and feel. 
    */
-  public boolean containsCustomComponents(JOptionPane pane) {
+  public boolean containsCustomComponents(JOptionPane pane) 
+  {
     boolean result = false;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java
index f481f8109d9f..70ea4f13be11 100644
--- a/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/multi/MultiSplitPaneUI.java
@@ -356,7 +356,8 @@ public class MultiSplitPaneUI extends SplitPaneUI
    * 
    * @param pane  the component.
    */
-  public void resetToPreferredSizes(JSplitPane pane) {
+  public void resetToPreferredSizes(JSplitPane pane) 
+  {
     Iterator iterator = uis.iterator();
     while (iterator.hasNext())
     {
@@ -372,7 +373,8 @@ public class MultiSplitPaneUI extends SplitPaneUI
    * @param pane  the component.
    * @param location  the location.
    */
-  public void setDividerLocation(JSplitPane pane, int location) {
+  public void setDividerLocation(JSplitPane pane, int location) 
+  {
     Iterator iterator = uis.iterator();
     while (iterator.hasNext())
     {
@@ -392,7 +394,8 @@ public class MultiSplitPaneUI extends SplitPaneUI
    * @return The location returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public int getDividerLocation(JSplitPane pane) {
+  public int getDividerLocation(JSplitPane pane) 
+  {
     int result = 0;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -421,7 +424,8 @@ public class MultiSplitPaneUI extends SplitPaneUI
    * @return The location returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public int getMinimumDividerLocation(JSplitPane pane) {
+  public int getMinimumDividerLocation(JSplitPane pane) 
+  {
     int result = 0;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -450,7 +454,8 @@ public class MultiSplitPaneUI extends SplitPaneUI
    * @return The location returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public int getMaximumDividerLocation(JSplitPane pane) {
+  public int getMaximumDividerLocation(JSplitPane pane) 
+  {
     int result = 0;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -476,7 +481,8 @@ public class MultiSplitPaneUI extends SplitPaneUI
    * @param pane  the component.
    * @param g  the graphics device.
    */
-  public void finishedPaintingChildren(JSplitPane pane, Graphics g) {
+  public void finishedPaintingChildren(JSplitPane pane, Graphics g) 
+  {
     Iterator iterator = uis.iterator();
     while (iterator.hasNext())
     {
diff --git a/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java
index 575de192a53c..2a2599bde1bb 100644
--- a/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/multi/MultiTabbedPaneUI.java
@@ -364,7 +364,8 @@ public class MultiTabbedPaneUI extends TabbedPaneUI
    * @return The tab index returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public int tabForCoordinate(JTabbedPane pane, int x, int y) {
+  public int tabForCoordinate(JTabbedPane pane, int x, int y) 
+  {
     int result = 0;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -394,7 +395,8 @@ public class MultiTabbedPaneUI extends TabbedPaneUI
    * @return The bounds returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public Rectangle getTabBounds(JTabbedPane pane, int index) {
+  public Rectangle getTabBounds(JTabbedPane pane, int index) 
+  {
     Rectangle result = null;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
@@ -423,7 +425,8 @@ public class MultiTabbedPaneUI extends TabbedPaneUI
    * @return The count returned by the UI delegate from the primary 
    *         look and feel. 
    */
-  public int getTabRunCount(JTabbedPane pane) {
+  public int getTabRunCount(JTabbedPane pane) 
+  {
     int result = 0;
     Iterator iterator = uis.iterator();
     // first UI delegate provides the return value
diff --git a/libjava/classpath/javax/swing/table/AbstractTableModel.java b/libjava/classpath/javax/swing/table/AbstractTableModel.java
index 3e9f6e9b382d..7914e0b3f46a 100644
--- a/libjava/classpath/javax/swing/table/AbstractTableModel.java
+++ b/libjava/classpath/javax/swing/table/AbstractTableModel.java
@@ -1,5 +1,5 @@
 /* AbstractTableModel.java --
-   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -83,7 +83,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable
     StringBuffer buffer = new StringBuffer();
     while (columnIndex >= 0)
       {
-        buffer.insert (0, (char) ('A' + columnIndex % 26));
+        buffer.insert(0, (char) ('A' + columnIndex % 26));
         columnIndex = columnIndex / 26 - 1;
       }
     return buffer.toString();
@@ -221,7 +221,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable
    * @param firstRow  the index of the first row.
    * @param lastRow  the index of the last row.
    */
-  public void fireTableRowsInserted (int firstRow, int lastRow)
+  public void fireTableRowsInserted(int firstRow, int lastRow)
   {
     fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
                                          TableModelEvent.ALL_COLUMNS,
@@ -235,7 +235,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable
    * @param firstRow  the index of the first row.
    * @param lastRow  the index of the last row.
    */
-  public void fireTableRowsUpdated (int firstRow, int lastRow)
+  public void fireTableRowsUpdated(int firstRow, int lastRow)
   {
     fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
                                          TableModelEvent.ALL_COLUMNS,
@@ -263,7 +263,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable
    * @param row  the row index.
    * @param column  the column index.
    */
-  public void fireTableCellUpdated (int row, int column)
+  public void fireTableCellUpdated(int row, int column)
   {
     fireTableChanged(new TableModelEvent(this, row, row, column));
   }
@@ -282,7 +282,7 @@ public abstract class AbstractTableModel implements TableModel, Serializable
     for (index = 0; index < list.length; index += 2)
       {
         listener = (TableModelListener) list [index + 1];
-        listener.tableChanged (event);
+        listener.tableChanged(event);
       }
   }
 
diff --git a/libjava/classpath/javax/swing/table/DefaultTableModel.java b/libjava/classpath/javax/swing/table/DefaultTableModel.java
index 09be2f75239f..79285903c00e 100644
--- a/libjava/classpath/javax/swing/table/DefaultTableModel.java
+++ b/libjava/classpath/javax/swing/table/DefaultTableModel.java
@@ -1,5 +1,5 @@
 /* DefaultTableModel.java --
-   Copyright (C) 2002, 2004, 2005,  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -249,7 +249,7 @@ public class DefaultTableModel extends AbstractTableModel
   public void setColumnIdentifiers(Vector columnIdentifiers) 
   {
     this.columnIdentifiers = columnIdentifiers;
-    setColumnCount((columnIdentifiers == null ? 0 : columnIdentifiers.size()));
+    setColumnCount(columnIdentifiers == null ? 0 : columnIdentifiers.size());
   }
   
   /**
@@ -289,13 +289,13 @@ public class DefaultTableModel extends AbstractTableModel
     if (rowCount < existingRowCount) 
     {
       dataVector.setSize(rowCount);
-      fireTableRowsDeleted(rowCount,existingRowCount-1);      
+      fireTableRowsDeleted(rowCount, existingRowCount - 1);      
     }
     else 
     {
       int rowsToAdd = rowCount - existingRowCount;
       addExtraRows(rowsToAdd, columnIdentifiers.size());
-      fireTableRowsInserted(existingRowCount,rowCount-1);
+      fireTableRowsInserted(existingRowCount, rowCount - 1);
     }
   }
 
@@ -353,7 +353,8 @@ public class DefaultTableModel extends AbstractTableModel
    * @param columnName the column name (<code>null</code> permitted).
    * @param columnData the column data.
    */
-  public void addColumn(Object columnName, Object[] columnData) {
+  public void addColumn(Object columnName, Object[] columnData) 
+  {
     if (columnData != null)
     {
       // check columnData array for cases where the number of items
@@ -384,7 +385,8 @@ public class DefaultTableModel extends AbstractTableModel
    * 
    * @param rowData the row data (<code>null</code> permitted).
    */
-  public void addRow(Vector rowData) {
+  public void addRow(Vector rowData) 
+  {
     int rowIndex = dataVector.size();
     dataVector.add(rowData);
     newRowsAdded(new TableModelEvent(
@@ -398,7 +400,8 @@ public class DefaultTableModel extends AbstractTableModel
    * 
    * @param rowData the row data (<code>null</code> permitted).
    */
-  public void addRow(Object[] rowData) {
+  public void addRow(Object[] rowData) 
+  {
     addRow(convertToVector(rowData));
   }
 
@@ -408,9 +411,10 @@ public class DefaultTableModel extends AbstractTableModel
    * @param row the row index.
    * @param rowData the row data.
    */
-  public void insertRow(int row, Vector rowData) {
+  public void insertRow(int row, Vector rowData) 
+  {
     dataVector.add(row, rowData);
-    fireTableRowsInserted(row,row);
+    fireTableRowsInserted(row, row);
   }
 
   /**
@@ -419,7 +423,8 @@ public class DefaultTableModel extends AbstractTableModel
    * @param row the row index.
    * @param rowData the row data.
    */
-  public void insertRow(int row, Object[] rowData) {
+  public void insertRow(int row, Object[] rowData) 
+  {
     insertRow(row, convertToVector(rowData));
   }
 
@@ -431,7 +436,8 @@ public class DefaultTableModel extends AbstractTableModel
    * @param endIndex the end row.
    * @param toIndex the row to move to.
    */
-  public void moveRow(int startIndex, int endIndex, int toIndex) {
+  public void moveRow(int startIndex, int endIndex, int toIndex) 
+  {
     Vector removed = new Vector();
     for (int i = endIndex; i >= startIndex; i--)
     {
@@ -452,9 +458,10 @@ public class DefaultTableModel extends AbstractTableModel
    * 
    * @param row the row index.
    */
-  public void removeRow(int row) {
+  public void removeRow(int row) 
+  {
     dataVector.remove(row);
-    fireTableRowsDeleted(row,row);
+    fireTableRowsDeleted(row, row);
   }
 
   /**
@@ -462,7 +469,8 @@ public class DefaultTableModel extends AbstractTableModel
    * 
    * @return The row count.
    */
-  public int getRowCount() {
+  public int getRowCount() 
+  {
     return dataVector.size();
   }
 
@@ -471,8 +479,9 @@ public class DefaultTableModel extends AbstractTableModel
    * 
    * @return The column count.
    */
-  public int getColumnCount() {
-    return (columnIdentifiers == null ? 0 : columnIdentifiers.size());
+  public int getColumnCount() 
+  {
+    return columnIdentifiers == null ? 0 : columnIdentifiers.size();
   }
 
   /**
@@ -485,7 +494,8 @@ public class DefaultTableModel extends AbstractTableModel
    * 
    * @return The column name.
    */
-  public String getColumnName(int column) {
+  public String getColumnName(int column)
+  {
     String result = "";
     if (columnIdentifiers == null) 
       result = super.getColumnName(column);
@@ -516,7 +526,8 @@ public class DefaultTableModel extends AbstractTableModel
    * 
    * @return <code>true</code> in all cases.
    */
-  public boolean isCellEditable(int row, int column) {
+  public boolean isCellEditable(int row, int column) 
+  {
     return true;
   }
 
@@ -529,7 +540,8 @@ public class DefaultTableModel extends AbstractTableModel
    * @return The value (<code>Object</code>, possibly <code>null</code>) at 
    *         the specified cell in the table.
    */
-  public Object getValueAt(int row, int column) {
+  public Object getValueAt(int row, int column) 
+  {
     return ((Vector) dataVector.get(row)).get(column);
   }
 
@@ -541,9 +553,10 @@ public class DefaultTableModel extends AbstractTableModel
    * @param row the row index.
    * @param column the column index.
    */
-  public void setValueAt(Object value, int row, int column) {
+  public void setValueAt(Object value, int row, int column) 
+  {
     ((Vector) dataVector.get(row)).set(column, value);
-    fireTableCellUpdated(row,column);
+    fireTableCellUpdated(row, column);
   }
 
   /**
@@ -554,7 +567,8 @@ public class DefaultTableModel extends AbstractTableModel
    * @return A vector (or <code>null</code> if the data array 
    *         is <code>null</code>).
    */
-  protected static Vector convertToVector(Object[] data) {
+  protected static Vector convertToVector(Object[] data) 
+  {
     if (data == null)
       return null;
     Vector vector = new Vector(data.length);
@@ -571,7 +585,8 @@ public class DefaultTableModel extends AbstractTableModel
    * @return A vector (or <code>null</code> if the data array 
    *         is <code>null</code>.
    */
-  protected static Vector convertToVector(Object[][] data) {
+  protected static Vector convertToVector(Object[][] data) 
+  {
     if (data == null)
       return null;
     Vector vector = new Vector(data.length);
diff --git a/libjava/classpath/javax/swing/table/JTableHeader.java b/libjava/classpath/javax/swing/table/JTableHeader.java
index f7c1e1cd5893..482317ff0adf 100644
--- a/libjava/classpath/javax/swing/table/JTableHeader.java
+++ b/libjava/classpath/javax/swing/table/JTableHeader.java
@@ -1,5 +1,5 @@
 /* JTableHeader.java --
-   Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,9 +38,8 @@ exception statement from your version. */
 
 package javax.swing.table;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.Font;
@@ -82,282 +81,516 @@ public class JTableHeader extends JComponent
     protected class AccessibleJTableHeaderEntry extends AccessibleContext
       implements Accessible, AccessibleComponent
     {
+      
+      private int columnIndex;
+      
+      private JTableHeader parent;
+      
+      private JTable table;
+      
       public AccessibleJTableHeaderEntry(int c, JTableHeader p, JTable t)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        columnIndex = c;
+        parent = p;
+        table = t;
       }
       
+      /**
+       * Returns the column header renderer.
+       * 
+       * @return The column header renderer.
+       */
+      Component getColumnHeaderRenderer()
+      {
+        TableColumn tc = parent.getColumnModel().getColumn(columnIndex);
+        TableCellRenderer r = tc.getHeaderRenderer();
+        if (r == null)
+          r = parent.getDefaultRenderer();
+        return r.getTableCellRendererComponent(table, tc.headerValue, 
+            false, false, -1, columnIndex);
+      }
+      
+      /**
+       * Returns the accessible context for the column header renderer, or 
+       * <code>null</code>.
+       * 
+       * @return The accessible context.
+       */
+      AccessibleContext getAccessibleColumnHeaderRenderer()
+      {
+        Component c = getColumnHeaderRenderer();
+        if (c instanceof Accessible)
+          return c.getAccessibleContext();
+        return null;
+      }
+      
+      /**
+       * @see #removeFocusListener(FocusListener)
+       */
       public void addFocusListener(FocusListener l)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          c.addFocusListener(l);
       }
       
+      /**
+       * @see #removePropertyChangeListener(PropertyChangeListener)
+       */
       public void addPropertyChangeListener(PropertyChangeListener l)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        // add the listener to the accessible context for the header
+        // renderer...
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          ac.addPropertyChangeListener(l);
       }
       
       public boolean contains(Point p)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.contains(p);
+        else 
+          return false;
       }
       
       public AccessibleAction getAccessibleAction()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac instanceof AccessibleAction)
+          return (AccessibleAction) ac;
+        else 
+          return null;
       }
       
       public Accessible getAccessibleAt(Point p)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getAccessibleAt(p);
+        else
+          return null;
       }
       
+      /**
+       * Returns <code>null</code> as the header entry has no accessible
+       * children.
+       * 
+       * @return <code>null</code>.
+       */
       public Accessible getAccessibleChild(int i)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        return null;
       }
       
+      /**
+       * Returns the number of accessible children, zero in this case.
+       * 
+       * @return 0
+       */
       public int getAccessibleChildrenCount()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        return 0;
       }
       
+      /**
+       * Returns the accessible component for this header entry.
+       * 
+       * @return <code>this</code>.
+       */
       public AccessibleComponent getAccessibleComponent()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        return this;
       }
       
+      /**
+       * Returns the accessible context for this header entry.
+       * 
+       * @return <code>this</code>.
+       */
       public AccessibleContext getAccessibleContext()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        return this;
       }
       
+      /**
+       * Returns the accessible description.
+       * 
+       * @return The accessible description.
+       * 
+       * @see #setAccessibleDescription(String)
+       */
       public String getAccessibleDescription()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          return ac.getAccessibleDescription();
+        return accessibleDescription;
       }
       
+      /**
+       * Returns the index of this header entry.
+       * 
+       * @return The index of this header entry.
+       */
       public int getAccessibleIndexInParent()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        return columnIndex;
       }
       
+      /**
+       * Returns the accessible name.
+       * 
+       * @return The accessible name.
+       * 
+       * @see #setAccessibleName(String)
+       */
       public String getAccessibleName()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          return ac.getAccessibleName();
+        return accessibleName;
       }
       
+      /**
+       * Returns the accessible role for the header entry.
+       * 
+       * @return The accessible role.
+       */
       public AccessibleRole getAccessibleRole()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          return ac.getAccessibleRole();
+        else
+          return null;
       }
       
       public AccessibleSelection getAccessibleSelection()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac instanceof AccessibleValue)
+          return (AccessibleSelection) ac;
+        else 
+          return null;
       }
       
       public AccessibleStateSet getAccessibleStateSet()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          return ac.getAccessibleStateSet();
+        else 
+          return null;
       }
       
       public AccessibleText getAccessibleText()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          return ac.getAccessibleText();
+        else 
+          return null;
       }
       
       public AccessibleValue getAccessibleValue()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac instanceof AccessibleValue)
+          return (AccessibleValue) ac;
+        else 
+          return null;
       }
       
       public Color getBackground()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getBackground();
+        else
+          return null;
       }
       
       public Rectangle getBounds()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getBounds();
+        else
+          return null;
       }
       
       public Cursor getCursor()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getCursor();
+        else
+          return null;
       }
       
       public Font getFont()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getFont();
+        else
+          return null;
       }
       
       public FontMetrics getFontMetrics(Font f)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getFontMetrics(f);
+        else
+          return null;
       }
       
       public Color getForeground()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getForeground();
+        else
+          return null;
       }
       
       public Locale getLocale()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        Component c = getColumnHeaderRenderer();
+        if (c != null)
+          return c.getLocale();
+        return null;
       }
       
       public Point getLocation()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getLocation();
+        else
+          return null;
       }
       
       public Point getLocationOnScreen()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getLocationOnScreen();
+        else
+          return null;
       }
       
       public Dimension getSize()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.getSize();
+        else
+          return null;
       }
       
       public boolean isEnabled()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.isEnabled();
+        else
+          return false;
       }
       
       public boolean isFocusTraversable()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.isFocusTraversable();
+        else
+          return false;
       }
       
       public boolean isShowing()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.isShowing();
+        else
+          return false;
       }
       
       public boolean isVisible()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          return c.isVisible();
+        else
+          return false;
       }
       
+      /**
+       * @see #addFocusListener(FocusListener)
+       */
       public void removeFocusListener(FocusListener l)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          c.removeFocusListener(l);
       }
       
+      /**
+       * @see #addPropertyChangeListener(PropertyChangeListener)
+       */
       public void removePropertyChangeListener(PropertyChangeListener l)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          ac.removePropertyChangeListener(l);
       }
       
+      /**
+       * @see #addFocusListener(FocusListener)
+       */
       public void requestFocus()
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent c = ac.getAccessibleComponent();
+        if (c != null)
+          c.requestFocus();
       }
       
+      /**
+       * @see #getAccessibleDescription()
+       */
       public void setAccessibleDescription(String s)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          ac.setAccessibleDescription(s);
+        else
+          accessibleDescription = s;
       }
       
+      /**
+       * @see #getAccessibleName()
+       */
       public void setAccessibleName(String s)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        if (ac != null)
+          ac.setAccessibleName(s);
       }
       
       public void setBackground(Color c)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setBackground(c);
       }
       
       public void setBounds(Rectangle r)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setBounds(r);
       }
       
       public void setCursor(Cursor c)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setCursor(c);
       }
       
       public void setEnabled(boolean b)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setEnabled(b);
       }
       
       public void setFont(Font f)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setFont(f);
       }
       
       public void setForeground(Color c)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setForeground(c);
       }
       
       public void setLocation(Point p)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setLocation(p);
       }
       
       public void setSize(Dimension d)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setSize(d);
       }
       
       public void setVisible(boolean b)
-        throws NotImplementedException
       {
-        throw new Error("not implemented");
+        AccessibleContext ac = getAccessibleColumnHeaderRenderer();
+        AccessibleComponent comp = ac.getAccessibleComponent();
+        if (comp != null)
+          comp.setVisible(b);
       }
     };
+    
+    public AccessibleRole getAccessibleRole()
+    {
+      return AccessibleRole.PANEL;
+    }
+    
+    public int getAccessibleChildrenCount()
+    {
+      return table.getColumnCount();
+    }
+    
+    public Accessible getAccessibleChild(int i)
+    {
+      return new AccessibleJTableHeaderEntry(i, JTableHeader.this, table);
+    }
+    
+    public Accessible getAccessibleAt(Point p)
+    {
+      return getAccessibleChild(columnAtPoint(p));
+    }
   }
   
   /**
diff --git a/libjava/classpath/javax/swing/table/TableCellEditor.java b/libjava/classpath/javax/swing/table/TableCellEditor.java
index b355311dcb2c..15070a7555fc 100644
--- a/libjava/classpath/javax/swing/table/TableCellEditor.java
+++ b/libjava/classpath/javax/swing/table/TableCellEditor.java
@@ -47,19 +47,19 @@ import javax.swing.JTable;
  * TableCellEditor public interface
  * @author Andrew Selkirk
  */
-public interface TableCellEditor extends CellEditor {
+public interface TableCellEditor extends CellEditor 
+{
 
-	/**
-	 * Get table cell editor component
-	 * @param table JTable
-	 * @param value Value of cell
-	 * @param isSelected Cell selected
-	 * @param row Row of cell
-	 * @param column Column of cell
-	 * @returns Component
-	 */
-	Component getTableCellEditorComponent(JTable table,
-			Object value, boolean isSelected, int row, int column);
+  /**
+   * Get table cell editor component
+   * @param table JTable
+   * @param value Value of cell
+   * @param isSelected Cell selected
+   * @param row Row of cell
+   * @param column Column of cell
+   * @return Component
+   */
+  Component getTableCellEditorComponent(JTable table, Object value, 
+      boolean isSelected, int row, int column);
 
-
-} // TableCellEditor
+}
diff --git a/libjava/classpath/javax/swing/table/TableCellRenderer.java b/libjava/classpath/javax/swing/table/TableCellRenderer.java
index 639b4b9ad735..6c1fecf560bf 100644
--- a/libjava/classpath/javax/swing/table/TableCellRenderer.java
+++ b/libjava/classpath/javax/swing/table/TableCellRenderer.java
@@ -46,21 +46,21 @@ import javax.swing.JTable;
  * TableCellRenderer public interface
  * @author Andrew Selkirk
  */
-public interface TableCellRenderer {
+public interface TableCellRenderer 
+{
 
-	/**
-	 * Get table cell renderer component
-	 * @param table JTable
-	 * @param value Value of cell
-	 * @param isSelected Cell selected
-	 * @param hasFocus Cell has focus
-	 * @param row Row of cell
-	 * @param column Column of cell
-	 * @returns Component
-	 */
-	Component getTableCellRendererComponent(JTable table,
-			Object value, boolean isSelected, boolean hasFocus,
-			int row, int column);
+  /**
+   * Get table cell renderer component
+   * @param table JTable
+   * @param value Value of cell
+   * @param isSelected Cell selected
+   * @param hasFocus Cell has focus
+   * @param row Row of cell
+   * @param column Column of cell
+   * @return Component
+   */
+  Component getTableCellRendererComponent(JTable table, Object value, 
+      boolean isSelected, boolean hasFocus, int row, int column);
 
 
-} // TableCellRenderer
+}
diff --git a/libjava/classpath/javax/swing/text/AbstractWriter.java b/libjava/classpath/javax/swing/text/AbstractWriter.java
index d5fc395e1ac0..8d5a6075df48 100644
--- a/libjava/classpath/javax/swing/text/AbstractWriter.java
+++ b/libjava/classpath/javax/swing/text/AbstractWriter.java
@@ -183,7 +183,8 @@ public abstract class AbstractWriter
     if (! elt.isLeaf())
       throw new BadLocationException("Element is not a leaf",
 				     elt.getStartOffset());
-    return document.getText(elt.getStartOffset(), elt.getEndOffset());
+    return document.getText(elt.getStartOffset(), 
+			    elt.getEndOffset() - elt.getStartOffset());
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/text/DefaultCaret.java b/libjava/classpath/javax/swing/text/DefaultCaret.java
index c9369af2089e..4ad204c00c99 100644
--- a/libjava/classpath/javax/swing/text/DefaultCaret.java
+++ b/libjava/classpath/javax/swing/text/DefaultCaret.java
@@ -216,13 +216,26 @@ public class DefaultCaret extends Rectangle
      */
     public void propertyChange(PropertyChangeEvent e)
     {
-      if (e.getPropertyName().equals("document"))
+      String name = e.getPropertyName(); 
+      
+      if (name.equals("document"))
         {
           Document oldDoc = (Document) e.getOldValue();
           oldDoc.removeDocumentListener(documentListener);
           Document newDoc = (Document) e.getNewValue();
           newDoc.addDocumentListener(documentListener);
         }
+      else if (name.equals("editable"))
+        {
+          active = (((Boolean) e.getNewValue()).booleanValue()
+                   && textComponent.isEnabled());
+        }
+      else if (name.equals("enabled"))
+        {
+          active = (((Boolean) e.getNewValue()).booleanValue()
+                   && textComponent.isEditable());
+        }
+      
     }
     
   }
@@ -281,8 +294,10 @@ public class DefaultCaret extends Rectangle
 
   /**
    * The text component in which this caret is installed.
+   * 
+   * (Package private to avoid synthetic accessor method.)
    */
-  private JTextComponent textComponent;
+  JTextComponent textComponent;
 
   /**
    * Indicates if the selection should be visible or not.
@@ -314,6 +329,12 @@ public class DefaultCaret extends Rectangle
    * package private to avoid an accessor method.
    */
   boolean visible = false;
+  
+  /** Indicates whether the text component where the caret is installed is
+   * editable and enabled. If either of these properties is <code>false</code>
+   * the caret is not drawn.
+   */ 
+  boolean active = true;
 
   /**
    * The current highlight entry.
@@ -388,14 +409,23 @@ public class DefaultCaret extends Rectangle
   
   /**
    * Moves the caret position when the mouse is dragged over the text
-   * component, modifying the selection accordingly.
+   * component, modifying the selectiony.
+   * 
+   * <p>When the text component where the caret is installed is disabled,
+   * the selection is not change but you can still scroll the text and
+   * update the caret's location.</p>
    *
    * @param event the <code>MouseEvent</code> describing the drag operation
    */
   public void mouseDragged(MouseEvent event)
   {
     if (event.getButton() == MouseEvent.BUTTON1)
-      moveCaret(event);
+      {
+        if (textComponent.isEnabled())
+          moveCaret(event);
+        else
+          positionCaret(event);
+      }
   }
 
   /**
@@ -426,6 +456,10 @@ public class DefaultCaret extends Rectangle
    */
   public void mouseClicked(MouseEvent event)
   {
+    // Do not modify selection if component is disabled.
+    if (!textComponent.isEnabled())
+      return;
+    
     int count = event.getClickCount();
     
     if (event.getButton() == MouseEvent.BUTTON1 && count >= 2)
@@ -523,7 +557,7 @@ public class DefaultCaret extends Rectangle
     // implemented (in regard to text components):
     // - a left-click moves the caret
     // - a left-click when shift is held down expands the selection
-    // - a right-click or click with any additionaly mouse button
+    // - a right-click or click with any additional mouse button
     //   on a text component is ignored
     // - a middle-click positions the caret and pastes the clipboard
     //   contents.
@@ -540,6 +574,7 @@ public class DefaultCaret extends Rectangle
         else
           {
             positionCaret(event);
+            
             textComponent.paste();
           }
       else
@@ -564,8 +599,11 @@ public class DefaultCaret extends Rectangle
    */
   public void focusGained(FocusEvent event)
   {
-    setVisible(true);    
-    updateTimerStatus();
+    if (textComponent.isEditable())
+      {
+        setVisible(true);    
+        updateTimerStatus();
+      }
   }
 
   /**
@@ -575,9 +613,10 @@ public class DefaultCaret extends Rectangle
    */
   public void focusLost(FocusEvent event)
   {
-    if (event.isTemporary() == false)
+    if (textComponent.isEditable() && event.isTemporary() == false)
       {
         setVisible(false);
+        
         // Stop the blinker, if running.
         if (blinkTimer != null && blinkTimer.isRunning())
           blinkTimer.stop();
@@ -670,6 +709,7 @@ public class DefaultCaret extends Rectangle
     textComponent.addPropertyChangeListener(propertyChangeListener);
     documentListener = new DocumentHandler();
     textComponent.getDocument().addDocumentListener(documentListener);
+    active = textComponent.isEditable() && textComponent.isEnabled();
 
     repaint();
   }
@@ -872,7 +912,7 @@ public class DefaultCaret extends Rectangle
       }
 
     // Now draw the caret on the new position if visible.
-    if (visible)
+    if (visible && active)
       {
         g.setColor(textComponent.getCaretColor());
         g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 1);
@@ -1013,7 +1053,9 @@ public class DefaultCaret extends Rectangle
         this.dot = Math.max(this.dot, 0);
         
         handleHighlight();
+
         appear();
+
         adjustVisibility(this);
       }
   }
@@ -1050,7 +1092,9 @@ public class DefaultCaret extends Rectangle
         this.mark = this.dot;
         
         clearHighlight();
+        
         appear();
+        
         adjustVisibility(this);
       }
   }
@@ -1104,7 +1148,7 @@ public class DefaultCaret extends Rectangle
    */
   public boolean isVisible()
   {
-    return visible;
+    return visible && active;
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/text/DefaultEditorKit.java b/libjava/classpath/javax/swing/text/DefaultEditorKit.java
index 1b686182b6a1..8602e69f8e73 100644
--- a/libjava/classpath/javax/swing/text/DefaultEditorKit.java
+++ b/libjava/classpath/javax/swing/text/DefaultEditorKit.java
@@ -52,6 +52,7 @@ import java.io.Reader;
 import java.io.Writer;
 
 import javax.swing.Action;
+import javax.swing.SwingConstants;
 
 /**
  * The default implementation of {@link EditorKit}. This <code>EditorKit</code>
@@ -60,6 +61,7 @@ import javax.swing.Action;
  *
  * @author original author unknown
  * @author Roman Kennke (roman@kennke.org)
+ * @author Robert Schuster (robertschuster@fsfe.org)
  */
 public class DefaultEditorKit extends EditorKit
 {
@@ -123,6 +125,122 @@ public class DefaultEditorKit extends EditorKit
     }
   }
 
+  static class SelectionBeginWordAction extends TextAction
+  {
+    SelectionBeginWordAction()
+    {
+      super(selectionBeginWordAction);
+    }
+  
+    public void actionPerformed(ActionEvent event)
+    {
+      try
+        {
+          JTextComponent t = getTextComponent(event);
+      
+          if (t != null)
+            {
+              int offs = Utilities.getWordStart(t, t.getCaretPosition());
+      
+              Caret c = t.getCaret();
+              c.moveDot(offs);
+              c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+            }
+        }
+      catch(BadLocationException ble)
+        {
+          // Can't happen.
+        }
+    }
+  }
+  
+  static class SelectionEndWordAction extends TextAction
+  {
+    SelectionEndWordAction()
+    {
+      super(selectionEndWordAction);
+    }
+  
+    public void actionPerformed(ActionEvent event)
+    {
+      try
+        {
+          JTextComponent t = getTextComponent(event);
+      
+          if (t != null)
+            {
+              int offs = Utilities.getWordEnd(t, t.getCaretPosition());
+      
+              Caret c = t.getCaret();
+              c.moveDot(offs);
+              c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+            }
+        }
+      catch(BadLocationException ble)
+        {
+          // Can't happen.
+        }
+    }
+  }
+  
+  static class BeginWordAction extends TextAction
+  {
+    BeginWordAction()
+    {
+      super(beginWordAction);
+    }
+  
+    public void actionPerformed(ActionEvent event)
+    {
+      try
+        {
+          JTextComponent t = getTextComponent(event);
+      
+          if (t != null)
+            {
+              int offs = Utilities.getWordStart(t, t.getCaretPosition());
+      
+              Caret c = t.getCaret();
+              c.setDot(offs);
+              c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+            }
+        }
+      catch(BadLocationException ble)
+        {
+          // Can't happen.
+        }
+    }
+  }
+  
+  static class EndWordAction extends TextAction
+  {
+    EndWordAction()
+    {
+      super(endWordAction);
+    }
+  
+    public void actionPerformed(ActionEvent event)
+    {
+      try
+        {
+          JTextComponent t = getTextComponent(event);
+      
+          if (t != null)
+            {
+              int offs = Utilities.getWordEnd(t, t.getCaretPosition());
+      
+              Caret c = t.getCaret();
+              c.setDot(offs);
+              c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+            }
+        }
+      catch(BadLocationException ble)
+        {
+          // Can't happen.
+        }
+    }
+  }
+
   static class PreviousWordAction
       extends TextAction
   {
@@ -258,336 +376,260 @@ public class DefaultEditorKit extends EditorKit
         }
     }
   }
-
-  static class SelectionEndLineAction
-      extends TextAction
+  
+  static class SelectionBeginLineAction
+    extends TextAction
   {
-    SelectionEndLineAction()
+    
+    SelectionBeginLineAction()
     {
-      super(selectionEndLineAction);
+      super(selectionBeginLineAction);
     }
 
     public void actionPerformed(ActionEvent event)
     {
       JTextComponent t = getTextComponent(event);
-     try
-     {
-       Point p = t.modelToView(t.getCaret().getDot()).getLocation();
-       int cur = t.getCaretPosition();
-       int y = p.y;
-       int length = t.getDocument().getLength();
-       while (y == p.y && cur < length)
-         y = t.modelToView(++cur).getLocation().y;
-       if (cur != length)
-         cur--;
-    
-       Caret c = t.getCaret();
-       c.moveDot(cur);
-       c.setMagicCaretPosition(t.modelToView(cur).getLocation());
-     }
-     catch (BadLocationException ble)
-     {
-       // Nothing to do here
-     }
+      Caret c = t.getCaret();
+      try
+        {
+          int offs = Utilities.getRowStart(t, c.getDot());
+          c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+        }
+      catch(BadLocationException ble)
+      {
+        // Can't happen.
+      }
+
     }
   }
 
-  static class SelectionBeginLineAction
+  static class SelectionEndLineAction
       extends TextAction
   {
-    SelectionBeginLineAction()
+    SelectionEndLineAction()
     {
-      super(selectionBeginLineAction);
+      super(selectionEndLineAction);
     }
 
     public void actionPerformed(ActionEvent event)
     {
       JTextComponent t = getTextComponent(event);
-      
+      Caret c = t.getCaret();
       try
-      {
-        // TODO: There is a more efficent solution, but
-        // viewToModel doesn't work properly.
-        Point p = t.modelToView(t.getCaret().getDot()).getLocation();
-        
-        int cur = t.getCaretPosition();
-        int y = p.y;
-        
-        while (y == p.y && cur > 0)
-          y = t.modelToView(--cur).getLocation().y;
-        if (cur != 0)
-          cur++;
-        
-        Caret c = t.getCaret();
-        c.moveDot(cur);
-        c.setMagicCaretPosition(t.modelToView(cur).getLocation());
-      }
-      catch (BadLocationException ble)
-      {
-        // Do nothing here.
-      }
+        {
+          int offs = Utilities.getRowEnd(t, c.getDot());
+          c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+        }
+      catch(BadLocationException ble)
+        {
+        // Can't happen.
+        }
+
     }
   }
-
-  static class SelectionDownAction
-      extends TextAction
+  
+  static class SelectLineAction extends TextAction
   {
-    SelectionDownAction()
+    SelectLineAction()
     {
-      super(selectionDownAction);
+      super(selectLineAction);
     }
-
+  
     public void actionPerformed(ActionEvent event)
     {
       JTextComponent t = getTextComponent(event);
+      Caret c = t.getCaret();
       try
         {
-          if (t != null)
-            {
-              Caret c = t.getCaret();
-              // The magic caret position may be null when the caret
-              // has not moved yet.
-              Point mcp = c.getMagicCaretPosition();
-              int x = (mcp != null) ? mcp.x : 0;
-              int pos = Utilities.getPositionBelow(t, t.getCaretPosition(), x);
-              
-              if (pos > -1)
-                t.moveCaretPosition(pos);
-            }
+          int offs1 = Utilities.getRowStart(t, c.getDot());
+          int offs2 = Utilities.getRowEnd(t, c.getDot());
+          
+          c.setDot(offs2);
+          c.moveDot(offs1);
+          
+          c.setMagicCaretPosition(t.modelToView(offs2).getLocation());
         }
-      catch(BadLocationException ble) 
+      catch(BadLocationException ble)
         {
-          // FIXME: Swallowing allowed?
+          // Can't happen.
         }
     }
   }
-
-  static class SelectionUpAction
-      extends TextAction
+  
+  static class SelectWordAction extends TextAction
   {
-    SelectionUpAction()
+    SelectWordAction()
     {
-      super(selectionUpAction);
+      super(selectWordAction);
     }
-
+  
     public void actionPerformed(ActionEvent event)
     {
       JTextComponent t = getTextComponent(event);
+      Caret c = t.getCaret();
+      int dot = c.getDot();
+
       try
         {
-          if (t != null)
+          int wordStart = Utilities.getWordStart(t, dot);
+      
+          if (dot == wordStart)
             {
-              Caret c = t.getCaret();
-              // The magic caret position may be null when the caret
-              // has not moved yet.
-              Point mcp = c.getMagicCaretPosition();
-              int x = (mcp != null) ? mcp.x : 0;
-              int pos = Utilities.getPositionAbove(t, t.getCaretPosition(), x);
+              // Current cursor position is on the first character in a word.
+              c.setDot(wordStart);
+              c.moveDot(Utilities.getWordEnd(t, wordStart));
+            }
+          else
+            {
+              // Current cursor position is not on the first character
+              // in a word. 
+              int nextWord = Utilities.getNextWord(t, dot);
+              int previousWord = Utilities.getPreviousWord(t, dot);
+              int previousWordEnd = Utilities.getWordEnd(t, previousWord);
               
-              if (pos > -1)
-                t.moveCaretPosition(pos);
+              // Cursor position is in the space between two words. In such a
+              // situation just select the space.
+              if (dot >= previousWordEnd && dot <= nextWord)
+                {
+                  c.setDot(previousWordEnd);
+                  c.moveDot(nextWord);
+                }
+              else
+                {
+                  // Cursor position is inside a word. Just select it then.
+                  c.setDot(previousWord);
+                  c.moveDot(previousWordEnd);
+                }
             }
+
+          // If the position was updated change the magic caret position
+          // as well.
+          if (c.getDot() != dot)
+            c.setMagicCaretPosition(t.modelToView(c.getDot()).getLocation());
+          
         }
-      catch(BadLocationException ble) 
+      catch(BadLocationException ble)
         {
-          // FIXME: Swallowing allowed?
+          // Can't happen.
         }
     }
   }
 
+  static class SelectionDownAction
+      extends TextAction.VerticalMovementAction
+  {
+    SelectionDownAction()
+    {
+      super(selectionDownAction, SwingConstants.SOUTH);
+    }
+
+    protected void actionPerformedImpl(Caret c, int offs)
+    {
+      c.moveDot(offs);
+    }
+    
+  }
+
+  static class SelectionUpAction
+  extends TextAction.VerticalMovementAction
+  {
+    SelectionUpAction()
+    {
+      super(selectionUpAction, SwingConstants.NORTH);
+    }
+
+    protected void actionPerformedImpl(Caret c, int offs)
+    {
+      c.moveDot(offs);
+    }
+
+  }
+
   static class SelectionForwardAction
-      extends TextAction
+      extends TextAction.HorizontalMovementAction
   {
     SelectionForwardAction()
     {
-      super(selectionForwardAction);
+      super(selectionForwardAction, SwingConstants.EAST);
     }
 
-    public void actionPerformed(ActionEvent event)
+    protected void actionPerformedImpl(Caret c, int offs)
     {
-      JTextComponent t = getTextComponent(event);
-      if (t != null)
-        {
-          int offs = t.getCaretPosition() + 1;
-          
-          if(offs <= t.getDocument().getLength())
-            {
-              Caret c = t.getCaret();
-              c.moveDot(offs);
-              try
-                {
-                  c.setMagicCaretPosition(t.modelToView(offs).getLocation());
-                }
-              catch(BadLocationException ble)
-              {
-                // Can't happen.
-              }
-            }
-        }
+      c.moveDot(offs);
     }
   }
 
   static class SelectionBackwardAction
-      extends TextAction
+      extends TextAction.HorizontalMovementAction
   {
     SelectionBackwardAction()
     {
-      super(selectionBackwardAction);
+      super(selectionBackwardAction, SwingConstants.WEST);
     }
 
-    public void actionPerformed(ActionEvent event)
+    protected void actionPerformedImpl(Caret c, int offs)
     {
-      JTextComponent t = getTextComponent(event);
-      if (t != null)
-        {
-      int offs = t.getCaretPosition() - 1;
-      
-      if(offs >= 0)
-        {
-          Caret c = t.getCaret();
-          c.moveDot(offs);
-          try
-            {
-              c.setMagicCaretPosition(t.modelToView(offs).getLocation());
-            }
-          catch(BadLocationException ble)
-          {
-            // Can't happen.
-          }
-        }
-        }
+      c.moveDot(offs);
     }
   }
 
   static class DownAction
-      extends TextAction
+      extends TextAction.VerticalMovementAction
   {
     DownAction()
     {
-      super(downAction);
+      super(downAction, SwingConstants.SOUTH);
     }
 
-    public void actionPerformed(ActionEvent event)
+    protected void actionPerformedImpl(Caret c, int offs)
     {
-      JTextComponent t = getTextComponent(event);
-      try
-        {
-          if (t != null)
-            {
-              Caret c = t.getCaret();
-              // The magic caret position may be null when the caret
-              // has not moved yet.
-              Point mcp = c.getMagicCaretPosition();
-              int x = (mcp != null) ? mcp.x : 0;
-              int pos = Utilities.getPositionBelow(t, t.getCaretPosition(), x);
-              
-              if (pos > -1)
-                t.setCaretPosition(pos);
-            }
-        }
-      catch(BadLocationException ble) 
-        {
-          // FIXME: Swallowing allowed?
-        }
+      c.setDot(offs);
     }
   }
 
   static class UpAction
-      extends TextAction
+      extends TextAction.VerticalMovementAction
   {
     UpAction()
     {
-      super(upAction);
+      super(upAction, SwingConstants.NORTH);
     }
 
-    public void actionPerformed(ActionEvent event)
+    protected void actionPerformedImpl(Caret c, int offs)
     {
-      JTextComponent t = getTextComponent(event);
-      try
-        {
-          if (t != null)
-            {
-              Caret c = t.getCaret();
-              // The magic caret position may be null when the caret
-              // has not moved yet.
-              Point mcp = c.getMagicCaretPosition();
-              int x = (mcp != null) ? mcp.x : 0;
-              int pos = Utilities.getPositionAbove(t, t.getCaretPosition(), x);
-              
-              if (pos > -1)
-                t.setCaretPosition(pos);
-            }
-        }
-      catch(BadLocationException ble) 
-        {
-          // FIXME: Swallowing allowed?
-        }
+      c.setDot(offs);
     }
+    
   }
 
   static class ForwardAction
-      extends TextAction
+      extends TextAction.HorizontalMovementAction
   {
     ForwardAction()
     {
-      super(forwardAction);
+      super(forwardAction, SwingConstants.EAST);
     }
 
-    public void actionPerformed(ActionEvent event)
+    protected void actionPerformedImpl(Caret c, int offs)
     {
-      JTextComponent t = getTextComponent(event);
-      if (t != null)
-        {
-          int offs = t.getCaretPosition() + 1;
-          if (offs <= t.getDocument().getLength())
-            {
-              Caret c = t.getCaret();
-              c.setDot(offs);
-              
-              try
-                {
-                  c.setMagicCaretPosition(t.modelToView(offs).getLocation());
-                }
-              catch (BadLocationException ble)
-                {
-                  // Should not happen.
-                }
-            }
-        }
-      
+      c.setDot(offs);
     }
+    
   }
 
   static class BackwardAction
-      extends TextAction
+      extends TextAction.HorizontalMovementAction
   {
     BackwardAction()
     {
-      super(backwardAction);
+      super(backwardAction, SwingConstants.WEST);
     }
 
-    public void actionPerformed(ActionEvent event)
+    protected void actionPerformedImpl(Caret c, int offs)
     {
-      JTextComponent t = getTextComponent(event);
-      if (t != null)
-        {
-          int offs = t.getCaretPosition() - 1;
-          if (offs >= 0)
-            {
-              Caret c = t.getCaret();
-              c.setDot(offs);
-              
-              try
-                {
-                  c.setMagicCaretPosition(t.modelToView(offs).getLocation());
-                }
-              catch (BadLocationException ble)
-                {
-                  // Should not happen.
-                }
-            }
-        }
+      c.setDot(offs);
     }
+    
   }
 
   static class DeletePrevCharAction
@@ -720,6 +762,55 @@ public class DefaultEditorKit extends EditorKit
     }
   }
 
+  static class BeginAction extends TextAction
+  {
+    
+    BeginAction()
+    {
+      super(beginAction);
+    }
+
+    public void actionPerformed(ActionEvent event)
+    {
+      JTextComponent t = getTextComponent(event);
+      Caret c = t.getCaret();
+      c.setDot(0);
+      try
+      {   
+        c.setMagicCaretPosition(t.modelToView(0).getLocation());
+      }
+      catch(BadLocationException ble)
+      {
+        // Can't happen.
+      }
+    }
+  }
+
+  static class EndAction extends TextAction
+  {
+      
+    EndAction()
+    {
+      super(endAction);
+    }
+
+    public void actionPerformed(ActionEvent event)
+    {
+      JTextComponent t = getTextComponent(event);
+      int offs = t.getDocument().getLength();
+      Caret c = t.getCaret();
+      c.setDot(offs);
+      try
+        {   
+          c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+        }
+      catch(BadLocationException ble)
+        {
+          // Can't happen.
+        }
+    }
+  }
+  
   /**
    * Creates a beep on the PC speaker.
    *
@@ -867,8 +958,8 @@ public class DefaultEditorKit extends EditorKit
       // first we filter the following events:
       // - control characters
       // - key events with the ALT modifier (FIXME: filter that too!)
-      char c = event.getActionCommand().charAt(0);
-      if (Character.isISOControl(c))
+      int cp = event.getActionCommand().codePointAt(0);
+      if (Character.isISOControl(cp))
         return;
 
       JTextComponent t = getTextComponent(event);
@@ -1345,8 +1436,6 @@ public class DefaultEditorKit extends EditorKit
    * The <code>Action</code>s that are supported by the
    * <code>DefaultEditorKit</code>.
    */
-  // TODO: All these inner classes look ugly. Maybe work out a better way
-  // to handle this.
   private static Action[] defaultActions = 
   new Action[] {
     // These classes are public because they are so in the RI.            
@@ -1387,9 +1476,21 @@ public class DefaultEditorKit extends EditorKit
     new PreviousWordAction(),
     new SelectionPreviousWordAction(),
 
+    new BeginAction(),
     new SelectionBeginAction(),
+    
+    new EndAction(),
     new SelectionEndAction(),
+    
+    new BeginWordAction(),
+    new SelectionBeginWordAction(),
+    
+    new EndWordAction(),
+    new SelectionEndWordAction(),
+    
     new SelectAllAction(),
+    new SelectLineAction(),
+    new SelectWordAction()
   };
 
   /**
diff --git a/libjava/classpath/javax/swing/text/FieldView.java b/libjava/classpath/javax/swing/text/FieldView.java
index 0c2f0fef156f..f41f90130926 100644
--- a/libjava/classpath/javax/swing/text/FieldView.java
+++ b/libjava/classpath/javax/swing/text/FieldView.java
@@ -50,6 +50,7 @@ import java.awt.event.ActionListener;
 
 import javax.swing.BoundedRangeModel;
 import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.event.DocumentEvent;
@@ -241,12 +242,29 @@ public class FieldView extends PlainView
 
     Shape newAlloc = adjustAllocation(s);
     
-    // Set a clip to prevent drawing outside of the allocation area.
-    // TODO: Is there a better way to achieve this?
     Shape clip = g.getClip();
-    g.setClip(s);
+    if (clip != null)
+      {
+        // Reason for this: The allocation area is always determined by the
+        // size of the component (and its insets) regardless of whether
+        // parts of the component are invisible or not (e.g. when the
+        // component is part of a JScrollPane and partly moved out of
+        // the user-visible range). However the clip of the Graphics
+        // instance may be adjusted properly to that condition but
+        // does not handle insets. By calculating the intersection
+        // we get the correct clip to paint the text in all cases.
+        Rectangle r = s.getBounds();
+        Rectangle cb = clip.getBounds();
+        SwingUtilities.computeIntersection(r.x, r.y, r.width, r.height, cb);
+
+        g.setClip(cb);
+      }
+    else
+      g.setClip(s);
+
     super.paint(g, newAlloc);
     g.setClip(clip);
+    
   }
 
   public void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
diff --git a/libjava/classpath/javax/swing/text/GapContent.java b/libjava/classpath/javax/swing/text/GapContent.java
index 219accb40563..1780d7ddfada 100644
--- a/libjava/classpath/javax/swing/text/GapContent.java
+++ b/libjava/classpath/javax/swing/text/GapContent.java
@@ -39,13 +39,10 @@ exception statement from your version. */
 package javax.swing.text;
 
 import java.io.Serializable;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.Iterator;
-import java.util.ListIterator;
+import java.util.Set;
 import java.util.Vector;
+import java.util.WeakHashMap;
 
 import javax.swing.undo.AbstractUndoableEdit;
 import javax.swing.undo.CannotRedoException;
@@ -60,8 +57,6 @@ import javax.swing.undo.UndoableEdit;
  * minimal (simple array access). The array only has to be shifted around when
  * the insertion point moves (then the gap also moves and one array copy is
  * necessary) or when the gap is filled up and the buffer has to be enlarged.
- * 
- * TODO: Implement UndoableEdit support stuff
  */
 public class GapContent
     implements AbstractDocument.Content, Serializable
@@ -71,11 +66,14 @@ public class GapContent
    * A {@link Position} implementation for <code>GapContent</code>.
    */
   private class GapContentPosition
-    implements Position, Comparable
+    implements Position
   {
 
-    /** The index within the buffer array. */
-    int mark;
+    /**
+     * The index to the positionMarks array entry, which in turn holds the
+     * mark into the buffer array.
+     */
+    int index;
 
     /**
      * Creates a new GapContentPosition object.
@@ -84,33 +82,20 @@ public class GapContent
      */
     GapContentPosition(int mark)
     {
-      this.mark = mark;
-    }
-
-    /**
-     * Comparable interface implementation. This is used to store all
-     * positions in an ordered fashion.
-     * 
-     * @param o the object to be compared to this
-     * 
-     * @return a negative integer if this is less than <code>o</code>, zero
-     *         if both are equal or a positive integer if this is greater than
-     *         <code>o</code>
-     * 
-     * @throws ClassCastException if <code>o</code> is not a
-     *         GapContentPosition or Integer object
-     */
-    public int compareTo(Object o)
-    {
-      if (o instanceof Integer)
+      // Try to find the mark in the positionMarks array, and store the index
+      // to it.
+      synchronized (GapContent.this)
         {
-          int otherMark = ((Integer) o).intValue();
-          return mark - otherMark;
-        }
-      else
-        {
-          GapContentPosition other = (GapContentPosition) o;
-          return mark - other.mark;
+          int i = binarySearch(positionMarks, mark, numMarks);
+          if (i >= 0) // mark found
+            {
+              index = i;
+            }
+          else
+            {
+              index = -i - 1;
+              insertMark(index, mark);
+            }
         }
     }
 
@@ -121,14 +106,19 @@ public class GapContent
      */
     public int getOffset()
     {
-      // Check precondition.
-      assert mark <= gapStart || mark >= gapEnd : "mark: " + mark
-                                               + ", gapStart: " + gapStart
-                                               + ", gapEnd: " + gapEnd;
-      if (mark <= gapStart)
-        return mark;
-      else
-        return mark - (gapEnd - gapStart);
+      synchronized (GapContent.this)
+        {
+          // Fetch the actual mark.
+          int mark = positionMarks[index];
+          // Check precondition.
+          assert mark <= gapStart || mark >= gapEnd : "mark: " + mark
+                                                   + ", gapStart: " + gapStart
+                                                   + ", gapEnd: " + gapEnd;
+          int res = mark;
+          if (mark > gapStart)
+            res -= (gapEnd - gapStart);
+          return res;
+        }
     }
   }
 
@@ -209,40 +199,6 @@ public class GapContent
     
   }
 
-  /**
-   * Compares WeakReference objects in a List by comparing the referenced
-   * objects instead.
-   *
-   * @author Roman Kennke (kennke@aicas.com)
-   */
-  private class WeakPositionComparator
-    implements Comparator
-  {
-
-    /**
-     * Compares two objects of type WeakReference. The objects are compared
-     * using the referenced objects compareTo() method.
-     */
-    public int compare(Object o1, Object o2)
-    {
-      // Unwrap references.
-      if (o1 instanceof WeakReference)
-        o1 = ((WeakReference) o1).get();
-      if (o2 instanceof WeakReference)
-        o2 = ((WeakReference) o2).get();
-
-      GapContentPosition p1 = (GapContentPosition) o1;
-      GapContentPosition p2 = (GapContentPosition) o2;
-
-      int retVal;
-      if (p1 == null || p2 == null)
-        retVal = -1;
-      else
-        retVal = p1.compareTo(p2);
-      return retVal;
-    }
-  }
-
   /** The serialization UID (compatible with JDK1.5). */
   private static final long serialVersionUID = -6226052713477823730L;
 
@@ -267,12 +223,26 @@ public class GapContent
    */
   int gapEnd;
 
+  // FIXME: We might want to track GC'ed GapContentPositions and remove their
+  // corresponding marks, or alternativly, perform some regular cleanup of
+  // the positionMarks array.
+
+  /**
+   * Holds the marks for positions. These marks are referenced by the
+   * GapContentPosition instances by an index into this array.
+   */
+  int[] positionMarks;
+
   /**
-   * The positions generated by this GapContent. They are kept in an ordered
-   * fashion, so they can be looked up easily. The value objects will be
-   * WeakReference objects that in turn hold GapContentPosition objects.
+   * The number of elements in the positionMarks array. The positionMarks array
+   * might be bigger than the actual number of elements.
    */
-  private ArrayList positions;
+  int numMarks;
+
+  /**
+   * (Weakly) Stores the GapContentPosition instances. 
+   */
+  WeakHashMap positions;
 
   /**
    * Creates a new GapContent object.
@@ -294,7 +264,9 @@ public class GapContent
     gapStart = 1;
     gapEnd = size;
     buffer[0] = '\n';
-    positions = new ArrayList();
+    positions = new WeakHashMap();
+    positionMarks = new int[10];
+    numMarks = 0;
   }
 
   /**
@@ -483,26 +455,30 @@ public class GapContent
    */
   public Position createPosition(final int offset) throws BadLocationException
   {
-    if (offset < 0 || offset > length())
-      throw new BadLocationException("The offset was out of the bounds of this"
-          + " buffer", offset);
-
-    clearPositionReferences();
-
-    // We store the actual array index in the GapContentPosition. The real
-    // offset is then calculated in the GapContentPosition.
-    int mark = offset;
-    if (offset >= gapStart)
-      mark += gapEnd - gapStart;
-    GapContentPosition pos = new GapContentPosition(mark);
-    WeakReference r = new WeakReference(pos);
-
-    // Add this into our list in a sorted fashion.
-    int index = Collections.binarySearch(positions, r,
-                                         new WeakPositionComparator());
-    if (index < 0)
-      index = -(index + 1);
-    positions.add(index, r);
+    // We try to find a GapContentPosition at the specified offset and return
+    // that. Otherwise we must create a new one.
+    GapContentPosition pos = null;
+    Set positionSet = positions.keySet();
+    for (Iterator i = positionSet.iterator(); i.hasNext();)
+      {
+        GapContentPosition p = (GapContentPosition) i.next();
+        if (p.getOffset() == offset)
+          {
+            pos = p;
+            break;
+          }
+      }
+
+    // If none was found, then create and return a new one.
+    if (pos == null)
+      {
+        int mark = offset;
+        if (mark >= gapStart)
+          mark += (gapEnd - gapStart);
+        pos = new GapContentPosition(mark);
+        positions.put(pos, null);
+      }
+
     return pos;
   }
 
@@ -542,7 +518,6 @@ public class GapContent
   {
     if (newGapStart == gapStart)
       return;
-
     int newGapEnd = newGapStart + gapEnd - gapStart;
     if (newGapStart < gapStart)
       {
@@ -583,7 +558,7 @@ public class GapContent
 
     assert newGapStart < gapStart : "The new gap start must be less than the "
                                     + "old gap start.";
-    setPositionsInRange(newGapStart, gapStart - newGapStart, gapStart);
+    setPositionsInRange(newGapStart, gapStart, false);
     gapStart = newGapStart;
   }
 
@@ -602,7 +577,7 @@ public class GapContent
 
     assert newGapEnd > gapEnd : "The new gap end must be greater than the "
                                 + "old gap end.";
-    setPositionsInRange(gapEnd, newGapEnd - gapEnd, newGapEnd);
+    setPositionsInRange(gapEnd, newGapEnd, false);
     gapEnd = newGapEnd;
   }
 
@@ -688,85 +663,79 @@ public class GapContent
     else
       res.clear();
 
-    int endOffset = offset + length;
-
-    int index1 = Collections.binarySearch(positions,
-                                          new GapContentPosition(offset),
-                                          new WeakPositionComparator());
-    if (index1 < 0)
-      index1 = -(index1 + 1);
-
-    // Search the first index with the specified offset. The binarySearch does
-    // not necessarily find the first one.
-    while (index1 > 0)
-      {
-        WeakReference r = (WeakReference) positions.get(index1 - 1);
-        GapContentPosition p = (GapContentPosition) r.get();
-        if (p != null && p.mark == offset || p == null)
-          index1--;
-        else
-          break;
-      }
+    int endOffs = offset + length;
 
-    for (ListIterator i = positions.listIterator(index1); i.hasNext();)
+    Set positionSet = positions.keySet();
+    for (Iterator i = positionSet.iterator(); i.hasNext();)
       {
-        WeakReference r = (WeakReference) i.next();
-        GapContentPosition p = (GapContentPosition) r.get();
-        if (p == null)
-          continue;
-
-        if (p.mark > endOffset)
-          break;
-        if (p.mark >= offset && p.mark <= endOffset)
+        GapContentPosition p = (GapContentPosition) i.next();
+        int offs = p.getOffset();
+        if (offs >= offset && offs < endOffs)
           res.add(p);
       }
+
     return res;
   }
   
   /**
-   * Sets the mark of all <code>Position</code>s that are in the range 
-   * specified by <code>offset</code> and </code>length</code> within 
-   * the buffer array to <code>value</code>
+   * Crunches all positions in the specified range to either the start or
+   * end of that interval. The interval boundaries are meant to be inclusive
+   * [start, end].
    *
-   * @param offset the start offset of the range to search
-   * @param length the length of the range to search
-   * @param value the new value for each mark
+   * @param start the start offset of the range
+   * @param end the end offset of the range
+   * @param toStart a boolean indicating if the positions should be crunched
+   *        to the start (true) or to the end (false)
    */
-  private void setPositionsInRange(int offset, int length, int value)
+  private void setPositionsInRange(int start, int end, boolean toStart)
   {
-    int endOffset = offset + length;
-
-    int index1 = Collections.binarySearch(positions,
-                                          new GapContentPosition(offset),
-                                          new WeakPositionComparator());
-    if (index1 < 0)
-      index1 = -(index1 + 1);
-
-    // Search the first index with the specified offset. The binarySearch does
-    // not necessarily find the first one.
-    while (index1 > 0)
+    // We slump together all the GapContentPositions to point to
+    // one mark. So this is implemented as follows:
+    // 1. Remove all the marks in the specified range.
+    // 2. Insert one new mark at the correct location.
+    // 3. Adjust all affected GapContentPosition instances to point to
+    //    this new mark.
+
+    synchronized (this)
       {
-        WeakReference r = (WeakReference) positions.get(index1 - 1);
-        GapContentPosition p = (GapContentPosition) r.get();
-        if (p != null && p.mark == offset || p == null)
-          index1--;
+        int startIndex = binarySearch(positionMarks, start, numMarks);
+        if (startIndex < 0) // Translate to insertion index, if not found.
+          startIndex = - startIndex - 1;
+        int endIndex = binarySearch(positionMarks, end, numMarks);
+        if (endIndex < 0) // Translate to insertion index - 1, if not found.
+          endIndex = - endIndex - 2;
+
+        // Update the marks.
+        // We have inclusive interval bounds, but let one element over for
+        // filling in the new value.
+        int removed = endIndex - startIndex;
+        if (removed <= 0)
+          return;
+        System.arraycopy(positionMarks, endIndex + 1, positionMarks,
+                         startIndex + 1, positionMarks.length - endIndex - 1);
+        numMarks -= removed;
+        if (toStart)
+          {
+            positionMarks[startIndex] = start;
+          }
         else
-          break;
-      }
-
-    for (ListIterator i = positions.listIterator(index1); i.hasNext();)
-      {
-        WeakReference r = (WeakReference) i.next();
-        GapContentPosition p = (GapContentPosition) r.get();
-        if (p == null)
-          continue;
-
-        if (p.mark > endOffset)
-          break;
-        
-        if (p.mark >= offset && p.mark <= endOffset)
-          p.mark = value;
-      }
+          {
+            positionMarks[startIndex] = end;
+          }
+
+        // Update all affected GapContentPositions to point to the new index
+        // and all GapContentPositions that come after the interval to
+        // have their index moved by -removed.
+        Set positionSet = positions.keySet();
+        for (Iterator i = positionSet.iterator(); i.hasNext();)
+          {
+            GapContentPosition p = (GapContentPosition) i.next();
+            if (p.index > startIndex || p.index <= endIndex)
+              p.index = startIndex;
+            else if (p.index > endIndex)
+              p.index -= removed;
+          }
+    }
   }
   
   /**
@@ -780,39 +749,44 @@ public class GapContent
    */
   private void adjustPositionsInRange(int offset, int length, int incr)
   {
-    int endOffset = offset + length;
+    int endMark = offset + length;
 
-    int index1 = Collections.binarySearch(positions,
-                                          new GapContentPosition(offset),
-                                          new WeakPositionComparator());
-    if (index1 < 0)
-      index1 = -(index1 + 1);
-
-    // Search the first index with the specified offset. The binarySearch does
-    // not necessarily find the first one.
-    while (index1 > 0)
+    synchronized (this)
       {
-        WeakReference r = (WeakReference) positions.get(index1 - 1);
-        GapContentPosition p = (GapContentPosition) r.get();
-        if (p != null && p.mark == offset || p == null)
-          index1--;
-        else
-          break;
+        // Find the start and end indices in the positionMarks array.
+        int startIndex = binarySearch(positionMarks, offset, numMarks);
+        if (startIndex < 0) // Translate to insertion index, if not found.
+          startIndex = - startIndex - 1;
+        int endIndex = binarySearch(positionMarks, endMark, numMarks);
+        if (endIndex < 0) // Translate to insertion index - 1, if not found.
+          endIndex = - endIndex - 2;
+
+        // We must not change the order of the marks, this would have
+        // unpredictable results while binary-searching the marks.
+        assert (startIndex <= 0
+                || positionMarks[startIndex - 1]
+                                 <= positionMarks [startIndex] + incr)
+               && (endIndex >= numMarks - 1
+                   || positionMarks[endIndex + 1]
+                                    >= positionMarks[endIndex] + incr)
+                : "Adjusting the marks must not change their order";
+
+        // Some debug helper output to determine if the start or end of the
+        // should ever be coalesced together with adjecent marks.
+        if (startIndex > 0 && positionMarks[startIndex - 1]
+                                          == positionMarks[startIndex] + incr)
+          System.err.println("DEBUG: We could coalesce the start of the region"
+                             + " in GapContent.adjustPositionsInRange()");
+        if (endIndex < numMarks - 1 && positionMarks[endIndex + 1]
+                                            == positionMarks[endIndex] + incr)
+            System.err.println("DEBUG: We could coalesce the end of the region"
+                               + " in GapContent.adjustPositionsInRange()");
+
+        // Actually adjust the marks.
+        for (int i = startIndex; i <= endIndex; i++)
+          positionMarks[i] += incr;
       }
 
-    for (ListIterator i = positions.listIterator(index1); i.hasNext();)
-      {
-        WeakReference r = (WeakReference) i.next();
-        GapContentPosition p = (GapContentPosition) r.get();
-        if (p == null)
-          continue;
-
-        if (p.mark > endOffset)
-          break;
-
-        if (p.mark >= offset && p.mark <= endOffset)
-          p.mark += incr;
-      }
   }
 
   /**
@@ -826,7 +800,7 @@ public class GapContent
     if (gapStart != 0)
       return;
 
-    setPositionsInRange(gapEnd, 0, 0);
+    positionMarks[0] = 0;
   }
 
   /**
@@ -866,27 +840,94 @@ public class GapContent
     System.err.println();
   }
 
-  private void dumpPositions()
+  /**
+   * Prints out the position marks.
+   */
+  private void dumpMarks()
+  {
+    System.err.print("positionMarks: ");
+    for (int i = 0; i < numMarks; i++)
+      System.err.print(positionMarks[i] + ", ");
+    System.err.println();
+  }
+
+  /**
+   * Inserts a mark into the positionMarks array. This must update all the
+   * GapContentPosition instances in positions that come after insertionPoint.
+   *
+   * This is package private to avoid synthetic accessor methods.
+   *
+   * @param insertionPoint the index at which to insert the mark
+   * @param mark the mark to insert
+   */
+  void insertMark(int insertionPoint, int mark)
   {
-    for (Iterator i = positions.iterator(); i.hasNext();)
+    synchronized (this)
       {
-        WeakReference r = (WeakReference) i.next();
-        GapContentPosition pos = (GapContentPosition) r.get();
-        System.err.println("position at: " + pos.mark);
+        // Update the positions.
+        Set positionSet = positions.keySet();
+        for (Iterator i = positionSet.iterator(); i.hasNext();)
+          {
+            GapContentPosition p = (GapContentPosition) i.next();
+            if (p.index >= insertionPoint)
+              p.index++;
+          }
+
+        // Update the position marks.
+        if (positionMarks.length <= numMarks)
+          {
+            int[] newMarks = new int[positionMarks.length + 10];
+            System.arraycopy(positionMarks, 0, newMarks, 0, insertionPoint);
+            newMarks[insertionPoint] = mark;
+            System.arraycopy(positionMarks, insertionPoint, newMarks,
+                             insertionPoint + 1,
+                             numMarks - insertionPoint);
+            positionMarks = newMarks;
+          }
+        else
+          {
+            System.arraycopy(positionMarks, insertionPoint, positionMarks,
+                             insertionPoint + 1,
+                             numMarks - insertionPoint);
+            positionMarks[insertionPoint] = mark;
+          }
+        numMarks++;
       }
   }
 
   /**
-   * Clears all GC'ed references in the positions array.
+   * An adaption of {@link java.util.Arrays#binarySearch(int[], int)} to 
+   * specify a maximum index up to which the array is searched. This allows
+   * us to have some trailing entries that we ignore.
+   *
+   * This is package private to avoid synthetic accessor methods.
+   *
+   * @param a the array
+   * @param key the key to search for
+   * @param maxIndex the maximum index up to which the search is performed
+   *
+   * @return the index of the found entry, or (-(index)-1) for the
+   *         insertion point when not found
+   *
+   * @see java.util.Arrays#binarySearch(int[], int)
    */
-  private void clearPositionReferences()
+  int binarySearch(int[] a, int key, int maxIndex)
   {
-    Iterator i = positions.iterator();
-    while (i.hasNext())
+    int low = 0;
+    int hi = maxIndex - 1;
+    int mid = 0;
+    while (low <= hi)
       {
-        WeakReference r = (WeakReference) i.next();
-        if (r.get() == null)
-          i.remove();
+        mid = (low + hi) >> 1;
+        final int d = a[mid];
+        if (d == key)
+          return mid;
+        else if (d > key)
+          hi = mid - 1;
+        else
+          // This gets the insertion point right on the last loop.
+          low = ++mid;
       }
+    return -mid - 1;
   }
 }
diff --git a/libjava/classpath/javax/swing/text/JTextComponent.java b/libjava/classpath/javax/swing/text/JTextComponent.java
index 1103de9b4732..9de151dfbac6 100644
--- a/libjava/classpath/javax/swing/text/JTextComponent.java
+++ b/libjava/classpath/javax/swing/text/JTextComponent.java
@@ -38,6 +38,8 @@ exception statement from your version. */
 
 package javax.swing.text;
 
+import gnu.classpath.NotImplementedException;
+
 import java.awt.AWTEvent;
 import java.awt.Color;
 import java.awt.Dimension;
@@ -176,6 +178,7 @@ public abstract class JTextComponent extends JComponent
      * @param e - caret event
      */
     public void caretUpdate(CaretEvent e)
+      throws NotImplementedException
     {
       // TODO: fire appropriate event.
       dot = e.getDot();
@@ -187,6 +190,7 @@ public abstract class JTextComponent extends JComponent
      * @return the accessible state set of this component
      */
     public AccessibleStateSet getAccessibleStateSet()
+      throws NotImplementedException
     {
       AccessibleStateSet state = super.getAccessibleStateSet();
       // TODO: Figure out what state must be added here to the super's state.
@@ -237,6 +241,7 @@ public abstract class JTextComponent extends JComponent
      * @param e - document event
      */
     public void insertUpdate(DocumentEvent e)
+      throws NotImplementedException
     {
       // TODO
     }
@@ -248,6 +253,7 @@ public abstract class JTextComponent extends JComponent
      * @param e - document event
      */
     public void removeUpdate(DocumentEvent e)
+      throws NotImplementedException
     {
       // TODO
     }
@@ -259,6 +265,7 @@ public abstract class JTextComponent extends JComponent
      * @param e - document event
      */
     public void changedUpdate(DocumentEvent e)
+      throws NotImplementedException
     {
       // TODO
     }
@@ -271,6 +278,7 @@ public abstract class JTextComponent extends JComponent
      * @return the character index, or -1
      */
     public int getIndexAtPoint(Point p)
+      throws NotImplementedException
     {
       return 0; // TODO
     }
@@ -289,6 +297,7 @@ public abstract class JTextComponent extends JComponent
      * @return the bounding box, may be empty or null.
      */
     public Rectangle getCharacterBounds(int index)
+      throws NotImplementedException
     {
       return null; // TODO
     }
@@ -311,6 +320,7 @@ public abstract class JTextComponent extends JComponent
     * @return the character's attributes
     */
     public AttributeSet getCharacterAttribute(int index)
+      throws NotImplementedException
     {
       return null; // TODO
     }
@@ -324,6 +334,7 @@ public abstract class JTextComponent extends JComponent
      * @return the selection of text at that index, or null
      */
     public String getAtIndex(int part, int index)
+      throws NotImplementedException
     {
       return null; // TODO
     }
@@ -337,6 +348,7 @@ public abstract class JTextComponent extends JComponent
      * @return the selection of text after that index, or null
      */
     public String getAfterIndex(int part, int index)
+      throws NotImplementedException
     {
       return null; // TODO
     }
@@ -350,6 +362,7 @@ public abstract class JTextComponent extends JComponent
      * @return the selection of text before that index, or null
      */
     public String getBeforeIndex(int part, int index)
+      throws NotImplementedException
     {
       return null; // TODO
     }
@@ -361,6 +374,7 @@ public abstract class JTextComponent extends JComponent
      * @return the 0-based number of actions
      */
     public int getAccessibleActionCount()
+      throws NotImplementedException
     {
       return 0; // TODO
     }
@@ -369,11 +383,11 @@ public abstract class JTextComponent extends JComponent
      * Get a description for the specified action. Returns null if out of
      * bounds.
      * 
-     * @param i
-     *          the action to describe, 0-based
+     * @param i  the action to describe, 0-based
      * @return description of the action
      */
     public String getAccessibleActionDescription(int i)
+      throws NotImplementedException
     {
       // TODO: Not implemented fully
       return super.getAccessibleDescription();
@@ -386,6 +400,7 @@ public abstract class JTextComponent extends JComponent
      * @return true if the action was performed
      */
     public boolean doAccessibleAction(int i)
+      throws NotImplementedException
     {
       return false; // TODO
     }
@@ -396,6 +411,7 @@ public abstract class JTextComponent extends JComponent
      * @param s the new text
      */
     public void setTextContents(String s)
+      throws NotImplementedException
     {
       // TODO
     }
@@ -407,6 +423,7 @@ public abstract class JTextComponent extends JComponent
      * @param s the new text
      */
     public void insertTextAtIndex(int index, String s)
+      throws NotImplementedException
     {
       replaceText(index, index, s);
     }
@@ -495,6 +512,7 @@ public abstract class JTextComponent extends JComponent
      * @param s the new attribute set for the range
      */
     public void setAttributes(int start, int end, AttributeSet s)
+      throws NotImplementedException
     {
       // TODO
     }
@@ -1365,7 +1383,7 @@ public abstract class JTextComponent extends JComponent
   {
     if (editable == newValue)
       return;
-
+    
     boolean oldValue = editable;
     editable = newValue;
     firePropertyChange("editable", oldValue, newValue);
@@ -1725,17 +1743,20 @@ public abstract class JTextComponent extends JComponent
 
   public void copy()
   {
+    if (isEnabled())
     doTransferAction("copy", TransferHandler.getCopyAction());
   }
 
   public void cut()
   {
-    doTransferAction("cut", TransferHandler.getCutAction());
+    if (editable && isEnabled())
+      doTransferAction("cut", TransferHandler.getCutAction());
   }
 
   public void paste()
   {
-    doTransferAction("paste", TransferHandler.getPasteAction());
+    if (editable && isEnabled())
+      doTransferAction("paste", TransferHandler.getPasteAction());
   }
 
   private void doTransferAction(String name, Action action)
diff --git a/libjava/classpath/javax/swing/text/PlainView.java b/libjava/classpath/javax/swing/text/PlainView.java
index 18818c0bad34..48fe37ce880e 100644
--- a/libjava/classpath/javax/swing/text/PlainView.java
+++ b/libjava/classpath/javax/swing/text/PlainView.java
@@ -437,132 +437,92 @@ public class PlainView extends View implements TabExpander
    */
   protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f)
   {
-    // Return early and do no updates if the allocation area is null
-    // (like the RI).
-    if (a == null)
-      return;
-    
-    float oldMaxLineLength = maxLineLength; 
-    Rectangle alloc = a.getBounds();
-    Element el = getElement();
-    ElementChange ec = changes.getChange(el);
-    
-    // If ec is null then no lines were added or removed, just 
-    // repaint the changed line
-    if (ec == null)
-      {
-        int line = el.getElementIndex(changes.getOffset());
-        
-        // If characters have been removed from the current longest line
-        // we have to find out which one is the longest now otherwise
-        // the preferred x-axis span will not shrink.
-        if (changes.getType() == DocumentEvent.EventType.REMOVE
-            && el.getElement(line) == longestLine)
-          {
-            maxLineLength = -1;
-            if (determineMaxLineLength() != alloc.width)
-              preferenceChanged(this, true, false);
-          }
-        
-        damageLineRange(line, line, a, getContainer());
-        return;
-      }
-    
-    Element[] removed = ec.getChildrenRemoved();
-    Element[] newElements = ec.getChildrenAdded();
-    
-    // If no Elements were added or removed, we just want to repaint
-    // the area containing the line that was modified
-    if (removed == null && newElements == null)
+    // This happens during initialization.
+    if (metrics == null)
       {
-        int line = getElement().getElementIndex(changes.getOffset());
-        
-        damageLineRange(line, line, a, getContainer());
+        updateMetrics();
+        preferenceChanged(null, true, true);
         return;
       }
 
-    // Check to see if we removed the longest line, if so we have to
-    // search through all lines and find the longest one again.
-    if (removed != null)
-      {
-        for (int i = 0; i < removed.length; i++)
-          if (removed[i].equals(longestLine))
-            {
-              // reset maxLineLength and search through all lines for longest one
-              maxLineLength = -1;
-              if (determineMaxLineLength() != alloc.width)
-                preferenceChanged(this, true, removed.length != newElements.length);
-              
-              ((JTextComponent)getContainer()).repaint();
-              
-              return;
-            }
-      }
-    
-    // If we've reached here, that means we haven't removed the longest line
-    if (newElements == null)
-      {
-        // No lines were added, just repaint the container and exit
-        ((JTextComponent)getContainer()).repaint();
-        
-        return;
-      }
+    Element element = getElement();
 
-    //  Make sure we have the metrics
-    updateMetrics();
-       
-    // If we've reached here, that means we haven't removed the longest line
-    // and we have added at least one line, so we have to check if added lines
-    // are longer than the previous longest line        
-    Segment seg = getLineBuffer();
-    float longestNewLength = 0;
-    Element longestNewLine = null;    
+    // Find longest line if it hasn't been initialized yet.
+    if (longestLine == null)
+      findLongestLine(0, element.getElementCount() - 1);
 
-    // Loop through the added lines to check their length
-    for (int i = 0; i < newElements.length; i++)
+    ElementChange change = changes.getChange(element);
+    if (changes.getType() == DocumentEvent.EventType.INSERT)
       {
-        Element child = newElements[i];
-        int start = child.getStartOffset();
-        int end = child.getEndOffset() - 1;
-        try
-          {
-            el.getDocument().getText(start, end - start, seg);
-          }
-        catch (BadLocationException ex)
+        // Handles character/line insertion.
+
+        // Determine if lines have been added. In this case we repaint
+        // differently.
+        boolean linesAdded = true;
+        if (change == null)
+          linesAdded = false;
+
+        // Determine the start line.
+        int start;
+        if (linesAdded)
+          start = change.getIndex();
+        else
+          start = element.getElementIndex(changes.getOffset());
+
+        // Determine the length of the updated region.
+        int length = 0;
+        if (linesAdded)
+          length = change.getChildrenAdded().length - 1;
+
+        // Update the longest line and length.
+        int oldMaxLength = (int) maxLineLength;
+        if (longestLine.getEndOffset() < changes.getOffset()
+            || longestLine.getStartOffset() > changes.getOffset()
+                                             + changes.getLength())
           {
-            AssertionError ae = new AssertionError("Unexpected bad location");
-	    ae.initCause(ex);
-	    throw ae;
+            findLongestLine(start, start + length);
           }
-                
-        if (seg == null || seg.array == null || seg.count == 0)
-          continue;
-        
-        int width = metrics.charsWidth(seg.array, seg.offset, seg.count);
-        if (width > longestNewLength)
+        else
           {
-            longestNewLine = child;
-            longestNewLength = width;
+            findLongestLine(0, element.getElementCount() - 1);
           }
+
+        // Trigger a preference change so that the layout gets updated
+        // correctly.
+        preferenceChanged(null, maxLineLength != oldMaxLength, linesAdded);
+
+        // Damage the updated line range.
+        int endLine = start;
+        if (linesAdded)
+          endLine = element.getElementCount() - 1;
+        damageLineRange(start, endLine, a, getContainer());
+
       }
-    
-    // Check if the longest of the new lines is longer than our previous
-    // longest line, and if so update our values
-    if (longestNewLength > maxLineLength)
+    else
       {
-        maxLineLength = longestNewLength;
-        longestLine = longestNewLine;
+        // Handles character/lines removals.
+
+        // Update the longest line and length and trigger preference changed.
+        int oldMaxLength = (int) maxLineLength;
+        if (change != null)
+          {
+            // Line(s) have been removed.
+            findLongestLine(0, element.getElementCount() - 1);
+            preferenceChanged(null, maxLineLength != oldMaxLength, true);
+          }
+        else
+          {
+            // No line has been removed.
+            int lineNo = getElement().getElementIndex(changes.getOffset());
+            Element line = getElement().getElement(lineNo);
+            if (longestLine == line)
+              {
+                findLongestLine(0, element.getElementCount() - 1);
+                preferenceChanged(null, maxLineLength != oldMaxLength, false);
+            }
+            damageLineRange(lineNo, lineNo, a, getContainer());
+        }
       }
-    
-    // Report any changes to the preferred sizes of the view
-    // which may cause the underlying component to be revalidated.
-    boolean widthChanged = oldMaxLineLength != maxLineLength;
-    boolean heightChanged = removed.length != newElements.length; 
-    if (widthChanged || heightChanged)
-      preferenceChanged(this, widthChanged, heightChanged);
-    
-    // Repaint the container
-    ((JTextComponent)getContainer()).repaint();
   }
 
   /**
@@ -648,5 +608,54 @@ public class PlainView extends View implements TabExpander
       lineBuffer = new Segment();
     return lineBuffer;
   }
+
+  /**
+   * Finds and updates the longest line in the view inside an interval of
+   * lines.
+   *
+   * @param start the start of the search interval
+   * @param end the end of the search interval
+   */
+  private void findLongestLine(int start, int end)
+  {
+    for (int i = start; i <= end; i++)
+      {
+        int w = getLineLength(i);
+        if (w > maxLineLength)
+          {
+            maxLineLength = w;
+            longestLine = getElement().getElement(i);
+          }
+      }
+  }
+
+  /**
+   * Determines the length of the specified line.
+   *
+   * @param line the number of the line
+   *
+   * @return the length of the line in pixels
+   */
+  private int getLineLength(int line)
+  {
+    Element lineEl = getElement().getElement(line);
+    Segment buffer = getLineBuffer();
+    try
+      {
+        Document doc = getDocument();
+        doc.getText(lineEl.getStartOffset(),
+                    lineEl.getEndOffset() - lineEl.getStartOffset() - 1,
+                    buffer);
+      }
+    catch (BadLocationException ex)
+      {
+        AssertionError err = new AssertionError("Unexpected bad location");
+        err.initCause(ex);
+        throw err;
+      }
+
+    return Utilities.getTabbedTextWidth(buffer, metrics, 0, this,
+                                        lineEl.getStartOffset());
+  }
 }
 
diff --git a/libjava/classpath/javax/swing/text/StyleContext.java b/libjava/classpath/javax/swing/text/StyleContext.java
index 8ef34400d295..63df3df6a91d 100644
--- a/libjava/classpath/javax/swing/text/StyleContext.java
+++ b/libjava/classpath/javax/swing/text/StyleContext.java
@@ -38,8 +38,6 @@ exception statement from your version. */
 
 package javax.swing.text;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Color;
 import java.awt.Font;
 import java.awt.FontMetrics;
@@ -50,7 +48,6 @@ import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.Enumeration;
 import java.util.EventListener;
-import java.util.HashSet;
 import java.util.Hashtable;
 
 import javax.swing.event.ChangeEvent;
@@ -413,7 +410,7 @@ public class StyleContext
   /**
    * These attribute keys are handled specially in serialization.
    */
-  private static HashSet staticAttributeKeys = new HashSet();
+  private static Hashtable staticAttributeKeys = new Hashtable();
 
   EventListenerList listenerList;
   Hashtable styleTable;
@@ -708,49 +705,125 @@ public class StyleContext
       }	
   }
 
-
-  // FIXME: there's some sort of quasi-serialization stuff in here which I
-  // have left incomplete; I'm not sure I understand the intent properly.
-
+  /**
+   * Gets the object previously registered with registerStaticAttributeKey.
+   * 
+   * @param key - the key that was registered.
+   * @return the object previously registered with registerStaticAttributeKey.
+   */
   public static Object getStaticAttribute(Object key)
-    throws NotImplementedException
   {
-    throw new InternalError("not implemented");
+    if (key == null)
+      return null;
+    return staticAttributeKeys.get(key);
   }
   
+  /**
+   * Returns the String that key will be registered with
+   * registerStaticAttributeKey.
+   * 
+   * @param key - the key that will be registered.
+   * @return the string the key will be registered with.
+   */
   public static Object getStaticAttributeKey(Object key)
-    throws NotImplementedException
   {
-    throw new InternalError("not implemented");
+    return key.getClass().getName() + "." + key.toString();
   }
 
+  /**
+   * Reads a set of attributes from the given object input stream. This will
+   * attempt to restore keys that were static objects by considering only the
+   * keys that have were registered with registerStaticAttributeKey. The
+   * attributes retrieved will be placed into the given set.
+   * 
+   * @param in - the stream to read from
+   * @param a - the set of attributes
+   * @throws ClassNotFoundException - may be encountered when reading from
+   *           stream
+   * @throws IOException - any I/O error
+   */
   public static void readAttributeSet(ObjectInputStream in, MutableAttributeSet a)
-    throws ClassNotFoundException, IOException, NotImplementedException
+    throws ClassNotFoundException, IOException
   {
-    throw new InternalError("not implemented");
+    if (in == null || a == null)
+      return;
+    
+    Object key = in.readObject();
+    Object val = in.readObject();
+    while (key != null && val != null)
+      {
+        Object staticKey = staticAttributeKeys.get(key);
+        Object staticVal = staticAttributeKeys.get(val);
+        
+        if (staticKey != null)
+          key = staticKey;
+        if (staticVal != null)
+          val = staticVal;
+        
+        a.addAttribute(key, val);
+        key = in.readObject();
+        val = in.readObject();
+      }
   }
   
+  /**
+   * Serialize an attribute set in a way that is compatible with it
+   * being read in again by {@link #readAttributeSet(ObjectInputStream, MutableAttributeSet)}.
+   * In particular registered static keys are transformed properly.
+   * 
+   * @param out - stream to write to
+   * @param a - the attribute set
+   * @throws IOException - any I/O error
+   */
   public static void writeAttributeSet(ObjectOutputStream out, AttributeSet a)
-    throws IOException, NotImplementedException
+    throws IOException
   {
-    throw new InternalError("not implemented");
+    Enumeration e = a.getAttributeNames();
+    while (e.hasMoreElements())
+      {
+        Object oldKey = e.nextElement();
+        Object newKey = getStaticAttribute(oldKey);
+        Object key = (newKey == null) ? oldKey : newKey;
+ 
+        out.writeObject(key);
+        out.writeObject(a.getAttribute(oldKey));
+      }
+    out.writeObject(null);
+    out.writeObject(null);
   }
 
+  /**
+   * Handles reading in the attributes. 
+   * @see #readAttributeSet(ObjectInputStream, MutableAttributeSet)
+   * 
+   * @param in - the stream to read from
+   * @param a - the set of attributes
+   * @throws ClassNotFoundException - may be encountered when reading from stream
+   * @throws IOException - any I/O error
+   */
   public void readAttributes(ObjectInputStream in, MutableAttributeSet a)
-    throws ClassNotFoundException, IOException, NotImplementedException 
+    throws ClassNotFoundException, IOException
   {
-    throw new InternalError("not implemented");
+    readAttributeSet(in, a);
   }
 
+  /**
+   * Handles writing of the given attributes.
+   * @see #writeAttributeSet(ObjectOutputStream, AttributeSet)
+   * 
+   * @param out - stream to write to
+   * @param a - the attribute set
+   * @throws IOException - any I/O error
+   */
   public void writeAttributes(ObjectOutputStream out, AttributeSet a)
-    throws IOException, NotImplementedException
+    throws IOException
   {
-    throw new InternalError("not implemented");
+    writeAttributeSet(out, a);
   }
 
   /**
    * Registers an attribute key as a well-known keys. When an attribute with
-   * such a key is written to a stream,, a special syntax is used so that it
+   * such a key is written to a stream, a special syntax is used so that it
    * can be recognized when it is read back in. All attribute keys defined
    * in <code>StyleContext</code> are registered as static keys. If you define
    * additional attribute keys that you want to exist as nonreplicated objects,
@@ -760,6 +833,8 @@ public class StyleContext
    */
   public static void registerStaticAttributeKey(Object key)
   {
-    staticAttributeKeys.add(key);
+    if (key != null)
+      staticAttributeKeys.put(key.getClass().getName() + "." + key.toString(),
+                              key);
   }
 }
diff --git a/libjava/classpath/javax/swing/text/TextAction.java b/libjava/classpath/javax/swing/text/TextAction.java
index 8588e3cd2024..144166e9cdb4 100644
--- a/libjava/classpath/javax/swing/text/TextAction.java
+++ b/libjava/classpath/javax/swing/text/TextAction.java
@@ -38,12 +38,14 @@ exception statement from your version. */
 
 package javax.swing.text;
 
+import java.awt.Point;
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
 import java.util.HashSet;
 
 import javax.swing.AbstractAction;
 import javax.swing.Action;
+import javax.swing.SwingConstants;
 
 /**
  * TextAction
@@ -108,4 +110,106 @@ public abstract class TextAction extends AbstractAction
   {
     return null; // TODO
   }
+  
+  /** Abstract helper class which implements everything needed for an
+   * Action implementation in <code>DefaultEditorKit</code> which
+   * does horizontal movement (and selection).  
+   */
+  abstract static class HorizontalMovementAction extends TextAction
+  {
+    int dir;
+    
+    HorizontalMovementAction(String name, int direction)
+    {
+      super(name);
+      dir = direction;
+    }
+    
+    public void actionPerformed(ActionEvent event)
+    {
+      JTextComponent t = getTextComponent(event);
+      try
+      {
+        if (t != null)
+          {
+            int offs
+              = Utilities.getNextVisualPositionFrom(t,
+                                                    t.getCaretPosition(),
+                                                    dir);
+              
+            Caret c = t.getCaret();
+            
+            actionPerformedImpl(c, offs);
+            
+            c.setMagicCaretPosition(t.modelToView(offs).getLocation());
+          }
+      }
+    catch(BadLocationException ble)
+      {
+        throw 
+          (InternalError) new InternalError("Illegal offset").initCause(ble);
+      }
+    
+    }
+    
+    protected abstract void actionPerformedImpl(Caret c, int offs)
+      throws BadLocationException;
+  }
+  
+  /** Abstract helper class which implements everything needed for an
+   * Action implementation in <code>DefaultEditorKit</code> which
+   * does vertical movement (and selection).
+   */  
+  abstract static class VerticalMovementAction extends TextAction
+  {
+    int dir;
+    
+    VerticalMovementAction(String name, int direction)
+    {
+      super(name);
+      dir = direction;
+    }
+
+    public void actionPerformed(ActionEvent event)
+    {
+      JTextComponent t = getTextComponent(event);
+      try
+        {
+          if (t != null)
+            {
+              Caret c = t.getCaret();
+              // The magic caret position may be null when the caret
+              // has not moved yet.
+              Point mcp = c.getMagicCaretPosition();
+
+              int pos;
+              if (mcp != null)
+                {
+                  mcp.y = t.modelToView(c.getDot()).y;
+                  pos = t.viewToModel(mcp);
+                }
+              else
+                pos = c.getDot();
+        
+              pos = Utilities.getNextVisualPositionFrom(t,
+                                                        t.getCaretPosition(),
+                                                        dir);
+        
+              if (pos > -1)
+                actionPerformedImpl(c, pos);
+            }
+        }
+      catch(BadLocationException ble) 
+      {
+        throw 
+          (InternalError) new InternalError("Illegal offset").initCause(ble);
+      }
+    }
+    
+    protected abstract void actionPerformedImpl(Caret c, int offs)
+    throws BadLocationException;
+    
+  }
+  
+  
 }
diff --git a/libjava/classpath/javax/swing/text/Utilities.java b/libjava/classpath/javax/swing/text/Utilities.java
index f154e55aac09..36361f49796b 100644
--- a/libjava/classpath/javax/swing/text/Utilities.java
+++ b/libjava/classpath/javax/swing/text/Utilities.java
@@ -43,6 +43,9 @@ import java.awt.Graphics;
 import java.awt.Point;
 import java.text.BreakIterator;
 
+import javax.swing.SwingConstants;
+import javax.swing.text.Position.Bias;
+
 /**
  * A set of utilities to deal with text. This is used by several other classes
  * inside this package.
@@ -337,7 +340,7 @@ public class Utilities
             // location or is not whitespace (meaning it is a number or
             // punctuation). The first case means that 'last' denotes the
             // beginning of a word while the second case means it is the start
-            // of some else.
+            // of something else.
             if (Character.isLetter(cp)
                 || !Character.isWhitespace(cp))
               return last;
@@ -346,7 +349,7 @@ public class Utilities
         current = wb.next();
       }
     
-    throw new BadLocationException("no more word", offs);
+    throw new BadLocationException("no more words", offs);
   }
 
   /**
@@ -363,24 +366,36 @@ public class Utilities
   public static final int getPreviousWord(JTextComponent c, int offs)
       throws BadLocationException
   {
-    if (offs < 0 || offs > (c.getText().length() - 1))
-      throw new BadLocationException("invalid offset specified", offs);
     String text = c.getText();
+    
+    if (offs <= 0 || offs > text.length())
+      throw new BadLocationException("invalid offset specified", offs);
+    
     BreakIterator wb = BreakIterator.getWordInstance();
     wb.setText(text);
     int last = wb.preceding(offs);
     int current = wb.previous();
+    int cp;
 
     while (current != BreakIterator.DONE)
       {
         for (int i = last; i < offs; i++)
           {
-            if (Character.isLetter(text.codePointAt(i)))
+            cp = text.codePointAt(i);
+            
+            // Return the last found bound if there is a letter at the current
+            // location or is not whitespace (meaning it is a number or
+            // punctuation). The first case means that 'last' denotes the
+            // beginning of a word while the second case means it is the start
+            // of some else.
+            if (Character.isLetter(cp)
+                || !Character.isWhitespace(cp))
               return last;
           }
         last = current;
         current = wb.previous();
       }
+    
     return 0;
   }
   
@@ -394,14 +409,17 @@ public class Utilities
   public static final int getWordStart(JTextComponent c, int offs)
       throws BadLocationException
   {
-    if (offs < 0 || offs >= c.getText().length())
+    String text = c.getText();
+    
+    if (offs < 0 || offs > text.length())
       throw new BadLocationException("invalid offset specified", offs);
     
-    String text = c.getText();
     BreakIterator wb = BreakIterator.getWordInstance();
     wb.setText(text);
+
     if (wb.isBoundary(offs))
       return offs;
+
     return wb.preceding(offs);
   }
   
@@ -674,4 +692,38 @@ public class Utilities
     else
       return offs+1;
     }
+  
+  /** This is an internal helper method which is used by the
+   * <code>javax.swing.text</code> package. It simply delegates the
+   * call to a method with the same name on the <code>NavigationFilter</code>
+   * of the provided <code>JTextComponent</code> (if it has one) or its UI.
+   * 
+   * If the underlying method throws a <code>BadLocationException</code> it
+   * will be swallowed and the initial offset is returned.
+   */
+  static int getNextVisualPositionFrom(JTextComponent t, int offset, int direction)
+  {
+    NavigationFilter nf = t.getNavigationFilter();
+    
+    try
+      {
+        return (nf != null) 
+          ? nf.getNextVisualPositionFrom(t,
+                                         offset,
+                                         Bias.Forward,
+                                         direction,
+                                         null)
+          : t.getUI().getNextVisualPositionFrom(t,
+                                                offset,
+                                                Bias.Forward,
+                                                direction,
+                                                null);
+      }
+    catch (BadLocationException ble)
+    {
+      return offset;
+    }
+    
+  }
+  
 }
diff --git a/libjava/classpath/javax/swing/text/html/HTMLDocument.java b/libjava/classpath/javax/swing/text/html/HTMLDocument.java
index fba6cad12e9b..b7a706904a4c 100644
--- a/libjava/classpath/javax/swing/text/html/HTMLDocument.java
+++ b/libjava/classpath/javax/swing/text/html/HTMLDocument.java
@@ -40,14 +40,12 @@ package javax.swing.text.html;
 
 import gnu.classpath.NotImplementedException;
 
+import gnu.javax.swing.text.html.CharacterAttributeTranslator;
 import java.io.IOException;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Stack;
 import java.util.Vector;
-
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.UndoableEditEvent;
 import javax.swing.text.AbstractDocument;
 import javax.swing.text.AttributeSet;
 import javax.swing.text.BadLocationException;
@@ -130,21 +128,6 @@ public class HTMLDocument extends DefaultStyledDocument
     return styleSheet;
   }
   
-  /**
-   * Replaces the contents of the document with the given element
-   * specifications. This is called before insert if the loading is done
-   * in bursts. This is the only method called if loading the document
-   * entirely in one burst.
-   * 
-   * @param data - the date that replaces the content of the document
-   */
-  protected void create(DefaultStyledDocument.ElementSpec[] data)
-  {
-    // Once the super behaviour is properly implemented it should be sufficient
-    // to simply call super.create(data).
-    super.create(data);
-  }
-  
   /**
    * This method creates a root element for the new document.
    * 
@@ -215,41 +198,6 @@ public class HTMLDocument extends DefaultStyledDocument
     return new BlockElement(parent, a);
   }
   
-  /**
-   * Inserts new elements in bulk. This is how elements get created in the
-   * document. The parsing determines what structure is needed and creates the
-   * specification as a set of tokens that describe the edit while leaving the
-   * document free of a write-lock. This method can then be called in bursts by
-   * the reader to acquire a write-lock for a shorter duration (i.e. while the
-   * document is actually being altered). 
-   * 
-   * @param offset - the starting offset 
-   * @param data - the element data
-   * @throws BadLocationException - if the given position does not
-   * represent a valid location in the associated document.
-   */
-  protected void insert(int offset, DefaultStyledDocument.ElementSpec[] data)
-    throws BadLocationException
-  {
-    super.insert(offset, data);
-  }
-  
-  /**
-   * Updates document structure as a result of text insertion. This will happen
-   * within a write lock. This implementation simply parses the inserted content
-   * for line breaks and builds up a set of instructions for the element buffer.
-   * 
-   * @param chng - a description of the document change
-   * @param attr - the attributes
-   */
-  protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng, 
-                              AttributeSet attr)
-  {
-    // FIXME: Not implemented
-    System.out.println("insertUpdate not implemented");
-    super.insertUpdate(chng, attr);    
-  }
-  
   /**
    * Returns the parser used by this HTMLDocument to insert HTML.
    * 
@@ -414,6 +362,7 @@ public class HTMLDocument extends DefaultStyledDocument
   }
 
   public void processHTMLFrameHyperlinkEvent(HTMLFrameHyperlinkEvent event)
+  throws NotImplementedException
   {
     // TODO: Implement this properly.
   }
@@ -646,12 +595,16 @@ public class HTMLDocument extends DefaultStyledDocument
       {
         // Put the old attribute set on the stack.
         pushCharacterStyle();
-        
-        // And create the new one by adding the attributes in <code>a</code>.
-        if (a != null)
-          charAttr.addAttribute(t, a.copyAttributes());          
+
+	// Translate tag.. return if succesful.
+	if(CharacterAttributeTranslator.translateTag(charAttr, t, a))
+	  return;
+
+        // Just add the attributes in <code>a</code>.
+ 	if (a != null)
+ 	  charAttr.addAttribute(t, a.copyAttributes());          
       }
-      
+
       /**
        * Called when an end tag is seen for one of the types of tags associated
        * with this Action.
@@ -724,17 +677,6 @@ public class HTMLDocument extends DefaultStyledDocument
         // FIXME: Implement.
         print ("IsindexAction.start not implemented");
       }
-      
-      /**
-       * Called when an end tag is seen for one of the types of tags associated
-       * with this Action.
-       */
-      public void end(HTML.Tag t)
-        throws NotImplementedException
-      {
-        // FIXME: Implement.
-        print ("IsindexAction.end not implemented");
-      } 
     }
     
     public class ParagraphAction extends BlockAction
@@ -745,7 +687,6 @@ public class HTMLDocument extends DefaultStyledDocument
        */
       public void start(HTML.Tag t, MutableAttributeSet a)
       {
-        // FIXME: What else must be done here?
         blockOpen(t, a);
       }
       
@@ -755,7 +696,6 @@ public class HTMLDocument extends DefaultStyledDocument
        */
       public void end(HTML.Tag t)
       {
-        // FIXME: What else must be done here?
         blockClose(t);
       } 
     }
@@ -771,6 +711,7 @@ public class HTMLDocument extends DefaultStyledDocument
       {
         // FIXME: Implement.
         print ("PreAction.start not implemented");
+        super.start(t, a);
       }
       
       /**
@@ -782,6 +723,7 @@ public class HTMLDocument extends DefaultStyledDocument
       {
         // FIXME: Implement.
         print ("PreAction.end not implemented");
+        super.end(t);
       } 
     }
     
@@ -792,22 +734,9 @@ public class HTMLDocument extends DefaultStyledDocument
        * of tags associated with this Action.
        */
       public void start(HTML.Tag t, MutableAttributeSet a)
-        throws NotImplementedException
       {
-        // FIXME: Implement.
-        print ("SpecialAction.start not implemented");
+        addSpecialElement(t, a);
       }
-      
-      /**
-       * Called when an end tag is seen for one of the types of tags associated
-       * with this Action.
-       */
-      public void end(HTML.Tag t)
-        throws NotImplementedException
-      {
-        // FIXME: Implement.
-        print ("SpecialAction.end not implemented");
-      }                
     }
     
     class AreaAction extends TagAction
@@ -1131,7 +1060,7 @@ public class HTMLDocument extends DefaultStyledDocument
      */
     protected void pushCharacterStyle()
     {
-      charAttrStack.push(charAttr);
+      charAttrStack.push(charAttr.copyAttributes());
     }
     
     /**
@@ -1565,8 +1494,8 @@ public class HTMLDocument extends DefaultStyledDocument
    */
   public Element getElement(String attrId)
   {
-    Element root = getDefaultRootElement();
-    return getElement(root, HTML.getAttributeKey(attrId) , attrId);
+    return getElement(getDefaultRootElement(), HTML.getAttributeKey(attrId),
+                      attrId);
   }
   
   /**
@@ -1690,53 +1619,4 @@ public class HTMLDocument extends DefaultStyledDocument
     //  FIXME: Not implemented fully, use InsertHTML* in HTMLEditorKit?
     System.out.println("insertAfterStart not implemented");
   }
-  
-  /**
-   * This method sets the attributes associated with the paragraph containing
-   * offset. If replace is false, s is merged with existing attributes. The
-   * length argument determines how many characters are affected by the new
-   * attributes. This is often the entire paragraph.
-   * 
-   * @param offset -
-   *          the offset into the paragraph (must be at least 0)
-   * @param length -
-   *          the number of characters affected (must be at least 0)
-   * @param s -
-   *          the attributes
-   * @param replace -
-   *          whether to replace existing attributes, or merge them
-   */
-  public void setParagraphAttributes(int offset, int length, AttributeSet s,
-                                     boolean replace)
-    throws NotImplementedException
-  {
-    //  FIXME: Not implemented.
-    System.out.println("setParagraphAttributes not implemented");
-    super.setParagraphAttributes(offset, length, s, replace);
-  }
-  
-  /**
-   * This method flags a change in the document.
-   * 
-   *  @param e - the Document event
-   */
-  protected void fireChangedUpdate(DocumentEvent e)
-    throws NotImplementedException
-  {
-    //  FIXME: Not implemented.
-    System.out.println("fireChangedUpdate not implemented");
-    super.fireChangedUpdate(e);    
-  }
-
-  /**
-   * This method fires an event intended to be caught by Undo listeners. It
-   * simply calls the super version inherited from DefaultStyledDocument. With
-   * this method, an HTML editor could easily provide undo support.
-   * 
-   * @param e - the UndoableEditEvent
-   */
-  protected void fireUndoableEditUpdate(UndoableEditEvent e)
-  {
-    super.fireUndoableEditUpdate(e);
-  }
 }
diff --git a/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java b/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java
index 92d9de938eb4..adda4922d574 100644
--- a/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java
+++ b/libjava/classpath/javax/swing/text/html/HTMLEditorKit.java
@@ -548,6 +548,8 @@ public class HTMLEditorKit
                    || tag.equals(HTML.Tag.BLOCKQUOTE)
                    || tag.equals(HTML.Tag.PRE))
             view = new BlockView(element, View.Y_AXIS);
+          else if (tag.equals(HTML.Tag.IMG))
+            view = new ImageView(element);
           
           // FIXME: Uncomment when the views have been implemented
           else if (tag.equals(HTML.Tag.CONTENT))
@@ -558,13 +560,12 @@ public class HTMLEditorKit
             view = new HTMLTableView(element);
           else if (tag.equals(HTML.Tag.TD))
             view = new ParagraphView(element);
+            
 
           /*
           else if (tag.equals(HTML.Tag.MENU) || tag.equals(HTML.Tag.DIR)
                    || tag.equals(HTML.Tag.UL) || tag.equals(HTML.Tag.OL))
             view = new ListView(element);
-          else if (tag.equals(HTML.Tag.IMG))
-            view = new ImageView(element);
           else if (tag.equals(HTML.Tag.HR))
             view = new HRuleView(element);
           else if (tag.equals(HTML.Tag.BR))
diff --git a/libjava/classpath/javax/swing/text/html/ImageView.java b/libjava/classpath/javax/swing/text/html/ImageView.java
new file mode 100644
index 000000000000..84b021070a9f
--- /dev/null
+++ b/libjava/classpath/javax/swing/text/html/ImageView.java
@@ -0,0 +1,441 @@
+package javax.swing.text.html;
+
+import gnu.javax.swing.text.html.CombinedAttributes;
+import gnu.javax.swing.text.html.ImageViewIconFactory;
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.MediaTracker;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import javax.swing.text.Element;
+import javax.swing.text.View;
+import javax.swing.text.Position.Bias;
+import javax.swing.text.html.HTML.Attribute;
+
+/**
+ * A view, representing a single image, represented by the HTML IMG tag.
+ * 
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) 
+ */
+public class ImageView extends View
+{
+  /**
+   * True if the image loads synchronuosly (on demand). By default, the image
+   * loads asynchronuosly.
+   */
+  boolean loadOnDemand;
+  
+  /**
+   * The image icon, wrapping the image,
+   */
+  ImageIcon imageIcon;
+ 
+  /**
+   * The image state.
+   */
+  byte imageState = MediaTracker.LOADING;
+
+  /**
+   * Creates the image view that represents the given element.
+   * 
+   * @param element the element, represented by this image view.
+   */
+  public ImageView(Element element)
+  {
+    super(element);
+  }
+ 
+  /**
+   * Load or reload the image. This method initiates the image reloading. After
+   * the image is ready, the repaint event will be scheduled. The current image,
+   * if it already exists, will be discarded.
+   * 
+   * @param itsTime
+   *          also load if the "on demand" property is set
+   */
+  void reloadImage(boolean itsTime)
+  {
+    URL url = getImageURL();
+    if (url == null)
+      imageState = (byte) MediaTracker.ERRORED;
+    else if (!(loadOnDemand && !itsTime))
+      imageIcon = new ImageIcon(url);
+    else
+      imageState = (byte) MediaTracker.LOADING;
+  }
+  
+  /**
+   * Get the image alignment. This method works handling standart alignment
+   * attributes in the HTML IMG tag (align = top bottom middle left right).
+   * Depending from the parameter, either horizontal or vertical alingment
+   * information is returned.
+   * 
+   * @param axis -
+   *          either X_AXIS or Y_AXIS
+   */
+  public float getAlignment(int axis)
+  {
+    AttributeSet attrs = getAttributes();
+    Object al = attrs.getAttribute(Attribute.ALIGN);
+    
+    // Default is top left aligned.
+    if (al == null)
+      return 0.0f;
+
+    String align = al.toString();
+
+    if (axis == View.X_AXIS)
+      {
+        if (align.equals("middle"))
+          return 0.5f;
+        else if (align.equals("left"))
+          return 0.0f;
+        else if (align.equals("right"))
+          return 1.0f;
+        else
+          return 0.0f;
+      }
+    else if (axis == View.Y_AXIS)
+      {
+        if (align.equals("middle"))
+          return 0.5f;
+        else if (align.equals("top"))
+          return 0.0f;
+        else if (align.equals("bottom"))
+          return 1.0f;
+        else
+          return 0.0f;
+      }
+    else
+      throw new IllegalArgumentException("axis " + axis);
+  }
+  
+  /**
+   * Get the text that should be shown as the image replacement and also as the
+   * image tool tip text. The method returns the value of the attribute, having
+   * the name {@link Attribute#ALT}. If there is no such attribute, the image
+   * name from the url is returned. If the URL is not available, the empty
+   * string is returned.
+   */
+  public String getAltText()
+  {
+    Object rt = getAttributes().getAttribute(Attribute.ALT);
+    if (rt != null)
+      return rt.toString();
+    else
+      {
+        URL u = getImageURL();
+        if (u == null)
+          return "";
+        else
+          return u.getFile();
+      }
+  }
+  
+  /**
+   * Returns the combination of the document and the style sheet attributes.
+   */
+  public AttributeSet getAttributes()
+  {
+    StyleSheet styles = getStyleSheet();
+    if (styles == null)
+      return super.getAttributes();
+    else
+      return CombinedAttributes.combine(super.getAttributes(),
+                                        styles.getViewAttributes(this));
+  }
+  
+  /**
+   * Get the image to render. May return null if the image is not yet loaded.
+   */
+  public Image getImage()
+  {
+    if (imageIcon == null)
+      return null;
+    else
+      return imageIcon.getImage();
+  }
+  
+  /**
+   * Get the URL location of the image to render. If this method returns null,
+   * the "no image" icon is rendered instead. By defaul, url must be present as
+   * the "src" property of the IMG tag. If it is missing, null is returned and
+   * the "no image" icon is rendered.
+   * 
+   * @return the URL location of the image to render.
+   */
+  public URL getImageURL()
+  {
+    Object url = getAttributes().getAttribute(Attribute.SRC);
+    if (url == null)
+      return null;
+
+    try
+      {
+        return new URL(url.toString());
+      }
+    catch (MalformedURLException e)
+      {
+        // The URL is malformed - no image.
+        return null;
+      }
+  }
+
+  /**
+   * Get the icon that should be displayed while the image is loading and hence
+   * not yet available.
+   * 
+   * @return an icon, showing a non broken sheet of paper with image.
+   */
+  public Icon getLoadingImageIcon()
+  {
+    return ImageViewIconFactory.getLoadingImageIcon();
+  }
+  
+  /**
+   * Get the image loading strategy.
+   * 
+   * @return false (default) if the image is loaded when the view is
+   *         constructed, true if the image is only loaded on demand when
+   *         rendering.
+   */
+  public boolean getLoadsSynchronously()
+  {
+    return loadOnDemand;
+  }
+
+  /**
+   * Get the icon that should be displayed when the image is not available.
+   * 
+   * @return an icon, showing a broken sheet of paper with image.
+   */
+  public Icon getNoImageIcon()
+  {
+    return ImageViewIconFactory.getNoImageIcon();
+  }
+  
+  /**
+   * Get the preferred span of the image along the axis. The image size is first
+   * requested to the attributes {@link Attribute#WIDTH} and
+   * {@link Attribute#HEIGHT}. If they are missing, and the image is already
+   * loaded, the image size is returned. If there are no attributes, and the
+   * image is not loaded, zero is returned.
+   * 
+   * @param axis -
+   *          either X_AXIS or Y_AXIS
+   * @return either width of height of the image, depending on the axis.
+   */
+  public float getPreferredSpan(int axis)
+  {
+    AttributeSet attrs = getAttributes();
+    
+    Image image = getImage();
+
+    if (axis == View.X_AXIS)
+      {
+        Object w = attrs.getAttribute(Attribute.WIDTH);
+        if (w != null)
+          return Integer.parseInt(w.toString());
+        else if (image != null)
+          return image.getWidth(getContainer());
+        else
+          return getNoImageIcon().getIconWidth();
+      }
+    else if (axis == View.Y_AXIS)
+      {
+        Object w = attrs.getAttribute(Attribute.HEIGHT);
+        if (w != null)
+          return Integer.parseInt(w.toString());
+        else if (image != null)
+          return image.getHeight(getContainer());
+        else
+          return getNoImageIcon().getIconHeight();
+      }
+    else
+      throw new IllegalArgumentException("axis " + axis);
+  }
+  
+  /**
+   * Get the associated style sheet from the document.
+   * 
+   * @return the associated style sheet.
+   */
+  protected StyleSheet getStyleSheet()
+  {
+    Document d = getElement().getDocument();
+    if (d instanceof HTMLDocument)
+      return ((HTMLDocument) d).getStyleSheet();
+    else
+      return null;
+  }
+
+  /**
+   * Get the tool tip text. This is overridden to return the value of the
+   * {@link #getAltText()}. The parameters are ignored.
+   * 
+   * @return that is returned by getAltText().
+   */
+  public String getToolTipText(float x, float y, Shape shape)
+  {
+    return getAltText();
+  }
+  
+  /**
+   * Paints the image or one of the two image state icons. The image is resized
+   * to the shape bounds. If there is no image available, the alternative text
+   * is displayed besides the image state icon.
+   * 
+   * @param g
+   *          the Graphics, used for painting.
+   * @param bounds
+   *          the bounds of the region where the image or replacing icon must be
+   *          painted.
+   */
+  public void paint(Graphics g, Shape bounds)
+  {
+    Rectangle r = bounds.getBounds();
+
+    if (imageIcon == null)
+
+      {
+        // Loading image on demand, rendering the loading icon so far.
+        reloadImage(true);
+         
+        // The reloadImage sets the imageIcon, unless the URL is broken 
+        // or malformed.
+        if (imageIcon != null)
+          {
+            if (imageIcon.getImageLoadStatus() != MediaTracker.COMPLETE)
+              {
+                // Render "not ready" icon, unless the image is ready
+                // immediately.
+                renderIcon(g, r, getLoadingImageIcon());
+                // Add the listener to repaint when the icon will be ready.
+                imageIcon.setImageObserver(getContainer());
+                return;
+              }
+          }
+        else
+          {
+            renderIcon(g, r, getNoImageIcon());
+            return;
+          }
+      }
+
+    imageState = (byte) imageIcon.getImageLoadStatus();
+
+    switch (imageState)
+      {
+      case MediaTracker.ABORTED:
+      case MediaTracker.ERRORED:
+        renderIcon(g, r, getNoImageIcon());
+        break;
+      case MediaTracker.LOADING:
+      // If the image is not loaded completely, we still render it, as the
+      // partial image may be available.
+      case MediaTracker.COMPLETE:
+      {
+        // Paint the scaled image.
+        Image scaled = imageIcon.getImage().getScaledInstance(
+                                                              r.width,
+                                                              r.height,
+                                                              Image.SCALE_DEFAULT);
+        ImageIcon painter = new ImageIcon(scaled);
+        painter.paintIcon(getContainer(), g, r.x, r.y);
+      }
+        break;
+      }
+  }
+  
+  /**
+   * Render "no image" icon and the alternative "no image" text. The text is
+   * rendered right from the icon and is aligned to the icon bottom.
+   */
+  private void renderIcon(Graphics g, Rectangle bounds, Icon icon)
+  {
+    Shape current = g.getClip();
+    try
+      {
+        g.setClip(bounds);
+        if (icon != null)
+          {
+            icon.paintIcon(getContainer(), g, bounds.x, bounds.y);
+            g.drawString(getAltText(), bounds.x + icon.getIconWidth(),
+                         bounds.y + icon.getIconHeight());
+          }
+      }
+    finally
+      {
+        g.setClip(current);
+      }
+  }
+  
+  /**
+   * Set if the image should be loaded only when needed (synchronuosly). By
+   * default, the image loads asynchronuosly. If the image is not yet ready, the
+   * icon, returned by the {@link #getLoadingImageIcon()}, is displayed.
+   */
+  public void setLoadsSynchronously(boolean load_on_demand)
+  {
+    loadOnDemand = load_on_demand;
+  }
+ 
+  /**
+   * Update all cached properties from the attribute set, returned by the
+   * {@link #getAttributes}.
+   */
+  protected void setPropertiesFromAttributes()
+  {
+    // In the current implementation, nothing is cached yet, unless the image
+    // itself.
+    imageIcon = null;
+  }
+  
+  /**
+   * Maps the picture co-ordinates into the image position in the model. As the
+   * image is not divideable, this is currently implemented always to return the
+   * start offset.
+   */
+  public int viewToModel(float x, float y, Shape shape, Bias[] bias)
+  {
+    return getStartOffset();
+  }
+  
+  /**
+   * This is currently implemented always to return the area of the image view,
+   * as the image is not divideable by character positions.
+   * 
+   * @param pos character position
+   * @param area of the image view
+   * @param bias bias
+   * 
+   * @return the shape, where the given character position should be mapped.
+   */
+  public Shape modelToView(int pos, Shape area, Bias bias)
+      throws BadLocationException
+  {
+    return area;
+  }
+  
+  /**
+   * Starts loading the image asynchronuosly. If the image must be loaded
+   * synchronuosly instead, the {@link #setLoadsSynchronously} must be
+   * called before calling this method. The passed parameters are not used.
+   */
+  public void setSize(float width, float height)
+  {
+    if (imageIcon == null)
+      reloadImage(false);
+  }  
+  
+
+}
diff --git a/libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java b/libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java
new file mode 100644
index 000000000000..d42951a05eca
--- /dev/null
+++ b/libjava/classpath/javax/swing/text/html/MinimalHTMLWriter.java
@@ -0,0 +1,452 @@
+/* MinimalHTMLWriter.java -- 
+   Copyright (C) 2006 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 javax.swing.text.html;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.AbstractWriter;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.Element;
+import javax.swing.text.ElementIterator;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.Style;
+import javax.swing.text.StyledDocument;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Stack;
+import java.awt.Color;
+
+/**
+ * MinimalHTMLWriter,
+ * A minimal AbstractWriter implementation for HTML.
+ *
+ * @author Sven de Marothy
+ */
+public class MinimalHTMLWriter extends AbstractWriter 
+{
+  private StyledDocument doc;
+  private Stack tagStack;
+  private boolean inFontTag = false;
+
+  /**
+   * Constructs a MinimalHTMLWriter.
+   * @param w - a Writer, for output.
+   * @param doc - the document
+   */
+  public MinimalHTMLWriter(Writer w, StyledDocument doc)
+  {
+    super(w, doc);
+    this.doc = doc;
+    tagStack = new Stack();
+  }
+
+  /**
+   * Constructs a MinimalHTMLWriter.
+   * @param w - a Writer, for output.
+   * @param doc - the document
+   * @param pos - start position
+   * @param len - length
+   */
+  public MinimalHTMLWriter(Writer w, StyledDocument doc, int pos, int len)
+  {
+    super(w, doc, pos, len);
+    this.doc = doc;
+    tagStack = new Stack();
+  }
+
+  /**
+   * Starts a span tag.
+   */
+  protected void startFontTag(String style) throws IOException
+  {
+    if( inFontTag() )
+      endOpenTags();
+    writeStartTag("<span style=\""+style+"\">");
+    inFontTag = true;
+  }
+
+  /**
+   * Returns whether the writer is within two span tags.
+   */
+  protected boolean inFontTag()
+  {
+    return inFontTag;
+  }
+
+  /**
+   * Ends a span tag.
+   */
+  protected void endFontTag() throws IOException
+  {    
+    writeEndTag("</span>");
+    inFontTag = false;
+  }
+
+  /**
+   * Write the entire HTML document.
+   */
+  public synchronized void write() throws IOException, BadLocationException
+  {
+    writeStartTag("<html>");
+    writeHeader();
+    writeBody();
+    writeEndTag("</html>");
+  }
+
+  /**
+   * Write a start tag and increment the indent.
+   */
+  protected void writeStartTag(String tag) throws IOException
+  {
+    indent();
+    write(tag+NEWLINE);
+    incrIndent();
+  }
+
+  /**
+   * Write an ending tag and decrement the indent.
+   */
+  protected void writeEndTag(String endTag) throws IOException
+  {
+    decrIndent();
+    indent();
+    write(endTag+NEWLINE);
+  }
+
+  /**
+   * Write the HTML header.
+   */
+  protected void writeHeader() throws IOException 
+  {
+    writeStartTag("<head>");
+    writeStartTag("<style>");
+    writeStartTag("<!--");
+    writeStyles();
+    writeEndTag("-->");
+    writeEndTag("</style>");
+    writeEndTag("</head>");
+  }
+
+  /**
+   * Write a paragraph start tag.
+   */
+  protected void writeStartParagraph(Element elem) throws IOException
+  {      
+    indent();
+    write("<p class=default>"+NEWLINE); // FIXME: Class value = ?
+    incrIndent();
+  }
+
+  /**
+   * Write a paragraph end tag, closes any other open tags.
+   */
+  protected void writeEndParagraph() throws IOException
+  {
+    endOpenTags();
+    writeEndTag("</p>");
+  }
+
+  /**
+   * Writes the body of the HTML document.
+   */ 
+  protected void writeBody() throws IOException, BadLocationException
+  {
+    writeStartTag("<body>");
+
+    ElementIterator ei = getElementIterator();
+    Element e = ei.first();
+    boolean inParagraph = false;
+    do
+      {
+	if( e.isLeaf() )
+	  {
+	    boolean hasNL = (getText(e).indexOf(NEWLINE) != -1);
+	    if( !inParagraph && hasText( e ) )
+	      {
+		writeStartParagraph(e);
+		inParagraph = true;
+	      }
+
+	    if( hasText( e ) )
+	      writeContent(e, true);
+
+	    if( hasNL && inParagraph )
+	      {
+		writeEndParagraph();
+		inParagraph = false;
+	      }
+	    else
+	      endOpenTags();
+	  }
+      } 
+    while((e = ei.next()) != null);
+
+    writeEndTag("</body>");
+  }
+
+  protected void text(Element elem) throws IOException, BadLocationException
+  {
+    write( getText(elem).trim() );
+  }
+
+  /**
+   * Write bold, indent and underline tags.
+   */
+  protected void writeHTMLTags(AttributeSet attr) throws IOException
+  {
+    if(attr.getAttribute(StyleConstants.Bold) != null)
+      if(((Boolean)attr.getAttribute(StyleConstants.Bold)).booleanValue())
+	{
+	  write("<b>");
+	  tagStack.push("</b>");
+	}
+    if(attr.getAttribute(StyleConstants.Italic) != null)
+      if(((Boolean)attr.getAttribute(StyleConstants.Italic)).booleanValue())
+	{
+	  write("<i>");
+	  tagStack.push("</i>");
+	}
+    if(attr.getAttribute(StyleConstants.Underline) != null)
+      if(((Boolean)attr.getAttribute(StyleConstants.Underline)).booleanValue())
+	{
+	  write("<u>");
+	  tagStack.push("</u>");
+	}
+  }
+
+  /**
+   * Returns whether the element contains text or not.
+   */
+  protected boolean isText(Element elem) 
+  {
+    return (elem.getEndOffset() != elem.getStartOffset());
+  }
+
+  /**
+   * Writes the content of an element.
+   */
+  protected void writeContent(Element elem, boolean needsIndenting)
+    throws IOException, BadLocationException
+  {
+    writeNonHTMLAttributes(elem.getAttributes());
+    if(needsIndenting)
+      indent();
+    writeHTMLTags(elem.getAttributes());
+    if( isText(elem) )
+      text(elem);
+    else 
+      writeLeaf(elem);
+
+    endOpenTags();
+  }
+
+  /**
+   * Writes a non-text leaf element.
+   */
+  protected void writeLeaf(Element e) throws IOException
+  {
+    // NOTE: Haven't tested if this is correct.
+    if(e.getName().equals(StyleConstants.IconElementName))
+      writeImage(e);
+    else 
+      writeComponent(e);
+  }
+
+  /**
+   * Write the HTML attributes which do not have tag equivalents, 
+   * e.g. attributes other than bold/italic/underlined.
+   */
+  protected void writeNonHTMLAttributes(AttributeSet attr) throws IOException
+  {
+    String style = "";
+
+    // Alignment? Background?
+
+    if( StyleConstants.getForeground(attr) != null )
+      style = style + "color: " + 
+	getColor(StyleConstants.getForeground(attr)) + "; ";
+
+    style = style + "font-size: "+StyleConstants.getFontSize(attr)+"pt; ";
+    style = style + "font-family: "+StyleConstants.getFontFamily(attr);
+
+    startFontTag(style);
+  }
+
+  /**
+   * Write the styles used.
+   */
+  protected void writeStyles() throws IOException
+  {
+    if(doc instanceof DefaultStyledDocument)
+      {
+	Enumeration styles = ((DefaultStyledDocument)doc).getStyleNames();
+	while(styles.hasMoreElements())
+	  writeStyle(doc.getStyle((String)styles.nextElement()));
+      }
+    else
+      { // What else to do here?
+	Style s = (Style)doc.getStyle("default");
+	if(s != null)
+	  writeStyle( s );
+      }
+  }
+
+  /**
+   * Write a set of attributes.
+   */
+  protected void writeAttributes(AttributeSet attr) throws IOException
+  {
+    Enumeration attribs = attr.getAttributeNames();
+    while(attribs.hasMoreElements())
+      {
+	Object attribName = attribs.nextElement();
+	String name = attribName.toString();
+	String output = getAttribute(name, attr.getAttribute(attribName));
+	if( output != null )
+	  {
+	    indent();
+	    write( output + NEWLINE );
+	  }
+      }
+  }
+
+  /**
+   * Deliberately unimplemented, handles component elements.
+   */ 
+  protected void writeComponent(Element elem) throws IOException
+  {
+  }
+
+  /**
+   * Deliberately unimplemented. 
+   * Writes StyleConstants.IconElementName elements.
+   */ 
+  protected void writeImage(Element elem) throws IOException
+  {
+  }
+
+  // -------------------- Private methods. --------------------------------
+
+  /**
+   * Write a single style attribute
+   */
+  private String getAttribute(String name, Object a) throws IOException
+  {
+    if(name.equals("foreground"))
+      return "foreground:"+getColor((Color)a)+";";
+    if(name.equals("background"))
+      return "background:"+getColor((Color)a)+";";
+    if(name.equals("italic"))
+      return "italic:"+(((Boolean)a).booleanValue() ? "italic;" : ";");
+    if(name.equals("bold"))
+      return "bold:"+(((Boolean)a).booleanValue() ? "bold;" : "normal;");
+    if(name.equals("family"))
+      return "family:" + a + ";";
+    if(name.equals("size"))
+      {
+	int size = ((Integer)a).intValue();
+	int htmlSize;
+	if( size > 24 )
+	  htmlSize = 7;
+	else if( size > 18 )
+	  htmlSize = 6;
+	else if( size > 14 )
+	  htmlSize = 5;
+	else if( size > 12 )
+	  htmlSize = 4;
+	else if( size > 10 )
+	  htmlSize = 3;
+	else if( size > 8 )
+	  htmlSize = 2;
+	else
+	  htmlSize = 1;
+
+	return "size:" + htmlSize + ";";
+      }
+
+    return null;
+  }
+
+  /**
+   * Stupid that Color doesn't have a method for this.
+   */
+  private String getColor(Color c)
+  {
+    String r = "00" + Integer.toHexString(c.getRed());
+    r = r.substring(r.length() - 2);
+    String g = "00" + Integer.toHexString(c.getGreen());
+    g = g.substring(g.length() - 2);
+    String b = "00" + Integer.toHexString(c.getBlue());
+    b = b.substring(b.length() - 2);
+    return "#" + r + g + b;
+  }
+
+  /**
+   * Empty the stack of open tags
+   */
+  private void endOpenTags() throws IOException
+  {
+    while(!tagStack.empty())
+      write((String)tagStack.pop());
+
+    if( inFontTag() )
+      {
+	write(""+NEWLINE);
+	endFontTag();
+      }
+  }
+
+  /**
+   * Output a single style
+   */
+  private void writeStyle(Style s) throws IOException
+  {
+    if( s == null )
+      return;
+
+    writeStartTag("p."+s.getName()+" {");
+    writeAttributes(s);
+    writeEndTag("}");
+  }
+
+  private boolean hasText(Element e) throws BadLocationException
+  {
+    return (getText(e).trim().length() > 0);
+  }
+}
diff --git a/libjava/classpath/javax/swing/tree/AbstractLayoutCache.java b/libjava/classpath/javax/swing/tree/AbstractLayoutCache.java
index 8dbdd2f5e58b..155343f5bcc4 100644
--- a/libjava/classpath/javax/swing/tree/AbstractLayoutCache.java
+++ b/libjava/classpath/javax/swing/tree/AbstractLayoutCache.java
@@ -1,5 +1,5 @@
 /* AbstractLayoutCache.java --
-   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,13 +38,10 @@ exception statement from your version. */
 
 package javax.swing.tree;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Rectangle;
 import java.util.Enumeration;
 
 import javax.swing.event.TreeModelEvent;
-import javax.swing.tree.VariableHeightLayoutCache.NodeRecord;
 
 /**
  * class AbstractLayoutCache
@@ -275,7 +272,7 @@ public abstract class AbstractLayoutCache
     for (int i = 0; i < n; i++)
       {
         TreePath path = getPathForRow(i);
-        r.setBounds(0,0,0,0);        
+        r.setBounds(0, 0, 0, 0);        
         r = getBounds(path, r);
         if (r.x + r.width > maximalWidth)
           maximalWidth = r.x + r.width;
diff --git a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
index be8317f975cb..6951b9600052 100644
--- a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
+++ b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
@@ -887,8 +887,7 @@ public class DefaultMutableTreeNode
       return false;
     if (node == this)
       return true;
-    return (node.getParent() == getParent()
-            && getParent() != null);
+    return node.getParent() == getParent() && getParent() != null;
   }
 
   /**
@@ -1070,7 +1069,7 @@ public class DefaultMutableTreeNode
 
       public Object nextElement()
       {
-          if(queue.isEmpty())
+          if (queue.isEmpty())
               throw new NoSuchElementException("No more elements left.");
 
           TreeNode node = (TreeNode) queue.removeFirst();
@@ -1105,7 +1104,7 @@ public class DefaultMutableTreeNode
 
       public Object nextElement()
       {
-          if( next == null )
+          if (next == null)
               throw new NoSuchElementException("No more elements left.");
 
           Object current = next;
@@ -1121,7 +1120,7 @@ public class DefaultMutableTreeNode
       private TreeNode traverse(Enumeration children)
       {
           // If more children are available step down.
-          if( children.hasMoreElements() )
+          if (children.hasMoreElements())
           {
               TreeNode child = (TreeNode) children.nextElement();
               childrenEnums.push(child.children());
@@ -1134,7 +1133,7 @@ public class DefaultMutableTreeNode
 
           // If there are no more levels left, there is no next
           // element to return.
-          if ( childrenEnums.isEmpty() )
+          if (childrenEnums.isEmpty())
               return null;
           else
           {
@@ -1165,7 +1164,7 @@ public class DefaultMutableTreeNode
 
        public Object nextElement()
        {
-           if( nodes.isEmpty() )
+           if (nodes.isEmpty())
                throw new NoSuchElementException("No more elements left!");
 
            Enumeration children = (Enumeration) childrenEnums.peek();
@@ -1175,7 +1174,7 @@ public class DefaultMutableTreeNode
 
        private Object traverse(Enumeration children)
        {
-           if ( children.hasMoreElements() )
+           if (children.hasMoreElements())
            {
                TreeNode node = (TreeNode) children.nextElement();
                nodes.push(node);
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java b/libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java
index cc19501d2b68..b0a4d8db823f 100644
--- a/libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java
@@ -382,7 +382,6 @@ public class DefaultTreeCellEditor
     editingContainer = createContainer();
     setFont(UIManager.getFont("Tree.font"));
     setBorderSelectionColor(UIManager.getColor("Tree.selectionBorderColor"));
-    editingIcon = renderer.getIcon();
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java b/libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java
index 5e93145ae5cc..e120b71c1674 100644
--- a/libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -1,5 +1,5 @@
 /* DefaultTreeCellRenderer.java 
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2006, Free Software Foundation, Inc.
  
  This file is part of GNU Classpath.
 
@@ -47,16 +47,17 @@ import java.awt.Graphics;
 import java.awt.Insets;
 import java.awt.Rectangle;
 
-import javax.swing.border.Border;
 import javax.swing.Icon;
 import javax.swing.JLabel;
 import javax.swing.JTree;
-import javax.swing.UIManager;
+import javax.swing.LookAndFeel;
 import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
 import javax.swing.plaf.UIResource;
 
 /**
- * DefaultTreeCellRenderer
+ * A default implementation of the {@link TreeCellRenderer} interface.
  * 
  * @author Andrew Selkirk
  */
@@ -64,71 +65,81 @@ public class DefaultTreeCellRenderer
   extends JLabel
   implements TreeCellRenderer
 {
-  // -------------------------------------------------------------
-  // Variables --------------------------------------------------
-  // -------------------------------------------------------------
 
   /**
-   * selected
+   * A flag indicating the current selection status.
    */
   protected boolean selected;
 
   /**
-   * hasFocus
+   * A flag indicating the current focus status.
    */
   protected boolean hasFocus;
 
   /**
-   * drawsFocusBorderAroundIcon
+   * drawsFocusBorderAroundIcon  // FIXME: is this used?
    */
   private boolean drawsFocusBorderAroundIcon;
 
   /**
-   * closedIcon
+   * The icon used to represent non-leaf nodes that are closed.
+   * 
+   * @see #setClosedIcon(Icon)
    */
   protected transient Icon closedIcon;
 
   /**
-   * leafIcon
+   * The icon used to represent leaf nodes.
+   * 
+   * @see #setLeafIcon(Icon)
    */
   protected transient Icon leafIcon;
 
   /**
-   * openIcon
+   * The icon used to represent non-leaf nodes that are open.
+   * 
+   * @see #setOpenIcon(Icon)
    */
   protected transient Icon openIcon;
 
   /**
-   * textSelectionColor
+   * The color used for text in selected cells.
+   * 
+   * @see #setTextSelectionColor(Color)
    */
   protected Color textSelectionColor;
 
   /**
-   * textNonSelectionColor
+   * The color used for text in non-selected cells.
+   * 
+   * @see #setTextNonSelectionColor(Color)
    */
   protected Color textNonSelectionColor;
 
   /**
-   * backgroundSelectionColor
+   * The background color for selected cells.
+   * 
+   * @see #setBackgroundSelectionColor(Color)
    */
   protected Color backgroundSelectionColor;
 
   /**
-   * backgroundNonSelectionColor
+   * The background color for non-selected cells.
+   * 
+   * @see #setBackgroundNonSelectionColor(Color)
    */
   protected Color backgroundNonSelectionColor;
 
   /**
-   * borderSelectionColor
+   * The border color for selected tree cells.
+   * 
+   * @see #setBorderSelectionColor(Color)
    */
   protected Color borderSelectionColor;
 
-  // -------------------------------------------------------------
-  // Initialization ---------------------------------------------
-  // -------------------------------------------------------------
-
   /**
-   * Constructor DefaultTreeCellRenderer
+   * Creates a new tree cell renderer with defaults appropriate for the 
+   * current {@link LookAndFeel}.
    */
   public DefaultTreeCellRenderer()
   {
@@ -138,19 +149,17 @@ public class DefaultTreeCellRenderer
 
     setTextNonSelectionColor(UIManager.getColor("Tree.textForeground"));
     setTextSelectionColor(UIManager.getColor("Tree.selectionForeground"));
-    setBackgroundNonSelectionColor(UIManager.getColor("Tree.nonSelectionBackground"));
+    setBackgroundNonSelectionColor(UIManager.getColor("Tree.textBackground"));
     setBackgroundSelectionColor(UIManager.getColor("Tree.selectionBackground"));
     setBorderSelectionColor(UIManager.getColor("Tree.selectionBorderColor"));
   }
 
-  // -------------------------------------------------------------
-  // Methods ----------------------------------------------------
-  // -------------------------------------------------------------
-
   /**
-   * getDefaultOpenIcon
+   * Returns the default icon for non-leaf tree cells that are open (expanded).
+   * The icon is fetched from the defaults table for the current 
+   * {@link LookAndFeel} using the key <code>Tree.openIcon</code>.
    * 
-   * @returns Icon
+   * @return The default icon.
    */
   public Icon getDefaultOpenIcon()
   {
@@ -158,9 +167,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getDefaultClosedIcon
+   * Returns the default icon for non-leaf tree cells that are closed (not 
+   * expanded).  The icon is fetched from the defaults table for the current 
+   * {@link LookAndFeel} using the key <code>Tree.closedIcon</code>.
    * 
-   * @returns Icon
+   * @return The default icon.
    */
   public Icon getDefaultClosedIcon()
   {
@@ -168,9 +179,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getDefaultLeafIcon
+   * Returns the default icon for leaf tree cells.  The icon is fetched from 
+   * the defaults table for the current {@link LookAndFeel} using the key 
+   * <code>Tree.leafIcon</code>.
    * 
-   * @returns Icon
+   * @return The default icon.
    */
   public Icon getDefaultLeafIcon()
   {
@@ -178,20 +191,25 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setOpenIcon
+   * Sets the icon to be displayed for non-leaf nodes that are open (expanded).
+   * Set this to <code>null</code> if no icon is required.
+   * 
+   * @param icon  the icon (<code>null</code> permitted).
    * 
-   * @param i
-   *          the icon.
+   * @see #getOpenIcon()
    */
-  public void setOpenIcon(Icon i)
+  public void setOpenIcon(Icon icon)
   {
-    openIcon = i;
+    openIcon = icon;
   }
 
   /**
-   * getOpenIcon
+   * Returns the icon displayed for non-leaf nodes that are open (expanded).  
+   * The default value is initialised from the {@link LookAndFeel}.
    * 
-   * @returns Icon
+   * @return The open icon (possibly <code>null</code>).
+   * 
+   * @see #setOpenIcon(Icon)
    */
   public Icon getOpenIcon()
   {
@@ -199,20 +217,25 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setClosedIcon
+   * Sets the icon to be displayed for non-leaf nodes that are closed.  Set 
+   * this to <code>null</code> if no icon is required.
+   * 
+   * @param icon  the icon (<code>null</code> permitted).
    * 
-   * @param i
-   *          the icon.
+   * @see #getClosedIcon()
    */
-  public void setClosedIcon(Icon i)
+  public void setClosedIcon(Icon icon)
   {
-    closedIcon = i;
+    closedIcon = icon;
   }
 
   /**
-   * getClosedIcon
+   * Returns the icon displayed for non-leaf nodes that are closed.  The 
+   * default value is initialised from the {@link LookAndFeel}.
+   * 
+   * @return The closed icon (possibly <code>null</code>).
    * 
-   * @returns Icon
+   * @see #setClosedIcon(Icon)
    */
   public Icon getClosedIcon()
   {
@@ -220,20 +243,25 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setLeafIcon
+   * Sets the icon to be displayed for leaf nodes.  Set this to 
+   * <code>null</code> if no icon is required.
    * 
-   * @param i
-   *          the icon.
+   * @param icon  the icon (<code>null</code> permitted).
+   * 
+   * @see #getLeafIcon()
    */
-  public void setLeafIcon(Icon i)
+  public void setLeafIcon(Icon icon)
   {
-    leafIcon = i;
+    leafIcon = icon;
   }
 
   /**
-   * getLeafIcon
+   * Returns the icon displayed for leaf nodes.  The default value is 
+   * initialised from the {@link LookAndFeel}.
+   * 
+   * @return The leaf icon (possibly <code>null</code>).
    * 
-   * @returns Icon
+   * @see #setLeafIcon(Icon)
    */
   public Icon getLeafIcon()
   {
@@ -241,10 +269,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setTextSelectionColor
+   * Sets the text color for tree cells that are selected.
    * 
-   * @param c
-   *          the color.
+   * @param c  the color (<code>null</code> permitted).
+   * 
+   * @see #getTextSelectionColor()
    */
   public void setTextSelectionColor(Color c)
   {
@@ -252,9 +281,13 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getTextSelectionColor
+   * Returns the text color for tree cells that are selected.
+   * The default value is obtained from the {@link LookAndFeel} defaults
+   * table using the key <code>Tree.selectionForeground</code>.
+   * 
+   * @return The text color for tree cells that are selected.
    * 
-   * @returns Color
+   * @see #setTextSelectionColor(Color)
    */
   public Color getTextSelectionColor()
   {
@@ -262,10 +295,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setTextNonSelectionColor
+   * Sets the text color for tree cells that are not selected.
+   * 
+   * @param c  the color (<code>null</code> permitted).
    * 
-   * @param c
-   *          the color.
+   * @see #getTextNonSelectionColor()
    */
   public void setTextNonSelectionColor(Color c)
   {
@@ -273,9 +307,13 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getTextNonSelectionColor
+   * Returns the text color for tree cells that are not selected.
+   * The default value is obtained from the {@link LookAndFeel} defaults
+   * table using the key <code>Tree.selectionForeground</code>.
    * 
-   * @returns Color
+   * @return The background color for tree cells that are not selected.
+   * 
+   * @see #setTextgroundNonSelectionColor(Color)
    */
   public Color getTextNonSelectionColor()
   {
@@ -283,10 +321,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setBackgroundSelectionColor
+   * Sets the background color for tree cells that are selected.
+   * 
+   * @param c  the color (<code>null</code> permitted).
    * 
-   * @param c
-   *          the color.
+   * @see #getBackgroundSelectionColor()
    */
   public void setBackgroundSelectionColor(Color c)
   {
@@ -294,9 +333,13 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getBackgroundSelectionColor
+   * Returns the background color for tree cells that are selected.
+   * The default value is obtained from the {@link LookAndFeel} defaults
+   * table using the key <code>Tree.selectionBackground</code>.
    * 
-   * @returns Color
+   * @return The background color for tree cells that are selected.
+   * 
+   * @see #setBackgroundSelectionColor(Color)
    */
   public Color getBackgroundSelectionColor()
   {
@@ -304,10 +347,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setBackgroundNonSelectionColor
+   * Sets the background color for tree cells that are not selected.
+   * 
+   * @param c  the color (<code>null</code> permitted).
    * 
-   * @param c
-   *          the color.
+   * @see #getBackgroundNonSelectionColor()
    */
   public void setBackgroundNonSelectionColor(Color c)
   {
@@ -315,9 +359,13 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getBackgroundNonSelectionColor
+   * Returns the background color for tree cells that are not selected.
+   * The default value is obtained from the {@link LookAndFeel} defaults
+   * table using the key <code>Tree.textBackground</code>.
+   * 
+   * @return The background color for tree cells that are not selected.
    * 
-   * @returns Color
+   * @see #setBackgroundNonSelectionColor(Color)
    */
   public Color getBackgroundNonSelectionColor()
   {
@@ -325,10 +373,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setBorderSelectionColor
+   * Sets the border color for tree cells that are selected.
    * 
-   * @param c
-   *          the color.
+   * @param c  the color (<code>null</code> permitted).
+   * 
+   * @see #getBorderSelectionColor()
    */
   public void setBorderSelectionColor(Color c)
   {
@@ -336,9 +385,13 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getBorderSelectionColor
+   * Returns the border color for tree cells that are selected.
+   * The default value is obtained from the {@link LookAndFeel} defaults
+   * table using the key <code>Tree.selectionBorderColor</code>.
+   * 
+   * @return The border color for tree cells that are selected.
    * 
-   * @returns Color
+   * @see #setBorderSelectionColor(Color)
    */
   public Color getBorderSelectionColor()
   {
@@ -346,10 +399,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setFont
+   * Sets the font.
    * 
-   * @param f
-   *          the font.
+   * @param f the font.
+   * 
+   * @see #getFont()
    */
   public void setFont(Font f)
   {
@@ -359,10 +413,9 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * setBackground
+   * Sets the background color.
    * 
-   * @param c
-   *          the color.
+   * @param c the color.
    */
   public void setBackground(Color c)
   {
@@ -372,23 +425,18 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getTreeCellRendererComponent
+   * Returns a component (in fact <code>this</code>) that can be used to
+   * render a tree cell with the specified state.
+   * 
+   * @param tree  the tree that the cell belongs to.
+   * @param val  the cell value.
+   * @param selected  indicates whether or not the cell is selected.
+   * @param expanded  indicates whether or not the cell is expanded.
+   * @param leaf  indicates whether or not the cell is a leaf in the tree.
+   * @param row  the row index.
+   * @param hasFocus  indicates whether or not the cell has the focus.
    * 
-   * @param tree
-   *          TODO
-   * @param val
-   *          TODO
-   * @param selected
-   *          TODO
-   * @param expanded
-   *          TODO
-   * @param leaf
-   *          TODO
-   * @param row
-   *          TODO
-   * @param hasFocus
-   *          TODO
-   * @returns Component
+   * @return <code>this</code>.
    */
   public Component getTreeCellRendererComponent(JTree tree, Object val,
                                                 boolean selected,
@@ -433,9 +481,11 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * getFont
+   * Returns the current font.
+   * 
+   * @return The current font.
    * 
-   * @return the current Font
+   * @see #setFont(Font)
    */
   public Font getFont()
   {
@@ -460,7 +510,7 @@ public class DefaultTreeCellRenderer
       insets = border.getBorderInsets(this);
 
     FontMetrics fm = getToolkit().getFontMetrics(getFont());
-    SwingUtilities.layoutCompoundLabel(((JLabel) this), fm, getText(),
+    SwingUtilities.layoutCompoundLabel((JLabel) this, fm, getText(),
                                        getIcon(), getVerticalAlignment(),
                                        getHorizontalAlignment(),
                                        getVerticalTextPosition(),
@@ -471,7 +521,7 @@ public class DefaultTreeCellRenderer
     Rectangle bounds = getBounds(ir);
     
     bounds.x = tr.x - insets.left;
-    bounds.width = tr.width + insets.left+insets.right;
+    bounds.width = tr.width + insets.left + insets.right;
     
     g.setColor(super.getBackground());
     g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
@@ -491,9 +541,9 @@ public class DefaultTreeCellRenderer
   }
 
   /**
-   * returns the preferred size of the cell.
+   * Returns the preferred size of the cell.
    * 
-   * @returns Dimension
+   * @return The preferred size of the cell.
    */
   public Dimension getPreferredSize()
   {
@@ -502,7 +552,7 @@ public class DefaultTreeCellRenderer
     Rectangle tr = new Rectangle();
 
     FontMetrics fm = getToolkit().getFontMetrics(getFont());
-    SwingUtilities.layoutCompoundLabel(((JLabel) this), fm, getText(),
+    SwingUtilities.layoutCompoundLabel((JLabel) this, fm, getText(),
                                        getIcon(), getVerticalAlignment(),
                                        getHorizontalAlignment(),
                                        getVerticalTextPosition(),
@@ -510,182 +560,156 @@ public class DefaultTreeCellRenderer
                                        getIconTextGap());
     Rectangle cr = ir.union(tr);
     return new Dimension(cr.width, cr.height);
-  } // getPreferredSize()
+  } 
 
   /**
-   * validate
+   * For performance reasons, this method is overridden to do nothing.
    */
   public void validate()
   {
     // Overridden for performance reasons.
-  } // validate()
+  } 
 
   /**
-   * revalidate
+   * For performance reasons, this method is overridden to do nothing.
    */
   public void revalidate()
   {
     // Overridden for performance reasons.
-  } // revalidate()
+  } 
 
   /**
-   * repaint
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
-   * @param value3
-   *          TODO
-   * @param value4
-   *          TODO
+   * @param tm ignored
+   * @param x coordinate of the region to mark as dirty
+   * @param y coordinate of the region to mark as dirty
+   * @param width dimension of the region to mark as dirty
+   * @param height dimension of the region to mark as dirty
    */
-  public void repaint(long value0, int value1, int value2, int value3,
-                      int value4)
+  public void repaint(long tm, int x, int y, int width, int height)
   {
     // Overridden for performance reasons.
-  } // repaint()
+  } 
 
   /**
-   * repaint
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
+   * @param area  the area to repaint.
    */
-  public void repaint(Rectangle value0)
+  public void repaint(Rectangle area)
   {
     // Overridden for performance reasons.
-  } // repaint()
+  } 
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  protected void firePropertyChange(String value0, Object value1, Object value2)
+  protected void firePropertyChange(String name, Object oldValue, 
+                                    Object newValue)
   {
     // Overridden for performance reasons.
-  } // firePropertyChange()
+  }
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String value0, byte value1, byte value2)
+  public void firePropertyChange(String name, byte oldValue, byte newValue)
   {
     // Overridden for performance reasons.
-  } // firePropertyChange()
+  }
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String value0, char value1, char value2)
+  public void firePropertyChange(String name, char oldValue, char newValue)
   {
     // Overridden for performance reasons.
-  } // firePropertyChange()
+  }
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String value0, short value1, short value2)
+  public void firePropertyChange(String name, short oldValue, short newValue)
   {
     // Overridden for performance reasons.
-  } // firePropertyChange()
+  } 
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String value0, int value1, int value2)
+  public void firePropertyChange(String name, int oldValue, int newValue)
   {
     // Overridden for performance reasons.
-  } // firePropertyChange()
+  }
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String value0, long value1, long value2)
+  public void firePropertyChange(String name, long oldValue, long newValue)
   {
     // Overridden for performance reasons.
-  } // firePropertyChange()
+  }
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0
-   *          TODO
-   * @param value1
-   *          TODO
-   * @param value2
-   *          TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String value0, float value1, float value2)
+  public void firePropertyChange(String name, float oldValue, float newValue)
   {
     // Overridden for performance reasons.
-  } // firePropertyChange()
+  }
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param value0 TODO
-   * @param value1 TODO
-   * @param value2 TODO
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String value0, double value1, double value2)
+  public void firePropertyChange(String name, double oldValue, double newValue)
   {
     //  Overridden for performance reasons.
-  } // firePropertyChange()
+  }
 
   /**
-   * firePropertyChange
+   * For performance reasons, this method is overridden to do nothing.
    * 
-   * @param name the property name.
-   * @param v1 the old value.
-   * @param v2 the new value.
+   * @param name  the property name.
+   * @param oldValue  the old value.
+   * @param newValue  the new value.
    */
-  public void firePropertyChange(String name, boolean v1, boolean v2)
+  public void firePropertyChange(String name, boolean oldValue, 
+                                 boolean newValue)
   {
     //  Overridden for performance reasons.
-  } // firePropertyChange()
+  } 
 
-} // DefaultTreeCellRenderer
+} 
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeModel.java b/libjava/classpath/javax/swing/tree/DefaultTreeModel.java
index c1ca679d006b..5819d15b627a 100644
--- a/libjava/classpath/javax/swing/tree/DefaultTreeModel.java
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeModel.java
@@ -1,5 +1,5 @@
 /* DefaultTreeModel.java -- 
-   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc.
  
 This file is part of GNU Classpath.
 
@@ -37,8 +37,6 @@ exception statement from your version. */
 
 package javax.swing.tree;
 
-import gnu.classpath.NotImplementedException;
-
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -62,7 +60,7 @@ public class DefaultTreeModel
   /**
    * root
    */
-  protected TreeNode root = null;
+  protected TreeNode root;
 
   /**
    * listenerList
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java b/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
index 0676f7ec8f46..0684ef766590 100644
--- a/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
@@ -147,9 +147,9 @@ public class DefaultTreeSelectionModel
     
     // Clone the selection and the list selection model.
     cloned.selection = (TreePath[]) selection.clone();
-    if (listSelectionModel!=null)
-      cloned.listSelectionModel = 
-        (DefaultListSelectionModel) listSelectionModel.clone();
+    if (listSelectionModel != null)
+      cloned.listSelectionModel 
+        = (DefaultListSelectionModel) listSelectionModel.clone();
     return cloned;
   }
 
@@ -171,7 +171,7 @@ public class DefaultTreeSelectionModel
             b.append(getRow(selection[i]));
             b.append(' ');
           }
-        b.append(", lead "+getLeadSelectionRow());
+        b.append(", lead " + getLeadSelectionRow());
         return b.toString();
       }
   }
@@ -360,7 +360,7 @@ public class DefaultTreeSelectionModel
           }
       }
     
-     if (path!=leadPath)
+     if (path != leadPath)
        {
         TreePath oldLead = leadPath;
         leadPath = path;
@@ -445,7 +445,7 @@ public class DefaultTreeSelectionModel
         
         // If the removed path was the lead path, set the lead path to null.
         TreePath oldLead = leadPath;
-        if (path!=null && leadPath!=null && path.equals(leadPath))
+        if (path != null && leadPath != null && path.equals(leadPath))
           leadPath = null;
 
         fireValueChanged(new TreeSelectionEvent(this, path, false, oldLead,
@@ -564,7 +564,7 @@ public class DefaultTreeSelectionModel
    */
   public boolean isSelectionEmpty()
   {
-    return ((selection == null) || (selection.length == 0));
+    return (selection == null) || (selection.length == 0);
   }
 
   /**
@@ -841,7 +841,7 @@ public class DefaultTreeSelectionModel
     if (leadIndex > 0 && leadIndex < selection.length)
       setSelectionPath(selection[leadIndex]);
     else
-      setSelectionPath(selection[selection.length -1]);
+      setSelectionPath(selection[selection.length - 1]);
   }
   
   /**
@@ -882,7 +882,7 @@ public class DefaultTreeSelectionModel
 
     for (int i = 1; i < rows.length; i++)
       {
-        if (rows[i-1] != rows[i] - 1)
+        if (rows[i - 1] != rows[i] - 1)
           return false;
       }
     return true;
diff --git a/libjava/classpath/javax/swing/tree/ExpandVetoException.java b/libjava/classpath/javax/swing/tree/ExpandVetoException.java
index 1c8827c8a6c0..57531d542007 100644
--- a/libjava/classpath/javax/swing/tree/ExpandVetoException.java
+++ b/libjava/classpath/javax/swing/tree/ExpandVetoException.java
@@ -1,5 +1,5 @@
 /* ExpandVetoException.java --
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -37,47 +37,40 @@ exception statement from your version. */
 
 package javax.swing.tree;
 
-// Imports
 import javax.swing.event.TreeExpansionEvent;
 
 /**
  * ExpandVetoException
  * @author Andrew Selkirk
  */
-public class ExpandVetoException extends Exception {
-
-	//-------------------------------------------------------------
-	// Variables --------------------------------------------------
-	//-------------------------------------------------------------
-	
-	/**
-	 * event
-	 */
-	protected TreeExpansionEvent	event	= null;
-
-
-	//-------------------------------------------------------------
-	// Initialization ---------------------------------------------
-	//-------------------------------------------------------------
-
-	/**
-	 * Constructor ExpandVetoException
-	 * @param event Tree Expansion Event
-	 */
-	public ExpandVetoException(TreeExpansionEvent event) {
-		super();
-		this.event = event;
-	} // ExpandVetoException()
-
-	/**
-	 * Constructor ExpandVetoException
-	 * @param event Tree Expansion Event
-	 * @param message Message
-	 */
-	public ExpandVetoException(TreeExpansionEvent event, String message) {
-		super(message);
-		this.event = event;
-	} // ExpandVetoException()
-
-
-} // ExpandVetoException
+public class ExpandVetoException extends Exception 
+{
+
+  /**
+   * event
+   */
+  protected TreeExpansionEvent event;
+
+
+  /**
+   * Constructor ExpandVetoException
+   * @param event Tree Expansion Event
+   */
+  public ExpandVetoException(TreeExpansionEvent event) 
+  {
+    super();
+    this.event = event;
+  } 
+
+  /**
+   * Constructor ExpandVetoException
+   * @param event Tree Expansion Event
+   * @param message Message
+   */
+  public ExpandVetoException(TreeExpansionEvent event, String message) 
+  {
+    super(message);
+    this.event = event;
+  } 
+
+} 
diff --git a/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java b/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java
index 96655ce75fdd..a699a6c9f21a 100644
--- a/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java
+++ b/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java
@@ -163,7 +163,7 @@ public class FixedHeightLayoutCache
     {
       // This method may be called in the context when the tree rectangle is
       // not known. To work around this, it is assumed near infinitely large.
-      if (bounds==null)
+      if (bounds == null)
         bounds = getNodeDimensions(node, row, depth, isExpanded, 
                                    new Rectangle());
       return bounds;      
@@ -266,7 +266,7 @@ public class FixedHeightLayoutCache
     if (expanded.contains(node))
       {
         int sc = treeModel.getChildCount(node);
-        int deeper = depth+1;
+        int deeper = depth + 1;
         for (int i = 0; i < sc; i++)
           {
             Object child = treeModel.getChild(node, i);
@@ -283,7 +283,7 @@ public class FixedHeightLayoutCache
   public void invalidatePathBounds(TreePath path)
   {
     NodeRecord r = (NodeRecord) nodes.get(path.getLastPathComponent());
-    if (r!=null)
+    if (r != null)
       r.bounds = null;
   } 
 
diff --git a/libjava/classpath/javax/swing/tree/RowMapper.java b/libjava/classpath/javax/swing/tree/RowMapper.java
index 690efb77e326..59eb1e3a9fab 100644
--- a/libjava/classpath/javax/swing/tree/RowMapper.java
+++ b/libjava/classpath/javax/swing/tree/RowMapper.java
@@ -1,5 +1,5 @@
 /* RowMapper.java --
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -41,14 +41,14 @@ package javax.swing.tree;
  * RowMapper public interface
  * @author Andrew Selkirk
  */
-public interface RowMapper {
+public interface RowMapper 
+{
 
-	/**
-	 * getRowsForPaths
-	 * @param path TreePath
-	 * @return TODO
-	 */
-	int[] getRowsForPaths(TreePath[] path);
+  /**
+   * getRowsForPaths
+   * @param path TreePath
+   * @return TODO
+   */
+  int[] getRowsForPaths(TreePath[] path);
 
-
-} // RowMapper
+} 
\ No newline at end of file
diff --git a/libjava/classpath/javax/swing/tree/TreeNode.java b/libjava/classpath/javax/swing/tree/TreeNode.java
index 94f2c69f8958..ae7380c703b4 100644
--- a/libjava/classpath/javax/swing/tree/TreeNode.java
+++ b/libjava/classpath/javax/swing/tree/TreeNode.java
@@ -45,7 +45,8 @@ import java.util.Enumeration;
  * 
  * @author Andrew Selkirk
  */
-public interface TreeNode {
+public interface TreeNode 
+{
 
   /**
    * Returns the parent node for this tree node, or <code>null</code> if this
diff --git a/libjava/classpath/javax/swing/tree/TreePath.java b/libjava/classpath/javax/swing/tree/TreePath.java
index 4671c4be54be..93b59b07edf7 100644
--- a/libjava/classpath/javax/swing/tree/TreePath.java
+++ b/libjava/classpath/javax/swing/tree/TreePath.java
@@ -262,14 +262,16 @@ public class TreePath implements Serializable
     if (path == null)
       return false;
     int count = getPathCount();
-    if (path.getPathCount() < count)
+    int otherPathLength = path.getPathCount();
+    if (otherPathLength < count)
       return false;
-    for (int i = 0; i < count; i++)
-    {
-      if (!this.path[i].equals(path.getPathComponent(i)))
-        return false;
-    }
-    return true;
+    while (otherPathLength > count)
+      {
+        otherPathLength--;
+        path = path.getParentPath();
+      }
+    
+    return equals(path);
   }
 
   /**
diff --git a/libjava/classpath/javax/swing/tree/TreeSelectionModel.java b/libjava/classpath/javax/swing/tree/TreeSelectionModel.java
index 4072ccc64c5b..9bdc99be350b 100644
--- a/libjava/classpath/javax/swing/tree/TreeSelectionModel.java
+++ b/libjava/classpath/javax/swing/tree/TreeSelectionModel.java
@@ -1,5 +1,5 @@
 /* TreeSelectionModel.java --
-   Copyright (C) 2002, 2004  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -46,39 +46,67 @@ import javax.swing.event.TreeSelectionListener;
  * TreeSelectionModel public interface
  * @author Andrew Selkirk
  */
-public interface TreeSelectionModel {
-
-	int SINGLE_TREE_SELECTION			= 1;
-	int CONTIGUOUS_TREE_SELECTION		= 2;
-	int DISCONTIGUOUS_TREE_SELECTION	= 4;
-
-	void setSelectionMode(int mode);
-	int getSelectionMode();
-	void setSelectionPath(TreePath path);
-	void setSelectionPaths(TreePath[] paths);
-	void addSelectionPath(TreePath path);
-	void addSelectionPaths(TreePath[] paths);
-	void removeSelectionPath(TreePath path);
-	void removeSelectionPaths(TreePath[] paths);
-	TreePath getSelectionPath();
-	TreePath[] getSelectionPaths();
-	int getSelectionCount();
-	boolean isPathSelected(TreePath path);
-	boolean isSelectionEmpty();
-	void clearSelection();
-	void setRowMapper(RowMapper newMapper);
-	RowMapper getRowMapper();
-	int[] getSelectionRows();
-	int getMinSelectionRow();
-	int getMaxSelectionRow();
-	boolean isRowSelected(int row);
-	void resetRowSelection();
-	int getLeadSelectionRow();
-	TreePath getLeadSelectionPath();
-	void addPropertyChangeListener(PropertyChangeListener listener);
-	void removePropertyChangeListener(PropertyChangeListener listener);
-	void addTreeSelectionListener(TreeSelectionListener x);
-	void removeTreeSelectionListener(TreeSelectionListener x);
-
-
-} // TreeSelectionModel
+public interface TreeSelectionModel 
+{
+
+  int SINGLE_TREE_SELECTION = 1;
+
+  int CONTIGUOUS_TREE_SELECTION = 2;
+
+  int DISCONTIGUOUS_TREE_SELECTION = 4;
+
+  void setSelectionMode(int mode);
+
+  int getSelectionMode();
+
+  void setSelectionPath(TreePath path);
+
+  void setSelectionPaths(TreePath[] paths);
+
+  void addSelectionPath(TreePath path);
+
+  void addSelectionPaths(TreePath[] paths);
+
+  void removeSelectionPath(TreePath path);
+
+  void removeSelectionPaths(TreePath[] paths);
+
+  TreePath getSelectionPath();
+
+  TreePath[] getSelectionPaths();
+
+  int getSelectionCount();
+
+  boolean isPathSelected(TreePath path);
+
+  boolean isSelectionEmpty();
+
+  void clearSelection();
+
+  void setRowMapper(RowMapper newMapper);
+
+  RowMapper getRowMapper();
+
+  int[] getSelectionRows();
+
+  int getMinSelectionRow();
+
+  int getMaxSelectionRow();
+
+  boolean isRowSelected(int row);
+
+  void resetRowSelection();
+
+  int getLeadSelectionRow();
+
+  TreePath getLeadSelectionPath();
+
+  void addPropertyChangeListener(PropertyChangeListener listener);
+
+  void removePropertyChangeListener(PropertyChangeListener listener);
+
+  void addTreeSelectionListener(TreeSelectionListener x);
+
+  void removeTreeSelectionListener(TreeSelectionListener x);
+
+}
diff --git a/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
index a9ed552e6354..0a787f7ca8ca 100644
--- a/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
+++ b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
@@ -162,7 +162,7 @@ public class VariableHeightLayoutCache
     {
       // This method may be called in the context when the tree rectangle is
       // not known. To work around this, it is assumed near infinitely large.
-      if (bounds==null)
+      if (bounds == null)
         bounds = getNodeDimensions(node, row, depth, isExpanded, 
                                    new Rectangle());
       return bounds;      
@@ -232,6 +232,9 @@ public class VariableHeightLayoutCache
     
     totalHeight = maximalWidth = 0;
 
+    if (treeModel == null)
+      return;
+
     Object root = treeModel.getRoot();
 
     if (rootVisible)
@@ -265,7 +268,7 @@ public class VariableHeightLayoutCache
     if (expanded.contains(node))
       {
         int sc = treeModel.getChildCount(node);
-        int deeper = depth+1;
+        int deeper = depth + 1;
         for (int i = 0; i < sc; i++)
           {
             Object child = treeModel.getChild(node, i);
@@ -282,7 +285,7 @@ public class VariableHeightLayoutCache
   public void invalidatePathBounds(TreePath path)
   {
     NodeRecord r = (NodeRecord) nodes.get(path.getLastPathComponent());
-    if (r!=null)
+    if (r != null)
       r.bounds = null;
   } 
 
@@ -555,9 +558,16 @@ public class VariableHeightLayoutCache
   public void setModel(TreeModel newModel)
   {
     treeModel = newModel;
-    // The root node is expanded by default.
-    expanded.add(treeModel.getRoot());
-    dirty = true;
+    // We need to clear the table and update the layout,
+    // so that we don't end up with wrong data in the tables.
+    expanded.clear();
+    update();
+    if (treeModel != null)
+      {
+        // The root node is expanded by default.
+        expanded.add(treeModel.getRoot());
+        dirty = true;
+      }
   }
   
   /**
diff --git a/libjava/classpath/lib/Makefile.in b/libjava/classpath/lib/Makefile.in
index b4818aab576a..00594b556072 100644
--- a/libjava/classpath/lib/Makefile.in
+++ b/libjava/classpath/lib/Makefile.in
@@ -69,8 +69,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -97,8 +95,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -121,6 +123,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -136,9 +140,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -160,6 +163,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -173,6 +177,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -186,6 +192,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -205,11 +212,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/Makefile.in b/libjava/classpath/native/Makefile.in
index e3ab7e7732dd..a05b06dd7846 100644
--- a/libjava/classpath/native/Makefile.in
+++ b/libjava/classpath/native/Makefile.in
@@ -72,8 +72,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -100,8 +98,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -124,6 +126,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -139,9 +143,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -163,6 +166,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -176,6 +180,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -189,6 +195,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -208,11 +215,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/fdlibm/Makefile.in b/libjava/classpath/native/fdlibm/Makefile.in
index d759292e9e4d..d5c2e0608fa6 100644
--- a/libjava/classpath/native/fdlibm/Makefile.in
+++ b/libjava/classpath/native/fdlibm/Makefile.in
@@ -91,8 +91,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -119,8 +117,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -143,6 +145,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -158,9 +162,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -182,6 +185,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -195,6 +199,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -208,6 +214,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -227,11 +234,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jawt/.cvsignore b/libjava/classpath/native/jawt/.cvsignore
new file mode 100644
index 000000000000..e9f2658a6943
--- /dev/null
+++ b/libjava/classpath/native/jawt/.cvsignore
@@ -0,0 +1,8 @@
+*.o
+*.a
+*.lo
+*.la
+.libs
+.deps
+Makefile
+Makefile.in
diff --git a/libjava/classpath/native/jawt/Makefile.am b/libjava/classpath/native/jawt/Makefile.am
index eae2181398e1..01abf3bb9345 100644
--- a/libjava/classpath/native/jawt/Makefile.am
+++ b/libjava/classpath/native/jawt/Makefile.am
@@ -1,20 +1,12 @@
-## GCJ LOCAL: install this library in GCJ's versioned library
-## directory
-gcc_version := $(shell cat $(top_srcdir)/../../gcc/BASE-VER)
-gcjversionedlibdir = $(libdir)/gcj-$(gcc_version)
-gcjversionedlib_LTLIBRARIES = libjawt.la
+nativeexeclib_LTLIBRARIES = libjawt.la
 
 libjawt_la_SOURCES = jawt.c
 libjawt_la_LIBADD = $(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
 
-## GCJ LOCAL: encode the library path and  use GCJ's library version
-libjawt_la_LDFLAGS = -rpath $(gcjversionedlibdir) \
-	-version-info `grep -v '^\#' $(top_srcdir)/../libtool-version`
-
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ @XTEST_LIBS@
 AM_CPPFLAGS = @CLASSPATH_INCLUDES@
 
 # Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
 # headers contain broken prototypes (by design, see gtkitemfactory.h).
 AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
-            @GTK_CFLAGS@ @CAIRO_CFLAGS@ @PANGOFT2_CFLAGS@
+            @GTK_CFLAGS@ @PANGOFT2_CFLAGS@
diff --git a/libjava/classpath/native/jawt/Makefile.in b/libjava/classpath/native/jawt/Makefile.in
index e2298c01965d..683bbb9dea53 100644
--- a/libjava/classpath/native/jawt/Makefile.in
+++ b/libjava/classpath/native/jawt/Makefile.in
@@ -58,9 +58,9 @@ am__vpath_adj = case $$p in \
     *) f=$$p;; \
   esac;
 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
-am__installdirs = "$(DESTDIR)$(gcjversionedlibdir)"
-gcjversionedlibLTLIBRARIES_INSTALL = $(INSTALL)
-LTLIBRARIES = $(gcjversionedlib_LTLIBRARIES)
+am__installdirs = "$(DESTDIR)$(nativeexeclibdir)"
+nativeexeclibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(nativeexeclib_LTLIBRARIES)
 libjawt_la_DEPENDENCIES =  \
 	$(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
 am_libjawt_la_OBJECTS = jawt.lo
@@ -91,8 +91,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -119,8 +117,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -143,6 +145,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -158,9 +162,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -182,6 +185,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -195,6 +199,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -208,6 +214,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -227,11 +234,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
@@ -286,21 +295,16 @@ target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
 vm_classes = @vm_classes@
-gcc_version := $(shell cat $(top_srcdir)/../../gcc/BASE-VER)
-gcjversionedlibdir = $(libdir)/gcj-$(gcc_version)
-gcjversionedlib_LTLIBRARIES = libjawt.la
+nativeexeclib_LTLIBRARIES = libjawt.la
 libjawt_la_SOURCES = jawt.c
 libjawt_la_LIBADD = $(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
-libjawt_la_LDFLAGS = -rpath $(gcjversionedlibdir) \
-	-version-info `grep -v '^\#' $(top_srcdir)/../libtool-version`
-
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ @XTEST_LIBS@
 AM_CPPFLAGS = @CLASSPATH_INCLUDES@
 
 # Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
 # headers contain broken prototypes (by design, see gtkitemfactory.h).
 AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
-            @GTK_CFLAGS@ @CAIRO_CFLAGS@ @PANGOFT2_CFLAGS@
+            @GTK_CFLAGS@ @PANGOFT2_CFLAGS@
 
 all: all-am
 
@@ -335,35 +339,35 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-install-gcjversionedlibLTLIBRARIES: $(gcjversionedlib_LTLIBRARIES)
+install-nativeexeclibLTLIBRARIES: $(nativeexeclib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
-	test -z "$(gcjversionedlibdir)" || $(mkdir_p) "$(DESTDIR)$(gcjversionedlibdir)"
-	@list='$(gcjversionedlib_LTLIBRARIES)'; for p in $$list; do \
+	test -z "$(nativeexeclibdir)" || $(mkdir_p) "$(DESTDIR)$(nativeexeclibdir)"
+	@list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
 	    f=$(am__strip_dir) \
-	    echo " $(LIBTOOL) --mode=install $(gcjversionedlibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(gcjversionedlibdir)/$$f'"; \
-	    $(LIBTOOL) --mode=install $(gcjversionedlibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(gcjversionedlibdir)/$$f"; \
+	    echo " $(LIBTOOL) --mode=install $(nativeexeclibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(nativeexeclibdir)/$$f'"; \
+	    $(LIBTOOL) --mode=install $(nativeexeclibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(nativeexeclibdir)/$$f"; \
 	  else :; fi; \
 	done
 
-uninstall-gcjversionedlibLTLIBRARIES:
+uninstall-nativeexeclibLTLIBRARIES:
 	@$(NORMAL_UNINSTALL)
-	@set -x; list='$(gcjversionedlib_LTLIBRARIES)'; for p in $$list; do \
+	@set -x; list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
 	  p=$(am__strip_dir) \
-	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(gcjversionedlibdir)/$$p'"; \
-	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(gcjversionedlibdir)/$$p"; \
+	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(nativeexeclibdir)/$$p'"; \
+	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(nativeexeclibdir)/$$p"; \
 	done
 
-clean-gcjversionedlibLTLIBRARIES:
-	-test -z "$(gcjversionedlib_LTLIBRARIES)" || rm -f $(gcjversionedlib_LTLIBRARIES)
-	@list='$(gcjversionedlib_LTLIBRARIES)'; for p in $$list; do \
+clean-nativeexeclibLTLIBRARIES:
+	-test -z "$(nativeexeclib_LTLIBRARIES)" || rm -f $(nativeexeclib_LTLIBRARIES)
+	@list='$(nativeexeclib_LTLIBRARIES)'; for p in $$list; do \
 	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
 	  test "$$dir" != "$$p" || dir=.; \
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
 libjawt.la: $(libjawt_la_OBJECTS) $(libjawt_la_DEPENDENCIES) 
-	$(LINK) -rpath $(gcjversionedlibdir) $(libjawt_la_LDFLAGS) $(libjawt_la_OBJECTS) $(libjawt_la_LIBADD) $(LIBS)
+	$(LINK) -rpath $(nativeexeclibdir) $(libjawt_la_LDFLAGS) $(libjawt_la_OBJECTS) $(libjawt_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -483,7 +487,7 @@ check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES)
 installdirs:
-	for dir in "$(DESTDIR)$(gcjversionedlibdir)"; do \
+	for dir in "$(DESTDIR)$(nativeexeclibdir)"; do \
 	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
 	done
 install: install-am
@@ -512,7 +516,7 @@ maintainer-clean-generic:
 	@echo "it deletes files that may require special tools to rebuild."
 clean: clean-am
 
-clean-am: clean-gcjversionedlibLTLIBRARIES clean-generic clean-libtool \
+clean-am: clean-generic clean-libtool clean-nativeexeclibLTLIBRARIES \
 	mostlyclean-am
 
 distclean: distclean-am
@@ -531,9 +535,9 @@ info: info-am
 
 info-am:
 
-install-data-am: install-gcjversionedlibLTLIBRARIES
+install-data-am:
 
-install-exec-am:
+install-exec-am: install-nativeexeclibLTLIBRARIES
 
 install-info: install-info-am
 
@@ -559,21 +563,20 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am: uninstall-gcjversionedlibLTLIBRARIES uninstall-info-am
+uninstall-am: uninstall-info-am uninstall-nativeexeclibLTLIBRARIES
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean \
-	clean-gcjversionedlibLTLIBRARIES clean-generic clean-libtool \
-	ctags distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-exec install-exec-am \
-	install-gcjversionedlibLTLIBRARIES install-info \
-	install-info-am install-man install-strip installcheck \
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-nativeexeclibLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am install-man \
+	install-nativeexeclibLTLIBRARIES install-strip installcheck \
 	installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags uninstall uninstall-am \
-	uninstall-gcjversionedlibLTLIBRARIES uninstall-info-am
+	tags uninstall uninstall-am uninstall-info-am \
+	uninstall-nativeexeclibLTLIBRARIES
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/libjava/classpath/native/jni/Makefile.in b/libjava/classpath/native/jni/Makefile.in
index 3bdeee20e4d6..30e9f37fca62 100644
--- a/libjava/classpath/native/jni/Makefile.in
+++ b/libjava/classpath/native/jni/Makefile.in
@@ -72,8 +72,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -100,8 +98,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -124,6 +126,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -139,9 +143,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -163,6 +166,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -176,6 +180,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -189,6 +195,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -208,11 +215,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/classpath/Makefile.in b/libjava/classpath/native/jni/classpath/Makefile.in
index b2e89f4934db..967dd6e8140d 100644
--- a/libjava/classpath/native/jni/classpath/Makefile.in
+++ b/libjava/classpath/native/jni/classpath/Makefile.in
@@ -82,8 +82,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -110,8 +108,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -134,6 +136,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -149,9 +153,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -173,6 +176,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -186,6 +190,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -199,6 +205,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -218,11 +225,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/classpath/jcl.h b/libjava/classpath/native/jni/classpath/jcl.h
index 514b7826291e..d358aeb9c854 100644
--- a/libjava/classpath/native/jni/classpath/jcl.h
+++ b/libjava/classpath/native/jni/classpath/jcl.h
@@ -1,5 +1,5 @@
 /* jcl.h
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -50,6 +50,10 @@ typedef jlong jpointer;
 #error "Unknown pointer size"
 #endif
 
+/* Helper macros for going between pointers and jlongs.  */
+#define JLONG_TO_PTR(T,P) ((T *)(long)P)
+#define PTR_TO_JLONG(P) ((jlong)(long)P)
+
 JNIEXPORT jclass JNICALL JCL_FindClass (JNIEnv * env, const char *className);
 JNIEXPORT void JNICALL JCL_ThrowException (JNIEnv * env,
 					   const char *className,
diff --git a/libjava/classpath/native/jni/gtk-peer/.cvsignore b/libjava/classpath/native/jni/gtk-peer/.cvsignore
new file mode 100644
index 000000000000..e9f2658a6943
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/.cvsignore
@@ -0,0 +1,8 @@
+*.o
+*.a
+*.lo
+*.la
+.libs
+.deps
+Makefile
+Makefile.in
diff --git a/libjava/classpath/native/jni/gtk-peer/Makefile.am b/libjava/classpath/native/jni/gtk-peer/Makefile.am
index cdee1e5a7907..fda823c04274 100644
--- a/libjava/classpath/native/jni/gtk-peer/Makefile.am
+++ b/libjava/classpath/native/jni/gtk-peer/Makefile.am
@@ -4,21 +4,18 @@ gcc_version := $(shell cat $(top_srcdir)/../../gcc/BASE-VER)
 gcjversionedlibdir = $(libdir)/gcj-$(gcc_version)
 gcjversionedlib_LTLIBRARIES = libgtkpeer.la
 
-# Gtk/Cairo JNI sources.
-if GTK_CAIRO
-  gtk_cairo_c_source_files = \
-    gnu_java_awt_peer_gtk_GdkGraphics2D.c
-else
-  gtk_cairo_c_source_files =
-endif
-
-libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
+# GTK JNI sources.
+libgtkpeer_la_SOURCES = gnu_java_awt_peer_gtk_CairoSurface.c \
+			gnu_java_awt_peer_gtk_CairoGraphics2D.c \
+			gnu_java_awt_peer_gtk_ComponentGraphics.c \
+			gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c \
+			gnu_java_awt_peer_gtk_FreetypeGlyphVector.c \
 			gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \
 			gnu_java_awt_peer_gtk_GdkFontPeer.c \
-			gnu_java_awt_peer_gtk_GdkGraphics.c \
 			gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c \
 			gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \
 			gnu_java_awt_peer_gtk_GdkRobotPeer.c \
+			gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c \
 			gnu_java_awt_peer_gtk_GdkTextLayout.c \
 			gnu_java_awt_peer_gtk_GtkButtonPeer.c \
 			gnu_java_awt_peer_gtk_GtkCanvasPeer.c \
@@ -48,10 +45,12 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
 			gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \
 			gnu_java_awt_peer_gtk_GtkToolkit.c \
 			gnu_java_awt_peer_gtk_GtkWindowPeer.c \
+			gnu_java_awt_peer_gtk_GtkVolatileImage.c \
+			cairographics2d.h \
 			gthread-jni.c \
+			gdkdisplay.h \
 			gdkfont.h \
 			gthread-jni.h \
-			gtkcairopeer.h \
 			gtk_jawt.c \
 			gtkpeer.h
 
@@ -62,12 +61,12 @@ libgtkpeer_la_LDFLAGS = -rpath $(gcjversionedlibdir) \
 libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \
 		       $(top_builddir)/native/jni/classpath/jcl.lo
 
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @FREETYPE2_LIBS@ \
-             @PANGOFT2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ -lX11 -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @FREETYPE2_LIBS@ \
+             @PANGOFT2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ @XTEST_LIBS@
 AM_CPPFLAGS = @CLASSPATH_INCLUDES@
 
 # Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
 # headers contain broken prototypes (by design, see gtkitemfactory.h).
 AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
-            @GTK_CFLAGS@ @CAIRO_CFLAGS@ @FREETYPE2_CFLAGS@ @PANGOFT2_CFLAGS@ \
+            @GTK_CFLAGS@ @FREETYPE2_CFLAGS@ @PANGOFT2_CFLAGS@ \
             @X_CFLAGS@
diff --git a/libjava/classpath/native/jni/gtk-peer/Makefile.in b/libjava/classpath/native/jni/gtk-peer/Makefile.in
index ff3e5a1174cc..9c155172121e 100644
--- a/libjava/classpath/native/jni/gtk-peer/Makefile.in
+++ b/libjava/classpath/native/jni/gtk-peer/Makefile.in
@@ -64,53 +64,17 @@ LTLIBRARIES = $(gcjversionedlib_LTLIBRARIES)
 libgtkpeer_la_DEPENDENCIES =  \
 	$(top_builddir)/native/jni/classpath/native_state.lo \
 	$(top_builddir)/native/jni/classpath/jcl.lo
-am__libgtkpeer_la_SOURCES_DIST =  \
-	gnu_java_awt_peer_gtk_GdkGraphics2D.c \
-	gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \
-	gnu_java_awt_peer_gtk_GdkFontPeer.c \
-	gnu_java_awt_peer_gtk_GdkGraphics.c \
-	gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c \
-	gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \
-	gnu_java_awt_peer_gtk_GdkRobotPeer.c \
-	gnu_java_awt_peer_gtk_GdkTextLayout.c \
-	gnu_java_awt_peer_gtk_GtkButtonPeer.c \
-	gnu_java_awt_peer_gtk_GtkCanvasPeer.c \
-	gnu_java_awt_peer_gtk_GtkCheckboxGroupPeer.c \
-	gnu_java_awt_peer_gtk_GtkCheckboxMenuItemPeer.c \
-	gnu_java_awt_peer_gtk_GtkCheckboxPeer.c \
-	gnu_java_awt_peer_gtk_GtkChoicePeer.c \
-	gnu_java_awt_peer_gtk_GtkClipboard.c \
-	gnu_java_awt_peer_gtk_GtkComponentPeer.c \
-	gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.c \
-	gnu_java_awt_peer_gtk_GtkFileDialogPeer.c \
-	gnu_java_awt_peer_gtk_GtkFramePeer.c \
-	gnu_java_awt_peer_gtk_GtkGenericPeer.c \
-	gnu_java_awt_peer_gtk_GtkImage.c \
-	gnu_java_awt_peer_gtk_GtkLabelPeer.c \
-	gnu_java_awt_peer_gtk_GtkListPeer.c \
-	gnu_java_awt_peer_gtk_GtkMenuBarPeer.c \
-	gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c \
-	gnu_java_awt_peer_gtk_GtkMenuItemPeer.c \
-	gnu_java_awt_peer_gtk_GtkMenuPeer.c \
-	gnu_java_awt_peer_gtk_GtkPanelPeer.c \
-	gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c \
-	gnu_java_awt_peer_gtk_GtkScrollbarPeer.c \
-	gnu_java_awt_peer_gtk_GtkScrollPanePeer.c \
-	gnu_java_awt_peer_gtk_GtkSelection.c \
-	gnu_java_awt_peer_gtk_GtkTextAreaPeer.c \
-	gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \
-	gnu_java_awt_peer_gtk_GtkToolkit.c \
-	gnu_java_awt_peer_gtk_GtkWindowPeer.c gthread-jni.c gdkfont.h \
-	gthread-jni.h gtkcairopeer.h gtk_jawt.c gtkpeer.h
-@GTK_CAIRO_TRUE@am__objects_1 =  \
-@GTK_CAIRO_TRUE@	gnu_java_awt_peer_gtk_GdkGraphics2D.lo
-am_libgtkpeer_la_OBJECTS = $(am__objects_1) \
+am_libgtkpeer_la_OBJECTS = gnu_java_awt_peer_gtk_CairoSurface.lo \
+	gnu_java_awt_peer_gtk_CairoGraphics2D.lo \
+	gnu_java_awt_peer_gtk_ComponentGraphics.lo \
+	gnu_java_awt_peer_gtk_ComponentGraphicsCopy.lo \
+	gnu_java_awt_peer_gtk_FreetypeGlyphVector.lo \
 	gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.lo \
 	gnu_java_awt_peer_gtk_GdkFontPeer.lo \
-	gnu_java_awt_peer_gtk_GdkGraphics.lo \
 	gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.lo \
 	gnu_java_awt_peer_gtk_GdkPixbufDecoder.lo \
 	gnu_java_awt_peer_gtk_GdkRobotPeer.lo \
+	gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.lo \
 	gnu_java_awt_peer_gtk_GdkTextLayout.lo \
 	gnu_java_awt_peer_gtk_GtkButtonPeer.lo \
 	gnu_java_awt_peer_gtk_GtkCanvasPeer.lo \
@@ -139,7 +103,8 @@ am_libgtkpeer_la_OBJECTS = $(am__objects_1) \
 	gnu_java_awt_peer_gtk_GtkTextAreaPeer.lo \
 	gnu_java_awt_peer_gtk_GtkTextFieldPeer.lo \
 	gnu_java_awt_peer_gtk_GtkToolkit.lo \
-	gnu_java_awt_peer_gtk_GtkWindowPeer.lo gthread-jni.lo \
+	gnu_java_awt_peer_gtk_GtkWindowPeer.lo \
+	gnu_java_awt_peer_gtk_GtkVolatileImage.lo gthread-jni.lo \
 	gtk_jawt.lo
 libgtkpeer_la_OBJECTS = $(am_libgtkpeer_la_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
@@ -154,7 +119,7 @@ CCLD = $(CC)
 LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(AM_LDFLAGS) $(LDFLAGS) -o $@
 SOURCES = $(libgtkpeer_la_SOURCES)
-DIST_SOURCES = $(am__libgtkpeer_la_SOURCES_DIST)
+DIST_SOURCES = $(libgtkpeer_la_SOURCES)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -168,8 +133,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -196,8 +159,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -220,6 +187,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -235,9 +204,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -259,6 +227,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -272,6 +241,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -285,6 +256,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -304,11 +276,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
@@ -366,19 +340,19 @@ vm_classes = @vm_classes@
 gcc_version := $(shell cat $(top_srcdir)/../../gcc/BASE-VER)
 gcjversionedlibdir = $(libdir)/gcj-$(gcc_version)
 gcjversionedlib_LTLIBRARIES = libgtkpeer.la
-@GTK_CAIRO_FALSE@gtk_cairo_c_source_files = 
 
-# Gtk/Cairo JNI sources.
-@GTK_CAIRO_TRUE@gtk_cairo_c_source_files = \
-@GTK_CAIRO_TRUE@    gnu_java_awt_peer_gtk_GdkGraphics2D.c
-
-libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
+# GTK JNI sources.
+libgtkpeer_la_SOURCES = gnu_java_awt_peer_gtk_CairoSurface.c \
+			gnu_java_awt_peer_gtk_CairoGraphics2D.c \
+			gnu_java_awt_peer_gtk_ComponentGraphics.c \
+			gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c \
+			gnu_java_awt_peer_gtk_FreetypeGlyphVector.c \
 			gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \
 			gnu_java_awt_peer_gtk_GdkFontPeer.c \
-			gnu_java_awt_peer_gtk_GdkGraphics.c \
 			gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c \
 			gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \
 			gnu_java_awt_peer_gtk_GdkRobotPeer.c \
+			gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c \
 			gnu_java_awt_peer_gtk_GdkTextLayout.c \
 			gnu_java_awt_peer_gtk_GtkButtonPeer.c \
 			gnu_java_awt_peer_gtk_GtkCanvasPeer.c \
@@ -408,10 +382,12 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
 			gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \
 			gnu_java_awt_peer_gtk_GtkToolkit.c \
 			gnu_java_awt_peer_gtk_GtkWindowPeer.c \
+			gnu_java_awt_peer_gtk_GtkVolatileImage.c \
+			cairographics2d.h \
 			gthread-jni.c \
+			gdkdisplay.h \
 			gdkfont.h \
 			gthread-jni.h \
-			gtkcairopeer.h \
 			gtk_jawt.c \
 			gtkpeer.h
 
@@ -421,15 +397,15 @@ libgtkpeer_la_LDFLAGS = -rpath $(gcjversionedlibdir) \
 libgtkpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \
 		       $(top_builddir)/native/jni/classpath/jcl.lo
 
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @FREETYPE2_LIBS@ \
-             @PANGOFT2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ -lX11 -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @FREETYPE2_LIBS@ \
+             @PANGOFT2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ @XTEST_LIBS@
 
 AM_CPPFLAGS = @CLASSPATH_INCLUDES@
 
 # Just the WARNING_CFLAGS. We cannot use the strict flags since the gtk
 # headers contain broken prototypes (by design, see gtkitemfactory.h).
 AM_CFLAGS = @WARNING_CFLAGS@ @ERROR_CFLAGS@ \
-            @GTK_CFLAGS@ @CAIRO_CFLAGS@ @FREETYPE2_CFLAGS@ @PANGOFT2_CFLAGS@ \
+            @GTK_CFLAGS@ @FREETYPE2_CFLAGS@ @PANGOFT2_CFLAGS@ \
             @X_CFLAGS@
 
 all: all-am
@@ -501,13 +477,17 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_CairoGraphics2D.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_CairoSurface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_ComponentGraphics.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_FreetypeGlyphVector.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkFontPeer.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkGraphics.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkGraphics2D.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkPixbufDecoder.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkRobotPeer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GdkTextLayout.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkButtonPeer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkCanvasPeer.Plo@am__quote@
@@ -536,6 +516,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkTextAreaPeer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkTextFieldPeer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkToolkit.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkVolatileImage.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnu_java_awt_peer_gtk_GtkWindowPeer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gthread-jni.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtk_jawt.Plo@am__quote@
diff --git a/libjava/classpath/native/jni/gtk-peer/cairographics2d.h b/libjava/classpath/native/jni/gtk-peer/cairographics2d.h
new file mode 100644
index 000000000000..2c12384deaf6
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/cairographics2d.h
@@ -0,0 +1,119 @@
+/* cairographics2d.h -- 
+   Copyright (C) 2006 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. */
+
+#ifndef CAIROGRAPHICS2D_H
+#define CAIROGRAPHICS2D_H
+
+
+#include <cairo.h>
+#include <gtk/gtk.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <config.h>
+#include "native_state.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <jni.h>
+
+/*
+ * These public final constants are part of the java2d public API, so we
+ * write them explicitly here to save fetching them from the constant pool
+ * all the time. 
+ */
+enum java_awt_alpha_composite_rule
+  {
+    java_awt_alpha_composite_CLEAR = 1,
+    java_awt_alpha_composite_SRC = 2,
+    java_awt_alpha_composite_SRC_OVER = 3,
+    java_awt_alpha_composite_DST_OVER = 4,
+    java_awt_alpha_composite_SRC_IN = 5,
+    java_awt_alpha_composite_DST_IN = 6,
+    java_awt_alpha_composite_SRC_OUT = 7,
+    java_awt_alpha_composite_DST_OUT = 8,
+    java_awt_alpha_composite_DST = 9,
+    java_awt_alpha_composite_SRC_ATOP = 10,
+    java_awt_alpha_composite_DST_ATOP = 11,
+    java_awt_alpha_composite_XOR = 12
+  };
+
+enum java_awt_basic_stroke_join_rule
+  {
+    java_awt_basic_stroke_JOIN_MITER = 0,
+    java_awt_basic_stroke_JOIN_ROUND = 1,
+    java_awt_basic_stroke_JOIN_BEVEL = 2
+  };
+
+enum java_awt_basic_stroke_cap_rule
+  {
+    java_awt_basic_stroke_CAP_BUTT = 0,
+    java_awt_basic_stroke_CAP_ROUND = 1,
+    java_awt_basic_stroke_CAP_SQUARE = 2
+  };
+
+enum java_awt_geom_path_iterator_winding_rule
+  {
+    java_awt_geom_path_iterator_WIND_EVEN_ODD = 0,
+    java_awt_geom_path_iterator_WIND_NON_ZERO = 1
+  };
+
+enum java_awt_rendering_hints_filter
+  {
+    java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR = 0,    
+    java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR = 1,
+    java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED = 2,
+    java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY = 3,
+    java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT = 4
+ 
+  };
+
+/**
+ * A structure which basically contains the cairo_t pointer. 
+ * The rest is for gradient and texture fills.
+ */
+struct cairographics2d
+{
+  cairo_t *cr;
+  cairo_surface_t *pattern_surface;
+  cairo_pattern_t *pattern; 
+  char *pattern_pixels;
+};
+
+cairo_t *cp_gtk_get_cairo_t(JNIEnv *env,
+			    jobject cairographics2dobj);
+
+#endif
diff --git a/libjava/classpath/native/jni/gtk-peer/gdkdisplay.h b/libjava/classpath/native/jni/gtk-peer/gdkdisplay.h
new file mode 100644
index 000000000000..238ff9e26132
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gdkdisplay.h
@@ -0,0 +1,67 @@
+#ifndef __GDKDISPLAY_H__
+#define __GDKDISPLAY_H__
+
+/* gdkdisplay.h -- Some global stuff related to displays & screens 
+   Copyright (C) 2006 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. */
+
+#include "gtkpeer.h"
+
+/* Allows storing GdkDisplay pointers in GdkGraphicsEnvironment instances. */
+extern struct state_table *cp_gtk_native_display_state_table;
+
+/* Allows storing GdkScreen pointers in GdkScreenGraphicsDevice instances. */
+extern struct state_table *cp_gtk_native_screen_state_table;
+
+#define NSA_DISPLAY_INIT(env, clazz) \
+  cp_gtk_native_display_state_table = cp_gtk_init_state_table (env, clazz)
+
+#define NSA_GET_DISPLAY_PTR(env, obj) \
+  cp_gtk_get_state (env, obj, cp_gtk_native_display_state_table)
+
+#define NSA_SET_DISPLAY_PTR(env, obj, ptr) \
+  cp_gtk_set_state (env, obj, cp_gtk_native_display_state_table, (void *)ptr)
+
+#define NSA_SCREEN_INIT(env, clazz) \
+  cp_gtk_native_screen_state_table = cp_gtk_init_state_table (env, clazz)
+
+#define NSA_GET_SCREEN_PTR(env, obj) \
+  cp_gtk_get_state (env, obj, cp_gtk_native_screen_state_table)
+
+#define NSA_SET_SCREEN_PTR(env, obj, ptr) \
+  cp_gtk_set_state (env, obj, cp_gtk_native_screen_state_table, (void *)ptr)
+
+#endif /* __GDKDISPLAY_H__ */
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
new file mode 100644
index 000000000000..f4f7c28d37ee
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
@@ -0,0 +1,703 @@
+/* gnu_java_awt_peer_gtk_CairoGraphics2d.c
+   Copyright (C) 2006  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. */
+
+#include "jcl.h"
+#include "gdkfont.h"
+#include "cairographics2d.h"
+#include "gnu_java_awt_peer_gtk_CairoGraphics2D.h"
+#include <gdk/gdktypes.h>
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkx.h>
+
+#include <cairo-ft.h>
+#include <cairo-xlib.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+static void install_font_peer(cairo_t *cr, struct peerfont *pfont);
+static void update_pattern_transform (struct cairographics2d *gr);
+static struct cairographics2d *getPointer(JNIEnv *env, jobject obj);
+
+static struct cairographics2d *
+getPointer(JNIEnv *env, jobject obj)
+{
+  jclass cls;
+  jlong value;
+  jfieldID nofid;
+  cls = (*env)->GetObjectClass( env, obj );
+  nofid = (*env)->GetFieldID( env, cls, "nativePointer", "J" );
+  value = (*env)->GetLongField( env, obj, nofid );
+  (*env)->DeleteLocalRef( env, cls );
+
+  return JLONG_TO_PTR(struct cairographics2d, value);
+}
+
+/**
+ * Returns the cairo_t * associated with a CairoGraphics2D object,
+ * This is used by GdkTextLayout.
+ */
+cairo_t *cp_gtk_get_cairo_t(JNIEnv *env,
+			    jobject cairographics2dobj)
+{
+  struct cairographics2d *gr = getPointer(env, cairographics2dobj);
+  g_assert(gr != NULL);
+  return gr->cr;
+}
+
+/**
+ * Allocates the cairographics2d structure.
+ */
+JNIEXPORT jlong JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_init
+  (JNIEnv *env __attribute__ ((unused)),
+   jobject obj __attribute__ ((unused)),
+   jlong cairo_t_pointer)
+{
+  struct cairographics2d *g = NULL;
+  cairo_t *cr = JLONG_TO_PTR(cairo_t, cairo_t_pointer);
+  g_assert(cr != NULL);
+
+  g = (struct cairographics2d *) g_malloc (sizeof (struct cairographics2d));
+
+  g_assert (g != NULL);
+  memset (g, 0, sizeof(struct cairographics2d));
+  g->cr = cr;
+  
+  return PTR_TO_JLONG(g);
+}
+
+/**
+ * Disposes of the cairographics2d structure.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_disposeNative
+  (JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer(env, obj);
+
+  if (gr == NULL)
+    return;
+
+  if (gr->cr)
+    cairo_destroy (gr->cr);
+
+  if (gr->pattern)
+    cairo_pattern_destroy (gr->pattern);
+  gr->pattern = NULL;
+  
+  if (gr->pattern_surface)
+    cairo_surface_destroy (gr->pattern_surface);
+  gr->pattern_surface = NULL;
+
+  if (gr->pattern_pixels)
+    g_free(gr->pattern_pixels);
+  gr->pattern_pixels = NULL;
+
+  g_free( gr );
+}
+
+/**
+ * Set the gradient.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setGradient
+  (JNIEnv *env, jobject obj, 
+   jdouble x1, jdouble y1, 
+   jdouble x2, jdouble y2,
+   jint r1, jint g1, jint b1, jint a1,
+   jint r2, jint g2, jint b2, jint a2,
+   jboolean cyclic)
+{
+  struct cairographics2d *gr = NULL;
+  cairo_pattern_t* pattern;
+  cairo_extend_t extend;
+
+  gr = getPointer (env, obj);
+  g_assert( gr != NULL );
+
+  pattern = cairo_pattern_create_linear(x1, y1, x2, y2);
+  g_assert( pattern != NULL );
+
+  cairo_pattern_add_color_stop_rgba(pattern, 0.0, r1 / 255.0, g1 / 255.0, 
+				    b1 / 255.0, a1 / 255.0);
+
+  cairo_pattern_add_color_stop_rgba(pattern, 1.0, r2 / 255.0, g2 / 255.0, 
+				    b2 / 255.0, a2 / 255.0);
+
+  extend = (cyclic == JNI_TRUE) ? CAIRO_EXTEND_REFLECT : CAIRO_EXTEND_NONE;
+
+  cairo_pattern_set_extend( pattern, extend );
+
+  gr->pattern = pattern;
+  cairo_set_source(gr->cr, gr->pattern);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setTexturePixels
+  (JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride)
+{
+  struct cairographics2d *gr = NULL;
+  jint *jpixels = NULL;
+
+  gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  if (gr->pattern)
+    cairo_pattern_destroy (gr->pattern);
+
+  if (gr->pattern_surface)
+    cairo_surface_destroy (gr->pattern_surface);
+
+  if (gr->pattern_pixels)
+    g_free (gr->pattern_pixels);
+
+  gr->pattern = NULL;
+  gr->pattern_surface = NULL;
+  gr->pattern_pixels = NULL;
+
+  gr->pattern_pixels = (char *) g_malloc (h * stride * 4);
+  g_assert (gr->pattern_pixels != NULL);
+
+  jpixels = (*env)->GetIntArrayElements (env, jarr, NULL);
+  g_assert (jpixels != NULL);
+  memcpy (gr->pattern_pixels, jpixels, h * stride * 4);
+  (*env)->ReleaseIntArrayElements (env, jarr, jpixels, 0);
+
+  gr->pattern_surface = cairo_image_surface_create_for_data ((unsigned char *)gr->pattern_pixels, 
+							CAIRO_FORMAT_ARGB32, 
+							w, h, stride * 4);
+  g_assert (gr->pattern_surface != NULL);
+  gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface);
+  g_assert (gr->pattern != NULL);
+  cairo_pattern_set_extend (gr->pattern, CAIRO_EXTEND_REPEAT);
+  cairo_set_source (gr->cr, gr->pattern);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels 
+  (JNIEnv *env, jobject obj, jintArray java_pixels, 
+   jint w, jint h, jint stride, jdoubleArray java_matrix)
+{
+  jint *native_pixels = NULL;
+  jdouble *native_matrix = NULL;
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  native_pixels = (*env)->GetIntArrayElements (env, java_pixels, NULL);
+  native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);
+  g_assert (native_pixels != NULL);
+  g_assert (native_matrix != NULL);
+  g_assert ((*env)->GetArrayLength (env, java_matrix) == 6);
+
+ {
+   cairo_matrix_t mat;
+   cairo_pattern_t *p;
+   cairo_surface_t *surf = cairo_image_surface_create_for_data ((unsigned char *)native_pixels, 
+							   CAIRO_FORMAT_ARGB32, 
+							   w, h, stride * 4);   
+   cairo_matrix_init_identity (&mat);
+   cairo_matrix_init (&mat, 
+                      native_matrix[0], native_matrix[1],
+                      native_matrix[2], native_matrix[3],
+                      native_matrix[4], native_matrix[5]);
+
+   p = cairo_pattern_create_for_surface (surf);
+   cairo_pattern_set_matrix (p, &mat);
+   if (gr->pattern)
+     cairo_pattern_set_filter (p, cairo_pattern_get_filter (gr->pattern));
+   cairo_set_source (gr->cr, p);
+   cairo_paint (gr->cr);
+   cairo_pattern_destroy (p);
+   cairo_surface_destroy (surf);
+ }
+  
+ (*env)->ReleaseIntArrayElements (env, java_pixels, native_pixels, 0);
+ (*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
+}
+
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetMatrix
+   (JNIEnv *env, jobject obj, jdoubleArray java_matrix)
+{
+  jdouble *native_matrix = NULL;
+  struct cairographics2d *gr = getPointer (env, obj);
+
+  native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);  
+  g_assert (native_matrix != NULL);
+  g_assert ((*env)->GetArrayLength (env, java_matrix) == 6);
+
+  {
+    cairo_matrix_t mat;
+
+    cairo_matrix_init_identity (&mat);
+    cairo_matrix_init (&mat, 
+                       native_matrix[0], native_matrix[1],
+                       native_matrix[2], native_matrix[3],
+                       native_matrix[4], native_matrix[5]);
+    cairo_set_matrix (gr->cr, &mat);
+  }
+
+  (*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
+  update_pattern_transform (gr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector
+   (JNIEnv *env, jobject obj, 
+    jobject font,
+    jfloat x, jfloat y, jint n,
+    jintArray java_codes,
+    jfloatArray java_positions)
+{
+  
+  struct cairographics2d *gr = NULL;
+  struct peerfont *pfont = NULL;
+  cairo_glyph_t *glyphs = NULL;
+  int *native_codes;
+  float *native_positions;
+  jint i = 0;
+
+  g_assert (obj != NULL);
+  g_assert (java_codes != NULL);
+  g_assert (java_positions != NULL);
+
+  gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
+  g_assert (pfont != NULL);
+
+  install_font_peer(gr->cr, pfont);
+
+  glyphs = g_malloc( sizeof(cairo_glyph_t) * n);
+  g_assert (glyphs != NULL);
+
+  native_codes = (*env)->GetIntArrayElements (env, java_codes, NULL);
+  native_positions = (*env)->GetFloatArrayElements (env, java_positions, NULL);
+  
+  for (i = 0; i < n; ++i)
+    {
+      glyphs[i].index = native_codes[i];
+      glyphs[i].x = x + native_positions[ 2*i ];
+      glyphs[i].y = y + native_positions[ 2*i + 1];
+    }
+
+  (*env)->ReleaseFloatArrayElements (env, java_positions, native_positions, 0);
+  (*env)->ReleaseIntArrayElements (env, java_codes, native_codes, 0);
+
+  cairo_show_glyphs (gr->cr, glyphs, n);
+
+  g_free(glyphs);
+}
+
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetOperator 
+   (JNIEnv *env, jobject obj, jint op)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  switch ((enum java_awt_alpha_composite_rule) op)
+    {
+    case java_awt_alpha_composite_CLEAR: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_CLEAR);
+      break;
+      
+    case java_awt_alpha_composite_SRC: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_SOURCE);
+      break;
+      
+    case java_awt_alpha_composite_SRC_OVER: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_OVER);
+      break;
+
+    case java_awt_alpha_composite_DST_OVER: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_OVER);
+      break;
+
+    case java_awt_alpha_composite_SRC_IN: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_IN);
+      break;
+
+    case java_awt_alpha_composite_DST_IN: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_IN);
+      break;
+
+    case java_awt_alpha_composite_SRC_OUT: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_OUT);
+      break;
+
+    case java_awt_alpha_composite_DST_OUT: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_OUT);
+      break;
+
+    case java_awt_alpha_composite_DST: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST);
+      break;
+
+    case java_awt_alpha_composite_SRC_ATOP: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_ATOP);
+      break;
+
+    case java_awt_alpha_composite_DST_ATOP: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_DEST_ATOP);
+      break;
+
+    case java_awt_alpha_composite_XOR: 
+      cairo_set_operator (gr->cr, CAIRO_OPERATOR_XOR);
+      break;
+    }
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetRGBAColor
+   (JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_set_source_rgba (gr->cr, r, g, b, a);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetFillRule 
+   (JNIEnv *env, jobject obj, jint rule)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  switch ((enum java_awt_geom_path_iterator_winding_rule) rule)
+    {
+    case java_awt_geom_path_iterator_WIND_NON_ZERO:
+      cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_WINDING);
+      break;
+    case java_awt_geom_path_iterator_WIND_EVEN_ODD:
+      cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_EVEN_ODD);
+      break;
+    }
+}
+
+/**
+ * Set the line style, except for dashes.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetLine
+  (JNIEnv *env, jobject obj, jdouble width, int cap, int join, double miterLimit)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  /* set width */
+  cairo_set_line_width (gr->cr, width);
+
+  /* set cap */
+  switch ((enum java_awt_basic_stroke_cap_rule) cap)
+    {
+    case java_awt_basic_stroke_CAP_BUTT: 
+      cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_BUTT);
+      break;
+
+    case java_awt_basic_stroke_CAP_ROUND: 
+      cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_ROUND);
+      break;
+
+    case java_awt_basic_stroke_CAP_SQUARE: 
+      cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_SQUARE);
+      break;
+    }
+
+  /* set join */
+  switch ((enum java_awt_basic_stroke_join_rule) join)
+    {
+    case java_awt_basic_stroke_JOIN_MITER:
+      cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_MITER);
+      break;
+
+    case java_awt_basic_stroke_JOIN_ROUND:
+      cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_ROUND);
+      break;
+
+    case java_awt_basic_stroke_JOIN_BEVEL:
+      cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_BEVEL);
+      break;
+    }
+
+  /* set miter */
+  cairo_set_miter_limit (gr->cr, miterLimit);
+}
+
+/**
+ * Set the line dashes
+ */ 
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetDash
+   (JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset)
+{
+  jdouble *dasharr = NULL;
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  dasharr = (*env)->GetDoubleArrayElements (env, dashes, NULL);  
+  g_assert (dasharr != NULL);
+
+  cairo_set_dash (gr->cr, dasharr, ndash, offset);
+
+  (*env)->ReleaseDoubleArrayElements (env, dashes, dasharr, 0);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoNewPath 
+   (JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_new_path (gr->cr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoMoveTo 
+   (JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_move_to (gr->cr, x, y);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoLineTo 
+   (JNIEnv *env, jobject obj, jdouble x, jdouble y)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_line_to (gr->cr, x, y);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoCurveTo 
+   (JNIEnv *env, jobject obj, jdouble x1, jdouble y1, jdouble x2, jdouble y2, jdouble x3, jdouble y3)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+  cairo_curve_to (gr->cr, x1, y1, x2, y2, x3, y3);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelMoveTo 
+   (JNIEnv *env, jobject obj, jdouble dx, jdouble dy)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_rel_move_to (gr->cr, dx, dy);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelLineTo 
+   (JNIEnv *env, jobject obj, jdouble dx, jdouble dy)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_rel_line_to (gr->cr, dx, dy);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRelCurveTo 
+   (JNIEnv *env, jobject obj, jdouble dx1, jdouble dy1, jdouble dx2, jdouble dy2, jdouble dx3, jdouble dy3)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_rel_curve_to (gr->cr, dx1, dy1, dx2, dy2, dx3, dy3);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoRectangle 
+   (JNIEnv *env, jobject obj, jdouble x, jdouble y, jdouble width, jdouble height)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+
+  cairo_rectangle (gr->cr, x, y, width, height);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClosePath 
+   (JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_close_path (gr->cr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoStroke 
+   (JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_stroke (gr->cr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFill 
+   (JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+
+  cairo_fill (gr->cr);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClip 
+   (JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer( env, obj );
+  g_assert( gr != NULL );
+
+  cairo_clip( gr->cr );
+}
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoResetClip 
+  (JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer( env, obj );
+  g_assert (gr != NULL);
+
+  cairo_reset_clip( gr->cr );
+}
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoPreserveClip 
+(JNIEnv *env, jobject obj)
+{
+  struct cairographics2d *gr = getPointer( env, obj );
+  g_assert (gr != NULL);
+
+  cairo_clip_preserve( gr->cr );
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter
+   (JNIEnv *env, jobject obj, jint filter)
+{
+  struct cairographics2d *gr = getPointer (env, obj);
+  g_assert (gr != NULL);
+  
+  if (gr->pattern == NULL)
+    return;
+  
+  switch ((enum java_awt_rendering_hints_filter) filter)
+    {
+    case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR:
+      cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST);
+      break;
+    case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR:
+      cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BILINEAR);
+      break; 
+    case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED:
+      cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_FAST);
+      break;
+    case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT:
+      cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST);
+      break;
+    case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY:
+      cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST);
+      break;
+    }
+}
+
+/************************** FONT STUFF ****************************/
+static void
+install_font_peer(cairo_t *cr,
+		  struct peerfont *pfont)
+{
+  cairo_font_face_t *ft;
+  FT_Face face = NULL;
+
+  g_assert(cr != NULL);
+  g_assert(pfont != NULL);
+
+  if (pfont->graphics_resource == NULL)
+    {
+      face = pango_ft2_font_get_face (pfont->font);
+      g_assert (face != NULL);
+
+      ft = cairo_ft_font_face_create_for_ft_face (face, 0);
+      g_assert (ft != NULL);
+
+      cairo_set_font_face (cr, ft);
+      cairo_font_face_destroy (ft);
+      cairo_set_font_size (cr,
+                           (pango_font_description_get_size (pfont->desc) /
+                            (double)PANGO_SCALE));
+      ft = cairo_get_font_face (cr);
+      pfont->graphics_resource = ft;
+    }
+  else
+    {
+      ft = (cairo_font_face_t *) pfont->graphics_resource;
+      cairo_set_font_face (cr, ft);
+      cairo_set_font_size (cr,
+                           (pango_font_description_get_size (pfont->desc) /
+                            (double)PANGO_SCALE));
+    }
+}
+
+static void 
+update_pattern_transform (struct cairographics2d *gr)
+{
+  cairo_matrix_t mat;
+
+  g_assert (gr != NULL);
+  if (gr->pattern == NULL)
+    return;
+
+  cairo_get_matrix (gr->cr, &mat);
+  cairo_pattern_set_matrix (gr->pattern, &mat);
+}
+
+
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
new file mode 100644
index 000000000000..3518aead590b
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
@@ -0,0 +1,312 @@
+/* gnu_java_awt_peer_gtk_CairoSurface.c
+   Copyright (C)  2006 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. */
+
+#include "jcl.h"
+#include "gtkpeer.h"
+#include <cairo-xlib.h>
+#include <gdk/gdkx.h>
+
+#include "gnu_java_awt_peer_gtk_CairoSurface.h"
+#include "cairographics2d.h"
+
+/**
+ * Field names in CairoSurface.java
+ */
+#define SURFACE "surfacePointer"
+#define BUFFER "bufferPointer"
+
+/* prototypes */
+static void *getNativeObject( JNIEnv *env, jobject obj, const char *pointer );
+static void setNativeObject( JNIEnv *env, jobject obj, void *ptr, const char *pointer );
+
+/**
+ * Creates a cairo surface, ARGB32, native ordering, premultiplied alpha.
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_create (JNIEnv *env, jobject obj, jint width, jint height, jint stride)
+{
+  cairo_surface_t* surface;
+  void *data = g_malloc(stride * height * 4);
+  memset(data, 0, stride * height * 4);
+  setNativeObject(env, obj, data, BUFFER);
+
+  surface = cairo_image_surface_create_for_data
+    (data, CAIRO_FORMAT_ARGB32, width, height, stride);
+
+  setNativeObject(env, obj, surface, SURFACE);
+}
+
+/**
+ * Destroy the surface
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_destroy (JNIEnv *env, jobject obj)
+{
+  void *buffer;
+  cairo_surface_t* surface = (cairo_surface_t *)getNativeObject(env, obj, SURFACE);
+  if( surface != NULL )
+    cairo_surface_destroy(surface);
+
+  buffer = getNativeObject(env, obj, BUFFER);
+  if( buffer != NULL )
+    g_free(buffer);
+}
+
+/**
+ * Gets a pixel
+ */
+JNIEXPORT jint JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_nativeGetElem (JNIEnv *env, jobject obj, jint i)
+{
+  jint *pixeldata = (jint *)getNativeObject(env, obj, BUFFER);
+
+  if( pixeldata == NULL )
+    return 0;
+
+  return pixeldata[i];
+}
+
+/**
+ * Sets a pixel
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_nativeSetElem 
+(JNIEnv *env, jobject obj, jint i, jint val)
+{
+  jint *pixeldata = (jint *)getNativeObject(env, obj, BUFFER);
+
+  if( pixeldata == NULL )
+    return;
+
+  pixeldata[i] = val;
+}
+
+/**
+ * Gets all pixels in an array
+ */
+JNIEXPORT jintArray JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_getPixels
+(JNIEnv *env, jobject obj, int size)
+{
+  jint *pixeldata, *jpixdata;
+  jintArray jpixels;
+
+  pixeldata = (jint *)getNativeObject(env, obj, BUFFER);
+  g_assert(pixeldata != NULL);
+
+  jpixels = (*env)->NewIntArray (env, size);
+  jpixdata = (*env)->GetIntArrayElements (env, jpixels, NULL);
+  memcpy (jpixdata, pixeldata, size * sizeof( jint ));
+
+  (*env)->ReleaseIntArrayElements (env, jpixels, jpixdata, 0);
+  return jpixels;
+}
+
+/**
+ * Sets all pixels by an array.
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_setPixels
+(JNIEnv *env, jobject obj, jintArray jpixels)
+{
+  jint *pixeldata, *jpixdata;
+  int size;
+  int width, height;
+  jclass cls;
+  jfieldID field;
+
+  if( jpixels == NULL )
+    return;
+
+  cls = (*env)->GetObjectClass (env, obj);
+  field = (*env)->GetFieldID (env, cls, "width", "I");
+  g_assert (field != 0);
+  width = (*env)->GetIntField (env, obj, field);
+
+  field = (*env)->GetFieldID (env, cls, "height", "I");
+  g_assert (field != 0);
+  height = (*env)->GetIntField (env, obj, field);
+
+  pixeldata = (jint *)getNativeObject(env, obj, BUFFER);
+  g_assert(pixeldata != NULL);
+  
+  jpixdata = (*env)->GetIntArrayElements (env, jpixels, NULL);
+  size = (*env)->GetArrayLength( env, jpixels );
+  if( size > width * height ) size = width * height; /* stop overflows. */
+  
+  memcpy (pixeldata, jpixdata, size * sizeof( jint ));
+
+  (*env)->ReleaseIntArrayElements (env, jpixels, jpixdata, 0);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_CairoSurface_drawSurface 
+   (JNIEnv *env, jobject obj, jobject context, jdoubleArray java_matrix)
+{
+  cairo_t *cr;
+  jdouble *native_matrix = NULL;
+  cairo_surface_t* surface = (cairo_surface_t *)getNativeObject(env, obj, SURFACE);
+  g_assert(surface != NULL);
+
+  cr = cp_gtk_get_cairo_t(env, context);
+  g_assert(cr != NULL);
+
+  native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);
+  g_assert (native_matrix != NULL);
+  g_assert ((*env)->GetArrayLength (env, java_matrix) == 6);
+
+ {
+   cairo_matrix_t mat;
+   cairo_pattern_t *p;
+   cairo_matrix_init_identity (&mat);
+   cairo_matrix_init (&mat, 
+                      native_matrix[0], native_matrix[1],
+                      native_matrix[2], native_matrix[3],
+                      native_matrix[4], native_matrix[5]);
+
+   p = cairo_pattern_create_for_surface (surface);
+   cairo_pattern_set_matrix (p, &mat);
+
+   cairo_set_source(cr, p);
+   cairo_paint(cr);
+   cairo_pattern_destroy(p);
+ }
+  
+ (*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
+}
+
+JNIEXPORT jlong JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_getFlippedBuffer 
+(JNIEnv *env, jobject obj, jint size)
+{
+  jint *dst;
+  jint *src = (jint *)getNativeObject(env, obj, BUFFER);
+  int i;
+  int t;
+
+  g_assert( src != NULL );
+  dst = g_malloc( size * sizeof( jint ) );
+
+  for(i = 0; i < size; i++ )
+    {
+      t = (src[i] & 0x0000FF) << 16;
+      dst[i] = (src[i] & 0x00FF0000) >> 16;
+      dst[i] |= (src[i] & 0xFF00FF00);
+      dst[i] |= t;
+    }
+
+  return PTR_TO_JLONG(dst);
+}
+
+/**
+ * Create and return a cairo context for drawing to the surface.
+ */
+JNIEXPORT jlong JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_newCairoContext (JNIEnv *env, jobject obj)
+{
+  cairo_surface_t* surface = (cairo_surface_t *)getNativeObject(env, obj, SURFACE);
+  cairo_t *ptr;
+  g_assert(surface != NULL);
+  ptr = cairo_create(surface);
+  g_assert(ptr != NULL);
+
+  return PTR_TO_JLONG(ptr);
+}
+
+/**
+ * copyArea.
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_CairoSurface_copyAreaNative (JNIEnv *env, 
+							jobject obj, 
+							jint x, jint y, 
+							jint w, jint h, 
+							jint dx, jint dy, 
+							jint stride)
+{
+  int row;
+  int srcOffset, dstOffset;
+  jint *temp;
+  jint *pixeldata = (jint *)getNativeObject(env, obj, BUFFER);
+  g_assert( pixeldata != NULL );
+
+  temp = g_malloc( h * w * 4 );
+  g_assert( temp != NULL );
+
+  srcOffset = x + (y * stride);
+  dstOffset = (x + dx) + ((y + dy) * stride);
+
+  for( row = 0; row < h; row++ )
+    memcpy( temp + (w * row), pixeldata + srcOffset + (stride * row), w * 4 );
+
+  for( row = 0; row < h; row++ )
+    memcpy( pixeldata + dstOffset + (stride * row), temp + (w * row), w * 4 );
+
+  g_free( temp );
+}
+
+/*
+ * Sets the native object field.
+ */
+static void 
+setNativeObject( JNIEnv *env, jobject obj, void *ptr, const char *pointer )
+{   
+  jclass cls;
+  jlong value;
+  jfieldID nofid;
+  cls = (*env)->GetObjectClass( env, obj );
+  value = PTR_TO_JLONG(ptr); 
+  nofid = (*env)->GetFieldID( env, cls, pointer, "J" );
+  (*env)->SetLongField( env, obj, nofid, value );
+  (*env)->DeleteLocalRef( env, cls );
+}
+
+/**
+ * Gets the native object field.
+ */
+static void *
+getNativeObject( JNIEnv *env, jobject obj, const char *pointer )
+{
+  jclass cls;
+  jlong value;
+  jfieldID nofid;
+  cls = (*env)->GetObjectClass( env, obj );
+  nofid = (*env)->GetFieldID( env, cls, pointer, "J" );
+  value = (*env)->GetLongField( env, obj, nofid );
+  (*env)->DeleteLocalRef( env, cls );
+  return JLONG_TO_PTR(void, value);
+}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
new file mode 100644
index 000000000000..7e3c83808c83
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
@@ -0,0 +1,307 @@
+/* gnu_java_awt_peer_gtk_ComponentGraphics.c
+   Copyright (C) 2006 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. */
+
+#include "jcl.h"
+#include "gtkpeer.h"
+#include <cairo-xlib.h>
+#include <gdk/gdktypes.h>
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkx.h>
+#include <X11/extensions/Xrender.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk-pixbuf/gdk-pixdata.h>
+
+#include <cairo-ft.h>
+#include <cairo-xlib.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gnu_java_awt_peer_gtk_ComponentGraphics.h"
+
+#include "cairographics2d.h"
+
+static short flush_scheduled = 0;
+
+static gboolean flush (gpointer data __attribute__((unused)))
+{
+  gdk_threads_enter ();
+
+  XFlush (GDK_DISPLAY ());
+  flush_scheduled = 0;
+
+  gdk_threads_leave ();
+
+  return FALSE;
+}
+
+/* The minimum time period between calls to XFlush, in
+   milliseconds. */
+#define MINIMUM_FLUSH_PERIOD 20
+
+/* schedule_flush must be called with the GDK lock held. */
+static void
+schedule_flush ()
+{
+  if (!flush_scheduled)
+    {
+      g_timeout_add (MINIMUM_FLUSH_PERIOD, flush, NULL);
+      flush_scheduled = 1;
+    }
+}
+
+void cp_gtk_grab_current_drawable(GtkWidget *widget, GdkDrawable **draw,
+				  GdkWindow **win)
+{
+  g_assert (widget != NULL);
+  g_assert (draw != NULL);
+  g_assert (win != NULL);
+
+  *win = widget->window;
+
+  *draw = *win;
+  gdk_window_get_internal_paint_info (*win, draw, 0, 0); 
+}
+
+/**
+ * Returns whether the XRender extension is supported
+ */
+JNIEXPORT jboolean JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_hasXRender
+  (JNIEnv *env __attribute__ ((unused)), jclass cls __attribute__ ((unused)))
+{
+#if HAVE_XRENDER
+  int ev = 0, err = 0; 
+  if( XRenderQueryExtension (GDK_DISPLAY (), &ev, &err) )
+    return JNI_TRUE;
+#endif
+  return JNI_FALSE;
+}
+
+
+JNIEXPORT jlong JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_initState
+  (JNIEnv *env, jobject obj __attribute__ ((unused)), jobject peer)
+{
+  Drawable draw;
+  Display * dpy;
+  Visual * vis;
+  GdkDrawable *drawable;
+  cairo_surface_t *surface;
+  GdkWindow *win;
+  GtkWidget *widget = NULL;
+  void *ptr = NULL;
+  int width, height;
+  cairo_t *cr;
+
+  gdk_threads_enter();
+
+  ptr = NSA_GET_PTR (env, peer);
+  g_assert (ptr != NULL);
+
+  widget = GTK_WIDGET (ptr);
+  g_assert (widget != NULL);
+
+  cp_gtk_grab_current_drawable (widget, &drawable, &win);
+  g_assert (drawable != NULL);
+
+  width = widget->allocation.width;
+  height = widget->allocation.height;
+
+  g_assert (drawable != NULL);
+
+  draw = gdk_x11_drawable_get_xid(drawable);
+  g_assert (draw != (XID) 0);
+  
+  dpy = gdk_x11_drawable_get_xdisplay(drawable);
+  g_assert (dpy != NULL);
+  
+  vis = gdk_x11_visual_get_xvisual(gdk_drawable_get_visual(drawable));
+  g_assert (vis != NULL);
+  
+  surface = cairo_xlib_surface_create (dpy, draw, vis, width, height);
+  g_assert (surface != NULL);
+
+  cr = cairo_create (surface);
+  g_assert(cr != NULL);
+
+  gdk_threads_leave();
+
+  return PTR_TO_JLONG(cr);
+}
+
+/**
+ * Disposes of the surface
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_disposeSurface
+  (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
+   jlong value)
+{
+  struct cairographics2d *gr;
+  cairo_surface_t *surface;
+
+  gr = JLONG_TO_PTR(struct cairographics2d, value);
+
+  if (gr == NULL)
+    return;
+
+  if (gr->cr == NULL)
+    return;
+
+  surface = cairo_get_target (gr->cr);
+  if (surface != NULL)
+    cairo_surface_destroy (surface);
+}
+
+JNIEXPORT jlong JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_initFromVolatile
+  (JNIEnv *env  __attribute__ ((unused)), jobject obj __attribute__ ((unused)),
+   jlong ptr, jint width, jint height)
+{
+  Drawable draw;
+  Display * dpy;
+  Visual * vis;
+  GdkDrawable *drawable;
+  cairo_surface_t *surface;
+  cairo_t *cr;
+
+  gdk_threads_enter();
+
+  drawable = JLONG_TO_PTR(GdkDrawable, ptr);
+  g_assert (drawable != NULL);
+
+  draw = gdk_x11_drawable_get_xid(drawable);
+  g_assert (draw != (XID) 0);
+  
+  dpy = gdk_x11_drawable_get_xdisplay(drawable);
+  g_assert (dpy != NULL);
+  
+  vis = gdk_x11_visual_get_xvisual(gdk_drawable_get_visual(drawable));
+  g_assert (vis != NULL);
+  
+  surface = cairo_xlib_surface_create (dpy, draw, vis, width, height);
+  g_assert (surface != NULL);
+
+  cr = cairo_create (surface);
+  g_assert(cr != NULL);
+
+  gdk_threads_leave();
+
+  return PTR_TO_JLONG(cr);
+}
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_start_1gdk_1drawing
+  (JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)))
+{
+  gdk_threads_enter();
+}
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_end_1gdk_1drawing
+  (JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)))
+{
+  schedule_flush ();
+  gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_copyAreaNative
+  (JNIEnv *env, jobject obj __attribute__((unused)), jobject peer,
+   jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+  GdkPixbuf *pixbuf;
+  GdkDrawable *drawable;
+  GdkWindow *win;
+  GtkWidget *widget = NULL;
+  void *ptr = NULL;
+
+  gdk_threads_enter();
+
+  ptr = NSA_GET_PTR (env, peer);
+  g_assert (ptr != NULL);
+
+  widget = GTK_WIDGET (ptr);
+  g_assert (widget != NULL);
+
+  cp_gtk_grab_current_drawable (widget, &drawable, &win);
+  g_assert (drawable != NULL);
+
+  pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, w, h );
+  gdk_pixbuf_get_from_drawable( pixbuf, drawable, NULL, x, y, 0, 0, w, h );
+  gdk_draw_pixbuf (drawable, NULL, pixbuf,
+		   0, 0, x + dx, y + dy, 
+		   w, h, 
+		   GDK_RGB_DITHER_NORMAL, 0, 0);
+  gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphics_drawVolatile
+(JNIEnv *env, jobject obj __attribute__ ((unused)), jobject peer, 
+ jobject img, jint x, jint y, jint w, jint h)
+{
+  GdkPixmap *pixmap;
+  GtkWidget *widget = NULL;
+  void *ptr = NULL;
+  GdkGC *gc;
+
+  gdk_threads_enter();
+  ptr = NSA_GET_PTR (env, peer);
+  g_assert (ptr != NULL);
+
+  widget = GTK_WIDGET (ptr);
+  g_assert (widget != NULL);
+
+  pixmap = cp_gtk_get_pixmap( env, img );
+ 
+  gc = gdk_gc_new(widget->window);
+  gdk_draw_drawable(widget->window,
+		    gc,
+		    pixmap,
+		    0, 0,
+		    x, y,
+		    w, h);
+
+  g_object_unref( gc );
+
+  schedule_flush ();
+
+  gdk_threads_leave();
+}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
new file mode 100644
index 000000000000..76caa5d0c004
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
@@ -0,0 +1,132 @@
+/* gnu_java_awt_peer_gtk_ComponentGraphicsCopy.c
+   Copyright (C) 2006 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. */
+
+#include "jcl.h"
+#include "gtkpeer.h"
+#include <cairo-xlib.h>
+#include <gdk/gdktypes.h>
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkx.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk-pixbuf/gdk-pixdata.h>
+
+#include <cairo-ft.h>
+#include <cairo-xlib.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gnu_java_awt_peer_gtk_ComponentGraphicsCopy.h"
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_getPixbuf
+   (JNIEnv *env, jobject obj __attribute__((unused)),
+    jobject peer, jobject image)
+{
+  gint width, height;
+  GdkPixbuf *pixbuf;
+  GdkDrawable *drawable;
+  GdkWindow *win;
+  GtkWidget *widget = NULL;
+  void *ptr = NULL;
+
+  gdk_threads_enter();
+
+  ptr = NSA_GET_PTR (env, peer);
+  g_assert (ptr != NULL);
+
+  widget = GTK_WIDGET (ptr);
+  g_assert (widget != NULL);
+
+  cp_gtk_grab_current_drawable (widget, &drawable, &win);
+  g_assert (drawable != NULL);
+
+  pixbuf = cp_gtk_image_get_pixbuf( env, image );
+  g_assert( pixbuf != NULL);
+
+  width = gdk_pixbuf_get_width( pixbuf );
+  height = gdk_pixbuf_get_height( pixbuf );
+
+  gdk_pixbuf_get_from_drawable( pixbuf, /* destination pixbuf */
+				drawable, 
+				NULL, /* colormap */
+				0, 0, 0, 0,
+				width, height );
+  gdk_threads_leave();
+}
+
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_ComponentGraphicsCopy_copyPixbuf
+  (JNIEnv *env, jobject obj __attribute__((unused)),
+   jobject peer, jobject image,
+   int x __attribute__((unused)), int y __attribute__((unused)),
+   int width __attribute__((unused)), int height __attribute__((unused)))
+{
+  gint pwidth, pheight;
+  GdkPixbuf *pixbuf;
+  GdkDrawable *drawable;
+  GdkWindow *win;
+  GtkWidget *widget = NULL;
+  void *ptr = NULL;
+
+  gdk_threads_enter();
+
+  ptr = NSA_GET_PTR (env, peer);
+  g_assert (ptr != NULL);
+
+  widget = GTK_WIDGET (ptr);
+  g_assert (widget != NULL);
+
+  cp_gtk_grab_current_drawable (widget, &drawable, &win);
+  g_assert (drawable != NULL);
+
+  pixbuf = cp_gtk_image_get_pixbuf( env, image );
+  g_assert( pixbuf != NULL);
+
+  pwidth = gdk_pixbuf_get_width( pixbuf );
+  pheight = gdk_pixbuf_get_height( pixbuf );
+
+  gdk_draw_pixbuf (drawable, NULL, pixbuf,
+		   0, 0, 0, 0, 
+		   pwidth, pheight, 
+		   GDK_RGB_DITHER_NORMAL, 0, 0);
+
+  gdk_threads_leave();
+}
+
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
new file mode 100644
index 000000000000..42abd983c7a8
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
@@ -0,0 +1,335 @@
+/* gnu_java_awt_FreetypeGlyphVector.c
+   Copyright (C) 2006  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. */
+
+#include <jni.h>
+#include <gtk/gtk.h>
+#include <string.h>
+#include <pango/pango.h>
+#include <pango/pangoft2.h>
+#include <pango/pangofc-font.h>
+#include <freetype/ftglyph.h>
+#include <freetype/ftoutln.h>
+#include "native_state.h"
+#include "gdkfont.h"
+#include "gnu_java_awt_peer_gtk_FreetypeGlyphVector.h"
+#include "cairographics2d.h"
+
+typedef struct gp
+{
+  JNIEnv *env;
+  jobject obj;
+  double px;
+  double py;
+  double sx;
+  double sy;
+} generalpath ;
+
+static PangoFcFont *
+getFont(JNIEnv *env, jobject obj)
+{
+  jfieldID fid;
+  jobject data;
+  jclass cls;
+  struct peerfont *pfont;
+
+  cls = (*env)->GetObjectClass (env, obj);
+  fid = (*env)->GetFieldID (env, cls, "peer", 
+				 "Lgnu/java/awt/peer/gtk/GdkFontPeer;");
+  g_assert (fid != 0);
+
+  data = (*env)->GetObjectField (env, obj, fid);
+  g_assert (data != NULL);
+
+  pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, data);
+  g_assert (pfont != NULL);
+  g_assert (pfont->font != NULL);
+
+  return (PangoFcFont *)pfont->font;
+}
+
+JNIEXPORT jint JNICALL 
+Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyph
+  (JNIEnv *env, jobject obj, jint codepoint)
+{
+  FT_Face ft_face;
+  jint glyph_index;
+  PangoFcFont *font;
+
+  font = getFont(env, obj);
+
+  ft_face = pango_fc_font_lock_face( font );
+  g_assert (ft_face != NULL);
+
+  glyph_index = FT_Get_Char_Index( ft_face, codepoint );
+
+  pango_fc_font_unlock_face (font);
+
+  return glyph_index;
+}
+
+JNIEXPORT jobject JNICALL 
+Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getKerning
+(JNIEnv *env, jobject obj, jint rightGlyph, jint leftGlyph)
+{
+  FT_Face ft_face;
+  FT_Vector kern;
+  jclass cls;
+  jmethodID method;
+  jvalue values[2];
+  PangoFcFont *font;
+
+  font = getFont(env, obj);
+  ft_face = pango_fc_font_lock_face( font );
+  g_assert (ft_face != NULL);
+  FT_Get_Kerning( ft_face, rightGlyph, leftGlyph, FT_KERNING_DEFAULT, &kern );
+
+  pango_fc_font_unlock_face( font );
+
+  values[0].d = (jdouble)kern.x/64.0;
+  values[1].d = (jdouble)kern.y/64.0;
+
+  cls = (*env)->FindClass (env, "java/awt/geom/Point2D$Double");
+  method = (*env)->GetMethodID (env, cls, "<init>", "(DD)V");
+  return (*env)->NewObjectA(env, cls, method, values);
+}
+
+JNIEXPORT jdoubleArray JNICALL 
+Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getMetricsNative
+(JNIEnv *env, jobject obj, jint glyphIndex )
+{
+  FT_Face ft_face;
+  jdouble *values;
+  jdoubleArray retArray = NULL;
+  PangoFcFont *font;
+
+  font = getFont(env, obj);
+  ft_face = pango_fc_font_lock_face( font );
+
+  g_assert (ft_face != NULL);
+
+  FT_Set_Transform( ft_face, NULL, NULL );
+
+  if( FT_Load_Glyph( ft_face, glyphIndex, FT_LOAD_DEFAULT ) != 0 )
+    {
+      pango_fc_font_unlock_face( font );
+      printf("Couldn't load glyph %i\n", glyphIndex);
+      return NULL;
+    }
+
+  retArray = (*env)->NewDoubleArray (env, 8);
+  values = (*env)->GetDoubleArrayElements (env, retArray, NULL);
+
+  values[0] = 0;
+  values[1] = (jdouble)ft_face->glyph->advance.x/64.0;
+  values[2] = (jdouble)ft_face->glyph->advance.y/64.0;
+  values[3] = (jdouble)ft_face->glyph->metrics.horiBearingX/64.0;
+  values[4] = -(jdouble)ft_face->glyph->metrics.horiBearingY/64.0;
+  values[5] = (jdouble)ft_face->glyph->metrics.width/64.0;
+  values[6] = (jdouble)ft_face->glyph->metrics.height/64.0;
+  values[7] = 0;
+
+  (*env)->ReleaseDoubleArrayElements (env, retArray, values, 0);
+  pango_fc_font_unlock_face( font );
+
+  return retArray;
+}
+
+/* GetOutline code follows ****************************/
+/********* Freetype callback functions *****************************/
+
+static int _moveTo( const FT_Vector* to,
+		    void *p)
+{
+  JNIEnv *env;
+  jobject obj;
+  jclass cls;
+  jmethodID method;
+  jvalue values[2];
+  generalpath *path = (generalpath *) p;
+
+  env = path->env;
+  obj = path->obj;
+
+  values[0].f = (jfloat)(to->x * path->sx + path->px);
+  values[1].f = (jfloat)(to->y * path->sy + path->py);
+
+  cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+  method = (*env)->GetMethodID (env, cls, "moveTo", "(FF)V");
+  (*env)->CallVoidMethodA(env, obj, method, values );
+
+  return 0;
+}
+
+static int _lineTo( const FT_Vector*  to,
+		    void *p)
+{
+  JNIEnv *env;
+  jobject obj;
+  jclass cls;
+  jmethodID method;
+  jvalue values[2];
+  generalpath *path = (generalpath *) p;
+
+  env = path->env;
+  obj = path->obj; 
+  values[0].f = (jfloat)(to->x * path->sx + path->px);
+  values[1].f = (jfloat)(to->y * path->sy + path->py);
+
+  cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+  method = (*env)->GetMethodID (env, cls, "lineTo", "(FF)V");
+  (*env)->CallVoidMethodA(env, obj, method, values );
+
+  return 0;
+}
+
+static int _quadTo( const FT_Vector*  cp,
+		    const FT_Vector*  to,
+		    void *p)
+{
+  JNIEnv *env;
+  jobject obj;
+  jclass cls;
+  jmethodID method;
+  jvalue values[4];
+  generalpath *path = (generalpath *) p;
+
+  env = path->env;
+  obj = path->obj;
+  values[0].f = (jfloat)(cp->x * path->sx + path->px);
+  values[1].f = (jfloat)(cp->y * path->sy + path->py);
+  values[2].f = (jfloat)(to->x * path->sx + path->px);
+  values[3].f = (jfloat)(to->y * path->sy + path->py);
+
+  cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+  method = (*env)->GetMethodID (env, cls, "quadTo", "(FFFF)V");
+  (*env)->CallVoidMethodA(env, obj, method, values );
+
+  return 0;
+}
+
+static int _curveTo( const FT_Vector*  cp1,
+		     const FT_Vector*  cp2,
+		     const FT_Vector*  to,
+		     void *p)
+{
+  JNIEnv *env;
+  jobject obj;
+  jclass cls;
+  jmethodID method;
+  jvalue values[6];
+  generalpath *path = (generalpath *) p;
+
+  env = path->env;
+  obj = path->obj;
+  values[0].f = (jfloat)(cp1->x * path->sx + path->px);
+  values[1].f = (jfloat)(cp1->y * path->sy + path->py);
+  values[2].f = (jfloat)(cp2->x * path->sx + path->px);
+  values[3].f = (jfloat)(cp2->y * path->sy + path->py);
+  values[4].f = (jfloat)(to->x * path->sx + path->px);
+  values[5].f = (jfloat)(to->y * path->sy + path->py);
+
+  cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+  method = (*env)->GetMethodID (env, cls, "curveTo", "(FFFFFF)V");
+  (*env)->CallVoidMethodA(env, obj, method, values );
+
+  return 0;
+}
+
+
+JNIEXPORT jobject JNICALL 
+Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative
+ (JNIEnv *env, jobject obj, jint glyphIndex)
+{
+  generalpath *path;
+  jobject gp;
+  FT_Outline_Funcs ftCallbacks =
+    {
+      (FT_Outline_MoveToFunc) _moveTo,
+      (FT_Outline_LineToFunc) _lineTo,
+      (FT_Outline_ConicToFunc) _quadTo,
+      (FT_Outline_CubicToFunc) _curveTo,
+      0,
+      0
+    };
+  PangoFcFont *font;
+  FT_Face ft_face;
+  FT_Glyph glyph;
+
+  font = getFont(env, obj);
+  ft_face = pango_fc_font_lock_face( font );
+
+  g_assert (ft_face != NULL);
+
+  path = g_malloc0 (sizeof (generalpath));
+  g_assert(path != NULL);
+  path->env = env;
+
+  path->px = path->py = 0.0;
+  path->sx = 1.0/64.0;
+  path->sy = -1.0/64.0;
+
+  {  /* create a GeneralPath instance */
+    jclass cls;
+    jmethodID method;
+    
+    cls = (*env)->FindClass (env, "java/awt/geom/GeneralPath");
+    method = (*env)->GetMethodID (env, cls, "<init>", "()V");
+    gp = path->obj = (*env)->NewObject (env, cls, method);
+  }
+	      
+  if(FT_Load_Glyph(ft_face,
+		   (FT_UInt)(glyphIndex),
+		   FT_LOAD_DEFAULT | FT_LOAD_NO_BITMAP) != 0)
+    {
+      pango_fc_font_unlock_face( font );
+      g_free(path); 
+      return NULL;
+    }
+
+  FT_Get_Glyph( ft_face->glyph, &glyph );
+  FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline),
+			&ftCallbacks, path);
+  FT_Done_Glyph( glyph );
+  
+  pango_fc_font_unlock_face( font );
+
+  g_free(path); 
+
+  return gp; 
+}
+
+
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
index 0726fb531bb9..ddaece1b2788 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
@@ -35,6 +35,13 @@
    obligated to do so.  If you do not wish to do so, delete this
    exception statement from your version. */
 
+#include <pango/pango.h>
+#include <pango/pangoft2.h>
+#include <pango/pangofc-font.h>
+#include <freetype/ftglyph.h>
+#include <freetype/ftoutln.h>
+#include <freetype/fttypes.h>
+#include <freetype/tttables.h>
 #include "gdkfont.h"
 #include "gnu_java_awt_peer_gtk_GdkFontPeer.h"
 
@@ -52,25 +59,11 @@ enum java_awt_font_baseline {
   java_awt_font_HANGING_BASELINE = 2
 };
 
-static jmethodID glyphVector_ctor;
-static jclass glyphVector_class;
-static PangoAttrList *attrs = NULL;
-
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkFontPeer_initStaticState 
   (JNIEnv *env, jclass clazz)
 {
   NSA_FONT_INIT (env, clazz);
-
-  glyphVector_class = (*env)->FindClass 
-    (env, "gnu/java/awt/peer/gtk/GdkGlyphVector");
-
-  glyphVector_class = (*env)->NewGlobalRef
-    (env, glyphVector_class);
-
-  glyphVector_ctor = (*env)->GetMethodID 
-    (env, glyphVector_class, "<init>", 
-     "([D[ILjava/awt/Font;Ljava/awt/font/FontRenderContext;)V");
 }
 
 JNIEXPORT void JNICALL
@@ -114,124 +107,26 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose
 }
 
 
-JNIEXPORT jobject JNICALL
-Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector
-  (JNIEnv *env, jobject self, 
-   jstring chars,
-   jobject font, 
-   jobject fontRenderContext)
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkFontPeer_releasePeerGraphicsResource
+   (JNIEnv *env, jobject java_font)
 {
   struct peerfont *pfont = NULL;
-  GList *items = NULL;
-  GList *i = NULL;
-  gchar *str = NULL;
-  int len = 0;
-  int j = 0;
-  double *native_extents = NULL;
-  int *native_codes = NULL;
-  jintArray java_codes = NULL;
-  jdoubleArray java_extents = NULL;
 
-  gdk_threads_enter ();
+  gdk_threads_enter();
 
-  pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, self);
+  pfont = (struct peerfont *) NSA_GET_FONT_PTR (env, java_font);
   g_assert (pfont != NULL);
-
-  len = (*cp_gtk_gdk_env())->GetStringUTFLength (env, chars);  
-  str = (gchar *)(*env)->GetStringUTFChars (env, chars, NULL);
-  g_assert (str != NULL);
-
-  if (attrs == NULL)
-    attrs = pango_attr_list_new ();
-
-  if (len > 0 && str[len-1] == '\0')
-    len--;
-  
-  items = pango_itemize (pfont->ctx, str, 0, len, attrs, NULL);
-
-  i = g_list_first (items);
-
-  if (i == NULL)       
+  if (pfont->graphics_resource != NULL)
     {
-      java_extents = (*env)->NewDoubleArray (env, 0);
-      java_codes = (*env)->NewIntArray (env, 0);
-    }
-  else
-    { 
-      PangoGlyphString *glyphs;
-      PangoItem *item = (PangoItem *)i->data;
-
-      pango_context_set_font_description (pfont->ctx, pfont->desc);
-      pango_context_set_language (pfont->ctx, gtk_get_default_language());
-      pango_context_load_font (pfont->ctx, pfont->desc);
-
-      glyphs = pango_glyph_string_new ();
-      g_assert (glyphs != NULL);
-
-      pango_shape (str + item->offset, item->length, 
-		   &(item->analysis), glyphs);
-
-      if (glyphs->num_glyphs > 0)
-	{
-	  int x = 0;
-	  double scale = ((double) PANGO_SCALE);
-
-	  java_extents = (*env)->NewDoubleArray (env, glyphs->num_glyphs * NUM_GLYPH_METRICS);
-	  java_codes = (*env)->NewIntArray (env, glyphs->num_glyphs);
-
-	  native_extents = (*env)->GetDoubleArrayElements (env, java_extents, NULL);
-	  native_codes = (*env)->GetIntArrayElements (env, java_codes, NULL);
-
-	  for (j = 0; j < glyphs->num_glyphs; ++j)
-	    {
-	      PangoRectangle ink;
-	      PangoRectangle logical;
-	      PangoGlyphGeometry *geom = &glyphs->glyphs[j].geometry;
-
-	      pango_font_get_glyph_extents (pfont->font, 
-					    glyphs->glyphs[j].glyph,
-					    &ink, &logical);
-
-	      native_codes[j] = glyphs->glyphs[j].glyph;
-
-	      native_extents[ GLYPH_LOG_X(j)      ] = (logical.x)      / scale;
-	      native_extents[ GLYPH_LOG_Y(j)      ] = (- logical.y)    / scale;
-	      native_extents[ GLYPH_LOG_WIDTH(j)  ] = (logical.width)  / scale;
-	      native_extents[ GLYPH_LOG_HEIGHT(j) ] = (logical.height) / scale;
-
-	      native_extents[ GLYPH_INK_X(j)      ] = (ink.x)       / scale;
-	      native_extents[ GLYPH_INK_Y(j)      ] = (- ink.y)     / scale;
-	      native_extents[ GLYPH_INK_WIDTH(j)  ] = (ink.width)   / scale;
-	      native_extents[ GLYPH_INK_HEIGHT(j) ] = (ink.height)  / scale;
-
-	      native_extents[ GLYPH_POS_X(j)      ] = (x + geom->x_offset)  / scale;
-	      native_extents[ GLYPH_POS_Y(j)      ] = (  - geom->y_offset)  / scale;
-
-	      x += geom->width;
-	    }
-	  (*env)->ReleaseDoubleArrayElements (env, java_extents, native_extents, 0);
-	  (*env)->ReleaseIntArrayElements (env, java_codes, native_codes, 0);
-	}
-
-      pango_glyph_string_free (glyphs);
+      cairo_font_face_destroy ((cairo_font_face_t *) pfont->graphics_resource);
+      pfont->graphics_resource = NULL;
     }
 
-  (*env)->ReleaseStringUTFChars (env, chars, str);
-
-  for (i = g_list_first (items); i != NULL; i = g_list_next (i))
-    pango_item_free(i->data);
-
-  g_list_free (items);
-
-  gdk_threads_leave ();
-
-  return (*env)->NewObject (env, 
-			    glyphVector_class, 
-			    glyphVector_ctor, 
-			    java_extents, java_codes,
-			    font, fontRenderContext);
+  gdk_threads_leave();
 }
 
+
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkFontPeer_getFontMetrics
    (JNIEnv *env, jobject java_font, jdoubleArray java_metrics)
@@ -389,7 +284,7 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTextMetrics
 
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
-  (JNIEnv *env, jobject self, jstring family_name_str, jint style_int, jint size, jboolean useGraphics2D)
+  (JNIEnv *env, jobject self, jstring family_name_str, jint style_int, jint size)
 {
   struct peerfont *pfont = NULL;
   char const *family_name = NULL;
@@ -426,22 +321,11 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
   if (style & java_awt_font_ITALIC)
     pango_font_description_set_style (pfont->desc, PANGO_STYLE_ITALIC);
 
-  if (useGraphics2D)
+  pango_font_description_set_size (pfont->desc, size * PANGO_SCALE);
+  if (pfont->ctx == NULL)
     {
-      pango_font_description_set_size (pfont->desc, size * PANGO_SCALE);
-      if (pfont->ctx == NULL)
-	{
-	  ft2_map = PANGO_FT2_FONT_MAP(pango_ft2_font_map_for_display ());
-	  pfont->ctx = pango_ft2_font_map_create_context (ft2_map);
-	}
-    }
-  else
-    {
-      /* GDK uses a slightly different DPI setting. */
-      pango_font_description_set_size (pfont->desc,
-				   size * cp_gtk_dpi_conversion_factor);
-      if (pfont->ctx == NULL)
-	pfont->ctx = gdk_pango_context_get();
+      ft2_map = PANGO_FT2_FONT_MAP(pango_ft2_font_map_for_display ());
+      pfont->ctx = pango_ft2_font_map_create_context (ft2_map);
     }
 
   g_assert (pfont->ctx != NULL);
@@ -465,3 +349,64 @@ Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
 }
 
 
+JNIEXPORT jbyteArray JNICALL 
+Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTrueTypeTable 
+  (JNIEnv *env, jobject self, jbyte n, jbyte a, jbyte m, jbyte e)
+{
+  struct peerfont *pfont = NULL;
+  FT_Face face;
+  FT_ULong length = 0;
+  FT_ULong tag;
+  int error;
+  FT_Byte *buffer;
+  jbyteArray result_array;
+  jbyte *rbuf;
+
+  pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, self);
+  if(pfont == NULL)
+    return NULL;
+
+  gdk_threads_enter ();
+  face = pango_fc_font_lock_face ((PangoFcFont *)pfont->font);
+  tag = FT_MAKE_TAG( n, a, m, e );
+
+  /* Get the length of the table requested */
+  error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length );
+  if ( error ) 
+    {
+      pango_fc_font_unlock_face ((PangoFcFont *)pfont->font);
+      gdk_threads_leave ();
+      return NULL;
+    }
+
+  buffer = (FT_Byte *)g_malloc0( length );
+  if ( buffer == NULL ) 
+    {
+      pango_fc_font_unlock_face ((PangoFcFont *)pfont->font);
+      gdk_threads_leave ();
+      return NULL;
+    }
+  /* get the table data */
+  error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
+  if ( error ) 
+    {
+      pango_fc_font_unlock_face ((PangoFcFont *)pfont->font);
+      g_free(buffer);
+      gdk_threads_leave ();
+      return NULL;
+    }
+
+  /* copy to a jbytearray */
+  result_array = (*env)->NewByteArray (env, length);
+
+  rbuf = (*env)->GetByteArrayElements (env, result_array, NULL);
+  memcpy(rbuf, buffer, length);
+  (*env)->ReleaseByteArrayElements (env, result_array, rbuf, 0);
+
+  g_free(buffer);
+  pango_fc_font_unlock_face ((PangoFcFont *)pfont->font);
+  gdk_threads_leave ();
+
+  /* done */
+  return result_array;
+}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
index 7662800f000c..89adcd1e5257 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
@@ -1,5 +1,5 @@
 /* gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006 Free Software Foundation, Inc.
 
    This file is part of GNU Classpath.
 
@@ -35,9 +35,43 @@
    obligated to do so.  If you do not wish to do so, delete this
    exception statement from your version. */
 
+#include <glib.h>
+#include <gdk/gdk.h>
+
 #include "gdkfont.h"
+#include "gdkdisplay.h"
 #include "gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h"
 
+struct state_table *cp_gtk_native_display_state_table;
+
+jclass gdkGraphicsEnvironment_class;
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_initStaticState
+(JNIEnv *env, jclass klazz __attribute__((unused)))
+{
+    gdkGraphicsEnvironment_class = (*env)->NewGlobalRef
+    (env, klazz);
+
+	NSA_DISPLAY_INIT(env, gdkGraphicsEnvironment_class);
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeInitState
+(JNIEnv *env, jobject obj)
+{
+	GdkDisplay *defaultDisplay;
+	
+    gdk_threads_enter();
+    
+    /* Retrieve the default display. */
+    defaultDisplay = gdk_display_get_default();
+    
+    gdk_threads_leave();
+    
+    /* Store display pointer in GdkGraphicsEnvironment instance. */
+    NSA_SET_DISPLAY_PTR(env, obj, (void *) defaultDisplay);
+}
 
 static gint
 cmp_families (const void *a, const void *b)
@@ -101,3 +135,109 @@ Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies
   
   return num;
 }
+
+JNIEXPORT jobjectArray JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetScreenDevices
+(JNIEnv *env, jobject obj)
+{
+	jmethodID gdkScreenGraphicsDevice_ctor, gdkScreenGraphicsDevice_init;
+	jclass gdkScreenGraphicsDevice_class;
+	int numScreens = 0, i = 0;
+	GdkDisplay *display;
+	jobjectArray array;
+	jobject instance;
+	
+	gdkScreenGraphicsDevice_class = (*env)->FindClass 
+    (env, "gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice");
+    
+	gdkScreenGraphicsDevice_ctor = (*env)->GetMethodID 
+    (env, gdkScreenGraphicsDevice_class, "<init>",
+     "(Lgnu/java/awt/peer/gtk/GdkGraphicsEnvironment;)V");
+
+	gdkScreenGraphicsDevice_init = (*env)->GetMethodID 
+    (env, gdkScreenGraphicsDevice_class, "init", "()V");
+
+	display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, obj);
+	
+	gdk_threads_enter();
+	
+	numScreens = gdk_display_get_n_screens(display);
+	
+	
+	/* Create a suitably sized array. */
+	array = (*env)->NewObjectArray(env,
+                                   numScreens,
+                                   gdkScreenGraphicsDevice_class,
+                                   NULL);
+	
+	/* Create GdkScreenGraphicsDevice instances, store the native pointer to
+	 * the GScreen object with them, run a 2nd initialization phase and
+	 * put the new instance into the result array.
+	 */
+	for ( ; i < numScreens ; i++)
+	{
+		instance = (*env)->NewObject (env, 
+                                      gdkScreenGraphicsDevice_class,
+                                      gdkScreenGraphicsDevice_ctor,
+                                      obj);
+									  
+        NSA_SET_SCREEN_PTR(env,
+                           instance,
+                           gdk_display_get_screen(display, i));
+						   
+        gdk_threads_leave();
+        (*env)->CallVoidMethod(env,
+                               instance,
+                               gdkScreenGraphicsDevice_init);
+		gdk_threads_enter();
+		
+        (*env)->SetObjectArrayElement(env, array, i, instance);
+    }
+	
+    gdk_threads_leave();
+	
+    return array;
+}
+
+JNIEXPORT jobject JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetDefaultScreenDevice
+(JNIEnv *env, jobject obj)
+{
+    jclass gdkScreenGraphicsDevice_class;
+    jmethodID gdkScreenGraphicsDevice_ctor, gdkScreenGraphicsDevice_init;
+    jobject defaultDevice;
+    GdkScreen *defaultScreen;
+    
+    gdkScreenGraphicsDevice_class = (*env)->FindClass 
+    (env, "gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice");
+    
+    gdkScreenGraphicsDevice_ctor = (*env)->GetMethodID 
+    (env, gdkScreenGraphicsDevice_class, "<init>",
+     "(Lgnu/java/awt/peer/gtk/GdkGraphicsEnvironment;)V");
+    
+    gdkScreenGraphicsDevice_init = (*env)->GetMethodID 
+    (env, gdkScreenGraphicsDevice_class, "init", "()V");
+    
+    /* Create the GdkScreenGraphicsDevice instance. */
+    defaultDevice = (*env)->NewObject (env, 
+									   gdkScreenGraphicsDevice_class,
+									   gdkScreenGraphicsDevice_ctor,
+									   obj);
+									   
+    gdk_threads_enter();
+	
+    defaultScreen = gdk_screen_get_default();
+	
+    gdk_threads_leave();
+									   
+	/* Class initialization will have set up the native_state storage
+	 * mechanism for GdkScreenGraphicsDevice.
+	 */
+    NSA_SET_SCREEN_PTR(env, defaultDevice, defaultScreen);
+
+    (*env)->CallVoidMethod(env,
+                           defaultDevice,
+                           gdkScreenGraphicsDevice_init);
+
+    return defaultDevice;	
+}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c
new file mode 100644
index 000000000000..965fb5a2342f
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c
@@ -0,0 +1,354 @@
+/* gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.c
+   Copyright (C) 2006 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. */
+
+#include <jcl.h>
+
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+#ifdef HAVE_XRANDR
+#include <X11/Xlib.h>
+#include <X11/extensions/Xrandr.h>
+#endif
+
+#include "gdkdisplay.h"
+
+#include "gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice.h"
+
+struct state_table *cp_gtk_native_screen_state_table;
+
+jclass gdkScreenGraphicsDevice_class;
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_initStaticState
+(JNIEnv *env, jclass klazz)
+{
+	gdkScreenGraphicsDevice_class = (*env)->NewGlobalRef
+    (env, klazz);
+
+	NSA_SCREEN_INIT(env, gdkScreenGraphicsDevice_class);
+}
+
+JNIEXPORT jobject JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetFixedDisplayMode
+(JNIEnv *env, jobject obj, jobject gdkGraphicsEnv __attribute__((unused)))
+{
+	jclass displayMode_class;
+	jmethodID displayMode_ctor;
+	GdkScreen *screen;
+	jobject fixedDisplayMode = NULL;
+#ifdef HAVE_XRANDR
+	int temp1, temp2;
+	GdkDisplay *display;
+
+    display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv);
+
+	gdk_threads_enter();
+
+	if (!XRRQueryExtension(GDK_DISPLAY_XDISPLAY(display), &temp1, &temp2))
+	  {
+        displayMode_class = (*env)->FindClass(env, "java/awt/DisplayMode");
+        displayMode_ctor = (*env)->GetMethodID(env,
+                                               displayMode_class,
+                                               "<init>",
+                                               "(IIII)V");
+
+        screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj);
+	  	
+	  	fixedDisplayMode = (*env)->NewObject(env,
+	  	                                     displayMode_class,
+	  	                                     displayMode_ctor,
+	  	                                     gdk_screen_get_width(screen),
+	  	                                     gdk_screen_get_height(screen),
+	  	                                     -1,
+	  	                                     0);
+	  }
+
+	gdk_threads_leave();
+	  
+#else
+
+    displayMode_class = (*env)->FindClass(env, "java/awt/DisplayMode");
+    displayMode_ctor = (*env)->GetMethodID(env,
+                                           displayMode_class,
+                                           "<init>",
+                                           "(IIII)V");
+
+    screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj);
+	  	
+    fixedDisplayMode = (*env)->NewObject(env,
+	                                     displayMode_class,
+	                                     displayMode_ctor,
+	                                     gdk_screen_get_width(screen),
+	                                     gdk_screen_get_height(screen),
+	                                     -1,
+	                                     0);
+
+#endif	  
+	return fixedDisplayMode;
+}
+
+JNIEXPORT jstring JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetIDString
+(JNIEnv *env, jobject obj)
+{
+	GdkScreen *screen;
+	gchar* displayName;
+	jstring string;
+
+    screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj);
+	
+	gdk_threads_enter();
+	
+	displayName = gdk_screen_make_display_name(screen);
+	
+	gdk_threads_leave();
+	
+    string = (*env)->NewStringUTF(env, displayName);
+    
+    g_free(displayName);
+    
+    return string;
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeRate
+(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused)))
+{
+#ifdef HAVE_XRANDR
+
+	GdkDisplay *display;
+	XRRScreenConfiguration *config;
+	int rate;
+	
+	display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv);
+	
+	gdk_threads_enter();
+	
+	config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW());
+
+	rate = (int) XRRConfigCurrentRate (config);
+
+    XRRFreeScreenConfigInfo (config);
+
+	gdk_threads_leave();
+	
+	return rate;
+#else
+    JCL_ThrowException(env,
+                       "java/lang/InternalError",
+                       "Method should not have been invoked.");
+    
+    return -1;
+#endif    
+}
+
+JNIEXPORT jint JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModeIndex
+(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused)))
+{
+#ifdef HAVE_XRANDR	
+
+	GdkDisplay *display;
+	XRRScreenConfiguration *config;
+	SizeID index;
+	Rotation rotation;
+	
+	display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv);
+	
+	gdk_threads_enter();
+	
+	config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW());
+
+	index = XRRConfigCurrentConfiguration (config, &rotation);
+
+    XRRFreeScreenConfigInfo (config);
+
+	gdk_threads_leave();
+	
+	return (int) index;
+
+#else
+
+    JCL_ThrowException(env,
+                       "java/lang/InternalError",
+                       "Method should not have been invoked.");
+   
+    return -1;
+   
+#endif	
+}
+
+JNIEXPORT jobjectArray JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetDisplayModes
+(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused)))
+{
+#ifdef HAVE_XRANDR
+	GdkDisplay *display;
+	XRRScreenConfiguration *config;
+	XRRScreenSize *screenSizes;
+	int nsizes = 0, nrates = 0, i = 0;
+	jclass x11DisplayMode_class;
+	jmethodID x11DisplayMode_ctor;
+	jobjectArray array;
+	jobject instance;
+	short *rates;
+	jshortArray shortArray;
+	
+	display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv);
+	
+	gdk_threads_enter();
+	
+	config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW());
+	
+	screenSizes = XRRConfigSizes(config, &nsizes);
+	
+	x11DisplayMode_class = (*env)->FindClass(env, "gnu/java/awt/peer/gtk/GdkScreenGraphicsDevice$X11DisplayMode");
+    
+	x11DisplayMode_ctor = (*env)->GetMethodID(env, x11DisplayMode_class, "<init>", "(II[S)V");
+
+	array = (*env)->NewObjectArray(env, nsizes, x11DisplayMode_class, NULL);
+
+	for (; i < nsizes ; i++)
+	  {
+	  	/* Retrieves refresh rate information. */
+	  	rates = XRRConfigRates(config, i, &nrates);
+	  	
+	  	/* Create a Java int array and put them in. */
+	  	shortArray = (*env)->NewIntArray(env, nrates);
+		(*env)->SetShortArrayRegion(env, shortArray, 0, nrates, (jshort *) rates);
+	  	
+	  	/* Create a GdkScreenGraphicsDevice.X11DisplayMode instance. */
+        instance = (*env)->NewObject(env,
+									 x11DisplayMode_class,
+									 x11DisplayMode_ctor,
+									 screenSizes[i].width,
+									 screenSizes[i].height,
+									 shortArray);
+									 
+		/* Put it into the result array. */
+        (*env)->SetObjectArrayElement(env, array, i, instance);
+	  }
+	  
+	/* Free everything acquired by xlib. */
+	XRRFreeScreenConfigInfo (config);
+
+	gdk_threads_leave();
+	
+	return array;
+#else
+    JCL_ThrowException(env,
+                       "java/lang/InternalError",
+                       "Method should not have been invoked.");
+    
+    return NULL;
+   
+#endif	
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeSetDisplayMode
+(JNIEnv *env, jobject obj __attribute__((unused)), jobject gdkGraphicsEnv __attribute__((unused)), jint index __attribute__((unused)), jshort rate __attribute__((unused)))
+{
+#ifdef HAVE_XRANDR
+	GdkDisplay *display;
+	XRRScreenConfiguration *config;
+	Rotation rotation;
+	
+	display = (GdkDisplay *) NSA_GET_DISPLAY_PTR(env, gdkGraphicsEnv);
+	
+	gdk_threads_enter();
+	
+	config = XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY(display), GDK_ROOT_WINDOW());
+
+	/* The rotation is not exposed to the Java API. So we retrieve its current
+	 * value and set it to the same when switching resolution.
+	 */
+	XRRConfigCurrentConfiguration (config, &rotation);
+	
+	XRRSetScreenConfigAndRate (GDK_DISPLAY_XDISPLAY(display),
+                        		   config,
+                               GDK_ROOT_WINDOW(),
+                               index,
+                               rotation,
+                               rate,
+                               CurrentTime);
+	
+	XRRFreeScreenConfigInfo(config);
+	
+	gdk_threads_leave();
+
+#else
+    JCL_ThrowException(env,
+                       "java/lang/InternalError",
+                       "Method should not have been invoked.");
+#endif	
+}
+
+JNIEXPORT jobject JNICALL
+Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetBounds
+(JNIEnv *env, jobject obj)
+{
+	jclass rectangle_class;
+	jmethodID rectangle_ctor;
+	GdkScreen *screen;
+	GdkWindow *window;
+	int x, y, w, h;
+	jobject instance;
+    
+	rectangle_class = (*env)->FindClass(env, "java/awt/Rectangle");
+    
+    rectangle_ctor = (*env)->GetMethodID 
+    (env, rectangle_class, "<init>", "(IIII)V");
+
+    screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj);
+
+	gdk_threads_enter();
+	
+	window = gdk_screen_get_root_window(screen);
+	
+	gdk_window_get_geometry(window, &x, &y, &w, &h, NULL);
+
+	gdk_threads_leave();
+	
+    instance = (*env)->NewObject(env,
+								 rectangle_class,
+								 rectangle_ctor,
+								 x, y, w, h);
+	
+	return instance;
+}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
index edce3917d680..92f2d37ca42a 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkTextLayout.c
@@ -1,5 +1,5 @@
 /* gnu_java_awt_GdkTextLayout.c
-   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
    
    This file is part of GNU Classpath.
    
@@ -47,6 +47,7 @@
 #include "native_state.h"
 #include "gdkfont.h"
 #include "gnu_java_awt_peer_gtk_GdkTextLayout.h"
+#include "cairographics2d.h"
 
 struct state_table *cp_gtk_native_text_layout_state_table;
 
@@ -60,6 +61,9 @@ typedef struct gp
   double sy;
 } generalpath ;
 
+static void paint_glyph_run(cairo_t *cr, cairo_glyph_t **glyphs,
+			    gint *n_glyphs, PangoLayoutRun *run);
+
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkTextLayout_initStaticState 
   (JNIEnv *env, jclass clazz)
@@ -93,8 +97,6 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText
   gchar *str = NULL;
   gint len = 0;
 
-  gdk_threads_enter ();
-
   g_assert(self != NULL);
   g_assert(text != NULL);
 
@@ -106,13 +108,37 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_setText
   str = (gchar *)(*env)->GetStringUTFChars (env, text, NULL);
   g_assert (str != NULL);
 
-  pango_layout_set_text (tl->pango_layout, text, len);
+  gdk_threads_enter ();
+
+  pango_layout_set_text (tl->pango_layout, str, len);
 
   (*env)->ReleaseStringUTFChars (env, text, str);
 
   gdk_threads_leave ();  
 }
 
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_GdkTextLayout_setFont (JNIEnv *env, jobject obj, jobject font)
+{
+  struct textlayout *tl;
+  struct peerfont *pf;
+
+  g_assert(obj != NULL);
+  g_assert(font != NULL);
+
+  tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, obj);
+  g_assert(tl != NULL);
+  g_assert(tl->pango_layout != NULL);
+  pf = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
+  g_assert(pf != NULL);
+  
+  gdk_threads_enter ();
+
+  pango_layout_set_font_description(tl->pango_layout, pf->desc);
+
+  gdk_threads_leave ();  
+}
+
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GdkTextLayout_indexToPos
   (JNIEnv *env, jobject self, jint idx, jdoubleArray javaPos)
@@ -207,10 +233,108 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_dispose
   gdk_threads_leave ();
 }
 
+/**
+ * Draw this textlayout on a cairo surface
+ * FIXME: Seems completely broken.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkTextLayout_cairoDrawGdkTextLayout
+   (JNIEnv *env, jobject obj, jobject cairographics, jfloat x, jfloat y)
+{
+  /* 
+   * FIXME: Some day we expect either cairo or pango will know how to make
+   * a pango layout paint to a cairo surface. that day is not yet here.
+   */
+
+  cairo_t *cr;
+  struct textlayout *tl = NULL;
+  PangoLayoutIter *i = NULL;
+  PangoLayoutRun *run = NULL;
+  cairo_glyph_t *glyphs = NULL;
+  gint n_glyphs = 0;
+
+  g_assert (cairographics != NULL);
+
+  cr = cp_gtk_get_cairo_t(env, cairographics);
+  tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, obj);
+
+  g_assert (cr != NULL);
+  g_assert (tl != NULL);
+  g_assert (tl->pango_layout != NULL);
+
+  gdk_threads_enter ();
+
+  i = pango_layout_get_iter (tl->pango_layout);
+  g_assert (i != NULL);
+
+  cairo_translate (cr, x, y);
+
+  do 
+    {
+      run = pango_layout_iter_get_run (i);
+      if (run != NULL)
+	paint_glyph_run (cr, &glyphs, &n_glyphs, run);
+    } 
+  while (pango_layout_iter_next_run (i));
+  
+  if (glyphs != NULL)
+    g_free (glyphs);
+
+  cairo_translate (cr, -x, -y);
+  
+  pango_layout_iter_free (i);
+
+  gdk_threads_leave ();
+}
+
+static void
+paint_glyph_run(cairo_t *cr,
+		cairo_glyph_t **glyphs,
+		gint *n_glyphs,
+		PangoLayoutRun *run)
+{
+  gint i = 0;
+  gint x = 0, y = 0;
+
+  g_assert (cr != NULL);
+  g_assert (glyphs != NULL);
+  g_assert (n_glyphs != NULL);
+  g_assert (run != NULL);
+
+  if (run->glyphs != NULL && run->glyphs->num_glyphs > 0)
+    {
+      if (*n_glyphs < run->glyphs->num_glyphs)
+	{
+	  *glyphs = g_realloc(*glyphs, 
+			      (sizeof(cairo_glyph_t) 
+			       * run->glyphs->num_glyphs));
+	  *n_glyphs = run->glyphs->num_glyphs;
+	}
+      
+      g_assert (*glyphs != NULL);
+
+      for (i = 0; i < run->glyphs->num_glyphs; ++i)
+	{	  
+	  (*glyphs)[i].index = run->glyphs->glyphs[i].glyph;
+
+	  (*glyphs)[i].x =
+	    ((double) (x + run->glyphs->glyphs[i].geometry.x_offset)) 
+	    / ((double) PANGO_SCALE);
+
+	  (*glyphs)[i].y =
+	    ((double) (y + run->glyphs->glyphs[i].geometry.y_offset)) 
+	    / ((double) PANGO_SCALE);
+	  
+	  x += run->glyphs->glyphs[i].geometry.width;
+	}
+      cairo_show_glyphs (cr, *glyphs, run->glyphs->num_glyphs);
+    }
+}
+
 /* GetOutline code follows ****************************/
 /********* Freetype callback functions *****************************/
 
-static int _moveTo( FT_Vector* to,
+static int _moveTo( const FT_Vector* to,
 		    void *p)
 {
   JNIEnv *env;
@@ -233,7 +357,7 @@ static int _moveTo( FT_Vector* to,
   return 0;
 }
 
-static int _lineTo( FT_Vector*  to,
+static int _lineTo( const FT_Vector*  to,
 		    void *p)
 {
   JNIEnv *env;
@@ -255,8 +379,8 @@ static int _lineTo( FT_Vector*  to,
   return 0;
 }
 
-static int _quadTo( FT_Vector*  cp,
-		    FT_Vector*  to,
+static int _quadTo( const FT_Vector*  cp,
+		    const FT_Vector*  to,
 		    void *p)
 {
   JNIEnv *env;
@@ -280,9 +404,9 @@ static int _quadTo( FT_Vector*  cp,
   return 0;
 }
 
-static int _curveTo( FT_Vector*  cp1,
-		     FT_Vector*  cp2,
-		     FT_Vector*  to,
+static int _curveTo( const FT_Vector*  cp1,
+		     const FT_Vector*  cp2,
+		     const FT_Vector*  to,
 		     void *p)
 {
   JNIEnv *env;
@@ -320,10 +444,10 @@ Java_gnu_java_awt_peer_gtk_GdkTextLayout_getOutline
   PangoLayoutLine *current_line;
   FT_Outline_Funcs ftCallbacks = 
     {
-      _moveTo,
-      _lineTo,
-      _quadTo,
-      _curveTo,
+      (FT_Outline_MoveToFunc) _moveTo,
+      (FT_Outline_LineToFunc) _lineTo,
+      (FT_Outline_ConicToFunc) _quadTo,
+      (FT_Outline_CubicToFunc) _curveTo,
       0,
       0
     };
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
index f44361972ecd..ef9ac12076af 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
@@ -56,17 +56,3 @@ Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_create
 
   gdk_threads_leave ();
 }
-
-JNIEXPORT void JNICALL 
-Java_gnu_java_awt_peer_gtk_GtkCanvasPeer_realize (JNIEnv *env, jobject obj)
-{
-  void *ptr;
-
-  gdk_threads_enter ();
-
-  ptr = NSA_GET_PTR (env, obj);
-
-  gtk_widget_realize (GTK_WIDGET (ptr));
-
-  gdk_threads_leave ();
-}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
index cb2c87238b28..7ce1185a46da 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkClipboard.c
@@ -242,14 +242,7 @@ clipboard_get_func (GtkClipboard *clipboard,
       
       pixbuf = cp_gtk_image_get_pixbuf (env, gtkimage);
       if (pixbuf != NULL)
-	{
-	  gtk_selection_data_set_pixbuf (selection, pixbuf);
-
-	  /* if the GtkImage is offscreen, this is a temporary pixbuf
-	     which should be thrown out. */
-	  if(cp_gtk_image_is_offscreen (env, gtkimage) == JNI_TRUE)
-	    gdk_pixbuf_unref (pixbuf);
-	}
+	gtk_selection_data_set_pixbuf (selection, pixbuf);
     }
   else if (info == URI_TARGET)
     {
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
index b0d4ab9b0199..4cd80a73f1bf 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
@@ -204,6 +204,7 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked
 {
   void *ptr;
   GtkWidget *widget;
+  GdkWindow *win;
   GdkCursorType gdk_cursor_type;
   GdkCursor *gdk_cursor;
 
@@ -255,16 +256,20 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked
     }
       
   widget = get_widget(GTK_WIDGET(ptr));
-
+  
+  win = widget->window;
+  if ((widget->window) == NULL)
+    win = GTK_WIDGET(ptr)->window;
+    
   if (image == NULL)
     gdk_cursor = gdk_cursor_new (gdk_cursor_type);
   else
     gdk_cursor
-      = gdk_cursor_new_from_pixbuf (gdk_drawable_get_display (widget->window),
+      = gdk_cursor_new_from_pixbuf (gdk_drawable_get_display (win),
 				    cp_gtk_image_get_pixbuf (env, image),
 				    x, y);
 
-  gdk_window_set_cursor (widget->window, gdk_cursor);
+  gdk_window_set_cursor (win, gdk_cursor);
   gdk_cursor_unref (gdk_cursor);
 
   /* Make sure the cursor is replaced on screen. */
@@ -748,6 +753,20 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground
   gdk_threads_leave ();
 }
 
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_realize (JNIEnv *env, jobject obj)
+{
+  void *ptr;
+
+  gdk_threads_enter ();
+
+  ptr = NSA_GET_PTR (env, obj);
+
+  gtk_widget_realize (GTK_WIDGET (ptr));
+
+  gdk_threads_leave ();
+}
+
 JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GtkComponentPeer_setVisibleNative
   (JNIEnv *env, jobject obj, jboolean visible)
@@ -792,30 +811,6 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isEnabled
   return ret_val;
 }
 
-JNIEXPORT jboolean JNICALL 
-Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isRealized
-  (JNIEnv *env, jobject obj)
-{
-  void *ptr;
-  jboolean ret_val;
-
-  gdk_threads_enter ();
-
-  ptr = NSA_GET_PTR (env, obj);
-
-  if (ptr == NULL)
-    {
-      gdk_threads_leave ();
-      return FALSE;
-    }
-
-  ret_val = GTK_WIDGET_REALIZED (get_widget(GTK_WIDGET (ptr)));
-
-  gdk_threads_leave ();
-
-  return ret_val;
-}
-
 JNIEXPORT jboolean JNICALL 
 Java_gnu_java_awt_peer_gtk_GtkComponentPeer_modalHasGrab
   (JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)))
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
index c60f48f51bba..766964314244 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
@@ -186,10 +186,5 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImage
 
   gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf);
 
-  /* if the GtkImage is offscreen, this is a temporary pixbuf which should 
-   be thrown out. */
-  if(cp_gtk_image_is_offscreen (env, gtkimage) == JNI_TRUE)
-    gdk_pixbuf_unref (pixbuf);
-
   gdk_threads_leave ();
 }
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
index 92bc09edde76..ff3fbe896b9e 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
@@ -37,8 +37,10 @@ exception statement from your version. */
 
 #include "jcl.h"
 #include "gtkpeer.h"
+#include <cairo-xlib.h>
+#include <gdk/gdkx.h>
+
 #include "gnu_java_awt_peer_gtk_GtkImage.h"
-#include <gdk-pixbuf/gdk-pixbuf.h>
 
 /* The constant fields in java.awt.Image */   
 #define SCALE_DEFAULT      1
@@ -49,13 +51,11 @@ exception statement from your version. */
 
 /* local stuff */
 static GdkInterpType mapHints(jint hints);
-static jboolean offScreen (JNIEnv * env, jobject obj);
-static void *getData (JNIEnv * env, jobject obj);
 static void createRawData (JNIEnv * env, jobject obj, void *ptr);
 static void setWidthHeight (JNIEnv * env, jobject obj, int width, int height);
 
 /**
- * Loads a pixmap from a file.
+ * Loads a pixbuf from a file.
  */
 JNIEXPORT jboolean JNICALL
 Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf
@@ -117,10 +117,14 @@ Java_gnu_java_awt_peer_gtk_GtkImage_loadImageFromData
 
   if (pixbuf == NULL)
     {
+      g_object_unref (loader);
       createRawData (env, obj, NULL);
       return JNI_FALSE;
     }
 
+  g_object_ref (pixbuf);
+  g_object_unref (loader);
+
   width =  gdk_pixbuf_get_width (pixbuf);
   height = gdk_pixbuf_get_height (pixbuf);
 
@@ -135,7 +139,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createFromPixbuf
 (JNIEnv *env, jobject obj)
 {
   int width, heigth;
-  GdkPixbuf *pixbuf = (GdkPixbuf *) getData (env, obj);
+  GdkPixbuf *pixbuf = cp_gtk_image_get_pixbuf (env, obj);
   width =  gdk_pixbuf_get_width (pixbuf);
   heigth = gdk_pixbuf_get_height (pixbuf);
   setWidthHeight(env, obj, width, heigth);
@@ -154,6 +158,8 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj)
   jint *result_array_iter, *dst;
   int i,j;
 
+  gdk_threads_enter ();
+
   pixbuf = cp_gtk_image_get_pixbuf (env, obj);
   width =  gdk_pixbuf_get_width (pixbuf);
   height = gdk_pixbuf_get_height (pixbuf);
@@ -190,11 +196,9 @@ Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj)
 	}
     }
   
-  if (offScreen (env, obj) == JNI_TRUE)
-    gdk_pixbuf_unref (pixbuf);
-
   (*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
     
+  gdk_threads_leave ();
   return result_array;
 }
 
@@ -206,7 +210,7 @@ JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GtkImage_setPixels(JNIEnv *env, jobject obj,
 					      jintArray pixels)
 {
-  GdkPixbuf *pixbuf = (GdkPixbuf *)getData (env, obj);
+  GdkPixbuf *pixbuf = cp_gtk_image_get_pixbuf (env, obj);
   int width, height, rowstride;
   guchar *pixeldata;
   jint *src_array_iter, *src;
@@ -231,10 +235,10 @@ Java_gnu_java_awt_peer_gtk_GtkImage_setPixels(JNIEnv *env, jobject obj,
 }
 
 /**
- * Allocates a Gtk Pixbuf or Pixmap.
+ * Allocates a Gtk Pixbuf 
  */
 JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap(JNIEnv *env, jobject obj)
+Java_gnu_java_awt_peer_gtk_GtkImage_createPixbuf(JNIEnv *env, jobject obj)
 {
   int width, height;
   jclass cls;
@@ -249,35 +253,58 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap(JNIEnv *env, jobject obj)
   g_assert (field != 0);
   height = (*env)->GetIntField (env, obj, field);
 
-  if (offScreen (env, obj) == JNI_FALSE)
-    createRawData (env, obj, gdk_pixbuf_new (GDK_COLORSPACE_RGB, 
-					     TRUE,
-					     8,
-					     width,
-					     height));
-  else
-    createRawData (env, obj, gdk_pixmap_new (NULL, width, height,
-					     gdk_rgb_get_visual ()->depth));
+  createRawData (env, obj, gdk_pixbuf_new (GDK_COLORSPACE_RGB, 
+					   TRUE,
+					   8,
+					   width,
+					   height));
 }
 
 /**
- * Frees the Gtk Pixmap.
+ * Allocates a Gtk Pixbuf 
  */
 JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap(JNIEnv *env, jobject obj)
+Java_gnu_java_awt_peer_gtk_GtkImage_initFromBuffer(JNIEnv *env, jobject obj,
+						   jlong bufferPointer)
 {
-  if (offScreen (env, obj) == JNI_FALSE)
-    gdk_pixbuf_unref ((GdkPixbuf *)getData (env, obj));
-  else
-    g_object_unref ((GdkPixmap *)getData (env, obj));
+  int width, height;
+  jclass cls;
+  jfieldID field;
+  GdkPixbuf *pixbuf;
+  const guchar *bp = JLONG_TO_PTR(const guchar, bufferPointer);
+
+  g_assert(bp != NULL);
+  cls = (*env)->GetObjectClass( env, obj );
+  field = (*env)->GetFieldID( env, cls, "width", "I" );
+  g_assert( field != 0 );
+  width = (*env)->GetIntField( env, obj, field );
+
+  field = (*env)->GetFieldID( env, cls, "height", "I" );
+  g_assert( field != 0 );
+  height = (*env)->GetIntField( env, obj, field );
+
+  pixbuf = gdk_pixbuf_new_from_data( bp,
+				     GDK_COLORSPACE_RGB, TRUE, 8,
+				     width, height, width * 4, NULL, NULL );
+  g_assert( pixbuf != NULL );
+  createRawData( env, obj, pixbuf );
 }
 
 /**
- * Sets this pixmap to a scaled version of the source pixmap.
+ * Frees the Gtk Pixbuf.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_freePixbuf(JNIEnv *env, jobject obj)
+{
+  gdk_pixbuf_unref (cp_gtk_image_get_pixbuf (env, obj));
+}
+
+/**
+ * Sets this to a scaled version of the original pixbuf
  * width and height of the destination GtkImage must be set.
  */
 JNIEXPORT void JNICALL 
-Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap(JNIEnv *env, 
+Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixbuf(JNIEnv *env, 
 						       jobject destination, 
 						       jobject source,
 						       jint hints)
@@ -304,251 +331,25 @@ Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap(JNIEnv *env,
 				width, height,
 				mapHints(hints));
 
-  if (offScreen (env, source) == JNI_TRUE)
-      gdk_pixbuf_unref (pixbuf);
-
   createRawData (env, destination, (void *)dst);
 }
 
-/**
- * Draws the pixbuf at x, y, scaled to width and height and 
- * optionally composited with a given background color.
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled 
-  (JNIEnv *env, jobject obj, jobject gc_obj,
-   jint bg_red, jint bg_green, jint bg_blue, 
-   jint x, jint y, jint width, jint height, jboolean composite)
-{
-  GdkPixbuf* dst;
-  struct graphics *g;
-  guint32 bgColor;
-
-  gdk_threads_enter ();
-  
-  if (width <= 0 || height <= 0)
-    {
-      gdk_threads_leave ();
-      return;
-    }
-
-  bgColor = ((bg_red & 0xFF) << 16) |
-    ((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
-    
-  g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj);
-  
-  if (!g || !GDK_IS_DRAWABLE (g->drawable))
-    {
-      gdk_threads_leave ();
-      return;
-    }
-
-  if (offScreen (env, obj) == JNI_FALSE)
-    {
-      GdkPixbuf* pixbuf = (GdkPixbuf *)getData (env, obj);
-
-      /* Scale and composite the image */
-      if (composite == JNI_TRUE)
-	dst = gdk_pixbuf_composite_color_simple (pixbuf,
-						 width,
-						 height,
-						 GDK_INTERP_BILINEAR,
-						 255,
-						 width,
-						 bgColor,
-						 bgColor);
-      else
-	dst = gdk_pixbuf_scale_simple(pixbuf,
-				      width, height,
-				      GDK_INTERP_BILINEAR);
-
-      gdk_draw_pixbuf (g->drawable,
-		       g->gc,
-		       dst,
-		       0, 0,
-		       x + g->x_offset, y + g->y_offset, 
-		       width, height,
-		       GDK_RGB_DITHER_NORMAL, 0, 0);
-      gdk_pixbuf_unref (dst);
-
-    } else {
-      /* Get a pixmap */
-      GdkPixmap* pixmap = (GdkPixmap *)getData (env, obj);
-      gdk_draw_drawable (g->drawable,
-			 g->gc,
-			 pixmap,
-			 0, 0, /* src x,y */
-			 x + g->x_offset, y + g->y_offset, 
-			 width, height);
-    }
-    
-  gdk_threads_leave ();
-}
-
-/**
- * Draws the pixbuf at x, y, scaled to width and height and 
- * optionally composited and/or flipped with a given background color.
- */
-JNIEXPORT void JNICALL 
-Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped 
-(JNIEnv *env, jobject obj, jobject gc_obj,
- jint bg_red, jint bg_green, jint bg_blue, 
-#if GTK_MINOR_VERSION > 4
- jboolean flipx, jboolean flipy,
-#else
- jboolean flipx __attribute__((unused)),
- jboolean flipy __attribute__((unused)),
-#endif
- jint srcx, jint srcy, jint srcwidth, jint srcheight, 
- jint dstx, jint dsty, jint dstwidth, jint dstheight, 
- jboolean composite)
-{
-  GdkPixbuf *pixbuf;
-  GdkPixbuf *tmp, *dst;
-  struct graphics *g;
-  guint32 bgColor;
-
-  gdk_threads_enter ();
-  
-  if (srcwidth <= 0 || srcheight <= 0
-      || dstwidth <= 0 || dstheight <= 0)
-    {
-      gdk_threads_leave ();
-      return;
-    }
-
-  bgColor = ((bg_red & 0xFF) << 16) |
-    ((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
-    
-  g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj);
-  
-  if (!g || !GDK_IS_DRAWABLE (g->drawable))
-    {
-      gdk_threads_leave ();
-      return;
-    }
-
-  if (offScreen (env, obj) == JNI_FALSE)
-    {
-      pixbuf = (GdkPixbuf *)getData (env, obj);
-
-      /* Get the source area */
-      tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, 
-			    TRUE,
-			    8,
-			    srcwidth,
-			    srcheight);
-
-      gdk_pixbuf_copy_area (pixbuf, 
-			    srcx, srcy,
-			    srcwidth, srcheight,
-			    tmp, 
-			    0, 0); /* dst x , dst y */
-    } else {
-      /* Get a pixbuf from the pixmap */
-      GdkDrawable *pixmap = (GdkDrawable *)getData(env, obj);
-      tmp = gdk_pixbuf_get_from_drawable (NULL,
-					  pixmap,
-					  gdk_drawable_get_colormap( pixmap ),
-					  srcx, srcy,
-					  0, 0, /* dst x , dst y */
-					  srcwidth, srcheight);
-    }
-
-  /* FIXME: This #if should be discarded once I feel comfortable about
-     GTK 2.6 dependence */
-#if GTK_MINOR_VERSION > 4
-  /* Flip it if necessary. */
-  if (flipx == JNI_TRUE)
-    {
-      GdkPixbuf *tmp2 = gdk_pixbuf_flip (tmp, TRUE);
-      gdk_pixbuf_unref (tmp);
-      tmp = tmp2;
-    }
-  if (flipy == JNI_TRUE)
-    {
-      GdkPixbuf *tmp2 = gdk_pixbuf_flip (tmp, FALSE);
-      gdk_pixbuf_unref (tmp);
-      tmp = tmp2;
-    }
-#endif
-  
-  /* Scale and composite the image */
-  if (composite == JNI_TRUE)
-    dst = gdk_pixbuf_composite_color_simple (tmp,
-					     dstwidth,
-					     dstheight,
-					     GDK_INTERP_BILINEAR,
-					     255,
-					     dstwidth,
-					     bgColor,
-					     bgColor);
-  else
-    dst = gdk_pixbuf_scale_simple(tmp,
-				  dstwidth, dstheight,
-				  GDK_INTERP_BILINEAR);
-  gdk_pixbuf_unref (tmp);
-    
-  gdk_draw_pixbuf (g->drawable,
-		   g->gc,
-		   dst,
-		   0, 0,
-		   dstx + g->x_offset, dsty + g->y_offset, 
-		   dstwidth, dstheight,
-		   GDK_RGB_DITHER_NORMAL, 0, 0);
-  
-  gdk_pixbuf_unref (dst);
-
-  gdk_threads_leave ();
-}
-
 /**
  * Used by GtkFramePeer
  */
 GdkPixbuf *cp_gtk_image_get_pixbuf (JNIEnv *env, jobject obj)
 {
-  int width, height;
-  GdkPixbuf *pixbuf;
-  GdkPixmap* pixmap;
   jclass cls;
-  jfieldID field;
-
-  if (offScreen (env, obj) == JNI_FALSE)
-    return (GdkPixbuf *)getData (env, obj);
+  jfieldID data_fid;
+  jobject data;
 
   cls = (*env)->GetObjectClass (env, obj);
-  field = (*env)->GetFieldID (env, cls, "width", "I");
-  g_assert (field != 0);
-  width = (*env)->GetIntField (env, obj, field);
-   
-  field = (*env)->GetFieldID (env, cls, "height", "I");
-  g_assert (field != 0);
-  height = (*env)->GetIntField (env, obj, field);
-
-  /* Get a pixmap */
-  pixmap = (GdkPixmap *)getData (env, obj);
-  pixbuf = gdk_pixbuf_get_from_drawable (NULL,
-					 pixmap,
-					 gdk_drawable_get_colormap( pixmap ),
-					 0, 0, /* src x , src y */
-					 0, 0, /* dst x , dst y */
-					 width, height);
-  return pixbuf;
-}
-
-/**
- * Used by GdkGraphics
- */
-GdkPixmap *cp_gtk_image_get_pixmap (JNIEnv *env, jobject obj)
-{
-  if (offScreen (env, obj) == JNI_FALSE)
-    return NULL;
-  return (GdkPixmap *)getData (env, obj);
-}
+  data_fid = (*env)->GetFieldID (env, cls, "pixbuf", 
+				 "Lgnu/classpath/Pointer;");
+  g_assert (data_fid != 0);
+  data = (*env)->GetObjectField (env, obj, data_fid);
 
-jboolean cp_gtk_image_is_offscreen (JNIEnv *env, jobject obj)
-{
-  return offScreen(env, obj);
+  return (GdkPixbuf *)JCL_GetRawData (env, data);
 }
 
 /**
@@ -593,18 +394,6 @@ static void setWidthHeight (JNIEnv * env, jobject obj, int width, int height)
   (*env)->SetIntField (env, obj, field, (jint)height);
 }
 
-/* Returns the value of the offScreen field. */
-static jboolean offScreen (JNIEnv *env, jobject obj)
-{
-  jclass cls;
-  jfieldID field;
-
-  cls = (*env)->GetObjectClass (env, obj);
-  field = (*env)->GetFieldID (env, cls, "offScreen", "Z");
-  g_assert (field != 0);
-  return (*env)->GetBooleanField (env, obj, field);
-}
-
 /* Store and get the pixbuf pointer */
 static void
 createRawData (JNIEnv * env, jobject obj, void *ptr)
@@ -614,7 +403,7 @@ createRawData (JNIEnv * env, jobject obj, void *ptr)
   jfieldID data_fid;
 
   cls = (*env)->GetObjectClass (env, obj);
-  data_fid = (*env)->GetFieldID (env, cls, "pixmap", 
+  data_fid = (*env)->GetFieldID (env, cls, "pixbuf", 
 				 "Lgnu/classpath/Pointer;");
   g_assert (data_fid != 0);
 
@@ -623,18 +412,3 @@ createRawData (JNIEnv * env, jobject obj, void *ptr)
   (*env)->SetObjectField (env, obj, data_fid, data);
 }
 
-static void *
-getData (JNIEnv * env, jobject obj)
-{
-  jclass cls;
-  jfieldID data_fid;
-  jobject data;
-
-  cls = (*env)->GetObjectClass (env, obj);
-  data_fid = (*env)->GetFieldID (env, cls, "pixmap", 
-				 "Lgnu/classpath/Pointer;");
-  g_assert (data_fid != 0);
-  data = (*env)->GetObjectField (env, obj, data_fid);
-
-  return JCL_GetRawData (env, data);
-}
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index b14330e5fe22..c966f6331a46 100644
--- a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
@@ -185,10 +185,6 @@ Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkInit (JNIEnv *env,
   old_glog_func = g_log_set_default_handler (&glog_func, NULL);
 #endif
 
-#if GTK_CAIRO
-  cp_gtk_graphics2d_init_jni ();
-#endif
-  cp_gtk_graphics_init_jni ();
   cp_gtk_button_init_jni ();
   cp_gtk_checkbox_init_jni ();
   cp_gtk_choice_init_jni ();
diff --git a/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
new file mode 100644
index 000000000000..5ca21a5677a5
--- /dev/null
+++ b/libjava/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
@@ -0,0 +1,216 @@
+/* gnu_java_awt_peer_gtk_VolatileImage.c
+   Copyright (C)  2006 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. */
+
+#include "jcl.h"
+#include "gtkpeer.h"
+#include <gdk/gdkx.h>
+#include <gdk/gdktypes.h>
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkx.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk-pixbuf/gdk-pixdata.h>
+
+#include "gnu_java_awt_peer_gtk_GtkVolatileImage.h"
+#include "cairographics2d.h"
+
+/* prototypes */
+static void *getNativeObject( JNIEnv *env, jobject obj );
+/* static void setNativeObject( JNIEnv *env, jobject obj, void *ptr ); */
+
+GdkPixmap *cp_gtk_get_pixmap( JNIEnv *env, jobject obj);
+
+/**
+ * Creates a cairo surface, ARGB32, native ordering, premultiplied alpha.
+ */
+JNIEXPORT jlong JNICALL 
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_init (JNIEnv *env, 
+						  jobject obj __attribute__ ((__unused__)), 
+						  jobject peer,
+						  jint width, jint height)
+{
+  GtkWidget *widget = NULL;
+  GdkPixmap* pixmap;
+  void *ptr = NULL;
+
+  gdk_threads_enter();
+
+  if( peer != NULL )
+    {
+      ptr = NSA_GET_PTR (env, peer);
+      g_assert (ptr != NULL);
+      
+      widget = GTK_WIDGET (ptr);
+      g_assert (widget != NULL);
+      pixmap = gdk_pixmap_new( widget->window, width, height, -1 );
+    }
+  else
+    pixmap = gdk_pixmap_new( NULL, width, height, 16 );
+
+  gdk_threads_leave();
+
+  g_assert( pixmap != NULL );
+
+  return PTR_TO_JLONG( pixmap );
+}
+
+/**
+ * Destroy the surface
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_destroy (JNIEnv *env, jobject obj)
+{
+  GdkPixmap* pixmap = getNativeObject(env, obj);
+  if( pixmap != NULL )
+    {
+      gdk_threads_enter();
+      g_object_unref( pixmap );
+      gdk_threads_leave();
+    }
+}
+
+/**
+ * Gets all pixels in an array
+ */
+JNIEXPORT jintArray JNICALL 
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_getPixels
+(JNIEnv *env, jobject obj)
+{
+  /* jint *pixeldata, *jpixdata; */
+  jint *jpixdata;
+  GdkPixmap *pixmap;
+  jintArray jpixels;
+  int width, height, depth, size;
+  jclass cls;
+  jfieldID field;
+
+  cls = (*env)->GetObjectClass (env, obj);
+  field = (*env)->GetFieldID (env, cls, "width", "I");
+  g_assert (field != 0);
+  width = (*env)->GetIntField (env, obj, field);
+
+  field = (*env)->GetFieldID (env, cls, "height", "I");
+  g_assert (field != 0);
+  height = (*env)->GetIntField (env, obj, field);
+
+  pixmap = GDK_PIXMAP(getNativeObject(env, obj));
+  g_assert(pixmap != NULL);
+
+  gdk_threads_enter();
+
+  /* get depth in bytes */
+  depth = gdk_drawable_get_depth( pixmap ) >> 3;
+  size = width * height * 4;
+  jpixels = (*env)->NewIntArray ( env, size );
+  jpixdata = (*env)->GetIntArrayElements (env, jpixels, NULL);
+  /*  memcpy (jpixdata, pixeldata, size * sizeof( jint )); */
+
+  (*env)->ReleaseIntArrayElements (env, jpixels, jpixdata, 0);
+
+  gdk_threads_leave();
+
+  return jpixels;
+}
+
+/**
+ * Copy area
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_copyArea
+(JNIEnv *env, jobject obj, jint x, jint y, jint w, jint h, jint dx, jint dy)
+{
+  GdkPixbuf *pixbuf;
+  GdkPixmap* pixmap = getNativeObject(env, obj);
+
+  g_assert (pixmap != NULL);
+
+  gdk_threads_enter();
+  
+  pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, w, h );
+  gdk_pixbuf_get_from_drawable( pixbuf, pixmap, NULL, x, y, 0, 0, w, h );
+  gdk_draw_pixbuf (pixmap, NULL, pixbuf,
+		   0, 0, x + dx, y + dy, 
+		   w, h, 
+		   GDK_RGB_DITHER_NORMAL, 0, 0);
+  gdk_threads_leave();
+}
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_GtkVolatileImage_drawVolatile
+(JNIEnv *env, jobject obj, jlong ptr, jint x, jint y, jint w, jint h)
+{
+  GdkPixmap *dst, *src;
+  GdkGC *gc;
+
+  src = JLONG_TO_PTR(GdkPixmap, ptr);
+  dst = getNativeObject(env, obj);
+  g_assert (src != NULL);
+  g_assert (dst != NULL);
+
+  gdk_threads_enter();
+ 
+  gc = gdk_gc_new( dst );
+  gdk_draw_drawable(dst,
+		    gc,
+		    src,
+		    0, 0,
+		    x, y,
+		    w, h);
+  g_object_unref( gc );
+
+  gdk_threads_leave();
+}
+
+GdkPixmap *cp_gtk_get_pixmap( JNIEnv *env, jobject obj)
+{
+  return (GdkPixmap *)getNativeObject(env, obj);
+}
+
+/**
+ * Gets the native object field.
+ */
+static void *
+getNativeObject( JNIEnv *env, jobject obj )
+{
+  jclass cls;
+  jlong value;
+  jfieldID nofid;
+  cls = (*env)->GetObjectClass( env, obj );
+  nofid = (*env)->GetFieldID( env, cls, "nativePointer", "J" );
+  value = (*env)->GetLongField( env, obj, nofid );
+  (*env)->DeleteLocalRef( env, cls );
+  return JLONG_TO_PTR(void, value);
+}
diff --git a/libjava/classpath/native/jni/gtk-peer/gtkpeer.h b/libjava/classpath/native/jni/gtk-peer/gtkpeer.h
index 9a1590b81d37..065d20608f56 100644
--- a/libjava/classpath/native/jni/gtk-peer/gtkpeer.h
+++ b/libjava/classpath/native/jni/gtk-peer/gtkpeer.h
@@ -36,12 +36,14 @@ obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 
+#include <cairo.h>
 #include <gtk/gtk.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <config.h>
 #include "native_state.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include <jni.h>
 
@@ -54,6 +56,7 @@ exception statement from your version. */
 
 extern struct state_table *cp_gtk_native_state_table;
 extern struct state_table *cp_gtk_native_global_ref_table;
+extern struct state_table *cp_gtk_native_graphics2d_state_table;
 
 #define NSA_INIT(env, clazz) \
    do {cp_gtk_native_state_table = cp_gtk_init_state_table (env, clazz); \
@@ -83,34 +86,21 @@ extern struct state_table *cp_gtk_native_global_ref_table;
     (*env)->DeleteGlobalRef (env, *globRefPtr); \
     free (globRefPtr);} while (0)
 
-extern struct state_table *cp_gtk_native_graphics_state_table;
+#define NSA_G2D_INIT(env, clazz) \
+  cp_gtk_native_graphics2d_state_table = cp_gtk_init_state_table (env, clazz)
 
-#define NSA_G_INIT(env, clazz) \
-  cp_gtk_native_graphics_state_table = cp_gtk_init_state_table (env, clazz)
+#define NSA_GET_G2D_PTR(env, obj) \
+  cp_gtk_get_state (env, obj, cp_gtk_native_graphics2d_state_table)
 
-#define NSA_GET_G_PTR(env, obj) \
-  cp_gtk_get_state (env, obj, cp_gtk_native_graphics_state_table)
+#define NSA_SET_G2D_PTR(env, obj, ptr) \
+  cp_gtk_set_state (env, obj, cp_gtk_native_graphics2d_state_table, (void *)ptr)
 
-#define NSA_SET_G_PTR(env, obj, ptr) \
-  cp_gtk_set_state (env, obj, cp_gtk_native_graphics_state_table, (void *)ptr)
-
-#define NSA_DEL_G_PTR(env, obj) \
-  cp_gtk_remove_state_slot (env, obj, cp_gtk_native_graphics_state_table)
+#define NSA_DEL_G2D_PTR(env, obj) \
+  cp_gtk_remove_state_slot (env, obj, cp_gtk_native_graphics2d_state_table)
 
 #define SWAPU32(w)							\
   (((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
 
-struct graphics
-{
-  GdkDrawable *drawable;
-  GdkGC *gc;
-  GdkColormap *cm;
-  PangoFontDescription *pango_font;
-  PangoContext *pango_context;
-  PangoLayout *pango_layout;
-  jint x_offset, y_offset;
-};
-
 /* New-style event masks. */
 #define AWT_BUTTON1_DOWN_MASK (1 << 10)
 #define AWT_BUTTON2_DOWN_MASK (1 << 11)
@@ -192,14 +182,12 @@ jint cp_gtk_state_to_awt_mods (guint state);
 
 /* Image helpers */
 GdkPixbuf *cp_gtk_image_get_pixbuf (JNIEnv *env, jobject obj);
-GdkPixmap *cp_gtk_image_get_pixmap (JNIEnv *env, jobject obj);
-jboolean cp_gtk_image_is_offscreen (JNIEnv *env, jobject obj);
+
+/* Component Graphics helpers */
+void cp_gtk_grab_current_drawable(GtkWidget *widget, GdkDrawable **draw,
+				  GdkWindow **win);
 
 /* JNI initialization functions */
-#if GTK_CAIRO
-void cp_gtk_graphics2d_init_jni (void);
-#endif
-void cp_gtk_graphics_init_jni (void);
 void cp_gtk_button_init_jni (void);
 void cp_gtk_checkbox_init_jni (void);
 void cp_gtk_choice_init_jni (void);
@@ -221,6 +209,8 @@ void cp_gtk_textcomponent_connect_signals (GObject *ptr, jobject *gref);
 /* Debugging */
 void cp_gtk_print_current_thread (void);
 
+GdkPixmap *cp_gtk_get_pixmap( JNIEnv *env, jobject obj);
+
 #define SYNCHRONIZE_GDK 0
 
 #define DEBUG_LOCKING 0
diff --git a/libjava/classpath/native/jni/java-io/Makefile.in b/libjava/classpath/native/jni/java-io/Makefile.in
index 940e46e73493..ca4b8a4728ff 100644
--- a/libjava/classpath/native/jni/java-io/Makefile.in
+++ b/libjava/classpath/native/jni/java-io/Makefile.in
@@ -92,8 +92,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -120,8 +118,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -144,6 +146,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -159,9 +163,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -183,6 +186,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -196,6 +200,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -209,6 +215,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -228,11 +235,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/java-lang/Makefile.in b/libjava/classpath/native/jni/java-lang/Makefile.in
index ed76c1546c35..70e673b3b31d 100644
--- a/libjava/classpath/native/jni/java-lang/Makefile.in
+++ b/libjava/classpath/native/jni/java-lang/Makefile.in
@@ -98,8 +98,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -126,8 +124,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -150,6 +152,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -165,9 +169,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -189,6 +192,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -202,6 +206,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -215,6 +221,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -234,11 +241,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/java-net/Makefile.in b/libjava/classpath/native/jni/java-net/Makefile.in
index 99511d08b031..cc47eb3fb73c 100644
--- a/libjava/classpath/native/jni/java-net/Makefile.in
+++ b/libjava/classpath/native/jni/java-net/Makefile.in
@@ -102,8 +102,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -130,8 +128,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -154,6 +156,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -169,9 +173,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -193,6 +196,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -206,6 +210,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -219,6 +225,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -238,11 +245,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/java-nio/Makefile.in b/libjava/classpath/native/jni/java-nio/Makefile.in
index 85ff65ed31fc..5634c92cea5b 100644
--- a/libjava/classpath/native/jni/java-nio/Makefile.in
+++ b/libjava/classpath/native/jni/java-nio/Makefile.in
@@ -99,8 +99,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -127,8 +125,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -151,6 +153,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -166,9 +170,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -190,6 +193,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -203,6 +207,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -216,6 +222,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -235,11 +242,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/java-util/Makefile.in b/libjava/classpath/native/jni/java-util/Makefile.in
index 7f013ab83955..7adf1a4ddaa2 100644
--- a/libjava/classpath/native/jni/java-util/Makefile.in
+++ b/libjava/classpath/native/jni/java-util/Makefile.in
@@ -90,8 +90,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -118,8 +116,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -142,6 +144,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -157,9 +161,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -181,6 +184,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -194,6 +198,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -207,6 +213,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -226,11 +233,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/midi-alsa/Makefile.in b/libjava/classpath/native/jni/midi-alsa/Makefile.in
index 48090e8e72d1..b0650c08d03c 100644
--- a/libjava/classpath/native/jni/midi-alsa/Makefile.in
+++ b/libjava/classpath/native/jni/midi-alsa/Makefile.in
@@ -93,8 +93,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -121,8 +119,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -145,6 +147,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -160,9 +164,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -184,6 +187,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -197,6 +201,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -210,6 +216,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -229,11 +236,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/midi-dssi/Makefile.in b/libjava/classpath/native/jni/midi-dssi/Makefile.in
index 6383c65485d4..969e029c7a4d 100644
--- a/libjava/classpath/native/jni/midi-dssi/Makefile.in
+++ b/libjava/classpath/native/jni/midi-dssi/Makefile.in
@@ -93,8 +93,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -121,8 +119,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -145,6 +147,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -160,9 +164,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -184,6 +187,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -197,6 +201,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -210,6 +216,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -229,11 +236,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/qt-peer/.cvsignore b/libjava/classpath/native/jni/qt-peer/.cvsignore
new file mode 100644
index 000000000000..369a52a2a3c2
--- /dev/null
+++ b/libjava/classpath/native/jni/qt-peer/.cvsignore
@@ -0,0 +1,9 @@
+*.o
+*.a
+*.lo
+*.la
+.libs
+.deps
+Makefile
+Makefile.in
+slotcallbacks.moc.h
diff --git a/libjava/classpath/native/jni/qt-peer/Makefile.in b/libjava/classpath/native/jni/qt-peer/Makefile.in
index e9c2bffa4299..537ead6318b3 100644
--- a/libjava/classpath/native/jni/qt-peer/Makefile.in
+++ b/libjava/classpath/native/jni/qt-peer/Makefile.in
@@ -116,8 +116,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -144,8 +142,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -168,6 +170,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -183,9 +187,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -207,6 +210,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -220,6 +224,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -233,6 +239,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -252,11 +259,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/jni/qt-peer/eventmethods.h b/libjava/classpath/native/jni/qt-peer/eventmethods.h
index ea5d45a5cafa..ae56da8e7aa6 100644
--- a/libjava/classpath/native/jni/qt-peer/eventmethods.h
+++ b/libjava/classpath/native/jni/qt-peer/eventmethods.h
@@ -1,5 +1,5 @@
 /* eventmethods.cpp --
-   Copyright (C)  2005  Free Software Foundation, Inc.
+   Copyright (C)  2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -62,7 +62,7 @@ private:
     env->DeleteGlobalRef(componentCls);
   }
 
-  void callVoidMethod(char *methodName)
+  void callVoidMethod(const char *methodName)
   {
     JNIEnv *env;
     vm->GetEnv((void **)&env, JNI_VERSION_1_1);
@@ -72,7 +72,7 @@ private:
     env->CallVoidMethod( target, fireEventID );
   }
 
-  void callMouseMethod(char *methodName, 
+  void callMouseMethod(const char *methodName,
 		       int modifiers, int x, int y, int clickCount)
   {
     JNIEnv *env;
diff --git a/libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp b/libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp
index 1ac17145c2f0..6f35c89b9bdb 100644
--- a/libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp
+++ b/libjava/classpath/native/jni/qt-peer/qtmenupeer.cpp
@@ -44,9 +44,11 @@ exception statement from your version. */
 #include "slotcallbacks.h"
 #include "componentevent.h"
 
-#define ADDMENU 0
-#define ADDITEM 1
-#define ADDSEPA 2
+typedef enum ActionType {
+  ActionMenu,
+  ActionItem,
+  ActionSeparator
+} ActionType;
 
 // Sets the title, but also tear-off.
 class MenuTitleEvent : public AWTEvent {
@@ -81,18 +83,18 @@ class MenuAction : public AWTEvent {
  private:
   QMenu *menu;
   QAction *action;
-  int isMenu; // 0 to add a menu, 1 to add an item, 2 to add a seperator
+  ActionType actionType; // type of action to add
   JavaVM *vm;
   jobject menuPeer;
   jobject itemPeer;
 
 public:
   MenuAction(JNIEnv *env, jobject mp, jobject ip, QMenu *m, QAction *a, 
-	     bool ismenu) : AWTEvent()
+	     ActionType actionType) : AWTEvent()
   {
     menu = m;
     action = a;
-    isMenu = ismenu;
+    this->actionType = actionType;
     env->GetJavaVM( &vm );
     menuPeer = env->NewGlobalRef( mp );
     if( ip != NULL )
@@ -104,35 +106,22 @@ public:
   void runEvent()
   {
     JNIEnv *env;
-    QAction *newAction; // adding an action creates a new duplicate.
     vm->GetEnv((void **)&env, JNI_VERSION_1_1);
-
-    switch(isMenu)
-      {
-      case ADDMENU:
-	newAction = menu->addMenu( (QMenu *)action );
-	break;
-      case ADDITEM:
-	newAction = menu->addAction(action->text());
-	newAction->setSeparator(action->isSeparator());
-	newAction->setCheckable(action->isCheckable());
-	//	delete action;
-	break;
-      case ADDSEPA:
-	newAction = menu->addSeparator();
-	break;
-      }
+    if (actionType == ActionMenu)
+      menu->addMenu ((QMenu *) action);
+    else
+      menu->addAction (action);
 
     jclass menuCls = env->GetObjectClass( menuPeer );
     jmethodID mid = env->GetMethodID(menuCls, "add", "(J)V");
     env->DeleteLocalRef(menuCls);
-    env->CallVoidMethod( menuPeer, mid, (jlong)newAction );
+    env->CallVoidMethod( menuPeer, mid, (jlong)action );
 
     env->DeleteGlobalRef( menuPeer );
     if( itemPeer != NULL )
       {
-	setNativeObject( env, itemPeer, newAction );
-	connectAction(newAction, env, itemPeer);
+	setNativeObject( env, itemPeer, action );
+	connectAction(action, env, itemPeer);
 	env->DeleteGlobalRef( itemPeer );
       }
   }
@@ -190,7 +179,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertSeperator
   QMenu *menu = (QMenu *)getNativeObject( env, obj );
   assert( menu );
   mainThread->postEventToMain( new MenuAction( env, obj, NULL,
-					       menu, NULL, ADDSEPA ) );
+					       menu, NULL, ActionSeparator ) );
 }
 
 /*
@@ -205,7 +194,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertItem
   QAction *action = (QAction *)getNativeObject( env, item );
   assert( action );
 
-  mainThread->postEventToMain( new MenuAction( env, obj, item, menu, action, ADDITEM ));
+  mainThread->postEventToMain( new MenuAction( env, obj, item, menu, action, ActionItem ));
 }
 
 /*
@@ -220,7 +209,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuPeer_insertMenu
   QMenu *insMenu = (QMenu *)getNativeObject(env, menu);
   assert( insMenu );
 
-  mainThread->postEventToMain( new MenuAction( env, obj, menu, thisMenu, (QAction *)insMenu, ADDMENU ) );
+  mainThread->postEventToMain( new MenuAction( env, obj, menu, thisMenu, (QAction *)insMenu, ActionMenu ) );
 }
 
 /*
diff --git a/libjava/classpath/native/jni/xmlj/Makefile.in b/libjava/classpath/native/jni/xmlj/Makefile.in
index 482b5a8421fc..01f275488603 100644
--- a/libjava/classpath/native/jni/xmlj/Makefile.in
+++ b/libjava/classpath/native/jni/xmlj/Makefile.in
@@ -92,8 +92,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -120,8 +118,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -144,6 +146,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -159,9 +163,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -183,6 +186,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -196,6 +200,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -209,6 +215,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -228,11 +235,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/plugin/.cvsignore b/libjava/classpath/native/plugin/.cvsignore
new file mode 100644
index 000000000000..17cbfe80b7d0
--- /dev/null
+++ b/libjava/classpath/native/plugin/.cvsignore
@@ -0,0 +1,6 @@
+Makefile.in
+.deps
+.libs
+libgcjwebplugin_la-gcjwebplugin.lo
+libgcjwebplugin.la
+Makefile
diff --git a/libjava/classpath/native/plugin/Makefile.am b/libjava/classpath/native/plugin/Makefile.am
new file mode 100644
index 000000000000..19c7618d8d52
--- /dev/null
+++ b/libjava/classpath/native/plugin/Makefile.am
@@ -0,0 +1,19 @@
+lib_LTLIBRARIES = libgcjwebplugin.la
+
+libgcjwebplugin_la_SOURCES = gcjwebplugin.cc
+
+libgcjwebplugin_la_CXXFLAGS = \
+	-Wall -DAPPLETVIEWER_EXECUTABLE="\"$(bindir)/appletviewer\"" \
+	-DPLUGIN_DATA_DIRECTORY="\"$(PLUGIN_DIR)/gcjwebplugin-data\"" \
+	$(MOZILLA_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS)
+
+libgcjwebplugin_la_LDFLAGS = -avoid-version \
+	$(GLIB_LIBS) $(GTK_LIBS) \
+	-lstdc++
+
+install-plugin: $(lib_LTLIBRARIES)
+	$(INSTALL) -d -m0755 $(DESTDIR)$(PLUGIN_DIR)
+	$(INSTALL) .libs/libgcjwebplugin.so $(DESTDIR)$(PLUGIN_DIR)
+
+uninstall-plugin:
+	rm -f $(DESTDIR)$(PLUGIN_DIR)/libgcjwebplugin.so
diff --git a/libjava/classpath/native/plugin/Makefile.in b/libjava/classpath/native/plugin/Makefile.in
new file mode 100644
index 000000000000..22b8d3d09342
--- /dev/null
+++ b/libjava/classpath/native/plugin/Makefile.in
@@ -0,0 +1,596 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = native/plugin
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
+	$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
+	$(top_srcdir)/m4/acinclude.m4 \
+	$(top_srcdir)/m4/ax_create_stdint_h.m4 \
+	$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
+	$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)"
+libLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libgcjwebplugin_la_LIBADD =
+am_libgcjwebplugin_la_OBJECTS = libgcjwebplugin_la-gcjwebplugin.lo
+libgcjwebplugin_la_OBJECTS = $(am_libgcjwebplugin_la_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libgcjwebplugin_la_SOURCES)
+DIST_SOURCES = $(libgcjwebplugin_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
+BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CLASSPATH_CONVENIENCE = @CLASSPATH_CONVENIENCE@
+CLASSPATH_INCLUDES = @CLASSPATH_INCLUDES@
+CLASSPATH_MODULE = @CLASSPATH_MODULE@
+COLLECTIONS_PREFIX = @COLLECTIONS_PREFIX@
+CP = @CP@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CREATE_ALSA_LIBRARIES_FALSE = @CREATE_ALSA_LIBRARIES_FALSE@
+CREATE_ALSA_LIBRARIES_TRUE = @CREATE_ALSA_LIBRARIES_TRUE@
+CREATE_API_DOCS_FALSE = @CREATE_API_DOCS_FALSE@
+CREATE_API_DOCS_TRUE = @CREATE_API_DOCS_TRUE@
+CREATE_COLLECTIONS_FALSE = @CREATE_COLLECTIONS_FALSE@
+CREATE_COLLECTIONS_TRUE = @CREATE_COLLECTIONS_TRUE@
+CREATE_CORE_JNI_LIBRARIES_FALSE = @CREATE_CORE_JNI_LIBRARIES_FALSE@
+CREATE_CORE_JNI_LIBRARIES_TRUE = @CREATE_CORE_JNI_LIBRARIES_TRUE@
+CREATE_DSSI_LIBRARIES_FALSE = @CREATE_DSSI_LIBRARIES_FALSE@
+CREATE_DSSI_LIBRARIES_TRUE = @CREATE_DSSI_LIBRARIES_TRUE@
+CREATE_GTK_PEER_LIBRARIES_FALSE = @CREATE_GTK_PEER_LIBRARIES_FALSE@
+CREATE_GTK_PEER_LIBRARIES_TRUE = @CREATE_GTK_PEER_LIBRARIES_TRUE@
+CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
+CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
+CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
+CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
+CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
+CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
+CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
+CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+ECJ = @ECJ@
+EGREP = @EGREP@
+ENABLE_LOCAL_SOCKETS_FALSE = @ENABLE_LOCAL_SOCKETS_FALSE@
+ENABLE_LOCAL_SOCKETS_TRUE = @ENABLE_LOCAL_SOCKETS_TRUE@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+EXAMPLESDIR = @EXAMPLESDIR@
+EXEEXT = @EXEEXT@
+FASTJAR = @FASTJAR@
+FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
+FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
+FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
+FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
+FOUND_GCJX_TRUE = @FOUND_GCJX_TRUE@
+FOUND_GCJ_FALSE = @FOUND_GCJ_FALSE@
+FOUND_GCJ_TRUE = @FOUND_GCJ_TRUE@
+FOUND_JIKES_FALSE = @FOUND_JIKES_FALSE@
+FOUND_JIKES_TRUE = @FOUND_JIKES_TRUE@
+FOUND_KJC_FALSE = @FOUND_KJC_FALSE@
+FOUND_KJC_TRUE = @FOUND_KJC_TRUE@
+FREETYPE2_CFLAGS = @FREETYPE2_CFLAGS@
+FREETYPE2_LIBS = @FREETYPE2_LIBS@
+GCJ = @GCJ@
+GCJX = @GCJX@
+GJDOC = @GJDOC@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
+INSTALL_CLASS_FILES_FALSE = @INSTALL_CLASS_FILES_FALSE@
+INSTALL_CLASS_FILES_TRUE = @INSTALL_CLASS_FILES_TRUE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_GLIBJ_ZIP_FALSE = @INSTALL_GLIBJ_ZIP_FALSE@
+INSTALL_GLIBJ_ZIP_TRUE = @INSTALL_GLIBJ_ZIP_TRUE@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION = @JAVA_LANG_SYSTEM_EXPLICIT_INITIALIZATION@
+JAY = @JAY@
+JAY_SKELETON = @JAY_SKELETON@
+JIKES = @JIKES@
+JIKESENCODING = @JIKESENCODING@
+JIKESWARNINGS = @JIKESWARNINGS@
+KJC = @KJC@
+LDFLAGS = @LDFLAGS@
+LIBDEBUG = @LIBDEBUG@
+LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVERSION = @LIBVERSION@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
+QT_CFLAGS = @QT_CFLAGS@
+QT_LIBS = @QT_LIBS@
+RANLIB = @RANLIB@
+REGEN_PARSERS_FALSE = @REGEN_PARSERS_FALSE@
+REGEN_PARSERS_TRUE = @REGEN_PARSERS_TRUE@
+REMOVE = @REMOVE@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRICT_WARNING_CFLAGS = @STRICT_WARNING_CFLAGS@
+STRIP = @STRIP@
+USER_CLASSLIB = @USER_CLASSLIB@
+USER_JAVAH = @USER_JAVAH@
+USER_SPECIFIED_CLASSLIB_FALSE = @USER_SPECIFIED_CLASSLIB_FALSE@
+USER_SPECIFIED_CLASSLIB_TRUE = @USER_SPECIFIED_CLASSLIB_TRUE@
+USER_SPECIFIED_JAVAH_FALSE = @USER_SPECIFIED_JAVAH_FALSE@
+USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
+USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
+USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
+VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+XML_CFLAGS = @XML_CFLAGS@
+XML_LIBS = @XML_LIBS@
+XSLT_CFLAGS = @XSLT_CFLAGS@
+XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZIP = @ZIP@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+default_toolkit = @default_toolkit@
+exec_prefix = @exec_prefix@
+glibjdir = @glibjdir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+nativeexeclibdir = @nativeexeclibdir@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+vm_classes = @vm_classes@
+lib_LTLIBRARIES = libgcjwebplugin.la
+libgcjwebplugin_la_SOURCES = gcjwebplugin.cc
+libgcjwebplugin_la_CXXFLAGS = \
+	-Wall -DAPPLETVIEWER_EXECUTABLE="\"$(bindir)/appletviewer\"" \
+	-DPLUGIN_DATA_DIRECTORY="\"$(PLUGIN_DIR)/gcjwebplugin-data\"" \
+	$(MOZILLA_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS)
+
+libgcjwebplugin_la_LDFLAGS = -avoid-version \
+	$(GLIB_LIBS) $(GTK_LIBS) \
+	-lstdc++
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cc .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  native/plugin/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  native/plugin/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  if test -f $$p; then \
+	    f=$(am__strip_dir) \
+	    echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+	    $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-libLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  p=$(am__strip_dir) \
+	  echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+	  $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
+	done
+
+clean-libLTLIBRARIES:
+	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libgcjwebplugin.la: $(libgcjwebplugin_la_OBJECTS) $(libgcjwebplugin_la_DEPENDENCIES) 
+	$(CXXLINK) -rpath $(libdir) $(libgcjwebplugin_la_LDFLAGS) $(libgcjwebplugin_la_OBJECTS) $(libgcjwebplugin_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgcjwebplugin_la-gcjwebplugin.Plo@am__quote@
+
+.cc.o:
+@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+@am__fastdepCXX_TRUE@	if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+@am__fastdepCXX_TRUE@	if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(LTCXXCOMPILE) -c -o $@ $<
+
+libgcjwebplugin_la-gcjwebplugin.lo: gcjwebplugin.cc
+@am__fastdepCXX_TRUE@	if $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgcjwebplugin_la_CXXFLAGS) $(CXXFLAGS) -MT libgcjwebplugin_la-gcjwebplugin.lo -MD -MP -MF "$(DEPDIR)/libgcjwebplugin_la-gcjwebplugin.Tpo" -c -o libgcjwebplugin_la-gcjwebplugin.lo `test -f 'gcjwebplugin.cc' || echo '$(srcdir)/'`gcjwebplugin.cc; \
+@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libgcjwebplugin_la-gcjwebplugin.Tpo" "$(DEPDIR)/libgcjwebplugin_la-gcjwebplugin.Plo"; else rm -f "$(DEPDIR)/libgcjwebplugin_la-gcjwebplugin.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='gcjwebplugin.cc' object='libgcjwebplugin_la-gcjwebplugin.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@	$(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgcjwebplugin_la_CXXFLAGS) $(CXXFLAGS) -c -o libgcjwebplugin_la-gcjwebplugin.lo `test -f 'gcjwebplugin.cc' || echo '$(srcdir)/'`gcjwebplugin.cc
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+	for dir in "$(DESTDIR)$(libdir)"; do \
+	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
+	done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libLTLIBRARIES clean-libtool ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am \
+	install-libLTLIBRARIES install-man install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-info-am \
+	uninstall-libLTLIBRARIES
+
+
+install-plugin: $(lib_LTLIBRARIES)
+	$(INSTALL) -d -m0755 $(DESTDIR)$(PLUGIN_DIR)
+	$(INSTALL) .libs/libgcjwebplugin.so $(DESTDIR)$(PLUGIN_DIR)
+
+uninstall-plugin:
+	rm -f $(DESTDIR)$(PLUGIN_DIR)/libgcjwebplugin.so
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libjava/classpath/native/plugin/gcjwebplugin.cc b/libjava/classpath/native/plugin/gcjwebplugin.cc
new file mode 100644
index 000000000000..deae81097721
--- /dev/null
+++ b/libjava/classpath/native/plugin/gcjwebplugin.cc
@@ -0,0 +1,1759 @@
+/* gcjwebplugin.cc -- web browser plugin to execute Java applets
+   Copyright (C) 2003, 2004, 2006  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. */
+
+// System includes.
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+// Netscape plugin API includes.
+#include <npapi.h>
+#include <npupp.h>
+
+// GLib includes.
+#include <glib.h>
+#include <glib/gstdio.h>
+
+// GTK includes.
+#include <gtk/gtk.h>
+
+// gcjwebplugin includes.
+#include "config.h"
+
+// Documentbase retrieval includes.
+#include <nsIPluginInstance.h>
+#include <nsIPluginInstancePeer.h>
+#include <nsIPluginTagInfo2.h>
+
+// Debugging macros.
+#define PLUGIN_DEBUG(message)                                           \
+  g_print ("GCJ PLUGIN: thread %p: %s\n", g_thread_self (), message)
+
+#define PLUGIN_DEBUG_TWO(first, second)                                 \
+  g_print ("GCJ PLUGIN: thread %p: %s %s\n", g_thread_self (),          \
+           first, second)
+
+// Error reporting macros.
+#define PLUGIN_ERROR(message)                                       \
+  g_printerr ("%s:%d: thread %p: Error: %s\n", __FILE__, __LINE__,  \
+              g_thread_self (), message)
+
+#define PLUGIN_ERROR_TWO(first, second)                                 \
+  g_printerr ("%s:%d: thread %p: Error: %s: %s\n", __FILE__, __LINE__,  \
+              g_thread_self (), first, second)
+
+// Plugin information passed to about:plugins.
+#define PLUGIN_NAME "GCJ Web Browser Plugin"
+#define PLUGIN_DESC "The " PLUGIN_NAME " executes Java applets."
+#define PLUGIN_MIME_DESC                                           \
+  "application/x-java-vm:class,jar:GCJ;"                           \
+  "application/x-java-applet:class,jar:GCJ;"                       \
+  "application/x-java-applet;version=1.1:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.1.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.1.2:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.1.3:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.2:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.2.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.2.2:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.3:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.3.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.4:class,jar:GCJ;"           \
+  "application/x-java-applet;version=1.4.1:class,jar:GCJ;"         \
+  "application/x-java-applet;version=1.4.2:class,jar:GCJ;"         \
+  "application/x-java-applet;jpi-version=1.4.2_01:class,jar:GCJ;"  \
+  "application/x-java-bean:class,jar:GCJ;"                         \
+  "application/x-java-bean;version=1.1:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.1.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.1.2:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.1.3:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.2:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.2.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.2.2:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.3:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.3.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.4:class,jar:GCJ;"             \
+  "application/x-java-bean;version=1.4.1:class,jar:GCJ;"           \
+  "application/x-java-bean;version=1.4.2:class,jar:GCJ;"           \
+  "application/x-java-bean;jpi-version=1.4.2_01:class,jar:GCJ;"
+#define PLUGIN_URL NS_INLINE_PLUGIN_CONTRACTID_PREFIX NS_JVM_MIME_TYPE
+#define PLUGIN_MIME_TYPE "application/x-java-vm"
+#define PLUGIN_FILE_EXTS "class,jar,zip"
+#define PLUGIN_MIME_COUNT 1
+
+// Security dialog messages.
+#define RESPONSE_TRUST_APPLET "Trust Applet"
+#define RESPONSE_TRUST_APPLET_ADD_TO_LIST "Trust Applet and Add to Whitelist"
+#define WHITELIST_FILENAME PLUGIN_DATA_DIRECTORY "/whitelist.txt"
+#define SECURITY_WARNING                                        \
+  "%s wants to load an applet.\n"                               \
+  "GNU Classpath's security implementation is not complete.\n"  \
+  "HOSTILE APPLETS WILL STEAL AND/OR DESTROY YOUR DATA!\n"
+#define SECURITY_DESCRIPTION                                            \
+  "Click \"Cancel\" if you do not trust the source of this applet.\n"   \
+  "Click \"Trust Applet\" to load and run this applet now.\n"           \
+  "Click \"Trust Applet and Add To Whitelist\" to always load"          \
+  " and run this applet from now on, without asking.\n"                 \
+  "The whitelist is a list of the URLs from which you trust"            \
+  " applets.\n"                                                         \
+  "Your whitelist file is \"" WHITELIST_FILENAME "\"."
+#define FAILURE_MESSAGE                                                 \
+  "This page wants to load an applet.\n"                                \
+  "The appletviewer is missing or not installed properly in \""         \
+  APPLETVIEWER_EXECUTABLE "\"."        
+
+// Documentbase retrieval required definition.
+static NS_DEFINE_IID (kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
+
+// Browser function table.
+static NPNetscapeFuncs browserFunctions;
+
+// Keeps track of initialization. NP_Initialize should only be
+// called once.
+bool initialized = false;
+
+// GCJPluginData stores all the data associated with a single plugin
+// instance.  A separate plugin instance is created for each <APPLET>
+// tag.  For now, each plugin instance spawns its own applet viewer
+// process but this may need to change if we find pages containing
+// multiple applets that expect to be running in the same VM.
+struct GCJPluginData
+{
+  // A unique identifier for this plugin window.
+  gchar* instance_string;
+  // Applet viewer input pipe name.
+  gchar* in_pipe_name;
+  // Applet viewer input channel.
+  GIOChannel* in_from_appletviewer;
+  // Applet viewer input watch source.
+  gint in_watch_source;
+  // Applet viewer output pipe name.
+  gchar* out_pipe_name;
+  // Applet viewer output channel.
+  GIOChannel* out_to_appletviewer;
+  // Applet viewer output watch source.
+  gint out_watch_source;
+  // Mutex to protect appletviewer_alive.
+  GMutex* appletviewer_mutex;
+  // Back-pointer to the plugin instance to which this data belongs.
+  // This should not be freed but instead simply set to NULL.
+  NPP owner;
+  // FALSE if the applet viewer process has died.  All code
+  // communicating with the applet viewer should check this flag
+  // before attempting to read from/write to the applet viewer pipes.
+  gboolean appletviewer_alive;
+  // The address of the plugin window.  This should not be freed but
+  // instead simply set to NULL.
+  gpointer window_handle;
+  // The last plugin window width sent to us by the browser.
+  guint32 window_width;
+  // The last plugin window height sent to us by the browser.
+  guint32 window_height;
+};
+
+// Documentbase retrieval type-punning union.
+typedef union
+{
+  void** void_field;
+  nsIPluginTagInfo2** info_field;
+} info_union;
+
+// Static instance helper functions.
+// Have the browser allocate a new GCJPluginData structure.
+static void plugin_data_new (GCJPluginData** data);
+// Documentbase retrieval.
+static gchar* plugin_get_documentbase (NPP instance);
+// plugin failure handling.
+static bool plugin_failed ();
+// Whitelist handling.
+static bool plugin_user_trusts_documentbase (char* documentbase);
+static bool plugin_ask_user_about_documentbase (char* documentbase);
+static void plugin_add_documentbase_to_whitelist (char* documentbase);
+// Callback used to monitor input pipe status.
+static gboolean plugin_in_pipe_callback (GIOChannel* source,
+                                         GIOCondition condition,
+                                         gpointer plugin_data);
+// Callback used to monitor output pipe status.
+static gboolean plugin_out_pipe_callback (GIOChannel* source,
+                                          GIOCondition condition,
+                                          gpointer plugin_data);
+static NPError plugin_start_appletviewer (GCJPluginData* data);
+static gchar* plugin_create_applet_tag (int16 argc, char* argn[],
+                                        char* argv[]);
+static void plugin_send_message_to_appletviewer (GCJPluginData* data,
+                                                 gchar const* message);
+static void plugin_stop_appletviewer (GCJPluginData* data);
+// Uninitialize GCJPluginData structure and delete pipes.
+static void plugin_data_destroy (GCJPluginData** data);
+
+// Global instance counter.
+// Mutex to protect plugin_instance_counter.
+static GMutex* plugin_instance_mutex = NULL;
+// A counter used to create uniquely named pipes.
+static gulong plugin_instance_counter = 0;
+// The user's documentbase whitelist.
+static GIOChannel* whitelist_file = NULL;
+// A global variable for reporting GLib errors.  This must be free'd
+// and set to NULL after each use.
+static GError* channel_error = NULL;
+
+// Functions prefixed by GCJ_ are instance functions.  They are called
+// by the browser and operate on instances of GCJPluginData.
+// Functions prefixed by plugin_ are static helper functions.
+// Functions prefixed by NP_ are factory functions.  They are called
+// by the browser and provide functionality needed to create plugin
+// instances.
+
+// INSTANCE FUNCTIONS
+
+// Creates a new gcjwebplugin instance.  This function creates a
+// GCJPluginData* and stores it in instance->pdata.  The following
+// GCJPluginData fiels are initialized: instance_string, in_pipe_name,
+// in_from_appletviewer, in_watch_source, out_pipe_name,
+// out_to_appletviewer, out_watch_source, appletviewer_mutex, owner,
+// appletviewer_alive.  In addition two pipe files are created.  All
+// of those fields must be properly destroyed, and the pipes deleted,
+// by GCJ_Destroy.  If an error occurs during initialization then this
+// function will free anything that's been allocated so far, set
+// instance->pdata to NULL and return an error code.
+NPError
+GCJ_New (NPMIMEType pluginType, NPP instance, uint16 mode,
+         int16 argc, char* argn[], char* argv[],
+         NPSavedData* saved)
+{
+  PLUGIN_DEBUG ("GCJ_New");
+
+  NPError np_error = NPERR_NO_ERROR;
+  GCJPluginData* data = NULL;
+
+  gchar* documentbase = NULL;
+  gchar* read_message = NULL;
+  gchar* applet_tag = NULL;
+  gchar* tag_message = NULL;
+
+  if (!instance)
+    {
+      PLUGIN_ERROR ("Browser-provided instance pointer is NULL.");
+      np_error = NPERR_INVALID_INSTANCE_ERROR;
+      goto cleanup_done;
+    }
+
+  // Initialize threads (needed for mutexes).
+  if (!g_thread_supported ())
+    g_thread_init (NULL);
+
+  // data
+  plugin_data_new (&data);
+  if (data == NULL)
+    {
+      PLUGIN_ERROR ("Failed to allocate plugin data.");
+      np_error = NPERR_OUT_OF_MEMORY_ERROR;
+      goto cleanup_done;
+    }
+
+  // Initialize data->instance_string.
+  //
+  // instance_string should be unique for this process so we use a
+  // combination of getpid and plugin_instance_counter.
+  //
+  // Critical region.  Reference and increment plugin_instance_counter
+  // global.
+  g_mutex_lock (plugin_instance_mutex);
+
+  // data->instance_string
+  data->instance_string = g_strdup_printf ("instance-%d-%ld",
+                                           getpid (),
+                                           plugin_instance_counter++);
+
+  g_mutex_unlock (plugin_instance_mutex);
+
+  // data->appletviewer_mutex
+  data->appletviewer_mutex = g_mutex_new ();
+
+  // Documentbase retrieval.
+  documentbase = plugin_get_documentbase (instance);
+  if (!documentbase)
+    {
+      PLUGIN_ERROR ("Documentbase retrieval failed."
+                    " Browser not Mozilla-based?");
+      goto cleanup_appletviewer_mutex;
+    }
+
+  if (!plugin_user_trusts_documentbase (documentbase))
+    {
+      PLUGIN_ERROR ("User does not trust applet.");
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_appletviewer_mutex;
+    }
+
+  // Create appletviewer-to-plugin pipe which we refer to as the input
+  // pipe.
+
+  // data->in_pipe_name
+  data->in_pipe_name = g_strdup_printf (PLUGIN_DATA_DIRECTORY
+                                        "/gcj-%s-appletviewer-to-plugin",
+                                        data->instance_string);
+  if (!data->in_pipe_name)
+    {
+      PLUGIN_ERROR ("Failed to create input pipe name.");
+      np_error = NPERR_OUT_OF_MEMORY_ERROR;
+      // If data->in_pipe_name is NULL then the g_free at
+      // cleanup_in_pipe_name will simply return.
+      goto cleanup_in_pipe_name;
+    }
+
+  if (mkfifo (data->in_pipe_name, 0700) == -1 && errno != EEXIST)
+    {
+      PLUGIN_ERROR_TWO ("Failed to create input pipe", strerror (errno));
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_in_pipe_name;
+    }
+
+  // Create plugin-to-appletviewer pipe which we refer to as the
+  // output pipe.
+
+  // data->out_pipe_name
+  data->out_pipe_name = g_strdup_printf (PLUGIN_DATA_DIRECTORY
+                                         "/gcj-%s-plugin-to-appletviewer",
+                                         data->instance_string);
+
+  if (!data->out_pipe_name)
+    {
+      PLUGIN_ERROR ("Failed to create output pipe name.");
+      np_error = NPERR_OUT_OF_MEMORY_ERROR;
+      goto cleanup_out_pipe_name;
+    }
+
+  if (mkfifo (data->out_pipe_name, 0700) == -1 && errno != EEXIST)
+    {
+      PLUGIN_ERROR_TWO ("Failed to create output pipe", strerror (errno));
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_out_pipe_name;
+    }
+
+  // Start a separate appletviewer process for each applet, even if
+  // there are multiple applets in the same page.  We may need to
+  // change this behaviour if we find pages with multiple applets that
+  // rely on being run in the same VM.
+
+  // Critical region.  Hold appletviewer_mutex while we start the
+  // appletviewer, create the IO channels and install the channel
+  // watch callbacks.
+  g_mutex_lock (data->appletviewer_mutex);
+  
+  np_error = plugin_start_appletviewer (data);
+  
+  // If the appletviewer is not installed, then a dialog box will
+  // show up and the plugin will be killed.
+  if (np_error != NPERR_NO_ERROR)
+    {
+      if (plugin_failed ())
+        goto cleanup_applet_failure; 
+  	}
+  
+  // Create plugin-to-appletviewer channel.  The default encoding for
+  // the file is UTF-8.
+  // data->out_to_appletviewer
+  data->out_to_appletviewer = g_io_channel_new_file (data->out_pipe_name,
+                                                     "w", &channel_error);
+  if (!data->out_to_appletviewer)
+    {
+      if (channel_error)
+        {
+          PLUGIN_ERROR_TWO ("Failed to create output channel",
+                            channel_error->message);
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      else
+        PLUGIN_ERROR ("Failed to create output channel");
+        
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_out_to_appletviewer;
+    }
+
+  // Watch for hangup and error signals on the output pipe.
+  data->out_watch_source =
+    g_io_add_watch (data->out_to_appletviewer,
+                    (GIOCondition) (G_IO_ERR | G_IO_HUP),
+                    plugin_out_pipe_callback, (gpointer) data);
+
+  // Create appletviewer-to-plugin channel.  The default encoding for
+  // the file is UTF-8.
+  // data->in_from_appletviewer
+  data->in_from_appletviewer = g_io_channel_new_file (data->in_pipe_name,
+                                                      "r", &channel_error);
+  if (!data->in_from_appletviewer)
+    {
+      if (channel_error)
+        {
+          PLUGIN_ERROR_TWO ("Failed to create input channel",
+                            channel_error->message);
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      else
+        PLUGIN_ERROR ("Failed to create input channel");
+        
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_in_from_appletviewer;
+    }
+
+  // Watch for hangup and error signals on the input pipe.
+  data->in_watch_source =
+    g_io_add_watch (data->in_from_appletviewer,
+                    (GIOCondition) (G_IO_IN | G_IO_ERR | G_IO_HUP),
+                    plugin_in_pipe_callback, (gpointer) data);
+
+  // Wait until we receive confirmation that the appletviewer has
+  // started.
+  if (g_io_channel_read_line (data->in_from_appletviewer,
+                              &read_message, NULL, NULL,
+                              &channel_error)
+      != G_IO_STATUS_NORMAL)
+    {
+      if (channel_error)
+        {
+          PLUGIN_ERROR_TWO ("Receiving confirmation from appletviewer failed",
+                            channel_error->message);
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      else
+        PLUGIN_ERROR ("Receiving confirmation from appletviewer failed");
+          
+      np_error = NPERR_GENERIC_ERROR;
+      goto cleanup_in_watch_source;
+    }
+
+  PLUGIN_DEBUG ("GCJ_New: got confirmation that appletviewer is running.");
+  data->appletviewer_alive = TRUE;
+
+  // Send applet tag message to appletviewer.
+  applet_tag = plugin_create_applet_tag (argc, argn, argv);
+  tag_message = g_strconcat ("tag ", documentbase, " ", applet_tag, NULL);
+
+  plugin_send_message_to_appletviewer (data, data->instance_string);
+  plugin_send_message_to_appletviewer (data, tag_message);
+
+  g_mutex_unlock (data->appletviewer_mutex);
+
+  // If initialization succeeded entirely then we store the plugin
+  // data in the instance structure and return.  Otherwise we free the
+  // data we've allocated so far and set instance->pdata to NULL.
+
+  // Set back-pointer to owner instance.
+  data->owner = instance;
+  instance->pdata = data;
+  goto cleanup_done;
+
+  // An error occurred while initializing the plugin data or spawning
+  // the appletviewer so we free the data we've already allocated.
+
+ cleanup_in_watch_source:
+  // Removing a source is harmless if it fails since it just means the
+  // source has already been removed.
+  g_source_remove (data->in_watch_source);
+  data->in_watch_source = 0;
+
+ cleanup_in_from_appletviewer:
+  if (data->in_from_appletviewer)
+    g_io_channel_unref (data->in_from_appletviewer);
+  data->in_from_appletviewer = NULL;
+
+  // cleanup_out_watch_source:
+  g_source_remove (data->out_watch_source);
+  data->out_watch_source = 0;
+
+ cleanup_out_to_appletviewer:
+  if (data->out_to_appletviewer)
+    g_io_channel_unref (data->out_to_appletviewer);
+  data->out_to_appletviewer = NULL;
+
+  // cleanup_out_pipe:
+  // Delete output pipe.
+  unlink (data->out_pipe_name);
+ 
+ cleanup_applet_failure:
+ cleanup_out_pipe_name:
+  g_free (data->out_pipe_name);
+  data->out_pipe_name = NULL;
+
+  // cleanup_in_pipe:
+  // Delete input pipe.
+  unlink (data->in_pipe_name);
+
+ cleanup_in_pipe_name:
+  g_free (data->in_pipe_name);
+  data->in_pipe_name = NULL;
+
+ cleanup_appletviewer_mutex:
+  g_free (data->appletviewer_mutex);
+  data->appletviewer_mutex = NULL;
+
+  // cleanup_instance_string:
+  g_free (data->instance_string);
+  data->instance_string = NULL;
+
+  // cleanup_data:
+  // Eliminate back-pointer to plugin instance.
+  data->owner = NULL;
+  (*browserFunctions.memfree) (data);
+  data = NULL;
+
+  // Initialization failed so return a NULL pointer for the browser
+  // data.
+  instance->pdata = NULL;
+
+ cleanup_done:
+  g_free (tag_message);
+  tag_message = NULL;
+  g_free (applet_tag);
+  applet_tag = NULL;
+  g_free (read_message);
+  read_message = NULL;
+  g_free (documentbase);
+  documentbase = NULL;
+
+  PLUGIN_DEBUG ("GCJ_New return");
+
+  return np_error;
+}
+
+NPError
+GCJ_GetValue (NPP instance, NPPVariable variable, void* value)
+{
+  PLUGIN_DEBUG ("GCJ_GetValue");
+
+  NPError np_error = NPERR_NO_ERROR;
+
+  switch (variable)
+    {
+    // This plugin needs XEmbed support.
+    case NPPVpluginNeedsXEmbed:
+      {
+        PLUGIN_DEBUG ("GCJ_GetValue: returning TRUE for NeedsXEmbed.");
+        PRBool* bool_value = (PRBool*) value;
+        *bool_value = PR_TRUE;
+      }
+      break;
+
+    default:
+      PLUGIN_ERROR ("Unknown plugin value requested.");
+      np_error = NPERR_GENERIC_ERROR;
+      break;
+    }
+
+  PLUGIN_DEBUG ("GCJ_GetValue return");
+
+  return np_error;
+}
+
+NPError
+GCJ_Destroy (NPP instance, NPSavedData** save)
+{
+  PLUGIN_DEBUG ("GCJ_Destroy");
+
+  GCJPluginData* data = (GCJPluginData*) instance->pdata;
+
+  if (data)
+    {
+      // Critical region.  Stop the appletviewer.
+      g_mutex_lock (data->appletviewer_mutex);
+
+      // Tell the appletviewer to destroy its embedded plugin window.
+      plugin_send_message_to_appletviewer (data, "destroy");
+      // Shut down the appletviewer.
+      plugin_stop_appletviewer (data);
+
+      g_mutex_unlock (data->appletviewer_mutex);
+
+      // Free plugin data.
+      plugin_data_destroy (&data);
+    }
+
+  PLUGIN_DEBUG ("GCJ_Destroy return");
+
+  return NPERR_NO_ERROR;
+}
+
+NPError
+GCJ_SetWindow (NPP instance, NPWindow* window)
+{
+  PLUGIN_DEBUG ("GCJ_SetWindow");
+
+  if (instance == NULL)
+    {
+      PLUGIN_ERROR ("Invalid instance.");
+
+      return NPERR_INVALID_INSTANCE_ERROR;
+    }
+
+  GCJPluginData* data = (GCJPluginData*) instance->pdata;
+
+  // Simply return if we receive a NULL window.
+  if ((window == NULL) || (window->window == NULL))
+    {
+      PLUGIN_DEBUG ("GCJ_SetWindow: got NULL window.");
+
+      return NPERR_NO_ERROR;
+    }
+
+  if (data->window_handle)
+    {
+      // The window already exists.
+      if (data->window_handle == window->window)
+	{
+          // The parent window is the same as in previous calls.
+          PLUGIN_DEBUG ("GCJ_SetWindow: window already exists.");
+
+          // Critical region.  Read data->appletviewer_mutex and send
+          // a message to the appletviewer.
+          g_mutex_lock (data->appletviewer_mutex);
+
+	  if (data->appletviewer_alive)
+	    {
+	      // The window is the same as it was for the last
+	      // SetWindow call.
+	      if (window->width != data->window_width)
+		{
+                  PLUGIN_DEBUG ("GCJ_SetWindow: window width changed.");
+		  // The width of the plugin window has changed.
+
+                  // Send the new width to the appletviewer.
+		  plugin_send_message_to_appletviewer (data,
+                                                       data->instance_string);
+                  gchar* width_message = g_strdup_printf ("width %d",
+                                                          window->width);
+		  plugin_send_message_to_appletviewer (data, width_message);
+                  g_free (width_message);
+                  width_message = NULL;
+
+                  // Store the new width.
+                  data->window_width = window->width;
+		}
+
+	      if (window->height != data->window_height)
+		{
+                  PLUGIN_DEBUG ("GCJ_SetWindow: window height changed.");
+		  // The height of the plugin window has changed.
+
+                  // Send the new height to the appletviewer.
+		  plugin_send_message_to_appletviewer (data,
+                                                       data->instance_string);
+                  gchar* height_message = g_strdup_printf ("height %d",
+                                                           window->height);
+		  plugin_send_message_to_appletviewer (data, height_message);
+                  g_free (height_message);
+                  height_message = NULL;
+
+                  // Store the new height.
+                  data->window_height = window->height;
+		}
+	    }
+	  else
+	    {
+              // The appletviewer is not running.
+	      PLUGIN_DEBUG ("GCJ_SetWindow: appletviewer is not running.");
+	    }
+
+          g_mutex_unlock (data->appletviewer_mutex);
+	}
+      else
+	{
+	  // The parent window has changed.  This branch does run but
+	  // doing nothing in response seems to be sufficient.
+	  PLUGIN_DEBUG ("GCJ_SetWindow: parent window changed.");
+	}
+    }
+  else
+    {
+      PLUGIN_DEBUG ("GCJ_SetWindow: setting window.");
+
+      // Critical region.  Send messages to appletviewer.
+      g_mutex_lock (data->appletviewer_mutex);
+
+      plugin_send_message_to_appletviewer (data, data->instance_string);
+      gchar *window_message = g_strdup_printf ("handle %ld",
+                                               (gulong) window->window);
+      plugin_send_message_to_appletviewer (data, window_message);
+      g_free (window_message);
+      window_message = NULL;
+
+      g_mutex_unlock (data->appletviewer_mutex);
+
+      // Store the window handle.
+      data->window_handle = window->window;
+    }
+
+  PLUGIN_DEBUG ("GCJ_SetWindow return");
+
+  return NPERR_NO_ERROR;
+}
+
+NPError
+GCJ_NewStream (NPP instance, NPMIMEType type, NPStream* stream,
+               NPBool seekable, uint16* stype)
+{
+  PLUGIN_DEBUG ("GCJ_NewStream");
+
+  PLUGIN_DEBUG ("GCJ_NewStream return");
+
+  return NPERR_NO_ERROR;
+}
+
+void
+GCJ_StreamAsFile (NPP instance, NPStream* stream, const char* filename)
+{
+  PLUGIN_DEBUG ("GCJ_StreamAsFile");
+
+  PLUGIN_DEBUG ("GCJ_StreamAsFile return");
+}
+
+NPError
+GCJ_DestroyStream (NPP instance, NPStream* stream, NPReason reason)
+{
+  PLUGIN_DEBUG ("GCJ_DestroyStream");
+
+  PLUGIN_DEBUG ("GCJ_DestroyStream return");
+
+  return NPERR_NO_ERROR;
+}
+
+int32
+GCJ_WriteReady (NPP instance, NPStream* stream)
+{
+  PLUGIN_DEBUG ("GCJ_WriteReady");
+
+  PLUGIN_DEBUG ("GCJ_WriteReady return");
+
+  return 0;
+}
+
+int32
+GCJ_Write (NPP instance, NPStream* stream, int32 offset, int32 len,
+           void* buffer)
+{
+  PLUGIN_DEBUG ("GCJ_Write");
+
+  PLUGIN_DEBUG ("GCJ_Write return");
+
+  return 0;
+}
+
+void
+GCJ_Print (NPP instance, NPPrint* platformPrint)
+{
+  PLUGIN_DEBUG ("GCJ_Print");
+
+  PLUGIN_DEBUG ("GCJ_Print return");
+}
+
+int16
+GCJ_HandleEvent (NPP instance, void* event)
+{
+  PLUGIN_DEBUG ("GCJ_HandleEvent");
+
+  PLUGIN_DEBUG ("GCJ_HandleEvent return");
+
+  return 0;
+}
+
+void
+GCJ_URLNotify (NPP instance, const char* url, NPReason reason,
+               void* notifyData)
+{
+  PLUGIN_DEBUG ("GCJ_URLNotify");
+
+  PLUGIN_DEBUG ("GCJ_URLNotify return");
+}
+
+jref
+GCJ_GetJavaClass (void)
+{
+  PLUGIN_DEBUG ("GCJ_GetJavaClass");
+
+  PLUGIN_DEBUG ("GCJ_GetJavaClass return");
+
+  return 0;
+}
+
+// HELPER FUNCTIONS
+
+static void
+plugin_data_new (GCJPluginData** data)
+{
+  PLUGIN_DEBUG ("plugin_data_new");
+
+  *data = (GCJPluginData*)
+    (*browserFunctions.memalloc) (sizeof (struct GCJPluginData));
+
+  // appletviewer_alive is false until the applet viewer is spawned.
+  if (*data)
+    memset (*data, 0, sizeof (struct GCJPluginData));
+
+  PLUGIN_DEBUG ("plugin_data_new return");
+}
+
+// Documentbase retrieval.  This function gets the current document's
+// documentbase.  This function relies on browser-private data so it
+// will only work when the plugin is loaded in a Mozilla-based
+// browser.  We could not find a way to retrieve the documentbase
+// using the original Netscape plugin API so we use the XPCOM API
+// instead.
+static gchar*
+plugin_get_documentbase (NPP instance)
+{
+  PLUGIN_DEBUG ("plugin_get_documentbase");
+
+  nsIPluginInstance* xpcom_instance = NULL;
+  nsIPluginInstancePeer* peer = NULL;
+  nsresult result = 0;
+  nsIPluginTagInfo2* pluginTagInfo2 = NULL;
+  info_union u = { NULL };
+  char const* documentbase = NULL;
+  gchar* documentbase_copy = NULL;
+
+  xpcom_instance = (nsIPluginInstance*) (instance->ndata);
+  if (!xpcom_instance)
+    {
+      PLUGIN_ERROR ("xpcom_instance is NULL.");
+      goto cleanup_done;
+    }
+
+  xpcom_instance->GetPeer (&peer);
+  if (!peer)
+    {
+      PLUGIN_ERROR ("peer is NULL.");
+      goto cleanup_done;
+    }
+
+  u.info_field = &pluginTagInfo2;
+
+  result = peer->QueryInterface (kIPluginTagInfo2IID,
+                                 u.void_field);
+  if (result || !pluginTagInfo2)
+    {
+      PLUGIN_ERROR ("pluginTagInfo2 retrieval failed.");
+      goto cleanup_peer;
+    }
+
+  pluginTagInfo2->GetDocumentBase (&documentbase);
+
+  if (!documentbase)
+    {
+      PLUGIN_ERROR ("documentbase is NULL.");
+      goto cleanup_plugintaginfo2;
+    }
+
+  documentbase_copy = g_strdup (documentbase);
+
+  // Release references.
+ cleanup_plugintaginfo2:
+  NS_RELEASE (pluginTagInfo2);
+
+ cleanup_peer:
+  NS_RELEASE (peer);
+
+ cleanup_done:
+  PLUGIN_DEBUG ("plugin_get_documentbase return");
+
+  return documentbase_copy;
+}
+
+// This function shows a error message if the appletviewer has
+// not been installed. It returns true, if the user presses the
+// ok button.
+static bool
+plugin_failed ()
+{
+  GtkWidget* dialog = NULL;
+  GtkWidget* ok_button = NULL;
+
+  dialog = gtk_message_dialog_new (NULL,
+                                   GTK_DIALOG_MODAL,
+                                   GTK_MESSAGE_WARNING,
+                                   GTK_BUTTONS_NONE,
+                                   FAILURE_MESSAGE);
+  ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                     GTK_STOCK_OK,
+                                     GTK_RESPONSE_OK);
+  gtk_widget_show_all (dialog);
+  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+    {
+      gtk_widget_destroy (dialog);
+      return true;	  
+    }
+  return false;
+}
+
+// plugin_user_trusts_documentbase returns true if the given
+// documentbase is in the documentbase whitelist.  Otherwise it asks
+// the user if he trusts the given documentbase by calling
+// plugin_ask_user_about_documentbase.
+static bool
+plugin_user_trusts_documentbase (char* documentbase)
+{
+  bool applet_in_whitelist = false;
+
+  // Check if documentbase is in whitelist.
+  while (true)
+    {
+      gchar* whitelist_entry = NULL;
+      gchar* newline_documentbase = NULL;
+
+      // If reading fails, break out of this loop with
+      // applet_in_whitelist still set to false.
+      if (g_io_channel_read_line (whitelist_file, &whitelist_entry,
+                                  NULL, NULL, &channel_error)
+          != G_IO_STATUS_NORMAL)
+        {
+          if (channel_error)
+            {
+              PLUGIN_ERROR_TWO ("Failed to read line from whitelist file",
+                                channel_error->message);
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+          else
+            PLUGIN_ERROR ("Failed to open whitelist file.");
+          g_free (whitelist_entry);
+          whitelist_entry = NULL;
+          break;
+        }
+
+      newline_documentbase = g_strdup_printf ("%s\n", documentbase);
+      if (!strcmp (newline_documentbase, whitelist_entry))
+        {
+          applet_in_whitelist = true;
+          g_free (newline_documentbase);
+          newline_documentbase = NULL;
+          g_free (whitelist_entry);
+          whitelist_entry = NULL;
+          break;
+        }
+      g_free (whitelist_entry);
+      whitelist_entry = NULL;
+      g_free (newline_documentbase);
+      newline_documentbase = NULL;
+    }
+
+  return applet_in_whitelist ? true
+    : plugin_ask_user_about_documentbase (documentbase);
+}
+
+// plugin_add_documentbase_to_whitelist adds the given documentbase to
+// the user's documentbase whitelist.
+static void
+plugin_add_documentbase_to_whitelist (char* documentbase)
+{
+  gsize bytes_written = 0;
+  char* newline_documentbase = NULL;
+  GIOStatus status = G_IO_STATUS_NORMAL;
+
+  newline_documentbase = g_strdup_printf ("%s\n", documentbase);
+  status = g_io_channel_write_chars (whitelist_file,
+                                     newline_documentbase, -1, &bytes_written,
+                                     &channel_error);
+  g_free (newline_documentbase);
+  newline_documentbase = NULL;
+
+  if (status != G_IO_STATUS_NORMAL)
+    {
+      if (channel_error)
+        {
+          PLUGIN_ERROR_TWO ("Error writing to whitelist file",
+                            channel_error->message);
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      else
+        PLUGIN_ERROR ("Error writing to whitelist file.");
+    }
+
+  if (g_io_channel_flush (whitelist_file, &channel_error)
+      != G_IO_STATUS_NORMAL)
+    {
+      if (channel_error)
+        {
+          PLUGIN_ERROR_TWO ("Failed to write whitelist file",
+                            channel_error->message);
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      else
+        PLUGIN_ERROR ("Failed to write whitelist file.");
+    }
+
+  if (g_io_channel_shutdown (whitelist_file, TRUE, &channel_error)
+      != G_IO_STATUS_NORMAL)
+    {
+      if (channel_error)
+        {
+          PLUGIN_ERROR_TWO ("Failed to close whitelist file",
+                            channel_error->message);
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      else
+        PLUGIN_ERROR ("Failed to close whitelist file.");
+    }
+}
+
+// plugin_ask_user_about_documentbase puts up a dialog box that asks if the
+// user trusts applets from this documentbase.  The user has three
+// options: "Cancel", "Trust Applet" and "Trust Applet and Add to
+// Whitelist".  If the user selects Cancel (the default) then a
+// generic error code is returned from GCJ_New, telling the browser
+// that the applet failed to load.  If the user selects "Trust Applet"
+// then plugin loading proceeds.  If the user selects "Trust Applet
+// and Add to Whitelist" then this documentbase is added to the user's
+// applet whitelist and plugin loading proceeds.
+static bool
+plugin_ask_user_about_documentbase (char* documentbase)
+{
+  GtkWidget* dialog = NULL;
+  GtkWidget* ok_button = NULL;
+  GtkWidget* cancel_button = NULL;
+  GtkWidget* whitelist_button = NULL;
+  gint dialog_response = GTK_RESPONSE_NONE;
+
+  dialog = gtk_message_dialog_new (NULL,
+                                   GTK_DIALOG_MODAL,
+                                   GTK_MESSAGE_WARNING,
+                                   GTK_BUTTONS_NONE,
+                                   SECURITY_WARNING,
+                                   documentbase);
+  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                            SECURITY_DESCRIPTION);
+
+  cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                         GTK_STOCK_CANCEL,
+                                         GTK_RESPONSE_CANCEL);
+  ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                     RESPONSE_TRUST_APPLET,
+                                     GTK_RESPONSE_OK);
+  whitelist_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                            RESPONSE_TRUST_APPLET_ADD_TO_LIST,
+                                            GTK_RESPONSE_APPLY);
+  gtk_widget_grab_focus (cancel_button);
+
+  gtk_widget_show_all (dialog);
+  dialog_response = gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_widget_destroy (dialog);
+  if (dialog_response == GTK_RESPONSE_CANCEL)
+    {
+      // The user does not trust this documentbase.
+      return false;
+    }
+  else if (dialog_response == GTK_RESPONSE_APPLY)
+    {
+      // The user wants this documentbase added to his documentbase
+      // whitelist.
+      plugin_add_documentbase_to_whitelist (documentbase);
+    }
+  // The user trusts this documentbase.
+  return true;
+}
+
+// plugin_in_pipe_callback is called when data is available on the
+// input pipe, or when the appletviewer crashes or is killed.  It may
+// be called after data has been destroyed in which case it simply
+// returns FALSE to remove itself from the glib main loop.
+static gboolean
+plugin_in_pipe_callback (GIOChannel* source,
+                         GIOCondition condition,
+                         gpointer plugin_data)
+{
+  PLUGIN_DEBUG ("plugin_in_pipe_callback");
+
+  GCJPluginData* data = (GCJPluginData*) plugin_data;
+  gboolean keep_installed = TRUE;
+
+  // If data is NULL then GCJ_Destroy has already been called and
+  // plugin_in_pipe_callback is being called after plugin
+  // destruction.  In that case all we need to do is return FALSE so
+  // that the plugin_in_pipe_callback watch is removed.
+  if (data)
+    {
+      // Critical region. Set or clear data->appletviewer_alive.
+      g_mutex_lock (data->appletviewer_mutex);
+
+      if (condition & G_IO_IN)
+        {
+          gchar* message = NULL;
+
+          if (g_io_channel_read_line (data->in_from_appletviewer,
+                                      &message, NULL, NULL,
+                                      &channel_error)
+              != G_IO_STATUS_NORMAL)
+            {
+              if (channel_error)
+                {
+                  PLUGIN_ERROR_TWO ("Failed to read line from input channel",
+                                    channel_error->message);
+                  g_error_free (channel_error);
+                  channel_error = NULL;
+                }
+              else
+                PLUGIN_ERROR ("Failed to read line from input channel");
+            }
+          else
+            {
+              if (g_str_has_prefix (message, "url "))
+                {
+                  gchar** parts = g_strsplit (message, " ", 3);
+                  PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
+                                    " opening URL", parts[1]);
+                  PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
+                                    " URL target", parts[2]);
+                  // Open the URL in a new browser window.
+                  NPError np_error =
+                    (*browserFunctions.geturl) (data->owner, parts[1], parts[2]);
+                  if (np_error != NPERR_NO_ERROR)
+                    PLUGIN_ERROR ("Failed to load URL.");
+                  g_strfreev (parts);
+                  parts = NULL;
+                }
+              else if (g_str_has_prefix (message, "status "))
+                {
+                  gchar** parts = g_strsplit (message, " ", 2);
+
+                  PLUGIN_DEBUG_TWO ("plugin_in_pipe_callback:"
+                                    " setting status", parts[1]);
+                  (*browserFunctions.status) (data->owner, parts[1]);
+                  g_strfreev (parts);
+                  parts = NULL;
+                }
+              g_print ("  PIPE: plugin read %s\n", message);
+            }
+
+          g_free (message);
+          message = NULL;
+
+          keep_installed = TRUE;
+        }
+
+      if (condition & (G_IO_ERR | G_IO_HUP))
+        {
+          PLUGIN_DEBUG ("appletviewer has stopped.");
+          data->appletviewer_alive = FALSE;
+          keep_installed = FALSE;
+        }
+      g_mutex_unlock (data->appletviewer_mutex);
+    }
+
+  PLUGIN_DEBUG ("plugin_in_pipe_callback return");
+
+  return keep_installed;
+}
+
+// plugin_out_pipe_callback is called when the appletviewer crashes or
+// is killed.  It may be called after data has been destroyed in which
+// case it simply returns FALSE to remove itself from the glib main
+// loop.
+static gboolean
+plugin_out_pipe_callback (GIOChannel* source,
+                          GIOCondition condition,
+                          gpointer plugin_data)
+{
+  PLUGIN_DEBUG ("plugin_out_pipe_callback");
+
+  GCJPluginData* data = (GCJPluginData*) plugin_data;
+
+  // If data is NULL then GCJ_Destroy has already been called and
+  // plugin_out_pipe_callback is being called after plugin
+  // destruction.  In that case all we need to do is return FALSE so
+  // that the plugin_out_pipe_callback watch is removed.
+  if (data)
+    {
+      // Critical region.  Clear data->appletviewer_alive.
+      g_mutex_lock (data->appletviewer_mutex);
+
+      PLUGIN_DEBUG ("plugin_out_pipe_callback: appletviewer has stopped.");
+      data->appletviewer_alive = FALSE;
+
+      g_mutex_unlock (data->appletviewer_mutex);
+    }
+
+  PLUGIN_DEBUG ("plugin_out_pipe_callback return");
+
+  return FALSE;
+}
+
+static NPError
+plugin_start_appletviewer (GCJPluginData* data)
+{
+  PLUGIN_DEBUG ("plugin_start_appletviewer");
+  NPError error = NPERR_NO_ERROR;
+  
+  if (!data->appletviewer_alive)
+    {
+      gchar* command_line[3] = { NULL, NULL, NULL };
+
+      command_line[0] = g_strdup (APPLETVIEWER_EXECUTABLE);
+      // Output from plugin's perspective is appletviewer's input.
+      // Input from plugin's perspective is appletviewer's output.
+      command_line[1] = g_strdup_printf ("--plugin=%s,%s",
+                                         data->out_pipe_name,
+                                         data->in_pipe_name);
+      command_line[2] = NULL;
+
+      if (!g_spawn_async (NULL, command_line, NULL, (GSpawnFlags) 0,
+                          NULL, NULL, NULL, &channel_error))
+        {
+          if (channel_error)
+            {
+              PLUGIN_ERROR_TWO ("Failed to spawn applet viewer",
+                                channel_error->message);
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+          else
+            PLUGIN_ERROR ("Failed to spawn applet viewer");
+          error = NPERR_GENERIC_ERROR;
+          goto cleanup;
+        }
+
+    cleanup:
+      g_free (command_line[0]);
+      command_line[0] = NULL;
+      g_free (command_line[1]);
+      command_line[1] = NULL;
+      g_free (command_line[2]);
+      command_line[2] = NULL;
+    }
+
+  PLUGIN_DEBUG ("plugin_start_appletviewer return");
+  return error;
+}
+
+// Build up the applet tag string that we'll send to the applet
+// viewer.
+static gchar*
+plugin_create_applet_tag (int16 argc, char* argn[], char* argv[])
+{
+  PLUGIN_DEBUG ("plugin_create_applet_tag");
+
+  gchar* applet_tag = g_strdup ("<EMBED ");
+  gchar* parameters = g_strdup ("");
+
+  for (int16 i = 0; i < argc; i++)
+    {
+      if (!g_ascii_strcasecmp (argn[i], "code"))
+        {
+          gchar* code = g_strdup_printf ("CODE=\"%s\" ", argv[i]);
+	  applet_tag = g_strconcat (applet_tag, code, NULL);
+          g_free (code);
+          code = NULL;
+	}
+      else if (!g_ascii_strcasecmp (argn[i], "codebase"))
+	{
+          gchar* codebase = g_strdup_printf ("CODEBASE=\"%s\" ", argv[i]);
+	  applet_tag = g_strconcat (applet_tag, codebase, NULL);
+          g_free (codebase);
+          codebase = NULL;
+	}
+      else if (!g_ascii_strcasecmp (argn[i], "archive"))
+	{
+          gchar* archive = g_strdup_printf ("ARCHIVE=\"%s\" ", argv[i]);
+	  applet_tag = g_strconcat (applet_tag, archive, NULL);
+          g_free (archive);
+          archive = NULL;
+	}
+      else if (!g_ascii_strcasecmp (argn[i], "width"))
+	{
+          gchar* width = g_strdup_printf ("WIDTH=\"%s\" ", argv[i]);
+	  applet_tag = g_strconcat (applet_tag, width, NULL);
+          g_free (width);
+          width = NULL;
+	}
+      else if (!g_ascii_strcasecmp (argn[i], "height"))
+	{
+          gchar* height = g_strdup_printf ("HEIGHT=\"%s\" ", argv[i]);
+	  applet_tag = g_strconcat (applet_tag, height, NULL);
+          g_free (height);
+          height = NULL;
+	}
+      else
+        {
+          // Escape the parameter value so that line termination
+          // characters will pass through the pipe.
+          if (argv[i] != '\0')
+            {
+              gchar* escaped = NULL;
+
+              escaped = g_strescape (argv[i], NULL);
+              parameters = g_strconcat (parameters, "<PARAM NAME=\"", argn[i],
+                                        "\" VALUE=\"", escaped, "\">", NULL);
+
+              g_free (escaped);
+              escaped = NULL;
+            }
+        }
+    }
+
+  applet_tag = g_strconcat (applet_tag, ">", parameters, "</EMBED>", NULL);
+
+  g_free (parameters);
+  parameters = NULL;
+
+  PLUGIN_DEBUG ("plugin_create_applet_tag return");
+
+  return applet_tag;
+}
+
+// plugin_send_message_to_appletviewer must be called while holding
+// data->appletviewer_mutex.
+static void
+plugin_send_message_to_appletviewer (GCJPluginData* data, gchar const* message)
+{
+  PLUGIN_DEBUG ("plugin_send_message_to_appletviewer");
+
+  if (data->appletviewer_alive)
+    {
+      gchar* newline_message = NULL;
+      gsize bytes_written = 0;
+
+      // Send message to appletviewer.
+      newline_message = g_strdup_printf ("%s\n", message);
+
+      // g_io_channel_write_chars will return something other than
+      // G_IO_STATUS_NORMAL if not all the data is written.  In that
+      // case we fail rather than retrying.
+      if (g_io_channel_write_chars (data->out_to_appletviewer,
+                                    newline_message, -1, &bytes_written,
+                                    &channel_error)
+            != G_IO_STATUS_NORMAL)
+        {
+          if (channel_error)
+            {
+              PLUGIN_ERROR_TWO ("Failed to write bytes to output channel",
+                                channel_error->message);
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+          else
+            PLUGIN_ERROR ("Failed to write bytes to output channel");
+        }            
+
+      if (g_io_channel_flush (data->out_to_appletviewer, &channel_error)
+          != G_IO_STATUS_NORMAL)
+        {
+          if (channel_error)
+            {
+              PLUGIN_ERROR_TWO ("Failed to flush bytes to output channel",
+                                channel_error->message);
+              g_error_free (channel_error);
+              channel_error = NULL;
+            }
+          else
+            PLUGIN_ERROR ("Failed to flush bytes to output channel");
+        }
+      g_free (newline_message);
+      newline_message = NULL;
+
+      g_print ("  PIPE: plugin wrote %s\n", message);
+    }
+
+  PLUGIN_DEBUG ("plugin_send_message_to_appletviewer return");
+}
+
+// Stop the appletviewer process.  When this is called the
+// appletviewer can be in any of three states: running, crashed or
+// hung.  If the appletviewer is running then sending it "shutdown"
+// will cause it to exit.  This will cause
+// plugin_out_pipe_callback/plugin_in_pipe_callback to be called and
+// the input and output channels to be shut down.  If the appletviewer
+// has crashed then plugin_out_pipe_callback/plugin_in_pipe_callback
+// would already have been called and data->appletviewer_alive cleared
+// in which case this function simply returns.  If the appletviewer is
+// hung then this function will be successful and the input and output
+// watches will be removed by plugin_data_destroy.
+// plugin_stop_appletviewer must be called with
+// data->appletviewer_mutex held.
+static void
+plugin_stop_appletviewer (GCJPluginData* data)
+{
+  PLUGIN_DEBUG ("plugin_stop_appletviewer");
+
+  if (data->appletviewer_alive)
+    {
+      // Shut down the appletviewer.
+      gsize bytes_written = 0;
+
+      if (data->out_to_appletviewer)
+        {
+          if (g_io_channel_write_chars (data->out_to_appletviewer, "shutdown",
+                                        -1, &bytes_written, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            {
+              if (channel_error)
+                {
+                  PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
+                                    " appletviewer", channel_error->message);
+                  g_error_free (channel_error);
+                  channel_error = NULL;
+                }
+              else
+                PLUGIN_ERROR ("Failed to write shutdown message to");
+            }
+
+          if (g_io_channel_flush (data->out_to_appletviewer, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            {
+              if (channel_error)
+                {
+                  PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
+                                    " appletviewer", channel_error->message);
+                  g_error_free (channel_error);
+                  channel_error = NULL;
+                }
+              else
+                PLUGIN_ERROR ("Failed to write shutdown message to");
+            }
+
+          if (g_io_channel_shutdown (data->out_to_appletviewer,
+                                     TRUE, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            {
+              if (channel_error)
+                {
+                  PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
+                                    " output channel", channel_error->message);
+                  g_error_free (channel_error);
+                  channel_error = NULL;
+                }
+              else
+                PLUGIN_ERROR ("Failed to shut down appletviewer");
+            }
+        }
+
+      if (data->in_from_appletviewer)
+        {
+          if (g_io_channel_shutdown (data->in_from_appletviewer,
+                                     TRUE, &channel_error)
+              != G_IO_STATUS_NORMAL)
+            {
+              if (channel_error)
+                {
+                  PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
+                                    " input channel", channel_error->message);
+                  g_error_free (channel_error);
+                  channel_error = NULL;
+                }
+              else
+                PLUGIN_ERROR ("Failed to shut down appletviewer");
+            }
+        }
+    }
+
+  PLUGIN_DEBUG ("plugin_stop_appletviewer return");
+}
+
+static void
+plugin_data_destroy (GCJPluginData** data)
+{
+  PLUGIN_DEBUG ("plugin_data_destroy");
+
+  GCJPluginData* tofree = *data;
+
+  tofree->window_handle = NULL;
+  tofree->window_height = 0;
+  tofree->window_width = 0;
+
+  // Copied from GCJ_New.
+
+  // cleanup_in_watch_source:
+  // Removing a source is harmless if it fails since it just means the
+  // source has already been removed.
+  g_source_remove (tofree->in_watch_source);
+  tofree->in_watch_source = 0;
+
+  // cleanup_in_from_appletviewer:
+  if (tofree->in_from_appletviewer)
+    g_io_channel_unref (tofree->in_from_appletviewer);
+  tofree->in_from_appletviewer = NULL;
+
+  // cleanup_out_watch_source:
+  g_source_remove (tofree->out_watch_source);
+  tofree->out_watch_source = 0;
+
+  // cleanup_out_to_appletviewer:
+  if (tofree->out_to_appletviewer)
+    g_io_channel_unref (tofree->out_to_appletviewer);
+  tofree->out_to_appletviewer = NULL;
+
+  // cleanup_out_pipe:
+  // Delete output pipe.
+  unlink (tofree->out_pipe_name);
+
+  // cleanup_out_pipe_name:
+  g_free (tofree->out_pipe_name);
+  tofree->out_pipe_name = NULL;
+
+  // cleanup_in_pipe:
+  // Delete input pipe.
+  unlink (tofree->in_pipe_name);
+
+  // cleanup_in_pipe_name:
+  g_free (tofree->in_pipe_name);
+  tofree->in_pipe_name = NULL;
+
+  // cleanup_appletviewer_mutex:
+  g_free (tofree->appletviewer_mutex);
+  tofree->appletviewer_mutex = NULL;
+
+  // cleanup_instance_string:
+  g_free (tofree->instance_string);
+  tofree->instance_string = NULL;
+
+  // cleanup_data:
+  // Eliminate back-pointer to plugin instance.
+  tofree->owner = NULL;
+  (*browserFunctions.memfree) (tofree);
+  tofree = NULL;
+
+  PLUGIN_DEBUG ("plugin_data_destroy return");
+}
+
+// FACTORY FUNCTIONS
+
+// Provides the browser with pointers to the plugin functions that we
+// implement and initializes a local table with browser functions that
+// we may wish to call.  Called once, after browser startup and before
+// the first plugin instance is created.
+// The field 'initialized' is set to true once this function has
+// finished. If 'initialized' is already true at the beginning of
+// this function, then it is evident that NP_Initialize has already
+// been called. There is no need to call this function more than once and
+// this workaround avoids any duplicate calls.
+NPError
+NP_Initialize (NPNetscapeFuncs* browserTable, NPPluginFuncs* pluginTable)
+{
+  PLUGIN_DEBUG ("NP_Initialize");
+  
+  if (initialized)
+    return NPERR_NO_ERROR;
+  else if ((browserTable == NULL) || (pluginTable == NULL))
+    {
+      PLUGIN_ERROR ("Browser or plugin function table is NULL.");
+
+      return NPERR_INVALID_FUNCTABLE_ERROR;
+    }
+    
+  // Ensure that the major version of the plugin API that the browser
+  // expects is not more recent than the major version of the API that
+  // we've implemented.
+  if ((browserTable->version >> 8) > NP_VERSION_MAJOR)
+    {
+      PLUGIN_ERROR ("Incompatible version.");
+
+      return NPERR_INCOMPATIBLE_VERSION_ERROR;
+    }
+
+  // Ensure that the plugin function table we've received is large
+  // enough to store the number of functions that we may provide.
+  if (pluginTable->size < sizeof (NPPluginFuncs))      
+    {
+      PLUGIN_ERROR ("Invalid plugin function table.");
+
+      return NPERR_INVALID_FUNCTABLE_ERROR;
+    }
+
+  // Ensure that the browser function table is large enough to store
+  // the number of browser functions that we may use.
+  if (browserTable->size < sizeof (NPNetscapeFuncs))
+    {
+      PLUGIN_ERROR ("Invalid browser function table.");
+
+      return NPERR_INVALID_FUNCTABLE_ERROR;
+    }
+
+  // Make sure the plugin data directory exists, creating it if
+  // necessary.
+  if (!g_file_test (PLUGIN_DATA_DIRECTORY,
+                    (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
+    {
+      int file_error = 0;
+
+      file_error = g_mkdir (PLUGIN_DATA_DIRECTORY, 0700);
+      if (file_error != 0)
+        {
+          PLUGIN_ERROR_TWO ("Failed to create data directory "
+                            PLUGIN_DATA_DIRECTORY " ",
+                            strerror (errno));
+          return NPERR_GENERIC_ERROR;
+        }
+    }
+
+  // Open the user's documentbase whitelist.
+  whitelist_file = g_io_channel_new_file (WHITELIST_FILENAME,
+                                          "a+", &channel_error);
+  if (!whitelist_file)
+    {
+      if (channel_error)
+        {
+          PLUGIN_ERROR_TWO ("Failed to open whitelist file "
+                            WHITELIST_FILENAME " ",
+                            channel_error->message);
+          g_error_free (channel_error);
+          channel_error = NULL;
+        }
+      else
+        PLUGIN_ERROR ("Failed to open whitelist file "
+                      WHITELIST_FILENAME);
+                      
+      return NPERR_GENERIC_ERROR;
+    }
+
+  // Store in a local table the browser functions that we may use.
+  browserFunctions.version = browserTable->version;
+  browserFunctions.size = browserTable->size;
+  browserFunctions.posturl = browserTable->posturl;
+  browserFunctions.geturl = browserTable->geturl;
+  browserFunctions.geturlnotify = browserTable->geturlnotify;
+  browserFunctions.requestread = browserTable->requestread;
+  browserFunctions.newstream = browserTable->newstream;
+  browserFunctions.write = browserTable->write;
+  browserFunctions.destroystream = browserTable->destroystream;
+  browserFunctions.status = browserTable->status;
+  browserFunctions.uagent = browserTable->uagent;
+  browserFunctions.memalloc = browserTable->memalloc;
+  browserFunctions.memfree = browserTable->memfree;
+  browserFunctions.memflush = browserTable->memflush;
+  browserFunctions.reloadplugins = browserTable->reloadplugins;
+  browserFunctions.getvalue = browserTable->getvalue;
+
+  // Return to the browser the plugin functions that we implement.
+  pluginTable->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
+  pluginTable->size = sizeof (NPPluginFuncs);
+  pluginTable->newp = NewNPP_NewProc (GCJ_New);
+  pluginTable->destroy = NewNPP_DestroyProc (GCJ_Destroy);
+  pluginTable->setwindow = NewNPP_SetWindowProc (GCJ_SetWindow);
+  pluginTable->newstream = NewNPP_NewStreamProc (GCJ_NewStream);
+  pluginTable->destroystream = NewNPP_DestroyStreamProc (GCJ_DestroyStream);
+  pluginTable->asfile = NewNPP_StreamAsFileProc (GCJ_StreamAsFile);
+  pluginTable->writeready = NewNPP_WriteReadyProc (GCJ_WriteReady);
+  pluginTable->write = NewNPP_WriteProc (GCJ_Write);
+  pluginTable->print = NewNPP_PrintProc (GCJ_Print);
+  pluginTable->urlnotify = NewNPP_URLNotifyProc (GCJ_URLNotify);
+  pluginTable->getvalue = NewNPP_GetValueProc (GCJ_GetValue);
+  
+  initialized = true;
+  plugin_instance_mutex = g_mutex_new ();
+
+  PLUGIN_DEBUG ("NP_Initialize: using " APPLETVIEWER_EXECUTABLE ".");
+
+  PLUGIN_DEBUG ("NP_Initialize return");
+
+  return NPERR_NO_ERROR;
+}
+
+// Returns a string describing the MIME type that this plugin
+// handles.
+char*
+NP_GetMIMEDescription (void)
+{
+  PLUGIN_DEBUG ("NP_GetMIMEDescription");
+
+  PLUGIN_DEBUG ("NP_GetMIMEDescription return");
+
+  return (char*) PLUGIN_MIME_DESC;
+}
+
+// Returns a value relevant to the plugin as a whole.  The browser
+// calls this function to obtain information about the plugin.
+NPError
+NP_GetValue (void* future, NPPVariable variable, void* value)
+{
+  PLUGIN_DEBUG ("NP_GetValue");
+
+  NPError result = NPERR_NO_ERROR;
+  gchar** char_value = (gchar**) value;
+
+  switch (variable)
+    {
+    case NPPVpluginNameString:
+      PLUGIN_DEBUG ("NP_GetValue: returning plugin name.");
+      *char_value = g_strdup (PLUGIN_NAME " " PACKAGE_VERSION);
+      break;
+
+    case NPPVpluginDescriptionString:
+      PLUGIN_DEBUG ("NP_GetValue: returning plugin description.");
+      *char_value = g_strdup (PLUGIN_DESC);
+      break;
+
+    default:
+      PLUGIN_ERROR ("Unknown plugin value requested.");
+      result = NPERR_GENERIC_ERROR;
+      break;
+    }
+
+  PLUGIN_DEBUG ("NP_GetValue return");
+
+  return result;
+}
+
+// Shuts down the plugin.  Called after the last plugin instance is
+// destroyed.
+NPError
+NP_Shutdown (void)
+{
+  PLUGIN_DEBUG ("NP_Shutdown");
+
+  // Free mutex.
+  if (plugin_instance_mutex)
+    {
+      g_mutex_free (plugin_instance_mutex);
+      plugin_instance_mutex = NULL;
+    }
+
+  if (whitelist_file)
+    {
+      g_io_channel_close (whitelist_file);
+      whitelist_file = NULL;
+    }
+  
+  initialized = false;
+  
+  PLUGIN_DEBUG ("NP_Shutdown return");
+
+  return NPERR_NO_ERROR;
+}
diff --git a/libjava/classpath/native/target/Linux/Makefile.in b/libjava/classpath/native/target/Linux/Makefile.in
index 3ea2e3b80404..4b36aa7fabd9 100644
--- a/libjava/classpath/native/target/Linux/Makefile.in
+++ b/libjava/classpath/native/target/Linux/Makefile.in
@@ -64,8 +64,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -92,8 +90,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -116,6 +118,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -131,9 +135,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -155,6 +158,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -168,6 +172,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -181,6 +187,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -200,11 +207,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/target/Makefile.in b/libjava/classpath/native/target/Makefile.in
index 0c644dd18035..5e35e28c22ff 100644
--- a/libjava/classpath/native/target/Makefile.in
+++ b/libjava/classpath/native/target/Makefile.in
@@ -73,8 +73,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -101,8 +99,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -125,6 +127,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -140,9 +144,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -164,6 +167,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -177,6 +181,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -190,6 +196,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -209,11 +216,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/native/target/generic/Makefile.in b/libjava/classpath/native/target/generic/Makefile.in
index 7cb9e1debf52..7b046f6c9f47 100644
--- a/libjava/classpath/native/target/generic/Makefile.in
+++ b/libjava/classpath/native/target/generic/Makefile.in
@@ -64,8 +64,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -92,8 +90,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -116,6 +118,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -131,9 +135,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -155,6 +158,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -168,6 +172,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -181,6 +187,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -200,11 +207,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/resource/Makefile.in b/libjava/classpath/resource/Makefile.in
index 20bbb0f734fe..67a9d6c5e23d 100644
--- a/libjava/classpath/resource/Makefile.in
+++ b/libjava/classpath/resource/Makefile.in
@@ -75,8 +75,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -103,8 +101,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -127,6 +129,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -142,9 +146,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -166,6 +169,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -179,6 +183,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -192,6 +198,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -211,11 +218,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/scripts/Makefile.in b/libjava/classpath/scripts/Makefile.in
index 21817065d976..71c01165c237 100644
--- a/libjava/classpath/scripts/Makefile.in
+++ b/libjava/classpath/scripts/Makefile.in
@@ -65,8 +65,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -93,8 +91,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -117,6 +119,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -132,9 +136,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -156,6 +159,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -169,6 +173,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -182,6 +188,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -201,11 +208,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
diff --git a/libjava/classpath/tools/.cvsignore b/libjava/classpath/tools/.cvsignore
new file mode 100644
index 000000000000..cf3688511ad4
--- /dev/null
+++ b/libjava/classpath/tools/.cvsignore
@@ -0,0 +1,6 @@
+jarsigner
+keytool
+Makefile.in
+Makefile
+tools.zip
+appletviewer
diff --git a/libjava/classpath/tools/Makefile.am b/libjava/classpath/tools/Makefile.am
index 0358b22b0a04..201939832f0b 100755
--- a/libjava/classpath/tools/Makefile.am
+++ b/libjava/classpath/tools/Makefile.am
@@ -21,6 +21,47 @@ endif
 endif
 endif
 
+if CREATE_WRAPPERS
+bin_SCRIPTS =
+bin_PROGRAMS = appletviewer jarsigner keytool
+
+if FOUND_GCJ
+LIBJVM = -lgcj
+else
+if FOUND_CACAO
+LIBJVM = -ljvm
+else
+LIBJVM =
+endif
+endif
+
+appletviewer_SOURCES = toolwrapper.c
+appletviewer_CFLAGS = -Wall \
+	-DDATA_DIR="\"$(datadir)\"" \
+	-DPACKAGE="\"$(PACKAGE)\"" \
+	-DTOOLNAME="\"appletviewer\""
+appletviewer_LDFLAGS = -L$(libdir) $(LIBJVM)
+
+jarsigner_SOURCES = toolwrapper.c
+jarsigner_CFLAGS = -Wall \
+	-DDATA_DIR="\"$(datadir)\"" \
+	-DPACKAGE="\"$(PACKAGE)\"" \
+	-DTOOLNAME="\"jarsigner\""
+jarsigner_LDFLAGS = -L$(libdir) $(LIBJVM)
+
+keytool_SOURCES = toolwrapper.c
+keytool_CFLAGS = -Wall \
+	-DDATA_DIR="\"$(datadir)\"" \
+	-DPACKAGE="\"$(PACKAGE)\"" \
+	-DTOOLNAME="\"keytool\""
+keytool_LDFLAGS = -L$(libdir) $(LIBJVM)
+
+else
+bin_SCRIPTS = appletviewer jarsigner keytool
+bin_PROGRAMS =
+endif
+EXTRA_DIST = toolwrapper.c appletviewer.in jarsigner.in keytool.in
+
 # All our example java source files
 TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java
 
@@ -32,7 +73,7 @@ TOOLS_ZIP = tools.zip
 BUILT_SOURCES = $(TOOLS_ZIP)
 
 # The templates that must be included into the generated zip file.
-GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav 
+GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav
 RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmi/rmic/templates/*.jav
 
 TOOLS_TEMPLATES = $(GRMIC_TEMPLATES) $(RMIC_TEMPLATES)
@@ -76,11 +117,14 @@ dist-hook:
 $(TOOLS_ZIP): $(TOOLS_JAVA_FILES)
 	mkdir -p classes/gnu/classpath/tools/giop/grmic/templates
 	mkdir -p classes/gnu/classpath/tools/rmi/rmic/templates
+	mkdir -p classes/gnu/classpath/tools/appletviewer
+	mkdir -p classes/gnu/classpath/tools/jarsigner
+	mkdir -p classes/gnu/classpath/tools/keytool
 	cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmi/rmic/templates
-	cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates	
+	cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates
 	cp $(RMI_HELPS) classes/gnu/classpath/tools/rmi/
 	cp $(GIOP_HELPS) classes/gnu/classpath/tools/giop/
-	$(JCOMPILER) -d classes $(TOOLS_JAVA_FILES) 
+	$(JCOMPILER) -d classes $(TOOLS_JAVA_FILES)
 	(cd classes; \
 	if test "$(ZIP)" != ""; then $(ZIP) -r ../$(TOOLS_ZIP) .; fi; \
 	if test "$(FASTJAR)" != ""; then $(FASTJAR) cf ../$(TOOLS_ZIP) .; fi; \
@@ -90,3 +134,7 @@ $(TOOLS_ZIP): $(TOOLS_JAVA_FILES)
 # Zip file be gone! (and make sure the classes are gone too)
 clean-local:
 	rm -rf $(TOOLS_ZIP) classes
+
+# FIXME: remove this when GNU Classpath includes a bootstrap VM.
+installcheck-binSCRIPTS:
+	:
diff --git a/libjava/classpath/tools/Makefile.in b/libjava/classpath/tools/Makefile.in
index e36d8175328b..d43c1b5ce334 100644
--- a/libjava/classpath/tools/Makefile.in
+++ b/libjava/classpath/tools/Makefile.in
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -37,9 +39,12 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
+@CREATE_WRAPPERS_TRUE@bin_PROGRAMS = appletviewer$(EXEEXT) \
+@CREATE_WRAPPERS_TRUE@	jarsigner$(EXEEXT) keytool$(EXEEXT)
 subdir = tools
 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-	$(srcdir)/jarsigner.sh.in $(srcdir)/keytool.sh.in
+	$(srcdir)/appletviewer.in $(srcdir)/jarsigner.in \
+	$(srcdir)/keytool.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
 	$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
@@ -52,18 +57,53 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/include/config.h
-CONFIG_CLEAN_FILES = jarsigner.sh keytool.sh
-SOURCES =
-DIST_SOURCES =
+CONFIG_CLEAN_FILES = appletviewer jarsigner keytool
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" \
+	"$(DESTDIR)$(TOOLSdir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am__appletviewer_SOURCES_DIST = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@am_appletviewer_OBJECTS =  \
+@CREATE_WRAPPERS_TRUE@	appletviewer-toolwrapper.$(OBJEXT)
+appletviewer_OBJECTS = $(am_appletviewer_OBJECTS)
+appletviewer_LDADD = $(LDADD)
+am__jarsigner_SOURCES_DIST = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@am_jarsigner_OBJECTS =  \
+@CREATE_WRAPPERS_TRUE@	jarsigner-toolwrapper.$(OBJEXT)
+jarsigner_OBJECTS = $(am_jarsigner_OBJECTS)
+jarsigner_LDADD = $(LDADD)
+am__keytool_SOURCES_DIST = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@am_keytool_OBJECTS =  \
+@CREATE_WRAPPERS_TRUE@	keytool-toolwrapper.$(OBJEXT)
+keytool_OBJECTS = $(am_keytool_OBJECTS)
+keytool_LDADD = $(LDADD)
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(appletviewer_SOURCES) $(jarsigner_SOURCES) \
+	$(keytool_SOURCES)
+DIST_SOURCES = $(am__appletviewer_SOURCES_DIST) \
+	$(am__jarsigner_SOURCES_DIST) $(am__keytool_SOURCES_DIST)
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
     *) f=$$p;; \
   esac;
 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
-am__installdirs = "$(DESTDIR)$(TOOLSdir)"
 TOOLSDATA_INSTALL = $(INSTALL_DATA)
 DATA = $(TOOLS_DATA)
+ETAGS = etags
+CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMDEP_FALSE = @AMDEP_FALSE@
@@ -75,8 +115,6 @@ AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
 BUILD_CLASS_FILES_FALSE = @BUILD_CLASS_FILES_FALSE@
 BUILD_CLASS_FILES_TRUE = @BUILD_CLASS_FILES_TRUE@
-CAIRO_CFLAGS = @CAIRO_CFLAGS@
-CAIRO_LIBS = @CAIRO_LIBS@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -103,8 +141,12 @@ CREATE_JNI_HEADERS_FALSE = @CREATE_JNI_HEADERS_FALSE@
 CREATE_JNI_HEADERS_TRUE = @CREATE_JNI_HEADERS_TRUE@
 CREATE_JNI_LIBRARIES_FALSE = @CREATE_JNI_LIBRARIES_FALSE@
 CREATE_JNI_LIBRARIES_TRUE = @CREATE_JNI_LIBRARIES_TRUE@
+CREATE_PLUGIN_FALSE = @CREATE_PLUGIN_FALSE@
+CREATE_PLUGIN_TRUE = @CREATE_PLUGIN_TRUE@
 CREATE_QT_PEER_LIBRARIES_FALSE = @CREATE_QT_PEER_LIBRARIES_FALSE@
 CREATE_QT_PEER_LIBRARIES_TRUE = @CREATE_QT_PEER_LIBRARIES_TRUE@
+CREATE_WRAPPERS_FALSE = @CREATE_WRAPPERS_FALSE@
+CREATE_WRAPPERS_TRUE = @CREATE_WRAPPERS_TRUE@
 CREATE_XMLJ_LIBRARY_FALSE = @CREATE_XMLJ_LIBRARY_FALSE@
 CREATE_XMLJ_LIBRARY_TRUE = @CREATE_XMLJ_LIBRARY_TRUE@
 CXX = @CXX@
@@ -127,6 +169,8 @@ EXAMPLESDIR = @EXAMPLESDIR@
 EXEEXT = @EXEEXT@
 FASTJAR = @FASTJAR@
 FIND = @FIND@
+FOUND_CACAO_FALSE = @FOUND_CACAO_FALSE@
+FOUND_CACAO_TRUE = @FOUND_CACAO_TRUE@
 FOUND_ECJ_FALSE = @FOUND_ECJ_FALSE@
 FOUND_ECJ_TRUE = @FOUND_ECJ_TRUE@
 FOUND_GCJX_FALSE = @FOUND_GCJX_FALSE@
@@ -142,9 +186,8 @@ FREETYPE2_LIBS = @FREETYPE2_LIBS@
 GCJ = @GCJ@
 GCJX = @GCJX@
 GJDOC = @GJDOC@
-GTK_CAIRO_ENABLED = @GTK_CAIRO_ENABLED@
-GTK_CAIRO_FALSE = @GTK_CAIRO_FALSE@
-GTK_CAIRO_TRUE = @GTK_CAIRO_TRUE@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_LIBS = @GLIB_LIBS@
 GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 INIT_LOAD_LIBRARY = @INIT_LOAD_LIBRARY@
@@ -166,6 +209,7 @@ KJC = @KJC@
 LDFLAGS = @LDFLAGS@
 LIBDEBUG = @LIBDEBUG@
 LIBICONV = @LIBICONV@
+LIBMAGIC = @LIBMAGIC@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
@@ -179,6 +223,8 @@ MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
 MAKEINFO = @MAKEINFO@
 MKDIR = @MKDIR@
 MOC = @MOC@
+MOZILLA_CFLAGS = @MOZILLA_CFLAGS@
+MOZILLA_LIBS = @MOZILLA_LIBS@
 OBJEXT = @OBJEXT@
 PACKAGE = @PACKAGE@
 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@@ -192,6 +238,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PATH_TO_GLIBJ_ZIP = @PATH_TO_GLIBJ_ZIP@
 PERL = @PERL@
 PKG_CONFIG = @PKG_CONFIG@
+PLUGIN_DIR = @PLUGIN_DIR@
 QT_CFLAGS = @QT_CFLAGS@
 QT_LIBS = @QT_LIBS@
 RANLIB = @RANLIB@
@@ -211,11 +258,13 @@ USER_SPECIFIED_JAVAH_TRUE = @USER_SPECIFIED_JAVAH_TRUE@
 USE_PREBUILT_GLIBJ_ZIP_FALSE = @USE_PREBUILT_GLIBJ_ZIP_FALSE@
 USE_PREBUILT_GLIBJ_ZIP_TRUE = @USE_PREBUILT_GLIBJ_ZIP_TRUE@
 VERSION = @VERSION@
+VM_BINARY = @VM_BINARY@
 WARNING_CFLAGS = @WARNING_CFLAGS@
 XML_CFLAGS = @XML_CFLAGS@
 XML_LIBS = @XML_LIBS@
 XSLT_CFLAGS = @XSLT_CFLAGS@
 XSLT_LIBS = @XSLT_LIBS@
+XTEST_LIBS = @XTEST_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
@@ -277,6 +326,33 @@ GLIBJ_CLASSPATH = '$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip'
 
 # Setup the compiler to use the GNU Classpath library we just build
 @FOUND_GCJ_TRUE@JCOMPILER = $(GCJ) -encoding UTF-8 --bootclasspath $(GLIBJ_CLASSPATH) --classpath . -C
+@CREATE_WRAPPERS_FALSE@bin_SCRIPTS = appletviewer jarsigner keytool
+@CREATE_WRAPPERS_TRUE@bin_SCRIPTS = 
+@CREATE_WRAPPERS_TRUE@@FOUND_CACAO_FALSE@@FOUND_GCJ_FALSE@LIBJVM = 
+@CREATE_WRAPPERS_TRUE@@FOUND_CACAO_TRUE@@FOUND_GCJ_FALSE@LIBJVM = -ljvm
+@CREATE_WRAPPERS_TRUE@@FOUND_GCJ_TRUE@LIBJVM = -lgcj
+@CREATE_WRAPPERS_TRUE@appletviewer_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@appletviewer_CFLAGS = -Wall \
+@CREATE_WRAPPERS_TRUE@	-DDATA_DIR="\"$(datadir)\"" \
+@CREATE_WRAPPERS_TRUE@	-DPACKAGE="\"$(PACKAGE)\"" \
+@CREATE_WRAPPERS_TRUE@	-DTOOLNAME="\"appletviewer\""
+
+@CREATE_WRAPPERS_TRUE@appletviewer_LDFLAGS = -L$(libdir) $(LIBJVM)
+@CREATE_WRAPPERS_TRUE@jarsigner_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@jarsigner_CFLAGS = -Wall \
+@CREATE_WRAPPERS_TRUE@	-DDATA_DIR="\"$(datadir)\"" \
+@CREATE_WRAPPERS_TRUE@	-DPACKAGE="\"$(PACKAGE)\"" \
+@CREATE_WRAPPERS_TRUE@	-DTOOLNAME="\"jarsigner\""
+
+@CREATE_WRAPPERS_TRUE@jarsigner_LDFLAGS = -L$(libdir) $(LIBJVM)
+@CREATE_WRAPPERS_TRUE@keytool_SOURCES = toolwrapper.c
+@CREATE_WRAPPERS_TRUE@keytool_CFLAGS = -Wall \
+@CREATE_WRAPPERS_TRUE@	-DDATA_DIR="\"$(datadir)\"" \
+@CREATE_WRAPPERS_TRUE@	-DPACKAGE="\"$(PACKAGE)\"" \
+@CREATE_WRAPPERS_TRUE@	-DTOOLNAME="\"keytool\""
+
+@CREATE_WRAPPERS_TRUE@keytool_LDFLAGS = -L$(libdir) $(LIBJVM)
+EXTRA_DIST = toolwrapper.c appletviewer.in jarsigner.in keytool.in
 
 # All our example java source files
 TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java
@@ -288,7 +364,7 @@ TOOLS_ZIP = tools.zip
 BUILT_SOURCES = $(TOOLS_ZIP)
 
 # The templates that must be included into the generated zip file.
-GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav 
+GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav
 RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmi/rmic/templates/*.jav
 TOOLS_TEMPLATES = $(GRMIC_TEMPLATES) $(RMIC_TEMPLATES)
 
@@ -312,6 +388,7 @@ all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -341,10 +418,157 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-jarsigner.sh: $(top_builddir)/config.status $(srcdir)/jarsigner.sh.in
+appletviewer: $(top_builddir)/config.status $(srcdir)/appletviewer.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+jarsigner: $(top_builddir)/config.status $(srcdir)/jarsigner.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-keytool.sh: $(top_builddir)/config.status $(srcdir)/keytool.sh.in
+keytool: $(top_builddir)/config.status $(srcdir)/keytool.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	     || test -f $$p1 \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  echo " rm -f $$p $$f"; \
+	  rm -f $$p $$f ; \
+	done
+
+installcheck-binPROGRAMS: $(bin_PROGRAMS)
+	bad=0; pid=$$$$; list="$(bin_PROGRAMS)"; for p in $$list; do \
+	  case ' $(AM_INSTALLCHECK_STD_OPTIONS_EXEMPT) ' in \
+	   *" $$p "* | *" $(srcdir)/$$p "*) continue;; \
+	  esac; \
+	  f=`echo "$$p" | \
+	     sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  for opt in --help --version; do \
+	    if "$(DESTDIR)$(bindir)/$$f" $$opt >c$${pid}_.out \
+	         2>c$${pid}_.err </dev/null \
+		 && test -n "`cat c$${pid}_.out`" \
+		 && test -z "`cat c$${pid}_.err`"; then :; \
+	    else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \
+	  done; \
+	done; rm -f c$${pid}_.???; exit $$bad
+appletviewer$(EXEEXT): $(appletviewer_OBJECTS) $(appletviewer_DEPENDENCIES) 
+	@rm -f appletviewer$(EXEEXT)
+	$(LINK) $(appletviewer_LDFLAGS) $(appletviewer_OBJECTS) $(appletviewer_LDADD) $(LIBS)
+jarsigner$(EXEEXT): $(jarsigner_OBJECTS) $(jarsigner_DEPENDENCIES) 
+	@rm -f jarsigner$(EXEEXT)
+	$(LINK) $(jarsigner_LDFLAGS) $(jarsigner_OBJECTS) $(jarsigner_LDADD) $(LIBS)
+keytool$(EXEEXT): $(keytool_OBJECTS) $(keytool_DEPENDENCIES) 
+	@rm -f keytool$(EXEEXT)
+	$(LINK) $(keytool_LDFLAGS) $(keytool_OBJECTS) $(keytool_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f $$d$$p; then \
+	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	    echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	    $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/appletviewer-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jarsigner-toolwrapper.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keytool-toolwrapper.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+appletviewer-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(appletviewer_CFLAGS) $(CFLAGS) -MT appletviewer-toolwrapper.o -MD -MP -MF "$(DEPDIR)/appletviewer-toolwrapper.Tpo" -c -o appletviewer-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/appletviewer-toolwrapper.Tpo" "$(DEPDIR)/appletviewer-toolwrapper.Po"; else rm -f "$(DEPDIR)/appletviewer-toolwrapper.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='toolwrapper.c' object='appletviewer-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(appletviewer_CFLAGS) $(CFLAGS) -c -o appletviewer-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+appletviewer-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(appletviewer_CFLAGS) $(CFLAGS) -MT appletviewer-toolwrapper.obj -MD -MP -MF "$(DEPDIR)/appletviewer-toolwrapper.Tpo" -c -o appletviewer-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/appletviewer-toolwrapper.Tpo" "$(DEPDIR)/appletviewer-toolwrapper.Po"; else rm -f "$(DEPDIR)/appletviewer-toolwrapper.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='toolwrapper.c' object='appletviewer-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(appletviewer_CFLAGS) $(CFLAGS) -c -o appletviewer-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+jarsigner-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jarsigner_CFLAGS) $(CFLAGS) -MT jarsigner-toolwrapper.o -MD -MP -MF "$(DEPDIR)/jarsigner-toolwrapper.Tpo" -c -o jarsigner-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/jarsigner-toolwrapper.Tpo" "$(DEPDIR)/jarsigner-toolwrapper.Po"; else rm -f "$(DEPDIR)/jarsigner-toolwrapper.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='toolwrapper.c' object='jarsigner-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jarsigner_CFLAGS) $(CFLAGS) -c -o jarsigner-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+jarsigner-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jarsigner_CFLAGS) $(CFLAGS) -MT jarsigner-toolwrapper.obj -MD -MP -MF "$(DEPDIR)/jarsigner-toolwrapper.Tpo" -c -o jarsigner-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/jarsigner-toolwrapper.Tpo" "$(DEPDIR)/jarsigner-toolwrapper.Po"; else rm -f "$(DEPDIR)/jarsigner-toolwrapper.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='toolwrapper.c' object='jarsigner-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(jarsigner_CFLAGS) $(CFLAGS) -c -o jarsigner-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
+
+keytool-toolwrapper.o: toolwrapper.c
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(keytool_CFLAGS) $(CFLAGS) -MT keytool-toolwrapper.o -MD -MP -MF "$(DEPDIR)/keytool-toolwrapper.Tpo" -c -o keytool-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/keytool-toolwrapper.Tpo" "$(DEPDIR)/keytool-toolwrapper.Po"; else rm -f "$(DEPDIR)/keytool-toolwrapper.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='toolwrapper.c' object='keytool-toolwrapper.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(keytool_CFLAGS) $(CFLAGS) -c -o keytool-toolwrapper.o `test -f 'toolwrapper.c' || echo '$(srcdir)/'`toolwrapper.c
+
+keytool-toolwrapper.obj: toolwrapper.c
+@am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(keytool_CFLAGS) $(CFLAGS) -MT keytool-toolwrapper.obj -MD -MP -MF "$(DEPDIR)/keytool-toolwrapper.Tpo" -c -o keytool-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/keytool-toolwrapper.Tpo" "$(DEPDIR)/keytool-toolwrapper.Po"; else rm -f "$(DEPDIR)/keytool-toolwrapper.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='toolwrapper.c' object='keytool-toolwrapper.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(keytool_CFLAGS) $(CFLAGS) -c -o keytool-toolwrapper.obj `if test -f 'toolwrapper.c'; then $(CYGPATH_W) 'toolwrapper.c'; else $(CYGPATH_W) '$(srcdir)/toolwrapper.c'; fi`
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -372,12 +596,54 @@ uninstall-TOOLSDATA:
 	  echo " rm -f '$(DESTDIR)$(TOOLSdir)/$$f'"; \
 	  rm -f "$(DESTDIR)$(TOOLSdir)/$$f"; \
 	done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
 tags: TAGS
-TAGS:
 
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
 ctags: CTAGS
-CTAGS:
-
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
@@ -412,9 +678,9 @@ distdir: $(DISTFILES)
 check-am: all-am
 check: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) check-am
-all-am: Makefile $(DATA)
+all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA)
 installdirs:
-	for dir in "$(DESTDIR)$(TOOLSdir)"; do \
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(TOOLSdir)"; do \
 	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
 	done
 install: $(BUILT_SOURCES)
@@ -445,11 +711,14 @@ maintainer-clean-generic:
 	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
 clean: clean-am
 
-clean-am: clean-generic clean-libtool clean-local mostlyclean-am
+clean-am: clean-binPROGRAMS clean-generic clean-libtool clean-local \
+	mostlyclean-am
 
 distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-libtool
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-libtool distclean-tags
 
 dvi: dvi-am
 
@@ -463,21 +732,23 @@ info-am:
 
 install-data-am: install-TOOLSDATA
 
-install-exec-am:
+install-exec-am: install-binPROGRAMS install-binSCRIPTS
 
 install-info: install-info-am
 
 install-man:
 
-installcheck-am:
+installcheck-am: installcheck-binPROGRAMS installcheck-binSCRIPTS
 
 maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
 mostlyclean: mostlyclean-am
 
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
 
 pdf: pdf-am
 
@@ -487,18 +758,23 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am: uninstall-TOOLSDATA uninstall-info-am
+uninstall-am: uninstall-TOOLSDATA uninstall-binPROGRAMS \
+	uninstall-binSCRIPTS uninstall-info-am
 
-.PHONY: all all-am check check-am clean clean-generic clean-libtool \
-	clean-local dist-hook distclean distclean-generic \
-	distclean-libtool distdir dvi dvi-am html html-am info info-am \
-	install install-TOOLSDATA install-am install-data \
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic clean-libtool clean-local ctags dist-hook \
+	distclean distclean-compile distclean-generic \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-TOOLSDATA install-am \
+	install-binPROGRAMS install-binSCRIPTS install-data \
 	install-data-am install-exec install-exec-am install-info \
 	install-info-am install-man install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am uninstall \
-	uninstall-TOOLSDATA uninstall-am uninstall-info-am
+	installcheck-am installcheck-binPROGRAMS \
+	installcheck-binSCRIPTS installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags uninstall uninstall-TOOLSDATA uninstall-am \
+	uninstall-binPROGRAMS uninstall-binSCRIPTS uninstall-info-am
 
 @FOUND_ECJ_FALSE@@FOUND_GCJX_FALSE@@FOUND_GCJ_FALSE@@FOUND_JIKES_FALSE@error dunno how to setup the JCOMPILER and compile
 
@@ -523,11 +799,14 @@ dist-hook:
 $(TOOLS_ZIP): $(TOOLS_JAVA_FILES)
 	mkdir -p classes/gnu/classpath/tools/giop/grmic/templates
 	mkdir -p classes/gnu/classpath/tools/rmi/rmic/templates
+	mkdir -p classes/gnu/classpath/tools/appletviewer
+	mkdir -p classes/gnu/classpath/tools/jarsigner
+	mkdir -p classes/gnu/classpath/tools/keytool
 	cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmi/rmic/templates
-	cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates	
+	cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates
 	cp $(RMI_HELPS) classes/gnu/classpath/tools/rmi/
 	cp $(GIOP_HELPS) classes/gnu/classpath/tools/giop/
-	$(JCOMPILER) -d classes $(TOOLS_JAVA_FILES) 
+	$(JCOMPILER) -d classes $(TOOLS_JAVA_FILES)
 	(cd classes; \
 	if test "$(ZIP)" != ""; then $(ZIP) -r ../$(TOOLS_ZIP) .; fi; \
 	if test "$(FASTJAR)" != ""; then $(FASTJAR) cf ../$(TOOLS_ZIP) .; fi; \
@@ -537,6 +816,10 @@ $(TOOLS_ZIP): $(TOOLS_JAVA_FILES)
 # Zip file be gone! (and make sure the classes are gone too)
 clean-local:
 	rm -rf $(TOOLS_ZIP) classes
+
+# FIXME: remove this when GNU Classpath includes a bootstrap VM.
+installcheck-binSCRIPTS:
+	:
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/libjava/classpath/tools/appletviewer.in b/libjava/classpath/tools/appletviewer.in
new file mode 100644
index 000000000000..81e39ad91e68
--- /dev/null
+++ b/libjava/classpath/tools/appletviewer.in
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a 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 of the License, 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; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, 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.
+##
+## A simple shell script to launch the GNU Classpath appletviewer tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.appletviewer.Main $@
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java
new file mode 100644
index 000000000000..dfbedfe36d2c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletClassLoader.java
@@ -0,0 +1,81 @@
+/* AppletClassLoader -- a loader for applet classes
+   Copyright (C) 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+
+public class AppletClassLoader extends URLClassLoader
+{
+  /**
+   * Constructs a new <code>AppletLoader</code> object.
+   *
+   * @param codebase the codebase of the applet
+   * @param archives the urls to add to the search path
+   */
+  public AppletClassLoader(URL codebase, ArrayList archives)
+  {
+    super(new URL[0]);
+
+    for (int count = 0; count < archives.size(); count++)
+      addURL((URL) archives.get(count));
+
+    addURL(codebase);
+  }
+
+  /**
+   * Finds the specified class. This method should be overridden by
+   * class loader implementations that follow the delegation model for
+   * loading classes, and will be invoked by the loadClass method after
+   * checking the parent class loader for the requested class. The default
+   * implementation throws a ClassNotFoundException.
+   *
+   * (description copied from java.lang.ClassLoader.findClass(String))
+   *
+   * @param name The name of the class.
+   *
+   * @return the resulting <code>Class</code> object.
+   *
+   * @exception ClassNotFoundException if the class is not found.
+   */
+  protected Class findClass(String name) throws ClassNotFoundException
+  {
+    return super.findClass(name);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java
new file mode 100644
index 000000000000..32ab31639ca7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletSecurityManager.java
@@ -0,0 +1,95 @@
+/* AppletSecurityManager.java -- an applet security manager
+   Copyright (C) 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.io.FilePermission;
+import java.net.SocketPermission;
+import java.security.Permission;
+import java.security.SecurityPermission;
+import java.util.PropertyPermission;
+
+class AppletSecurityManager extends SecurityManager
+{
+  private boolean plugin;
+  
+  AppletSecurityManager(boolean plugin)
+  {
+    this.plugin = plugin;
+  }
+
+  public void checkPermission(Permission permission)
+  {
+    if (permission == null)
+      throw new NullPointerException();
+
+    // FIXME: we need to restrict this.
+    //
+    // libgcj asks for "java.io.FilePermission <<ALL FILES>> execute"
+    // to be able to execute "addr2line" to get proper stack traces.
+    if (permission instanceof FilePermission)
+      return;
+    
+    // FIXME: we need to restrict this.
+    if (permission instanceof SecurityPermission)
+      return;
+    
+    // FIXME: is this really needed ?
+    if (permission instanceof PropertyPermission)
+      return;
+    
+    // Needed to allow to access AWT event queue.
+    if (permission.getName().equals("accessEventQueue"))
+      return;
+    
+    // Needed to create a class loader for each codebase.
+    if (permission.getName().equals("createClassLoader"))
+      return;
+
+    // FIXME: we need to allow access to codebase here.
+
+    if (permission instanceof SocketPermission      // for net access
+	|| permission instanceof RuntimePermission) // for checkWrite(FileDescriptor)
+      return;
+
+    if (! plugin && permission.getName().equals("exitVM"))
+      return;
+    
+    // Reject all other permissions.
+    throw new SecurityException();
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java
new file mode 100644
index 000000000000..80d572857ca3
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletTag.java
@@ -0,0 +1,489 @@
+/* AppletTag.java -- a representation of an HTML APPLET tag
+   Copyright (C) 2003, 2004, 2005, 2006  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 gnu.classpath.tools.appletviewer;
+
+import gnu.xml.dom.html2.DomHTMLAppletElement;
+import gnu.xml.dom.html2.DomHTMLEmbedElement;
+import gnu.xml.dom.html2.DomHTMLObjectElement;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+
+import java.io.File;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Locale;
+
+/**
+ * @author Lillian Angel (langel@redhat.com)
+ * @author Thomas Fitzsimmons (fitzsim@redhat.com)
+ */
+class AppletTag
+{
+  
+  /**
+   * The document base of this applet.
+   */
+  URL documentbase;
+  
+  /**
+   * name of applet tag. 
+   */
+  String name = "";
+  
+  /**
+   * code of applet tag.
+   */
+  String code = "";
+  
+  /**
+   * codebase of applet tag.
+   */
+  String codebase = "";
+  
+  /**
+   * The archives.
+   */
+  ArrayList archives = new ArrayList();
+  
+  /**
+   * The parameters.
+   */
+  HashMap parameters = new HashMap();
+    
+  /**
+   * The screen size.
+   */
+  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+
+  /**
+   * Default constructor.
+   */
+  AppletTag()
+  {
+    // Do nothing.
+  }
+  
+  /**
+   * Constructs an AppletTag and parses the given applet element.
+   * 
+   * @param appElement - the Applet element to parse.
+   */
+  AppletTag(DomHTMLAppletElement appElement)
+  {    
+    name = appElement.getName();
+    parameters.put("name", name);
+
+    parameters.put("object", appElement.getObject());
+    parameters.put("align", appElement.getAlign());
+    parameters.put("alt", appElement.getAlt());
+    parameters.put("height", appElement.getHeight());
+    parameters.put("hspace", Integer.toString(appElement.getHspace()));
+    parameters.put("vspace", Integer.toString(appElement.getVspace()));
+    parameters.put("width", appElement.getWidth());
+    
+    TagParser.parseParams(appElement, this);
+    
+    if (code.equals(""))
+      {
+        code = appElement.getCode();
+        if (code.equals(""))
+          code = appElement.getCls();
+      }
+
+    // Must initialize codebase before archives
+    if (codebase.equals(""))
+      {
+        codebase = appElement.getCodeBase();
+        if (codebase.equals(""))
+          codebase = appElement.getSrc();
+      }
+    
+    if (archives.size() == 0)
+      {
+        String arcs = "";
+        String arch = appElement.getArchive();
+        
+        if (code.indexOf(".") < 0)
+          arcs = code + ".jar";
+        
+        if (!arch.equals(""))
+          arcs += "," + arch;
+        
+        if (!arcs.equals(""))
+          archives = TagParser.parseArchives(arcs, this);
+      }
+  }
+  
+  /**
+   * Constructs an AppletTag and parses the given embed element.
+   * 
+   * @param embElement - the Embed element to parse.
+   */
+  AppletTag(DomHTMLEmbedElement embElement)
+  {
+    // In an EMBED tag, a parameter is any non-standard attribute. This
+    // is a problem for applets that take parameters named "code",
+    // "codebase", "archive", "object", or "type". The solution is to
+    // allow the same attributes, prefixed by "java_". The presence of
+    // a "java_" attribute indicates that the non-prefixed attribute
+    // should be interpreted as a parameter. For example if "java_code"
+    // and "code" attributes are present in the EMBED tag then the
+    // "code" attribute is interpreted as a parameter.
+    
+    name = embElement.getName();
+    parameters.put("name", name);
+    
+    String jobj = embElement.getJavaObject();
+    if (!jobj.equals(""))
+      parameters.put("java_object", jobj);
+    else
+      parameters.put("object", embElement.getObject());
+
+    parameters.put("width", embElement.getWidth());
+    parameters.put("height", embElement.getHeight());
+    parameters.put("align", embElement.getAlign());
+    parameters.put("alt", embElement.getAlt());
+    parameters.put("hspace", Integer.toString(embElement.getHspace()));
+    parameters.put("mayscript", embElement.getMayscript());
+    parameters.put("pluginspage", embElement.getPluginsPage());
+    parameters.put("title", embElement.getTitle());
+    parameters.put("type", embElement.getType());
+    parameters.put("java_type", embElement.getJavaType());
+    parameters.put("vspace", Integer.toString(embElement.getVspace()));
+    
+    TagParser.parseParams(embElement, this);
+
+    // Must initialize codebase before archives
+    if (codebase.equals(""))
+      {
+        String javacb = embElement.getJavaCodeBase();
+        if (!javacb.equals(""))
+          codebase = javacb;
+        else
+          codebase = embElement.getCodeBase();
+      }
+
+    if (code.equals(""))
+      {
+        String jcode = embElement.getJavaCode();
+        if (!jcode.equals(""))
+          code = jcode;
+        else
+          code = embElement.getCode(); 
+      }
+    
+    if (archives.size() == 0)
+      {
+        String arcs = "";
+        String jarch = embElement.getJavaArchive();
+        String arch = embElement.getArchive();
+        
+        if (code.indexOf(".") < 0)
+          arcs = code + ".jar";
+        
+        if (!jarch.equals(""))
+          arcs += "," + jarch;
+        else if (!arch.equals(""))
+          arcs += "," + arch;
+        
+        if (!arcs.equals(""))
+          archives = TagParser.parseArchives(arcs, this);
+      }
+  }
+
+  /**
+   * Constructs an AppletTag and parses the given object element.
+   * 
+   * @param objElement - the Object element to parse.
+   */
+  AppletTag(DomHTMLObjectElement objElement)
+  {
+    // In an OBJECT tag, a parameter is any non-standard attribute. This
+    // is a problem for applets that take parameters named "code",
+    // "codebase", "archive", "object", or "type". The solution is to
+    // allow the same attributes, prefixed by "java_". The presence of
+    // a "java_" attribute indicates that the non-prefixed attribute
+    // should be interpreted as a parameter. For example if "java_code"
+    // and "code" attributes are present in the OBJECT tag then the
+    // "code" attribute is interpreted as a parameter.
+
+    name = objElement.getName();
+    parameters.put("name", name);
+
+    String jobj = objElement.getJavaObject();
+    if (!jobj.equals(""))
+      parameters.put("java_object", jobj);
+    else
+      parameters.put("object", objElement.getObject());
+
+    parameters.put("type", objElement.getType());
+    parameters.put("java_type", objElement.getJavaType());
+    parameters.put("align", objElement.getAlign());
+    parameters.put("codetype", objElement.getCodeType());
+    parameters.put("data", objElement.getData());
+    parameters.put("declare", Boolean.toString(objElement.getDeclare()));
+    parameters.put("height", objElement.getHeight());
+    parameters.put("hspace", Integer.toString(objElement.getHspace()));
+    parameters.put("border", objElement.getBorder());
+    parameters.put("standby", objElement.getStandby());
+    parameters.put("tabindex", Integer.toString(objElement.getTabIndex()));
+    parameters.put("usemap", objElement.getUseMap());
+    parameters.put("vspace", Integer.toString(objElement.getVspace()));
+    parameters.put("width", objElement.getWidth());
+    parameters.put("mayscript", objElement.getMayscript());
+    parameters.put("scriptable", objElement.getScriptable());
+
+    TagParser.parseParams(objElement, this);
+
+    // Must initialize codebase before archives
+    if (codebase.equals(""))
+      {
+        String javacb = objElement.getJavaCodeBase();
+        if (! javacb.equals(""))
+          codebase = javacb;
+        else
+          codebase = objElement.getCodeBase();
+      }
+
+    if (code.equals(""))
+      {
+        String jcode = objElement.getJavaCode();
+        if (!jcode.equals(""))
+          code = jcode;
+        else
+          code = objElement.getCode(); 
+      }
+    
+    if (archives.size() == 0)
+      {
+        String arcs = "";
+        String jarch = objElement.getJavaArchive();
+        String arch = objElement.getArchive();
+        
+        if (code.indexOf(".") < 0)
+          arcs = code + ".jar";
+        
+        if (!jarch.equals(""))
+          arcs += "," + jarch;
+        else if (!arch.equals(""))
+          arcs += "," + arch;
+        
+        if (!arcs.equals(""))
+          archives = TagParser.parseArchives(arcs, this);
+      }
+  }
+  
+  /**
+   * String representation of the tag.
+   * 
+   * @return the string representation.
+   */
+  public String toString()
+  {
+    return ("  name=" + name + "\n" + "  code=" + code + "\n" + "  codebase="
+            + codebase + "\n" + "  archive=" + archives + "\n" + "  parameters="
+            + parameters + "\n" + "  documentbase=" + documentbase + "\n");
+  }
+  
+  /**
+   * Returns the size of the applet.
+   * 
+   * @return the size.
+   */
+  Dimension getSize()
+  {
+    Dimension size = new Dimension(320, 200);
+
+    try
+      {
+        String widthStr = (String) parameters.get("width");
+        
+        if (widthStr != null && ! widthStr.equals(""))
+          {
+            if (widthStr.charAt(widthStr.length() - 1) == '%')
+              {
+                double p = NumberFormat.getPercentInstance(Locale.US).parse(widthStr).intValue() / 100.0;
+                size.width = (int)(p * screenSize.width);
+              }
+            else
+              size.width = NumberFormat.getInstance(Locale.US).parse(widthStr).intValue();
+          }
+      }
+    catch (ParseException e)
+      {
+        // Use default.
+      }
+
+    try
+      {
+        String heightStr = (String) parameters.get("height");
+
+        if (heightStr != null && !heightStr.equals(""))
+          {
+            if (heightStr.charAt(heightStr.length() - 1) == '%')
+              {
+                double p = NumberFormat.getPercentInstance(Locale.US).parse(heightStr).intValue() / 100.0;
+                size.height = (int) (p * screenSize.height);
+              }
+            else
+              size.height = NumberFormat.getInstance(Locale.US).parse(heightStr).intValue();
+          }
+      }
+    catch (ParseException e)
+      {
+        // Use default.
+      }
+
+    return size;
+  }
+  
+  /**
+   * Gets the code base.
+   *  
+   * @return the codebase.
+   */
+  String getCodeBase()
+  {
+    return codebase;
+  }
+  
+  /**
+   * Gets the archive list.
+   *  
+   * @return the archive list.
+   */
+  ArrayList getArchives()
+  {
+    return archives;
+  }
+  
+  /**
+   * Gets the code.
+   * 
+   * @return the code.
+   */
+  String getCode()
+  {
+    return code;
+  }
+  
+  /**
+   * Gets the document base.
+   *  
+   * @return the document base.
+   */
+  URL getDocumentBase()
+  {
+    return documentbase;
+  }
+  
+  /**
+   * Gets the specified parameter.
+   * 
+   * @param name - the specified parameter.
+   * @return the parameter.
+   */
+  String getParameter(String name)
+  {
+    return (String) parameters.get(name.toLowerCase());
+  }
+  
+  /**
+   * Prepends the base to the codebase.
+   * 
+   * @return the new URL.
+   */
+  URL prependCodeBase(String base) throws MalformedURLException
+  {
+    if (documentbase == null)
+      documentbase = TagParser.db;
+        
+    URL fullcodebase;
+
+    //If no codebase was specified, default to documentbase.
+    if (codebase.equals(""))
+      {
+        if (documentbase.getFile().endsWith(File.separator))
+          fullcodebase = documentbase;
+        else
+          {
+            String dirname = documentbase.getFile();
+            if (dirname.indexOf(".") < 0)
+              fullcodebase = new URL(documentbase + File.separator);
+            else
+              {
+                // Determine dirname for file by stripping everything
+                // past the last file separator.
+                dirname = dirname.substring(0,
+                                            dirname.lastIndexOf(File.separatorChar) + 1);
+
+                fullcodebase = new URL(documentbase.getProtocol(),
+                                       documentbase.getHost(),
+                                       documentbase.getPort(), dirname);
+              }
+          }
+      }
+    else
+      {
+        // codebase was specified.
+        URL codebaseURL = new URL(documentbase, codebase);
+        
+        if ("file".equals(codebaseURL.getProtocol()))
+          {
+            if (new File(codebaseURL.getFile()).isDirectory() && !codebase.endsWith(File.separator))
+              fullcodebase = new URL(documentbase, codebase + File.separator);
+            else
+              fullcodebase = new URL(documentbase, codebase);
+          }
+        else if (codebase.endsWith(File.separator))
+          fullcodebase = new URL(documentbase, codebase);
+        else
+          fullcodebase = new URL(documentbase, codebase + File.separator);
+      }
+    
+    return new URL(fullcodebase, base);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java
new file mode 100644
index 000000000000..b2376a4cb77f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/AppletWarning.java
@@ -0,0 +1,66 @@
+/* AppletWarning -- a security warning message display dialog
+   Copyright (C) 2003, 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import javax.swing.JOptionPane;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class AppletWarning
+{
+  private static String TITLE = "WARNING";
+  private static boolean showWarning = false;
+
+  private static String MESSAGE =
+    "The current version of this applet plugin does not provide\n" +
+    "a security manager capable of handling Java (tm) applets. Applets\n" +
+    "have UNRESTRICTED access to your computer. This means they can do\n" +
+    "anything you can do, like deleting all your important data.\n\n" +
+    "Continue ?";
+  
+  public static int show()
+  {
+    if (showWarning)
+      return JOptionPane.showConfirmDialog(null, MESSAGE, TITLE,
+                                           JOptionPane.YES_NO_OPTION,
+                                           JOptionPane.WARNING_MESSAGE);
+    else
+      return JOptionPane.YES_OPTION;
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java
new file mode 100644
index 000000000000..7e118e93162c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletContext.java
@@ -0,0 +1,133 @@
+/* CommonAppletContext.java -- a common applet's context
+   Copyright (C) 2004, 2005, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.applet.AudioClip;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+
+/*
+ * CommonAppletContext represents the common context stuff for both
+ * types, plugins and standalone.
+ */
+abstract class CommonAppletContext
+  implements AppletContext
+{
+  // FIXME: this needs to be static, and we need one AppletContext per
+  // Applet.
+  List applets = new ArrayList();
+  HashMap streams = new HashMap();
+
+  void addApplet(Applet applet)
+  {
+    applets.add(applet);
+  }
+
+  ///////////////////////////////
+  //// AppletContext methods ////
+  ///////////////////////////////
+  public AudioClip getAudioClip(URL url)
+  {
+    return Applet.newAudioClip(url);
+  }
+
+  public Image getImage(URL url)
+  {
+    return Toolkit.getDefaultToolkit().getImage(url);
+  }
+
+  public Applet getApplet(String name)
+  {
+    Applet a;
+    String appletName;
+    Iterator i = applets.iterator();
+
+    while (i.hasNext())
+      {
+	a = (Applet) i.next();
+
+	appletName = a.getParameter("name");
+	if (a != null && appletName != null && appletName.equals(name))
+	  return a;
+      }
+    return null;
+  }
+
+  public Enumeration getApplets()
+  {
+    return Collections.enumeration(applets);
+  }
+
+  public void showDocument(URL url)
+  {
+    showDocument(url, "_self");
+  }
+
+  /*
+  // FIXME: implement.
+  public abstract void showDocument (URL url, String target);
+
+  // FIXME: implement.
+  public abstract void showStatus (String status);
+  */
+  public void setStream(String key, InputStream stream)
+  {
+    streams.put(key, stream);
+  }
+
+  public InputStream getStream(String key)
+  {
+    return (InputStream) streams.get(key);
+  }
+
+  public Iterator getStreamKeys()
+  {
+    return streams.keySet().iterator();
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
new file mode 100644
index 000000000000..bc0cc45e1280
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/CommonAppletStub.java
@@ -0,0 +1,138 @@
+/* CommonAppletStub.java -- an applet-browser interface class
+   Copyright (C) 2003, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.applet.AppletContext;
+import java.applet.AppletStub;
+import java.applet.Applet;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+
+class CommonAppletStub
+  implements AppletStub
+{
+  private AppletTag tag;
+  private AppletContext context;
+  private Applet applet;
+
+  CommonAppletStub(AppletTag tag, AppletContext context, Applet applet)
+  {
+    this.tag = tag;
+    this.context = context;
+    this.applet = applet;
+  }
+
+  ////////////////////////////////
+  ////// AppletStub Methods //////
+  ////////////////////////////////
+  
+  /**
+   * Tests whether or not this applet is currently active. An applet
+   * becomes active just before the browser invokes start (), and
+   * becomes inactive just before the browser invokes stop ().
+   *
+   * @return true if applet is active, false otherwise
+   */
+  public boolean isActive()
+  {
+    return true;
+  }
+
+  /**
+   * Returns the basename URL of the document in which this applet is
+   * embedded.
+   *
+   * @return the document base url.
+   */
+  public URL getDocumentBase()
+  {
+    return tag.getDocumentBase();
+  }
+
+  /**
+   * Returns the URL of the code base for this applet.
+   *
+   * @return the codebase url
+   */
+  public URL getCodeBase()
+  {
+    try
+      {
+	return tag.prependCodeBase("");
+      }
+    catch (MalformedURLException e)
+      {
+        throw new RuntimeException("unknown codebase");
+      }
+  }
+
+  /**
+   * Returns the value of the specified parameter that was specified
+   * in the <code>APPLET</code> tag for this applet.
+   *
+   * @param name the key name
+   *
+   * @return the key value
+   */
+  public String getParameter(String name)
+  {
+    return (String) tag.getParameter(name.toLowerCase());
+  }
+
+  /**
+   * Returns the applet context for this applet.
+   *
+   * @return the context
+   */
+  public AppletContext getAppletContext()
+  {
+    return context;
+  }
+
+  /**
+   * Requests that the applet window for this applet be resized.
+   *
+   * @param width the new witdh
+   * @param height the new height
+   */
+  public void appletResize(int width, int height)
+  {
+    applet.setBounds (0, 0, width, height);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java
new file mode 100644
index 000000000000..9c937cc779d6
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ConsoleDialog.java
@@ -0,0 +1,175 @@
+/* ConsoleDialog -- a console dialog for applets
+   Copyright (C) 2003, 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Panel;
+import java.awt.TextArea;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+
+/**
+ * This class is a little dialog showing standard output and standard error output.
+ *
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class ConsoleDialog extends Frame
+  implements ActionListener
+{
+  static class InternalOutputStream extends OutputStream
+  {
+    private ConsoleDialog console;
+
+    public InternalOutputStream(ConsoleDialog console)
+    {
+      super();
+      this.console = console;
+    }
+
+    public void write(int data) throws IOException
+    {
+      console.print(String.valueOf((char) data));
+    }
+  }
+
+  private TextArea textArea;
+  private Button buttonClear;
+  private Button buttonHide;
+  private PrintStream printStream;
+
+  /**
+   * Creates a console dialog object.
+   */
+  public ConsoleDialog()
+  {
+    super(Main.messages.getString("gcjwebplugin.console_title"));
+
+    setSize(400, 200);
+    setLayout(new BorderLayout());
+    addWindowListener(new WindowAdapter()
+        {
+	  public void windowClosing(WindowEvent event)
+	  {
+	    hide();
+	  }
+        });
+
+    textArea = new TextArea();
+    textArea.setEditable(false);
+    add(textArea);
+
+    Panel panel = new Panel();
+    panel.setLayout(new FlowLayout());
+    add(panel, BorderLayout.SOUTH);
+
+    buttonClear = new Button(Main.messages.getString("gcjwebplugin.console_clear"));
+    buttonClear.addActionListener(this);
+    panel.add(buttonClear);
+
+    buttonHide = new Button(Main.messages.getString("gcjwebplugin.console_hide"));
+    buttonHide.addActionListener(this);
+    panel.add(buttonHide);
+
+    printStream = new PrintStream(new InternalOutputStream(this));
+    clearTextArea();
+  }
+
+  /**
+   * Clears the content of the textarea and inserts the initial text.
+   */
+  public void clearTextArea()
+  {
+    textArea.setText("");
+    
+    println("java.vm.version: " + System.getProperty("java.vm.version"));
+    println("java.vm.vendor: " + System.getProperty("java.vm.vendor"));
+  }
+
+  /**
+   * Print a message into the console dialog.
+   *
+   * @param message the message to print.
+   */
+  public void print(String message)
+  {
+    textArea.append(message);
+  }
+
+  /**
+   * Print a line into the console dialog.
+   *
+   * @param message the line to print.
+   */
+  public void println(String message)
+  {
+    print(message + "\n");
+  }
+
+  /**
+   * Perform actions on button clicks inside the console dialog.
+   *
+   * @param event the event.
+   */
+  public void actionPerformed(ActionEvent event)
+  {
+    if (event.getSource() == buttonHide)
+      hide(); // Hide console window.
+    else if (event.getSource() == buttonClear)
+      clearTextArea(); // Clear text area and insert standard messages.
+  }
+
+  /**
+   * Returns a <code>PrintStream</code> object that prints into the
+   * console dialog.
+   *
+   * @return the <code>PrintStream</code> object.
+   */
+  public PrintStream getPrintStream()
+  {
+    return printStream;
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java
new file mode 100644
index 000000000000..059dbee40afd
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/ErrorApplet.java
@@ -0,0 +1,53 @@
+/* ErrorApplet.java -- an applet to load in case of an error
+   Copyright (C) 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.applet.Applet;
+import java.awt.BorderLayout;
+import java.awt.Button;
+
+public class ErrorApplet extends Applet
+{
+  public ErrorApplet(String message)
+  {
+    setLayout(new BorderLayout());
+
+    Button button = new Button(message);
+    add(button);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java
new file mode 100644
index 000000000000..1d9fed2b04de
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/Main.java
@@ -0,0 +1,293 @@
+/* Main.java -- a standalone viewer for Java applets
+   Copyright (C) 2003, 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import java.applet.Applet;
+import java.awt.Dimension;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ResourceBundle;
+
+
+class Main
+{
+  /**
+   * The localized strings are kept in a separate file.
+   */
+  public static final ResourceBundle messages = ResourceBundle.getBundle
+    ("gnu.classpath.tools.appletviewer.MessagesBundle");
+
+  private static HashMap classLoaderCache = new HashMap();
+  
+  private static ClassLoader getClassLoader(URL codebase, ArrayList archives)
+  {
+    // Should load class loader each time. It is possible that there
+    // are more than one applet to be loaded with different archives.
+    AppletClassLoader loader = new AppletClassLoader(codebase, archives);
+    classLoaderCache.put(codebase, loader);
+
+    return loader;
+  }
+  
+  private static String code = null;
+  private static String codebase = null;
+  private static String archive = null;
+  private static List parameters = new ArrayList();
+  private static Dimension dimensions = new Dimension(-1, -1);
+  private static String pipeInName = null;
+  private static String pipeOutName = null;
+  private static boolean pluginMode = false;
+  private static Parser parser = null;
+
+  static Applet createApplet(AppletTag tag)
+  {
+    Applet applet = null;
+
+    try
+      {
+        ClassLoader loader = getClassLoader(tag.prependCodeBase(""),
+                                            tag.getArchives());
+        String code = tag.getCode();
+
+        if (code.endsWith(".class"))
+          code = code.substring(0, code.length() - 6).replace('/', '.');
+
+        Class c = loader.loadClass(code);
+        applet = (Applet) c.newInstance();
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+
+    if (applet == null)
+      applet = new ErrorApplet("Error loading applet");
+
+    return applet;
+  }
+
+  protected static boolean verbose;
+
+  /**
+   * The main method starting the applet viewer.
+   *
+   * @param args the arguments given on the command line.
+   *
+   * @exception IOException if an error occurs.
+   */
+  public static void main(String[] args) throws IOException
+  {
+    parser = new ClasspathToolParser("appletviewer", true);
+    parser.setHeader("usage: appletviewer [OPTION] -code CODE | URL...");
+
+    OptionGroup attributeGroup = new OptionGroup("Applet tag options");
+
+    attributeGroup.add(new Option("code", Main.messages.getString
+                                  ("gcjwebplugin.code_description"),
+                                  "CODE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          code = argument;
+        }
+      });
+    attributeGroup.add(new Option("codebase", Main.messages.getString
+                                  ("gcjwebplugin.codebase_description"),
+                                  "CODEBASE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          codebase = argument;
+        }
+      });
+    attributeGroup.add(new Option("archive", Main.messages.getString
+                                  ("gcjwebplugin.archive_description"),
+                                  "ARCHIVE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          archive = argument;
+        }
+      });
+    attributeGroup.add(new Option("width", Main.messages.getString
+                                  ("gcjwebplugin.width_description"),
+                                  "WIDTH")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          dimensions.width = Integer.parseInt(argument);
+        }
+      });
+    attributeGroup.add(new Option("height", Main.messages.getString
+                                  ("gcjwebplugin.height_description"),
+                                  "HEIGHT")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          dimensions.height = Integer.parseInt(argument);
+        }
+      });
+    attributeGroup.add(new Option("param", Main.messages.getString
+                                  ("gcjwebplugin.param_description"),
+                                  "NAME,VALUE")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          parameters.add(argument);
+        }
+      });
+    OptionGroup pluginGroup = new OptionGroup("Plugin option");
+    pluginGroup.add(new Option("plugin", Main.messages.getString
+                               ("gcjwebplugin.plugin_description"),
+                               "INPUT,OUTPUT")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          pluginMode = true;
+          int comma = argument.indexOf(',');
+          pipeInName = argument.substring(0, comma);
+          pipeOutName = argument.substring(comma + 1);
+        }
+      });
+    OptionGroup debuggingGroup = new OptionGroup("Debugging option");
+    debuggingGroup.add(new Option("verbose", Main.messages.getString
+                                  ("gcjwebplugin.verbose_description"),
+                                  (String) null)
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          verbose = true;
+        }
+      });
+    OptionGroup compatibilityGroup = new OptionGroup("Compatibility options");
+    compatibilityGroup.add(new Option("debug", Main.messages.getString
+                                      ("gcjwebplugin.debug_description"),
+                                      (String) null)
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          // Currently ignored.
+        }
+      });
+    compatibilityGroup.add(new Option("encoding", Main.messages.getString
+                                      ("gcjwebplugin.encoding_description"),
+                                      "CHARSET")
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          // FIXME: We should probably be using
+          // java.nio.charset.CharsetDecoder to handle the encoding.  What
+          // is the status of Classpath's implementation?
+        }
+      });
+    parser.add(attributeGroup);
+    parser.add(pluginGroup);
+    parser.add(debuggingGroup);
+    parser.add(compatibilityGroup);
+
+    String[] urls = parser.parse(args);
+
+    // Print arguments.
+    printArguments(args);
+
+    args = urls;
+
+    if (dimensions.height < 0)
+      dimensions.height = 200;
+
+    if (dimensions.width < 0)
+      dimensions.width = (int) (1.6 * dimensions.height);
+
+    //System.setSecurityManager(new AppletSecurityManager(pluginMode));
+
+    if (pluginMode)
+      {
+	InputStream in;
+	OutputStream out;
+
+        in = new FileInputStream(pipeInName);
+        out = new FileOutputStream(pipeOutName);
+
+	PluginAppletViewer.start(in, out);
+      }
+    else
+      {
+        if (code == null)
+          {
+            // The --code option wasn't given and there are no URL
+            // arguments so we have nothing to work with.
+            if (args.length == 0)
+              {
+                System.err.println(Main.messages.getString("gcjwebplugin.no_input_files"));
+                System.exit(1);
+              }
+            // Create a standalone appletviewer from a list of URLs.
+            new StandaloneAppletViewer(args);
+          }
+        else
+          {
+            // Create a standalone appletviewer from the --code
+            // option.
+            new StandaloneAppletViewer(code, codebase, archive, parameters, dimensions);
+          }
+      }
+  }
+
+  static void printArguments(String[] args)
+  {
+    if (verbose)
+      {
+        System.out.println("raw arguments:");
+
+        for (int i = 0; i < args.length; i++)
+          System.out.println(" " + args[i]);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
new file mode 100644
index 000000000000..a0e6acd124ce
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletContext.java
@@ -0,0 +1,72 @@
+/* PluginAppletContext.java -- an applet's context within a web browser
+   Copyright (C) 2003, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.net.URL;
+import java.io.IOException;
+
+/*
+ * PluginAppletContext represents the context within a webpage of a
+ * group of applets that all share the same codebase.
+ */
+class PluginAppletContext extends CommonAppletContext
+{
+  public void showDocument(URL url, String target)
+  {
+    try
+      {
+        PluginAppletViewer.write("url " + url + " " + target);
+      }
+    catch(IOException e)
+      {
+        System.err.println("showDocument failed: " + e);
+      }
+  }
+
+  public void showStatus(String status)
+  {
+    try
+      {
+        PluginAppletViewer.write("status " + status);
+      }
+    catch(IOException e)
+      {
+        System.err.println("showDocument failed: " + e);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
new file mode 100644
index 000000000000..fdb8097b44b8
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletViewer.java
@@ -0,0 +1,172 @@
+/* PluginAppletViewer.java -- manages embeddable applet windows
+   Copyright (C) 2003, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.MalformedURLException;
+import java.nio.charset.Charset;
+import java.util.HashMap;
+
+
+/**
+ * PluginAppletViewer communicates through pipes with a web browser
+ * plugin.  A PluginAppletViewer manages applet windows that may be
+ * embedded into web pages.
+ */
+class PluginAppletViewer
+{
+  // A mapping of instance IDs to PluginAppletWindows.
+  static HashMap appletWindows = new HashMap ();
+
+  private static BufferedReader pluginInputStream;
+  private static BufferedWriter pluginOutputStream;
+
+  static void start(InputStream inputStream, OutputStream outputStream)
+    throws MalformedURLException, IOException
+  {
+    // Set up input and output pipes.  Use UTF-8 encoding.
+    pluginInputStream =
+      new BufferedReader(new InputStreamReader(inputStream,
+                                               Charset.forName("UTF-8")));
+    pluginOutputStream =
+      new BufferedWriter(new OutputStreamWriter(outputStream,
+                                                Charset.forName("UTF-8")));
+
+    write("running");
+
+    // Read first message.
+    String message = read();
+
+    PluginAppletWindow currentWindow = null;
+
+    while (true)
+      {
+	if (message.startsWith("instance"))
+	  {
+	    // Read applet instance identifier.
+	    String key = message.substring(9);
+
+	    if (appletWindows.get(key) == null)
+	      appletWindows.put(key, new PluginAppletWindow());
+
+	    currentWindow = (PluginAppletWindow) appletWindows.get(key);
+	  }
+	else if (message.startsWith("tag"))
+	  {
+	    int pos = message.indexOf(' ', 4);
+	    String documentbase = message.substring(4, pos);
+        String tag = message.substring(pos + 1);
+        currentWindow.setParser(tag, documentbase);
+	  }
+	else if (message.startsWith("handle"))
+	  {
+	    long handle = Long.parseLong(message.substring(7));
+
+	    currentWindow.setHandle(handle);
+	  }
+	else if (message.startsWith("width"))
+	  {
+	    int width = Integer.parseInt(message.substring(6));
+
+	    currentWindow.setSize(width, currentWindow.getHeight());
+	  }
+	else if (message.startsWith("height"))
+	  {
+	    int height = Integer.parseInt(message.substring(7));
+
+	    currentWindow.setSize(currentWindow.getWidth(), height);
+	  }
+	else if (message.startsWith("destroy"))
+	  {
+	    appletWindows.remove(currentWindow);
+	    currentWindow.dispose();
+	  }
+
+	// Read next message.
+	message = read();
+      }
+  }
+
+  /**
+   * Write string to plugin.
+   * 
+   * @param message the message to write
+   *
+   * @exception IOException if an error occurs
+   */
+  static void write(String message) throws IOException
+  {
+    pluginOutputStream.write(message, 0, message.length());
+    pluginOutputStream.newLine();
+    pluginOutputStream.flush();
+
+    System.err.println("  PIPE: applet viewer wrote: " + message);
+  }
+
+  /**
+   * Read string from plugin.
+   *
+   * @return the read string
+   *
+   * @exception IOException if an error occurs
+   */
+  static String read() throws IOException
+  {
+    String message = pluginInputStream.readLine();
+
+    System.err.println("  PIPE: applet viewer read: " + message);
+
+    if (message == null || message.equals("shutdown"))
+      {
+	// Close input/output channels to plugin.
+	pluginInputStream.close();
+	pluginOutputStream.close();
+
+	System.err.println("appletviewer: exiting plugin applet viewer");
+	System.exit(0);
+      }
+
+    return message;
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
new file mode 100644
index 000000000000..6d36e1cf0b9d
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/PluginAppletWindow.java
@@ -0,0 +1,454 @@
+/* PluginAppletWindow.java -- an embeddable applet window
+   Copyright (C) 2003, 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import gnu.java.awt.EmbeddedWindow;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.awt.Dimension;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.swing.JOptionPane;
+
+
+class PluginAppletWindow
+    extends EmbeddedWindow
+    implements ContainerListener, ComponentListener, MouseListener,
+    MouseMotionListener, InputMethodListener, HierarchyListener,
+    HierarchyBoundsListener
+{
+  
+  // This class implements various listeners because the author of an applet
+  // may attach listeners to it, unaware of the applet's parent (this class). 
+  // So, we must pass all listener events on this plugin applet window to the
+  // actual applet.
+  
+  private static HashMap contexts = new HashMap();
+  private Applet applet;
+  private TagParser parser;
+  private AppletTag tag;
+
+  PluginAppletWindow()
+  {
+    super();
+    addContainerListener(this);
+    addComponentListener(this);
+    addMouseListener(this);
+    addMouseMotionListener(this);
+    addInputMethodListener(this);
+    addHierarchyListener(this);
+    addHierarchyBoundsListener(this);
+  }  
+  
+  ///////////////////////////////////
+  /// ContainerListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when a component is added to the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component
+   *          addition
+   */
+  public void componentAdded(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentAdded(event);
+      }
+  }
+
+  /**
+   * This method is called when a component is removed from the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component removal
+   */
+  public void componentRemoved(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentRemoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// ComponentListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the component is resized.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the resize
+   */
+  public void componentResized(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentResized(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is moved.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the move
+   */
+  public void componentMoved(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentMoved(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is made visible.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentShown(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentShown(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is hidden.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentHidden(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentHidden(event);
+      }
+  }
+     
+  ///////////////////////////////////
+  ////// MouseListener Methods //////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is clicked (pressed and released
+   * in short succession) on a component.
+   *
+   * @param event the <code>MouseEvent</code> indicating the click
+   */
+  public void mouseClicked(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseClicked(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is pressed over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the press
+   */
+  public void mousePressed(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mousePressed(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is released over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the release
+   */
+  public void mouseReleased(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseReleased(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse enters a component.
+   *
+   * @param event the <code>MouseEvent</code> for the entry
+   */
+  public void mouseEntered(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseEntered(event);
+      }
+  }
+
+  /** 
+   * This method is called when the mouse exits a component.
+   *
+   * @param event the <code>MouseEvent</code> for the exit
+   */
+  public void mouseExited(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseExited(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// MouseMotionListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is moved over a component
+   * while a button has been pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseDragged(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseDragged(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is moved over a component
+   * while no button is pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseMoved(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseMoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// InputMethodListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the text change
+   */
+  public void inputMethodTextChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].inputMethodTextChanged(event);
+      }
+  }
+
+  /**
+   * This method is called when the cursor position within the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the change
+   */
+  public void caretPositionChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].caretPositionChanged(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  //// HierarchyListener Methods ////
+  ///////////////////////////////////
+  
+  /**
+   * Called when the hierarchy of this component changes. Use
+   * <code>getChangeFlags()</code> on the event to see what exactly changed.
+   *
+   * @param e the event describing the change
+   */
+  public void hierarchyChanged(HierarchyEvent event)
+  {
+    if (applet != null)
+      {
+        HierarchyListener[] l = applet.getHierarchyListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].hierarchyChanged(event);
+      }
+  }
+  
+  /////////////////////////////////////////
+  //// HierarchyBoundsListener Methods ////
+  /////////////////////////////////////////
+  
+  /**
+   * Called when an ancestor component of the source is moved.
+   *
+   * @param e the event describing the ancestor's motion
+   */
+  public void ancestorMoved(HierarchyEvent e)
+  {
+    if (applet != null)
+      {
+        HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].ancestorMoved(e);
+      }
+  }
+
+  /**
+   * Called when an ancestor component is resized.
+   *
+   * @param e the event describing the ancestor's resizing
+   */
+  public void ancestorResized(HierarchyEvent e)
+  {
+    if (applet != null)
+      {
+        HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].ancestorResized(e);
+      }
+  }
+  
+  void setParser(String tag, String documentbase) throws MalformedURLException, IOException
+  {
+    URL documentbaseURL = TagParser.getLocationToURL(documentbase);
+    StringReader in = new StringReader(tag);
+    this.parser = new TagParser(in, documentbaseURL);
+  }
+
+  // /////////////////////////////////
+  // //// EmbeddedWindow Method //////
+  // /////////////////////////////////
+
+  /**
+   * Set the native handle of the window system to embed the window in.
+   * 
+   * @param handle the native handle.
+   */
+  public void setHandle(long handle)
+  {
+    super.setHandle(handle);
+    addNotify();
+
+    ArrayList l = parser.parseAppletTags();
+    int s = l.size();
+
+    for (int i = 0; i < s; i++)
+      {
+        tag = (AppletTag) l.get(i);
+        applet = Main.createApplet(tag);
+
+        if (contexts.get(tag.getCodeBase()) == null)
+          contexts.put(tag.getCodeBase(), new PluginAppletContext());
+
+        int result = AppletWarning.show();
+        if (result == JOptionPane.NO_OPTION)
+          return;
+
+        add(applet);
+
+        AppletContext context = (AppletContext) contexts.get(tag.getCodeBase());
+        ((PluginAppletContext) context).addApplet(applet);
+
+        applet.setStub(new CommonAppletStub(tag, context, applet));
+        Dimension size = getSize();
+        if (size.width == 0 || size.height == 0)
+          size = tag.getSize();
+        applet.setSize(size);          
+        
+        // Initialize the applet before showing this window so that
+        // the applet doesn't receive events before it has been
+        // initialized.
+        applet.init();
+        applet.start();
+        setVisible(true);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
new file mode 100644
index 000000000000..a779f068ab61
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletContext.java
@@ -0,0 +1,75 @@
+/* StandaloneAppletContext.java -- an applet's context within the
+   standalone viewer
+   Copyright (C) 2003, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * StandaloneAppletContext represents the context within a webpage of a
+ * group of applets that all share the same codebase.
+ */
+class StandaloneAppletContext extends CommonAppletContext
+{
+  private List appletWindows;
+
+  StandaloneAppletContext(List appletWindows)
+  {
+    this.appletWindows = appletWindows;
+  }
+
+  public void showDocument(URL url, String target)
+  {
+    System.err.println("showDocument is not implemented in standalone mode");
+  }
+
+  // In standalone mode, there are potentially several windows, each
+  // with its own status bar.  In plugin mode, all the applets in the
+  // same context (on the same page) share the browser's status bar.
+  // The best way to simulate the plugin mode behaviour in standalone
+  // mode is to show the same status on each window's status bar.
+  public void showStatus(String status)
+  {
+    Iterator window = appletWindows.iterator();
+    while (window.hasNext())
+      ((StandaloneAppletWindow) window.next()).showStatus(status);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
new file mode 100644
index 000000000000..2b58f4b87e83
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletViewer.java
@@ -0,0 +1,144 @@
+/* StandaloneAppletViewer.java -- a standalone viewer for Java applets
+   Copyright (C) 2003, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.awt.Dimension;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+
+/**
+ * StandaloneAppletViewer displays an applet in its own Frame.  Most
+ * of the context that is available to an applet within a webpage is
+ * available to it in StandaloneAppletViewer.
+ */
+class StandaloneAppletViewer extends Main
+{
+  static ArrayList appletTags = new ArrayList();
+  static ArrayList appletWindows = new ArrayList();
+
+  StandaloneAppletViewer(String[] urls)
+    throws MalformedURLException, IOException
+  {
+    // Handle each file specified on the command line.
+    for (int i = 0; i < urls.length; i++)
+      {
+        TagParser parser = new TagParser(urls[i]);
+        appletTags.addAll(parser.parseAppletTags());
+      }
+
+    printTags();
+    createWindows();
+  }
+
+  StandaloneAppletViewer(String code, String codebase, String archives,
+                         List parameters, Dimension dimensions)
+    throws IOException
+    {
+      if (!(code.equals("") || code.endsWith(".class")))
+        {
+          System.err.println("appletviewer: option '--code' requires a class filename");
+          System.exit(1);
+        }
+      
+      String tagString =
+        "<EMBED"
+        + " CODE=\"" + code + "\""
+        + " WIDTH=" + dimensions.width
+        + " HEIGHT=" + dimensions.height
+        + " CODEBASE=\"" + codebase + "\""
+        + " ARCHIVE=\"" + archives + "\">";
+
+      // Handle parameters.
+      Iterator pairs = parameters.iterator();
+      while (pairs.hasNext())
+        {
+          StringTokenizer paramTokenizer =
+            new StringTokenizer((String) pairs.next(), ",");
+          tagString +=
+            "<PARAM NAME=" + paramTokenizer.nextToken().trim() + " VALUE="
+            + paramTokenizer.nextToken().trim() + ">";
+        }
+      
+      tagString += "</EMBED>";
+
+      StringReader reader = new StringReader(tagString);
+      String path = System.getProperty("user.dir") + File.separator;
+      TagParser parser = new TagParser(reader,
+                                    new URL("file", "", path));
+      appletTags.addAll(parser.parseAppletTags());
+
+      printTags();
+      createWindows();
+    }
+
+  void printTags()
+  {
+    if (verbose)
+      {
+        System.out.println("parsed applet tags:");
+
+        for (int i = 0; i < appletTags.size(); i++)
+          {
+            AppletTag tag = (AppletTag) appletTags.get(i);
+
+            System.out.println(" tag " + i + ":");
+            System.out.println(tag);
+          }
+      }
+  }
+
+  void createWindows()
+  {
+    for (int i = 0; i < appletTags.size(); i++)
+      {
+        AppletTag tag = (AppletTag) appletTags.get(i);
+          
+        // Create a StandaloneAppletWindow and add it to the
+        // appletWindows list.
+        new StandaloneAppletWindow(tag, appletWindows);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
new file mode 100644
index 000000000000..3b337bf803cf
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/StandaloneAppletWindow.java
@@ -0,0 +1,559 @@
+/* StandaloneAppletWindow.java -- an applet frame
+   Copyright (C) 2003, 2004, 2006  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 gnu.classpath.tools.appletviewer;
+
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Insets;
+import java.awt.Label;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerEvent;
+import java.awt.event.ContainerListener;
+import java.awt.event.HierarchyBoundsListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
+import java.awt.event.InputMethodEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.HashMap;
+import java.util.List;
+
+class StandaloneAppletWindow
+    extends Frame
+    implements ActionListener, ContainerListener, ComponentListener,
+    MouseListener, MouseMotionListener, InputMethodListener, HierarchyListener,
+    HierarchyBoundsListener
+{
+  
+  // This class implements various listeners because the author of an applet
+  // may attach listeners to it, unaware of the applet's parent (this class). 
+  // So, we must pass all listener events on this plugin applet window to the
+  // actual applet.
+  
+  private static int testWindowCount;
+  private static HashMap contexts = new HashMap();
+  private Applet applet;
+  private Label status = new Label();
+
+  private MenuItem restartItem;
+  private MenuItem reloadItem;
+  private MenuItem cancelItem;
+  private MenuItem saveItem;
+  private MenuItem startItem;
+  private MenuItem cloneItem;
+  private MenuItem tagItem;
+  private MenuItem infoItem;
+  private MenuItem editItem;
+  private MenuItem encodingItem;
+  private MenuItem printItem;
+  private MenuItem propertiesItem;
+  private MenuItem closeItem;
+  private MenuItem quitItem;
+
+  StandaloneAppletWindow(AppletTag tag, List appletWindows)
+  {
+    appletWindows.add(this);
+    applet = Main.createApplet(tag);
+
+    if (contexts.get(tag.codebase) == null)
+      contexts.put(tag.codebase, new StandaloneAppletContext(appletWindows));
+
+    setLayout(new BorderLayout());
+    add(applet, BorderLayout.CENTER);
+    add(status, BorderLayout.SOUTH);
+
+    addWindowListener(new WindowAdapter()
+        {
+	  public void windowClosing(WindowEvent event)
+	  {
+	    applet.stop();
+	    StandaloneAppletWindow.this.hide();
+	    System.exit(0);
+	  }
+        });
+    
+    addContainerListener(this);
+    addComponentListener(this);
+    addMouseListener(this);
+    addMouseMotionListener(this);
+    addInputMethodListener(this);
+    addHierarchyListener(this);
+    addHierarchyBoundsListener(this);
+    
+    restartItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_restart"));
+    restartItem.setEnabled(false);
+    restartItem.addActionListener(this);
+    reloadItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_reload"));
+    reloadItem.setEnabled(false);
+    reloadItem.addActionListener(this);
+    cancelItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_cancel"));
+    cancelItem.setEnabled(false);
+    cancelItem.addActionListener(this);
+    saveItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_save"));
+    saveItem.setEnabled(false);
+    saveItem.addActionListener(this);
+    startItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_start"));
+    startItem.setEnabled(false);
+    startItem.addActionListener(this);
+    cloneItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_clone"));
+    cloneItem.setEnabled(false);
+    cloneItem.addActionListener(this);
+    closeItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_close"));
+    closeItem.setEnabled(false);
+    closeItem.addActionListener(this);
+    tagItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_tag"));
+    tagItem.setEnabled(false);
+    tagItem.addActionListener(this);
+    infoItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_info"));
+    infoItem.setEnabled(false);
+    infoItem.addActionListener(this);
+    editItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_edit"));
+    editItem.setEnabled(false);
+    editItem.addActionListener(this);
+    editItem.setEnabled(false);
+    encodingItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_encoding"));
+    encodingItem.setEnabled(false);
+    encodingItem.addActionListener(this);
+    printItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_print"));
+    printItem.setEnabled(false);
+    printItem.addActionListener(this);
+    propertiesItem =
+      new MenuItem(Main.messages.getString("gcjwebplugin.menu_properties"));
+    propertiesItem.setEnabled(false);
+    propertiesItem.addActionListener(this);
+    quitItem = new MenuItem(Main.messages.getString("gcjwebplugin.menu_quit"));
+    quitItem.addActionListener(this);
+
+    MenuBar menuBar = new MenuBar();
+    Menu menuApplet = new Menu(Main.messages.getString("gcjwebplugin.menu_title"));
+    menuBar.add(menuApplet);
+    menuApplet.add(restartItem);
+    menuApplet.add(reloadItem);
+    menuApplet.add(cancelItem);
+    menuApplet.add(saveItem);
+    menuApplet.add(startItem);
+    menuApplet.add(cloneItem);
+    menuApplet.addSeparator();
+    menuApplet.add(tagItem);
+    menuApplet.add(infoItem);
+    menuApplet.add(editItem);
+    menuApplet.add(encodingItem);
+    menuApplet.addSeparator();
+    menuApplet.add(printItem);
+    menuApplet.addSeparator();
+    menuApplet.add(propertiesItem);
+    menuApplet.addSeparator();
+    menuApplet.add(closeItem);
+    menuApplet.add(quitItem);
+    setMenuBar(menuBar);
+    setTitle("GCJ Applet Viewer: " + tag.code);
+
+    AppletContext context = (AppletContext) contexts.get(tag.codebase);
+    ((StandaloneAppletContext) context).addApplet(applet);
+
+    applet.setStub(new CommonAppletStub(tag, context, applet));
+
+    // Create the frame's peer. Otherwise getPreferredSize will read
+    // its insets as 0.
+    addNotify();
+    Insets i = getInsets();
+    Dimension size = tag.getSize();
+    setSize(i.left + size.width + i.right,
+            i.top + size.height + status.getPreferredSize().height
+            + i.bottom);
+    applet.setSize(size);
+
+    // Initialize the applet before showing this window so that the
+    // applet doesn't receive events before it has been initialized.
+    applet.init();
+    applet.start();
+    setVisible(true);
+  }
+
+  private void closeWindow()
+  {
+    applet.stop();
+    StandaloneAppletViewer.appletWindows.remove(this);
+    StandaloneAppletWindow.this.hide();
+  }
+
+  public void actionPerformed(ActionEvent e)
+  {
+    if (e.getSource() == quitItem)
+      {
+        closeWindow();
+        System.exit(0);
+      }
+    else if (e.getSource() == closeItem)
+      {
+	// Close current window.
+	closeWindow();
+	
+	// Exit if there are other windows left.
+	if (StandaloneAppletViewer.appletWindows.isEmpty())
+          System.exit(0);
+      }
+  }
+
+  void showStatus(String status)
+  {
+    this.status.setText(status);
+  }
+  
+
+  ///////////////////////////////////
+  /// ContainerListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when a component is added to the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component
+   *          addition
+   */
+  public void componentAdded(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentAdded(event);
+      }
+  }
+
+  /**
+   * This method is called when a component is removed from the container.
+   * 
+   * @param event the <code>ContainerEvent</code> indicating component removal
+   */
+  public void componentRemoved(ContainerEvent event)
+  {
+    if (applet != null)
+      {
+        ContainerListener[] l = applet.getContainerListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentRemoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// ComponentListener Methods /////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the component is resized.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the resize
+   */
+  public void componentResized(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentResized(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is moved.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the move
+   */
+  public void componentMoved(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentMoved(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is made visible.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentShown(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentShown(event);
+      }
+  }
+
+  /**
+   * This method is called when the component is hidden.
+   *
+   * @param event the <code>ComponentEvent</code> indicating the visibility
+   */
+  public void componentHidden(ComponentEvent event)
+  {
+    if (applet != null)
+      {
+        ComponentListener[] l = applet.getComponentListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].componentHidden(event);
+      }
+  }
+     
+  ///////////////////////////////////
+  ////// MouseListener Methods //////
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is clicked (pressed and released
+   * in short succession) on a component.
+   *
+   * @param event the <code>MouseEvent</code> indicating the click
+   */
+  public void mouseClicked(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseClicked(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is pressed over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the press
+   */
+  public void mousePressed(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mousePressed(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is released over a component.
+   *
+   * @param event the <code>MouseEvent</code> for the release
+   */
+  public void mouseReleased(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseReleased(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse enters a component.
+   *
+   * @param event the <code>MouseEvent</code> for the entry
+   */
+  public void mouseEntered(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseEntered(event);
+      }
+  }
+
+  /** 
+   * This method is called when the mouse exits a component.
+   *
+   * @param event the <code>MouseEvent</code> for the exit
+   */
+  public void mouseExited(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseListener[] l = applet.getMouseListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseExited(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// MouseMotionListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the mouse is moved over a component
+   * while a button has been pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseDragged(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseDragged(event);
+      }
+  }
+
+  /**
+   * This method is called when the mouse is moved over a component
+   * while no button is pressed.
+   *
+   * @param event the <code>MouseEvent</code> indicating the motion
+   */
+  public void mouseMoved(MouseEvent event)
+  {
+    if (applet != null)
+      {
+        MouseMotionListener[] l = applet.getMouseMotionListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].mouseMoved(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  /// InputMethodListener Methods ///
+  ///////////////////////////////////
+  
+  /**
+   * This method is called when the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the text change
+   */
+  public void inputMethodTextChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].inputMethodTextChanged(event);
+      }
+  }
+
+  /**
+   * This method is called when the cursor position within the text is changed.
+   *
+   * @param event the <code>InputMethodEvent</code> indicating the change
+   */
+  public void caretPositionChanged(InputMethodEvent event)
+  {
+    if (applet != null)
+      {
+        InputMethodListener[] l = applet.getInputMethodListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].caretPositionChanged(event);
+      }
+  }
+  
+  ///////////////////////////////////
+  //// HierarchyListener Methods ////
+  ///////////////////////////////////
+  
+  /**
+   * Called when the hierarchy of this component changes. Use
+   * <code>getChangeFlags()</code> on the event to see what exactly changed.
+   *
+   * @param e the event describing the change
+   */
+  public void hierarchyChanged(HierarchyEvent event)
+  {
+    if (applet != null)
+      {
+        HierarchyListener[] l = applet.getHierarchyListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].hierarchyChanged(event);
+      }
+  }
+  
+  /////////////////////////////////////////
+  //// HierarchyBoundsListener Methods ////
+  /////////////////////////////////////////
+  
+  /**
+   * Called when an ancestor component of the source is moved.
+   *
+   * @param e the event describing the ancestor's motion
+   */
+  public void ancestorMoved(HierarchyEvent e)
+  {
+    if (applet != null)
+      {
+        HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].ancestorMoved(e);
+      }
+  }
+
+  /**
+   * Called when an ancestor component is resized.
+   *
+   * @param e the event describing the ancestor's resizing
+   */
+  public void ancestorResized(HierarchyEvent e)
+  {
+    if (applet != null)
+      {
+        HierarchyBoundsListener[] l = applet.getHierarchyBoundsListeners();
+        for (int i = 0; i < l.length; i++)
+          l[i].ancestorResized(e);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java
new file mode 100644
index 000000000000..68dce97e0baf
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java
@@ -0,0 +1,302 @@
+/* TagParser.java -- a parser for applet tags
+   Copyright (C) 2006  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 gnu.classpath.tools.appletviewer;
+
+import gnu.javax.swing.text.html.parser.HTML_401F;
+
+import gnu.xml.dom.DomNode;
+import gnu.xml.dom.html2.DomHTMLAppletElement;
+import gnu.xml.dom.html2.DomHTMLDocument;
+import gnu.xml.dom.html2.DomHTMLEmbedElement;
+import gnu.xml.dom.html2.DomHTMLObjectElement;
+import gnu.xml.dom.html2.DomHTMLParamElement;
+import gnu.xml.dom.html2.DomHTMLParser;
+
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.Reader;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.w3c.dom.NodeList;
+
+
+public class TagParser
+{
+    
+  /**
+   * Parsed document.
+   */
+  DomHTMLDocument document;
+  
+  /**
+   * The document base of this applet.
+   */
+  URL documentbase;
+  
+  /**
+   * The document base of all the applets.
+   */
+  static URL db;
+  
+  /** 
+   * The tags in the document.
+   */
+  Vector tags = new Vector();
+  
+  /**
+   * Default constructor.
+   */
+  TagParser()
+  {
+    // Do nothing.
+  }
+
+  /**
+   * Constructs and parses document using the given location.
+   * 
+   * @param location - location of applet
+   */
+  TagParser(String location) throws IOException
+  {
+    documentbase = getLocationToURL(location);
+    db = documentbase;
+    InputStreamReader in = new InputStreamReader(documentbase.openStream());
+    document = (DomHTMLDocument) (new DomHTMLParser(HTML_401F.getInstance()).parseDocument(in));
+  }
+
+  /**
+   * Constructs and parses document.
+   * 
+   * @param in - Reader to parse document from.
+   * @param documentBase - the URL of the applet
+   * @throws IOException - is thrown if any IO error occurs.
+   */
+  TagParser(Reader in, URL documentBase) throws IOException
+  {
+    documentbase = documentBase;
+    db = documentbase;
+    document = (DomHTMLDocument) (new DomHTMLParser(HTML_401F.getInstance()).parseDocument(in));
+  }
+  
+  /**
+   * Parses all applet tags in document.
+   * 
+   * @return a list of AppletTag objects representing the applet tags
+   * in document
+   */
+  ArrayList parseAppletTags()
+  {    
+    ArrayList allTags = new ArrayList();
+    if (document == null)
+      return null;;
+    
+    recurseDocument(document.getChildNodes());
+
+    int sz = tags.size();
+    for (int j = 0; j < sz; j++)
+      {
+        Object curr = tags.get(j);
+        // Order of checking is important here.
+        // Must check embed element before applet element
+        // because DomHTMLEmbedElement extends DomHTMLAppletElement
+        AppletTag a = null;
+        if (curr instanceof DomHTMLEmbedElement)
+          a = new AppletTag((DomHTMLEmbedElement) curr);
+        else if (curr instanceof DomHTMLAppletElement)
+          a = new AppletTag((DomHTMLAppletElement) curr);
+        else if (curr instanceof DomHTMLObjectElement)
+          a = new AppletTag((DomHTMLObjectElement) curr);
+        a.documentbase = documentbase;
+        allTags.add(a);
+      }
+    
+    return allTags;
+  }
+  
+  /**
+   * Recurses the document in search for the appropriate tags.
+   * 
+   * @param list - the Node list.
+   */
+  private void recurseDocument(NodeList list)
+  {
+    // Recurse and store all APPLET, OBJECT and EMBED tags.
+    int length = list.getLength();
+    for (int i = 0; i < length; i++)
+      {
+        DomNode curr = (DomNode) list.item(i);
+        if ((curr instanceof DomHTMLEmbedElement) || 
+            (curr instanceof DomHTMLAppletElement) ||
+            (curr instanceof DomHTMLObjectElement))
+          tags.add(curr);
+        recurseDocument(curr.getChildNodes());
+      }
+  }
+  
+  /**
+   * Parses the param elements for a given node.
+   * 
+   * @param node - the node element to parse.
+   */
+  static void parseParams(DomNode node, AppletTag t)
+  {
+    boolean ja = false;
+    boolean jb = false;
+    boolean jc = false;
+    NodeList l = node.getChildNodes();
+    int size = l.getLength();
+    
+    if (size != 0)
+      for (int i = 0; i < size; i++)
+        {
+          Object c = l.item(i);
+          if (! (c instanceof DomHTMLParamElement))
+            continue;
+          DomHTMLParamElement curr = (DomHTMLParamElement) c;
+          String key = curr.getName();
+          String val = curr.getValue();
+          
+          if (key.equals("java_code"))
+            {
+              jc = true;
+              t.code = val;
+            }
+          else if (key.equals("java_codebase"))
+            {
+              jb = true;
+              t.codebase = val;
+            }
+          else if (!jc && key.equals("code"))
+            t.code = val;
+          else if (!jc && key.equals("classid"))
+            {
+              int x = val.indexOf(":");
+              if (x != -1)
+                val = val.substring(x + 1);
+              t.code = val;
+            }
+          else if (!jb && key.equals("codebase"))
+            t.codebase = val;
+          else if (key.equals("java_archive"))
+            {
+              ja = true;
+              t.archives = parseArchives(val, t);
+              val = t.archives.toString();
+            }
+          else if (!ja && key.equals("archive"))
+            {
+              t.archives = parseArchives(val, t);
+              val = t.archives.toString();
+            }
+
+          t.parameters.put(key.toLowerCase(), val);
+        }
+  }
+  
+  /**
+   * Parses the archive string and returns a list.
+   * 
+   * @param the list of archives (comma-separated) in a String.
+   */
+  static ArrayList parseArchives(String arcs, AppletTag t)
+  {
+    try
+      {
+        ArrayList list = new ArrayList();
+
+        StringTokenizer tagTokenizer = new StringTokenizer(arcs, ",");
+        while (tagTokenizer.hasMoreTokens())
+          list.add(t.prependCodeBase(tagTokenizer.nextToken().trim()));
+
+        return list;
+      }
+    catch (MalformedURLException e)
+      {
+      }
+    return null;
+  }
+  
+  /**
+   * Gets the location to the URL, given a location.
+   * 
+   * @param location - the given location.
+   * @return the URL.
+   */
+  static URL getLocationToURL(String location) throws IOException
+  {
+    URL tmpDocumentBase = null;
+
+    try
+      {        
+        // Try parsing location as a URL.
+        tmpDocumentBase = new URL(location);
+        
+        // If no file was specified in the URL the assume the user
+        // meant the root page.
+        String f = tmpDocumentBase.getFile();
+        if (f.indexOf(".") == -1 && !f.endsWith(File.separator))
+          if (new File(tmpDocumentBase.getFile()).isDirectory())
+            tmpDocumentBase = new URL(location.concat(File.separator));
+      }
+    catch (MalformedURLException e)
+      {
+        // location is not a URL.  See if it is an HTML file.
+        String path;
+
+        if (location.startsWith(File.separator))
+          path = new File(location).getCanonicalPath();
+        else
+          path = new File(System.getProperty("user.dir") + File.separator
+                          + location).getCanonicalPath();
+
+        tmpDocumentBase = new URL("file", "", path);
+        
+        if (new File(tmpDocumentBase.getFile()).isDirectory())
+          tmpDocumentBase = new URL("file", "", path + File.separator);
+      }
+    
+    return tmpDocumentBase;
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
new file mode 100644
index 000000000000..e712056ef98f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
@@ -0,0 +1,73 @@
+/* ClasspathToolParser.java -- Parser subclass for classpath tools
+   Copyright (C) 2006 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 gnu.classpath.tools.getopt;
+
+import java.text.MessageFormat;
+
+import gnu.classpath.Configuration;
+
+/**
+ * This is like the Parser class, but is specialized for use by
+ * tools distributed with GNU Classpath.  In particular it automatically
+ * computes the version string using the program's name.
+ */
+public class ClasspathToolParser
+    extends Parser
+{
+  private static String getVersionString(String programName)
+  {
+    String fmt = (Messages.getString("ClasspathToolParser.VersionFormat")); //$NON-NLS-1$
+    return MessageFormat.format(fmt, 
+                                new Object[]
+                                  {
+                                    programName,
+                                    Configuration.CLASSPATH_VERSION
+                                  });
+  }
+
+  public ClasspathToolParser(String programName)
+  {
+    super(programName, getVersionString(programName));
+  }
+
+  public ClasspathToolParser(String programName, boolean longOnly)
+  {
+    super(programName, getVersionString(programName), longOnly);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
new file mode 100644
index 000000000000..455389127fd2
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
@@ -0,0 +1,62 @@
+/* FileArgumentCallback.java - handle non-option command line arguments
+   Copyright (C) 2006 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 gnu.classpath.tools.getopt;
+
+/**
+ * This is a callback class which is used when a "file name" is found by the
+ * command-line parser. A file name is any command-line argument which does not
+ * start with a dash and which is not the argument of some preceding option.
+ */
+public abstract class FileArgumentCallback
+{
+  /**
+   * Create a new instance.
+   */
+  protected FileArgumentCallback()
+  {
+  }
+
+  /**
+   * This is called when a file argument is seen.
+   * 
+   * @param fileArgument the file name
+   */
+  public abstract void notifyFile(String fileArgument)
+    throws OptionException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java
new file mode 100644
index 000000000000..3c963d786b34
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- i18n support for getopt
+ Copyright (C) 2006 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 gnu.classpath.tools.getopt;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+  private static final String BUNDLE_NAME
+    = "gnu.classpath.tools.getopt.Messages"; //$NON-NLS-1$
+
+  private static final ResourceBundle RESOURCE_BUNDLE
+    = ResourceBundle.getBundle(BUNDLE_NAME);
+
+  private Messages()
+  {
+  }
+
+  public static String getString(String key)
+  {
+    try
+      {
+        return RESOURCE_BUNDLE.getString(key);
+      }
+    catch (MissingResourceException e)
+      {
+        return '!' + key + '!';
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java
new file mode 100644
index 000000000000..6f775e4a105a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Option.java
@@ -0,0 +1,200 @@
+/* Option.java - represent a command-line option
+ Copyright (C) 2006 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 gnu.classpath.tools.getopt;
+
+/**
+ * This is the base class representing an option. An option can have a short
+ * form. This is a single character, like '-x'. An option can have a long form,
+ * like '--verbose'; if the parser is working in "long option only" mode, then a
+ * long flag has a single dash, like '-verbose'. Both a long and a short form
+ * may be specified; it is not valid to have neither. A description is mandatory
+ * for options; this is used to automatically generate '--help' output.
+ */
+public abstract class Option
+{
+  private char shortName;
+
+  private String longName;
+
+  private String description;
+
+  private String argumentName;
+
+  /**
+   * Create a new option with the given short name and description.
+   * 
+   * @param shortName the short name
+   * @param description the description
+   */
+  protected Option(char shortName, String description)
+  {
+    this.shortName = shortName;
+    this.description = description;
+  }
+
+  /**
+   * Create a new option with the given short name and description.
+   * 
+   * @param shortName the short name
+   * @param description the description
+   * @param argumentName the descriptive name of the argument, if this option
+   *          takes an argument; otherwise null
+   */
+  protected Option(char shortName, String description, String argumentName)
+  {
+    this.shortName = shortName;
+    this.description = description;
+    this.argumentName = argumentName;
+  }
+
+  /**
+   * Create a new option with the given long name and description. The long name
+   * should be specified without any leading dashes.
+   * 
+   * @param longName the long name
+   * @param description the description
+   */
+  protected Option(String longName, String description)
+  {
+    this.longName = longName;
+    this.description = description;
+  }
+
+  /**
+   * Create a new option with the given long name and description. The long name
+   * should be specified without any leading dashes.
+   * 
+   * @param longName the long name
+   * @param description the description
+   * @param argumentName the descriptive name of the argument, if this option
+   *          takes an argument; otherwise null
+   */
+  protected Option(String longName, String description, String argumentName)
+  {
+    this.longName = longName;
+    this.description = description;
+    this.argumentName = argumentName;
+  }
+
+  /**
+   * Create a new option with the given short and long names and description.
+   * The long name should be specified without any leading dashes.
+   * 
+   * @param longName the long name
+   * @param shortName the short name
+   * @param description the description
+   */
+  protected Option(String longName, char shortName, String description)
+  {
+    this.shortName = shortName;
+    this.longName = longName;
+    this.description = description;
+  }
+
+  /**
+   * Create a new option with the given short and long names and description.
+   * The long name should be specified without any leading dashes.
+   * 
+   * @param longName the long name
+   * @param shortName the short name
+   * @param description the description
+   * @param argumentName the descriptive name of the argument, if this option
+   *          takes an argument; otherwise null
+   */
+  protected Option(String longName, char shortName, String description,
+                   String argumentName)
+  {
+    this.shortName = shortName;
+    this.longName = longName;
+    this.argumentName = argumentName;
+    this.description = description;
+  }
+
+  /**
+   * Return the short name of the option, or \0 if none.
+   */
+  public char getShortName()
+  {
+    return shortName;
+  }
+
+  /**
+   * Return the long name of the option, or null if none.
+   */
+  public String getLongName()
+  {
+    return longName;
+  }
+
+  /**
+   * Return true if the argument takes an option.
+   */
+  public boolean getTakesArgument()
+  {
+    return argumentName != null;
+  }
+
+  /**
+   * Return the name of the argument. If the option does not take an argument,
+   * returns null.
+   */
+  public String getArgumentName()
+  {
+    return argumentName;
+  }
+
+  /**
+   * Return the description of the option.
+   */
+  public String getDescription()
+  {
+    return description;
+  }
+
+  /**
+   * This is called by the parser when this option is recognized. It may be
+   * called multiple times during a single parse. If this option takes an
+   * argument, the argument will be passed in. Otherwise the argument will be
+   * null.
+   * 
+   * @param argument the argument
+   * @throws OptionException if the option or its argument is somehow invalid
+   */
+  public abstract void parsed(String argument) throws OptionException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java
new file mode 100644
index 000000000000..a09d716f4246
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionException.java
@@ -0,0 +1,52 @@
+/* OptionException.java - when command-line processing fails
+ Copyright (C) 2006 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 gnu.classpath.tools.getopt;
+
+/**
+ * An OptionException is thrown internally when an error is seen when parsing a
+ * command line.
+ */
+public class OptionException
+    extends Exception
+{
+  public OptionException(String message)
+  {
+    super(message);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java
new file mode 100644
index 000000000000..f7d966d94599
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/OptionGroup.java
@@ -0,0 +1,271 @@
+/* OptionGroup.java - a group of related command-line options
+ Copyright (C) 2006 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 gnu.classpath.tools.getopt;
+
+import java.io.PrintStream;
+import java.text.BreakIterator;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+
+/**
+ * An option group holds a collection of Options. It also has a name. Option
+ * groups are primarily useful for grouping help output.
+ */
+public class OptionGroup
+{
+  /** An 80-character string of whitespaces to use as a source for padding. */
+  private static final String FILLER = "                                        "
+                                     + "                                        ";
+  private String name;
+
+  ArrayList options = new ArrayList();
+
+  /**
+   * Create a new nameless option group. This can only be used by Parser.
+   */
+  OptionGroup()
+  {
+  }
+
+  /**
+   * Create a new option group with the indicated name.
+   * 
+   * @param name the name
+   */
+  public OptionGroup(String name)
+  {
+    this.name = name;
+  }
+
+  /**
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link Parser#MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the default {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @param leftMargin a positive value indicating the column position of the
+   *          start of the first line. Continuation lines, if they exist, are
+   *          printed starting at <code>leftMargin + 2</code> as per GNU
+   *          convention.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text, int leftMargin)
+  {
+    formatText(out, text, leftMargin, Locale.getDefault());
+  }
+
+  /**
+   * Similar to the method with the same name and three arguments, except that
+   * the caller MUST specify a non-null {@link Locale} instance.
+   * <p>
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link Parser#MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the designated {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @param leftMargin a positive value indicating the column position of the
+   *          start of the first line. Continuation lines, if they exist, are
+   *          printed starting at <code>leftMargin + 2</code> as per GNU
+   *          convention.
+   * @param aLocale the {@link Locale} instance to use when constructing the
+   *          {@link BreakIterator}.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text, int leftMargin,
+                                   Locale aLocale)
+  {
+    BreakIterator bit = BreakIterator.getLineInstance(aLocale);
+    String[] lines = text.split("\n");
+    int length = leftMargin;
+    String leftPadding = FILLER.substring(0, leftMargin + 2);
+    for (int i = 0; i < lines.length; i++)
+      {
+        text = lines[i];
+        bit.setText(text);
+        int start = bit.first();
+        int finish;
+        while ((finish = bit.next()) != BreakIterator.DONE)
+          {
+            String word = text.substring(start, finish);
+            length += word.length();
+            if (length >= Parser.MAX_LINE_LENGTH)
+              {
+                out.println();
+                out.print(leftPadding);
+                length = word.length() + leftMargin + 2;
+              }
+            out.print(word);
+            start = finish;
+          }
+        out.println();
+        if (i != lines.length - 1)
+          {
+            length = leftMargin + 2;
+            out.print(leftPadding);
+          }
+      }
+  }
+
+  /**
+   * Add an option to this option group.
+   * 
+   * @param opt the option to add
+   */
+  public void add(Option opt)
+  {
+    options.add(opt);
+  }
+
+  /**
+   * Print the help output for this option group.
+   * 
+   * @param out the stream to which to print
+   */
+  public void printHelp(PrintStream out, boolean longOnly)
+  {
+    // Compute maximum lengths.
+    int maxArgLen = 0;
+    boolean shortOptionSeen = false;
+    Iterator it;
+
+    // The first pass only looks to see if we have a short option.
+    it = options.iterator();
+    while (it.hasNext())
+      {
+        Option option = (Option) it.next();
+        if (option.getShortName() != '\0')
+          {
+            shortOptionSeen = true;
+            break;
+          }
+      }
+
+    it = options.iterator();
+    while (it.hasNext())
+      {
+        Option option = (Option) it.next();
+        String argName = option.getArgumentName();
+        // First compute the width required for the short
+        // option. "2" is the initial indentation. In the
+        // GNU style we don't print an argument name for
+        // a short option if there is also a long name for
+        // the option.
+        int thisArgLen = 2;
+        if (shortOptionSeen)
+          thisArgLen += 4;
+        if (option.getLongName() != null)
+          {
+            // Handle either '-' or '--'.
+            thisArgLen += 1 + option.getLongName().length();
+            if (! longOnly)
+              ++thisArgLen;
+          }
+        // Add in the width of the argument name.
+        if (argName != null)
+          thisArgLen += 1 + argName.length();
+        maxArgLen = Math.max(maxArgLen, thisArgLen);
+      }
+
+    // Print the help.
+    if (name != null)
+      out.println(name + ":");
+    it = options.iterator();
+    while (it.hasNext())
+      {
+        Option option = (Option) it.next();
+        String argName = option.getArgumentName();
+        int column = 0;
+        if (option.getShortName() != '\0')
+          {
+            out.print("  -");
+            out.print(option.getShortName());
+            column += 4;
+            if (option.getLongName() == null)
+              {
+                if (argName != null)
+                  {
+                    // This is a silly hack just for '-J'.  We don't
+                    // support joined options in general, but this option
+                    // is filtered out before argument processing can see it.
+                    if (option.getShortName() != 'J')
+                      {
+                        out.print(' ');
+                        ++column;
+                      }
+                    out.print(argName);
+                    column += argName.length();
+                  }
+                out.print("  ");
+              }
+            else
+              out.print(", ");
+            column += 2;
+          }
+        // Indent the long option past the short options, if one
+        // was seen.
+        for (; column < (shortOptionSeen ? 6 : 2); ++column)
+          out.print(' ');
+        if (option.getLongName() != null)
+          {
+            out.print(longOnly ? "-" : "--");
+            out.print(option.getLongName());
+            column += (longOnly ? 1 : 2) + option.getLongName().length();
+            if (argName != null)
+              {
+                out.print(" " + argName);
+                column += 1 + argName.length();
+              }
+          }
+        // FIXME: should have a better heuristic for padding.
+        out.print(FILLER.substring(0, maxArgLen + 4 - column));
+        formatText(out, option.getDescription(), maxArgLen + 4);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
new file mode 100644
index 000000000000..082cf89450b9
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/getopt/Parser.java
@@ -0,0 +1,454 @@
+/* Parser.java - parse command line options
+ Copyright (C) 2006 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 gnu.classpath.tools.getopt;
+
+import java.io.PrintStream;
+import java.text.BreakIterator;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+
+/**
+ * An instance of this class is used to parse command-line options. It does "GNU
+ * style" argument recognition and also automatically handles "--help" and
+ * "--version" processing. It can also be put in "long option only" mode. In
+ * this mode long options are recognized with a single dash (as well as a double
+ * dash) and strings of options like "-abc" are never parsed as a collection of
+ * short options.
+ */
+public class Parser
+{
+  /** The maximum right column position. */
+  public static final int MAX_LINE_LENGTH = 80;
+
+  private String programName;
+
+  private String headerText;
+
+  private String footerText;
+
+  private boolean longOnly;
+
+  private ArrayList options = new ArrayList();
+
+  private ArrayList optionGroups = new ArrayList();
+
+  private OptionGroup defaultGroup = new OptionGroup();
+
+  // These are used while parsing.
+  private int currentIndex;
+
+  private String[] args;
+
+  /**
+   * Create a new parser. The program name is used when printing error messages.
+   * The version string is printed verbatim in response to "--version".
+   * 
+   * @param programName the name of the program
+   * @param versionString the program's version information
+   */
+  public Parser(String programName, String versionString)
+  {
+    this(programName, versionString, false);
+  }
+
+  /**
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link #MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the default {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text)
+  {
+    formatText(out, text, Locale.getDefault());
+  }
+
+  /**
+   * Similar to the method with the same name and two arguments, except that the
+   * caller MUST specify a non-null {@link Locale} instance.
+   * <p>
+   * Print a designated text to a {@link PrintStream}, eventually wrapping the
+   * lines of text so as to ensure that the width of each line does not overflow
+   * {@link #MAX_LINE_LENGTH} columns. The line-wrapping is done with a
+   * {@link BreakIterator} using the designated {@link Locale}.
+   * <p>
+   * The text to print may contain <code>\n</code> characters. This method will
+   * force a line-break for each such character.
+   * 
+   * @param out the {@link PrintStream} destination of the formatted text.
+   * @param text the text to print.
+   * @param aLocale the {@link Locale} instance to use when constructing the
+   *          {@link BreakIterator}.
+   * @see Parser#MAX_LINE_LENGTH
+   */
+  protected static void formatText(PrintStream out, String text, Locale aLocale)
+  {
+    BreakIterator bit = BreakIterator.getLineInstance(aLocale);
+    String[] lines = text.split("\n"); //$NON-NLS-1$
+    for (int i = 0; i < lines.length; i++)
+      {
+        text = lines[i];
+        bit.setText(text);
+        int length = 0;
+        int finish;
+        int start = bit.first();
+        while ((finish = bit.next()) != BreakIterator.DONE)
+          {
+            String word = text.substring(start, finish);
+            length += word.length();
+            if (length >= MAX_LINE_LENGTH)
+              {
+                out.println();
+                length = word.length();
+              }
+            out.print(word);
+            start = finish;
+          }
+        out.println();
+      }
+  }
+
+  /**
+   * Create a new parser. The program name is used when printing error messages.
+   * The version string is printed verbatim in response to "--version".
+   * 
+   * @param programName the name of the program
+   * @param versionString the program's version information
+   * @param longOnly true if the parser should work in long-option-only mode
+   */
+  public Parser(String programName, final String versionString, boolean longOnly)
+  {
+    this.programName = programName;
+    this.longOnly = longOnly;
+
+    // Put standard options in their own section near the end.
+    OptionGroup finalGroup = new OptionGroup(Messages.getString("Parser.StdOptions")); //$NON-NLS-1$
+    finalGroup.add(new Option("help", Messages.getString("Parser.PrintHelp")) //$NON-NLS-1$ //$NON-NLS-2$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        printHelp(System.out);
+        System.exit(0);
+      }
+    });
+    finalGroup.add(new Option("version", Messages.getString("Parser.PrintVersion")) //$NON-NLS-1$ //$NON-NLS-2$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        System.out.println(versionString);
+        System.exit(0);
+      }
+    });
+    finalGroup.add(new Option('J', Messages.getString("Parser.JArgument"), Messages.getString("Parser.JName")) //$NON-NLS-1$ //$NON-NLS-2$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        // -J should be handled by the appletviewer wrapper binary.
+        // We add it here so that it shows up in the --help output.
+        // Note that there is a special case for this in OptionGroup.
+      }
+    });
+    add(finalGroup);
+
+    add(defaultGroup);
+  }
+
+  /**
+   * Set the header text that is printed by --help.
+   * 
+   * @param headerText the header text
+   */
+  public void setHeader(String headerText)
+  {
+    this.headerText = headerText;
+  }
+
+  /**
+   * Set the footer text that is printed by --help.
+   * 
+   * @param footerText the footer text
+   */
+  public void setFooter(String footerText)
+  {
+    this.footerText = footerText;
+  }
+
+  /**
+   * Add an option to this parser. The option is added to the default option
+   * group; this affects where it is placed in the help output.
+   * 
+   * @param opt the option
+   */
+  public synchronized void add(Option opt)
+  {
+    options.add(opt);
+    defaultGroup.add(opt);
+  }
+
+  /**
+   * Add an option group to this parser. All the options in this group will be
+   * recognized by the parser.
+   * 
+   * @param group the option group
+   */
+  public synchronized void add(OptionGroup group)
+  {
+    options.addAll(group.options);
+    // This ensures that the final group always appears at the end
+    // of the options.
+    if (optionGroups.isEmpty())
+      optionGroups.add(group);
+    else
+      optionGroups.add(optionGroups.size() - 1, group);
+  }
+
+  public void printHelp()
+  {
+    this.printHelp(System.out);
+  }
+
+  void printHelp(PrintStream out)
+  {
+    if (headerText != null)
+      {
+        formatText(out, headerText);
+        out.println();
+      }
+
+    Iterator it = optionGroups.iterator();
+    while (it.hasNext())
+      {
+        OptionGroup group = (OptionGroup) it.next();
+        // An option group might be empty, in which case we don't
+        // want to print it..
+        if (! group.options.isEmpty())
+          {
+            group.printHelp(out, longOnly);
+            out.println();
+          }
+      }
+
+    if (footerText != null)
+      formatText(out, footerText);
+  }
+
+  /**
+   * This method can be overridden by subclassses to provide some option
+   * validation.  It is called by the parser after all options have been
+   * parsed.  If an option validation problem is encountered, this should
+   * throw an {@link OptionException} whose message should be shown to
+   * the user.
+   * <p>
+   * It is better to do validation here than after {@link #parse(String[])}
+   * returns, because the parser will print a message referring the
+   * user to the <code>--help</code> option.
+   * <p>
+   * The base implementation does nothing.
+   * 
+   * @throws OptionException the error encountered
+   */
+  protected void validate() throws OptionException
+  {
+    // Base implementation does nothing.
+  }
+
+  private String getArgument(String request) throws OptionException
+  {
+    ++currentIndex;
+    if (currentIndex >= args.length)
+      {
+        String message
+          = MessageFormat.format(Messages.getString("Parser.ArgReqd"), //$NON-NLS-1$
+                                 new Object[] { request });
+        throw new OptionException(request);
+      }
+    return args[currentIndex];
+  }
+
+  private void handleLongOption(String real, int index) throws OptionException
+  {
+    String option = real.substring(index);
+    String justName = option;
+    int eq = option.indexOf('=');
+    if (eq != - 1)
+      justName = option.substring(0, eq);
+    Option found = null;
+    for (int i = options.size() - 1; i >= 0; --i)
+      {
+        Option opt = (Option) options.get(i);
+        if (justName.equals(opt.getLongName()))
+          {
+            found = opt;
+            break;
+          }
+      }
+    if (found == null)
+      {
+        String msg = MessageFormat.format(Messages.getString("Parser.Unrecognized"), //$NON-NLS-1$
+                                          new Object[] { real });
+        throw new OptionException(msg);
+      }
+    String argument = null;
+    if (found.getTakesArgument())
+      {
+        if (eq == - 1)
+          argument = getArgument(real);
+        else
+          argument = option.substring(eq + 1);
+      }
+    else if (eq != - 1)
+      {
+        String msg
+          = MessageFormat.format(Messages.getString("Parser.NoArg"), //$NON-NLS-1$
+                                 new Object[] { real.substring(0, eq + index) });
+        throw new OptionException(msg);
+      }
+    found.parsed(argument);
+  }
+
+  private void handleShortOption(char option) throws OptionException
+  {
+    Option found = null;
+    for (int i = options.size() - 1; i >= 0; --i)
+      {
+        Option opt = (Option) options.get(i);
+        if (option == opt.getShortName())
+          {
+            found = opt;
+            break;
+          }
+      }
+    if (found == null)
+      {
+        String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
+                                          new Object[] { "" + option }); //$NON-NLS-1$
+        throw new OptionException(msg);
+      }
+    String argument = null;
+    if (found.getTakesArgument())
+      argument = getArgument("-" + option); //$NON-NLS-1$
+    found.parsed(argument);
+  }
+
+  private void handleShortOptions(String option) throws OptionException
+  {
+    for (int i = 1; i < option.length(); ++i)
+      {
+        handleShortOption(option.charAt(i));
+      }
+  }
+
+  /**
+   * Parse a command line. Any files which are found will be passed to the file
+   * argument callback. This method will exit on error or when --help or
+   * --version is specified.
+   * 
+   * @param inArgs the command-line arguments
+   * @param files the file argument callback
+   */
+  public synchronized void parse(String[] inArgs, FileArgumentCallback files)
+  {
+    try
+      {
+        args = inArgs;
+        for (currentIndex = 0; currentIndex < args.length; ++currentIndex)
+          {
+            if (args[currentIndex].length() == 0
+                || args[currentIndex].charAt(0) != '-'
+                || "-".equals(args[currentIndex])) //$NON-NLS-1$
+              {
+                files.notifyFile(args[currentIndex]);
+                continue;
+              }
+            if ("--".equals(args[currentIndex])) //$NON-NLS-1$
+              break;
+            if (args[currentIndex].charAt(1) == '-')
+              handleLongOption(args[currentIndex], 2);
+            else if (longOnly)
+              handleLongOption(args[currentIndex], 1);
+            else
+              handleShortOptions(args[currentIndex]);
+          }
+        // Add remaining arguments to leftovers.
+        for (++currentIndex; currentIndex < args.length; ++currentIndex)
+          files.notifyFile(args[currentIndex]);
+        // See if something went wrong.
+        validate();
+      }
+    catch (OptionException err)
+      {
+        System.err.println(programName + ": " + err.getMessage()); //$NON-NLS-1$
+        String fmt;
+        if (longOnly)
+          fmt = Messages.getString("Parser.TryHelpShort"); //$NON-NLS-1$
+        else
+          fmt = Messages.getString("Parser.TryHelpLong"); //$NON-NLS-1$
+        String msg = MessageFormat.format(fmt, new Object[] { programName });
+        System.err.println(programName + ": " + msg); //$NON-NLS-1$
+        System.exit(1);
+      }
+  }
+
+  /**
+   * Parse a command line. Any files which are found will be returned. This
+   * method will exit on error or when --help or --version is specified.
+   * 
+   * @param inArgs the command-line arguments
+   */
+  public String[] parse(String[] inArgs)
+  {
+    final ArrayList fileResult = new ArrayList();
+    parse(inArgs, new FileArgumentCallback()
+    {
+      public void notifyFile(String fileArgument)
+      {
+        fileResult.add(fileArgument);
+      }
+    });
+    return (String[]) fileResult.toArray(new String[0]);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java b/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java
index a372cfd66952..c910d7083c7d 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.java
@@ -104,6 +104,17 @@ public class GRMIC
                 else
                   HelpPrinter.printHelpAndExit(HelpPath);
               }
+            else if (c.equals("-classpath"))
+              {
+                int f = i + 1;
+                if (f < args.length)
+                  {
+                    compiler.setClassPath(args[f]);
+                    i++;
+                  }
+                else
+                  HelpPrinter.printHelpAndExit(HelpPath);
+              }
             else if (c.charAt(0) != '-')
             // No more options - start of class list.
               {
@@ -124,17 +135,7 @@ public class GRMIC
             if (args[i].charAt(0) != '-')
               {
                 compiler.reset();
-                Class c = null;
-                try
-                  {
-                    c = Thread.currentThread().getContextClassLoader().loadClass(
-                                                                                 args[i]);
-                  }
-                catch (ClassNotFoundException e)
-                  {
-                    System.err.println(args[i] + " class not found.");
-                    System.exit(1);
-                  }
+                Class c = compiler.loadClass(args[i]);
 
                 compiler.compile(c);
                 String packag = compiler.getPackageName().replace('.', '/');
diff --git a/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt b/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt
index 08aaf148f6e8..875bcdbcf38c 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt
+++ b/libjava/classpath/tools/gnu/classpath/tools/giop/GRMIC.txt
@@ -9,18 +9,20 @@ Please report bugs at http://www.gnu.org/software/classpath/bugs.html
 Usage: grmic <options> <class names>
 
  where <options> includes:
-  -poa          Generate the Servant based ties (default)
-  -impl         Generate the obsoleted ObjectImpl based ties
-                 (for backward compatibility)
-  -nowarn       Show no warnings
-  -nowrite      Do not write any files (check for errors only)
-  -d <folder>   Place generated files into the given folder
+  -poa              Generate the Servant based ties (default)
+  -impl             Generate the obsoleted ObjectImpl based ties
+                      (for backward compatibility)
+  -nowarn            Show no warnings
+  -nowrite           Do not write any files (check for errors only)
+  -d <folder>        Place generated files into the given folder
+  -classpath <path>  Specifies the path, where to find the classes being 
+                     compiled  
   
-  -help         Print this help text
-  -v            Print version
-  -verbose      Verbose output
-  -force        Try to generate code even if the input classes seem not
-                consistent with RMI specification. 
+  -help              Print this help text
+  -v                 Print version
+  -verbose           Verbose output
+  -force             Try to generate code even if the input classes seem not
+                     consistent with RMI specification. 
   
   
  and <class names> can include one or more non abstract classes that implement
diff --git a/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java b/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
index 4beba1c9fd7f..6d895a14cd35 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
@@ -23,7 +23,11 @@ package gnu.classpath.tools.giop.grmic;
 
 import gnu.classpath.tools.AbstractMethodGenerator;
 
+import java.io.File;
 import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 import java.util.ArrayList;
@@ -33,6 +37,7 @@ import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Properties;
+import java.util.StringTokenizer;
 import java.util.TreeSet;
 
 /**
@@ -104,6 +109,11 @@ public class GiopRmicCompiler
    * Force mode - do not check the exceptions
    */
   protected boolean force = false;
+  
+  /**
+   * The class loader to load the class being compiled.
+   */
+  ClassLoader classLoader;
 
   /**
    * Clear data, preparing for the next compilation.
@@ -116,6 +126,78 @@ public class GiopRmicCompiler
     methods.clear();
     vars.clear();
   }
+  
+  /**
+   * Set the class path (handle the -classpath key)
+   * 
+   * @param classPath the class path to set.
+   */
+  public void setClassPath(String classPath)
+  {
+    classLoader = Thread.currentThread().getContextClassLoader();
+    StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator,
+                                              true);
+    ArrayList urls = new ArrayList(tok.countTokens());
+    String s = null;
+    try
+      {
+        while (tok.hasMoreTokens())
+          {
+            s = tok.nextToken();
+            if (s.equals(File.pathSeparator))
+              urls.add(new File(".").toURL());
+            else
+              {
+                urls.add(new File(s).toURL());
+                if (tok.hasMoreTokens())
+                  {
+                    // Skip the separator.
+                    tok.nextToken();
+                    // If the classpath ended with a separator,
+                    // append the current directory.
+                    if (! tok.hasMoreTokens())
+                      urls.add(new File(".").toURL());
+                  }
+              }
+          }
+      }
+    catch (MalformedURLException ex)
+      {
+        System.err.println("Malformed path '" + s + "' in classpath '"
+                           + classPath + "'");
+        System.exit(1);
+      }
+    URL[] u = new URL[urls.size()];
+    for (int i = 0; i < u.length; i++)
+      {
+        u[i] = (URL) urls.get(i);
+      }
+
+    classLoader = new URLClassLoader(u, classLoader);
+  }    
+  
+  /**
+   * Loads the class with the given name (uses class path, if applicable)
+   * 
+   * @param name the name of the class.
+   */
+  public Class loadClass(String name)
+  {
+    ClassLoader loader = classLoader;
+    if (loader == null)
+      loader = Thread.currentThread().getContextClassLoader();
+    try
+      {
+        return loader.loadClass(name);
+      }
+    catch (ClassNotFoundException e)
+      {
+        System.err.println(name+" not found on "+loader);
+        System.exit(1);
+        // Unreacheable code.
+        return null;
+      }
+  }
 
   /**
    * Compile the given class (the instance of Remote), generating the stub and
@@ -193,12 +275,12 @@ public class GiopRmicCompiler
                     remEx = true;
                     break;
                   }
-                if (! remEx && !force)
-                  throw new CompilationError(m[i].getName() + ", defined in "
-                                             + c.getName()
-                                             + ", does not throw "
-                                             + RemoteException.class.getName());
-              }
+	      }
+	    if (! remEx && !force)
+	      throw new CompilationError(m[i].getName() + ", defined in "
+					 + c.getName()
+					 + ", does not throw "
+					 + RemoteException.class.getName());
             AbstractMethodGenerator mm = createMethodGenerator(m[i]);
             methods.add(mm);
           }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java
new file mode 100644
index 000000000000..6363157ae8fc
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Action.java
@@ -0,0 +1,51 @@
+/* Action.java - an action taken by the jar driver
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.io.IOException;
+
+public abstract class Action
+{
+  protected Action()
+  {
+  }
+
+  public abstract void run(Main parameters)
+    throws IOException;
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java
new file mode 100644
index 000000000000..55159660d460
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java
@@ -0,0 +1,247 @@
+/* Creator.java - create a new jar file
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+
+public class Creator
+    extends Action
+{
+  JarOutputStream outputStream;
+  HashSet writtenItems = new HashSet();
+  // The manifest to use, or null if we don't want a manifest.
+  Manifest manifest;
+
+  private long copyFile(CRC32 crc, InputStream is, OutputStream output)
+      throws IOException
+  {
+    byte[] buffer = new byte[1024];
+    long size = 0;
+    while (true)
+      {
+        int len = is.read(buffer);
+        if (len == - 1)
+          break;
+        size += len;
+        output.write(buffer, 0, len);
+        crc.update(buffer, 0, len);
+      }
+    output.close();
+    return size;
+  }
+
+  protected void writeFile(boolean isDirectory, InputStream inputFile,
+                           String filename, boolean verbose)
+    throws IOException
+  {
+    if (writtenItems.contains(filename))
+      {
+        if (verbose)
+          {
+            String msg = MessageFormat.format(Messages.getString("Creator.Ignoring"), //$NON-NLS-1$
+                                              new Object[] { filename });
+            System.err.println(msg);
+          }
+        return;
+      }
+
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    CRC32 crc = new CRC32();
+    long size;
+    if (isDirectory)
+      {
+        size = 0;
+      }
+    else
+      {
+        size = copyFile(crc, inputFile, out);
+      }
+
+    ZipEntry entry = new ZipEntry(filename);
+    entry.setCrc(crc.getValue());
+    entry.setSize(size);
+
+    outputStream.putNextEntry(entry);
+    out.writeTo(outputStream);
+    outputStream.closeEntry();
+    writtenItems.add(filename);
+
+    if (verbose)
+      {
+        long csize = entry.getCompressedSize();
+        long perc;
+        if (size == 0)
+          perc = 0;
+        else
+          perc = 100 - (100 * csize) / size;
+        String msg = MessageFormat.format(Messages.getString("Creator.Adding"), //$NON-NLS-1$
+                                          new Object[]
+                                            {
+                                              filename,
+                                              Long.valueOf(size),
+                                              Long.valueOf(entry.getSize()),
+                                              Long.valueOf(perc)
+                                            });
+        System.err.println(msg);
+      }
+  }
+
+  protected void writeFile(File file, String filename, boolean verbose)
+      throws IOException
+  {
+    boolean isDirectory = file.isDirectory();
+    InputStream inputStream = null;
+    if (isDirectory)
+      {
+        if (filename.charAt(filename.length() - 1) != '/')
+          filename += '/';
+      }
+    else
+      inputStream = new FileInputStream(file);
+    writeFile(isDirectory, inputStream, filename, verbose);
+  }
+
+  private void addEntries(ArrayList result, Entry entry)
+  {
+    if (entry.file.isDirectory())
+      {
+        String name = entry.name;
+        if (name.charAt(name.length() - 1) != '/')
+          {
+            name += '/';
+            entry = new Entry(entry.file, name);
+          }
+        result.add(entry);
+        String[] files = entry.file.list();
+        for (int i = 0; i < files.length; ++i)
+          addEntries(result, new Entry(new File(entry.file, files[i]),
+                                       entry.name + files[i]));
+      }
+    else
+      result.add(entry);
+  }
+
+  private ArrayList getAllEntries(Main parameters)
+  {
+    Iterator it = parameters.entries.iterator();
+    ArrayList allEntries = new ArrayList();
+    while (it.hasNext())
+      {
+        Entry entry = (Entry) it.next();
+        addEntries(allEntries, entry);
+      }
+    return allEntries;
+  }
+
+  private void writeCommandLineEntries(Main parameters)
+      throws IOException
+  {
+    // We've already written the manifest, make sure to mark it.
+    writtenItems.add("META-INF/"); //$NON-NLS-1$
+    writtenItems.add(JarFile.MANIFEST_NAME);
+
+    ArrayList allEntries = getAllEntries(parameters);
+    Iterator it = allEntries.iterator();
+    while (it.hasNext())
+      {
+        Entry entry = (Entry) it.next();
+        writeFile(entry.file, entry.name, parameters.verbose);
+      }
+  }
+
+  protected Manifest createManifest(Main parameters)
+    throws IOException
+  {
+    if (! parameters.wantManifest)
+      return null;
+    if (parameters.manifestFile != null)
+      {
+        // User specified a manifest file.
+        InputStream contents = new FileInputStream(parameters.manifestFile);
+        return new Manifest(contents);
+      }
+    return new Manifest();
+  }
+
+  protected void writeCommandLineEntries(Main parameters, OutputStream os)
+    throws IOException
+  {
+    manifest = createManifest(parameters);
+    outputStream = new JarOutputStream(os, manifest);
+    // FIXME: in Classpath this sets the method too late for the
+    // manifest file.
+    outputStream.setMethod(parameters.storageMode);
+    writeCommandLineEntries(parameters);
+  }
+
+  protected void close() throws IOException
+  {
+    outputStream.finish();
+    outputStream.close();
+  }
+
+  public void run(Main parameters) throws IOException
+  {
+    if (parameters.archiveFile == null || parameters.archiveFile.equals("-")) //$NON-NLS-1$
+      writeCommandLineEntries(parameters, System.out);
+    else
+      {
+        OutputStream os
+          = new BufferedOutputStream(new FileOutputStream(parameters.archiveFile));
+        writeCommandLineEntries(parameters, os);
+      }
+    close();
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java
new file mode 100644
index 000000000000..aa8679aab55c
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Entry.java
@@ -0,0 +1,60 @@
+/* Entry.java - represent a single file to write to a jar
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.io.File;
+
+public class Entry
+{
+  public File file;
+
+  public String name;
+
+  public Entry(File file, String name)
+  {
+    this.file = file;
+    this.name = name;
+  }
+
+  public Entry(File file)
+  {
+    this.file = file;
+    this.name = file.toString();
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java
new file mode 100644
index 000000000000..203ff0566850
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Extractor.java
@@ -0,0 +1,127 @@
+/* Extractor.java - action to extract from a jar file
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class Extractor
+    extends Action
+{
+  // This is a set of all the items specified on the command line.
+  private WorkSet allItems;
+
+  private void copyFile(InputStream input, File output) throws IOException
+  {
+    FileOutputStream os = new FileOutputStream(output);
+    byte[] buffer = new byte[1024];
+    while (true)
+      {
+        int len = input.read(buffer);
+        if (len == - 1)
+          break;
+        os.write(buffer, 0, len);
+      }
+    os.close();
+  }
+
+  public void run(Main parameters) throws IOException
+  {
+    // Figure out what we want to extract.
+    allItems = new WorkSet(parameters.entries);
+    // Open the input file.
+    ZipInputStream zis;
+    File zfile = parameters.archiveFile;
+    if (zfile == null || "-".equals(zfile.getName())) //$NON-NLS-1$
+      zis = new ZipInputStream(System.in);
+    else
+      {
+        InputStream ins = new BufferedInputStream(new FileInputStream(zfile));
+        zis = new ZipInputStream(ins);
+      }
+    // Extract stuff.
+    while (true)
+      {
+        ZipEntry entry = zis.getNextEntry();
+        if (entry == null)
+          break;
+        if (! allItems.contains(entry.getName()))
+          continue;
+        File file = new File(entry.getName());
+        if (entry.isDirectory())
+          {
+            if (file.mkdirs())
+              {
+                if (parameters.verbose)
+                  {
+                    String msg
+                      = MessageFormat.format(Messages.getString("Extractor.Created"), //$NON-NLS-1$
+                                             new Object[] { file });
+                    System.err.println(msg);
+                  }
+              }
+            continue;
+          }
+
+        File parent = file.getParentFile();
+        if (parent != null)
+          parent.mkdirs();
+
+        copyFile(zis, file);
+
+        if (parameters.verbose)
+          {
+            String fmt;
+            if (entry.getMethod() == ZipEntry.STORED)
+              fmt = Messages.getString("Extractor.Extracted"); //$NON-NLS-1$
+            else
+              fmt = Messages.getString("Extractor.Inflated"); //$NON-NLS-1$
+            String msg = MessageFormat.format(fmt, new Object[] { file });
+            System.err.println(msg);
+          }
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java
new file mode 100644
index 000000000000..aae25f82166a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Indexer.java
@@ -0,0 +1,144 @@
+/* Indexer.java -- add index.list file to jar
+   Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import gnu.java.net.IndexListParser;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.MessageFormat;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+public class Indexer
+    extends Updater
+{
+  private void indexJarFile(StringBuffer result, File fileName,
+                            boolean verbose)
+    throws IOException
+  {
+    if (verbose)
+      {
+        String msg = MessageFormat.format(Messages.getString("Indexer.Indexing"), //$NON-NLS-1$
+                                          new Object[] { fileName });
+        System.err.println(msg);
+      }
+    JarFile jf = new JarFile(fileName);
+
+    // Index the files in this jar.
+    // The results look a little better if we keep them
+    // in insertion order.
+    LinkedHashSet entries = new LinkedHashSet();
+    Enumeration e = jf.entries();
+    while (e.hasMoreElements())
+      {
+        JarEntry entry = (JarEntry) e.nextElement();
+        String name = entry.getName();
+        if (name.startsWith("META-INF/")) //$NON-NLS-1$
+          continue;
+        int index = name.lastIndexOf('/');
+        if (index != -1)
+          name = name.substring(0, index);
+        entries.add(name);
+      }
+    if (! entries.isEmpty())
+      {
+        result.append(fileName);
+        // Any line ending will do.
+        result.append('\n');
+        Iterator i = entries.iterator();
+        while (i.hasNext())
+          {
+            result.append(i.next());
+            result.append('\n');
+          }
+        // Paragraph break.
+        result.append('\n');
+      }
+
+    // Now read pointed-to jars.
+    Manifest m = jf.getManifest();
+    if (m != null)
+      {
+        File parent = fileName.getParentFile();
+        Attributes attrs = m.getMainAttributes();
+        String jars = attrs.getValue(Attributes.Name.CLASS_PATH);
+        if (jars != null)
+          {
+            StringTokenizer st = new StringTokenizer(jars, " "); //$NON-NLS-1$
+            while (st.hasMoreTokens())
+              {
+                String name = st.nextToken();
+                indexJarFile(result, new File(parent, name), verbose);
+              }
+          }
+      }
+
+    jf.close();
+  }
+
+  protected void writeCommandLineEntries(Main parameters, OutputStream os)
+    throws IOException
+  {
+    // This is a pretty lame design.  We know the super call will
+    // only have side effects and won't actually write anything important.
+    super.writeCommandLineEntries(parameters, os);
+
+    // Now compute our index file and write it.
+    StringBuffer contents = new StringBuffer();
+    indexJarFile(contents, parameters.archiveFile, parameters.verbose);
+    if (contents.length() != 0)
+      {
+        // Insert in reverse order to avoid computing anything.
+        contents.insert(0, "1.0\n\n"); //$NON-NLS-1$
+        contents.insert(0, IndexListParser.JAR_INDEX_VERSION_KEY);
+        ByteArrayInputStream in
+          = new ByteArrayInputStream(contents.toString().getBytes());
+        writeFile(false, in, IndexListParser.JAR_INDEX_FILE, parameters.verbose);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java
new file mode 100644
index 000000000000..98275f789f6f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Lister.java
@@ -0,0 +1,112 @@
+/* Lister.java - action to list contents of a jar file
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class Lister
+    extends Action
+{
+  private WorkSet allItems;
+
+  private long readUntilEnd(InputStream is) throws IOException
+  {
+    byte[] buffer = new byte[5 * 1024];
+    long result = 0;
+    while (true)
+      {
+        int r = is.read(buffer);
+        if (r == -1)
+          break;
+        result += r;
+      }
+    return result;
+  }
+
+  private void listJar(ZipInputStream zis, boolean verbose) throws IOException
+  {
+    MessageFormat format = null;
+    if (verbose)
+      format = new MessageFormat(" {0,date,E M dd HH:mm:ss z yyyy} {1}");
+    while (true)
+      {
+        ZipEntry entry = zis.getNextEntry();
+        if (entry == null)
+          break;
+        if (! allItems.contains(entry.getName()))
+          continue;
+        if (verbose)
+          {
+            // Read the stream; entry.getSize() is unreliable.
+            // (Also, we're just going to read it anyway.)
+            long size = readUntilEnd(zis);
+            // No easy way to right-justify the size using
+            // MessageFormat -- how odd.
+            String s = "     " + size;
+            int index = Math.min(s.length() - 5, 5);
+            System.out.print(s.substring(index));
+            Object[] values = new Object[] { new Date(entry.getTime()),
+                                            entry.getName() };
+            System.out.println(format.format(values));
+          }
+        else
+          System.out.println(entry.getName());
+      }
+  }
+
+  public void run(Main parameters) throws IOException
+  {
+    allItems = new WorkSet(parameters.entries);
+    File file = parameters.archiveFile;
+    ZipInputStream zis;
+    if (file == null || "-".equals(file.getName()))
+      zis = new ZipInputStream(System.in);
+    else
+      zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
+    listJar(zis, parameters.verbose);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java
new file mode 100644
index 000000000000..8ea770bb63f1
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Main.java
@@ -0,0 +1,266 @@
+/* Main.java - jar program main()
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.zip.ZipOutputStream;
+
+public class Main
+{
+  /** The mode of operation. This is the class representing
+   * the action; we make a new instance before using it. It
+   * must be a subclass of Action. 'null' means the mode
+   * has not yet been set.  */
+  Class operationMode;
+
+  /** The archive file name.  */
+  File archiveFile;
+
+  /** The zip storage mode.  */
+  int storageMode = ZipOutputStream.DEFLATED;
+
+  /** True if we should read file names from stdin.  */
+  boolean readNamesFromStdin = false;
+
+  /** True for verbose mode.  */
+  boolean verbose = false;
+
+  /** True if we want a manifest file.  */
+  boolean wantManifest = true;
+
+  /** Name of manifest file to use.  */
+  File manifestFile;
+
+  /** A list of Entry objects, each describing a file to write.  */
+  ArrayList entries = new ArrayList();
+
+  /** Used only while parsing, holds the first argument for -C.  */
+  String changedDirectory;
+
+  void setArchiveFile(String filename) throws OptionException
+  {
+    if (archiveFile != null)
+      {
+        String fmt = MessageFormat.format(Messages.getString("Main.ArchiveAlreadySet"), //$NON-NLS-1$
+                                          new Object[] { archiveFile });
+        throw new OptionException(fmt);
+      }
+    archiveFile = new File(filename);
+  }
+
+  class HandleFile
+      extends FileArgumentCallback
+  {
+    public void notifyFile(String fileArgument)
+    {
+      Entry entry;
+      if (changedDirectory != null)
+        {
+          entry = new Entry(new File(changedDirectory, fileArgument),
+                            fileArgument);
+          changedDirectory = null;
+        }
+      else
+        entry = new Entry(new File(fileArgument));
+      entries.add(entry);
+    }
+  }
+
+  // An option that knows how to set the operation mode.
+  private class ModeOption
+      extends Option
+  {
+    private Class mode;
+
+    public ModeOption(char shortName, String description, Class mode)
+    {
+      super(shortName, description);
+      this.mode = mode;
+    }
+
+    public ModeOption(char shortName, String description, String argName,
+                      Class mode)
+    {
+      super(shortName, description, argName);
+      this.mode = mode;
+    }
+
+    public void parsed(String argument) throws OptionException
+    {
+      if (operationMode != null)
+        throw new OptionException(Messages.getString("Main.ModeAlreaySet")); //$NON-NLS-1$
+      operationMode = mode;
+      // We know this is only the case for -i.
+      if (argument != null)
+        setArchiveFile(argument);
+    }
+  }
+
+  private class JarParser extends ClasspathToolParser
+  {
+    public JarParser(String name)
+    {
+      super(name);
+    }
+
+    protected void validate() throws OptionException
+    {
+      if (operationMode == null)
+        throw new OptionException(Messages.getString("Main.MustSpecify")); //$NON-NLS-1$
+      if (changedDirectory != null)
+        throw new OptionException(Messages.getString("Main.TwoArgsReqd")); //$NON-NLS-1$
+      if (! wantManifest && manifestFile != null)
+        throw new OptionException(Messages.getString("Main.CantHaveBoth")); //$NON-NLS-1$
+      if (operationMode == Indexer.class)
+        {
+          // Some extra validation for -i.
+          if (! entries.isEmpty())
+            throw new OptionException(Messages.getString("Main.NoFilesWithi")); //$NON-NLS-1$
+          if (! wantManifest)
+            throw new OptionException(Messages.getString("Main.NoMAndi")); //$NON-NLS-1$
+          if (manifestFile != null)
+            throw new OptionException(Messages.getString("Main.AnotherNomAndi")); //$NON-NLS-1$
+        }
+    }
+  }
+
+  private Parser initializeParser()
+  {
+    Parser p = new JarParser("jar"); //$NON-NLS-1$
+    p.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+    OptionGroup grp = new OptionGroup(Messages.getString("Main.OpMode")); //$NON-NLS-1$
+    grp.add(new ModeOption('c', Messages.getString("Main.Create"), Creator.class)); //$NON-NLS-1$
+    grp.add(new ModeOption('x', Messages.getString("Main.Extract"), Extractor.class)); //$NON-NLS-1$
+    grp.add(new ModeOption('t', Messages.getString("Main.List"), Lister.class)); //$NON-NLS-1$
+    grp.add(new ModeOption('u', Messages.getString("Main.Update"), Updater.class)); //$NON-NLS-1$
+    // Note that -i works in-place and explicitly requires a file name.
+    grp.add(new ModeOption('i', Messages.getString("Main.Index"), Messages.getString("Main.FileArg"), Indexer.class)); //$NON-NLS-1$ //$NON-NLS-2$
+    p.add(grp);
+
+    grp = new OptionGroup(Messages.getString("Main.OpMods")); //$NON-NLS-1$
+    grp.add(new Option('f', Messages.getString("Main.ArchiveName"), Messages.getString("Main.FileArg2")) //$NON-NLS-1$ //$NON-NLS-2$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        setArchiveFile(argument);
+      }
+    });
+    grp.add(new Option('0', Messages.getString("Main.NoZip")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        storageMode = ZipOutputStream.STORED;
+      }
+    });
+    grp.add(new Option('v', Messages.getString("Main.Verbose")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    grp.add(new Option('M', Messages.getString("Main.NoManifest")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        wantManifest = false;
+      }
+    });
+    grp.add(new Option('m', Messages.getString("Main.ManifestName"), Messages.getString("Main.ManifestArgName")) //$NON-NLS-1$ //$NON-NLS-2$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        manifestFile = new File(argument);
+      }
+    });
+    // -@
+    p.add(grp);
+
+    grp = new OptionGroup(Messages.getString("Main.FileNameGroup")); //$NON-NLS-1$
+    grp.add(new Option('C', Messages.getString("Main.ChangeDir"), //$NON-NLS-1$
+                       Messages.getString("Main.ChangeDirArg")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        changedDirectory = argument;
+      }
+    });
+    p.add(grp);
+
+    return p;
+  }
+
+  private void run(String[] args)
+      throws InstantiationException, IllegalAccessException, IOException
+  {
+    Parser p = initializeParser();
+    // Special hack to emulate old tar-style commands.
+    if (args.length > 0 && args[0].charAt(0) != '-')
+      args[0] = '-' + args[0];
+    p.parse(args, new HandleFile());
+    Action t = (Action) operationMode.newInstance();
+    t.run(this);
+  }
+
+  public static void main(String[] args)
+  {
+    Main jarprogram = new Main();
+    try
+      {
+        jarprogram.run(args);
+      }
+    catch (Exception e)
+      {
+        System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+        e.printStackTrace(System.err);
+        System.exit(1);
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java
new file mode 100644
index 000000000000..ea54bd08faa4
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for jar
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+  private static final String BUNDLE_NAME
+    = "gnu.classpath.tools.jar.messages"; //$NON-NLS-1$
+
+  private static final ResourceBundle RESOURCE_BUNDLE
+    = ResourceBundle.getBundle(BUNDLE_NAME);
+
+  private Messages()
+  {
+  }
+
+  public static String getString(String key)
+  {
+    try
+      {
+        return RESOURCE_BUNDLE.getString(key);
+      }
+    catch (MissingResourceException e)
+      {
+        return '!' + key + '!';
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java b/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java
new file mode 100644
index 000000000000..29586befdf34
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/Updater.java
@@ -0,0 +1,91 @@
+/* Updater.java - action to update a jar file
+ Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+public class Updater
+    extends Creator
+{
+  JarFile inputJar;
+
+  protected Manifest createManifest(Main parameters) throws IOException
+  {
+    Manifest result = inputJar.getManifest();
+    if (result == null)
+      return super.createManifest(parameters);
+    if (parameters.manifestFile != null)
+      result.read(new FileInputStream(parameters.manifestFile));
+    return result;
+  }
+
+  public void run(Main parameters) throws IOException
+  {
+    // Set this early so that createManifest can use it.
+    inputJar = new JarFile(parameters.archiveFile);
+
+    // Write all the new entries to a temporary file.
+    File tmpFile = File.createTempFile("jarcopy", null);
+    OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile));
+    writeCommandLineEntries(parameters, os);
+
+    // Now read the old file and copy extra entries to the new file.
+    Enumeration e = inputJar.entries();
+    while (e.hasMoreElements())
+      {
+        ZipEntry entry = (ZipEntry) e.nextElement();
+        if (writtenItems.contains(entry.getName()))
+          continue;
+        writeFile(entry.isDirectory(), inputJar.getInputStream(entry),
+                  entry.getName(), parameters.verbose);
+      }
+
+    close();
+    tmpFile.renameTo(parameters.archiveFile);
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java b/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java
new file mode 100644
index 000000000000..ff0b487861e7
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jar/WorkSet.java
@@ -0,0 +1,86 @@
+/* WorkSet.java -- Helper to track what files to work on
+   Copyright (C) 2006 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 gnu.classpath.tools.jar;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+
+public class WorkSet
+{
+  private HashSet allItems;
+
+  private void initSet(ArrayList entries)
+  {
+    if (entries == null || entries.isEmpty())
+      return;
+    allItems = new HashSet();
+    Iterator it = entries.iterator();
+    while (it.hasNext())
+      {
+        Entry entry = (Entry) it.next();
+        int len = entry.name.length();
+        while (len > 0 && entry.name.charAt(len - 1) == '/')
+          --len;
+        String name = entry.name.substring(0, len);
+        allItems.add(name);
+      }
+  }
+
+  public WorkSet(ArrayList entries)
+  {
+    initSet(entries);
+  }
+
+  public boolean contains(String filename)
+  {
+    if (allItems == null)
+      return true;
+    while (filename.length() > 0)
+      {
+        if (allItems.contains(filename))
+          return true;
+        int index = filename.lastIndexOf('/');
+        if (index == -1)
+          break;
+        filename = filename.substring(0, index);
+      }
+    return false;
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
index 40bee9fe931d..8d3bc31af0ad 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/JarSigner.java
@@ -141,7 +141,7 @@ public class JarSigner
                       main.isInternalSF());
     log.finer("Created .DSA file"); //$NON-NLS-1$
     if (main.isVerbose())
-      System.out.println(Messages.getString("JarSigner.11") + dsaFileName); //$NON-NLS-1$
+      System.out.println(Messages.getString("JarSigner.8") + dsaFileName); //$NON-NLS-1$
 
     // cleanup
     outSignedJarFile.close();
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
index f460a96cc3a2..6928bce5945b 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Main.java
@@ -39,9 +39,13 @@ exception statement from your version. */
 package gnu.classpath.tools.jarsigner;
 
 import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.HelpPrinter;
 import gnu.classpath.tools.common.CallbackUtil;
 import gnu.classpath.tools.common.ProviderUtil;
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
 import gnu.java.security.OID;
 import gnu.java.security.Registry;
 import gnu.javax.security.auth.callback.ConsoleCallbackHandler;
@@ -61,6 +65,7 @@ import java.security.Security;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateException;
+import java.util.ArrayList;
 import java.util.Locale;
 import java.util.jar.Attributes.Name;
 import java.util.logging.Logger;
@@ -81,8 +86,8 @@ import javax.security.auth.callback.UnsupportedCallbackException;
  */
 public class Main
 {
-  private static final Logger log = Logger.getLogger(Main.class.getName());
-  private static final String HELP_PATH = "jarsigner/jarsigner.txt"; //$NON-NLS-1$
+  protected static final Logger log = Logger.getLogger(Main.class.getName());
+  static final String KEYTOOL_TOOL = "jarsigner"; //$NON-NLS-1$
   private static final Locale EN_US_LOCALE = new Locale("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$
   static final String DIGEST = "SHA1-Digest"; //$NON-NLS-1$
   static final String DIGEST_MANIFEST = "SHA1-Digest-Manifest"; //$NON-NLS-1$
@@ -91,20 +96,20 @@ public class Main
   static final OID DSA_SIGNATURE_OID = new OID(Registry.DSA_OID_STRING);
   static final OID RSA_SIGNATURE_OID = new OID(Registry.RSA_OID_STRING);
 
-  private boolean verify;
-  private String ksURL;
-  private String ksType;
-  private String password;
-  private String ksPassword;
-  private String sigFileName;
-  private String signedJarFileName;
-  private boolean verbose;
-  private boolean certs;
-  private boolean internalSF;
-  private boolean sectionsOnly;
-  private String providerClassName;
-  private String jarFileName;
-  private String alias;
+  protected boolean verify;
+  protected String ksURL;
+  protected String ksType;
+  protected String password;
+  protected String ksPassword;
+  protected String sigFileName;
+  protected String signedJarFileName;
+  protected boolean verbose;
+  protected boolean certs;
+  protected boolean internalSF;
+  protected boolean sectionsOnly;
+  protected String providerClassName;
+  protected String jarFileName;
+  protected String alias;
 
   protected Provider provider;
   private boolean providerInstalled;
@@ -115,6 +120,9 @@ public class Main
   private Certificate[] signerCertificateChain;
   /** The callback handler to use when needing to interact with user. */
   private CallbackHandler handler;
+  /** The command line parser. */
+  private ToolParser cmdLineParser;
+  protected ArrayList fileAndAlias = new ArrayList();;
 
   private Main()
   {
@@ -126,10 +134,12 @@ public class Main
     log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
 
     Main tool = new Main();
+    int result = 1;
     try
       {
         tool.processArgs(args);
         tool.start();
+        result = 0;
       }
     catch (SecurityException x)
       {
@@ -141,11 +151,13 @@ public class Main
         log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
         System.err.println(Messages.getString("Main.9") + x); //$NON-NLS-1$
       }
+    finally
+      {
+        tool.teardown();
+      }
 
-    tool.teardown();
-
-    log.exiting(Main.class.getName(), "main"); //$NON-NLS-1$
-    // System.exit(0);
+    log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
+    System.exit(result);
   }
 
   // helper methods -----------------------------------------------------------
@@ -155,65 +167,15 @@ public class Main
    * preparation for the user desired action.
    * 
    * @param args an array of options (strings).
-   * @throws Exception if an exceptio occurs during the process.
+   * @throws Exception if an exception occurs during the process.
    */
   private void processArgs(String[] args) throws Exception
   {
     log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
 
-    HelpPrinter.checkHelpKey(args, HELP_PATH);
-    if (args == null || args.length == 0)
-      HelpPrinter.printHelpAndExit(HELP_PATH);
-
-    int limit = args.length;
-    log.finest("args.length=" + limit); //$NON-NLS-1$
-    int i = 0;
-    String opt;
-    while (i < limit)
-      {
-        opt = args[i++];
-        log.finest("args[" + (i - 1) + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-verify".equals(opt)) // -verify //$NON-NLS-1$
-          verify = true;
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          ksURL = args[i++];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          ksType = args[i++];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          ksPassword = args[i++];
-        else if ("-keypass".equals(opt)) // -keypass PASSWORD //$NON-NLS-1$
-          password = args[i++];
-        else if ("-sigfile".equals(opt)) // -sigfile NAME //$NON-NLS-1$
-          sigFileName = args[i++];
-        else if ("-signedjar".equals(opt)) // -signedjar FILE_NAME //$NON-NLS-1$
-          signedJarFileName = args[i++];
-        else if ("-verbose".equals(opt)) // -verbose //$NON-NLS-1$
-          verbose = true;
-        else if ("-certs".equals(opt)) // -certs //$NON-NLS-1$
-          certs = true;
-        else if ("-internalsf".equals(opt)) // -internalsf //$NON-NLS-1$
-          internalSF = true;
-        else if ("-sectionsonly".equals(opt)) // -sectionsonly //$NON-NLS-1$
-          sectionsOnly = true;
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          providerClassName = args[i++];
-        else
-          {
-            jarFileName = opt;
-            if (! verify)
-              alias = args[i++];
-
-            break;
-          }
-      }
-
-    if (i < limit) // more options than needed
-      log.fine("Last argument is assumed at index #" + (i - 1) //$NON-NLS-1$
-               + ". Remaining arguments (" + args[i] //$NON-NLS-1$
-               + "...) will be ignored"); //$NON-NLS-1$
+    cmdLineParser = new ToolParser();
+    cmdLineParser.initializeParser();
+    cmdLineParser.parse(args, new ToolParserCallback());
 
     setupCommonParams();
     if (verify)
@@ -319,9 +281,6 @@ public class Main
   {
     log.entering(this.getClass().getName(), "setupCommonParams"); //$NON-NLS-1$
 
-    if (jarFileName == null)
-      HelpPrinter.printHelpAndExit(HELP_PATH);
-
     File jar = new File(jarFileName);
     if (! jar.exists())
       throw new FileNotFoundException(jarFileName);
@@ -429,9 +388,6 @@ public class Main
     InputStream stream = url.openStream();
     store.load(stream, ksPasswordChars);
 
-    if (alias == null)
-      HelpPrinter.printHelpAndExit(HELP_PATH);
-
     if (! store.containsAlias(alias))
       throw new SecurityException(Messages.getFormattedString("Main.6", alias)); //$NON-NLS-1$
 
@@ -564,4 +520,155 @@ public class Main
 
     return handler;
   }
+
+  private class ToolParserCallback
+      extends FileArgumentCallback
+  {
+    public void notifyFile(String fileArgument)
+    {
+      fileAndAlias.add(fileArgument);
+    }
+  }
+
+  private class ToolParser
+      extends ClasspathToolParser
+  {
+    public ToolParser()
+    {
+      super(KEYTOOL_TOOL, true);
+    }
+
+    protected void validate() throws OptionException
+    {
+      if (fileAndAlias.size() < 1)
+        throw new OptionException(Messages.getString("Main.133")); //$NON-NLS-1$
+
+      jarFileName = (String) fileAndAlias.get(0);
+      if (! verify) // must have an ALIAS. use "mykey" if undefined
+        if (fileAndAlias.size() < 2)
+          {
+            log.finer("Missing ALIAS argument. Will use [mykey] instead"); //$NON-NLS-1$
+            alias = "mykey"; //$NON-NLS-1$
+          }
+        else
+          alias = (String) fileAndAlias.get(1);
+    }
+
+    public void initializeParser()
+    {
+      setHeader(Messages.getString("Main.2")); //$NON-NLS-1$
+      setFooter(Messages.getString("Main.1")); //$NON-NLS-1$
+      OptionGroup signGroup = new OptionGroup(Messages.getString("Main.0")); //$NON-NLS-1$
+      signGroup.add(new Option("keystore", //$NON-NLS-1$
+                               Messages.getString("Main.101"), //$NON-NLS-1$
+                               Messages.getString("Main.102")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          ksURL = argument;
+        }
+      });
+      signGroup.add(new Option("storetype", //$NON-NLS-1$
+                               Messages.getString("Main.104"), //$NON-NLS-1$
+                               Messages.getString("Main.105")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          ksType = argument;
+        }
+      });
+      signGroup.add(new Option("storepass", //$NON-NLS-1$
+                               Messages.getString("Main.107"), //$NON-NLS-1$
+                               Messages.getString("Main.108")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          ksPassword = argument;
+        }
+      });
+      signGroup.add(new Option("keypass", //$NON-NLS-1$
+                               Messages.getString("Main.110"), //$NON-NLS-1$
+                               Messages.getString("Main.111")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          password = argument;
+        }
+      });
+      signGroup.add(new Option("sigfile", //$NON-NLS-1$
+                               Messages.getString("Main.113"), //$NON-NLS-1$
+                               Messages.getString("Main.114")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          sigFileName = argument;
+        }
+      });
+      signGroup.add(new Option("signedjar", //$NON-NLS-1$
+                               Messages.getString("Main.116"), //$NON-NLS-1$
+                               Messages.getString("Main.117")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          signedJarFileName = argument;
+        }
+      });
+      add(signGroup);
+
+      OptionGroup verifyGroup = new OptionGroup(Messages.getString("Main.118")); //$NON-NLS-1$
+      verifyGroup.add(new Option("verify", //$NON-NLS-1$
+                                 Messages.getString("Main.120")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          verify = true;
+        }
+      });
+      verifyGroup.add(new Option("certs", //$NON-NLS-1$
+                                 Messages.getString("Main.122")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          certs = true;
+        }
+      });
+      add(verifyGroup);
+
+      OptionGroup commonGroup = new OptionGroup(Messages.getString("Main.123")); //$NON-NLS-1$
+      commonGroup.add(new Option("verbose", //$NON-NLS-1$
+                                 Messages.getString("Main.125")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          verbose = true;
+        }
+      });
+      commonGroup.add(new Option("internalsf", //$NON-NLS-1$
+                                 Messages.getString("Main.127")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          internalSF = true;
+        }
+      });
+      commonGroup.add(new Option("sectionsonly", //$NON-NLS-1$
+                                 Messages.getString("Main.129")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          sectionsOnly = true;
+        }
+      });
+      commonGroup.add(new Option("provider", //$NON-NLS-1$
+                                 Messages.getString("Main.131"), //$NON-NLS-1$
+                                 Messages.getString("Main.132")) //$NON-NLS-1$
+      {
+        public void parsed(String argument) throws OptionException
+        {
+          providerClassName = argument;
+        }
+      });
+      add(commonGroup);
+    }
+  }
 }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
index 2846391153ce..35f461669de3 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/Messages.java
@@ -54,7 +54,7 @@ import java.util.logging.Logger;
 class Messages
 {
   private static final Logger log = Logger.getLogger(Messages.class.getName());
-  private static final String BUNDLE_NAME = "gnu.classpath.tools.jarsigner.MessageBundle"; //$NON-NLS-1$
+  private static final String BUNDLE_NAME = "gnu.classpath.tools.jarsigner.messages";
   private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
   private static final Map CACHED_FORMATS = new HashMap(5);
 
@@ -88,7 +88,7 @@ class Messages
           CACHED_FORMATS.put(key, mf);
       }
 
-    // if the argument is not an array, then build one consisiting of the
+    // if the argument is not an array, then build one consisting of the
     // sole argument before passing it to the format() method
     try
       {
diff --git a/libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html
new file mode 100644
index 000000000000..50574ddb794a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/jarsigner/package.html
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.classpath.tools.jarsigner
+
+Copyright (C) 2006 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. -->
+
+<html>
+<head>
+  <title>GNU Classpath - gnu.classpath.tools.jarsigner</title>
+</head>
+
+<body>
+This package contains the classes that provide an implementation of the
+Security Tool: <code>jarsigner</code>. The behaviour of these classes should
+match that of the same tool provided in the RI version 1.4.2, except for the
+following:
+
+<ul>
+  <li>The RI tool accepts -J<i>javaoption</i> options which it then passes to
+  the underlying JVM.  This is because the RI tool acts as a <i>wrapper</i>
+  around the JVM launcher.
+  <p>
+  This implementation DOES NOT support these options.
+  </li>
+</ul>
+</body>
+</html>
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
index 0c64246e8c99..fc85e6abd153 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/CertReqCmd.java
@@ -38,6 +38,11 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.OID;
 import gnu.java.security.der.BitString;
 import gnu.java.security.der.DER;
@@ -123,7 +128,7 @@ import javax.security.auth.x500.X500Principal;
  *      
  *      <dt>-keypass PASSWORD</dt>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -170,15 +175,16 @@ import javax.security.auth.x500.X500Principal;
 class CertReqCmd extends Command
 {
   private static final Logger log = Logger.getLogger(CertReqCmd.class.getName());
-  private String _alias;
-  private String _sigAlgorithm;
-  private String _certReqFileName;
-  private String _password;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
-  private boolean nullAttributes;
+  private static final String ATTRIBUTES_OPT = "attributes"; //$NON-NLS-1$
+  protected String _alias;
+  protected String _sigAlgorithm;
+  protected String _certReqFileName;
+  protected String _password;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  protected boolean nullAttributes;
 
   // default 0-arguments constructor
 
@@ -246,60 +252,19 @@ class CertReqCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS //$NON-NLS-1$
-          _alias = args[++i];
-        else if ("-sigalg".equals(opt)) // -sigalg ALGORITHM //$NON-NLS-1$
-          _sigAlgorithm = args[++i];
-        else if ("-file".equals(opt)) // -file FILE_NAME //$NON-NLS-1$
-          _certReqFileName = args[++i];
-        else if ("-keypass".equals(opt)) // -keypass PASSWORD //$NON-NLS-1$
-          _password = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else if ("-attributes".equals(opt)) //$NON-NLS-1$
-          nullAttributes = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setOutputStreamParam(_certReqFileName);
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
     setAliasParam(_alias);
     setKeyPasswordNoPrompt(_password);
-//    setSignatureAlgorithm(_sigAlgorithm);
 
     log.finer("-certreq handler will use the following options:"); //$NON-NLS-1$
     log.finer("  -alias=" + alias); //$NON-NLS-1$
     log.finer("  -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
     log.finer("  -file=" + _certReqFileName); //$NON-NLS-1$
-    log.finer("  -keypass=" + _password); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
     log.finer("  -attributes=" + nullAttributes); //$NON-NLS-1$
@@ -346,6 +311,108 @@ class CertReqCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.CERTREQ_CMD, true);
+    result.setHeader(Messages.getString("CertReqCmd.25")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("CertReqCmd.24")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("CertReqCmd.23")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("CertReqCmd.22"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.21")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.SIGALG_OPT,
+                           Messages.getString("CertReqCmd.20"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.19")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _sigAlgorithm = argument;
+      }
+    });
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("CertReqCmd.18"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.17")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _certReqFileName = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("CertReqCmd.16"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("CertReqCmd.14"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.13")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("CertReqCmd.12"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.11")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("CertReqCmd.10"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("CertReqCmd.8"), //$NON-NLS-1$
+                           Messages.getString("CertReqCmd.7")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("CertReqCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    options.add(new Option(ATTRIBUTES_OPT,
+                           Messages.getString("CertReqCmd.5")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        nullAttributes = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   /**
    * @param aliasName
    * @param publicKey
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
index a596146445de..0811074b8c1d 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Command.java
@@ -42,6 +42,7 @@ import gnu.classpath.SystemProperties;
 import gnu.classpath.tools.common.CallbackUtil;
 import gnu.classpath.tools.common.ProviderUtil;
 import gnu.classpath.tools.common.SecurityProviderInfo;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.OID;
 import gnu.java.security.Registry;
 import gnu.java.security.der.BitString;
@@ -167,10 +168,17 @@ abstract class Command
   private int providerNdx = -2;
   /** The callback handler to use when needing to interact with user. */
   private CallbackHandler handler;
+  /** The shutdown hook. */
+  private ShutdownHook shutdownThread;
 
   // Constructor(s) -----------------------------------------------------------
 
-  // default 0-arguments constructor
+  protected Command()
+  {
+    super();
+    shutdownThread = new ShutdownHook();
+    Runtime.getRuntime().addShutdownHook(shutdownThread);
+  }
 
   // Methods ------------------------------------------------------------------
 
@@ -193,14 +201,16 @@ abstract class Command
   public void doCommand() throws Exception
   {
     try
-    {
-      setup();
-      start();
-    }
+      {
+        setup();
+        start();
+      }
     finally
-    {
-      teardown();
-    }
+      {
+        teardown();
+        if (shutdownThread != null)
+          Runtime.getRuntime().removeShutdownHook(shutdownThread);
+      }
   }
 
   /**
@@ -228,11 +238,18 @@ abstract class Command
    * 
    * @param args an array of options for this handler and possibly other
    *          commands and their options.
-   * @param startIndex the index of the first argument in <code>args</code> to
-   *          process.
-   * @return the index of the first unprocessed argument in <code>args</code>.
+   * @return the remaining un-processed <code>args</code>.
    */
-  abstract int processArgs(String[] args, int startIndex);
+  String[] processArgs(String[] args)
+  {
+    log.entering(this.getClass().getName(), "processArgs", args); //$NON-NLS-1$
+
+    Parser cmdOptionsParser = getParser();
+    String[] result = cmdOptionsParser.parse(args);
+
+    log.exiting(this.getClass().getName(), "processArgs", result); //$NON-NLS-1$
+    return result;
+  }
 
   /**
    * Initialize this concrete command handler for later invocation of the
@@ -345,6 +362,12 @@ abstract class Command
 
   // parameter setup and validation methods -----------------------------------
 
+  /**
+   * @return a {@link Parser} that knows how to parse the concrete command's
+   *         options.
+   */
+  abstract Parser getParser();
+
   /**
    * Convenience method to setup the key store given its type, its password, its
    * location and portentially a specialized security provider.
@@ -486,7 +509,6 @@ abstract class Command
         storePasswordChars = pcb.getPassword();
         pcb.clearPassword();
       }
-    log.finest("storePasswordChars = [" + String.valueOf(storePasswordChars)+ "]"); //$NON-NLS-1$ //$NON-NLS-2$
   }
 
   /**
@@ -575,7 +597,7 @@ abstract class Command
     catch (IOException x)
     {
       log.fine("Exception while closing the key store input stream: " + x //$NON-NLS-1$
-                 + ". Ignore"); //$NON-NLS-1$
+               + ". Ignore"); //$NON-NLS-1$
     }
   }
 
@@ -970,7 +992,7 @@ abstract class Command
   protected void saveKeyStore(char[] password) throws IOException,
       KeyStoreException, NoSuchAlgorithmException, CertificateException
   {
-    log.entering(this.getClass().getName(), "saveKeyStore", String.valueOf(password)); //$NON-NLS-1$
+    log.entering(this.getClass().getName(), "saveKeyStore"); //$NON-NLS-1$
 
     URLConnection con = storeURL.openConnection();
     con.setDoOutput(true);
@@ -1144,4 +1166,15 @@ abstract class Command
 
     return handler;
   }
+
+  // Inner class(es) ==========================================================
+
+  private class ShutdownHook
+      extends Thread
+  {
+    public void run()
+    {
+      teardown();
+    }
+  }
 }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
index 968af50f8e99..4c32ee1e6973 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/DeleteCmd.java
@@ -38,6 +38,12 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
 import java.io.IOException;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
@@ -64,7 +70,7 @@ import javax.security.auth.callback.UnsupportedCallbackException;
  *      omitted from the command line.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -106,11 +112,11 @@ import javax.security.auth.callback.UnsupportedCallbackException;
 class DeleteCmd extends Command
 {
   private static final Logger log = Logger.getLogger(DeleteCmd.class.getName());
-  private String _alias;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  protected String _alias;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
 
   // default 0-arguments constructor
 
@@ -148,36 +154,6 @@ class DeleteCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS //$NON-NLS-1$
-          _alias = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
@@ -187,7 +163,6 @@ class DeleteCmd extends Command
     log.finer("  -alias=" + alias); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
@@ -206,6 +181,73 @@ class DeleteCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.DELETE_CMD, true);
+    result.setHeader(Messages.getString("DeleteCmd.18")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("DeleteCmd.17")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("DeleteCmd.16")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("DeleteCmd.15"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.14")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("DeleteCmd.13"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.12")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("DeleteCmd.11"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("DeleteCmd.9"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("DeleteCmd.7"), //$NON-NLS-1$
+                           Messages.getString("DeleteCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("DeleteCmd.5")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   /**
    * Set the alias to delete from the key store.
    * <p>
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
index c1c0d4f83503..46f7acdf013e 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ExportCmd.java
@@ -38,6 +38,11 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.util.Base64;
 
 import java.io.IOException;
@@ -69,7 +74,7 @@ import java.util.logging.Logger;
  *      exported to. If omitted, STDOUT will be used instead.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -119,13 +124,13 @@ import java.util.logging.Logger;
 class ExportCmd extends Command
 {
   private static final Logger log = Logger.getLogger(ExportCmd.class.getName());
-  private String _alias;
-  private String _certFileName;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
-  private boolean rfc;
+  protected String _alias;
+  protected String _certFileName;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  protected boolean rfc;
 
   // default 0-arguments constructor
 
@@ -178,72 +183,37 @@ class ExportCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt);
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS
-          _alias = args[++i];
-        else if ("-file".equals(opt)) // -file FILE_NAME
-          _certFileName = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME
-          _providerClassName = args[++i];
-        else if ("-rfc".equals(opt))
-          rfc = true;
-        else if ("-v".equals(opt))
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setOutputStreamParam(_certFileName);
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
     setAliasParam(_alias);
 
-    log.finer("-export handler will use the following options:");
-    log.finer("  -alias=" + alias);
-    log.finer("  -file=" + _certFileName);
-    log.finer("  -storetype=" + storeType);
-    log.finer("  -keystore=" + storeURL);
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars));
-    log.finer("  -provider=" + provider);
-    log.finer("  -rfc=" + rfc);
-    log.finer("  -v=" + verbose);
+    log.finer("-export handler will use the following options:"); //$NON-NLS-1$
+    log.finer("  -alias=" + alias); //$NON-NLS-1$
+    log.finer("  -file=" + _certFileName); //$NON-NLS-1$
+    log.finer("  -storetype=" + storeType); //$NON-NLS-1$
+    log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
+    log.finer("  -provider=" + provider); //$NON-NLS-1$
+    log.finer("  -rfc=" + rfc); //$NON-NLS-1$
+    log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
 
   void start() throws KeyStoreException, CertificateEncodingException,
       IOException
   {
-    log.entering(this.getClass().getName(), "start");
+    log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
 
     ensureStoreContainsAlias();
     Certificate certificate;
     if (store.isCertificateEntry(alias))
       {
-        log.fine("Alias [" + alias + "] is a trusted certificate");
+        log.finer("Alias [" + alias + "] is a trusted certificate"); //$NON-NLS-1$ //$NON-NLS-2$
         certificate = store.getCertificate(alias);
       }
     else
       {
-        log.fine("Alias [" + alias + "] is a key entry");
+        log.finer("Alias [" + alias + "] is a key entry"); //$NON-NLS-1$ //$NON-NLS-2$
         Certificate[] chain = store.getCertificateChain(alias);
         certificate = chain[0];
       }
@@ -253,14 +223,100 @@ class ExportCmd extends Command
       {
         String encoded = Base64.encode(derBytes, 0, derBytes.length, true);
         PrintWriter pw = new PrintWriter(outStream, true);
-        pw.println("-----BEGIN CERTIFICATE-----");
+        pw.println("-----BEGIN CERTIFICATE-----"); //$NON-NLS-1$
         pw.println(encoded);
-        pw.println("-----END CERTIFICATE-----");
+        pw.println("-----END CERTIFICATE-----"); //$NON-NLS-1$
       }
     else
       outStream.write(derBytes);
 
     // stream is closed in Command.teardown()
-    log.exiting(this.getClass().getName(), "start");
+    log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.EXPORT_CMD, true);
+    result.setHeader(Messages.getString("ExportCmd.17")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("ExportCmd.18")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("ExportCmd.19")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("ExportCmd.20"), //$NON-NLS-1$
+                           Messages.getString("ExportCmd.21")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("ExportCmd.22"), //$NON-NLS-1$
+                           Messages.getString("ExportCmd.23")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _certFileName = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("ExportCmd.24"), //$NON-NLS-1$
+                           Messages.getString("ExportCmd.25")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("ExportCmd.26"), //$NON-NLS-1$
+                           Messages.getString("ExportCmd.27")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("ExportCmd.28"), //$NON-NLS-1$
+                           Messages.getString("ExportCmd.29")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("ExportCmd.30"), //$NON-NLS-1$
+                           Messages.getString("ExportCmd.31")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.RFC_OPT,
+                           Messages.getString("ExportCmd.32")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        rfc = true;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("ExportCmd.33")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
   }
 }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
index 2d92134c240b..6da0f58b6fa2 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
@@ -38,6 +38,11 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.util.Util;
 import gnu.java.security.x509.X500DistinguishedName;
 
@@ -153,7 +158,7 @@ import javax.security.auth.callback.UnsupportedCallbackException;
  *      
  *      <dt>-validity DAY_COUNT</dt>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -198,19 +203,20 @@ class GenKeyCmd extends Command
   /** Default key size in bits. */
   private static final int DEFAULT_KEY_SIZE = 1024;
 
-  private String _alias;
-  private String _keyAlgorithm;
-  private String _keySizeStr;
-  private String _sigAlgorithm;
-  private String _dName;
-  private String _password;
-  private String _validityStr;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  protected String _alias;
+  protected String _keyAlgorithm;
+  protected String _keySizeStr;
+  protected String _sigAlgorithm;
+  protected String _dName;
+  protected String _password;
+  protected String _validityStr;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
   private int keySize;
   private X500DistinguishedName distinguishedName;
+  private Parser cmdOptionsParser;
 
   // default 0-arguments constructor
 
@@ -294,48 +300,6 @@ class GenKeyCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS //$NON-NLS-1$
-          _alias = args[++i];
-        else if ("-keyalg".equals(opt)) // -keyalg ALGORITHM //$NON-NLS-1$
-          _keyAlgorithm = args[++i];
-        else if ("-keysize".equals(opt)) // -keysize KEY_SIZE //$NON-NLS-1$
-          _keySizeStr = args[++i];
-        else if ("-sigalg".equals(opt)) // -sigalg ALGORITHM //$NON-NLS-1$
-          _sigAlgorithm = args[++i];
-        else if ("-dname".equals(opt)) // -dname NAME //$NON-NLS-1$
-          _dName = args[++i];
-        else if ("-keypass".equals(opt)) // -keypass PASSWORD //$NON-NLS-1$
-          _password = args[++i];
-        else if ("-validity".equals(opt)) // -validity DAY_COUNT //$NON-NLS-1$
-          _validityStr = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
@@ -352,11 +316,9 @@ class GenKeyCmd extends Command
     log.finer("  -keysize=" + keySize); //$NON-NLS-1$
     log.finer("  -sigalg=" + signatureAlgorithm.getAlgorithm()); //$NON-NLS-1$
     log.finer("  -dname=" + distinguishedName); //$NON-NLS-1$
-    log.finer("  -keypass=" + String.valueOf(keyPasswordChars)); //$NON-NLS-1$
     log.finer("  -validity=" + validityInDays); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
@@ -368,14 +330,14 @@ class GenKeyCmd extends Command
     log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
 
     // 1. generate a new key-pair
-    log.fine("About to generate key-pair...");
+    log.finer("About to generate key-pair..."); //$NON-NLS-1$
     keyPairGenerator.initialize(keySize);
     KeyPair kp = keyPairGenerator.generateKeyPair();
     PublicKey publicKey = kp.getPublic();
     PrivateKey privateKey = kp.getPrivate();
 
     // 2. generate a self-signed certificate
-    log.fine("About to generate a self-signed certificate...");
+    log.finer("About to generate a self-signed certificate..."); //$NON-NLS-1$
     byte[] derBytes = getSelfSignedCertificate(distinguishedName,
                                                publicKey,
                                                privateKey);
@@ -398,6 +360,127 @@ class GenKeyCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.GENKEY_CMD, true);
+    result.setHeader(Messages.getString("GenKeyCmd.57")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("GenKeyCmd.58")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("GenKeyCmd.59")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("GenKeyCmd.60"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.61")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.KEYALG_OPT,
+                           Messages.getString("GenKeyCmd.62"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.63")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _keyAlgorithm = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSIZE_OPT,
+                           Messages.getString("GenKeyCmd.64"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.65")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _keySizeStr = argument;
+      }
+    });
+    options.add(new Option(Main.SIGALG_OPT,
+                           Messages.getString("GenKeyCmd.66"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.63")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _sigAlgorithm = argument;
+      }
+    });
+    options.add(new Option(Main.DNAME_OPT,
+                           Messages.getString("GenKeyCmd.68"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.69")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _dName = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("GenKeyCmd.70"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.71")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.VALIDITY_OPT,
+                           Messages.getString("GenKeyCmd.72"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.73")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _validityStr = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("GenKeyCmd.74"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.75")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("GenKeyCmd.76"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.77")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("GenKeyCmd.78"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.71")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("GenKeyCmd.80"), //$NON-NLS-1$
+                           Messages.getString("GenKeyCmd.81")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("GenKeyCmd.82")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   /**
    * @param size the desired key size as a string.
    * @throws NumberFormatException if the string does not represent a valid
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
index cb6b6dac2a53..46c5b97692bf 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
@@ -38,6 +38,12 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
 import java.util.logging.Logger;
 
 /**
@@ -55,7 +61,7 @@ import java.util.logging.Logger;
  *      option is omitted, the tool will process STDIN.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -97,11 +103,11 @@ import java.util.logging.Logger;
 class IdentityDBCmd extends Command
 {
   private static final Logger log = Logger.getLogger(IdentityDBCmd.class.getName());
-  private String _idbFileName;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  protected String _idbFileName;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
 
   // default 0-arguments constructor
 
@@ -139,47 +145,85 @@ class IdentityDBCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
+  void setup() throws Exception
   {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt);
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-file".equals(opt)) // -file FILE_NAME
-          _idbFileName = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt))
-          verbose = true;
-        else
-          break;
-      }
+    setInputStreamParam(_idbFileName);
+    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
 
-    return i;
+    log.finer("-identitydb handler will use the following options:"); //$NON-NLS-1$
+    log.finer("  -file=" + _idbFileName); //$NON-NLS-1$
+    log.finer("  -storetype=" + storeType); //$NON-NLS-1$
+    log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
+    log.finer("  -provider=" + provider); //$NON-NLS-1$
+    log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
 
-  void setup() throws Exception
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
   {
-    setInputStreamParam(_idbFileName);
-    setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.IDENTITYDB_CMD, true);
+    result.setHeader(Messages.getString("IdentityDBCmd.7")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("IdentityDBCmd.8")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("IdentityDBCmd.9")); //$NON-NLS-1$
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("IdentityDBCmd.10"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.11")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _idbFileName = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("IdentityDBCmd.12"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.13")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("IdentityDBCmd.14"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.15")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("IdentityDBCmd.16"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.17")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("IdentityDBCmd.18"), //$NON-NLS-1$
+                           Messages.getString("IdentityDBCmd.19")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("IdentityDBCmd.20")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
 
-    log.finer("-identitydb handler will use the following options:");
-    log.finer("  -file=" + _idbFileName);
-    log.finer("  -storetype=" + storeType);
-    log.finer("  -keystore=" + storeURL);
-    log.finer("  -storepass=" + new String(storePasswordChars));
-    log.finer("  -provider=" + provider);
-    log.finer("  -v=" + verbose);
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
   }
 }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
index b5058b581b41..2e01bc0e4f99 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ImportCmd.java
@@ -39,6 +39,11 @@ exception statement from your version. */
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.x509.X509CertPath;
 
 import java.io.FileInputStream;
@@ -47,6 +52,7 @@ import java.security.Key;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
+import java.security.Principal;
 import java.security.PublicKey;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertPathValidator;
@@ -57,11 +63,14 @@ import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 import java.security.cert.PKIXCertPathValidatorResult;
 import java.security.cert.PKIXParameters;
+import java.security.cert.TrustAnchor;
+import java.security.cert.X509Certificate;
 import java.security.interfaces.DSAParams;
 import java.security.interfaces.DSAPublicKey;
 import java.security.interfaces.RSAPublicKey;
 import java.util.Collection;
 import java.util.LinkedList;
+import java.util.ListIterator;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -139,7 +148,7 @@ import javax.security.auth.callback.UnsupportedCallbackException;
  *      should be considered when trying to establish chain-of-trusts.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -181,17 +190,37 @@ import javax.security.auth.callback.UnsupportedCallbackException;
 class ImportCmd extends Command
 {
   private static final Logger log = Logger.getLogger(ImportCmd.class.getName());
-  private String _alias;
-  private String _certFileName;
-  private String _password;
-  private boolean noPrompt;
-  private boolean trustCACerts;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  private static final String GKR = "gkr"; //$NON-NLS-1$
+  private static final String JKS = "jks"; //$NON-NLS-1$
+  private static final String LIB = "lib"; //$NON-NLS-1$
+  private static final String SECURITY = "security"; //$NON-NLS-1$
+  private static final String CACERTS = "cacerts"; //$NON-NLS-1$
+  private static final String CACERTS_GKR = CACERTS + "." + GKR; //$NON-NLS-1$
+  protected String _alias;
+  protected String _certFileName;
+  protected String _password;
+  protected boolean noPrompt;
+  protected boolean trustCACerts;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
   private CertificateFactory x509Factory;
   private boolean imported;
+  /**
+   * Pathname to a GKR-type cacerts file to use when trustCACerts is true. This
+   * is usually a file named "cacerts.gkr" located in lib/security in the folder
+   * specified by the system-property "gnu.classpath.home".
+   */
+  private String gkrCaCertsPathName;
+  /**
+   * Pathname to a JKS-type cacerts file to use when trustCACerts is true. This
+   * is usually a file named "cacerts" located in lib/security in the folder
+   * specified by the system-property "java.home".
+   */
+  private String jksCaCertsPathName;
+  /** Alias self-signed certificate.  used when importing certificate replies. */
+  private X509Certificate selfSignedCertificate;
 
   // default 0-arguments constructor
 
@@ -259,44 +288,6 @@ class ImportCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS //$NON-NLS-1$
-          _alias = args[++i];
-        else if ("-file".equals(opt)) // -file FILE_NAME //$NON-NLS-1$
-          _certFileName = args[++i];
-        else if ("-keypass".equals(opt)) // -keypass PASSWORD //$NON-NLS-1$
-          _password = args[++i];
-        else if ("-noprompt".equals(opt)) //$NON-NLS-1$
-          noPrompt = true;
-        else if ("-trustcacerts".equals(opt)) //$NON-NLS-1$
-          trustCACerts = true;
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setInputStreamParam(_certFileName);
@@ -307,12 +298,10 @@ class ImportCmd extends Command
     log.finer("-import handler will use the following options:"); //$NON-NLS-1$
     log.finer("  -alias=" + alias); //$NON-NLS-1$
     log.finer("  -file=" + _certFileName); //$NON-NLS-1$
-    log.finer("  -keypass=" + _password); //$NON-NLS-1$
     log.finer("  -noprompt=" + noPrompt); //$NON-NLS-1$
     log.finer("  -trustcacerts=" + trustCACerts); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
@@ -323,6 +312,20 @@ class ImportCmd extends Command
   {
     log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
 
+    if (trustCACerts)
+      {
+        String fs = SystemProperties.getProperty("file.separator"); //$NON-NLS-1$
+        String classpathHome = SystemProperties.getProperty("gnu.classpath.home"); //$NON-NLS-1$
+        gkrCaCertsPathName = new StringBuilder(classpathHome).append(fs)
+            .append(LIB).append(fs)
+            .append(SECURITY).append(fs)
+            .append(CACERTS_GKR).toString();
+        String javaHome = SystemProperties.getProperty("java.home"); //$NON-NLS-1$
+        jksCaCertsPathName = new StringBuilder(javaHome).append(fs)
+            .append(LIB).append(fs)
+            .append(SECURITY).append(fs)
+            .append(CACERTS).toString();
+      }
     x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
     // the alias will tell us whether we're dealing with
     // a new trusted certificate or a certificate reply
@@ -339,6 +342,107 @@ class ImportCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.IMPORT_CMD, true);
+    result.setHeader(Messages.getString("ImportCmd.27")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("ImportCmd.26")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("ImportCmd.25")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("ImportCmd.24"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.23")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("ImportCmd.22"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.21")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _certFileName = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("ImportCmd.20"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.19")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option("noprompt", //$NON-NLS-1$
+                           Messages.getString("ImportCmd.18")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        noPrompt = true;
+      }
+    });
+    options.add(new Option("trustcacerts", //$NON-NLS-1$
+                           Messages.getString("ImportCmd.17")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        trustCACerts = true;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("ImportCmd.16"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.15")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("ImportCmd.14"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.13")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("ImportCmd.12"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.11")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("ImportCmd.10"), //$NON-NLS-1$
+                           Messages.getString("ImportCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("ImportCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   /**
    * When importing a new trusted certificate, <i>alias</i> MUST NOT yet exist
    * in the key store.
@@ -542,8 +646,8 @@ class ImportCmd extends Command
     if (chain == null)
       throw new IllegalArgumentException(Messages.getFormattedString("ImportCmd.37", //$NON-NLS-1$
                                                                      alias));
-    Certificate anchor = chain[0];
-    PublicKey anchorPublicKey = anchor.getPublicKey();
+    selfSignedCertificate = (X509Certificate) chain[0];
+    PublicKey anchorPublicKey = selfSignedCertificate.getPublicKey();
     PublicKey certPublicKey = certificate.getPublicKey();
     boolean sameKey;
     if (anchorPublicKey instanceof DSAPublicKey)
@@ -598,17 +702,54 @@ class ImportCmd extends Command
   }
 
   /**
-   * @param chain
+   * Given a collection of certificates returned as a certificate-reply, this
+   * method sorts the certificates in the collection so that the <i>Issuer</i>
+   * of the certificate at position <code>i</code> is the <i>Subject</i> of
+   * the certificate at position <code>i + 1</code>.
+   * <p>
+   * This method uses <code>selfSignedCertificate</code> to discover the first
+   * certificate in the chain. The <i>Trust Anchor</i> of the chain; i.e. the
+   * self-signed CA certificate, if it exsits, will be discovered/established
+   * later by an appropriate <i>Certificate Path Validator</i>.
+   * <p>
+   * An exception is thrown if (a) no initial certificate is found in the
+   * designated collection which can be used as the start of the chain, or (b)
+   * if a chain can not be constructed using all the certificates in the
+   * designated collection.
+   * 
+   * @param chain a collection of certificates, not necessarily ordered, but
+   *          assumed to include a CA certificate authenticating our alias
+   *          public key, which is the subject of the alias self-signed
+   *          certificate.
    * @return the input collection, ordered with own certificate first, and CA's
    *         self-signed certificate last.
    */
   private LinkedList orderChain(Collection chain)
   {
     log.entering(this.getClass().getName(), "orderChain"); //$NON-NLS-1$
-
+    LinkedList in = new LinkedList(chain);
+    int initialCount = in.size();
     LinkedList result = new LinkedList();
-    
-
+    Principal issuer = selfSignedCertificate.getIssuerDN();
+    ListIterator it;
+    outer: while (in.size() > 0)
+      {
+        for (it = in.listIterator(); it.hasNext();)
+          {
+            X509Certificate certificate = (X509Certificate) it.next();
+            if (issuer.equals(certificate.getSubjectDN()))
+              {
+                it.remove();
+                result.addLast(certificate);
+                issuer = certificate.getIssuerDN();
+                continue outer;
+              }
+          }
+        throw new IllegalArgumentException(
+            Messages.getFormattedString(Messages.getString("ImportCmd.7"), //$NON-NLS-1$
+                                        new Object[] { Integer.valueOf(result.size()),
+                                                       Integer.valueOf(initialCount) }));
+      }
     log.entering(this.getClass().getName(), "orderChain", result); //$NON-NLS-1$
     return result;
   }
@@ -646,13 +787,19 @@ class ImportCmd extends Command
       CertificateEncodingException
   {
     log.entering(this.getClass().getName(), "findTrustAndUpdate"); //$NON-NLS-1$
-
-    X509CertPath certPath = new X509CertPath(reply);
     CertPathValidator validator = CertPathValidator.getInstance("PKIX"); //$NON-NLS-1$
+    X509CertPath certPath = new X509CertPath(reply);
     PKIXCertPathValidatorResult cpvr = findTrustInStore(certPath, validator);
-    if (cpvr == null && trustCACerts)
-      cpvr = findTrustInCACerts(certPath, validator);
-
+    if (cpvr == null && trustCACerts) // try cacerts.gkr - a GKR key store
+      {
+        PKIXParameters params = getCertPathParameters(GKR, gkrCaCertsPathName);
+        cpvr = validate(validator, certPath, params);
+        if (cpvr == null) // try cacerts - a JKS key store
+          {
+            params = getCertPathParameters(JKS, jksCaCertsPathName);
+            cpvr = validate(validator, certPath, params);
+          }
+      }
     boolean result = false;
     if (cpvr == null)
       {
@@ -671,12 +818,12 @@ class ImportCmd extends Command
       }
     else
       {
-        log.fine("Found a chain-of-trust anchored by " + cpvr.getTrustAnchor()); //$NON-NLS-1$
-        Certificate trustedCert = cpvr.getTrustAnchor().getTrustedCert();
+        TrustAnchor anchor = cpvr.getTrustAnchor();
+        log.fine("Found a chain-of-trust anchored by " + anchor); //$NON-NLS-1$
+        Certificate trustedCert = anchor.getTrustedCert();
         reply.addLast(trustedCert);
         result = true;
       }
-
     log.entering(this.getClass().getName(), "findTrustAndUpdate", //$NON-NLS-1$
                  Boolean.valueOf(result));
     return result;
@@ -705,33 +852,32 @@ class ImportCmd extends Command
     return result;
   }
 
-  private PKIXCertPathValidatorResult findTrustInCACerts(X509CertPath certPath,
-                                                         CertPathValidator validator)
+  /**
+   * Return an instance of {@link PKIXParameters} constructed using a key store
+   * of the designated type and located at the designated path.
+   * 
+   * @param type the type of the key-store to load.
+   * @param pathName the local File System fully qualified path name to the key
+   *          store.
+   * @return an instance of <code>CertPathParameters</code> to use for
+   *         validating certificates and certificate replies.
+   */
+  private PKIXParameters getCertPathParameters(String type, String pathName)
   {
-    log.entering(this.getClass().getName(), "findTrustInCACerts"); //$NON-NLS-1$
-
+    log.entering(this.getClass().getName(), "getCertPathParameters", //$NON-NLS-1$
+                 new Object[] { type, pathName });
     FileInputStream stream = null;
-    PKIXCertPathValidatorResult result = null;
+    PKIXParameters result = null;
     try
       {
-        KeyStore cacerts = KeyStore.getInstance("jks"); //$NON-NLS-1$
-        String cacertsPath = SystemProperties.getProperty("java.home");
-        String fs = SystemProperties.getProperty("file.separator"); //$NON-NLS-1$
-        cacertsPath = new StringBuilder(cacertsPath).append(fs)
-            .append("lib").append(fs) //$NON-NLS-1$
-            .append("security").append(fs) //$NON-NLS-1$
-            .append("cacerts").toString(); //$NON-NLS-1$
-        stream = new FileInputStream(cacertsPath);
+        KeyStore cacerts = KeyStore.getInstance(type);
+        stream = new FileInputStream(pathName);
         cacerts.load(stream, "changeit".toCharArray()); //$NON-NLS-1$
-        PKIXParameters params = new PKIXParameters(cacerts);
-        result = (PKIXCertPathValidatorResult) validator.validate(certPath,
-                                                                  params);
+        result = new PKIXParameters(cacerts);
       }
     catch (Exception x)
       {
-        log.log(Level.FINE,
-                "Exception in findTrustInCACerts(). Ignore + Return NULL", //$NON-NLS-1$
-                x);
+        log.log(Level.FINE, "Exception in getCertPathParameters(). Ignore", x); //$NON-NLS-1$
       }
     finally
       {
@@ -744,8 +890,27 @@ class ImportCmd extends Command
             {
             }
       }
+    log.exiting(this.getClass().getName(), "getCertPathParameters", result); //$NON-NLS-1$
+    return result;
+  }
 
-    log.exiting(this.getClass().getName(), "findTrustInCACerts", result); //$NON-NLS-1$
+  private PKIXCertPathValidatorResult validate(CertPathValidator validator,
+                                               X509CertPath certPath,
+                                               PKIXParameters params)
+  {
+    log.entering(this.getClass().getName(), "validate"); //$NON-NLS-1$
+    PKIXCertPathValidatorResult result = null;
+    if (params != null)
+      try
+        {
+          result = (PKIXCertPathValidatorResult) validator.validate(certPath,
+                                                                    params);
+        }
+      catch (Exception x)
+        {
+          log.log(Level.FINE, "Exception in validate(). Ignore", x); //$NON-NLS-1$
+        }
+    log.exiting(this.getClass().getName(), "validate", result); //$NON-NLS-1$
     return result;
   }
 }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
index 5936719f7eba..61a8eb880f35 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
@@ -38,6 +38,12 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
 import java.io.IOException;
 import java.security.Key;
 import java.security.KeyStoreException;
@@ -90,7 +96,7 @@ import javax.security.auth.callback.UnsupportedCallbackException;
  *      material of the newly cloned copy of the <i>Key Entry</i>.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -132,14 +138,14 @@ import javax.security.auth.callback.UnsupportedCallbackException;
 class KeyCloneCmd extends Command
 {
   private static final Logger log = Logger.getLogger(KeyCloneCmd.class.getName());
-  private String _alias;
-  private String _destAlias;
-  private String _password;
-  private String _newPassword;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  protected String _alias;
+  protected String _destAlias;
+  protected String _password;
+  protected String _newPassword;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
   private String destinationAlias;
   private char[] newKeyPasswordChars;
 
@@ -197,58 +203,18 @@ class KeyCloneCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS //$NON-NLS-1$
-          _alias = args[++i];
-        else if ("-dest".equals(opt)) // -dest ALIAS //$NON-NLS-1$
-          _destAlias = args[++i];
-        else if ("-keypass".equals(opt)) // -keypass PASSWORD //$NON-NLS-1$
-          _password = args[++i];
-        else if ("-new".equals(opt)) // -new PASSWORD //$NON-NLS-1$
-          _newPassword = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
     setAliasParam(_alias);
     setKeyPasswordNoPrompt(_password);
     setDestinationAlias(_destAlias);
-//    setNewKeyPassword(_newPassword);
 
     log.finer("-keyclone handler will use the following options:"); //$NON-NLS-1$
     log.finer("  -alias=" + alias); //$NON-NLS-1$
     log.finer("  -dest=" + destinationAlias); //$NON-NLS-1$
-    log.finer("  -keypass=" + _password); //$NON-NLS-1$
-    log.finer("  -new=" + _newPassword); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
@@ -276,6 +242,100 @@ class KeyCloneCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.KEYCLONE_CMD, true);
+    result.setHeader(Messages.getString("KeyCloneCmd.22")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("KeyCloneCmd.21")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("KeyCloneCmd.20")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("KeyCloneCmd.19"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.16")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.DEST_OPT,
+                           Messages.getString("KeyCloneCmd.17"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.16")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _destAlias = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("KeyCloneCmd.15"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.NEW_OPT,
+                           Messages.getString("KeyCloneCmd.13"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _newPassword = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("KeyCloneCmd.11"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("KeyCloneCmd.9"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("KeyCloneCmd.7"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("KeyCloneCmd.5"), //$NON-NLS-1$
+                           Messages.getString("KeyCloneCmd.4")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("KeyCloneCmd.3")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   private void setDestinationAlias(String name) throws IOException,
       UnsupportedCallbackException
   {
@@ -294,9 +354,9 @@ class KeyCloneCmd extends Command
   private void setNewKeyPassword(String password) throws IOException,
       UnsupportedCallbackException
   {
-    if (password != null) // ask user to provide one
+    if (password != null)
       newKeyPasswordChars = password.toCharArray();
-    else
+    else // ask user to provide one
       {
         boolean ok = false;
         Callback[] prompts = new Callback[1];
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
index 9dc7b8164c76..83beb161b069 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
@@ -39,6 +39,11 @@ exception statement from your version. */
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 
 import java.io.IOException;
 import java.security.Key;
@@ -86,7 +91,7 @@ import javax.security.auth.callback.UnsupportedCallbackException;
  *      private key material of the designated Key Entry.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -128,13 +133,13 @@ import javax.security.auth.callback.UnsupportedCallbackException;
 class KeyPasswdCmd extends Command
 {
   private static final Logger log = Logger.getLogger(KeyPasswdCmd.class.getName());
-  private String _alias;
-  private String _password;
-  private String _newPassword;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  protected String _alias;
+  protected String _password;
+  protected String _newPassword;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
   private char[] newPasswordChars;
 
   // default 0-arguments constructor
@@ -185,54 +190,17 @@ class KeyPasswdCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS //$NON-NLS-1$
-          _alias = args[++i];
-        else if ("-keypass".equals(opt)) // -keypass PASSWORD //$NON-NLS-1$
-          _password = args[++i];
-        else if ("-new".equals(opt)) // -new PASSWORD //$NON-NLS-1$
-          _newPassword = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
     setAliasParam(_alias);
     setKeyPasswordNoPrompt(_password);
-//    setNewKeyPassword(_newPassword);
 
     log.finer("-keypasswd handler will use the following options:"); //$NON-NLS-1$
     log.finer("  -alias=" + alias); //$NON-NLS-1$
-    log.finer("  -keypass=" + _password); //$NON-NLS-1$
     log.finer("  -new=" + _newPassword); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
@@ -259,6 +227,91 @@ class KeyPasswdCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.KEYPASSWD_CMD, true);
+    result.setHeader(Messages.getString("KeyPasswdCmd.23")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("KeyPasswdCmd.22")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("KeyPasswdCmd.21")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("KeyPasswdCmd.20"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.19")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("KeyPasswdCmd.18"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.NEW_OPT,
+                           Messages.getString("KeyPasswdCmd.16"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _newPassword = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("KeyPasswdCmd.14"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.13")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("KeyPasswdCmd.12"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.11")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("KeyPasswdCmd.10"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("KeyPasswdCmd.8"), //$NON-NLS-1$
+                           Messages.getString("KeyPasswdCmd.7")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("KeyPasswdCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   /**
    * Set the new password to use for protecting Alias's private key.
    * 
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
index 655242785342..99fcfa2cf9a5 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/ListCmd.java
@@ -38,6 +38,11 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.util.Base64;
 
 import java.io.IOException;
@@ -64,7 +69,7 @@ import java.util.logging.Logger;
  *      omitted from the command line.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -113,12 +118,12 @@ import java.util.logging.Logger;
 class ListCmd extends Command
 {
   private static final Logger log = Logger.getLogger(ListCmd.class.getName());
-  private String _alias;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
-  private boolean rfc;
+  protected String _alias;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
+  protected boolean rfc;
   private boolean all;
 
   // default 0-arguments constructor
@@ -166,44 +171,11 @@ class ListCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS //$NON-NLS-1$
-          _alias = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else if ("-rfc".equals(opt)) //$NON-NLS-1$
-          rfc = true;
-        else
-          break;
-      }
-
-    all = _alias == null;
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setOutputStreamParam(null); // use stdout
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
+    all = _alias == null;
     if (! all)
       setAliasParam(_alias);
 
@@ -218,7 +190,6 @@ class ListCmd extends Command
     log.finer("  -alias=" + alias); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
     log.finer("  -rfc=" + rfc); //$NON-NLS-1$
@@ -254,6 +225,81 @@ class ListCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.LIST_CMD, true);
+    result.setHeader(Messages.getString("ListCmd.20")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("ListCmd.19")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("ListCmd.18")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("ListCmd.17"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.16")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("ListCmd.15"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.14")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("ListCmd.13"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.12")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("ListCmd.11"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("ListCmd.9"), //$NON-NLS-1$
+                           Messages.getString("ListCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("ListCmd.7")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    options.add(new Option(Main.RFC_OPT,
+                           Messages.getString("ListCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        rfc = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   /**
    * Prints the certificate(s) associated with the designated alias.
    * 
@@ -312,7 +358,7 @@ class ListCmd extends Command
   private void print1Chain(Certificate[] chain, PrintWriter writer)
       throws CertificateEncodingException
   {
-    if (!verbose && !rfc)
+    if (! verbose && ! rfc)
       fingerprint(chain[0], writer);
     else
       {
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
index fb7aa4509da8..582aba082287 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Main.java
@@ -38,8 +38,12 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
-import gnu.classpath.tools.HelpPrinter;
 import gnu.classpath.tools.common.ProviderUtil;
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.Registry;
 import gnu.javax.crypto.jce.GnuCrypto;
 import gnu.javax.security.auth.callback.GnuCallbacks;
@@ -57,8 +61,51 @@ import java.util.logging.Logger;
 public class Main
 {
   private static final Logger log = Logger.getLogger(Main.class.getName());
-  /** The relative file path to the command tool's help text. */
-  private static final String HELP_PATH = "keytool/keytool.txt"; //$NON-NLS-1$
+  static final String KEYTOOL_TOOL = "keytool"; //$NON-NLS-1$
+  static final String GENKEY_CMD = "genkey"; //$NON-NLS-1$
+  static final String IMPORT_CMD = "import"; //$NON-NLS-1$
+  static final String SELFCERT_CMD = "selfcert"; //$NON-NLS-1$
+  static final String IDENTITYDB_CMD = "identitydb"; //$NON-NLS-1$
+  static final String CERTREQ_CMD = "certreq"; //$NON-NLS-1$
+  static final String EXPORT_CMD = "export"; //$NON-NLS-1$
+  static final String LIST_CMD = "list"; //$NON-NLS-1$
+  static final String PRINTCERT_CMD = "printcert"; //$NON-NLS-1$
+  static final String KEYCLONE_CMD = "keyclone"; //$NON-NLS-1$
+  static final String STOREPASSWD_CMD = "storepasswd"; //$NON-NLS-1$
+  static final String KEYPASSWD_CMD = "keypasswd"; //$NON-NLS-1$
+  static final String DELETE_CMD = "delete"; //$NON-NLS-1$
+
+  static final String _GENKEY = "-" + GENKEY_CMD; //$NON-NLS-1$
+  static final String _IMPORT = "-" + IMPORT_CMD; //$NON-NLS-1$
+  static final String _SELFCERT = "-" + SELFCERT_CMD; //$NON-NLS-1$
+  static final String _IDENTITYDB = "-" + IDENTITYDB_CMD; //$NON-NLS-1$
+  static final String _CERTREQ = "-" + CERTREQ_CMD; //$NON-NLS-1$
+  static final String _EXPORT = "-" + EXPORT_CMD; //$NON-NLS-1$
+  static final String _LIST = "-" + LIST_CMD; //$NON-NLS-1$
+  static final String _PRINTCERT = "-" + PRINTCERT_CMD; //$NON-NLS-1$
+  static final String _KEYCLONE = "-" + KEYCLONE_CMD; //$NON-NLS-1$
+  static final String _STOREPASSWD = "-" + STOREPASSWD_CMD; //$NON-NLS-1$
+  static final String _KEYPASSWD = "-" + KEYPASSWD_CMD; //$NON-NLS-1$
+  static final String _DELETE = "-" + DELETE_CMD; //$NON-NLS-1$
+  static final String _HELP = "-help"; //$NON-NLS-1$
+
+  static final String ALIAS_OPT = "alias"; //$NON-NLS-1$
+  static final String SIGALG_OPT = "sigalg"; //$NON-NLS-1$
+  static final String KEYALG_OPT = "keyalg"; //$NON-NLS-1$
+  static final String KEYSIZE_OPT = "keysize"; //$NON-NLS-1$
+  static final String KEYPASS_OPT = "keypass"; //$NON-NLS-1$
+  static final String VALIDITY_OPT = "validity"; //$NON-NLS-1$
+  static final String STORETYPE_OPT = "storetype"; //$NON-NLS-1$
+  static final String STOREPASS_OPT = "storepass"; //$NON-NLS-1$
+  static final String KEYSTORE_OPT = "keystore"; //$NON-NLS-1$
+  static final String PROVIDER_OPT = "provider"; //$NON-NLS-1$
+  static final String FILE_OPT = "file"; //$NON-NLS-1$
+  static final String VERBOSE_OPT = "v"; //$NON-NLS-1$
+  static final String DEST_OPT = "dest"; //$NON-NLS-1$
+  static final String NEW_OPT = "new"; //$NON-NLS-1$
+  static final String RFC_OPT = "rfc"; //$NON-NLS-1$
+  static final String DNAME_OPT = "dname"; //$NON-NLS-1$
+
   /** The Preferences key name for the last issued certificate serial nbr. */
   static final String LAST_SERIAL_NUMBER = "lastSerialNumber"; //$NON-NLS-1$
   /** Constant denoting the X.509 certificate type. */
@@ -70,6 +117,8 @@ public class Main
   private int gnuCryptoProviderNdx = -2;
   /** The new position of GNU Callbacks provider if it is not already installed. */
   private int gnuCallbacksNdx = -2;
+  /** The command line parser. */
+  private Parser cmdLineParser;
 
   private Main()
   {
@@ -81,117 +130,140 @@ public class Main
     log.entering(Main.class.getName(), "main", args); //$NON-NLS-1$
 
     Main tool = new Main();
+    int result = 1;
     try
       {
         tool.setup();
         tool.start(args);
+        result = 0;
+      }
+    catch (OptionException x)
+      {
+        System.err.println(x.getMessage());
+        if (tool.cmdLineParser != null)
+          tool.cmdLineParser.printHelp();
       }
     catch (SecurityException x)
       {
         log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
-        System.err.println(Messages.getString("Main.6") + x.getMessage()); //$NON-NLS-1$
+        System.err.println(Messages.getFormattedString("Main.6", //$NON-NLS-1$
+                                                       x.getMessage()));
       }
     catch (Exception x)
       {
         log.throwing(Main.class.getName(), "main", x); //$NON-NLS-1$
-        System.err.println(Messages.getString("Main.8") + x); //$NON-NLS-1$
+        System.err.println(Messages.getFormattedString("Main.8", x)); //$NON-NLS-1$
       }
     finally
-    {
-      tool.teardown();
-    }
+      {
+        tool.teardown();
+      }
 
-    log.exiting(Main.class.getName(), "main"); //$NON-NLS-1$
-    // System.exit(0);
+    log.exiting(Main.class.getName(), "main", Integer.valueOf(result)); //$NON-NLS-1$
+    System.exit(result);
   }
 
   // helper methods -----------------------------------------------------------
 
+  private void setup()
+  {
+    log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$
+
+    cmdLineParser = getParser();
+    gnuCryptoProviderNdx = ProviderUtil.addProvider(new GnuCrypto());
+    gnuCallbacksNdx = ProviderUtil.addProvider(new GnuCallbacks());
+
+    log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$
+  }
+
   private void start(String[] args) throws Exception
   {
-    log.entering(this.getClass().getName(), "start", args); //$NON-NLS-1$
+    log.entering(this.getClass().getName(), "start"); //$NON-NLS-1$
 
-    if (args == null)
-      args = new String[0];
+    if (args == null || args.length == 0)
+      throw new OptionException(""); //$NON-NLS-1$
 
-    int limit = args.length;
-    log.finest("args.length=" + limit); //$NON-NLS-1$
-    int i = 0;
     String opt;
     Command cmd;
-    while (i < limit)
+    while (args.length > 0)
       {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
+        opt = args[0];
         cmd = null;
-        if ("-genkey".equals(opt)) //$NON-NLS-1$
+        if (_GENKEY.equals(opt))
           cmd = new GenKeyCmd();
-        else if ("-import".equals(opt)) //$NON-NLS-1$
+        else if (_IMPORT.equals(opt))
           cmd = new ImportCmd();
-        else if ("-selfcert".equals(opt)) //$NON-NLS-1$
+        else if (_SELFCERT.equals(opt))
           cmd = new SelfCertCmd();
-        else if ("-identitydb".equals(opt)) //$NON-NLS-1$
+        else if (_IDENTITYDB.equals(opt))
           cmd = new IdentityDBCmd();
-        else if ("-certreq".equals(opt)) //$NON-NLS-1$
+        else if (_CERTREQ.equals(opt))
           cmd = new CertReqCmd();
-        else if ("-export".equals(opt)) //$NON-NLS-1$
+        else if (_EXPORT.equals(opt))
           cmd = new ExportCmd();
-        else if ("-list".equals(opt)) //$NON-NLS-1$
+        else if (_LIST.equals(opt))
           cmd = new ListCmd();
-        else if ("-printcert".equals(opt)) //$NON-NLS-1$
+        else if (_PRINTCERT.equals(opt))
           cmd = new PrintCertCmd();
-        else if ("-keyclone".equals(opt)) //$NON-NLS-1$
+        else if (_KEYCLONE.equals(opt))
           cmd = new KeyCloneCmd();
-        else if ("-storepasswd".equals(opt)) //$NON-NLS-1$
+        else if (_STOREPASSWD.equals(opt))
           cmd = new StorePasswdCmd();
-        else if ("-keypasswd".equals(opt)) //$NON-NLS-1$
+        else if (_KEYPASSWD.equals(opt))
           cmd = new KeyPasswdCmd();
-        else if ("-delete".equals(opt)) //$NON-NLS-1$
+        else if (_DELETE.equals(opt))
           cmd = new DeleteCmd();
-        else if ("-help".equals(opt)) //$NON-NLS-1$
-          {
-            printHelp();
-            i++;
-          }
+        else if (_HELP.equals(opt))
+          throw new OptionException(""); //$NON-NLS-1$
         else
-          {
-            log.fine("Unknown command [" + opt + "] at index #" + i //$NON-NLS-1$ //$NON-NLS-2$
-                     + ". Arguments from that token onward will be ignored"); //$NON-NLS-1$
-            break;
-          }
-
-        if (cmd != null)
-          {
-            i = cmd.processArgs(args, i);
-            cmd.doCommand();
-          }
-      }
-
-    // the -help command is the default; i.e.
-    //     keytool
-    // is equivalent to:
-    //     keytool -help
-    if (i == 0)
-      printHelp();
+          throw new OptionException(Messages.getFormattedString("Main.18", //$NON-NLS-1$
+                                                                opt));
 
-    if (i < limit) // more options than needed
-      log.fine("Last recognized argument is assumed at index #" + (i - 1) //$NON-NLS-1$
-               + ". Remaining arguments (" + args[i] + "...) will be ignored"); //$NON-NLS-1$ //$NON-NLS-2$
+        String[] cmdArgs = new String[args.length - 1];
+        System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
+        args = cmd.processArgs(cmdArgs);
+        cmd.doCommand();
+      }
 
     log.exiting(this.getClass().getName(), "start"); //$NON-NLS-1$
   }
 
-  private void setup()
+  private Parser getParser()
   {
-    log.entering(this.getClass().getName(), "setup"); //$NON-NLS-1$
-
-    gnuCryptoProviderNdx = ProviderUtil.addProvider(new GnuCrypto());
-    gnuCallbacksNdx = ProviderUtil.addProvider(new GnuCallbacks());
-
-    log.exiting(this.getClass().getName(), "setup"); //$NON-NLS-1$
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(KEYTOOL_TOOL, true);
+    result.setHeader(Messages.getString("Main.19")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("Main.20")); //$NON-NLS-1$
+    OptionGroup cmdGroup = new OptionGroup(Messages.getString("Main.21")); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(GENKEY_CMD,
+                                   Messages.getString("Main.22"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(IMPORT_CMD,
+                                   Messages.getString("Main.23"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(SELFCERT_CMD,
+                                   Messages.getString("Main.24"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(IDENTITYDB_CMD,
+                                   Messages.getString("Main.25"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(CERTREQ_CMD,
+                                   Messages.getString("Main.26"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(EXPORT_CMD,
+                                   Messages.getString("Main.27"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(LIST_CMD,
+                                   Messages.getString("Main.28"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(PRINTCERT_CMD,
+                                   Messages.getString("Main.29"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(KEYCLONE_CMD,
+                                   Messages.getString("Main.30"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(STOREPASSWD_CMD,
+                                   Messages.getString("Main.31"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(KEYPASSWD_CMD,
+                                   Messages.getString("Main.32"))); //$NON-NLS-1$
+    cmdGroup.add(new NoParseOption(DELETE_CMD,
+                                   Messages.getString("Main.33"))); //$NON-NLS-1$
+    result.add(cmdGroup);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
   }
 
   private void teardown()
@@ -213,7 +285,28 @@ public class Main
     if (helpPrinted)
       return;
 
-    HelpPrinter.printHelp(HELP_PATH);
     helpPrinted = true;
   }
+
+  // Inner class(es)
+  // ==========================================================================
+
+  private class NoParseOption
+      extends Option
+  {
+    public NoParseOption(String name, String description)
+    {
+      super(name, description);
+    }
+
+    public NoParseOption(String name, String description, String param)
+    {
+      super(name, description, param);
+    }
+
+    public void parsed(String argument) throws OptionException
+    {
+      // do nothing
+    }
+  }
 }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
index e3308e021f66..7ecaa1c37ab1 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/Messages.java
@@ -54,7 +54,7 @@ import java.util.logging.Logger;
 class Messages
 {
   private static final Logger log = Logger.getLogger(Messages.class.getName());
-  private static final String BUNDLE_NAME = "gnu.classpath.tools.keytool.MessageBundle"; //$NON-NLS-1$
+  private static final String BUNDLE_NAME = "gnu.classpath.tools.keytool.messages";
   private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
   private static final Map CACHED_FORMATS = new HashMap(5);
 
@@ -88,7 +88,7 @@ class Messages
           CACHED_FORMATS.put(key, mf);
       }
 
-    // if the argument is not an array, then build one consisiting of the
+    // if the argument is not an array, then build one consisting of the
     // sole argument before passing it to the format() method
     try
       {
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
index 9ba1d59702b5..d259258e7239 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
@@ -38,6 +38,12 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
 import java.io.PrintWriter;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateException;
@@ -63,7 +69,7 @@ import java.util.logging.Logger;
 class PrintCertCmd extends Command
 {
   private static final Logger log = Logger.getLogger(PrintCertCmd.class.getName());
-  private String _certFileName;
+  protected String _certFileName;
 
   // default 0-arguments constructor
 
@@ -77,40 +83,18 @@ class PrintCertCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt);
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-file".equals(opt)) // -file FILE_NAME
-          _certFileName = args[++i];
-        else if ("-v".equals(opt))
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setInputStreamParam(_certFileName);
 
-    log.finer("-printcert handler will use the following options:");
-    log.finer("  -file=" + _certFileName);
-    log.finer("  -v=" + verbose);
+    log.finer("-printcert handler will use the following options:"); //$NON-NLS-1$
+    log.finer("  -file=" + _certFileName); //$NON-NLS-1$
+    log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
 
   void start() throws CertificateException
   {
-    log.entering(getClass().getName(), "start");
+    log.entering(getClass().getName(), "start"); //$NON-NLS-1$
 
     CertificateFactory x509Factory = CertificateFactory.getInstance(Main.X_509);
     Certificate certificate = x509Factory.generateCertificate(inStream);
@@ -118,6 +102,39 @@ class PrintCertCmd extends Command
     writer.println();
     printVerbose(certificate, writer);
 
-    log.exiting(getClass().getName(), "start");
+    log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
+  }
+
+  // own methods --------------------------------------------------------------
+
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.PRINTCERT_CMD, true);
+    result.setHeader(Messages.getString("PrintCertCmd.5")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("PrintCertCmd.6")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("PrintCertCmd.7")); //$NON-NLS-1$
+    options.add(new Option(Main.FILE_OPT,
+                           Messages.getString("PrintCertCmd.8"), //$NON-NLS-1$
+                           Messages.getString("PrintCertCmd.9")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _certFileName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("PrintCertCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
   }
 }
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
index db7d45994f90..db700a164e0c 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
@@ -38,6 +38,11 @@ exception statement from your version. */
 
 package gnu.classpath.tools.keytool;
 
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 import gnu.java.security.x509.X500DistinguishedName;
 
 import java.io.ByteArrayInputStream;
@@ -129,7 +134,7 @@ import javax.security.auth.x500.X500Principal;
  *      
  *      <dt>-keypass PASSWORD</dt>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -171,15 +176,15 @@ import javax.security.auth.x500.X500Principal;
 class SelfCertCmd extends Command
 {
   private static final Logger log = Logger.getLogger(SelfCertCmd.class.getName());
-  private String _alias;
-  private String _sigAlgorithm;
-  private String _dName;
-  private String _password;
-  private String _validityStr;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  protected String _alias;
+  protected String _sigAlgorithm;
+  protected String _dName;
+  protected String _password;
+  protected String _validityStr;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
   private X500DistinguishedName distinguishedName;
   private int validityInDays;
 
@@ -253,71 +258,29 @@ class SelfCertCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt);
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-alias".equals(opt)) // -alias ALIAS
-          _alias = args[++i];
-        else if ("-sigalg".equals(opt)) // -sigalg ALGORITHM
-          _sigAlgorithm = args[++i];
-        else if ("-dname".equals(opt)) // -dname NAME
-          _dName = args[++i];
-        else if ("-keypass".equals(opt)) // -keypass PASSWORD
-          _password = args[++i];
-        else if ("-validity".equals(opt)) // -validity DAY_COUNT
-          _validityStr = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt))
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
     setAliasParam(_alias);
     setKeyPasswordNoPrompt(_password);
-//    setDName(_dName);
     setValidityParam(_validityStr);
-//    setSignatureAlgorithm(_sigAlgorithm);
-
-    log.finer("-selfcert handler will use the following options:");
-    log.finer("  -alias=" + alias);
-    log.finer("  -sigalg=" + _sigAlgorithm);
-    log.finer("  -dname=" + _dName);
-    log.finer("  -keypass=" + _password);
-    log.finer("  -validity=" + validityInDays);
-    log.finer("  -storetype=" + storeType);
-    log.finer("  -keystore=" + storeURL);
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars));
-    log.finer("  -provider=" + provider);
-    log.finer("  -v=" + verbose);
+
+    log.finer("-selfcert handler will use the following options:"); //$NON-NLS-1$
+    log.finer("  -alias=" + alias); //$NON-NLS-1$
+    log.finer("  -sigalg=" + _sigAlgorithm); //$NON-NLS-1$
+    log.finer("  -dname=" + _dName); //$NON-NLS-1$
+    log.finer("  -validity=" + validityInDays); //$NON-NLS-1$
+    log.finer("  -storetype=" + storeType); //$NON-NLS-1$
+    log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
+    log.finer("  -provider=" + provider); //$NON-NLS-1$
+    log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
 
   void start() throws KeyStoreException, NoSuchAlgorithmException,
       UnrecoverableKeyException, IOException, UnsupportedCallbackException,
       InvalidKeyException, SignatureException, CertificateException
   {
-    log.entering(getClass().getName(), "start");
+    log.entering(getClass().getName(), "start"); //$NON-NLS-1$
 
     // 1. get the key entry and certificate chain associated to alias
     Key privateKey = getAliasPrivateKey();
@@ -337,7 +300,7 @@ class SelfCertCmd extends Command
     byte[] derBytes = getSelfSignedCertificate(distinguishedName,
                                                publicKey,
                                                (PrivateKey) privateKey);
-    CertificateFactory x509Factory = CertificateFactory.getInstance("X.509");
+    CertificateFactory x509Factory = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
     ByteArrayInputStream bais = new ByteArrayInputStream(derBytes);
     Certificate certificate = x509Factory.generateCertificate(bais);
 
@@ -348,11 +311,114 @@ class SelfCertCmd extends Command
     // 7. persist the key store
     saveKeyStore();
 
-    log.exiting(getClass().getName(), "start");
+    log.exiting(getClass().getName(), "start"); //$NON-NLS-1$
   }
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.SELFCERT_CMD, true);
+    result.setHeader(Messages.getString("SelfCertCmd.14")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("SelfCertCmd.15")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("SelfCertCmd.16")); //$NON-NLS-1$
+    options.add(new Option(Main.ALIAS_OPT,
+                           Messages.getString("SelfCertCmd.17"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.18")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _alias = argument;
+      }
+    });
+    options.add(new Option(Main.SIGALG_OPT,
+                           Messages.getString("SelfCertCmd.19"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.20")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _sigAlgorithm = argument;
+      }
+    });
+    options.add(new Option(Main.DNAME_OPT,
+                           Messages.getString("SelfCertCmd.21"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.22")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _dName = argument;
+      }
+    });
+    options.add(new Option(Main.KEYPASS_OPT,
+                           Messages.getString("SelfCertCmd.23"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.24")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _password = argument;
+      }
+    });
+    options.add(new Option(Main.VALIDITY_OPT,
+                           Messages.getString("SelfCertCmd.25"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.26")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _validityStr = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("SelfCertCmd.27"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.28")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("SelfCertCmd.29"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.30")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("SelfCertCmd.31"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.32")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("SelfCertCmd.33"), //$NON-NLS-1$
+                           Messages.getString("SelfCertCmd.34")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("SelfCertCmd.35")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   private void setDName(String name, X500Principal defaultName)
   {
     if (name != null && name.trim().length() > 0)
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
index 1eb053c1c9ae..6c4dfddb92a6 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
@@ -39,6 +39,11 @@ exception statement from your version. */
 package gnu.classpath.tools.keytool;
 
 import gnu.classpath.SystemProperties;
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
 
 import java.io.IOException;
 import java.security.KeyStoreException;
@@ -65,7 +70,7 @@ import javax.security.auth.callback.UnsupportedCallbackException;
  *      designated key store.
  *      <p></dd>
  *      
- *      <dt>-storetype STORE_TYP}</dt>
+ *      <dt>-storetype STORE_TYPE</dt>
  *      <dd>Use this option to specify the type of the key store to use. The
  *      default value, if this option is omitted, is that of the property
  *      <code>keystore.type</code> in the security properties file, which is
@@ -107,11 +112,11 @@ import javax.security.auth.callback.UnsupportedCallbackException;
 class StorePasswdCmd extends Command
 {
   private static final Logger log = Logger.getLogger(StorePasswdCmd.class.getName());
-  private String _newPassword;
-  private String _ksType;
-  private String _ksURL;
-  private String _ksPassword;
-  private String _providerClassName;
+  protected String _newPassword;
+  protected String _ksType;
+  protected String _ksURL;
+  protected String _ksPassword;
+  protected String _providerClassName;
   private char[] newStorePasswordChars;
 
   // default 0-arguments constructor
@@ -150,46 +155,14 @@ class StorePasswdCmd extends Command
 
   // life-cycle methods -------------------------------------------------------
 
-  int processArgs(String[] args, int i)
-  {
-    int limit = args.length;
-    String opt;
-    while (++i < limit)
-      {
-        opt = args[i];
-        log.finest("args[" + i + "]=" + opt); //$NON-NLS-1$ //$NON-NLS-2$
-        if (opt == null || opt.length() == 0)
-          continue;
-
-        if ("-new".equals(opt)) // -new PASSWORD //$NON-NLS-1$
-          _newPassword = args[++i];
-        else if ("-storetype".equals(opt)) // -storetype STORE_TYPE //$NON-NLS-1$
-          _ksType = args[++i];
-        else if ("-keystore".equals(opt)) // -keystore URL //$NON-NLS-1$
-          _ksURL = args[++i];
-        else if ("-storepass".equals(opt)) // -storepass PASSWORD //$NON-NLS-1$
-          _ksPassword = args[++i];
-        else if ("-provider".equals(opt)) // -provider PROVIDER_CLASS_NAME //$NON-NLS-1$
-          _providerClassName = args[++i];
-        else if ("-v".equals(opt)) //$NON-NLS-1$
-          verbose = true;
-        else
-          break;
-      }
-
-    return i;
-  }
-
   void setup() throws Exception
   {
     setKeyStoreParams(_providerClassName, _ksType, _ksPassword, _ksURL);
     setNewKeystorePassword(_newPassword);
 
     log.finer("-storepasswd handler will use the following options:"); //$NON-NLS-1$
-    log.finer("  -new=" + String.valueOf(newStorePasswordChars)); //$NON-NLS-1$
     log.finer("  -storetype=" + storeType); //$NON-NLS-1$
     log.finer("  -keystore=" + storeURL); //$NON-NLS-1$
-    log.finer("  -storepass=" + String.valueOf(storePasswordChars)); //$NON-NLS-1$
     log.finer("  -provider=" + provider); //$NON-NLS-1$
     log.finer("  -v=" + verbose); //$NON-NLS-1$
   }
@@ -206,6 +179,73 @@ class StorePasswdCmd extends Command
 
   // own methods --------------------------------------------------------------
 
+  Parser getParser()
+  {
+    log.entering(this.getClass().getName(), "getParser"); //$NON-NLS-1$
+
+    Parser result = new ClasspathToolParser(Main.STOREPASSWD_CMD, true);
+    result.setHeader(Messages.getString("StorePasswdCmd.18")); //$NON-NLS-1$
+    result.setFooter(Messages.getString("StorePasswdCmd.17")); //$NON-NLS-1$
+    OptionGroup options = new OptionGroup(Messages.getString("StorePasswdCmd.16")); //$NON-NLS-1$
+    options.add(new Option(Main.NEW_OPT,
+                           Messages.getString("StorePasswdCmd.15"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _newPassword = argument;
+      }
+    });
+    options.add(new Option(Main.STORETYPE_OPT,
+                           Messages.getString("StorePasswdCmd.13"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.12")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksType = argument;
+      }
+    });
+    options.add(new Option(Main.KEYSTORE_OPT,
+                           Messages.getString("StorePasswdCmd.11"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.10")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksURL = argument;
+      }
+    });
+    options.add(new Option(Main.STOREPASS_OPT,
+                           Messages.getString("StorePasswdCmd.9"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.8")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _ksPassword = argument;
+      }
+    });
+    options.add(new Option(Main.PROVIDER_OPT,
+                           Messages.getString("StorePasswdCmd.7"), //$NON-NLS-1$
+                           Messages.getString("StorePasswdCmd.6")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        _providerClassName = argument;
+      }
+    });
+    options.add(new Option(Main.VERBOSE_OPT,
+                           Messages.getString("StorePasswdCmd.5")) //$NON-NLS-1$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        verbose = true;
+      }
+    });
+    result.add(options);
+
+    log.exiting(this.getClass().getName(), "getParser", result); //$NON-NLS-1$
+    return result;
+  }
+
   protected void setNewKeystorePassword(String password) throws IOException,
       UnsupportedCallbackException
   {
diff --git a/libjava/classpath/tools/gnu/classpath/tools/keytool/package.html b/libjava/classpath/tools/gnu/classpath/tools/keytool/package.html
new file mode 100644
index 000000000000..c447b8d01876
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/keytool/package.html
@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.classpath.tools.keytool
+
+Copyright (C) 2006 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. -->
+
+<html>
+<head>
+<title>GNU Classpath - gnu.classpath.tools.keytool</title>
+</head>
+
+<body>
+This package contains the classes that provide an implementation of the
+Security Tool: <code>keytool</code>. The behaviour of these classes should
+match that of the same tool provided in the RI version 1.4.2, except for the
+following:
+
+<ul>
+  <li>The RI tool accepts -J<i>javaoption</i> options which it then passes to
+  the underlying JVM.  This is because the RI tool acts as a <i>wrapper</i>
+  around the JVM launcher.
+  <p>
+  This implementation DOES NOT support these options.
+  </li>
+
+  <li>The RI tool is capable of importing JDK-1.1 style <i>identities</i>.
+  <p>
+  This implementation does not offer this feature.
+  </li>
+</ul>
+</body>
+</html>
diff --git a/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java
new file mode 100644
index 000000000000..4c6bae4dce92
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- translation support for native2ascii
+ Copyright (C) 2006 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 gnu.classpath.tools.native2ascii;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+  private static final String BUNDLE_NAME
+    = "gnu.classpath.tools.native2ascii.messages"; //$NON-NLS-1$
+
+  private static final ResourceBundle RESOURCE_BUNDLE
+    = ResourceBundle.getBundle(BUNDLE_NAME);
+
+  private Messages()
+  {
+  }
+
+  public static String getString(String key)
+  {
+    try
+      {
+        return RESOURCE_BUNDLE.getString(key);
+      }
+    catch (MissingResourceException e)
+      {
+        return '!' + key + '!';
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
new file mode 100644
index 000000000000..9508c103e08a
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
@@ -0,0 +1,185 @@
+/* Native2ASCII.java - native2ascii program
+ Copyright (C) 2003 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 gnu.classpath.tools.native2ascii;
+
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+/**
+ * Native2ASCII main program.
+ * @author Ito Kazumitsu <kaz@maczuka.gcd.org>
+ */
+public class Native2ASCII
+{
+  // Input file.
+  String input;
+  // Output file.
+  String output;
+  // Encoding to use.
+  String encoding;
+  // True for reverse operation.
+  boolean reversed;
+
+  private class HandleFile extends FileArgumentCallback
+  {
+    public HandleFile()
+    {
+    }
+
+    public void notifyFile(String fileArgument)
+      throws OptionException
+    {
+      if (input == null)
+        input = fileArgument;
+      else if (output == null)
+        output = fileArgument;
+      else
+        throw new OptionException(Messages.getString("Native2ASCII.TooManyFiles")); //$NON-NLS-1$
+    }
+  }
+
+  private Parser createParser()
+  {
+    Parser result = new ClasspathToolParser("native2ascii", true); //$NON-NLS-1$
+    result.setHeader(Messages.getString("Native2ASCII.Usage")); //$NON-NLS-1$
+
+    result.add(new Option("encoding", Messages.getString("Native2ASCII.EncodingHelp"), Messages.getString("Native2ASCII.EncodingArgName")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        if (encoding != null)
+          throw new OptionException(Messages.getString("Native2ASCII.EncodingSpecified")); //$NON-NLS-1$
+        encoding = argument;
+      }
+    });
+    result.add(new Option("reversed", Messages.getString("Native2ASCII.ReversedHelp")) //$NON-NLS-1$ //$NON-NLS-2$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        reversed = true;
+      }
+    });
+
+    return result;
+  }
+
+  private void run(String[] args)
+  {
+    Parser argParser = createParser();
+    argParser.parse(args, new HandleFile());
+
+    if (encoding == null)
+      encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
+    try
+      {
+        InputStream is = (input == null ? System.in
+                                        : new FileInputStream(input));
+        OutputStream os = (output == null ? (OutputStream) System.out
+                                          : new FileOutputStream(output));
+
+        BufferedReader rdr = new BufferedReader(new InputStreamReader(is,
+                                                                      encoding));
+        PrintWriter wtr = new PrintWriter(
+                                          new BufferedWriter(
+                                                             new OutputStreamWriter(
+                                                                                    os,
+                                                                                    encoding)));
+        while (true)
+          {
+            String s = rdr.readLine();
+            if (s == null)
+              break;
+            StringBuffer sb = new StringBuffer(s.length() + 80);
+            for (int i = 0; i < s.length(); i++)
+              {
+                char c = s.charAt(i);
+                if (reversed
+                    && i + 6 < s.length()
+                    && s.charAt(i) == '\\'
+                    && s.charAt(i + 1) == 'u')
+                  {
+                    int num = Integer.parseInt(s.substring(i + 2, i + 6), 16);
+                    sb.append((char) num);
+                    i += 5;
+                  }
+                else if ((int)c <= 127 || reversed)
+                  {
+                    sb.append(c);
+                  }
+                else
+                  {
+                    sb.append("\\u"); //$NON-NLS-1$
+                    if ((int)c <= 0xff)
+                      sb.append("00"); //$NON-NLS-1$
+                    else if ((int)c <= 0xfff)
+                      sb.append("0"); //$NON-NLS-1$
+                    sb.append(Integer.toHexString((int) c));
+                  }
+              }
+            wtr.println(sb.toString());
+          }
+        rdr.close();
+        wtr.flush();
+        wtr.close();
+      }
+    catch (Exception e)
+      {
+        e.printStackTrace();
+      }
+  }
+
+  public static void main(String[] args)
+  {
+    new Native2ASCII().run(args);
+    String encoding = System.getProperty("file.encoding"); //$NON-NLS-1$
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java b/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java
index c44453011572..fa4d87c1707f 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.java
@@ -41,7 +41,7 @@ public class RMIC
   /**
    * The version of the compiler.
    */
-  public static String VERSION = "0.0 alpha pre";
+  public static String VERSION = "0.01 alpha pre";
   
   /**
    * The GRMIC compiler methods
@@ -112,6 +112,17 @@ public class RMIC
                 else
                   HelpPrinter.printHelpAndExit(HelpPath);
               }
+            else if (c.equals("-classpath"))
+              {
+                int f = i + 1;
+                if (f < args.length)
+                  {
+                    compiler.setClassPath(args[f]);
+                    i++;
+                  }
+                else
+                  HelpPrinter.printHelpAndExit(HelpPath);
+              }
             else if (c.charAt(0) != '-')
             // No more options - start of class list.
               {
@@ -132,17 +143,7 @@ public class RMIC
             if (args[i].charAt(0) != '-')
               {
                 compiler.reset();
-                Class c = null;
-                try
-                  {
-                    c = Thread.currentThread().getContextClassLoader().loadClass(
-                                                                                 args[i]);
-                  }
-                catch (ClassNotFoundException e)
-                  {
-                    System.err.println(args[i] + " class not found.");
-                    System.exit(1);
-                  }
+                Class c = compiler.loadClass(args[i]);
 
                 compiler.compile(c);
                 String packag = compiler.getPackageName().replace('.', '/');
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt b/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt
index 7ec371e9a34f..882cca5538ab 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmi/RMIC.txt
@@ -9,25 +9,29 @@ Please report bugs at http://www.gnu.org/software/classpath/bugs.html
 Usage: rmic <options> <class names>
 
  where <options> includes:
-  -nowarn       Show no warnings
-  -nowrite      Do not write any files (check for errors only)
-  -d <folder>   Place generated files into the given folder
+  -nowarn            Show no warnings
+  -nowrite           Do not write any files (check for errors only)
+  -d <folder>        Place generated files into the given folder
+  -classpath <path>  Specifies the path, where to find the classes being 
+                     compiled
   
-  -help         Print this help text
-  -v            Print version
-  -verbose      Verbose output
-  -force        Try to generate code even if the input classes seem not
-                consistent with RMI specification.
+  -help              Print this help text
+  -v                 Print version
+  -verbose           Verbose output
+  -force             Try to generate code even if the input classes seem not
+                     consistent with RMI specification.
   
-  -1.2          Generate v 1.2 stubs (default)*
+  -1.2               Generate v 1.2 stubs (default)*
   
-  -iiop         Generate stubs and ties for the GIOP based RMI package extension,
-                javax.rmi. With this key, the two additional keys are accepted:
-    -poa           Generate the Servant based ties (default)
-    -impl          Generate the obsoleted ObjectImpl based ties
-                   (for backward compatibility)
-    -help       Show more details on the giop stub and tie generator options.                
-  -giop         Same as -iiop*                    
+  -iiop              Generate stubs and ties for the GIOP based RMI package 
+                     extension, javax.rmi. With this key, the two additional 
+                     keys are accepted:
+    -poa               Generate the Servant based ties (default)
+    -impl              Generate the obsoleted ObjectImpl based ties
+                        (for backward compatibility)
+    -help            Show more details on the giop stub and tie generator 
+                      options.                
+  -giop              Same as -iiop*                    
                 
   
  and <class names> can include one or more non abstract classes that implement
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html b/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html
new file mode 100644
index 000000000000..71df83b614af
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmi/registry/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.rmi.registry package.
+   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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.classpath.tools.rmi.registry</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
diff --git a/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java b/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java
new file mode 100644
index 000000000000..a6ab67addd6f
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/serialver/Messages.java
@@ -0,0 +1,68 @@
+/* Messages.java -- translations for serialver tool
+ Copyright (C) 2006 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 gnu.classpath.tools.serialver;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+  private static final String BUNDLE_NAME
+    = "gnu.classpath.tools.serialver.messages"; //$NON-NLS-1$
+
+  private static final ResourceBundle RESOURCE_BUNDLE
+    = ResourceBundle.getBundle(BUNDLE_NAME);
+
+  private Messages()
+  {
+  }
+
+  public static String getString(String key)
+  {
+    // TODO Auto-generated method stub
+    try
+      {
+        return RESOURCE_BUNDLE.getString(key);
+      }
+    catch (MissingResourceException e)
+      {
+        return '!' + key + '!';
+      }
+  }
+}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java b/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java
new file mode 100644
index 000000000000..b5a12ec927b5
--- /dev/null
+++ b/libjava/classpath/tools/gnu/classpath/tools/serialver/SerialVer.java
@@ -0,0 +1,163 @@
+/* gnu.classpath.tools.SerialVer
+ Copyright (C) 1998, 1999, 2000, 2001 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., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+
+package gnu.classpath.tools.serialver;
+
+import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.ObjectStreamClass;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+/**
+ * This class is an implementation of the `serialver' program. Any number of
+ * class names can be passed as arguments, and the serial version unique
+ * identitfier for each class will be printed in a manner suitable for cuting
+ * and pasting into a Java source file.
+ */
+public class SerialVer
+{
+  // List of classes to load.
+  ArrayList classes = new ArrayList();
+  // The class path to use.
+  String classpath;
+
+  // FIXME: taken from ClassLoader, should share it.
+  private static void addFileURL(ArrayList list, String file)
+  {
+    try
+      {
+        list.add(new File(file).toURL());
+      }
+    catch(java.net.MalformedURLException x)
+      {
+      }
+  }
+
+  private ClassLoader getClassLoader()
+  {
+    // FIXME: this code is taken from ClassLoader.
+    // We should share it somewhere.
+    URL[] urls;
+    if (classpath == null)
+      urls = new URL[0];
+    else
+      {
+        StringTokenizer tok = new StringTokenizer(classpath,
+                                                  File.pathSeparator, true);
+        ArrayList list = new ArrayList();
+        while (tok.hasMoreTokens())
+          {
+            String s = tok.nextToken();
+            if (s.equals(File.pathSeparator))
+              addFileURL(list, "."); //$NON-NLS-1$
+            else
+              {
+                addFileURL(list, s);
+                if (tok.hasMoreTokens())
+                  {
+                    // Skip the separator.
+                    tok.nextToken();
+                    // If the classpath ended with a separator,
+                    // append the current directory.
+                    if (!tok.hasMoreTokens())
+                      addFileURL(list, "."); //$NON-NLS-1$
+                  }
+              }
+          }
+        urls = new URL[list.size()];
+        urls = (URL[]) list.toArray(urls);
+      }
+    return new URLClassLoader(urls);
+  }
+
+  private void printMessage(String format, String klass)
+  {
+    System.err.println(MessageFormat.format(format, new Object[] { klass }));
+  }
+
+  public void run(String[] args)
+  {
+    Parser p = new ClasspathToolParser("serialver", true) //$NON-NLS-1$
+    {
+      protected void validate() throws OptionException
+      {
+        if (classes.isEmpty())
+          throw new OptionException(Messages.getString("SerialVer.NoClassesSpecd")); //$NON-NLS-1$
+      }
+    };
+    p.setHeader(Messages.getString("SerialVer.HelpHeader")); //$NON-NLS-1$
+
+    p.add(new Option(Messages.getString("SerialVer.5"), Messages.getString("SerialVer.ClasspathHelp"), "PATH") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    {
+      public void parsed(String argument) throws OptionException
+      {
+        if (classpath != null)
+          throw new OptionException(Messages.getString("SerialVer.DupClasspath")); //$NON-NLS-1$
+        classpath = argument;
+      }
+    });
+
+    p.parse(args, new FileArgumentCallback()
+    {
+      public void notifyFile(String fileArgument) throws OptionException
+      {
+        classes.add(fileArgument);
+      }
+    });
+
+    ClassLoader loader = getClassLoader();
+    Iterator it = classes.iterator();
+    while (it.hasNext())
+      {
+        String name = (String) it.next();
+        try
+          {
+            Class clazz = loader.loadClass(name);
+            ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
+            if (osc != null)
+              System.out.println(clazz.getName() + ": " //$NON-NLS-1$
+                                 + "static final long serialVersionUID = " //$NON-NLS-1$
+                                 + osc.getSerialVersionUID() + "L;"); //$NON-NLS-1$
+            else
+              printMessage(Messages.getString("SerialVer.ClassNotSerial"), name); //$NON-NLS-1$
+          }
+        catch (ClassNotFoundException e)
+          {
+            printMessage(Messages.getString("SerialVer.ClassNotFound"), name); //$NON-NLS-1$
+          }
+      }
+  }
+
+  public static void main(String[] args)
+  {
+    new SerialVer().run(args);
+  }
+}
\ No newline at end of file
diff --git a/libjava/classpath/tools/jarsigner.in b/libjava/classpath/tools/jarsigner.in
new file mode 100644
index 000000000000..537b7faf091b
--- /dev/null
+++ b/libjava/classpath/tools/jarsigner.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a 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 of the License, 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; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, 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.
+##
+##
+## A simple shell script to launch the GNU Classpath jarsigner tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.jarsigner.Main $@
diff --git a/libjava/classpath/tools/keytool.in b/libjava/classpath/tools/keytool.in
new file mode 100644
index 000000000000..613baf7fd7d2
--- /dev/null
+++ b/libjava/classpath/tools/keytool.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a 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 of the License, 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; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, 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.
+##
+##
+## A simple shell script to launch the GNU Classpath keytool tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.keytool.Main $@
diff --git a/libjava/classpath/tools/toolwrapper.c b/libjava/classpath/tools/toolwrapper.c
new file mode 100644
index 000000000000..de6556c63eab
--- /dev/null
+++ b/libjava/classpath/tools/toolwrapper.c
@@ -0,0 +1,220 @@
+/* toolwrapper.c -- a native tool wrapper for VMs that support the JNI
+   invocation interface
+   Copyright (C) 2006  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. */
+
+#include <jni.h>
+#include <string.h>
+#include <stdlib.h>
+#include "config.h"
+
+#ifndef JNI_VERSION_1_2
+# error JNI version 1.2 or greater required
+#endif
+
+union env_union
+{
+  void *void_env;
+  JNIEnv *jni_env;
+};
+
+int
+main (int argc, const char** argv)
+{
+  union env_union tmp;
+  JNIEnv* env;
+  JavaVM* jvm;
+  JavaVMInitArgs vm_args;
+  jint result;
+  jclass class_id;
+  jmethodID method_id;
+  jstring str;
+  jclass string_class_id;
+  jobjectArray args_array;
+  char** non_vm_argv;
+  int non_vm_argc;
+  int i;
+  int classpath_found = 0;
+
+  env = NULL;
+  jvm = NULL;
+
+  vm_args.nOptions = 0;
+  vm_args.options = NULL;
+
+  non_vm_argc = 0;
+  non_vm_argv = NULL;
+
+  if (argc > 1)
+    {
+      for (i = 1; i < argc; i++)
+	{
+	  if (!strncmp (argv[i], "-J", 2))
+	    {
+	      if (!strncmp (argv[i], "-J-Djava.class.path=", 20))
+		classpath_found = 1;
+
+	      /* A virtual machine option. */
+	      vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+
+	      if (vm_args.options == NULL)
+		{
+		  fprintf (stderr, TOOLNAME ": realloc failed.\n");
+		  goto destroy;
+		}
+
+	      if (strlen (argv[i]) == 2)
+		{
+		  fprintf (stderr, TOOLNAME ": the -J option must not be followed by a space.\n");
+		  goto destroy;
+		}
+	      else
+		vm_args.options[vm_args.nOptions++].optionString = strdup (argv[i] + 2);
+	    }
+	  else
+	    {
+	      non_vm_argv = (char**) realloc (non_vm_argv, (non_vm_argc + 1) * sizeof (char*));
+	      if (non_vm_argv == NULL)
+		{
+		  fprintf (stderr, TOOLNAME ": realloc failed.\n");
+		  goto destroy;
+		}
+	      non_vm_argv[non_vm_argc++] = strdup (argv[i]);
+	    }
+	}
+    }
+
+  if (!classpath_found)
+    {
+      /* Set the invocation classpath. */
+      vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+
+      if (vm_args.options == NULL)
+	{
+	  fprintf (stderr, TOOLNAME ": realloc failed.\n");
+	  goto destroy;
+	}
+
+      vm_args.options[vm_args.nOptions++].optionString = "-Djava.class.path=" DATA_DIR "/" PACKAGE "/tools.zip";
+    }
+
+  /* Terminate vm_args.options with a NULL element. */
+  vm_args.options = (JavaVMOption*) realloc (vm_args.options, (vm_args.nOptions + 1) * sizeof (JavaVMOption));
+  if (vm_args.options == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": realloc failed.\n");
+      goto destroy;
+    }
+  vm_args.options[vm_args.nOptions].optionString = NULL;
+
+  /* Terminate non_vm_argv with a NULL element. */
+  non_vm_argv = (char**) realloc (non_vm_argv, (non_vm_argc + 1) * sizeof (char*));
+  if (non_vm_argv == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": realloc failed.\n");
+      goto destroy;
+    }
+  non_vm_argv[non_vm_argc] = NULL;
+
+  vm_args.version = JNI_VERSION_1_2;
+  vm_args.ignoreUnrecognized = JNI_TRUE;
+
+  result = JNI_CreateJavaVM (&jvm, &tmp.void_env, &vm_args);
+
+  if (result < 0)
+    {
+      fprintf (stderr, TOOLNAME ": couldn't create virtual machine\n");
+      goto destroy;
+    }
+
+  env = tmp.jni_env;
+
+  string_class_id = (*env)->FindClass (env, "java/lang/String");
+  if (string_class_id == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": FindClass failed.\n");
+      goto destroy;
+    }
+
+  args_array = (*env)->NewObjectArray (env, non_vm_argc, string_class_id, NULL);
+  if (args_array == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": NewObjectArray failed.\n");
+      goto destroy;
+    }
+
+  for (i = 0; i < non_vm_argc; i++)
+    {
+      str = (*env)->NewStringUTF (env, non_vm_argv[i]);
+      if (str == NULL)
+	{
+	  fprintf (stderr, TOOLNAME ": NewStringUTF failed.\n");
+	  goto destroy;
+	}
+
+      (*env)->SetObjectArrayElement (env, args_array, i, str);
+    }
+
+  class_id = (*env)->FindClass (env, "gnu/classpath/tools/" TOOLNAME "/Main");
+  if (class_id == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": FindClass failed.\n");
+      goto destroy;
+    }
+
+  method_id = (*env)->GetStaticMethodID (env, class_id, "main", "([Ljava/lang/String;)V");
+
+  if (method_id == NULL)
+    {
+      fprintf (stderr, TOOLNAME ": GetStaticMethodID failed.\n");
+      goto destroy;
+    }
+
+  (*env)->CallStaticVoidMethod (env, class_id, method_id, args_array);
+
+ destroy:
+
+  if (env != NULL)
+    {
+      if ((*env)->ExceptionOccurred (env))
+	(*env)->ExceptionDescribe (env);
+
+      if (jvm != NULL)
+	(*jvm)->DestroyJavaVM (jvm);
+    }
+
+  return 1;
+}
diff --git a/libjava/java/lang/String.java b/libjava/java/lang/String.java
index 3e0bfbee89d2..bd75797a2b1a 100644
--- a/libjava/java/lang/String.java
+++ b/libjava/java/lang/String.java
@@ -1319,7 +1319,7 @@ public final class String implements Serializable, Comparable, CharSequence
    */
   public synchronized int codePointCount(int start, int end)
   {
-    if (start < 0 || end >= count || start > end)
+    if (start < 0 || end > count || start > end)
       throw new StringIndexOutOfBoundsException();
 
     int count = 0;
diff --git a/libjava/sources.am b/libjava/sources.am
index 203776efda3f..3e4c1ad1392b 100644
--- a/libjava/sources.am
+++ b/libjava/sources.am
@@ -773,12 +773,14 @@ gnu_java_awt_java2d_source_files = \
 classpath/gnu/java/awt/java2d/AbstractGraphics2D.java \
 classpath/gnu/java/awt/java2d/AlphaCompositeContext.java \
 classpath/gnu/java/awt/java2d/CubicSegment.java \
+classpath/gnu/java/awt/java2d/ImagePaint.java \
 classpath/gnu/java/awt/java2d/LineSegment.java \
 classpath/gnu/java/awt/java2d/PolyEdge.java \
 classpath/gnu/java/awt/java2d/PolyEdgeComparator.java \
 classpath/gnu/java/awt/java2d/QuadSegment.java \
 classpath/gnu/java/awt/java2d/RasterGraphics.java \
-classpath/gnu/java/awt/java2d/Segment.java
+classpath/gnu/java/awt/java2d/Segment.java \
+classpath/gnu/java/awt/java2d/TexturePaintContext.java
 
 gnu_java_awt_java2d_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_java2d_source_files)))
 
@@ -813,13 +815,17 @@ gnu/java/awt/peer.list: $(gnu_java_awt_peer_source_files)
 
 
 gnu_java_awt_peer_gtk_source_files = \
+classpath/gnu/java/awt/peer/gtk/BufferedImageGraphics.java \
+classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java \
+classpath/gnu/java/awt/peer/gtk/CairoSurface.java \
+classpath/gnu/java/awt/peer/gtk/CairoSurfaceGraphics.java \
+classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java \
+classpath/gnu/java/awt/peer/gtk/ComponentGraphicsCopy.java \
+classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java \
 classpath/gnu/java/awt/peer/gtk/GThreadMutex.java \
 classpath/gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java \
 classpath/gnu/java/awt/peer/gtk/GdkFontMetrics.java \
 classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java \
-classpath/gnu/java/awt/peer/gtk/GdkGlyphVector.java \
-classpath/gnu/java/awt/peer/gtk/GdkGraphics.java \
-classpath/gnu/java/awt/peer/gtk/GdkGraphics2D.java \
 classpath/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java \
 classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \
 classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
@@ -859,7 +865,8 @@ classpath/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java \
 classpath/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java \
 classpath/gnu/java/awt/peer/gtk/GtkToolkit.java \
 classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java \
-classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java
+classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java \
+classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
 
 gnu-java-awt-peer-gtk.lo: $(gnu_java_awt_peer_gtk_source_files)
 	@find classpath/lib/gnu/java/awt/peer/gtk -name '*.class' > gnu-java-awt-peer-gtk.list
@@ -937,6 +944,25 @@ gnu-java-awt-peer-swing.lo: $(gnu_java_awt_peer_swing_source_files)
 	$(LTGCJCOMPILE) -fjni -findirect-dispatch -fno-indirect-classes -c -o gnu-java-awt-peer-swing.lo @gnu-java-awt-peer-swing.list
 	@rm -f gnu-java-awt-peer-swing.list
 
+gnu_java_awt_print_source_files = \
+classpath/gnu/java/awt/print/JavaPrinterGraphics.java \
+classpath/gnu/java/awt/print/JavaPrinterJob.java \
+classpath/gnu/java/awt/print/PostScriptGraphics2D.java \
+classpath/gnu/java/awt/print/SpooledDocument.java
+
+gnu_java_awt_print_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_awt_print_source_files)))
+
+gnu/java/awt/print.list: $(gnu_java_awt_print_source_files)
+	@$(mkinstalldirs) $(dir $@)
+	@for file in $(gnu_java_awt_print_source_files); do \
+	  if test -f $(srcdir)/$$file; then \
+	    echo $(srcdir)/$$file; \
+	  else echo $$file; fi; \
+	done > gnu/java/awt/print.list
+
+-include gnu/java/awt/print.deps
+
+
 gnu_java_beans_source_files = \
 classpath/gnu/java/beans/BeanInfoEmbryo.java \
 classpath/gnu/java/beans/DefaultExceptionListener.java \
@@ -3333,8 +3359,27 @@ gnu/javax/swing/plaf/metal.list: $(gnu_javax_swing_plaf_metal_source_files)
 -include gnu/javax/swing/plaf/metal.deps
 
 
+gnu_javax_swing_text_html_source_files = \
+classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java \
+classpath/gnu/javax/swing/text/html/CombinedAttributes.java \
+classpath/gnu/javax/swing/text/html/ImageViewIconFactory.java
+
+gnu_javax_swing_text_html_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_javax_swing_text_html_source_files)))
+
+gnu/javax/swing/text/html.list: $(gnu_javax_swing_text_html_source_files)
+	@$(mkinstalldirs) $(dir $@)
+	@for file in $(gnu_javax_swing_text_html_source_files); do \
+	  if test -f $(srcdir)/$$file; then \
+	    echo $(srcdir)/$$file; \
+	  else echo $$file; fi; \
+	done > gnu/javax/swing/text/html.list
+
+-include gnu/javax/swing/text/html.deps
+
+
 gnu_javax_swing_text_html_parser_source_files = \
 classpath/gnu/javax/swing/text/html/parser/HTML_401F.java \
+classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java \
 classpath/gnu/javax/swing/text/html/parser/gnuDTD.java \
 classpath/gnu/javax/swing/text/html/parser/htmlAttributeSet.java \
 classpath/gnu/javax/swing/text/html/parser/htmlValidator.java
@@ -7051,7 +7096,8 @@ classpath/javax/swing/plaf/basic/BasicToolTipUI.java \
 classpath/javax/swing/plaf/basic/BasicTreeUI.java \
 classpath/javax/swing/plaf/basic/BasicViewportUI.java \
 classpath/javax/swing/plaf/basic/ComboPopup.java \
-classpath/javax/swing/plaf/basic/DefaultMenuLayout.java
+classpath/javax/swing/plaf/basic/DefaultMenuLayout.java \
+classpath/javax/swing/plaf/basic/SharedUIDefaults.java
 
 javax_swing_plaf_basic_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_swing_plaf_basic_source_files)))
 
@@ -7301,8 +7347,10 @@ classpath/javax/swing/text/html/HTMLDocument.java \
 classpath/javax/swing/text/html/HTMLEditorKit.java \
 classpath/javax/swing/text/html/HTMLFrameHyperlinkEvent.java \
 classpath/javax/swing/text/html/HTMLTableView.java \
+classpath/javax/swing/text/html/ImageView.java \
 classpath/javax/swing/text/html/InlineView.java \
 classpath/javax/swing/text/html/ListView.java \
+classpath/javax/swing/text/html/MinimalHTMLWriter.java \
 classpath/javax/swing/text/html/NullView.java \
 classpath/javax/swing/text/html/ObjectView.java \
 classpath/javax/swing/text/html/Option.java \
@@ -8368,6 +8416,7 @@ all_packages_source_files = \
   gnu/java/awt/image.list \
   gnu/java/awt/java2d.list \
   gnu/java/awt/peer.list \
+  gnu/java/awt/print.list \
   gnu/java/io.list \
   gnu/java/lang.list \
   gnu/java/lang/reflect.list \
@@ -8455,6 +8504,7 @@ all_packages_source_files = \
   gnu/javax/security/auth/login.list \
   gnu/javax/swing/plaf/gnu.list \
   gnu/javax/swing/plaf/metal.list \
+  gnu/javax/swing/text/html.list \
   gnu/javax/swing/text/html/parser.list \
   gnu/javax/swing/text/html/parser/models.list \
   gnu/javax/swing/text/html/parser/support.list \
@@ -8585,6 +8635,7 @@ ordinary_header_files = \
   $(gnu_java_awt_image_header_files) \
   $(gnu_java_awt_java2d_header_files) \
   $(gnu_java_awt_peer_header_files) \
+  $(gnu_java_awt_print_header_files) \
   $(gnu_java_io_header_files) \
   $(gnu_java_lang_header_files) \
   $(gnu_java_lang_reflect_header_files) \
@@ -8672,6 +8723,7 @@ ordinary_header_files = \
   $(gnu_javax_security_auth_login_header_files) \
   $(gnu_javax_swing_plaf_gnu_header_files) \
   $(gnu_javax_swing_plaf_metal_header_files) \
+  $(gnu_javax_swing_text_html_header_files) \
   $(gnu_javax_swing_text_html_parser_header_files) \
   $(gnu_javax_swing_text_html_parser_models_header_files) \
   $(gnu_javax_swing_text_html_parser_support_header_files) \
-- 
GitLab