summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-29 16:19:43 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-29 16:19:43 +0000
commitedd2a15cd1b0c0771bde794ca558397414515e7f (patch)
tree7a03d9df49a3eafa27a831ff321ce65168bfa16b
parent5418bfcd1dcd18878b4d0910610513c6247632ec (diff)
downloadclasspath-edd2a15cd1b0c0771bde794ca558397414515e7f.tar.gz
2006-05-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD to generics-branch (2006-05-20 to 2006-05-29)
-rw-r--r--.externalToolBuilders/Configure.launch15
-rw-r--r--ChangeLog657
-rw-r--r--INSTALL6
-rw-r--r--NEWS20
-rw-r--r--configure.ac63
-rw-r--r--doc/tools.texinfo18
-rw-r--r--examples/gnu/classpath/examples/awt/Demo.java95
-rw-r--r--examples/gnu/classpath/examples/swing/Demo.java10
-rw-r--r--examples/gnu/classpath/examples/swing/FillRect.java334
-rw-r--r--examples/gnu/classpath/examples/swing/TableDemo.java180
-rw-r--r--gnu/classpath/Configuration.java.in6
-rw-r--r--gnu/java/awt/BitwiseXORComposite.java2
-rw-r--r--gnu/java/awt/font/opentype/NameDecoder.java46
-rw-r--r--gnu/java/awt/peer/gtk/GdkFontPeer.java89
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java519
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics2D.java241
-rw-r--r--gnu/java/awt/peer/gtk/GdkTextLayout.java57
-rw-r--r--gnu/java/awt/peer/gtk/GtkCanvasPeer.java1
-rw-r--r--gnu/java/awt/peer/gtk/GtkComponentPeer.java22
-rw-r--r--gnu/java/awt/peer/gtk/GtkImage.java10
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java49
-rw-r--r--gnu/java/lang/management/OperatingSystemMXBeanImpl.java73
-rw-r--r--gnu/java/lang/management/package.html46
-rw-r--r--gnu/java/net/loader/JarURLLoader.java5
-rw-r--r--include/Makefile.am4
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkFontPeer.h3
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphics.h47
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphics2D.h12
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h1
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkComponentPeer.h2
-rw-r--r--include/java_net_VMURLConnection.h22
-rw-r--r--java/awt/Graphics2D.java2
-rw-r--r--java/awt/Window.java90
-rw-r--r--java/awt/dnd/DragGestureRecognizer.java13
-rw-r--r--java/beans/beancontext/BeanContextSupport.java291
-rw-r--r--java/io/ObjectStreamConstants.java126
-rw-r--r--java/lang/management/ManagementFactory.java81
-rw-r--r--java/lang/management/OperatingSystemMXBean.java103
-rw-r--r--java/lang/management/package.html64
-rw-r--r--java/math/BigInteger.java2
-rw-r--r--java/net/URLConnection.java10
-rw-r--r--java/nio/CharBuffer.java12
-rw-r--r--java/util/logging/FileHandler.java75
-rw-r--r--javax/accessibility/AccessibleContext.java2
-rw-r--r--javax/naming/CompositeName.java9
-rw-r--r--javax/naming/CompoundName.java4
-rw-r--r--javax/naming/Context.java560
-rw-r--r--javax/naming/ContextNotEmptyException.java7
-rw-r--r--javax/naming/InitialContext.java440
-rw-r--r--javax/naming/NameParser.java22
-rw-r--r--javax/naming/NamingEnumeration.java49
-rw-r--r--javax/naming/PartialResultException.java6
-rw-r--r--javax/naming/Reference.java158
-rw-r--r--javax/naming/Referenceable.java14
-rw-r--r--javax/naming/SizeLimitExceededException.java7
-rw-r--r--javax/naming/spi/InitialContextFactory.java21
-rw-r--r--javax/naming/spi/InitialContextFactoryBuilder.java17
-rw-r--r--javax/naming/spi/NamingManager.java82
-rw-r--r--javax/naming/spi/ObjectFactory.java29
-rw-r--r--javax/naming/spi/ObjectFactoryBuilder.java24
-rw-r--r--javax/naming/spi/ResolveResult.java82
-rw-r--r--javax/naming/spi/Resolver.java11
-rw-r--r--javax/naming/spi/StateFactory.java28
-rw-r--r--javax/swing/DefaultCellEditor.java19
-rw-r--r--javax/swing/JLabel.java41
-rw-r--r--javax/swing/JTable.java144
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxUI.java120
-rw-r--r--javax/swing/plaf/basic/BasicTableUI.java2
-rw-r--r--javax/swing/plaf/basic/BasicTreeUI.java29
-rw-r--r--javax/swing/table/JTableHeader.java407
-rw-r--r--javax/swing/text/html/MinimalHTMLWriter.java4
-rw-r--r--javax/swing/tree/AbstractLayoutCache.java7
-rw-r--r--javax/swing/tree/DefaultMutableTreeNode.java15
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java442
-rw-r--r--javax/swing/tree/DefaultTreeModel.java6
-rw-r--r--javax/swing/tree/DefaultTreeSelectionModel.java18
-rw-r--r--javax/swing/tree/ExpandVetoException.java71
-rw-r--r--javax/swing/tree/FixedHeightLayoutCache.java6
-rw-r--r--javax/swing/tree/RowMapper.java20
-rw-r--r--javax/swing/tree/TreeNode.java3
-rw-r--r--javax/swing/tree/TreeSelectionModel.java102
-rw-r--r--javax/swing/tree/VariableHeightLayoutCache.java6
-rw-r--r--native/jawt/Makefile.am14
-rw-r--r--native/jni/gtk-peer/Makefile.am19
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c89
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c758
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c534
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c14
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c49
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c40
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c4
-rw-r--r--native/jni/gtk-peer/gtkcairopeer.h93
-rw-r--r--native/jni/gtk-peer/gtkpeer.h75
-rw-r--r--native/jni/java-net/Makefile.am3
-rw-r--r--native/jni/java-net/java_net_VMURLConnection.c102
-rw-r--r--native/jni/qt-peer/eventmethods.h6
-rw-r--r--resource/gnu/classpath/tools/jarsigner/messages.properties (renamed from resource/gnu/classpath/tools/jarsigner/MessageBundle.properties)40
-rw-r--r--resource/gnu/classpath/tools/keytool/messages.properties (renamed from resource/gnu/classpath/tools/keytool/MessageBundle.properties)41
-rw-r--r--resource/gnu/classpath/tools/native2ascii/messages.properties43
-rw-r--r--resource/gnu/classpath/tools/serialver/messages.properties44
-rwxr-xr-xscripts/check_jni_methods.sh2
-rwxr-xr-xtools/Makefile.am44
-rw-r--r--tools/gnu/classpath/tools/appletviewer/AppletTag.java22
-rw-r--r--tools/gnu/classpath/tools/getopt/FileArgumentCallback.java3
-rw-r--r--tools/gnu/classpath/tools/jar/Extractor.java43
-rw-r--r--tools/gnu/classpath/tools/jar/Lister.java24
-rw-r--r--tools/gnu/classpath/tools/jar/WorkSet.java86
-rw-r--r--tools/gnu/classpath/tools/jarsigner/Messages.java4
-rw-r--r--tools/gnu/classpath/tools/keytool/ImportCmd.java167
-rw-r--r--tools/gnu/classpath/tools/keytool/Messages.java4
-rw-r--r--tools/gnu/classpath/tools/native2ascii/Messages.java67
-rw-r--r--tools/gnu/classpath/tools/native2ascii/Native2ASCII.java185
-rw-r--r--tools/gnu/classpath/tools/serialver/Messages.java68
-rw-r--r--tools/gnu/classpath/tools/serialver/SerialVer.java163
-rw-r--r--tools/toolwrapper.c (renamed from tools/appletviewer.c)51
-rw-r--r--vm/reference/java/lang/VMClassLoader.java8
-rw-r--r--vm/reference/java/net/VMURLConnection.java79
117 files changed, 6105 insertions, 3441 deletions
diff --git a/.externalToolBuilders/Configure.launch b/.externalToolBuilders/Configure.launch
index 96bcda0fe..d2347ae84 100644
--- a/.externalToolBuilders/Configure.launch
+++ b/.externalToolBuilders/Configure.launch
@@ -1,2 +1,13 @@
-<?xml version='1.0'?>
-<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,auto,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE' value='${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot; editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/classpath/Makefile.in&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${build_project}/configure'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='--prefix=${build_project}/install --enable-regen-headers --enable-gtk-cairo'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration> \ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/classpath/Makefile.in&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--prefix=${build_project}/install --enable-regen-headers --with-ecj"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${build_project}/configure"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+</launchConfiguration>
diff --git a/ChangeLog b/ChangeLog
index e58dd1bda..a848d3086 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,660 @@
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java (copying constructor):
+ Do not reuse fg in the constructor.
+
+2006-05-29 Carsten Neumann <cn-develop@gmx.net>
+
+ * java/io/ObjectStreamConstants.java: Added API docs.
+
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java (setColor):
+ Take no action if this color is already set.
+
+2006-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java (translate):
+ Rewritten.
+ * examples/gnu/classpath/examples/swing/FillRect.java (paintComponent):
+ Optionally paint with translation. (createContent): Added option
+ to test painting with translation
+
+2006-05-29 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java (FileHandler): Set the instance field
+ pattern to the default value when null.
+ Pass field pattern, and not parameter with same name to createFileStream.
+
+2006-05-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/lang/management/OperatingSystemMXBeanImpl.java:
+ New class implementing the OS bean.
+ * gnu/java/lang/management/package.html:
+ New file to document the gnu.java.lang.management package.
+ * java/lang/management/ManagementFactory.java:
+ New class to provide access to the OS bean.
+ * java/lang/management/OperatingSystemMXBean.java:
+ New interface.
+ * java/lang/management/package.html:
+ New file to document the java.lang.management package.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/keytool/ImportCmd.java (GKR): New constant.
+ (JKS): Likewise.
+ (LIB): Likewise.
+ (SECURITY): Likewise.
+ (CACERTS): Likewise.
+ (CACERTS_GKR): Likewise.
+ (gkrCaCertsPathName): New field.
+ (jksCaCertsPathName): Likewise.
+ (selfSignedCertificate): Likewise.
+ (start): Initialize trusted certificate key stores if -trustcacerts is
+ specified.
+ (ensureReplyIsOurs): Initialize selfSignedCertificate.
+ (orderChain): Implemented.
+ (findTrustAndUpdate): Check a cacerts.gkr (GKR) and a cacert (JKS) trusted
+ certificate key stores if -trustcacerts option is specified.
+ (findTrustInCACerts): Removed.
+ (getCertPathParameters): New method.
+ (validate): New method.
+ * resource/gnu/classpath/tools/keytool/messages.properties: Added message.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java (PROPERTY_PREFIX): New constant.
+ (PATTERN_KEY): Likewise.
+ (DEFAULT_PATTERN): Likewise.
+ (LIMIT_KEY): Likewise.
+ (DEFAULT_LIMIT): Likewise.
+ (COUNT_KEY): Likewise.
+ (DEFAULT_COUNT): Likewise.
+ (APPEND_KEY): Likewise.
+ (DEFAULT_APPEND): Likewise.
+ (FileHandler()): Use pattern value as set in logging.properties.
+ Use constants defined above.
+ (FileHandler(1)): Use constants defined above.
+ (FileHandler(2)): Likewise.
+ (FileHandler(3)): Likewise.
+ (FileHandler(4)): Likewise.
+ (createFileStream): Likewise.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java: Reverted previous patch.
+ * java/util/logging/LogManager.java: Likewise.
+
+2006-05-28 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * java/util/logging/FileHandler.java (PATTERN_KEY): New constant.
+ (DEFAULT_PATTERN): Likewise.
+ (FileHandler()): Use configured pattern property if any; otherwise use a
+ default value as per RI documentation.
+ * java/util/logging/LogManager.java (getStringProperty): New method.
+
+2006-05-27 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * NEWS: Announce libjawtgnu.so-to-libjawt.so rename.
+
+2006-05-27 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * configure.ac (FOUND_CACAO): New automake conditional.
+ Add --enable-tool-wrappers.
+ * NEWS: Introduce the --enable-tool-wrappers option.
+ * tools/Makefile.am[CREATE_WRAPPERS]: Build wrapper binaries.
+ * tools/appletviewer.c: Remove file. Make tool-indepedent and
+ rename ...
+ * tools/toolwrapper.c: New file.
+
+2006-05-27 Dalibor Topic <robilad@kaffe.org>
+
+ * java/awt/Graphics2D.java: Use full class name for
+ PrinterJob in javadoc.
+
+2006-05-27 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/qt-peer/eventmethods.h (callVoidMethod): Silence warning.
+ (callMouseMethod): Likewise.
+
+2006-05-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * native/jni/java-net/java_net_VMURLConnection.c:
+ Fix function declarations to specify unused parameters.
+ * scripts/check_jni_methods.sh:
+ Remove copies of the same function using uniq.
+
+2006-05-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * vm/reference/java/net/VMURLConnection.java:
+ Make package-private and final.
+
+2006-05-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/swing/TableDemo.java
+ (TModed): Added editor for the icons column.
+ (createContent): Increase the row height by 2 px.
+
+2006-05-26 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27685:
+ * java/math/BigInteger.java (modPow): Correctly handle negative
+ exponent.
+
+2006-05-26 Tom Tromey <tromey@redhat.com>
+
+ * configure.ac: Check for magic.h and -lmagic.
+ * vm/reference/java/net/VMURLConnection.java: New file.
+ * include/java_net_VMURLConnection.h: New file.
+ * include/Makefile.am (H_FILES): Add VMURLConnection.h.
+ ($(top_srcdir)/include/java_net_VMURLConnection.h): New target.
+ * native/jni/java-net/Makefile.am (libjavanet_la_SOURCES):
+ Mention new file.
+ (libjavanet_la_LIBADD): Add $(LIBMAGIC).
+ * native/jni/java-net/java_net_VMURLConnection.c: New file.
+
+2006-05-26 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * tools/Makefile.am (installcheck-binSCRIPTS): Do nothing.
+
+2006-05-26 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jawt/Makefile.am (nativeexeclib_LTLIBRARIES): Rename
+ libjawtgnu.la libjawt.la.
+
+2006-05-26 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Remove
+ gtkcairopeer.h.
+
+2006-05-25 Lillian Angel <langel@redhat.com>
+
+ PR 26174
+ * java/awt/Window.java
+ (Window): Moved code to helper.
+ (addWindowFocusListener): New function. Handles focus
+ listener code. Added code to handle focus lost/gained
+ from the window.
+
+2006-05-25 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * configure.ac:
+ Make pkg-config check for GTK+ >= 2.8.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+ (flush): Remove debugging printfs.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+ (schedule_flush): New function.
+ (end_drawing_operation): Call schedule_flush.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * examples/gnu/classpath/examples/swing/Demo.java: Add FillRect
+ paint performance demo.
+ * examples/gnu/classpath/examples/swing/FillRect.java: New file.
+
+2006-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * INSTALL: Bump GTK requirement to 2.8 or higher. Do not mention
+ Cairo version requirement. Do not mention --enable-gtk-cairo
+ configure option.
+ * NEWS: Add entry for GdkGraphics2D.
+ * configure.ac: Remove --enable-gtk-cairo and explicit checks for
+ Cairo library and headers.
+ * .externalToolBuilders/Configure.launch: Remove
+ --enable-gtk-cairo from configure line.
+ * gnu/classpath/Configuration.java.in (GTK_CAIRO_ENABLED): Remove
+ field.
+ * gnu/java/awt/BitwiseXORComposite.java: Fix javadoc typo.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c : Remove
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GdkGraphics.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Remove.
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Remove
+ Unlocked method variants. Remove GTK_CAIRO_ENABLED and
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GdkTextLayout.java: Remove instanceof
+ Graphics2D check. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GtkCanvasPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+ (realize): Remove method.
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (isRealized): Remove method.
+ (realize): Implement as a native method. Remove useGraphics2D
+ references. Always assume Graphics2D is enabled.
+ * gnu/java/awt/peer/gtk/GtkImage.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c: Replace
+ GdkGraphics references with GdkGraphics2D references.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java,
+ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c: Remove
+ useGraphics2D references. Always assume Graphics2D is enabled.
+ * include/Makefile.am (GTKPEER_H_FILES): Remove
+ gnu_java_awt_peer_gtk_GdkGraphics.h.
+ * include/gnu_java_awt_peer_gtk_GdkFontPeer.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics.h: Remove.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics2D.h: Regenerate.
+ * include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h: Likewise.
+ * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h: Likewise.
+ * native/jawt/Makefile.am (AM_LDFLAGS): Remove CAIRO_LIBS.
+ * native/jni/gtk-peer/Makefile.am (libgtkpeer_la_SOURCES): Remove
+ gnu_java_awt_peer_gtk_GdkGraphics.c. Include
+ gnu_java_awt_peer_gtk_GdkGraphics2D.c unconditionally.
+ (AM_LDFLAGS): Remove CAIRO_LIBS.
+ (AM_CFLAGS): Remove CAIRO_CFLAGS.
+ * native/jni/gtk-peer/gtkcairopeer.h: Remove. Move declarations
+ to ...
+ * native/jni/gtk-peer/gtkpeer.h: Add Graphics2D declarations.
+
+2006-05-25 Lillian Angel <langel@redhat.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+ (Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked):
+ Added check to prevent assertion error. If widget->window is null, then
+ use the parent widget's window to set the cursor on.
+
+2006-05-25 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/plaf/basic/BasicTreeUI.java (TreeCancelEditingAction):
+ Implemented.
+
+2006-05-24 Lillian Angel <langel@redhat.com>
+
+ * tools/gnu/classpath/tools/appletviewer/AppletTag.java
+ (prependCodeBase): Added check to determine if the documentbase
+ points to a directory or a file.
+
+2006-05-24 Sven de Marothy <sven@physto.se>
+
+ * java/awt/dnd/DragGestureRecognizer.java
+ (resetRecognizer): Implement.
+ (fireDragGestureRecognized): Implement.
+
+2006-05-24 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicComboBoxUI.java: Marked stub methods and
+ fixed source code formatting.
+
+2006-05-24 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/JTable.java (valueChanged): If is editing, stop editing.
+
+2006-05-24 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ Reported by Antony Balkisson.
+ * javax/swing/JTable.java (selectAll): Return without action
+ if the table is empty.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/swing/TableDemo.java:
+ (SliderCell): New inner class. (setCustomEditors,
+ setInformativeHeaders): New fields. (createContent):
+ Rewritten.
+ * javax/swing/DefaultCellEditor.java
+ (JComboBoxDelegate.shouldSelectCell): New method.
+ * javax/swing/JTable.java (editCellAt): Call shouldSelectCell.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (MouseInputHandler.mouseClicked): Start editing on a single
+ click if the cell editor is not a default cell editor.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/naming/CompositeName.java,
+ javax/swing/naming/CompoundName.java:
+ Documented.
+
+2006-05-23 Archie Cobbs <archie@dellroad.org>
+
+ * vm/reference/java/lang/VMClassLoader.java: fix static initializer
+ ordering problem.
+
+2006-05-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/tree/AbstractLayoutCache.java: Coding style fixes,
+ * javax/swing/tree/DefaultMutableTreeNode.java: Likewise,
+ * javax/swing/tree/DefaultTreeCellRenderer.java: Likewise,
+ * javax/swing/tree/DefaultTreeModel.java: Likewise,
+ * javax/swing/tree/DefaultTreeSelectionModel.java: Likewise,
+ * javax/swing/tree/ExpandVetoException.java: Likewise,
+ * javax/swing/tree/FixedHeightLayoutCache.java: Likewise,
+ * javax/swing/tree/RowMapper.java: Likewise,
+ * javax/swing/tree/TreeNode.java: Likewise,
+ * javax/swing/tree/TreeSelectionModel.java: Likewise,
+ * javax/swing/tree/VariableHeightLayoutCache.java: Likewise.
+
+2006-05-23 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/tree/DefaultTreeCellRenderer.java
+ (DefaultTreeCellRenderer): Changed key for
+ setBackgroundNonSelectionColor(),
+ plus API docs all over.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27680
+ * javax/swing/JTable.java (booleanInvertingEditor): New field.
+ (defaultEditorsByColumnClass, defaultRenderersByColumnClass):
+ Initialise in constructor. (columnMoved): Cancel editing.
+ (createDefaultEditors): Rewritten. (editCellAt):
+ Just invert the value if this is a boolean cell.
+ (initialiseLocalVars): Do not initialise renderer and editor tables.
+ (setUI): Create editors and renderers here.
+
+2006-05-23 Robert Schuster <robertschuster@fsfe.org>
+
+ * examples/gnu/classpath/examples/awt/Demo.java:
+ (MainWindow.MainWindow): Added ResolutionWindow and FullscreenWindow
+ instance as subframe.
+ (ResolutionWindow): New inner class.
+ (FullscreenWindow): New inner class.
+
+2006-05-23 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 27680
+ * javax/swing/JTable.java (BooleanCellRenderer, IconCellRenderer):
+ Set horizontal alignment to centered.
+
+2006-05-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/accessibility/AccessibleContext.java
+ (getAccessibleComponent): Fixed typo in docs,
+ * javax/swing/JLabel.java:
+ (AccessibleJLabel.getAccessibleName): Check for explicit
+ accessibleName,
+ * javax/swing/JTableHeader.java
+ (AccessibleJTableHeaderEntry.columnIndex): New field,
+ (AccessibleJTableHeaderEntry.parent): New field,
+ (AccessibleJTableHeaderEntry.table): New field,
+ (AccessibleJTableHeaderEntry.AccessibleJTableHeaderEntry()):
+ Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleColumnHeaderRenderer): New
+ utility method,
+ (AccessibleJTableHeaderEntry.addFocusListener): Implemented,
+ (AccessibleJTableHeaderEntry.addPropertyChangeListener): Implemented,
+ (AccessibleJTableHeaderEntry.contains): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleAction): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleAt): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleChild): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleChildrenCount): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleComponent): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleContext): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleDescription): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleIndexInParent): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleName): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleRole): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleSelection): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleStateSet): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleText): Implemented,
+ (AccessibleJTableHeaderEntry.getAccessibleValue): Implemented,
+ (AccessibleJTableHeaderEntry.getBackground): Implemented,
+ (AccessibleJTableHeaderEntry.getBounds): Implemented,
+ (AccessibleJTableHeaderEntry.getCursor): Implemented,
+ (AccessibleJTableHeaderEntry.getFont): Implemented,
+ (AccessibleJTableHeaderEntry.getFontMetrics): Implemented,
+ (AccessibleJTableHeaderEntry.getForeground): Implemented,
+ (AccessibleJTableHeaderEntry.getLocation): Implemented,
+ (AccessibleJTableHeaderEntry.getLocationOnScreen): Implemented,
+ (AccessibleJTableHeaderEntry.getSize): Implemented,
+ (AccessibleJTableHeaderEntry.isEnabled): Implemented,
+ (AccessibleJTableHeaderEntry.isFocusTraversable): Implemented,
+ (AccessibleJTableHeaderEntry.isShowing): Implemented,
+ (AccessibleJTableHeaderEntry.isVisible): Implemented,
+ (AccessibleJTableHeaderEntry.removeFocusListener): Implemented,
+ (AccessibleJTableHeaderEntry.removePropertyChangeListener):
+ Implemented,
+ (AccessibleJTableHeaderEntry.requestFocus): Implemented,
+ (AccessibleJTableHeaderEntry.setAccessibleDescription): Implemented,
+ (AccessibleJTableHeaderEntry.setAccessibleName): Implemented,
+ (AccessibleJTableHeaderEntry.setBackground): Implemented,
+ (AccessibleJTableHeaderEntry.setBounds): Implemented,
+ (AccessibleJTableHeaderEntry.setCursor): Implemented,
+ (AccessibleJTableHeaderEntry.setEnabled): Implemented,
+ (AccessibleJTableHeaderEntry.setFont): Implemented,
+ (AccessibleJTableHeaderEntry.setForeground): Implemented,
+ (AccessibleJTableHeaderEntry.setLocation): Implemented,
+ (AccessibleJTableHeaderEntry.setSize): Implemented,
+ (AccessibleJTableHeaderEntry.setVisible): Implemented,
+ (AccessibleJTableHeader.getAccessibleRole): Implemented,
+ (AccessibleJTableHeader.getAccessibleChildrenCount): Implemented,
+ (AccessibleJTableHeader.getAccessibleChild): Implemented,
+ (AccessibleJTableHeader.getAccessibleAt): Implemented.
+
+2006-05-22 Tom Tromey <tromey@redhat.com>
+
+ * NEWS: Updated.
+
+2006-05-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (AccessibleJLabel.getAccessibleName): New method (override),
+ (setLabelFor): Fire 'labelFor' property change event before other
+ events.
+
+2006-05-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JLabel.java
+ (AccessibleJLabel.getAccessibleRole): New method (override).
+
+2006-05-22 Tom Tromey <tromey@redhat.com>
+
+ * resource/gnu/classpath/tools/serialver/messages.properties: New
+ file.
+ * tools/gnu/classpath/tools/serialver/Messages.java: New file.
+ * tools/gnu/classpath/tools/serialver/SerialVer.java (classes): New
+ field.
+ (classpath): Likewise.
+ (run): New method.
+ (main): Use it.
+ (addFileURL): New method.
+ (getClassLoader): Likewise.
+ (printMessage): Likewise.
+
+2006-05-22 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/serialver/SerialVer.java: New file.
+
+2006-05-22 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/JTable.java (doLayout): In the column
+ resize mode, only repaing the changed part of the table.
+ (getLeftResizingBoundary): New method.
+
+2006-05-22 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/spi/InitialContextFactory.java,
+ javax/naming/spi/InitialContextFactoryBuilder.java,
+ javax/naming/spi/NamingManager.java,
+ javax/naming/spi/ObjectFactory.java,
+ javax/naming/spi/ResolveResult.java,
+ javax/naming/spi/Resolver.java,
+ javax/naming/spi/StateFactory.java: Documented.
+
+2006-05-21 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/27688:
+ * tools/gnu/classpath/tools/jar/Extractor.java (allItems): Now
+ a WorkSet.
+ (initSet): Removed.
+ (shouldExtract): Removed.
+ (run): Updated.
+ * tools/gnu/classpath/tools/jar/WorkSet.java: New file.
+ * tools/gnu/classpath/tools/jar/Lister.java (readUntilEnd): New
+ method.
+ (listJar): Use it.
+ (allItems): New field.
+ (run): Initialize it.
+ (listJar): Use it.
+
+2006-05-22 Sven de Marothy <sven@physto.se>
+
+ * java/nio/CharBuffer.java
+ (wrap): Fix bounds checking.
+
+2004-08-26 Tom Tromey <tromey@redhat.com>
+
+ * java/io/OutputStream.java
+ (OutputStream): Implements Closeable, Flushable.
+
+2006-04-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/io/ObjectOutputStream.java:
+ (writeObject(Object)): Added enum support.
+ (writeClassDescriptor(ObjectStreamClass)): Likewise.
+ * java/io/ObjectStreamClass.java:
+ (isEnum()): New package-private method.
+ (setFlags(Class)): Added enum support.
+ * java/io/ObjectStreamConstants.java:
+ (SC_ENUM): Added.
+
+2006-03-29 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/io/ObjectInputStream.java:
+ (parseContent(byte)): Added enum support.
+ * java/io/ObjectStreamConstants.java:
+ (TC_ENUM): Added.
+ (TC_MAX): Changed to new maximum, TC_ENUM.
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/beans/beancontext/BeanContextSupport.java:
+ (instantiateChild(String)): Implemented.
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/beans/beancontext/BeanContextSupport.java:
+ (add(Object)): Add further documentation.
+ (isEmpty()): Documented.
+ (propertyChange(PropertyChangeEvent)): Implemented.
+ (remove(Object)): Documented.
+ (remove(Object,boolean)): Documented and implemented.
+ (vetoableChange(PropertyChangeEvent)): Marked as
+ implemented (only subclasses appear to need this).
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * java/beans/beancontext/BeanContextSupport.java:
+ (add(Object)): Implement support for the child being
+ a BeanContextChild.
+ (avoidingGui()): Implemented.
+ (dontUseGui()): Likewise.
+ (needsGui()): Likewise.
+ (okToUseGui()): Likewise.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/Context.java,
+ javax/naming/ContextNotEmptyException.java,
+ javax/naming/Reference.java: Documented.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/swing/text/html/MinimalHTMLWriter.java
+ (writeComponent, writeImage): Declare that the method
+ may throw the IOException.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ PR 26972
+ * javax/naming/InitialContext.java (colon_list): Changed type to
+ hashset. (use_properties): New field. (init(Hashtable)): Rewritten.
+ (merge): Rewritten.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/InitialContext.java: Documented.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/NameParser.java,
+ javax/naming/NamingEnumeration.java,
+ javax/naming/PartialResultException.java,
+ javax/naming/SizeLimitExceededException.java,
+ javax/naming/spi/ObjectFactory.java,
+ javax/naming/spi/ObjectFactoryBuilder.java: Documented.
+
+2006-05-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/java/net/loader/JarURLLoader.java:
+ Use Map.Entry instead of LinkedHashMap.Entry
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/Context.java: Documented.
+
+2006-05-21 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/naming/Referenceable.java: Documented.
+ * javax/naming/spi/NamingManager.java: Documented.
+
+2006-05-21 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * doc/tools.texinfo: Replaced references to MessageBundle.properties
+ to messages.properties.
+ * resource/gnu/classpath/tools/jarsigner/MessageBundle.properties:
+ Renamed to messages.properties.
+ * resource/gnu/classpath/tools/keytool/MessageBundle.properties:
+ Likewise.
+ * resource/gnu/classpath/tools/jarsigner/messages.properties:
+ Renamed from MessageBundle.properties.
+ Added copyright notice.
+ * resource/gnu/classpath/tools/keytool/messages.properties:
+ Likewise.
+ * tools/gnu/classpath/tools/jarsigner/Messages.java
+ (BUNDLE_NAME): Use messages instead of MessageBundle properties file.
+ (getFormattedString): Fixed a spelling mistake.
+ * tools/gnu/classpath/tools/keytool/Messages.java: Likewise.
+
+2006-05-20 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/font/opentype/NameDecoder.java
+ Made class public.
+ (getName): Use getShort instead of getChar(), fix PS name.
+ (decodeName): New method.
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (getSubFamilyName): Implement.
+ (getPostScriptName): Use the NameDecoder class instead.
+ (parsePSName): Removed.
+ (getName): Added
+
+2006-05-20 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GdkFontPeer.java
+ (getTrueTypeTable): New native method.
+ (getPostScriptName): Reimplement.
+ (parsePSName): New method.
+ (getNumGlyphs): Implement.
+ * include/gnu_java_awt_peer_gtk_GdkFontPeer.h: New native method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+ (Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTrueTypeTable):
+ New function. File is now explicitly dependent on FT2.
+
+2006-05-20 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/native2ascii/Messages.java: New file.
+ * resource/gnu/classpath/tools/native2ascii/messages.properties: New
+ file.
+ * tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
+ (HandleFile): New class.
+ (input, output, encoding, reversed): New fields.
+ (createParser): New method.
+ (run): Likewise.
+ (main): Use 'run'.
+ * tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
+ (notifyFile): Throws OptionException.
+
+2006-05-20 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/native2ascii/Native2ASCII.java: New file,
+ from cp-tools.
+
2006-05-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
* native/jni/java-nio/gnu_java_nio_VMChannel.c:
diff --git a/INSTALL b/INSTALL
index 7dabbf866..97983fdce 100644
--- a/INSTALL
+++ b/INSTALL
@@ -46,14 +46,11 @@ Suggested Software
are required unless --disable-gtk-peer is used as an argument to
configure.
- - GTK+ 2.4.x (or higher)
+ - GTK+ 2.8.x (or higher)
- gdk-pixbuf
- XTest Extension (libXtst) for GdkRobot support in java.awt.
- For building the Cairo GdkGraphics2D backend you need at least
- Cairo 0.5.0.
-
For building gcjwebplugin you'll need the Mozilla plugin
support headers and libraries.
@@ -116,7 +113,6 @@ gives a complete list.
--enable-java compile Java source default=yes
--enable-jni compile JNI source default=yes
--enable-gtk-peer compile GTK native peers default=yes
- --enable-gtk-cairo compile cairo based Graphics2D default=no
--enable-qt-peer compile Qt4 native peers default=no
--enable-default-toolkit
fully qualified class name of default AWT toolkit
diff --git a/NEWS b/NEWS
index b44b9ebc2..c27e24433 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,25 @@
New in release 0.92 (UNRELEASED)
+* libjawtgnu.so has been renamed libjawt.so for binary compatibility.
+ libjawt.so should be installed in a VM-specific directory rather
+ than directly in /usr/lib. Proprietary VMs put their libjawt.so
+ implementations in VM-specific directories but search /usr/lib first.
+ If GNU Classpath's libjawt.so is installed in /usr/lib it will create
+ problems for people who use a proprietary VM to run AWT Native
+ Interface applications.
+* The GdkGraphics2D backend has been made the default. There is no
+ longer an explicit dependency on Cairo, the --enable-gtk-cairo
+ configure option is gone, and GTK 2.8 or higher is now required to
+ build the GTK peers.
* A Mozilla plugin, 'gcjwebplugin', is now included. It introduces a
dependency on the Mozilla plugin support headers and libraries.
-* An 'appletviewer' tool is now included.
-* A 'jar' tool is now included.
+* Several new tools are now included:
+ * appletviewer
+ * jar
+ * native2ascii
+ * serialver
+ A new configure option --enable-tool-wrappers causes wrapper
+ binaries to be built for VMs that support the JNI Invocation API.
New in release 0.91 (May 15, 2006)
diff --git a/configure.ac b/configure.ac
index 533247e92..bdfb727f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,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 -----------------------------------------------------------
@@ -249,6 +232,7 @@ AC_ARG_WITH([vm],
])
AC_SUBST(VM_BINARY)
+AM_CONDITIONAL(FOUND_CACAO, test "x`basename $VM_BINARY`" = xcacao)
dnl -----------------------------------------------------------
dnl Regenerate headers at build time (disabled by default)
@@ -263,6 +247,20 @@ 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
@@ -306,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]))
@@ -324,6 +323,10 @@ if test "x${COMPILE_JNI}" = xyes; then
mmap munmap mincore msync madvise getpagesize sysconf \
])
+ LIBMAGIC=
+ AC_CHECK_LIB(magic, magic_open, LIBMAGIC=-lmagic)
+ AC_SUBST(LIBMAGIC)
+
AC_HEADER_TIME
AC_STRUCT_TM
AC_STRUCT_TIMEZONE
@@ -400,19 +403,12 @@ if test "x${COMPILE_JNI}" = xyes; then
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
-
+ 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)
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)
@@ -714,15 +710,20 @@ scripts/classpath.spec
lib/Makefile
lib/gen-classlist.sh
lib/copy-vmresources.sh
-tools/appletviewer
tools/Makefile
-tools/jarsigner
-tools/keytool
examples/Makefile
examples/Makefile.jawt])
-AC_CONFIG_COMMANDS([gen-classlist],[chmod 755 lib/gen-classlist.sh])
-AC_CONFIG_COMMANDS([copy-vmresources],[chmod 755 lib/copy-vmresources.sh])
+
+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/doc/tools.texinfo b/doc/tools.texinfo
index 53eadfaae..ad61f6f74 100644
--- a/doc/tools.texinfo
+++ b/doc/tools.texinfo
@@ -721,7 +721,7 @@ Command.23=A correct key password MUST be provided
When the tool needs to signal a mandatory but missing key password, it would reference the property named @code{Command.23} and the message "@kbd{A correct key password MUST be provided}" will be used instead. This indirect referencing of "resources" permits replacing, as late as possible, the English strings with strings in other languages, provided of course @i{Resource Bundles} in those languages are provided.
-For the GNU Classpath Tools described in this Guide, the @i{Resource Bundles} are files named @file{MessageBundle[_ll[_CC[_VV]]].properties} where:
+For the GNU Classpath Tools described in this Guide, the @i{Resource Bundles} are files named @file{messages[_ll[_CC[_VV]]].properties} where:
@ftable @var
@item ll
@@ -746,16 +746,16 @@ The location of the @i{Resource Bundles} for the GNU Classpath Tools is specific
The collection of @i{Resource Bundles} in a location act as an inverted tree with a parent-child relationship. For example suppose in the @file{gnu/classpath/tools/keytool} there are 3 message bundles named:
@enumerate
-@item @code{MessageBundle.properties}
-@item @code{MessageBundle_fr.properties}
-@item @code{MessageBundle_fr_FR.properties}
+@item @code{messages.properties}
+@item @code{messages_fr.properties}
+@item @code{messages_fr_FR.properties}
@end enumerate
-In the above example, bundle #1 will act as the parent of bundle #2, which in turn will act as the parent for bundle #3. This ordering is used by the Java runtime to choose which file to load based on the set Locale. For example if the Locale is @code{fr_CH}, @code{MessageBundle_fr.properties} will be used because (a) @code{MessageBundle_fr_CH.properties} does not exist, but (b) @code{MessageBundle_fr.properties} is the parent for the required bundle, and it exists. As another example, suppose the Locale was set to @code{en_AU}; then the tool will end up using @code{MessageBundle.properties} because (a) @code{MessageBundle_en_AU.properties} does not exist, (b) @code{MessageBundle_en.properties} which is the parent for the required bundle does not exist, but (c) @code{MessageBundle.properties} exists and is the root of the hierarchy.
+In the above example, bundle #1 will act as the parent of bundle #2, which in turn will act as the parent for bundle #3. This ordering is used by the Java runtime to choose which file to load based on the set Locale. For example if the Locale is @code{fr_CH}, @code{messages_fr.properties} will be used because (a) @code{messages_fr_CH.properties} does not exist, but (b) @code{messages_fr.properties} is the parent for the required bundle, and it exists. As another example, suppose the Locale was set to @code{en_AU}; then the tool will end up using @code{messages.properties} because (a) @code{messages_en_AU.properties} does not exist, (b) @code{messages_en.properties} which is the parent for the required bundle does not exist, but (c) @code{messages.properties} exists and is the root of the hierarchy.
-You can see from the examples above that @file{MessageBundle.properties} is the safety net that the Java runtime falls back to when failing to find a specific bunlde and its parent(s). This file is always provided with the Tool. In time, more localized versions will be included to cater for other languages.
+You can see from the examples above that @file{messages.properties} is the safety net that the Java runtime falls back to when failing to find a specific bunlde and its parent(s). This file is always provided with the Tool. In time, more localized versions will be included to cater for other languages.
-In the meantime, if you are willing to contribute localized versions of these resources, grab the @file{MessageBundle.properties} for a specific tool; translate it; save it with the appropriate language and region suffix and mail it to @code{classpath@@gnu.org}.
+In the meantime, if you are willing to contribute localized versions of these resources, grab the @file{messages.properties} for a specific tool; translate it; save it with the appropriate language and region suffix and mail it to @code{classpath@@gnu.org}.
@comment ----------------------------------------------------------------------
@@ -763,7 +763,7 @@ In the meantime, if you are willing to contribute localized versions of these re
@comment node-name, next, previous, up
@section Message Formats
-If you open any of the @file{MessageBundle.properties} described in the previous section, you may see properties that look like so:
+If you open any of the @file{messages.properties} described in the previous section, you may see properties that look like so:
@example
Command.67=Issuer: @{0@}
@@ -774,7 +774,7 @@ Command.70=\ \ \ \ \ until: @{0,date,full@} - @{0,time,full@}
These are @i{Message Formats} used by the tools to customize a text string that will then be used either as a prompt for User input or as output.
-If you are translating a @file{MessageBundle.properties} be careful not to alter text between curly braces.
+If you are translating a @file{messages.properties} be careful not to alter text between curly braces.
@comment ----------------------------------------------------------------------
diff --git a/examples/gnu/classpath/examples/awt/Demo.java b/examples/gnu/classpath/examples/awt/Demo.java
index 64594e47b..5e668dde6 100644
--- a/examples/gnu/classpath/examples/awt/Demo.java
+++ b/examples/gnu/classpath/examples/awt/Demo.java
@@ -154,6 +154,8 @@ class Demo
addSubWindow ("RandomTests", new TestWindow (this));
addSubWindow ("RoundRect", new RoundRectWindow ());
addSubWindow ("Animation", new AnimationWindow ());
+ addSubWindow ("Resolution", new ResolutionWindow ());
+ addSubWindow ("Fullscreen", new FullscreenWindow ());
Panel sp = new Panel();
PrettyPanel p = new PrettyPanel();
@@ -744,6 +746,99 @@ class Demo
t.beep();
}
}
+
+ static class ResolutionWindow extends SubFrame
+ {
+ GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+ public void init ()
+ {
+ initted = true;
+
+ setTitle("Change Screen Resolution");
+ final List list = new List();
+ DisplayMode[] modes = gd.getDisplayModes();
+
+ for (int i=0;i<modes.length;i++ )
+ list.add(modes[i].getWidth() + "x"
+ + modes[i].getHeight()
+ + ((modes[i].getBitDepth() != DisplayMode.BIT_DEPTH_MULTI)
+ ? "x" + modes[i].getBitDepth() + "bpp"
+ : "")
+ + ((modes[i].getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN)
+ ? "@" + modes[i].getRefreshRate() + "Hz"
+ : ""));
+
+ ActionListener al = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ int i = list.getSelectedIndex();
+ gd.setDisplayMode(gd.getDisplayModes()[i]);
+ }
+ };
+
+ Button b = new Button("Switch");
+ Button c = new Button("Close");
+
+ list.addActionListener(al);
+ b.addActionListener(al);
+
+ c.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ dispose();
+ }
+ });
+
+ setLayout(new GridLayout(3, 1, 5, 5));
+ add(list);
+ add(b);
+ add(c);
+
+ pack();
+ }
+ }
+
+ static class FullscreenWindow extends SubFrame
+ {
+ GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
+
+ public void init ()
+ {
+ initted = true;
+
+ setTitle("Fullscreen Exclusive Mode");
+
+ ActionListener al = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ if (gd.getFullScreenWindow() == FullscreenWindow.this)
+ gd.setFullScreenWindow(null);
+ else
+ gd.setFullScreenWindow(FullscreenWindow.this);
+ }
+ };
+
+ Button b = new Button("Toggle Fullscreen");
+ Button c = new Button("Close");
+
+ b.addActionListener(al);
+
+ c.addActionListener(new ActionListener () {
+ public void actionPerformed (ActionEvent e) {
+ gd.setFullScreenWindow(null);
+ dispose();
+ }
+ });
+
+ setLayout(new GridLayout(3, 1, 5, 5));
+ add(b);
+ add(c);
+
+ pack();
+ }
+ }
static class RoundRectWindow extends SubFrame
{
diff --git a/examples/gnu/classpath/examples/swing/Demo.java b/examples/gnu/classpath/examples/swing/Demo.java
index 0f0b3555e..6447077a3 100644
--- a/examples/gnu/classpath/examples/swing/Demo.java
+++ b/examples/gnu/classpath/examples/swing/Demo.java
@@ -156,7 +156,10 @@ public class Demo
examples.add(new JMenuItem(new PopupAction("NavigationFilter",
NavigationFilterDemo.createDemoFactory())));
-
+ examples.add(new JMenuItem(new PopupAction("Paint Performance",
+ FillRect.createDemoFactory())));
+
+
final JMenuItem vmMenu;
help.add(new JMenuItem("just play with the widgets"));
@@ -543,7 +546,10 @@ public class Demo
panel.add(new JButton(new PopupAction("Tree",
TreeDemo.createDemoFactory())));
panel.add(new JButton(new PopupAction("Theme Editor",
- MetalThemeEditor.createDemoFactory())));
+ MetalThemeEditor.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("Paint Performance",
+ FillRect.createDemoFactory())));
+
JButton exitDisposer = mkDisposerButton(frame);
panel.add(exitDisposer);
diff --git a/examples/gnu/classpath/examples/swing/FillRect.java b/examples/gnu/classpath/examples/swing/FillRect.java
new file mode 100644
index 000000000..11e208d85
--- /dev/null
+++ b/examples/gnu/classpath/examples/swing/FillRect.java
@@ -0,0 +1,334 @@
+/* FillRect.java - demonstrator for classpath/gcj fillrect performance issue
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+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. */
+
+package gnu.classpath.examples.swing;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+/**
+ * @author Norman Hendrich
+ */
+public class FillRect
+ extends JPanel
+ implements ActionListener
+{
+
+ static FillRect fillRectDemo;
+
+ LCDCanvas lcd;
+ Worker worker;
+ JLabel label;
+ JCheckBox translate;
+
+ int nx = 64;
+ int ny = 64;
+ int matrix[][], future[][];
+ int generation = 0;
+
+ // 20 msec, or 50 repaints per sec (theoretically)
+ int sleepMillis = 20;
+ long lastMillis = System.currentTimeMillis();
+
+ boolean enableRepaints = true;
+
+ /**
+ * If true, test translation.
+ */
+ boolean testTranslation = false;
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public FillRect()
+ {
+ setSize(64, 64);
+ createContent();
+ }
+
+ public void createContent()
+ {
+ setLayout(new BorderLayout());
+
+ JPanel p = new JPanel(new BorderLayout());
+ lcd = new LCDCanvas();
+ label = new JLabel();
+ label.setText("paintComponent took 00 msec. (00000 fillRect calls)");
+
+ translate = new JCheckBox("translate");
+ translate.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent event)
+ {
+ testTranslation = translate.isSelected();
+ }
+ });
+
+ JPanel bottom = new JPanel();
+ bottom.add(label);
+ bottom.add(translate);
+
+ p.add(lcd, BorderLayout.CENTER);
+ p.add(bottom, BorderLayout.SOUTH);
+ add(p);
+ }
+
+ public void setSize(int _nx,int _ny )
+ {
+ nx = _nx;
+ ny = _ny;
+ matrix = new int[nx][ny];
+ future = new int[nx][ny];
+ }
+
+ public void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ public void setSleepMillis(int millis)
+ {
+ sleepMillis = millis;
+ }
+
+ public class LCDCanvas extends JPanel
+ {
+ private int sx, sy;
+ private Color activePixel = new Color(30, 30, 40);
+ private Color passivePixel = new Color(200, 180, 240);
+ private Color gridPixel = new Color(255, 240, 240);
+
+ public LCDCanvas()
+ {
+ super();
+ sx = 4 * nx;
+ sy = 4 * ny;
+ }
+
+ public void paintComponent(Graphics g)
+ {
+ // for buffered drawing - not used atm
+ // g.drawImage( buffer, 0, 0, null );
+ long t1 = System.currentTimeMillis();
+
+ g.setColor(gridPixel);
+ g.fillRect(0, 0, sx, sy);
+
+ Color pixelColor = null;
+
+ int dx, dy;
+
+ for (int ix = 0; ix < nx; ix++)
+ {
+ for (int iy = 0; iy < ny; iy++)
+ {
+ if (matrix[ix][iy] != 0)
+ pixelColor = activePixel;
+ else
+ pixelColor = passivePixel;
+
+ dx = 4 * ix;
+ dy = 4 * iy;
+ g.setColor(pixelColor);
+
+ if (testTranslation)
+ {
+ g.translate(dx, dy);
+ g.fillRect(0, 0, 3, 3);
+ g.translate(-dx, -dy);
+ }
+ else
+ g.fillRect(dx, dy, 3, 3);
+ }
+ }
+
+ long t2 = System.currentTimeMillis();
+
+ label.setText("paintComponent took " + (t2 - t1) + " msec. "
+ + "(" + (nx * ny + 1) + " fillRect calls)");
+ }
+
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(sx,sy);
+ }
+
+ public Dimension getMinimumSize()
+ {
+ return new Dimension(sx,sy);
+ }
+ }
+
+ public class Worker extends Thread
+ {
+ public void run()
+ {
+ boolean running = true;
+ while(running)
+ {
+ iteration();
+
+ if (enableRepaints)
+ display();
+
+ if (sleepMillis > 0)
+ {
+ try
+ {
+ Thread.sleep( sleepMillis );
+ }
+ catch(InterruptedException ie)
+ {
+ running = false;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * stupid animation algorithm: show binary representation of current
+ * iteration.
+ */
+ public void iteration()
+ {
+ generation++;
+
+ for (int i = 0; i < nx; i++)
+ {
+ long tmp1 = 1L << i;
+ for (int j = 0; j < ny; j++)
+ {
+ // count neighbors
+ long tmp2 = (1L << j);
+
+
+ long tmp3 = generation & tmp1 & tmp2;
+ if (tmp3 != 0)
+ matrix[i][j] = 1;
+ else
+ matrix[i][j] = 0;
+ }
+ }
+
+ if ((generation % 100) == 0)
+ {
+ long t = System.currentTimeMillis();
+ // System.out.println(
+ // " generation= " + generation +
+ // " iterations/sec= " + 100.0*1000/(t-lastMillis) );
+ lastMillis = t;
+ }
+ }
+
+ public void display()
+ {
+ lcd.repaint();
+ }
+
+ public static void usage()
+ {
+ System.out.println(
+ "Usage: <java> FillRect2 [-sleep <millis>] [-size <int>] [-nopaint]\n"
+ + "Example: jamvm FillRect2 -sleep 10 -size 100\n"
+ );
+ System.exit(0);
+ }
+
+ public static void main(String args[])
+ throws Exception
+ {
+ fillRectDemo = new FillRect();
+ for (int i = 0; i < args.length; i++)
+ {
+ if ("-help".equals(args[i]))
+ {
+ usage();
+ }
+ if ("-sleep".equals(args[i]))
+ {
+ fillRectDemo.setSleepMillis( Integer.parseInt(args[i + 1]));
+ i++;
+ }
+ if ("-size".equals(args[i]))
+ {
+ int size = Integer.parseInt(args[i + 1]);
+ fillRectDemo.setSize(size, size);
+ i++;
+ }
+ if ("-nopaint".equals(args[i]))
+ {
+ fillRectDemo.enableRepaints = false;
+ }
+ }
+
+ SwingUtilities.invokeLater (new Runnable()
+ {
+ public void run()
+ {
+
+ fillRectDemo.initFrameContent();
+ JFrame frame = new JFrame("FillRect performance test");
+ frame.getContentPane().add(fillRectDemo);
+ frame.pack();
+ frame.show();
+ fillRectDemo.worker = fillRectDemo.new Worker();
+ fillRectDemo.worker.start();
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a SliderDemo.
+ *
+ * @return a DemoFactory that creates a SliderDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ fillRectDemo = new FillRect();
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ fillRectDemo.worker = fillRectDemo.new Worker();
+ fillRectDemo.worker.start();
+ }
+ });
+ return fillRectDemo;
+ }
+ };
+ }
+}
diff --git a/examples/gnu/classpath/examples/swing/TableDemo.java b/examples/gnu/classpath/examples/swing/TableDemo.java
index e661ee3ad..d4a97b3ef 100644
--- a/examples/gnu/classpath/examples/swing/TableDemo.java
+++ b/examples/gnu/classpath/examples/swing/TableDemo.java
@@ -39,19 +39,36 @@ exception statement from your version. */
package gnu.classpath.examples.swing;
import java.awt.BorderLayout;
+import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.text.DateFormat;
+import java.util.Date;
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.DefaultCellEditor;
+import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
+import javax.swing.JList;
import javax.swing.JPanel;
+import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
+import javax.swing.JSlider;
import javax.swing.JTable;
+import javax.swing.JTextField;
import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
import javax.swing.plaf.metal.MetalIconFactory;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
/**
* Displays the editable table. The first column consists of check boxes.
@@ -78,12 +95,11 @@ public class TableDemo extends JPanel
{
/**
- * Return true if the cell is editable.
- * Icons are not editable, other cells are editable.
+ * All cells are editable in our table.
*/
public boolean isCellEditable(int row, int column)
{
- return column!=1;
+ return true;
}
/**
@@ -144,6 +160,77 @@ public class TableDemo extends JPanel
}
/**
+ * The scroll bar renderer.
+ */
+ class SliderCell
+ extends AbstractCellEditor
+ implements TableCellEditor, TableCellRenderer
+ {
+ /**
+ * The editor bar.
+ */
+ JSlider bar;
+
+ /**
+ * The renderer bar.
+ */
+ JSlider rendererBar;
+
+ /**
+ * The border around the bar, if required.
+ */
+ Border border = BorderFactory.createLineBorder(table.getGridColor());
+
+ SliderCell()
+ {
+ bar = new JSlider();
+ bar.setOrientation(JScrollBar.HORIZONTAL);
+ bar.setMinimum(0);
+ bar.setMaximum(rows);
+ bar.setBorder(border);
+
+ rendererBar = new JSlider();
+ rendererBar.setMinimum(0);
+ rendererBar.setMaximum(rows);
+ rendererBar.setEnabled(false);
+ }
+
+ /**
+ * Get the editor.
+ */
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row,
+ int column)
+ {
+ if (value instanceof Integer)
+ bar.setValue(((Integer) value).intValue());
+ return bar;
+ }
+
+ /**
+ * Get the renderer.
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ rendererBar.setValue(((Integer) value).intValue());
+ if (hasFocus)
+ rendererBar.setBorder(border);
+ else
+ rendererBar.setBorder(null);
+ return rendererBar;
+ }
+
+ public Object getCellEditorValue()
+ {
+ return new Integer(bar.getValue());
+ }
+
+ }
+
+ /**
* The table being displayed.
*/
JTable table = new JTable();
@@ -159,6 +246,25 @@ public class TableDemo extends JPanel
Object[][] values;
/**
+ * The icons that appear in the icon column.
+ */
+ Icon[] icons = new Icon[]
+ {
+ MetalIconFactory.getTreeComputerIcon(),
+ MetalIconFactory.getTreeHardDriveIcon(),
+ MetalIconFactory.getTreeFolderIcon(),
+ };
+
+ /**
+ * The choices in the combo boxes
+ */
+ String [] sides = new String[]
+ {
+ "north", "south", "east", "west"
+ };
+
+
+ /**
* Create the table demo with the given titel.
*/
public TableDemo()
@@ -178,29 +284,25 @@ public class TableDemo extends JPanel
setLayout(new BorderLayout());
values = new Object[rows][];
- // The icons that appear in the icon column.
- Icon[] icons = new Icon[]
- {
- MetalIconFactory.getTreeComputerIcon(),
- MetalIconFactory.getTreeHardDriveIcon(),
- MetalIconFactory.getTreeFolderIcon(),
- };
-
for (int i = 0; i < values.length; i++)
{
values[i] = new Object[cols];
- for (int j = 2; j < cols; j++)
+ for (int j = 3; j < cols; j++)
{
values[i][j] = "" + ((char) ('a' + j)) + i;
}
values [i][0] = i % 2 == 0? Boolean.TRUE : Boolean.FALSE;
- values [i][1] = icons [ i % icons.length ];
+ values [i][1] = icons [ i % icons.length ];
+ values [i][2] = sides [ i % sides.length ];
+ values [i][4] = new Integer(i);
}
table.setModel(model);
// Make the columns with gradually increasing width:
DefaultTableColumnModel cm = new DefaultTableColumnModel();
+ table.setColumnModel(cm);
+
for (int i = 0; i < cols; i++)
{
TableColumn column = new TableColumn(i);
@@ -215,8 +317,9 @@ public class TableDemo extends JPanel
cm.addColumn(column);
}
-
- table.setColumnModel(cm);
+
+ setCustomEditors();
+ setInformativeHeaders();
// Create the table, place it into scroll pane and place
// the pane into this frame.
@@ -226,6 +329,52 @@ public class TableDemo extends JPanel
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroll.getViewport().add(table);
add(scroll, BorderLayout.CENTER);
+
+ // Increase the row height to make the icons and sliders look better.
+ table.setRowHeight(table.getRowHeight()+2);
+ }
+
+ /**
+ * Set the more informative column headers for specific columns.
+ */
+ void setInformativeHeaders()
+ {
+ TableColumnModel cm = table.getColumnModel();
+
+ cm.getColumn(0).setHeaderValue("check");
+ cm.getColumn(1).setHeaderValue("icon");
+ cm.getColumn(2).setHeaderValue("combo");
+ cm.getColumn(3).setHeaderValue("edit combo");
+ cm.getColumn(4).setHeaderValue("slider");
+ }
+
+ /**
+ * Set the custom editors for combo boxes. This method also sets one
+ * custom renderer.
+ */
+ void setCustomEditors()
+ {
+ TableColumnModel cm = table.getColumnModel();
+
+ // Set combo-box based editor for icons (note that no custom
+ // renderer is needed for JComboBox to work with icons.
+ JComboBox combo0 = new JComboBox(icons);
+ cm.getColumn(1).setCellEditor(new DefaultCellEditor(combo0));
+
+ // Set the simple combo box editor for the third column:
+ JComboBox combo1 = new JComboBox(sides);
+ cm.getColumn(2).setCellEditor(new DefaultCellEditor(combo1));
+
+ // Set the editable combo box for the forth column:
+ JComboBox combo2 = new JComboBox(sides);
+ combo2.setEditable(true);
+ cm.getColumn(3).setCellEditor(new DefaultCellEditor(combo2));
+
+ SliderCell scrollView = new SliderCell();
+ cm.getColumn(4).setCellEditor(scrollView);
+ cm.getColumn(4).setCellRenderer(scrollView);
+
+ table.setColumnModel(cm);
}
/**
@@ -266,3 +415,4 @@ public class TableDemo extends JPanel
};
}
}
+
diff --git a/gnu/classpath/Configuration.java.in b/gnu/classpath/Configuration.java.in
index 569ccf541..7f490d529 100644
--- a/gnu/classpath/Configuration.java.in
+++ b/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/gnu/java/awt/BitwiseXORComposite.java b/gnu/java/awt/BitwiseXORComposite.java
index b568e1108..9205df1dd 100644
--- a/gnu/java/awt/BitwiseXORComposite.java
+++ b/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/gnu/java/awt/font/opentype/NameDecoder.java b/gnu/java/awt/font/opentype/NameDecoder.java
index bc0c0df09..e4ea202bb 100644
--- a/gnu/java/awt/font/opentype/NameDecoder.java
+++ b/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/gnu/java/awt/peer/gtk/GdkFontPeer.java b/gnu/java/awt/peer/gtk/GdkFontPeer.java
index 82744480d..544efa3c9 100644
--- a/gnu/java/awt/peer/gtk/GdkFontPeer.java
+++ b/gnu/java/awt/peer/gtk/GdkFontPeer.java
@@ -40,6 +40,7 @@ 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;
@@ -53,6 +54,7 @@ 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
{
@@ -79,17 +81,18 @@ 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);
protected void finalize ()
{
- if (GtkToolkit.useGraphics2D ())
- GdkGraphics2D.releasePeerGraphicsResource(this);
+ GdkGraphics2D.releasePeerGraphicsResource(this);
dispose ();
}
@@ -139,26 +142,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)
@@ -265,7 +326,13 @@ 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,
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
deleted file mode 100644
index a5b9ff135..000000000
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ /dev/null
@@ -1,519 +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 gnu.java.awt.AWTUtilities;
-
-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
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- {
- 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;
-
- computeIntersection(x, y, width, height, clip);
- 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);
- }
-
- private Rectangle computeIntersection(int x, int y, int w, int h,
- Rectangle rect)
- {
- int x2 = (int) rect.x;
- int y2 = (int) rect.y;
- int w2 = (int) rect.width;
- int h2 = (int) rect.height;
-
- int dx = (x > x2) ? x : x2;
- int dy = (y > y2) ? y : y2;
- int dw = (x + w < x2 + w2) ? (x + w - dx) : (x2 + w2 - dx);
- int dh = (y + h < y2 + h2) ? (y + h - dy) : (y2 + h2 - dy);
-
- if (dw >= 0 && dh >= 0)
- rect.setBounds(dx, dy, dw, dh);
- else
- rect.setBounds(0, 0, 0, 0);
-
- return rect;
- }
-
-}
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
index 323d5614a..ff3555015 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
@@ -100,10 +100,6 @@ public class GdkGraphics2D extends Graphics2D
static
{
- if (! Configuration.GTK_CAIRO_ENABLED)
- throw new Error("Graphics2D not implemented. "
- + "Cairo was not found or disabled at configure time");
-
if (Configuration.INIT_LOAD_LIBRARY)
System.loadLibrary("gtkpeer");
@@ -132,15 +128,12 @@ public class GdkGraphics2D extends Graphics2D
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()
{
@@ -157,28 +150,19 @@ public class GdkGraphics2D extends Graphics2D
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);
- }
-
GdkGraphics2D(GdkGraphics2D g)
{
- if (!GtkToolkit.useGraphics2D ())
- fail_g2d ();
-
+ Color foreground;
+
paint = g.paint;
stroke = g.stroke;
setRenderingHints(g.hints);
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)
{
@@ -203,7 +187,7 @@ public class GdkGraphics2D extends Graphics2D
component = g.component;
copyState(g);
- setColor(fg);
+ setColor(foreground);
setBackground(bg);
setPaint(paint);
setStroke(stroke);
@@ -221,9 +205,6 @@ public class GdkGraphics2D extends Graphics2D
GdkGraphics2D(int width, int height)
{
- if (!GtkToolkit.useGraphics2D ())
- fail_g2d ();
-
initState(width, height);
setColor(Color.black);
@@ -239,15 +220,9 @@ public class GdkGraphics2D extends Graphics2D
GdkGraphics2D(GtkComponentPeer component)
{
- if (!GtkToolkit.useGraphics2D ())
- fail_g2d ();
-
this.component = component;
- if (component.isRealized())
- initComponentGraphics2D();
- else
- connectSignals(component);
+ initComponentGraphics2D();
}
void initComponentGraphics2D()
@@ -265,21 +240,6 @@ public class GdkGraphics2D extends Graphics2D
stateStack = new Stack();
}
- 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));
-
- stateStack = new Stack();
- }
-
GdkGraphics2D(BufferedImage bimage)
{
this.bimage = bimage;
@@ -324,37 +284,25 @@ public class GdkGraphics2D extends Graphics2D
// drawing utility methods
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);
-
+
// simple passthroughs to cairo
private native void cairoSave();
private native void cairoRestore();
private native void cairoSetMatrix(double[] m);
- private native void cairoSetMatrixUnlocked(double[] m);
private native void cairoSetOperator(int cairoOperator);
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);
@@ -745,49 +693,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;
@@ -799,17 +704,6 @@ public class GdkGraphics2D extends Graphics2D
}
}
- 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)
@@ -854,10 +748,35 @@ public class GdkGraphics2D extends Graphics2D
{
transform(AffineTransform.getScaleInstance(sx, sy));
}
-
+
+ /**
+ * 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)
{
- transform(AffineTransform.getTranslateInstance(tx, ty));
+ // 200 -> 140
+ if (transform != null)
+ transform.translate(tx, ty);
+ else
+ transform = AffineTransform.getTranslateInstance(tx, ty);
+
+ if (clip != null)
+ {
+ // 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;
+ }
+
+ setTransform(transform);
}
public void translate(int x, int y)
@@ -899,48 +818,27 @@ 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)
{
if (c == null)
c = Color.BLACK;
+
+ if (c.equals(fg))
+ return;
fg = c;
paint = c;
@@ -948,27 +846,11 @@ public class GdkGraphics2D extends Graphics2D
fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
}
- public void setColorUnlocked(Color c)
- {
- if (c == null)
- c = Color.BLACK;
-
- fg = c;
- paint = c;
- cairoSetRGBAColorUnlocked(fg.getRed() / 255.0, fg.getGreen() / 255.0,
- fg.getBlue() / 255.0, fg.getAlpha() / 255.0);
- }
-
public Color getColor()
{
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));
@@ -1096,11 +978,6 @@ public class GdkGraphics2D extends Graphics2D
bg = c;
}
- public void setBackgroundUnlocked(Color c)
- {
- setBackground(c);
- }
-
public Color getBackground()
{
return bg;
@@ -1290,7 +1167,10 @@ public class GdkGraphics2D extends Graphics2D
(int) (a.getAlpha() * ((float) c.getAlpha()))));
}
else
- throw new java.lang.UnsupportedOperationException();
+ {
+ // FIXME: implement general Composite support
+ throw new java.lang.UnsupportedOperationException();
+ }
}
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
@@ -1355,36 +1235,6 @@ public class GdkGraphics2D extends Graphics2D
|| hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
}
- public void setRenderingHintsUnlocked(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);
-
- else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR))
- cairoSurfaceSetFilterUnlocked(1);
- }
-
- if (hints.containsKey(RenderingHints.KEY_ALPHA_INTERPOLATION))
- {
- if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED))
- cairoSurfaceSetFilterUnlocked(2);
-
- else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY))
- cairoSurfaceSetFilterUnlocked(3);
-
- else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT))
- cairoSurfaceSetFilterUnlocked(4);
- }
-
- shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
- || hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
- }
-
public void addRenderingHints(Map hints)
{
this.hints.add(new RenderingHints(hints));
@@ -1657,11 +1507,6 @@ public class GdkGraphics2D extends Graphics2D
.getFont(f.getName(), f.getAttributes());
}
- public void setFontUnlocked(Font f)
- {
- setFont (f);
- }
-
public String toString()
{
return (getClass().getName()
diff --git a/gnu/java/awt/peer/gtk/GdkTextLayout.java b/gnu/java/awt/peer/gtk/GdkTextLayout.java
index c3ae581b1..9189bd4b7 100644
--- a/gnu/java/awt/peer/gtk/GdkTextLayout.java
+++ b/gnu/java/awt/peer/gtk/GdkTextLayout.java
@@ -201,60 +201,9 @@ 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 ();
- }
- }
- }
+ // we share pango structures directly with GdkGraphics2D
+ GdkGraphics2D gg2 = (GdkGraphics2D) g2;
+ gg2.drawGdkTextLayout(this, x, y);
}
public TextHitInfo getStrongCaret (TextHitInfo hit1,
diff --git a/gnu/java/awt/peer/gtk/GtkCanvasPeer.java b/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
index 797d653d2..edfc9ceee 100644
--- a/gnu/java/awt/peer/gtk/GtkCanvasPeer.java
+++ b/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/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index 1a85de5fe..3e464ab1a 100644
--- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/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())
@@ -212,10 +208,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);
+ image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();
g.setColor(getBackground());
@@ -247,10 +240,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 new GdkGraphics2D (this);
}
public Point getLocationOnScreen ()
diff --git a/gnu/java/awt/peer/gtk/GtkImage.java b/gnu/java/awt/peer/gtk/GtkImage.java
index 5e5f1de01..83ce2cbef 100644
--- a/gnu/java/awt/peer/gtk/GtkImage.java
+++ b/gnu/java/awt/peer/gtk/GtkImage.java
@@ -168,7 +168,7 @@ public class GtkImage extends Image
* Should be called with the GdkPixbufDecoder.pixbufLock held.
* Also acquires global gdk lock for drawing.
*/
- private native void drawPixelsScaled (GdkGraphics gc,
+ private native void drawPixelsScaled (GdkGraphics2D gc,
int bg_red, int bg_green, int bg_blue,
int x, int y, int width, int height,
boolean composite);
@@ -178,7 +178,7 @@ public class GtkImage extends Image
* Should be called with the GdkPixbufDecoder.pixbufLock held.
* Also acquires global gdk lock for drawing.
*/
- private native void drawPixelsScaledFlipped (GdkGraphics gc,
+ private native void drawPixelsScaledFlipped (GdkGraphics2D gc,
int bg_red, int bg_green,
int bg_blue,
boolean flipX, boolean flipY,
@@ -466,7 +466,7 @@ public class GtkImage extends Image
if (!isLoaded)
return null;
if (offScreen)
- return new GdkGraphics(this);
+ return null; // FIXME: (Graphics) new GdkGraphics(this);
else
throw new IllegalAccessError("This method only works for off-screen"
+" Images.");
@@ -540,7 +540,7 @@ public class GtkImage extends Image
/**
* Draws an image with eventual scaling/transforming.
*/
- public boolean drawImage (GdkGraphics g, int dx1, int dy1, int dx2, int dy2,
+ public boolean drawImage (GdkGraphics2D g, int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgcolor, ImageObserver observer)
{
@@ -613,7 +613,7 @@ public class GtkImage extends Image
* 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,
+ public boolean drawImage (GdkGraphics2D g, int x, int y, int width, int height,
Color bgcolor, ImageObserver observer)
{
if (addObserver(observer))
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index 7757db0c5..8e342cb92 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/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
@@ -179,10 +160,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
Image image;
try
{
- if (useGraphics2D())
- image = GdkPixbufDecoder.createBufferedImage(filename);
- else
- image = new GtkImage(filename);
+ image = GdkPixbufDecoder.createBufferedImage(filename);
}
catch (IllegalArgumentException iae)
{
@@ -196,11 +174,8 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
Image image;
try
{
- if (useGraphics2D())
- image = GdkPixbufDecoder.createBufferedImage(url);
- else
- image = new GtkImage(url);
- }
+ image = GdkPixbufDecoder.createBufferedImage(url);
+ }
catch (IllegalArgumentException iae)
{
image = null;
@@ -213,10 +188,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
Image image;
try
{
- if (useGraphics2D())
- image = GdkPixbufDecoder.createBufferedImage(producer);
- else
- image = new GtkImage(producer);
+ image = GdkPixbufDecoder.createBufferedImage(producer);
}
catch (IllegalArgumentException iae)
{
@@ -231,16 +203,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);
- }
+ image = GdkPixbufDecoder.createBufferedImage(imagedata,
+ imageoffset,
+ imagelength);
}
catch (IllegalArgumentException iae)
{
diff --git a/gnu/java/lang/management/OperatingSystemMXBeanImpl.java b/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
new file mode 100644
index 000000000..3ba059b36
--- /dev/null
+++ b/gnu/java/lang/management/OperatingSystemMXBeanImpl.java
@@ -0,0 +1,73 @@
+/* OperatingSystemMXBeanImpl.java - Implementation of an operating system bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.lang.management;
+
+import java.lang.management.OperatingSystemMXBean;
+
+/**
+ * Provides access to information about the underlying operating
+ * system.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public final class OperatingSystemMXBeanImpl
+ implements OperatingSystemMXBean
+{
+
+ public String getArch()
+ {
+ return System.getProperty("os.arch");
+ }
+
+ public int getAvailableProcessors()
+ {
+ return Runtime.getRuntime().availableProcessors();
+ }
+
+ public String getName()
+ {
+ return System.getProperty("os.name");
+ }
+
+ public String getVersion()
+ {
+ return System.getProperty("os.version");
+ }
+
+}
diff --git a/gnu/java/lang/management/package.html b/gnu/java/lang/management/package.html
new file mode 100644
index 000000000..fc1bafc0c
--- /dev/null
+++ b/gnu/java/lang/management/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in gnu.java.lang.management package.
+ 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.java.lang.management</title></head>
+
+<body>
+<p>GNU implementations of the Java system management beans.</p>
+
+</body>
+</html>
diff --git a/gnu/java/net/loader/JarURLLoader.java b/gnu/java/net/loader/JarURLLoader.java
index 130c6fc95..1e6b6bdaa 100644
--- a/gnu/java/net/loader/JarURLLoader.java
+++ b/gnu/java/net/loader/JarURLLoader.java
@@ -11,6 +11,7 @@ import java.net.URLStreamHandlerFactory;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
@@ -100,7 +101,7 @@ public final class JarURLLoader extends URLLoader
Iterator it = indexMap.entrySet().iterator();
while (it.hasNext())
{
- LinkedHashMap.Entry entry = (LinkedHashMap.Entry) it.next();
+ Map.Entry entry = (Map.Entry) it.next();
URL subURL = (URL) entry.getKey();
Set prefixes = (Set) entry.getValue();
if (subURL.equals(baseURL))
@@ -206,4 +207,4 @@ public final class JarURLLoader extends URLLoader
{
return classPath;
}
-} \ No newline at end of file
+}
diff --git a/include/Makefile.am b/include/Makefile.am
index 5cda78e88..783ba18ee 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -38,7 +38,6 @@ $(top_srcdir)/include/gnu_xml_libxmlj_transform_GnomeTransformerFactory.h
GTKPEER_H_FILES = \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkFontPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GdkPixbufDecoder.h \
@@ -136,6 +135,7 @@ $(top_srcdir)/include/java_lang_VMSystem.h \
$(top_srcdir)/include/java_lang_reflect_VMArray.h \
$(top_srcdir)/include/java_net_VMInetAddress.h \
$(top_srcdir)/include/java_net_VMNetworkInterface.h \
+$(top_srcdir)/include/java_net_VMURLConnection.h \
$(top_srcdir)/include/java_nio_VMDirectByteBuffer.h \
$(top_srcdir)/include/java_nio_MappedByteBufferImpl.h \
$(top_srcdir)/include/java_util_VMTimeZone.h
@@ -197,6 +197,8 @@ $(top_srcdir)/include/java_net_VMInetAddress.h: $(top_srcdir)/vm/reference/java/
$(JAVAH) -o $@ java.net.VMInetAddress
$(top_srcdir)/include/java_net_VMNetworkInterface.h: $(top_srcdir)/vm/reference/java/net/VMNetworkInterface.java
$(JAVAH) -o $@ java.net.VMNetworkInterface
+$(top_srcdir)/include/java_net_VMURLConnection.h: $(top_srcdir)/vm/reference/java/net/VMURLConnection.java
+ $(JAVAH) -o $@ java.net.VMURLConnection
$(top_srcdir)/include/java_nio_VMDirectByteBuffer.h: $(top_srcdir)/vm/reference/java/nio/VMDirectByteBuffer.java
$(JAVAH) -o $@ java.nio.VMDirectByteBuffer
$(top_srcdir)/include/java_nio_MappedByteBufferImpl.h: $(top_srcdir)/java/nio/MappedByteBufferImpl.java
diff --git a/include/gnu_java_awt_peer_gtk_GdkFontPeer.h b/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
index 900146674..745be47d6 100644
--- a/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
+++ b/include/gnu_java_awt_peer_gtk_GdkFontPeer.h
@@ -13,9 +13,10 @@ 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 jbyteArray JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getTrueTypeTable (JNIEnv *env, jobject, jbyte, jbyte, jbyte, jbyte);
JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_getGlyphVector (JNIEnv *env, jobject, jstring, jobject, jobject);
#ifdef __cplusplus
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphics.h b/include/gnu_java_awt_peer_gtk_GdkGraphics.h
deleted file mode 100644
index 8a87738f2..000000000
--- a/include/gnu_java_awt_peer_gtk_GdkGraphics.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_awt_peer_gtk_GdkGraphics__
-#define __gnu_java_awt_peer_gtk_GdkGraphics__
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initStaticState (JNIEnv *env, jclass);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II (JNIEnv *env, jobject, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeCopyState (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeDispose (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon (JNIEnv *env, jobject, jintArray, jintArray, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon (JNIEnv *env, jobject, jintArray, jintArray, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline (JNIEnv *env, jobject, jintArray, jintArray, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString (JNIEnv *env, jobject, jobject, jstring, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle (JNIEnv *env, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor (JNIEnv *env, jobject, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative (JNIEnv *env, jobject, jint, jint);
-#undef gnu_java_awt_peer_gtk_GdkGraphics_GDK_COPY
-#define gnu_java_awt_peer_gtk_GdkGraphics_GDK_COPY 0L
-#undef gnu_java_awt_peer_gtk_GdkGraphics_GDK_XOR
-#define gnu_java_awt_peer_gtk_GdkGraphics_GDK_XOR 2L
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gnu_java_awt_peer_gtk_GdkGraphics__ */
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h b/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
index 2d29cfc73..6bf66b7aa 100644
--- a/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
+++ b/include/gnu_java_awt_peer_gtk_GdkGraphics2D.h
@@ -11,39 +11,27 @@ extern "C"
#endif
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStaticState (JNIEnv *env, jclass);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStateUnlocked (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II (JNIEnv *env, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState___3III (JNIEnv *env, jobject, jintArray, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_connectSignals (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable (JNIEnv *env, jobject, jobject, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_drawPixels (JNIEnv *env, jobject, jintArray, jint, jint, jint, jdoubleArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked (JNIEnv *env, jobject, jintArray, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels (JNIEnv *env, jobject, jintArray, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_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_GdkGraphics2D_setGradientUnlocked (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_GdkGraphics2D_cairoSave (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRestore (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix (JNIEnv *env, jobject, jdoubleArray);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked (JNIEnv *env, jobject, jdoubleArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked (JNIEnv *env, jobject, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth (JNIEnv *env, jobject, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked (JNIEnv *env, jobject, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin (JNIEnv *env, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked (JNIEnv *env, jobject, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash (JNIEnv *env, jobject, jdoubleArray, jint, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked (JNIEnv *env, jobject, jdoubleArray, jint, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit (JNIEnv *env, jobject, jdouble);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked (JNIEnv *env, jobject, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoMoveTo (JNIEnv *env, jobject, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoLineTo (JNIEnv *env, jobject, jdouble, jdouble);
diff --git a/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h b/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
index 44ab6870c..e774713a7 100644
--- a/include/gnu_java_awt_peer_gtk_GtkCanvasPeer.h
+++ b/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/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h b/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
index 207e08d05..f2014595f 100644
--- a/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
+++ b/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/include/java_net_VMURLConnection.h b/include/java_net_VMURLConnection.h
new file mode 100644
index 000000000..270a14a75
--- /dev/null
+++ b/include/java_net_VMURLConnection.h
@@ -0,0 +1,22 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __java_net_VMURLConnection__
+#define __java_net_VMURLConnection__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_java_net_VMURLConnection_init (JNIEnv *env, jclass);
+JNIEXPORT jstring JNICALL Java_java_net_VMURLConnection_guessContentTypeFromBuffer (JNIEnv *env, jclass, jbyteArray, jint);
+#undef java_net_VMURLConnection_LENGTH
+#define java_net_VMURLConnection_LENGTH 1024L
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __java_net_VMURLConnection__ */
diff --git a/java/awt/Graphics2D.java b/java/awt/Graphics2D.java
index 53d7ca5e6..a833038c3 100644
--- a/java/awt/Graphics2D.java
+++ b/java/awt/Graphics2D.java
@@ -62,7 +62,7 @@ import java.util.Map;
* <code>Graphics2D</code> (*);</li>
* <li>a {@link BufferedImage} - see
* {@link BufferedImage#createGraphics()} (*);</li>
- * <li>a {@link PrinterJob} - in the
+ * <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>
diff --git a/java/awt/Window.java b/java/awt/Window.java
index aa0689ce8..4861dd0a4 100644
--- a/java/awt/Window.java
+++ b/java/awt/Window.java
@@ -42,6 +42,7 @@ import gnu.classpath.NotImplementedException;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
@@ -132,33 +133,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 +144,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.
diff --git a/java/awt/dnd/DragGestureRecognizer.java b/java/awt/dnd/DragGestureRecognizer.java
index f855ba63f..759ec9ac2 100644
--- a/java/awt/dnd/DragGestureRecognizer.java
+++ b/java/awt/dnd/DragGestureRecognizer.java
@@ -1,5 +1,5 @@
/* DragGestureRecognizer.java --
- Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -132,7 +132,7 @@ public abstract class DragGestureRecognizer implements Serializable
public void resetRecognizer()
throws NotImplementedException
{
- throw new Error("not implemented");
+ events = new ArrayList();
}
/**
@@ -156,10 +156,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/java/beans/beancontext/BeanContextSupport.java b/java/beans/beancontext/BeanContextSupport.java
index f3d5ff609..a12c078df 100644
--- a/java/beans/beancontext/BeanContextSupport.java
+++ b/java/beans/beancontext/BeanContextSupport.java
@@ -1,5 +1,5 @@
/* BeanContextSupport.java --
- Copyright (C) 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@ package java.beans.beancontext;
import gnu.classpath.NotImplementedException;
+import java.beans.Beans;
import java.beans.DesignMode;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -59,7 +60,12 @@ import java.util.Iterator;
import java.util.Locale;
/**
+ * This is a helper class for implementing a bean context. It is
+ * intended to be used either by subclassing or by calling methods
+ * of this implementation from another.
+ *
* @author Michael Koch
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.2
*/
public class BeanContextSupport extends BeanContextChildSupport
@@ -180,27 +186,102 @@ public class BeanContextSupport extends BeanContextChildSupport
initialize ();
}
- public boolean add (Object targetChild)
+ /**
+ * <p>
+ * Add a child to the bean context. A child can be a simple
+ * <code>Object</code>, a <code>BeanContextChild</code>
+ * or another <code>BeanContext</code>.
+ * </p>
+ * <p>
+ * The children of a <code>BeanContext</code> form a set. As
+ * a result, this method returns <code>false</code> if the given
+ * object is already a child of this context.
+ * </p>
+ * <p>
+ * If the child is a <code>BeanContextChild</code>, or a proxy
+ * for such a child, the <code>setBeanContext()</code> method
+ * is invoked on the child. If this operation is vetoed by the
+ * child, via throwing a <code>PropertyVetoException</code>,
+ * then the current completion state of the <code>add()</code>
+ * operation is rolled back and a <code>IllegalStateException</code>
+ * is thrown. If the <code>BeanContextChild</code> is successfully
+ * added, then the context registers with its
+ * <code>PropertyChangeListener</code> and
+ * <code>VetoableChangeListener</code> for "beanContext" events.
+ * </p>
+ * <p>
+ * If the child implements <code>java.beans.Visibility</code>,
+ * then its ability to use a GUI is set based on that of
+ * this context.
+ * </p>
+ * <p>
+ * A <code>BeanContextMembershipEvent</code> is fired when the
+ * child is successfully added to the bean context.
+ * </p>
+ * <p>
+ * This method is synchronized over the global hierarchy lock.
+ * </p>
+ *
+ * @param targetChild the child to add.
+ * @return false if the child has already been added.
+ * @throws IllegalArgumentException if the child is null.
+ * @throws IllegalStateException if the child vetos the setting
+ * of its context.
+ */
+ public boolean add(Object targetChild)
{
- if (targetChild == null)
- throw new IllegalArgumentException();
-
- BCSChild child;
- synchronized (children)
- {
- if (children.containsKey(targetChild)
- || ! validatePendingAdd(targetChild))
- return false;
- child = createBCSChild(targetChild, beanContextChildPeer);
- children.put(targetChild, child);
- }
- synchronized (targetChild)
+ synchronized (globalHierarchyLock)
{
- childJustAddedHook(targetChild, child);
+ if (targetChild == null)
+ throw new IllegalArgumentException();
+
+ BCSChild child;
+ synchronized (children)
+ {
+ if (children.containsKey(targetChild)
+ || ! validatePendingAdd(targetChild))
+ return false;
+ child = createBCSChild(targetChild, beanContextChildPeer);
+ children.put(targetChild, child);
+ }
+ synchronized (targetChild)
+ {
+ BeanContextChild bcChild = null;
+ if (targetChild instanceof BeanContextChild)
+ bcChild = (BeanContextChild) targetChild;
+ if (targetChild instanceof BeanContextProxy)
+ bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy();
+ if (bcChild != null)
+ try
+ {
+ bcChild.setBeanContext(this);
+ bcChild.addVetoableChangeListener("beanContext", this);
+ bcChild.addPropertyChangeListener("beanContext", this);
+ }
+ catch (PropertyVetoException e)
+ {
+ synchronized (children)
+ {
+ children.remove(targetChild);
+ }
+ throw new IllegalStateException("The child refused to " +
+ "associate itself with " +
+ "this context.", e);
+ }
+ if (targetChild instanceof Visibility)
+ {
+ Visibility visibleChild = (Visibility) targetChild;
+ if (okToUseGui)
+ visibleChild.okToUseGui();
+ else
+ visibleChild.dontUseGui();
+ }
+ childJustAddedHook(targetChild, child);
+ }
+ fireChildrenAdded(new BeanContextMembershipEvent(this,
+ new Object[]{ targetChild }));
+ return true;
}
- fireChildrenAdded(new BeanContextMembershipEvent(this,
- new Object[] { targetChild }));
- return true;
}
public boolean addAll (Collection c)
@@ -219,10 +300,18 @@ public class BeanContextSupport extends BeanContextChildSupport
}
}
- public boolean avoidingGui ()
+ /**
+ * Returns true if this bean needs a GUI
+ * but is being prevented from using one.
+ *
+ * @return true if <code>needsGui()</code>
+ * is true but the bean has been
+ * told not to use it.
+ */
+ public boolean avoidingGui()
throws NotImplementedException
{
- throw new Error ("Not implemented");
+ return needsGui() && (!okToUseGui);
}
protected Iterator bcsChildren ()
@@ -321,10 +410,13 @@ public class BeanContextSupport extends BeanContextChildSupport
throw new Error ("Not implemented");
}
- public void dontUseGui ()
- throws NotImplementedException
+ /**
+ * Informs this bean that is should not make
+ * use of the GUI.
+ */
+ public void dontUseGui()
{
- throw new Error ("Not implemented");
+ okToUseGui = false;
}
protected final void fireChildrenAdded (BeanContextMembershipEvent bcme)
@@ -426,10 +518,20 @@ public class BeanContextSupport extends BeanContextChildSupport
children = new HashMap();
}
+ /**
+ * This is a convenience method for instantiating a bean inside this
+ * context. It delegates to the appropriate method in
+ * <code>java.beans.Beans</code> using the context's classloader.
+ *
+ * @param beanName the name of the class of bean to instantiate.
+ * @throws IOException if an I/O error occurs in loading the class.
+ * @throws ClassNotFoundException if the class, <code>beanName</code>,
+ * can not be found.
+ */
public Object instantiateChild (String beanName)
- throws IOException, ClassNotFoundException, NotImplementedException
+ throws IOException, ClassNotFoundException
{
- throw new Error ("Not implemented");
+ return Beans.instantiate(getClass().getClassLoader(), beanName, this);
}
public boolean isDesignTime ()
@@ -437,6 +539,11 @@ public class BeanContextSupport extends BeanContextChildSupport
return designTime;
}
+ /**
+ * Returns true if this bean context has no children.
+ *
+ * @return true if there are no children.
+ */
public boolean isEmpty ()
{
synchronized (children)
@@ -459,22 +566,38 @@ public class BeanContextSupport extends BeanContextChildSupport
}
}
- public boolean needsGui ()
- throws NotImplementedException
+ /**
+ * Returns false as this bean does not a
+ * GUI for its operation.
+ *
+ * @return false
+ */
+ public boolean needsGui()
{
- throw new Error ("Not implemented");
+ return false;
}
+ /**
+ * Informs this bean that it is okay to make use of
+ * the GUI.
+ */
public void okToUseGui ()
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ okToUseGui = true;
}
+ /**
+ * Subclasses may use this method to catch property changes
+ * arising from the children of this context. At present,
+ * we just listen for the beans being assigned to a different
+ * context and remove them from here if such an event occurs.
+ *
+ * @param pce the property change event.
+ */
public void propertyChange (PropertyChangeEvent pce)
- throws NotImplementedException
{
- throw new Error ("Not implemented");
+ if (pce.getNewValue() != this)
+ remove(pce.getSource(), false);
}
public final void readChildren (ObjectInputStream ois)
@@ -483,18 +606,100 @@ public class BeanContextSupport extends BeanContextChildSupport
throw new Error ("Not implemented");
}
+ /**
+ * Remove the specified child from the context. This is
+ * the same as calling <code>remove(Object,boolean)</code>
+ * with a request for the <code>setBeanContext()</code> method
+ * of the child to be called (i.e. the second argument is true).
+ *
+ * @param targetChild the child to remove.
+ */
public boolean remove (Object targetChild)
{
return remove(targetChild, true);
}
+ /**
+ * <p>
+ * Removes a child from the bean context. A child can be a simple
+ * <code>Object</code>, a <code>BeanContextChild</code>
+ * or another <code>BeanContext</code>. If the given child is not
+ * a child of this context, this method returns <code>false</code>.
+ * </p>
+ * <p>
+ * If the child is a <code>BeanContextChild</code>, or a proxy
+ * for such a child, the <code>setBeanContext()</code> method
+ * is invoked on the child (if specified). If this operation is vetoed
+ * by the child, via throwing a <code>PropertyVetoException</code>,
+ * then the current completion state of the <code>remove()</code>
+ * operation is rolled back and a <code>IllegalStateException</code>
+ * is thrown. If the <code>BeanContextChild</code> is successfully
+ * removed, then the context deregisters with its
+ * <code>PropertyChangeListener</code> and
+ * <code>VetoableChangeListener</code> for "beanContext" events.
+ * </p>
+ * <p>
+ * A <code>BeanContextMembershipEvent</code> is fired when the
+ * child is successfully removed from the bean context.
+ * </p>
+ * <p>
+ * This method is synchronized over the global hierarchy lock.
+ * </p>
+ *
+ * @param targetChild the child to add.
+ * @param callChildSetBC true if the <code>setBeanContext()</code>
+ * method of the child should be called.
+ * @return false if the child doesn't exist.
+ * @throws IllegalArgumentException if the child is null.
+ * @throws IllegalStateException if the child vetos the setting
+ * of its context.
+ */
protected boolean remove (Object targetChild, boolean callChildSetBC)
- throws NotImplementedException
{
- if (targetChild == null)
- throw new IllegalArgumentException();
-
- throw new Error ("Not implemented");
+ synchronized (globalHierarchyLock)
+ {
+ if (targetChild == null)
+ throw new IllegalArgumentException();
+
+ BCSChild child;
+ synchronized (children)
+ {
+ if (!children.containsKey(targetChild)
+ || !validatePendingRemove(targetChild))
+ return false;
+ child = (BCSChild) children.remove(targetChild);
+ }
+ synchronized (targetChild)
+ {
+ BeanContextChild bcChild = null;
+ if (targetChild instanceof BeanContextChild)
+ bcChild = (BeanContextChild) targetChild;
+ if (targetChild instanceof BeanContextProxy)
+ bcChild = ((BeanContextProxy) targetChild).getBeanContextProxy();
+ if (bcChild != null)
+ try
+ {
+ if (callChildSetBC)
+ bcChild.setBeanContext(null);
+ bcChild.removeVetoableChangeListener("beanContext", this);
+ bcChild.removePropertyChangeListener("beanContext", this);
+ }
+ catch (PropertyVetoException e)
+ {
+ synchronized (children)
+ {
+ children.put(targetChild, child);
+ }
+ throw new IllegalStateException("The child refused to " +
+ "disassociate itself with " +
+ "this context.", e);
+ }
+ childJustRemovedHook(targetChild, child);
+ }
+ fireChildrenRemoved(new BeanContextMembershipEvent(this,
+ new Object[]{ targetChild }));
+ return true;
+ }
}
public boolean removeAll (Collection c)
@@ -578,10 +783,16 @@ public class BeanContextSupport extends BeanContextChildSupport
return true;
}
+ /**
+ * Subclasses may use this method to veto changes arising
+ * from the children of this context.
+ *
+ * @param pce the vetoable property change event fired.
+ */
public void vetoableChange (PropertyChangeEvent pce)
- throws PropertyVetoException, NotImplementedException
+ throws PropertyVetoException
{
- throw new Error ("Not implemented");
+ /* Purposefully left empty */
}
public final void writeChildren (ObjectOutputStream oos)
diff --git a/java/io/ObjectStreamConstants.java b/java/io/ObjectStreamConstants.java
index c4af4a03f..a29db2a0e 100644
--- a/java/io/ObjectStreamConstants.java
+++ b/java/io/ObjectStreamConstants.java
@@ -50,8 +50,6 @@ package java.io;
*/
public interface ObjectStreamConstants
{
- // FIXME: Javadoc comment these values.
-
/**
* The serialization stream protocol version 1. This version was
* the default serialization protocol before JDK 1.2.
@@ -70,39 +68,159 @@ public interface ObjectStreamConstants
*/
int PROTOCOL_VERSION_2 = 2;
+ /**
+ * The magic number that is written as part of the stream header.
+ */
short STREAM_MAGIC = (short)0xaced;
+
+ /**
+ * The stream version number that is written as part of the stream header.
+ * Note that this is different from the protocol version that specifies
+ * the data format for the stream.
+ */
short STREAM_VERSION = 5;
+ /**
+ * Token value to designate a <code>null</code> reference in the stream.
+ */
byte TC_NULL = (byte)112; //0x70
+
+ /**
+ * Token value to designate a reference to an already serialized object.
+ */
byte TC_REFERENCE = (byte)113; //0x71
+
+ /**
+ * Token value to designate a class descriptor is next in the stream.
+ */
byte TC_CLASSDESC = (byte)114; //0x72
+
+ /**
+ * Token value to designate a new object is next in the stream.
+ */
byte TC_OBJECT = (byte)115; //0x73
+
+ /**
+ * Token value to designate a new string is next in the stream.
+ */
byte TC_STRING = (byte)116; //0x74
+
+ /**
+ * Token value to designate a new array is next in the stream.
+ */
byte TC_ARRAY = (byte)117; //0x75
+
+ /**
+ * Token reference to designate a reference to a class.
+ */
byte TC_CLASS = (byte)118; //0x76
+
+ /**
+ * Token value to designate a block of primitive data is next in the stream.
+ * The next byte in the stream holds the size of the block (in bytes).
+ */
byte TC_BLOCKDATA = (byte)119; //0x77
+
+ /**
+ * Token value to designate the end of a block of primitve data.
+ */
byte TC_ENDBLOCKDATA = (byte)120; //0x78
+
+ /**
+ * Token value to designate a reset of the stream state.
+ */
byte TC_RESET = (byte)121; //0x79
+
+ /**
+ * Token value to designate a long block of primitive data is next in the
+ * stream. The next long in the stream holds the size of the block
+ * (in bytes).
+ */
byte TC_BLOCKDATALONG = (byte)122; //0x7A
+
+ /**
+ * Token value to designate an exception occured during serialization.
+ */
byte TC_EXCEPTION = (byte)123; //0x7B
+
+ /**
+ * Token value to designate a long string is next in the stream.
+ */
byte TC_LONGSTRING = (byte)124; //0x7C
+
+ /**
+ * Token value to designate a proxy class descriptor is next in the stream.
+ */
byte TC_PROXYCLASSDESC = (byte)125; //0x7D
- byte TC_ENUM = (byte)126; //0x7E
+ /**
+ * Token value to designate an enum constant is next in the stream.
+ *
+ * @since 1.5
+ */
+ byte TC_ENUM = (byte)126; //0x7E
+
+ /**
+ * The first token value.
+ */
byte TC_BASE = TC_NULL;
+
+ /**
+ * The last token value.
+ */
byte TC_MAX = TC_ENUM;
+ /**
+ * The first handle that will be assigned to an object, for later references.
+ */
int baseWireHandle = 0x7e0000;
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * defines the <code>writeObject</code> method.
+ */
byte SC_WRITE_METHOD = 0x01;
+
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * is serializeable.
+ */
byte SC_SERIALIZABLE = 0x02;
+
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * is externalizable.
+ */
byte SC_EXTERNALIZABLE = 0x04;
+
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that
+ * externalizable data is written in block data mode.
+ *
+ * @since 1.2
+ */
byte SC_BLOCK_DATA = 0x08;
- byte SC_ENUM = 0x10;
+ /**
+ * Flag used in <code>ObjectStreamClass</code> to designate that the class
+ * is an enum constant.
+ *
+ * @since 1.5
+ */
+ byte SC_ENUM = 0x10;
+
+ /**
+ * Constant for use with a <code>SecurityManager</code> to check if
+ * substitution of objects is allowed.
+ */
SerializablePermission SUBSTITUTION_PERMISSION
= new SerializablePermission("enableSubstitution");
+ /**
+ * Constant for use with a <code>SecurityManager</code> to check if
+ * overriding of the <code>writeObject</code> and <code>readObject</code>
+ * methods is allowed.
+ */
SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION
= new SerializablePermission("enableSubclassImplementation");
}
diff --git a/java/lang/management/ManagementFactory.java b/java/lang/management/ManagementFactory.java
new file mode 100644
index 000000000..d070f719c
--- /dev/null
+++ b/java/lang/management/ManagementFactory.java
@@ -0,0 +1,81 @@
+/* ManagementFactory.java - Factory for obtaining system beans.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+import gnu.java.lang.management.OperatingSystemMXBeanImpl;
+
+/**
+ * <p>
+ * Provides access to the system's management beans via a series
+ * of static methods.
+ * </p>
+ * <p>
+ * An instance of a system management bean can be obtained by
+ * using one of the following methods:
+ * </p>
+ * <ol>
+ * <li>Calling the appropriate static method of this factory.
+ * </li>
+ * </ol>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ManagementFactory
+{
+
+ /**
+ * The operating system management bean.
+ */
+ private static OperatingSystemMXBean osBean;
+
+ /**
+ * Returns the operating system management bean for the
+ * operating system on which the virtual machine is running.
+ *
+ * @return an instance of {@link OperatingSystemMXBean} for
+ * the underlying operating system.
+ */
+ public static OperatingSystemMXBean getOperatingSystemMXBean()
+ {
+ if (osBean == null)
+ osBean = new OperatingSystemMXBeanImpl();
+ return osBean;
+ }
+
+}
diff --git a/java/lang/management/OperatingSystemMXBean.java b/java/lang/management/OperatingSystemMXBean.java
new file mode 100644
index 000000000..74b9ae5a1
--- /dev/null
+++ b/java/lang/management/OperatingSystemMXBean.java
@@ -0,0 +1,103 @@
+/* OperatingSystemMXBean.java - Interface for an operating system bean
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.lang.management;
+
+/**
+ * Provides access to information about the underlying operating
+ * system. Instances of this bean are obtained by calling
+ * {@link ManagementFactory#getOperatingSystemMXBean()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface OperatingSystemMXBean
+{
+
+ /**
+ * Returns the name of the underlying system architecture. This
+ * is equivalent to obtaining the <code>os.arch</code> property
+ * via {@link System#getProperty(String)}.
+ *
+ * @return the name of the underlying system architecture on which
+ * the VM is running.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the name property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getArch();
+
+ /**
+ * Returns the number of processors currently available to the
+ * virtual machine. This number is subject to change during
+ * execution of the virtual machine, and will always be >= 1.
+ * The call is equivalent to {@link Runtime#availableProcessors()}.
+ *
+ * @return the number of processors available to the VM.
+ */
+ int getAvailableProcessors();
+
+ /**
+ * Returns the name of the underlying operating system. This
+ * is equivalent to obtaining the <code>os.name</code> property
+ * via {@link System#getProperty(String)}.
+ *
+ * @return the name of the operating system on which the VM
+ * is running.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the name property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getName();
+
+ /**
+ * Returns the version of the underlying operating system. This
+ * is equivalent to obtaining the <code>os.version</code> property
+ * via {@link System#getProperty(String)}.
+ *
+ * @return the version of the operating system on which the VM
+ * is running.
+ * @throws SecurityException if a security manager exists which
+ * prevents access to the name property.
+ * @see java.lang.System#getProperty(String)
+ * @see java.lang.SecurityManager#checkPropertyAccess(String)
+ */
+ String getVersion();
+
+}
diff --git a/java/lang/management/package.html b/java/lang/management/package.html
new file mode 100644
index 000000000..1b37cc1a5
--- /dev/null
+++ b/java/lang/management/package.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.lang.management package.
+ 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 - java.lang.management</title></head>
+
+<body>
+
+<p>
+A series of management beans which provide access to information about the
+virtual machine and its underlying operating system.
+</p>
+<p>The following beans are provided:</p>
+<ul>
+<li>
+<span style="font-weight: bold;">{@link java.lang.management.OperatingSystemMXBean} </span>
+&mdash; Information about the underlying operating system.
+</li>
+</ul>
+<h2>Accessing the Beans</h2>
+<p>
+An instance of a bean can be obtained by using one of the following methods:
+</p>
+<ol>
+<li>Calling the appropriate static method of the {@link java.lang.management.ManagementFactory}
+</li>
+</ol>
+</body>
+</html>
diff --git a/java/math/BigInteger.java b/java/math/BigInteger.java
index 6edd48392..0a683f7b7 100644
--- a/java/math/BigInteger.java
+++ b/java/math/BigInteger.java
@@ -1162,7 +1162,7 @@ public class BigInteger extends Number implements Comparable<BigInteger>
throw new ArithmeticException("non-positive modulo");
if (exponent.isNegative())
- return modInverse(m);
+ return modInverse(m).modPow(exponent.negate(), m);
if (exponent.isOne())
return mod(m);
diff --git a/java/net/URLConnection.java b/java/net/URLConnection.java
index a17ba2e20..325ff2329 100644
--- a/java/net/URLConnection.java
+++ b/java/net/URLConnection.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.net;
-import gnu.classpath.NotImplementedException;
import gnu.classpath.SystemProperties;
import java.io.IOException;
@@ -972,11 +971,12 @@ public abstract class URLConnection
* @exception IOException If an error occurs
*/
public static String guessContentTypeFromStream(InputStream is)
- throws IOException, NotImplementedException
+ throws IOException
{
- // See /etc/gnome-vfs-mime-magic or /etc/mime-magic for a reasonable
- // idea of how to handle this.
- return "application/octet-stream";
+ String result = VMURLConnection.guessContentTypeFromStream(is);
+ if (result == null)
+ return "application/octet-stream";
+ return result;
}
/**
diff --git a/java/nio/CharBuffer.java b/java/nio/CharBuffer.java
index 751e1cec3..34f429f62 100644
--- a/java/nio/CharBuffer.java
+++ b/java/nio/CharBuffer.java
@@ -109,14 +109,12 @@ public abstract class CharBuffer extends Buffer
{
// FIXME: implement better handling of java.lang.String.
// Probably share data with String via reflection.
-
- if ((start < 0)
- || (start > seq.length())
- || (end < start)
- || (end > (seq.length() - start)))
- throw new IndexOutOfBoundsException();
-
+
int len = end - start;
+
+ if( len < 0 )
+ throw new IndexOutOfBoundsException();
+
char[] buffer = new char[len];
for (int i = 0; i < len; i++)
diff --git a/java/util/logging/FileHandler.java b/java/util/logging/FileHandler.java
index cde861916..357d51e14 100644
--- a/java/util/logging/FileHandler.java
+++ b/java/util/logging/FileHandler.java
@@ -192,6 +192,42 @@ public class FileHandler
extends StreamHandler
{
/**
+ * A literal that prefixes all file-handler related properties in the
+ * logging.properties file.
+ */
+ private static final String PROPERTY_PREFIX = "java.util.logging.FileHandler";
+ /**
+ * The name of the property to set for specifying a file naming (incl. path)
+ * pattern to use with rotating log files.
+ */
+ private static final String PATTERN_KEY = PROPERTY_PREFIX + ".pattern";
+ /**
+ * The default pattern to use when the <code>PATTERN_KEY</code> property was
+ * not specified in the logging.properties file.
+ */
+ private static final String DEFAULT_PATTERN = "%h/java%u.log";
+ /**
+ * The name of the property to set for specifying an approximate maximum
+ * amount, in bytes, to write to any one log output file. A value of zero
+ * (which is the default) implies a no limit.
+ */
+ private static final String LIMIT_KEY = PROPERTY_PREFIX + ".limit";
+ private static final int DEFAULT_LIMIT = 0;
+ /**
+ * The name of the property to set for specifying how many output files to
+ * cycle through. The default value is 1.
+ */
+ private static final String COUNT_KEY = PROPERTY_PREFIX + ".count";
+ private static final int DEFAULT_COUNT = 1;
+ /**
+ * The name of the property to set for specifying whether this handler should
+ * append, or not, its output to existing files. The default value is
+ * <code>false</code> meaning NOT to append.
+ */
+ private static final String APPEND_KEY = PROPERTY_PREFIX + ".append";
+ private static final boolean DEFAULT_APPEND = false;
+
+ /**
* The number of bytes a log file is approximately allowed to reach
* before it is closed and the handler switches to the next file in
* the rotating set. A value of zero means that files can grow
@@ -252,16 +288,10 @@ public class FileHandler
public FileHandler()
throws IOException, SecurityException
{
- this(/* pattern: use configiguration */ null,
-
- LogManager.getIntProperty("java.util.logging.FileHandler.limit",
- /* default */ 0),
-
- LogManager.getIntProperty("java.util.logging.FileHandler.count",
- /* default */ 1),
-
- LogManager.getBooleanProperty("java.util.logging.FileHandler.append",
- /* default */ false));
+ this(LogManager.getLogManager().getProperty(PATTERN_KEY),
+ LogManager.getIntProperty(LIMIT_KEY, DEFAULT_LIMIT),
+ LogManager.getIntProperty(COUNT_KEY, DEFAULT_COUNT),
+ LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
}
@@ -269,10 +299,7 @@ public class FileHandler
public FileHandler(String pattern)
throws IOException, SecurityException
{
- this(pattern,
- /* limit */ 0,
- /* count */ 1,
- /* append */ false);
+ this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, DEFAULT_APPEND);
}
@@ -280,10 +307,7 @@ public class FileHandler
public FileHandler(String pattern, boolean append)
throws IOException, SecurityException
{
- this(pattern,
- /* limit */ 0,
- /* count */ 1,
- append);
+ this(pattern, DEFAULT_LIMIT, DEFAULT_COUNT, append);
}
@@ -292,9 +316,7 @@ public class FileHandler
throws IOException, SecurityException
{
this(pattern, limit, count,
- LogManager.getBooleanProperty(
- "java.util.logging.FileHandler.append",
- /* default */ false));
+ LogManager.getBooleanProperty(APPEND_KEY, DEFAULT_APPEND));
}
@@ -350,7 +372,7 @@ public class FileHandler
throws IOException, SecurityException
{
super(/* output stream, created below */ null,
- "java.util.logging.FileHandler",
+ PROPERTY_PREFIX,
/* default level */ Level.ALL,
/* formatter */ null,
/* default formatter */ XMLFormatter.class);
@@ -358,14 +380,14 @@ public class FileHandler
if ((limit <0) || (count < 1))
throw new IllegalArgumentException();
- this.pattern = pattern;
+ this.pattern = pattern != null ? pattern : DEFAULT_PATTERN;
this.limit = limit;
this.count = count;
this.append = append;
this.written = 0;
this.logFiles = new LinkedList ();
- setOutputStream (createFileStream (pattern, limit, count, append,
+ setOutputStream (createFileStream (this.pattern, limit, count, append,
/* generation */ 0));
}
@@ -389,10 +411,9 @@ public class FileHandler
* LogManager configuration property.
*/
if (pattern == null)
- pattern = LogManager.getLogManager().getProperty(
- "java.util.logging.FileHandler.pattern");
+ pattern = LogManager.getLogManager().getProperty(PATTERN_KEY);
if (pattern == null)
- pattern = "%h/java%u.log";
+ pattern = DEFAULT_PATTERN;
if (count > 1 && !has (pattern, 'g'))
pattern = pattern + ".%g";
diff --git a/javax/accessibility/AccessibleContext.java b/javax/accessibility/AccessibleContext.java
index 972f4feae..ee3a5287b 100644
--- a/javax/accessibility/AccessibleContext.java
+++ b/javax/accessibility/AccessibleContext.java
@@ -496,7 +496,7 @@ public abstract class AccessibleContext
}
/**
- * Get any supported accessible compoent. The default implementation returns
+ * Get any supported accessible component. The default implementation returns
* null.
*
* @return the supported component, or null
diff --git a/javax/naming/CompositeName.java b/javax/naming/CompositeName.java
index 46e841b93..612932152 100644
--- a/javax/naming/CompositeName.java
+++ b/javax/naming/CompositeName.java
@@ -47,11 +47,18 @@ import java.util.NoSuchElementException;
import java.util.Vector;
/**
+ * Represents names that may span over several namespaces. For instance,
+ * the composite name http://www.gnu.org/software/classpath/index.html spans
+ * over three namespaces (the protocol http, the web server location
+ * (www.gnu.org) and the index.html location on the server).
+ *
* @author Tom Tromey (tromey@redhat.com)
*/
public class CompositeName implements Name, Cloneable, Serializable
{
private static final long serialVersionUID = 1667768148915813118L;
+
+ private transient Vector elts;
public CompositeName ()
{
@@ -331,6 +338,4 @@ public class CompositeName implements Name, Cloneable, Serializable
for (int i = 0; i < elts.size(); i++)
s.writeObject(elts.get(i));
}
-
- private transient Vector elts;
}
diff --git a/javax/naming/CompoundName.java b/javax/naming/CompoundName.java
index e48a49064..703d44e47 100644
--- a/javax/naming/CompoundName.java
+++ b/javax/naming/CompoundName.java
@@ -48,6 +48,10 @@ import java.util.Properties;
import java.util.Vector;
/**
+ * Represents hierarchical names from the single namespace. For instance,
+ * the path /home/audriusa/classpath/file.txt is the compound name, using
+ * the filesystem namespace.
+ *
* @author Tom Tromey (tromey@redhat.com)
* @date May 16, 2001
*
diff --git a/javax/naming/Context.java b/javax/naming/Context.java
index fe67b231b..86231ca12 100644
--- a/javax/naming/Context.java
+++ b/javax/naming/Context.java
@@ -1,5 +1,5 @@
-/* Context.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+/* Context.java -- A naming context
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,123 +40,453 @@ package javax.naming;
import java.util.Hashtable;
+import javax.naming.directory.InvalidAttributesException;
+
public interface Context
{
- // Property with name of the inital context factory to use
- String INITIAL_CONTEXT_FACTORY
- = "java.naming.factory.initial";
-
- // Property with colon-separated list of object factories to use.
- String OBJECT_FACTORIES
- = "java.naming.factory.object";
-
- // Property with colon-separated list of state factories to use.
- String STATE_FACTORIES
- = "java.naming.factory.state";
-
- // Property with colon-separated list of package prefixes to use.
- String URL_PKG_PREFIXES
- = "java.naming.factory.url.pkgs";
-
- // Property with URL specifying configuration for the service
- // provider to use.
- String PROVIDER_URL
- = "java.naming.provider.url";
+ /**
+ * Property with name of the inital context factory to use
+ */
+ String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial";
+
+ /**
+ * Property with colon-separated list of object factories to use.
+ */
+ String OBJECT_FACTORIES = "java.naming.factory.object";
+
+ /**
+ * Property with colon-separated list of state factories to use.
+ */
+ String STATE_FACTORIES = "java.naming.factory.state";
+
+ /**
+ * Property with colon-separated list of package prefixes to use.
+ */
+ String URL_PKG_PREFIXES = "java.naming.factory.url.pkgs";
+
+ /**
+ * Property with URL specifying configuration for the service provider to use.
+ */
+ String PROVIDER_URL = "java.naming.provider.url";
+
+ /**
+ * Property with the DNS host and domain names to use.
+ */
+ String DNS_URL = "java.naming.dns.url";
+
+ /**
+ * Property with the authoritativeness of the service requested.
+ */
+ String AUTHORITATIVE = "java.naming.authoritative";
+
+ /**
+ * Property with the batch size to use when returning data via the service's
+ * protocol.
+ */
+ String BATCHSIZE = "java.naming.batchsize";
+
+ /**
+ * Property defining how referrals encountered by the service provider are to
+ * be processed.
+ */
+ String REFERRAL = "java.naming.referral";
+
+ /**
+ * Property specifying the security protocol to use.
+ */
+ String SECURITY_PROTOCOL = "java.naming.security.protocol";
+
+ /**
+ * Property specifying the security level to use.
+ */
+ String SECURITY_AUTHENTICATION = "java.naming.security.authentication";
+
+ /**
+ * Property for the identity of the principal for authenticating the caller to
+ * the service.
+ */
+ String SECURITY_PRINCIPAL = "java.naming.security.principal";
+
+ /**
+ * Property specifying the credentials of the principal for authenticating the
+ * caller to the service.
+ */
+ String SECURITY_CREDENTIALS = "java.naming.security.credentials";
+
+ /**
+ * Property for specifying the preferred language to use with the service.
+ */
+ String LANGUAGE = "java.naming.language";
+
+ /**
+ * Property for the initial context constructor to use when searching for
+ * other properties.
+ */
+ String APPLET = "java.naming.applet";
+
+ /**
+ * Give the specified name for the specified object. The passed name must not
+ * be already bound to some other object.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws NameAlreadyBoundException if this name is already used to name some
+ * object.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void bind(Name name, Object obj) throws NamingException;
+
+ /**
+ * Give the specified name for the specified object. The passed name must not
+ * be already bound to some other object.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws NameAlreadyBoundException if this name is already used to name some
+ * object.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void bind(String name, Object obj) throws NamingException;
+
+ /**
+ * Gets the previously named object by name. If the passed name is empty, the
+ * method should return a cloned instance of this naming context.
+ *
+ * @param name the name of the object being searched in this context
+ * @return the named object
+ * @throws NamingException if the naming fails.
+ */
+ Object lookup(Name name) throws NamingException;
+
+ /**
+ * Gets the previously named object by name. If the passed name is empty, the
+ * method should return a cloned instance of this naming context.
+ *
+ * @param name the name of the object being searched in this context
+ * @return the named object
+ * @throws NamingException if the naming fails.
+ */
+ Object lookup(String name) throws NamingException;
+
+ /**
+ * Give the specified name for the specified object. Unlike bind, this method
+ * silently replaces the existing binding for this name, if one exists.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rebind(Name name, Object obj) throws NamingException;
+
+ /**
+ * Give the specified name for the specified object. Unlike bind, this method
+ * silently replaces the existing binding for this name, if one exists.
+ *
+ * @param name the name that will be given to the object (in the scope of this
+ * context).
+ * @param obj the object being named.
+ * @throws InvalidAttributesException if the object does not supply all
+ * required attributes.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rebind(String name, Object obj) throws NamingException;
+
+ /**
+ * Removes the name - object mapping from the current context. This method
+ * returns without action if the name is not bound to an object in the
+ * terminal context, but throws {@link NameNotFoundException} if one of the
+ * intermadiate contexts does not exist.
+ *
+ * @param name the name to be removed
+ * @throws NameNotFoundException if one of the intermediate naming contexts
+ * does not exist. Will not be thrown if just the terminal binding
+ * is missing.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void unbind(Name name) throws NamingException;
+
+ /**
+ * Removes the name - object mapping from the current context. This method
+ * returns without action if the name is not bound to an object in the
+ * terminal context, but throws {@link NameNotFoundException} if one of the
+ * intermadiate contexts does not exist.
+ *
+ * @param name the name to be removed
+ * @throws NameNotFoundException if one of the intermediate naming contexts
+ * does not exist. Will not be thrown if just the terminal binding
+ * is missing.
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void unbind(String name) throws NamingException;
+
+ /**
+ * Renames the existing binding, removing the existing and giving the new name
+ * for the same object.
+ *
+ * @param oldName the existing name of the known object
+ * @param newName the new name of the same object
+ * @throws NameNotFoundException if the oldName is unknown for this context
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rename(Name oldName, Name newName) throws NamingException;
+
+ /**
+ * Renames the existing binding, removing the existing and giving the new name
+ * for the same object.
+ *
+ * @param oldName the existing name of the known object
+ * @param newName the new name of the same object
+ * @throws NameNotFoundException if the oldName is unknown for this context
+ * @throws NamingException if the naming operation has failed due other
+ * reasons.
+ */
+ void rename(String oldName, String newName) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name bindings that are present
+ * the given subcontext. The enumeration elements have the type of
+ * {@link NameClassPair}, providing also information about the class of the
+ * bound object. The behaviour in the case if the bindings are added or
+ * removed later is not defined. The contents of the subcontexts are not
+ * included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration list(Name name) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name bindings that are present
+ * the given subcontext. The enumeration elements have the type of
+ * {@link NameClassPair}, providing also information about the class of the
+ * bound object. The behaviour in the case if the bindings are added or
+ * removed later is not defined. The contents of the subcontexts are not
+ * included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration list(String name) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name - object bindings that
+ * are present the given subcontext. The enumeration elements have the type of
+ * {@link Binding}, providing also information about the class of the bound
+ * object. The behaviour in the case if the bindings are added or removed
+ * later is not defined. The contents of the subcontexts are not included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration listBindings(Name name) throws NamingException;
+
+ /**
+ * Creates and returns the enumeration over the name - object bindings that
+ * are present the given subcontext. The enumeration elements have the type of
+ * {@link Binding}, providing also information about the class of the bound
+ * object. The behaviour in the case if the bindings are added or removed
+ * later is not defined. The contents of the subcontexts are not included.
+ *
+ * @param name the name of the subcontext
+ * @return the enumeration over the names, known for the given subcontext.
+ * @throws NamingException
+ */
+ NamingEnumeration listBindings(String name) throws NamingException;
+
+ /**
+ * Creates the new naming subcontext and binds it to the current (this)
+ * context.
+ *
+ * @param name the name of the new context being created
+ * @return the newly created context, bound to the instance of the context on
+ * that the method has been called
+ * @throws NameAlreadyBoundException if this name is already bound
+ * @throws InvalidAttributesException if the creation of the new context
+ * requires the missing mandatory attributes
+ * @throws NamingException
+ */
+ Context createSubcontext(Name name) throws NamingException;
+
+ /**
+ * Creates the new naming subcontext and binds it to the current (this)
+ * context.
+ *
+ * @param name the name of the new context being created
+ * @return the newly created context, bound to the instance of the context on
+ * that the method has been called
+ * @throws NameAlreadyBoundException if this name is already bound
+ * @throws InvalidAttributesException if the creation of the new context
+ * requires the missing mandatory attributes
+ * @throws NamingException
+ */
+ Context createSubcontext(String name) throws NamingException;
+
+ /**
+ * Removes the naming subcontext from this naming context. Returns without
+ * action if such subcontext does not exist. The context being destroyed must
+ * be empty.
+ *
+ * @param name the name of the subcontext beig removed.
+ * @throws ContextNotEmptyException if the named context is not empty.
+ * @throws NamingException
+ */
+ void destroySubcontext(Name name) throws NamingException;
+
+ /**
+ * Removes the naming subcontext from this naming context. Returns without
+ * action if such subcontext does not exist. The context being destroyed must
+ * be empty.
+ *
+ * @param name the name of the subcontext beig removed.
+ * @throws ContextNotEmptyException if the named context is not empty.
+ * @throws NamingException
+ */
+ void destroySubcontext(String name) throws NamingException;
+
+ /**
+ * Retrieves the named object, not following the link of the terminal atomic
+ * component of the name. If the object, named by the passed name, is not a
+ * link, returns that object itself. The intermediate links, if present, are
+ * followed.
+ *
+ * @param name the name of the object that may be a link, leading to another
+ * object.
+ * @return the named object, not following the terminal link (if present).
+ * @throws NamingException
+ */
+ Object lookupLink(Name name) throws NamingException;
+
+ /**
+ * Retrieves the named object, not following the link of the terminal atomic
+ * component of the name. If the object, named by the passed name, is not a
+ * link, returns that object itself. The intermediate links, if present, are
+ * followed.
+ *
+ * @param name the name of the object that may be a link, leading to another
+ * object.
+ * @return the named object, not following the terminal link (if present).
+ * @throws NamingException
+ */
+ Object lookupLink(String name) throws NamingException;
- // Property with the DNS host and domain names to use.
- String DNS_URL
- = "java.naming.dns.url";
+ /**
+ * Obtains the name parser for parsing the names of the given naming
+ * subcontext.
+ *
+ * @param name the name of the subcontext for that the parser must be obtained
+ * @return the parser to parse the names of that context
+ * @throws NamingException
+ */
+ NameParser getNameParser(Name name) throws NamingException;
+
+ /**
+ * Obtains the name parser for parsing the names of the given naming
+ * subcontext.
+ *
+ * @param name the name of the subcontext for that the parser must be obtained
+ * @return the parser to parse the names of that context
+ * @throws NamingException
+ */
+ NameParser getNameParser(String name) throws NamingException;
- // Property with the authoritativeness of the service requested.
- String AUTHORITATIVE
- = "java.naming.authoritative";
+ /**
+ * Composes the name of this context together with another name, related to
+ * this context.
+ *
+ * @param name a name, defined in the scope of this context
+ * @param prefix a name of this context itself, defined in the scope of some
+ * ancestor
+ * @return the name of the same object as named by the first parameter, but
+ * related to the context of the specified ancestor.
+ * @throws NamingException
+ */
+ Name composeName(Name name, Name prefix) throws NamingException;
+
+ /**
+ * Composes the name of this context together with another name, related to
+ * this context.
+ *
+ * @param name a name, defined in the scope of this context
+ * @param prefix a name of this context itself, defined in the scope of some
+ * ancestor
+ * @return the name of the same object as named by the first parameter, but
+ * related to the context of the specified ancestor.
+ * @throws NamingException
+ */
+ String composeName(String name, String prefix) throws NamingException;
- // Property with the batch size to use when returning data via the
- // service's protocol.
- String BATCHSIZE
- = "java.naming.batchsize";
+ /**
+ * Add new environment property to the environment of this context. Both name
+ * and value of the new property must not be null. If the property is already
+ * defined, is current value is replaced by the propVal.
+ *
+ * @param propName the name of the new property
+ * @param propVal the value of the new property
+ * @return the previous value of this property or null if the property has not
+ * been previously defined
+ * @throws NamingException
+ */
+ Object addToEnvironment(String propName, Object propVal)
+ throws NamingException;
- // Property defining how referrals encountered by the service
- // provider are to be processed.
- String REFERRAL
- = "java.naming.referral";
-
- // Property specifying the security protocol to use.
- String SECURITY_PROTOCOL
- = "java.naming.security.protocol";
-
- // Property specifying the security level to use.
- String SECURITY_AUTHENTICATION
- = "java.naming.security.authentication";
-
- // Property for the identity of the principal for authenticating
- // the caller to the service.
- String SECURITY_PRINCIPAL
- = "java.naming.security.principal";
-
- // Property specifying the credentials of the principal for
- // authenticating the caller to the service.
- String SECURITY_CREDENTIALS
- = "java.naming.security.credentials";
-
- // Property for specifying the preferred language to use with the
- // service.
- String LANGUAGE
- = "java.naming.language";
-
- // Property for the initial context constructor to use when searching
- // for other properties.
- String APPLET
- = "java.naming.applet";
-
- void bind (Name name, Object obj) throws NamingException;
- void bind (String name, Object obj) throws NamingException;
-
- Object lookup (Name name) throws NamingException;
- Object lookup (String name) throws NamingException;
-
- void rebind (Name name, Object obj) throws NamingException;
- void rebind (String name, Object obj) throws NamingException;
-
- void unbind (Name name) throws NamingException;
- void unbind (String name) throws NamingException;
-
- void rename (Name oldName, Name newName) throws NamingException;
- void rename (String oldName, String newName) throws NamingException;
-
- NamingEnumeration<NameClassPair> list (Name name) throws NamingException;
- NamingEnumeration<NameClassPair> list (String name) throws NamingException;
-
- NamingEnumeration<Binding> listBindings (Name name)
- throws NamingException;
- NamingEnumeration<Binding> listBindings (String name)
- throws NamingException;
-
- void destroySubcontext (Name name) throws NamingException;
- void destroySubcontext (String name) throws NamingException;
-
- Context createSubcontext (Name name) throws NamingException;
- Context createSubcontext (String name) throws NamingException;
-
- Object lookupLink (Name name) throws NamingException;
- Object lookupLink (String name) throws NamingException;
-
- NameParser getNameParser (Name name) throws NamingException;
- NameParser getNameParser (String name) throws NamingException;
-
- Name composeName (Name name, Name prefix) throws NamingException;
- String composeName (String name,
- String prefix) throws NamingException;
-
- Object addToEnvironment (String propName,
- Object propVal) throws NamingException;
-
- Object removeFromEnvironment (String propName) throws NamingException;
-
- Hashtable<?, ?> getEnvironment () throws NamingException;
-
- void close () throws NamingException;
-
- String getNameInNamespace () throws NamingException;
+ /**
+ * Removes the property with the given name from the environment. Returns
+ * without action if this property is not defined.
+ *
+ * @param propName the name of the property being removed.
+ * @return the value of the property that has been removed or null if the
+ * property was not defined.
+ * @throws NamingException
+ */
+ Object removeFromEnvironment(String propName) throws NamingException;
+
+ /**
+ * Returns the environment, associated with this naming context. The returned
+ * table should never be modified by the caller. Use {@link #addToEnvironment}
+ * and {@link #removeFromEnvironment} to modify the environement, if needed.
+ *
+ * @return the table, representing the environment of this context
+ * @throws NamingException
+ */
+ Hashtable<?,?> getEnvironment() throws NamingException;
+
+ /**
+ * Releases all resources, associated with this context. The close() method
+ * can be called several times, but after it has been once invoked, it is not
+ * allowed to call any other method of this context,
+ *
+ * @throws NamingException
+ */
+ void close() throws NamingException;
+
+ /**
+ * Returs the full name of this naming context. The returned string is not a
+ * JNDI composite name and should not be passed directly to the methods of the
+ * naming context.
+ *
+ * @return the full name of this naming context, in its own namespace.
+ * @throws OperationNotSupportedException if the naming system, represented by
+ * this context, does not support the notation of the full name.
+ * @throws NamingException
+ */
+ String getNameInNamespace() throws NamingException;
}
-
diff --git a/javax/naming/ContextNotEmptyException.java b/javax/naming/ContextNotEmptyException.java
index acbd46bff..e856341c1 100644
--- a/javax/naming/ContextNotEmptyException.java
+++ b/javax/naming/ContextNotEmptyException.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package javax.naming;
-
+/**
+ * This exception is thrown in response to the attempt to destroy the non
+ * empty context. Only empty contexts (without bindings) can be destroyed.
+ *
+ * @see Context#destroySubcontext
+ */
public class ContextNotEmptyException extends NamingException
{
private static final long serialVersionUID = 1090963683348219877L;
diff --git a/javax/naming/InitialContext.java b/javax/naming/InitialContext.java
index 7e153c5f7..801d1ebb6 100644
--- a/javax/naming/InitialContext.java
+++ b/javax/naming/InitialContext.java
@@ -1,5 +1,5 @@
-/* InitialContext.java --
- Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* InitialContext.java -- Initial naming context.
+ Copyright (C) 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,170 +43,291 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Properties;
import javax.naming.spi.NamingManager;
+/**
+ * The starting context for performing naming operations. All naming operations
+ * are performed in the scope of some context. The initial context is the
+ * starting point for the name resolution.
+ */
public class InitialContext implements Context
{
+ /**
+ * Contains the default initial context. This value is returned by
+ * {@link NamingManager#getInitialContext}. It is set by this method
+ * when calling it first time. The subsequent calls return the value of
+ * this field.
+ */
protected Context defaultInitCtx;
+
+ /**
+ * Indicates if the initial context was obtained by calling
+ * {@link NamingManager#getInitialContext}.
+ */
protected boolean gotDefault = false;
- protected Hashtable<Object, Object> myProps;
- public InitialContext (Hashtable<?, ?> environment)
- throws NamingException
+ /**
+ * The environment, associated with this initial context.
+ */
+ protected Hashtable<String,Object> myProps;
+
+ /**
+ * The list of the properties, to that the second alternative value must
+ * be appended after the colon to the first possible value. Used in
+ * {@link #merge(Hashtable, Hashtable)}
+ */
+ static final HashSet colon_list;
+ static
+ {
+ colon_list = new HashSet();
+ colon_list.add(Context.OBJECT_FACTORIES);
+ colon_list.add(Context.URL_PKG_PREFIXES);
+ colon_list.add(Context.STATE_FACTORIES);
+ };
+
+ /**
+ * The properties that are searched in the agreed places in the
+ * {@link #init(Hashtable)} method.
+ */
+ static final String[] use_properties =
+ {
+ Context.DNS_URL,
+ Context.INITIAL_CONTEXT_FACTORY,
+ Context.OBJECT_FACTORIES,
+ Context.PROVIDER_URL,
+ Context.STATE_FACTORIES,
+ Context.URL_PKG_PREFIXES,
+ };
+
+
+ /**
+ * Creates the new initial context with the given properties.
+ *
+ * @param environment the properties, used by the initial context being
+ * created.
+ * @throws NamingException
+ */
+ public InitialContext(Hashtable<?,?> environment) throws NamingException
{
- init (environment);
+ init(environment);
}
- protected InitialContext (boolean lazy)
- throws NamingException
+ /**
+ * Creates the initial context with the possibility to delay its
+ * initialisation.
+ *
+ * @param lazy specified if the initialization should not be performed by this
+ * constructor (true). If the valueis false, it works the same way as
+ * the parameterless constructor.
+ * @throws NamingException
+ */
+ protected InitialContext(boolean lazy) throws NamingException
{
if (! lazy)
- init (null);
+ init(null);
}
- public InitialContext ()
- throws NamingException
+ /**
+ * Creates teh new initial context with no properties. Same as
+ * InitialContext(null).
+ *
+ * @throws NamingException
+ */
+ public InitialContext() throws NamingException
{
- init (null);
+ init(null);
}
- /** @since 1.3 */
- protected void init (Hashtable<?, ?> environment)
- throws NamingException
- {
- // FIXME: Is this enough?
- final String[] properties = {
- Context.DNS_URL,
- Context.INITIAL_CONTEXT_FACTORY,
- Context.OBJECT_FACTORIES,
- Context.PROVIDER_URL,
- Context.STATE_FACTORIES,
- Context.URL_PKG_PREFIXES,
- };
-
- // Create myProps, cloning environment if needed.
+ /**
+ * <p>
+ * Initialises the context, using the properties, specified in the passed
+ * table.
+ * </p>
+ * The missing properties are additionally obtained (in order) from the
+ * following locations:
+ * <ul>
+ * <li>If the passed parameter contains the key Context.APPLET, its value
+ * must be the instance of the {@link Applet}. Then the properties are
+ * requested via {@link Applet#getParameter(String)}.</li>
+ * <li>The value of the system property is used.</li>
+ * <li>The resource "jndi.properties" is requested from the context class
+ * loader of the current thread</li>
+ * <li>The property file "jndi.properties" is read from the location,
+ * specified by the system property "gnu.classpath.home.url".
+ * </ul>
+ * </p>
+ *
+ * @param environment the table of the properties, may be null. The method
+ * modifies the table and stores the reference to it. The caller must
+ * not later reuse this structure for other purposes.
+ * @since 1.3
+ */
+ protected void init(Hashtable environment) throws NamingException
+ {
+ // If is documented that the caller should not modify the environment.
if (environment != null)
- myProps = (Hashtable) environment.clone ();
+ myProps = environment;
else
- myProps = new Hashtable ();
-
- Applet napplet = (Applet) myProps.get (Context.APPLET);
-
- for (int i = properties.length - 1; i >= 0; i--)
+ myProps = new Hashtable<String,Object>();
+
+ Applet napplet = (Applet) myProps.get(Context.APPLET);
+
+ Properties pApplet = null;
+ if (napplet != null)
+ pApplet = new Properties();
+ Properties pSystem = new Properties();
+ Object value;
+
+ for (int i = use_properties.length - 1; i >= 0; i--)
{
- Object o = myProps.get (properties[i]);
-
- if (o == null)
- {
- if (napplet != null)
- o = napplet.getParameter (properties[i]);
- if (o == null)
- o = System.getProperty (properties[i]);
- if (o != null)
- myProps.put (properties[i], o);
- }
+ String key = use_properties[i];
+ if (napplet != null)
+ {
+ value = napplet.getParameter(key);
+ if (value != null)
+ pApplet.put(key, value);
+ }
+
+ value = System.getProperty(key);
+ if (value != null)
+ pSystem.put(key, value);
}
+
+ merge(myProps, pSystem);
+ if (pApplet != null)
+ merge(myProps, pApplet);
try
{
- Enumeration ep = Thread.currentThread().getContextClassLoader().getResources("jndi.naming");
- while (ep.hasMoreElements ())
- {
- URL url = (URL) ep.nextElement ();
- Properties p = new Properties ();
-
- try
- {
- InputStream is = url.openStream ();
- p.load (is);
- is.close ();
- }
- catch (IOException e)
- {
- }
-
- merge (myProps, p);
- }
+ Enumeration ep = Thread.currentThread().
+ getContextClassLoader().getResources("jndi.properties");
+ while (ep.hasMoreElements())
+ {
+ URL url = (URL) ep.nextElement();
+ Properties p = new Properties();
+
+ try
+ {
+ InputStream is = url.openStream();
+ p.load(is);
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // Ignore.
+ }
+
+ merge(myProps, p);
+ }
}
catch (IOException e)
{
+ // Ignore.
}
String home = System.getProperty("gnu.classpath.home.url");
if (home != null)
{
- String url = home + "/jndi.properties";
- Properties p = new Properties ();
-
- try
- {
- InputStream is = new URL(url).openStream();
- p.load (is);
- is.close ();
- }
- catch (IOException e)
- {
- // Ignore.
- }
-
- merge (myProps, p);
+ String url = home + "/jndi.properties";
+ Properties p = new Properties();
+
+ try
+ {
+ InputStream is = new URL(url).openStream();
+ p.load(is);
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // Ignore.
+ }
+
+ merge(myProps, p);
}
}
-
- // FIXME: Is this enough?
- private static final String[] colon_list =
- {
- Context.OBJECT_FACTORIES,
- Context.URL_PKG_PREFIXES,
- Context.STATE_FACTORIES
- };
-
- private static void merge (Hashtable h1, Hashtable h2)
- {
- Enumeration e2 = h2.keys();
+
+ /**
+ * Merge the content of the two tables. If the second table contains the key
+ * that is missing in the first table, this key - value pair is copied to the
+ * first table. If both first and second tables contain the same key AND the
+ * {@link #colon_list} set also contains this key, the value from the second
+ * table is appended to the value from the first table after semicolon, and
+ * the resulted value replaces the value in the first table.
+ *
+ * @param primary the first table to merge. The merged result is also stored
+ * in this table.
+ * @param additional the second table, from where additional values are taken
+ */
+ static void merge (Hashtable primary, Hashtable additional)
+ {
+ Enumeration en = additional.keys();
- while (e2.hasMoreElements())
+ while (en.hasMoreElements())
{
- String key2 = (String) e2.nextElement();
- Object value1 = h1.get(key2);
- if (value1 == null)
- h1.put(key2, h2.get(key2));
- else if (key2.compareTo(colon_list[0]) == 0
- || key2.compareTo(colon_list[1]) == 0
- || key2.compareTo(colon_list[2]) == 0
- || key2.compareTo(colon_list[3]) == 0)
- {
- String value2 = (String) h2.get(key2);
- h1.put(key2, (String) value1 + ":" + value2);
- }
+ String key2 = (String) en.nextElement();
+ Object value1 = primary.get(key2);
+ if (value1 == null)
+ primary.put(key2, additional.get(key2));
+ else if (colon_list.contains(key2))
+ {
+ String value2 = (String) additional.get(key2);
+ primary.put(key2, (String) value1 + ":" + value2);
+ }
}
}
-
- protected Context getDefaultInitCtx () throws NamingException
+
+ /**
+ * Get the default initial context. If {@link #gotDefault} == false, this
+ * method obtains the initial context from the naming manager and sets
+ * gotDefault to true. Otherwise the cached value ({@link #defaultInitCtx} is
+ * returned.
+ *
+ * @return the default initial context
+ * @throws NamingException
+ */
+ protected Context getDefaultInitCtx() throws NamingException
{
if (! gotDefault)
{
- defaultInitCtx = NamingManager.getInitialContext (myProps);
- gotDefault = true;
+ defaultInitCtx = NamingManager.getInitialContext(myProps);
+ gotDefault = true;
}
return defaultInitCtx;
}
-
- protected Context getURLOrDefaultInitCtx (Name name)
- throws NamingException
- {
- if (name.size () > 0)
- return getURLOrDefaultInitCtx (name.get (0));
+ /**
+ * Obtains the context for resolving the given name. If the first component of
+ * the name is the URL string, this method tries to find the corressponding
+ * URL naming context. If it is not an URL string, or the URL context is not
+ * found, the default initial context is returned.
+ *
+ * @param name the name, for that it is required to obtain the context.
+ * @return the context for resolving the name.
+ * @throws NamingException
+ */
+ protected Context getURLOrDefaultInitCtx(Name name) throws NamingException
+ {
+ if (name.size() > 0)
+ return getURLOrDefaultInitCtx(name.get(0));
else
- return getDefaultInitCtx ();
+ return getDefaultInitCtx();
}
- protected Context getURLOrDefaultInitCtx (String name)
- throws NamingException
+ /**
+ * Obtains the context for resolving the given name. If the first component of
+ * the name is the URL string, this method tries to find the corressponding
+ * URL naming context. If it is not an URL string, or the URL context is not
+ * found, the default initial context is returned.
+ *
+ * @param name the name, for that it is required to obtain the context.
+ * @return the context for resolving the name.
+ * @throws NamingException
+ */
+ protected Context getURLOrDefaultInitCtx(String name) throws NamingException
{
String scheme = null;
@@ -214,182 +335,211 @@ public class InitialContext implements Context
return getDefaultInitCtx();
int colon = name.indexOf(':');
int slash = name.indexOf('/');
- if (colon > 0 && (slash == -1 || colon < slash))
+ if (colon > 0 && (slash == - 1 || colon < slash))
scheme = name.substring(0, colon);
- if (scheme != null)
+ if (scheme != null)
{
- Context context =
- NamingManager.getURLContext(scheme, myProps);
- if (context != null)
- return context;
+ Context context = NamingManager.getURLContext(scheme, myProps);
+ if (context != null)
+ return context;
}
-
+
return getDefaultInitCtx();
}
+ /** @inheritDoc */
public void bind (Name name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).bind (name, obj);
}
+ /** @inheritDoc */
public void bind (String name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).bind (name, obj);
}
+ /** @inheritDoc */
public Object lookup (Name name) throws NamingException
{
try
{
- return getURLOrDefaultInitCtx (name).lookup (name);
+ return getURLOrDefaultInitCtx (name).lookup (name);
}
catch (CannotProceedException cpe)
{
- Context ctx = NamingManager.getContinuationContext (cpe);
- return ctx.lookup (cpe.getRemainingName());
+ Context ctx = NamingManager.getContinuationContext (cpe);
+ return ctx.lookup (cpe.getRemainingName());
}
}
+ /** @inheritDoc */
public Object lookup (String name) throws NamingException
{
try
- {
- return getURLOrDefaultInitCtx (name).lookup (name);
- }
+ {
+ return getURLOrDefaultInitCtx (name).lookup (name);
+ }
catch (CannotProceedException cpe)
- {
- Context ctx = NamingManager.getContinuationContext (cpe);
- return ctx.lookup (cpe.getRemainingName());
- }
+ {
+ Context ctx = NamingManager.getContinuationContext (cpe);
+ return ctx.lookup (cpe.getRemainingName());
+ }
}
+ /** @inheritDoc */
public void rebind (Name name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).rebind (name, obj);
}
-
+
+ /** @inheritDoc */
public void rebind (String name, Object obj) throws NamingException
{
getURLOrDefaultInitCtx (name).rebind (name, obj);
}
+ /** @inheritDoc */
public void unbind (Name name) throws NamingException
{
getURLOrDefaultInitCtx (name).unbind (name);
}
+ /** @inheritDoc */
public void unbind (String name) throws NamingException
{
getURLOrDefaultInitCtx (name).unbind (name);
}
+ /** @inheritDoc */
public void rename (Name oldName, Name newName) throws NamingException
{
getURLOrDefaultInitCtx (oldName).rename (oldName, newName);
}
+ /** @inheritDoc */
public void rename (String oldName, String newName) throws NamingException
{
getURLOrDefaultInitCtx (oldName).rename (oldName, newName);
}
- public NamingEnumeration<NameClassPair> list (Name name)
- throws NamingException
+ /** @inheritDoc */
+ public NamingEnumeration list (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).list (name);
}
- public NamingEnumeration<NameClassPair> list (String name)
- throws NamingException
+ /** @inheritDoc */
+ public NamingEnumeration list (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).list (name);
}
- public NamingEnumeration<Binding> listBindings (Name name)
- throws NamingException
+ /** @inheritDoc */
+ public NamingEnumeration listBindings (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).listBindings (name);
}
- public NamingEnumeration<Binding> listBindings (String name)
- throws NamingException
+ /** @inheritDoc */
+ public NamingEnumeration listBindings (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).listBindings (name);
}
+ /** @inheritDoc */
public void destroySubcontext (Name name) throws NamingException
{
getURLOrDefaultInitCtx (name).destroySubcontext (name);
}
+ /** @inheritDoc */
public void destroySubcontext (String name) throws NamingException
{
getURLOrDefaultInitCtx (name).destroySubcontext (name);
}
+ /** @inheritDoc */
public Context createSubcontext (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).createSubcontext (name);
}
+ /** @inheritDoc */
public Context createSubcontext (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).createSubcontext (name);
}
+ /** @inheritDoc */
public Object lookupLink (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).lookupLink (name);
}
+ /** @inheritDoc */
public Object lookupLink (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).lookupLink (name);
}
+ /** @inheritDoc */
public NameParser getNameParser (Name name) throws NamingException
{
return getURLOrDefaultInitCtx (name).getNameParser (name);
}
+ /** @inheritDoc */
public NameParser getNameParser (String name) throws NamingException
{
return getURLOrDefaultInitCtx (name).getNameParser (name);
}
+ /** @inheritDoc */
public Name composeName (Name name, Name prefix) throws NamingException
{
return getURLOrDefaultInitCtx (name).composeName (name, prefix);
}
+ /** @inheritDoc */
public String composeName (String name,
- String prefix) throws NamingException
+ String prefix) throws NamingException
{
return getURLOrDefaultInitCtx (name).composeName (name, prefix);
}
-
+
+ /** @inheritDoc */
public Object addToEnvironment (String propName,
- Object propVal) throws NamingException
+ Object propVal) throws NamingException
{
return myProps.put (propName, propVal);
}
+ /** @inheritDoc */
public Object removeFromEnvironment (String propName) throws NamingException
{
return myProps.remove (propName);
}
- public Hashtable<?, ?> getEnvironment () throws NamingException
+ /** @inheritDoc */
+ public Hashtable<?,?> getEnvironment () throws NamingException
{
return myProps;
}
+ /** @inheritDoc */
public void close () throws NamingException
{
myProps = null;
defaultInitCtx = null;
}
+ /**
+ * This operation is not supported for the initial naming context.
+ *
+ * @throws OperationNotSupportedException always, unless the method is
+ * overridden in the derived class.
+ */
public String getNameInNamespace () throws NamingException
{
throw new OperationNotSupportedException ();
diff --git a/javax/naming/NameParser.java b/javax/naming/NameParser.java
index 1aeaf3600..004b40627 100644
--- a/javax/naming/NameParser.java
+++ b/javax/naming/NameParser.java
@@ -1,5 +1,5 @@
-/* NameParser.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+/* NameParser.java -- JNDI name parser interface
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,24 @@ exception statement from your version. */
package javax.naming;
+/**
+ * Parser the string representation of the given name into the {@link Name}
+ * representation.
+ *
+ * @see Context#getNameParser(String)
+ * @see Context#getNameParser(Name)
+ */
public interface NameParser
-{
+{
+ /**
+ * Parser the string name representation into the {@link Name} representation
+ *
+ * @param name the string representation of the name
+ * @return the {@link Name} representation of the name.
+ * @throws InvalidNameException if the name violates the syntax, expected by
+ * this parser
+ * @throws NamingException if some other naming exception occurs
+ */
Name parse (String name) throws NamingException;
}
diff --git a/javax/naming/NamingEnumeration.java b/javax/naming/NamingEnumeration.java
index 5f299fc98..a7c57706f 100644
--- a/javax/naming/NamingEnumeration.java
+++ b/javax/naming/NamingEnumeration.java
@@ -1,5 +1,5 @@
-/* NamingEnumeration.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+/* NamingEnumeration.java -- The JNDI enumeration
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,50 @@ package javax.naming;
import java.util.Enumeration;
+/**
+ * <p>The specific type of enumeration that supports throwing various exceptions by
+ * the hasMore method. The exceptions are only thrown if the enumeration is
+ * scanned using {@link #next()} and {@link #hasMore()}. If the inherited
+ * {@link java.util.Enumeration#nextElement()} and
+ * {@link Enumeration#hasMoreElements()} are used instead, the exceptions are
+ * not throwed, and the enumeration is just iterated over available elements.
+ * </p>
+ * <p>This enumeration becomes invalid after throwing the exception. If the
+ * exception has been thrown, not other method should be called of that
+ * enumeration.</p>
+ */
public interface NamingEnumeration<T> extends Enumeration<T>
{
- void close() throws NamingException;
- boolean hasMore() throws NamingException;
+ /**
+ * Returns the next element in this enumeration. The naming - specific
+ * exceptions are only throws after returning all still available elements of
+ * the enumeration.
+ *
+ * @return the next element of this enumeration
+ * @throws NamingException
+ */
T next() throws NamingException;
+
+ /**
+ * Checks if there are more unvisited elements in the enumeration, throwing
+ * exceptions if there are some unvisited, but not available elements.
+ *
+ * @return true if there are some unvisited elements, false otherwise.
+ * @throws PartialResultException if the enumeration, returned by the
+ * {@link Context#list(Name)} or other similar method contains only
+ * partial answer.
+ * @throws SizeLimitExceededException if remaining elements are not available
+ * because of the previously specified size limit.
+ * @throws NamingException
+ */
+ boolean hasMore() throws NamingException;
+
+ /**
+ * Immediately frees all resources, owned by this enumeration. If invoked, it
+ * must be the last method called for that enumeration.
+ *
+ * @throws NamingException
+ */
+ void close() throws NamingException;
+
}
diff --git a/javax/naming/PartialResultException.java b/javax/naming/PartialResultException.java
index 61660781f..28f0467fe 100644
--- a/javax/naming/PartialResultException.java
+++ b/javax/naming/PartialResultException.java
@@ -38,7 +38,11 @@ exception statement from your version. */
package javax.naming;
-
+/**
+ * Thrown from the {@link javax.naming.NamingEnumeration}, this exception
+ * indicates that the enumeration represents only part of the existing
+ * elements that would be an answer to the specified request.
+ */
public class PartialResultException extends NamingException
{
private static final long serialVersionUID = 2572144970049426786L;
diff --git a/javax/naming/Reference.java b/javax/naming/Reference.java
index 67e31c056..b5bec2d60 100644
--- a/javax/naming/Reference.java
+++ b/javax/naming/Reference.java
@@ -43,54 +43,118 @@ import java.util.Enumeration;
import java.util.Vector;
/**
+ * This class represents a reference to an object that is located outside of the
+ * naming/directory system.
+ *
+ * @see Referenceable
+ *
* @author Tom Tromey (tromey@redhat.com)
- * @date May 16, 2001
*/
public class Reference implements Cloneable, Serializable
{
private static final long serialVersionUID = - 1673475790065791735L;
-
+
+ /**
+ * The list of addresses, stored in this reference. The object may be
+ * have by several different addresses.
+ */
+ protected Vector addrs;
+
+ /**
+ * The name of the class factory to create an instance of the object,
+ * referenced by this reference.
+ */
+ protected String classFactory;
+
+ /**
+ * The location, from where the class factory should be loaded.
+ */
+ protected String classFactoryLocation;
+
+ /**
+ * The name of the class of the object, to that this reference refers.
+ */
+ protected String className;
+
+ /**
+ * Create a new reference that is referencting to the object of the
+ * specified class.
+ */
public Reference (String className)
{
this.className = className;
addrs = new Vector ();
}
-
+
+ /**
+ * Create a new reference that is referencing to the object of the
+ * specified class with the given address.
+ */
public Reference (String className, RefAddr addr)
{
this.className = className;
addrs = new Vector ();
addrs.add (addr);
}
-
- public Reference (String className, String factory, String factoryLocation)
+
+ /**
+ * Create a new reference that is referencing to the object of the
+ * specified class, specifying the class and location of the factory that
+ * produces these objects.
+ *
+ * @param className the object class name
+ * @param factoryClassName the object factory class name
+ * @param factoryLocation the object factory location
+ */
+ public Reference (String className, String factoryClassName,
+ String factoryLocation)
{
this.className = className;
- this.classFactory = factory;
+ this.classFactory = factoryClassName;
this.classFactoryLocation = factoryLocation;
addrs = new Vector ();
}
+ /**
+ * Create a new reference that is referencing to the object of the
+ * specified class, specifying the class and location of the factory that
+ * produces these objects and also the address of this object.
+ *
+ * @param className the object class name
+ * @param addr the address of the object
+ * @param factoryClassName the object factory class name
+ * @param factoryLocation the object factory location
+ */
public Reference (String className, RefAddr addr,
- String factory, String factoryLocation)
+ String factoryClassName, String factoryLocation)
{
this.className = className;
- this.classFactory = factory;
+ this.classFactory = factoryClassName;
this.classFactoryLocation = factoryLocation;
addrs = new Vector ();
addrs.add (addr);
}
+ /**
+ * Add the new address for this object at the given position of the
+ * address list.
+ */
public void add (int posn, RefAddr addr)
{
addrs.add (posn, addr);
}
-
+
+ /**
+ * Appends the new object address to the end of the address list.
+ */
public void add (RefAddr addr)
{
addrs.add (addr);
}
-
+
+ /**
+ * Removes all defined addresses of the object.
+ */
public void clear ()
{
addrs.clear ();
@@ -109,7 +173,10 @@ public class Reference implements Cloneable, Serializable
{
return (a == null) ? (b == null) : a.equals (b);
}
-
+
+ /**
+ * Compares two addresses for equality, by value.
+ */
public boolean equals (Object obj)
{
if (! (obj instanceof Reference))
@@ -120,12 +187,23 @@ public class Reference implements Cloneable, Serializable
&& equals (className, r.className)
&& addrs.equals (r.addrs));
}
-
+
+ /**
+ * Get the address of this object at the given position.
+ */
public RefAddr get (int posn)
{
return (RefAddr) addrs.get (posn);
}
-
+
+ /**
+ * Get the given type of address for this object.
+ *
+ * @param addrType the needed type of address
+ *
+ * @return the address of this object, having the specified type. If there
+ * is no address of such type, null is returned.
+ */
public RefAddr get (String addrType)
{
for (int i = 0; i < addrs.size (); ++i)
@@ -136,27 +214,50 @@ public class Reference implements Cloneable, Serializable
}
return null;
}
-
+
+ /**
+ * Get the enumeration over all defined addresses of the object.
+ */
public Enumeration<RefAddr> getAll ()
{
return addrs.elements ();
}
-
+
+ /**
+ * Get the name of the class of the referenced object.
+ *
+ * @see #className
+ */
public String getClassName ()
{
return className;
}
-
+
+ /**
+ * Get the location of the factory class of the referenced object.
+ *
+ * @see #classFactoryLocation
+ */
public String getFactoryClassLocation ()
{
return classFactoryLocation;
}
+ /**
+ * Get the name of the factory class of the referenced object
+ *
+ * @see #classFactory
+ */
public String getFactoryClassName ()
{
return classFactory;
}
-
+
+ /**
+ * Get the hashcode of this reference.
+ *
+ * @return the sum of the hash codes of the addresses.
+ */
public int hashCode ()
{
// The spec says the hash code is the sum of the hash codes of the
@@ -166,17 +267,30 @@ public class Reference implements Cloneable, Serializable
h += addrs.get (i).hashCode ();
return h;
}
-
+
+ /**
+ * Remove the address at the given position.
+ *
+ * @param posn the position of the address to remove
+ *
+ * @return the removed address
+ */
public Object remove (int posn)
{
return addrs.remove (posn);
}
-
+
+ /**
+ * Return the number of the defined addresses.
+ */
public int size ()
{
return addrs.size ();
}
-
+
+ /**
+ * Return the string representation.
+ */
public String toString ()
{
String x = getClass ().toString () + "[";
@@ -189,8 +303,4 @@ public class Reference implements Cloneable, Serializable
return x + "]";
}
- protected Vector<RefAddr> addrs;
- protected String classFactory;
- protected String classFactoryLocation;
- protected String className;
}
diff --git a/javax/naming/Referenceable.java b/javax/naming/Referenceable.java
index cf1100aab..21c5238bc 100644
--- a/javax/naming/Referenceable.java
+++ b/javax/naming/Referenceable.java
@@ -1,5 +1,5 @@
/* Referenceable.java --
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,19 @@ exception statement from your version. */
package javax.naming;
+/**
+ * The object, implementing this interface, can provided the
+ * {@link Reference} about itself.
+ */
public interface Referenceable
{
+ /**
+ * Get the reference about this object.
+ *
+ * @return the reference about this object, cannot be null.
+ *
+ * @throws NamingException if the naming exception has been raised while
+ * retrieving the reference.
+ */
Reference getReference() throws NamingException;
}
diff --git a/javax/naming/SizeLimitExceededException.java b/javax/naming/SizeLimitExceededException.java
index 3ca9a23b7..caffa70c3 100644
--- a/javax/naming/SizeLimitExceededException.java
+++ b/javax/naming/SizeLimitExceededException.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package javax.naming;
-
+/**
+ * Thrown from the {@link javax.naming.NamingEnumeration}, this exception
+ * indicates that there are more elements than the previously specified
+ * size limit. Hence the enumeration represents only part of the existing
+ * elements that would be an answer to the specified request.
+ */
public class SizeLimitExceededException extends LimitExceededException
{
private static final long serialVersionUID = 7129289564879168579L;
diff --git a/javax/naming/spi/InitialContextFactory.java b/javax/naming/spi/InitialContextFactory.java
index fea451da5..f715327ef 100644
--- a/javax/naming/spi/InitialContextFactory.java
+++ b/javax/naming/spi/InitialContextFactory.java
@@ -43,8 +43,29 @@ import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
+/**
+ * <p>
+ * Defines a factory that creates the initial context for the beginning of the
+ * name resolution. JNDI allows to specify different implementations of the
+ * initial context at runtime.
+ * </p>
+ * <p>
+ * The class, implementing this interface, must be public and have a public
+ * parameterless constructor
+ * </p>
+ */
public interface InitialContextFactory
{
+ /**
+ * Create a new initial context
+ *
+ * @param environment the properties, used when creating the context. The
+ * implementing class will not modify the table nor keep the
+ * reference to it. After the method returns, the caller can safely
+ * reuse the table for other purposes.
+ * @return the new initial context
+ * @throws NamingException if the naming exception has occured
+ */
Context getInitialContext (Hashtable<?, ?> environment)
throws NamingException;
}
diff --git a/javax/naming/spi/InitialContextFactoryBuilder.java b/javax/naming/spi/InitialContextFactoryBuilder.java
index fef073e8a..31bafe6dc 100644
--- a/javax/naming/spi/InitialContextFactoryBuilder.java
+++ b/javax/naming/spi/InitialContextFactoryBuilder.java
@@ -42,8 +42,25 @@ import java.util.Hashtable;
import javax.naming.NamingException;
+/**
+ * Represents the builder that creates instances of the factories that produce
+ * initial naming contexts. JNDI allows to specifiy different initial contexts
+ * at runtime. The user program can install its own initial context factory
+ * builder.
+ *
+ * @see NamingManager#setInitialContextFactoryBuilder
+ */
public interface InitialContextFactoryBuilder
{
+ /**
+ * Create the new initial context factory
+ *
+ * @param environment the properties, used for creation of the initial
+ * context factory. The parameter is owned by the caller: it is safe to reuse
+ * the table for other purposes after the method returns.
+ * @return the created initial context factory, never null.
+ * @throws NamingException on failure
+ */
InitialContextFactory createInitialContextFactory (Hashtable<?, ?> environment)
throws NamingException;
}
diff --git a/javax/naming/spi/NamingManager.java b/javax/naming/spi/NamingManager.java
index 8fdc39f47..04c119edc 100644
--- a/javax/naming/spi/NamingManager.java
+++ b/javax/naming/spi/NamingManager.java
@@ -1,5 +1,6 @@
-/* NamingManager.java --
- Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* NamingManager.java -- Creates contexts and objects
+ Copyright (C) 2000, 2001, 2002, 2003, 2004,
+ 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,9 +56,10 @@ import javax.naming.Referenceable;
import javax.naming.StringRefAddr;
/**
- * Contains methods for creating context objects and objects referred to by
+ * Contains methods for creating contexts and objects referred to by
* location information. The location is specified in the scope of the
- * certain naming or directory service.
+ * certain naming or directory service. This class only contais static
+ * methods and cannot be instantiated.
*/
public class NamingManager
{
@@ -380,7 +382,58 @@ public class NamingManager
path += ":" + path2;
return new StringTokenizer (path != null ? path : "", ":");
}
-
+
+ /**
+ * <p>Creates an object for the specified name context, environment and
+ * referencing context object.</p>
+ * <p>
+ * If the builder factory is set by
+ * {@link #setObjectFactoryBuilder(ObjectFactoryBuilder)}, the call is
+ * delegated to that factory. Otherwise, the object is created using the
+ * following rules:
+ * <ul>
+ * <li>If the referencing object (refInfo) contains the factory class name,
+ * the object is created by this factory. If the creation fails,
+ * the parameter refInfo is returned as the method return value.</li>
+ * <li>If the referencing object has no factory class name, and the addresses
+ * are StringRefAddrs having the address type "URL", the object is
+ * created by the URL context factory. The used factory corresponds the
+ * the naming schema of the each URL. If the attempt to create
+ * the object this way is not successful, the subsequent rule is
+ * tried.</li>
+ * <li> If the refInfo is not an instance of Reference or Referencable
+ * (for example, null), the object is created by the factories,
+ * specified in the Context.OBJECT_FACTORIES property of the
+ * environment and the provider resource file, associated with the
+ * nameCtx. The value of this property is the colon separated list
+ * of the possible factories. If none of the factories can be
+ * loaded, the refInfo is returned.
+ * </ul>
+ * </p>
+ * <p>The object factory must be public and have the public parameterless
+ * constructor.</p>
+ *
+ * @param refInfo the referencing object, for which the new object must be
+ * created (can be null). If not null, it is usually an instance of
+ * the {@link Reference} or {@link Referenceable}.
+ * @param name the name of the object. The name is relative to
+ * the nameCtx naming context. The value of this parameter can be
+ * null if the name is not specified.
+ * @param nameCtx the naming context, in which scope the name of the new
+ * object is specified. If this parameter is null, the name is
+ * specified in the scope of the initial context.
+ * @param environment contains additional information for creating the object.
+ * This paramter can be null if there is no need to provide any
+ * additional information.
+ *
+ * @return the created object. If the creation fails, in some cases
+ * the parameter refInfo may be returned.
+ *
+ * @throws NamingException if the attempt to name the new object has failed
+ * @throws Exception if the object factory throws it. The object factory
+ * only throws an exception if it does not want other factories
+ * to be used to create the object.
+ */
public static Object getObjectInstance (Object refInfo,
Name name,
Context nameCtx,
@@ -521,7 +574,7 @@ public class NamingManager
if (env != null)
env.put (CPE, cpe);
- // It is really unclear to me if this is right.
+ // TODO: Check if this implementation matches the API specification
try
{
Object obj = getObjectInstance (cpe.getResolvedObj(),
@@ -540,7 +593,22 @@ public class NamingManager
throw cpe;
}
-
+
+ /**
+ * Get the object state for binding.
+ *
+ * @param obj the object, for that the binding state must be retrieved. Cannot
+ * be null.
+ * @param name the name of this object, related to the nameCtx. Can be null if
+ * not specified.
+ * @param nameCtx the naming context, to that the object name is related. Can
+ * be null if the name is related to the initial default context.
+ * @param environment the properties for creating the object state. Can be
+ * null if no properties are provided.
+ * @return the object state for binding, may be null if no changes are
+ * returned by the factory
+ * @throws NamingException
+ */
public static Object getStateToBind (Object obj, Name name,
Context nameCtx, Hashtable<?, ?> environment)
throws NamingException
diff --git a/javax/naming/spi/ObjectFactory.java b/javax/naming/spi/ObjectFactory.java
index 3374742c1..4534481a7 100644
--- a/javax/naming/spi/ObjectFactory.java
+++ b/javax/naming/spi/ObjectFactory.java
@@ -1,5 +1,5 @@
/* ObjectFactory.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,9 +43,34 @@ import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.Name;
+/**
+ * Represents a factory for creating the object. ObjectFactory performs the
+ * operation, that is the opposite to the operation, performed by the
+ * {@link StateFactory}. Classes, implementing this interface, must be public
+ * and have public parameterless constructor.
+ */
public interface ObjectFactory
{
- Object getObjectInstance (Object obj, Name name, Context nameCtx,
+ /**
+ * Creates the object, using the specified name and location information. The
+ * call of this method must be thread safe.
+ *
+ * @param refObj may provide the reference and location information. Can be null.
+ * @param name the name of the new object in the scope of the specified naming
+ * context. Can be null if the name is not specified.
+ * @param nameCtx the context, in which the object name is specified. Can be
+ * null if the name is specified in the scope of the default initial
+ * context.
+ * @param environment the properties, providing additional information on how
+ * to create an object. Can be null if not additional information is
+ * provided.
+ * @return the newly created object or null if the object cannot be created
+ * @throws Exception if this factory suggest not to try creating of this
+ * object by other alternative factories
+ *
+ * @see NamingManager#getObjectInstance(Object, Name, Context, Hashtable)
+ */
+ Object getObjectInstance (Object refObj, Name name, Context nameCtx,
Hashtable<?, ?> environment)
throws Exception;
}
diff --git a/javax/naming/spi/ObjectFactoryBuilder.java b/javax/naming/spi/ObjectFactoryBuilder.java
index 5d3f96bdc..6a528b17a 100644
--- a/javax/naming/spi/ObjectFactoryBuilder.java
+++ b/javax/naming/spi/ObjectFactoryBuilder.java
@@ -1,5 +1,5 @@
-/* ObjectFactoryBuilder.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+/* ObjectFactoryBuilder.java -- the builder that creates the object factories.
+ Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,14 +41,30 @@ package javax.naming.spi;
import java.util.Hashtable;
import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
/**
+ * Represents the builder that creates the object factories.
+ *
+ * @see NamingManager#setObjectFactoryBuilder(ObjectFactoryBuilder)
+ *
* @author Warren Levy (warrenl@redhat.com)
- * @date June 1, 2001
*/
public interface ObjectFactoryBuilder
{
- ObjectFactory createObjectFactory(Object obj,
+ /**
+ * Create a new object using the supplied environment.
+ *
+ * @param refInfo the referencing object, for which the new object must be
+ * created (can be null). If not null, it is usually an instance of
+ * the {@link Reference} or {@link Referenceable}.
+ * @param environment contains the additional information about the factory
+ * being created. Can be null.
+ * @return the created object factory. The null is never returned.
+ * @throws NamingException
+ */
+ ObjectFactory createObjectFactory(Object refInfo,
Hashtable<?, ?> environment)
throws NamingException;
}
diff --git a/javax/naming/spi/ResolveResult.java b/javax/naming/spi/ResolveResult.java
index 07e2df3c0..d5051a5d4 100644
--- a/javax/naming/spi/ResolveResult.java
+++ b/javax/naming/spi/ResolveResult.java
@@ -45,8 +45,11 @@ import javax.naming.InvalidNameException;
import javax.naming.Name;
/**
+ * Stores the partial resolution of the name. This class contains the
+ * object to which part of the name has been resolved and the remaining,
+ * unresolved part of this name.
+ *
* @author Warren Levy (warrenl@redhat.com)
- * @date June 5, 2001
*/
public class ResolveResult implements Serializable
@@ -54,51 +57,92 @@ public class ResolveResult implements Serializable
private static final long serialVersionUID = - 4552108072002407559L;
// Serialized fields.
+ /**
+ * The object, to that part of the name has been resolved.
+ */
protected Object resolvedObj;
+
+ /**
+ * The remaining, unresolved part of the name.
+ */
protected Name remainingName;
-
+
+ /**
+ * Create the unitialised instance with both parts being null.
+ */
protected ResolveResult()
{
- resolvedObj = null;
- remainingName = null;
}
-
- public ResolveResult(Object robj, String rcomp)
+
+ /**
+ * Create the initialised instance
+ *
+ * @param resolved the object, to that the name is partially resolved
+ * @param remaining the remaining unresolved part of the name.
+ */
+ public ResolveResult(Object resolved, String remaining)
{
- if (robj == null || rcomp == null)
+ if (resolved == null || remaining == null)
throw new IllegalArgumentException ();
- resolvedObj = robj;
+ resolvedObj = resolved;
remainingName = new CompositeName ();
try
{
- remainingName.add (rcomp);
+ remainingName.add (remaining);
}
catch (InvalidNameException _)
{
}
}
- public ResolveResult(Object robj, Name rname)
+ /**
+ * Create the initialised instance
+ *
+ * @param resolved the object, to that the name is partially resolved
+ * @param remaining the remaining unresolved part of the name.
+ */
+ public ResolveResult(Object resolved, Name remaining)
{
- resolvedObj = robj;
- remainingName = rname;
+ resolvedObj = resolved;
+ remainingName = remaining;
}
+ /**
+ * Get the remaining unresolved part of the name
+ *
+ * @return the remaining unresolved part of the name.
+ */
public Name getRemainingName()
{
return remainingName;
}
+ /**
+ * Get the object to that the name was partially resolved
+ *
+ * @return the object, to that the name is partially resolved
+ */
public Object getResolvedObj()
{
return resolvedObj;
}
-
+
+ /**
+ * Set the remaining unresolved name.
+ *
+ * @param name the name being set. The passed parameter is cloned, so the
+ * caller can reuse or modify it after the method returns.
+ */
public void setRemainingName(Name name)
{
remainingName = (Name) name.clone();
}
-
+
+ /**
+ * Append the name to the end of the resolved name.
+ *
+ * @param name the name to append
+ */
public void appendRemainingName(Name name)
{
try
@@ -110,6 +154,11 @@ public class ResolveResult implements Serializable
}
}
+ /**
+ * Append the name to the end of the resolved name.
+ *
+ * @param name the name to append
+ */
public void appendRemainingComponent(String name)
{
try
@@ -121,6 +170,11 @@ public class ResolveResult implements Serializable
}
}
+ /**
+ * Set the object to that the part of the name has been resolved.
+ *
+ * @param obj the object, to that the name has been partially resolved.
+ */
public void setResolvedObj(Object obj)
{
resolvedObj = obj;
diff --git a/javax/naming/spi/Resolver.java b/javax/naming/spi/Resolver.java
index a204fc6a6..f01790502 100644
--- a/javax/naming/spi/Resolver.java
+++ b/javax/naming/spi/Resolver.java
@@ -1,5 +1,5 @@
/* Resolver.java --
- Copyright (C) 2001, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,12 +41,17 @@ package javax.naming.spi;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
+import javax.naming.NotContextException;
/**
++ * <p>Represents the object, capable for the at least partial name resolution.
++ * The object is not necessay capable for the complete name resolution and
++ * need not implement the {@link Context}.</p>
++ * <p>
++ * Both passed parameters and returned results are owned by the caller.</p>
++ *
* @author Warren Levy (warrenl@redhat.com)
- * @date June 1, 2001
*/
-
public interface Resolver
{
ResolveResult resolveToClass(Name name,
diff --git a/javax/naming/spi/StateFactory.java b/javax/naming/spi/StateFactory.java
index af5ed11c7..0c48309e3 100644
--- a/javax/naming/spi/StateFactory.java
+++ b/javax/naming/spi/StateFactory.java
@@ -1,5 +1,5 @@
/* StateFactory.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,11 +45,35 @@ import javax.naming.Name;
import javax.naming.NamingException;
/**
+ * Represents a factory, producing the object states for binding. The operation,
+ * performed by this factory, is the reverse operation with related to the
+ * operation, performed by the {@link ObjectFactory}. Classes, implementing
+ * this interface, must be public and have public parameterless constructor.
+ *
+ * @see DirStateFactory
+ * @see ObjectFactory
* @author Warren Levy (warrenl@redhat.com)
- * @date June 1, 2001
*/
public interface StateFactory
{
+ /**
+ * Get the object state for binding.
+ *
+ * @param obj the object, for that the binding state must be retrieved. Cannot
+ * be null.
+ * @param name the name of this object, related to the nameCtx. Can be null if
+ * not specified.
+ * @param nameCtx the naming context, to that the object name is related. Can
+ * be null if the name is related to the initial default context.
+ * @param environment the properties for creating the object state. Can be
+ * null if no properties are provided.
+ * @return the object state for binding, may be null if no changes are
+ * returned by the factory
+ * @throws NamingException
+ *
+ * @see NamingManager#getStateToBind
+ * @see DirectoryManager#getStateToBind
+ */
Object getStateToBind(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment) throws NamingException;
}
diff --git a/javax/swing/DefaultCellEditor.java b/javax/swing/DefaultCellEditor.java
index 9c951d395..16ed1ec68 100644
--- a/javax/swing/DefaultCellEditor.java
+++ b/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/javax/swing/JLabel.java b/javax/swing/JLabel.java
index a2dbb3251..a5fe3ba1a 100644
--- a/javax/swing/JLabel.java
+++ b/javax/swing/JLabel.java
@@ -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.
@@ -895,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);
}
}
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index a4ef6fbcd..a81cb71ee 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -1045,7 +1045,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.
@@ -1251,6 +1261,12 @@ public class JTable
private class IconCellRenderer
extends DefaultTableCellRenderer
{
+ IconCellRenderer()
+ {
+ setHorizontalAlignment(SwingConstants.CENTER);
+ }
+
+
/**
* Returns the component that is used for rendering the value.
*
@@ -1352,14 +1368,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.
@@ -1618,7 +1634,13 @@ public class JTable
* @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.
*/
@@ -1751,12 +1773,6 @@ 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;
setRowHeight(16);
@@ -1805,7 +1821,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);
}
/**
@@ -1903,6 +1922,8 @@ public class JTable
*/
public void columnMoved (TableColumnModelEvent event)
{
+ if (isEditing())
+ editingCanceled(null);
revalidate();
repaint();
}
@@ -2046,6 +2067,10 @@ public class JTable
*/
public void valueChanged (ListSelectionEvent event)
{
+ // If we are in the editing process, end the editing session.
+ if (isEditing())
+ editingStopped(null);
+
// 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()));
@@ -3313,7 +3338,7 @@ public class JTable
public void doLayout()
{
TableColumn resizingColumn = null;
-
+
int ncols = getColumnCount();
if (ncols < 1)
return;
@@ -3339,7 +3364,7 @@ public class JTable
{
TableColumn col;
TableColumn [] cols;
-
+
switch (getAutoResizeMode())
{
case AUTO_RESIZE_LAST_COLUMN:
@@ -3401,20 +3426,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>
*/
@@ -3454,6 +3503,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()
@@ -3670,6 +3723,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();
@@ -3819,30 +3876,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/javax/swing/plaf/basic/BasicComboBoxUI.java b/javax/swing/plaf/basic/BasicComboBoxUI.java
index 0f0949543..ea6f98504 100644
--- a/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/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.
@@ -38,6 +38,8 @@ 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.Container;
@@ -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();
@@ -976,9 +972,8 @@ public class BasicComboBoxUI extends ComboBoxUI
protected void installKeyboardActions()
{
SwingUtilities.replaceUIInputMap(comboBox,
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
- (InputMap) UIManager.get("ComboBox.ancestorInputMap"));
-
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
+ (InputMap) UIManager.get("ComboBox.ancestorInputMap"));
// Install any action maps here.
}
@@ -989,7 +984,7 @@ public class BasicComboBoxUI extends ComboBoxUI
protected void uninstallKeyboardActions()
{
SwingUtilities.replaceUIInputMap(comboBox,
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
// Uninstall any action maps here.
}
@@ -1149,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();
}
}
@@ -1170,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.
}
}
@@ -1202,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();
}
@@ -1219,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();
@@ -1231,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();
@@ -1245,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)
{
@@ -1301,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"))
{
@@ -1343,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/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java
index 64638b45a..bd5d2d916 100644
--- a/javax/swing/plaf/basic/BasicTableUI.java
+++ b/javax/swing/plaf/basic/BasicTableUI.java
@@ -228,8 +228,6 @@ public class BasicTableUI extends TableUI
if (e.getClickCount() < ce.getClickCountToStart())
return;
}
- else if (e.getClickCount() < 2)
- return;
table.editCellAt(row, col);
}
}
diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java
index df8fbd01d..6756a3ac5 100644
--- a/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/javax/swing/plaf/basic/BasicTreeUI.java
@@ -2591,42 +2591,31 @@ public class BasicTreeUI
}
/**
- * 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)
- throws NotImplementedException
{
- // 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)
- throws NotImplementedException
{
- // TODO: Implement this properly.
- }
-
- /**
- * Returns true if the action is enabled.
- *
- * @return true if the action is enabled, false otherwise
- */
- public boolean isEnabled()
- throws NotImplementedException
- {
- // TODO: Implement this properly.
- return false;
+ if (isEnabled() && tree.isEditing())
+ tree.cancelEditing();
}
}
diff --git a/javax/swing/table/JTableHeader.java b/javax/swing/table/JTableHeader.java
index f7c1e1cd5..c11a96fb3 100644
--- a/javax/swing/table/JTableHeader.java
+++ b/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.
@@ -41,6 +41,7 @@ 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 +83,506 @@ 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 accessible context for the column header renderer, or
+ * <code>null</code>.
+ *
+ * @return The accessible context.
+ */
+ AccessibleContext getAccessibleColumnHeaderRenderer()
+ {
+ AccessibleContext ac = null;
+ TableColumn tc = parent.getColumnModel().getColumn(columnIndex);
+ TableCellRenderer r = tc.getHeaderRenderer();
+ if (r == null)
+ r = parent.getDefaultRenderer();
+ Component c = r.getTableCellRendererComponent(table, tc.headerValue,
+ false, false, -1, columnIndex);
+ if (c instanceof Accessible)
+ ac = c.getAccessibleContext();
+ return ac;
}
+ /**
+ * @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
{
+ // FIXME
throw new Error("not implemented");
}
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/javax/swing/text/html/MinimalHTMLWriter.java b/javax/swing/text/html/MinimalHTMLWriter.java
index 4dc67298a..d42951a05 100644
--- a/javax/swing/text/html/MinimalHTMLWriter.java
+++ b/javax/swing/text/html/MinimalHTMLWriter.java
@@ -349,7 +349,7 @@ public class MinimalHTMLWriter extends AbstractWriter
/**
* Deliberately unimplemented, handles component elements.
*/
- protected void writeComponent(Element elem)
+ protected void writeComponent(Element elem) throws IOException
{
}
@@ -357,7 +357,7 @@ public class MinimalHTMLWriter extends AbstractWriter
* Deliberately unimplemented.
* Writes StyleConstants.IconElementName elements.
*/
- protected void writeImage(Element elem)
+ protected void writeImage(Element elem) throws IOException
{
}
diff --git a/javax/swing/tree/AbstractLayoutCache.java b/javax/swing/tree/AbstractLayoutCache.java
index 713c9cae7..772c0c96c 100644
--- a/javax/swing/tree/AbstractLayoutCache.java
+++ b/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/javax/swing/tree/DefaultMutableTreeNode.java b/javax/swing/tree/DefaultMutableTreeNode.java
index 389101be1..9f587946f 100644
--- a/javax/swing/tree/DefaultMutableTreeNode.java
+++ b/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/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index 5e93145ae..e120b71c1 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/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/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index 5ca69e2ff..e8cbf4bb4 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/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/javax/swing/tree/DefaultTreeSelectionModel.java b/javax/swing/tree/DefaultTreeSelectionModel.java
index 1a761d6c7..db16a1a60 100644
--- a/javax/swing/tree/DefaultTreeSelectionModel.java
+++ b/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/javax/swing/tree/ExpandVetoException.java b/javax/swing/tree/ExpandVetoException.java
index 1c8827c8a..57531d542 100644
--- a/javax/swing/tree/ExpandVetoException.java
+++ b/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/javax/swing/tree/FixedHeightLayoutCache.java b/javax/swing/tree/FixedHeightLayoutCache.java
index b8192211d..dff9298e8 100644
--- a/javax/swing/tree/FixedHeightLayoutCache.java
+++ b/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/javax/swing/tree/RowMapper.java b/javax/swing/tree/RowMapper.java
index 690efb77e..59eb1e3a9 100644
--- a/javax/swing/tree/RowMapper.java
+++ b/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/javax/swing/tree/TreeNode.java b/javax/swing/tree/TreeNode.java
index 94f2c69f8..ae7380c70 100644
--- a/javax/swing/tree/TreeNode.java
+++ b/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/javax/swing/tree/TreeSelectionModel.java b/javax/swing/tree/TreeSelectionModel.java
index 4072ccc64..9bdc99be3 100644
--- a/javax/swing/tree/TreeSelectionModel.java
+++ b/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/javax/swing/tree/VariableHeightLayoutCache.java b/javax/swing/tree/VariableHeightLayoutCache.java
index 302fb0e45..f2bbc2bfe 100644
--- a/javax/swing/tree/VariableHeightLayoutCache.java
+++ b/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;
@@ -265,7 +265,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 +282,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;
}
diff --git a/native/jawt/Makefile.am b/native/jawt/Makefile.am
index b6e6f0af0..30e5a345b 100644
--- a/native/jawt/Makefile.am
+++ b/native/jawt/Makefile.am
@@ -1,16 +1,12 @@
-nativeexeclib_LTLIBRARIES = libjawtgnu.la
+nativeexeclib_LTLIBRARIES = libjawt.la
-libjawtgnu_la_SOURCES = jawt.c
-libjawtgnu_la_LIBADD = $(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
-# FIXME: libtool doesn't allow overriding SONAME, but we need to set
-# it to libjawt.so for binary compatibility.
-#
-# libjawtgnu_la_LDFLAGS = -Wl,-soname -Wl,libjawt.so
+libjawt_la_SOURCES = jawt.c
+libjawt_la_LIBADD = $(top_builddir)/native/jni/gtk-peer/libgtkpeer.la
-AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @CAIRO_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @PANGOFT2_LIBS@ @X_LIBS@ -lXtst
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/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am
index 9c373cb4d..4b113c978 100644
--- a/native/jni/gtk-peer/Makefile.am
+++ b/native/jni/gtk-peer/Makefile.am
@@ -1,17 +1,9 @@
nativeexeclib_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) \
- gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \
+# GTK JNI sources.
+libgtkpeer_la_SOURCES = 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_GdkGraphics2D.c \
gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c \
gnu_java_awt_peer_gtk_GdkPixbufDecoder.c \
gnu_java_awt_peer_gtk_GdkRobotPeer.c \
@@ -47,19 +39,18 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
gthread-jni.c \
gdkfont.h \
gthread-jni.h \
- gtkcairopeer.h \
gtk_jawt.c \
gtkpeer.h
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@ \
+AM_LDFLAGS = @CLASSPATH_MODULE@ @GTK_LIBS@ @FREETYPE2_LIBS@ \
@PANGOFT2_LIBS@ @X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ -lX11 -lXtst
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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
index 0726fb531..c0f776b20 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontPeer.c
+++ b/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"
@@ -389,7 +396,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 +433,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 +461,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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
deleted file mode 100644
index 29bc1855b..000000000
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+++ /dev/null
@@ -1,758 +0,0 @@
-/* gdkgraphics.c
- Copyright (C) 1999 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"
-#include "gdkfont.h"
-#include "gnu_java_awt_peer_gtk_GdkGraphics.h"
-#include <gdk/gdkprivate.h>
-#include <gdk/gdkx.h>
-
-static jmethodID initComponentGraphicsUnlockedID;
-
-/*
- * AWT applications may call Graphics methods from threads other than
- * the GDK main thread, so we must call XFlush after each batch of
- * drawing operations, otherwise animations flicker. Flushing after
- * every graphics operation is excessive and negatively affects
- * performance (PR 26486). We set the maximum frequency to 50 times
- * per second, or a minimum period of 20 milliseconds between calls to
- * XFlush. See gnu.classpath.examples.awt.AnimationApplet for an
- * example applet that requires these XFlush calls.
- */
-
-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_graphics_init_jni (void)
-{
- jclass gdkgraphics;
-
- gdkgraphics = (*cp_gtk_gdk_env())->FindClass (cp_gtk_gdk_env(),
- "gnu/java/awt/peer/gtk/GdkGraphics");
-
- initComponentGraphicsUnlockedID =
- (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics,
- "initComponentGraphicsUnlocked",
- "()V");
-}
-
-struct state_table *cp_gtk_native_graphics_state_table;
-
-static struct state_table *native_graphics_global_ref_table;
-
-#define NSA_GLOBAL_G_INIT(env, clazz) \
- native_graphics_global_ref_table = cp_gtk_init_state_table (env, clazz)
-
-#define NSA_GET_GLOBAL_G_REF(env, obj) \
- cp_gtk_get_state (env, obj, native_graphics_global_ref_table)
-
-#define NSA_SET_GLOBAL_G_REF(env, obj) \
- do {jobject *globRefPtr; \
- globRefPtr = (jobject *) malloc (sizeof (jobject)); \
- *globRefPtr = (*env)->NewGlobalRef (env, obj); \
- cp_gtk_set_state (env, obj, native_graphics_global_ref_table, (void *)globRefPtr);} while (0)
-
-#define NSA_DEL_GLOBAL_G_REF(env, obj) \
- do {jobject *globRefPtr = cp_gtk_get_state (env, obj, native_graphics_global_ref_table); \
- cp_gtk_remove_state_slot (env, obj, native_graphics_global_ref_table); \
- (*env)->DeleteGlobalRef (env, *globRefPtr); \
- free (globRefPtr);} while (0)
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initStaticState
- (JNIEnv *env, jclass clazz)
-{
- gdk_threads_enter();
-
- NSA_G_INIT (env, clazz);
- NSA_GLOBAL_G_INIT (env, clazz);
-
- gdk_threads_leave();
-}
-
-#define GDK_STABLE_IS_PIXMAP(d) (GDK_IS_PIXMAP(d))
-
-static GdkPoint *translate_points (JNIEnv *env, jintArray xpoints,
- jintArray ypoints, jint npoints,
- jint x_offset, jint y_offset);
-static void realize_cb (GtkWidget *widget, jobject jgraphics);
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeCopyState
- (JNIEnv *env, jobject obj, jobject old)
-{
- struct graphics *g = NULL;
- struct graphics *g_old = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- g_old = (struct graphics *) NSA_GET_G_PTR (env, old);
-
- *g = *g_old;
-
- g->gc = gdk_gc_new (g->drawable);
- gdk_gc_copy (g->gc, g_old->gc);
-
- if (GDK_STABLE_IS_PIXMAP (g->drawable))
- g_object_ref (g->drawable);
- else /* GDK_IS_WINDOW (g->drawable) */
- g_object_ref (g->drawable);
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
-
- NSA_SET_G_PTR (env, obj, g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II
- (JNIEnv *env, jobject obj, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- g->x_offset = g->y_offset = 0;
-
- g->drawable = (GdkDrawable *) gdk_pixmap_new (NULL, width, height,
- gdk_rgb_get_visual ()->depth);
- g->cm = gdk_rgb_get_colormap ();
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
- g->gc = gdk_gc_new (g->drawable);
-
- NSA_SET_G_PTR (env, obj, g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
- (JNIEnv *env, jobject obj, jobject source)
-{
- struct graphics *g = NULL;
- GdkPixmap *pixmap = NULL;
-
- gdk_threads_enter ();
-
- pixmap = cp_gtk_image_get_pixmap (env, source);
- g_assert(pixmap != NULL);
- g_object_ref (pixmap);
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- g->x_offset = g->y_offset = 0;
-
- g->drawable = (GdkDrawable *)pixmap;
-
- g->cm = gdk_drawable_get_colormap (g->drawable);
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
- g->gc = gdk_gc_new (g->drawable);
-
- NSA_SET_G_PTR (env, obj, g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked
- (JNIEnv *env, jobject obj, jobject peer)
-{
- struct graphics *g = NULL;
- void *ptr = NULL;
- GtkWidget *widget = NULL;
- GdkColor color;
-
- g = (struct graphics *) g_malloc (sizeof (struct graphics));
- ptr = NSA_GET_PTR (env, peer);
- g->x_offset = 0;
- g->y_offset = 0;
-
- widget = GTK_WIDGET (ptr);
- g->drawable = (GdkDrawable *) widget->window;
-
- g_object_ref (g->drawable);
- g->cm = gtk_widget_get_colormap (widget);
-
- if (g->cm != NULL)
- g_object_ref (g->cm);
-
- g->gc = gdk_gc_new (g->drawable);
- gdk_gc_copy (g->gc, widget->style->fg_gc[GTK_STATE_NORMAL]);
- color = widget->style->fg[GTK_STATE_NORMAL];
-
- NSA_SET_G_PTR (env, obj, g);
-}
-
-/* copy the native state of the peer (GtkWidget *) to the native state
- of the graphics object */
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
- (JNIEnv *env, jobject obj, jobject peer)
-{
- gdk_threads_enter ();
- Java_gnu_java_awt_peer_gtk_GdkGraphics_initStateUnlocked
- (env, obj, peer);
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals
- (JNIEnv *env, jobject obj, jobject peer)
-{
- void *ptr = NULL;
- jobject *gref = NULL;
-
- gdk_threads_enter ();
-
- NSA_SET_GLOBAL_G_REF (env, obj);
- gref = NSA_GET_GLOBAL_G_REF (env, obj);
-
- ptr = NSA_GET_PTR (env, peer);
-
- g_signal_connect_after (G_OBJECT (ptr), "realize",
- G_CALLBACK (realize_cb), *gref);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_nativeDispose
- (JNIEnv *env, jobject obj)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_DEL_G_PTR (env, obj);
-
- /* check if dispose has been called already */
- if (!g)
- {
- gdk_threads_leave ();
- return;
- }
-
- XFlush (GDK_DISPLAY ());
-
- if (g->gc != NULL)
- g_object_unref (g->gc);
-
- if (GDK_STABLE_IS_PIXMAP (g->drawable))
- g_object_unref (g->drawable);
- else if (g->drawable != NULL)
- g_object_unref (g->drawable);
-
- if (g->cm != NULL)
- g_object_unref (g->cm);
-
- g_free (g);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_translateNative
- (JNIEnv *env, jobject obj, jint x, jint y)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- g->x_offset += x;
- g->y_offset += y;
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawString
- (JNIEnv *env, jobject obj, jobject font, jstring str, jint x, jint y)
-{
- struct peerfont *pfont = NULL;
- struct graphics *g = NULL;
- const char *cstr = NULL;
- const char *sTmp = NULL;
- char *tmp = NULL;
- char *p = NULL;
- int count = 0;
- int charSize = 0;
- int baseline_y = 0;
- PangoLayoutIter *iter = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- g_assert (g != NULL);
-
- pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
- g_assert (pfont != NULL);
-
- cstr = (*env)->GetStringUTFChars (env, str, NULL);
- g_assert (cstr != NULL);
-
- charSize = sizeof(char);
- p = malloc((strlen(cstr) + 1) * charSize);
- g_assert (p != NULL);
-
- tmp = p;
- sTmp = cstr;
- for (; *sTmp != '\0'; sTmp++)
- if (((unsigned char) *sTmp) >= ' ')
- {
- *p = *sTmp;
- count++;
- p++;
- }
- *p = '\0';
-
- p = realloc(tmp, (count + 1) * charSize);
- g_assert (p != NULL);
- pango_layout_set_text (pfont->layout, p, -1);
- free(p);
-
- pango_layout_set_font_description (pfont->layout, pfont->desc);
- iter = pango_layout_get_iter (pfont->layout);
-
- baseline_y = pango_layout_iter_get_baseline (iter);
-
- gdk_draw_layout (g->drawable, g->gc,
- x + g->x_offset,
- y + g->y_offset - PANGO_PIXELS (baseline_y),
- pfont->layout);
-
- pango_layout_iter_free (iter);
- pango_layout_set_text (pfont->layout, "", -1);
-
- schedule_flush ();
-
- (*env)->ReleaseStringUTFChars (env, str, cstr);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine
- (JNIEnv *env, jobject obj, jint x, jint y, jint x2, jint y2)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_line (g->drawable, g->gc,
- x + g->x_offset, y + g->y_offset,
- x2 + g->x_offset, y2 + g->y_offset);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_rectangle (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset, width, height);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawRect
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_rectangle (g->drawable, g->gc, FALSE,
- x + g->x_offset, y + g->y_offset, width, height);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea
- (JNIEnv *env, jobject obj, jint x, jint y,
- jint width, jint height, jint dx, jint dy)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_drawable ((GdkWindow *)g->drawable,
- g->gc,
- (GdkWindow *)g->drawable,
- x + g->x_offset, y + g->y_offset,
- x + g->x_offset + dx, y + g->y_offset + dy,
- width, height);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
- GdkGCValues saved;
- GtkWidget *widget = NULL;
- union widget_union w;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- if (!g)
- {
- gdk_threads_leave ();
- return;
- }
-
- if (GDK_IS_WINDOW (g->drawable))
- {
- w.widget = &widget;
- gdk_window_get_user_data (GDK_WINDOW (g->drawable), w.void_widget);
- if (widget == NULL || !GTK_IS_EVENT_BOX (widget))
- gdk_window_clear_area ((GdkWindow *) g->drawable,
- x + g->x_offset, y + g->y_offset,
- width, height);
- }
- else
- {
- gdk_gc_get_values (g->gc, &saved);
- gdk_gc_set_background (g->gc, &(saved.background));
- gdk_draw_rectangle (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset, width, height);
- gdk_gc_set_foreground (g->gc, &(saved.foreground));
- }
-
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction
- (JNIEnv *env, jobject obj, jint func)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_gc_set_function (g->gc, func);
-
- gdk_threads_leave ();
-}
-
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_setFGColor
- (JNIEnv *env, jobject obj, jint red, jint green, jint blue)
-{
- GdkColor color;
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- color.red = red << 8;
- color.green = green << 8;
- color.blue = blue << 8;
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- if (g->cm != NULL)
- gdk_colormap_alloc_color (g->cm, &color, TRUE, TRUE);
-
- gdk_gc_set_foreground (g->gc, &color);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height,
- jint angle1, jint angle2)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, FALSE,
- x + g->x_offset, y + g->y_offset,
- width, height, angle1 << 6, angle2 << 6);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-static GdkPoint *
-translate_points (JNIEnv *env, jintArray xpoints, jintArray ypoints,
- jint npoints, jint x_offset, jint y_offset)
-{
- GdkPoint *points;
- jint *x, *y;
- int i;
-
- /* allocate one more point than necessary, in case we need to tack
- on an extra due to the semantics of Java polygons. */
- points = g_malloc (sizeof (GdkPoint) * (npoints + 1));
-
- x = (*env)->GetIntArrayElements (env, xpoints, NULL);
- y = (*env)->GetIntArrayElements (env, ypoints, NULL);
-
- for (i = 0; i < npoints; i++)
- {
- points[i].x = x[i] + x_offset;
- points[i].y = y[i] + y_offset;
- }
-
- (*env)->ReleaseIntArrayElements (env, xpoints, x, JNI_ABORT);
- (*env)->ReleaseIntArrayElements (env, ypoints, y, JNI_ABORT);
-
- return points;
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolyline
- (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
- jint npoints)
-{
- struct graphics *g = NULL;
- GdkPoint *points = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- points = translate_points (env, xpoints, ypoints, npoints,
- g->x_offset, g->y_offset);
-
- gdk_draw_lines (g->drawable, g->gc, points, npoints);
- schedule_flush ();
-
- g_free (points);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawPolygon
- (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
- jint npoints)
-{
- struct graphics *g = NULL;
- GdkPoint *points = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- points = translate_points (env, xpoints, ypoints, npoints,
- g->x_offset, g->y_offset);
-
- /* make sure the polygon is closed, per Java semantics.
- if it's not, we close it. */
- if (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y)
- points[npoints++] = points[0];
-
- gdk_draw_lines (g->drawable, g->gc, points, npoints);
- schedule_flush ();
-
- g_free (points);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon
- (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints,
- jint npoints)
-{
- struct graphics *g = NULL;
- GdkPoint *points = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
- points = translate_points (env, xpoints, ypoints, npoints,
- g->x_offset, g->y_offset);
- gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints);
- schedule_flush ();
-
- g_free (points);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height,
- jint angle1, jint angle2)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset,
- width, height, angle1 << 6, angle2 << 6);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_drawOval
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, FALSE,
- x + g->x_offset, y + g->y_offset,
- width, height, 0, 23040);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_fillOval
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- gdk_draw_arc (g->drawable, g->gc, TRUE,
- x + g->x_offset, y + g->y_offset,
- width, height, 0, 23040);
- schedule_flush ();
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_setClipRectangle
- (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
-{
- struct graphics *g = NULL;
- GdkRectangle rectangle;
-
- gdk_threads_enter ();
-
- g = (struct graphics *) NSA_GET_G_PTR (env, obj);
-
- rectangle.x = x + g->x_offset;
- rectangle.y = y + g->y_offset;
- rectangle.width = width;
- rectangle.height = height;
-
- gdk_gc_set_clip_rectangle (g->gc, &rectangle);
-
- gdk_threads_leave ();
-}
-
-static void
-realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject jgraphics)
-{
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(),
- jgraphics,
- initComponentGraphicsUnlockedID);
-
- NSA_DEL_GLOBAL_G_REF (cp_gtk_gdk_env(), jgraphics);
-}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
index b42f649a1..56c13b6c1 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
@@ -1,42 +1,41 @@
/* gnu_java_awt_peer_gtk_GdkGraphics2d.c
Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
- This file is part of GNU Classpath.
+This file is part of GNU Classpath.
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
#include "jcl.h"
-#include "gtkcairopeer.h"
#include "gdkfont.h"
#include "gnu_java_awt_peer_gtk_GdkGraphics2D.h"
#include <gdk/gdktypes.h>
@@ -53,37 +52,47 @@
#include <stdio.h>
#include <stdlib.h>
-static jmethodID initComponentGraphics2DUnlockedID;
+struct state_table *cp_gtk_native_graphics2d_state_table;
-void
-cp_gtk_graphics2d_init_jni (void)
-{
- jclass gdkgraphics2d;
- JNIEnv *env = cp_gtk_gdk_env();
+/*
+ * AWT applications may call Graphics methods from threads other than
+ * the GDK main thread, so we must call XFlush after each batch of
+ * drawing operations, otherwise animations flicker. Flushing after
+ * every graphics operation is excessive and negatively affects
+ * performance (PR 26486). We set the maximum frequency to 50 times
+ * per second, or a minimum period of 20 milliseconds between calls to
+ * XFlush. See gnu.classpath.examples.awt.AnimationApplet for an
+ * example applet that requires these XFlush calls.
+ */
- gdkgraphics2d = (*env)->FindClass (env,
- "gnu/java/awt/peer/gtk/GdkGraphics2D");
- if ((*env)->ExceptionOccurred(env))
- return;
+static short flush_scheduled = 0;
- initComponentGraphics2DUnlockedID = (*cp_gtk_gdk_env())->GetMethodID (cp_gtk_gdk_env(), gdkgraphics2d,
- "initComponentGraphics2DUnlocked",
- "()V");
-}
+static gboolean flush (gpointer data __attribute__((unused)))
+{
+ gdk_threads_enter ();
-static struct state_table *native_graphics2d_state_table;
+ XFlush (GDK_DISPLAY ());
+ flush_scheduled = 0;
-#define NSA_G2D_INIT(env, clazz) \
- native_graphics2d_state_table = cp_gtk_init_state_table (env, clazz)
+ gdk_threads_leave ();
-#define NSA_GET_G2D_PTR(env, obj) \
- cp_gtk_get_state (env, obj, native_graphics2d_state_table)
+ return FALSE;
+}
-#define NSA_SET_G2D_PTR(env, obj, ptr) \
- cp_gtk_set_state (env, obj, native_graphics2d_state_table, (void *)ptr)
+/* The minimum time period between calls to XFlush, in
+ milliseconds. */
+#define MINIMUM_FLUSH_PERIOD 20
-#define NSA_DEL_G2D_PTR(env, obj) \
- cp_gtk_remove_state_slot (env, obj, native_graphics2d_state_table)
+/* 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;
+ }
+}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStaticState
@@ -157,8 +166,6 @@ peer_is_disposed(JNIEnv *env, jobject obj)
jclass cls;
jobject peer;
- return 0;
-
if (fid == NULL)
{
cls = (*env)->GetObjectClass(env, obj);
@@ -170,12 +177,9 @@ peer_is_disposed(JNIEnv *env, jobject obj)
if (peer == NULL || NSA_GET_PTR (env, peer) != NULL)
return 0;
else
- {
- return 1;
- }
+ return 1;
}
-
static void
grab_current_drawable (GtkWidget *widget, GdkDrawable **draw, GdkWindow **win)
{
@@ -367,6 +371,8 @@ end_drawing_operation (JNIEnv *env, struct graphics2d * gr)
memcpy (gr->javabuf, gr->javabuf_copy, gr->width * gr->height * 4);
(*env)->ReleasePrimitiveArrayCritical (env, gr->jarray, gr->javabuf, JNI_COMMIT);
}
+
+ schedule_flush ();
}
@@ -389,14 +395,6 @@ check_for_debug (struct graphics2d *gr)
gr->debug = (gboolean)(getenv("DEBUGJ2D") != NULL);
}
-static void
-realize_cb (GtkWidget *widget __attribute__ ((unused)), jobject peer)
-{
- (*cp_gtk_gdk_env())->CallVoidMethod (cp_gtk_gdk_env(),
- peer,
- initComponentGraphics2DUnlockedID);
-}
-
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_copyState
(JNIEnv *env, jobject obj, jobject old)
@@ -553,7 +551,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__II
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
- (JNIEnv *env, jobject self, jobject other, jint x, jint y)
+ (JNIEnv *env, jobject obj, jobject other, jint x, jint y)
{
struct graphics2d *src = NULL;
struct graphics2d *dst = NULL;
@@ -567,15 +565,15 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
cairo_operator_t tmp_op;
gdk_threads_enter();
-
- if (peer_is_disposed(env, self))
+
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
return;
}
src = (struct graphics2d *)NSA_GET_G2D_PTR (env, other);
- dst = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
+ dst = (struct graphics2d *)NSA_GET_G2D_PTR (env, obj);
g_assert (src != NULL);
g_assert (dst != NULL);
@@ -585,8 +583,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
/* gdk_flush(); */
- if (!GDK_IS_DRAWABLE (src->drawable) ||
- !GDK_IS_DRAWABLE (dst->drawable))
+ if (!GDK_IS_DRAWABLE (src->drawable) ||
+ !GDK_IS_DRAWABLE (dst->drawable))
{
gdk_threads_leave ();
return;
@@ -611,8 +609,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
if (src->pattern)
cairo_pattern_set_matrix (src->pattern, &matrix);
- gdk_flush();
-
end_drawing_operation(env, dst);
if (src->debug) printf ("copied %d x %d pixels from offscreen drawable\n", width, height);
@@ -621,43 +617,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_gdkDrawDrawable
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initStateUnlocked
- (JNIEnv *env, jobject obj, jobject peer)
-{
- struct graphics2d *gr = NULL;
- GtkWidget *widget = NULL;
- void *ptr = NULL;
-
- if (peer_is_disposed(env, obj))
- return;
-
- ptr = NSA_GET_PTR (env, peer);
- g_assert (ptr != NULL);
-
- gr = (struct graphics2d *) g_malloc (sizeof (struct graphics2d));
- g_assert (gr != NULL);
- memset (gr, 0, sizeof(struct graphics2d));
-
- check_for_debug (gr);
-
- widget = GTK_WIDGET (ptr);
- g_assert (widget != NULL);
-
- grab_current_drawable (widget, &(gr->drawable), &(gr->win));
- g_assert (gr->drawable != NULL);
-
- gr->width = widget->allocation.width;
- gr->height = widget->allocation.height;
-
- if (x_server_has_render_extension ())
- init_graphics2d_as_renderable (gr);
- else
- init_graphics2d_as_pixbuf (gr);
-
- NSA_SET_G2D_PTR (env, obj, gr);
-}
-
-JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2
(JNIEnv *env, jobject obj, jobject peer)
{
@@ -669,7 +628,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkCo
if (peer_is_disposed(env, obj))
{
- gdk_threads_leave ();
+ gdk_threads_leave();
return;
}
@@ -702,62 +661,58 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_initState__Lgnu_java_awt_peer_gtk_GtkCo
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_connectSignals
- (JNIEnv *env, jobject obj, jobject peer)
-{
- void *ptr;
-
- gdk_threads_enter ();
-
- ptr = NSA_GET_PTR (env, peer);
-
- g_signal_connect_after (G_OBJECT (ptr), "realize",
- G_CALLBACK (realize_cb), obj);
-
- gdk_threads_leave ();
-}
-
-JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
(JNIEnv *env, jobject obj)
{
struct graphics2d *gr = NULL;
- gdk_threads_enter();
-
gr = (struct graphics2d *) NSA_DEL_G2D_PTR (env, obj);
- if (gr == NULL)
+ /* dispose has been called more than once */
+ if (gr == NULL)
+ return;
+
+ gdk_threads_enter();
+
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
- return; /* dispose has been called more than once */
+ return;
}
if (gr->surface)
cairo_surface_destroy (gr->surface);
+ gr->surface = NULL;
cairo_destroy (gr->cr);
+ gr->cr = NULL;
if (gr->drawbuf)
g_object_unref (gr->drawbuf);
+ gr->drawbuf = NULL;
if (gr->drawable)
g_object_unref (gr->drawable);
+ gr->drawable = NULL;
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;
if (gr->mode == MODE_JAVA_ARRAY)
{
(*env)->DeleteGlobalRef (env, gr->jarray);
if (gr->javabuf_copy)
g_free (gr->javabuf_copy);
+ gr->javabuf_copy = NULL;
}
if (gr->debug) printf ("disposed of graphics2d\n");
@@ -768,27 +723,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_dispose
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_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)
-{
- gdk_threads_enter();
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
- (env, obj,
- x1, y1, x2, y2,
- r1, g1, b1, a1,
- r2, g2, b2, a2,
- cyclic);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradient
(JNIEnv *env, jobject obj,
jdouble x1, jdouble y1,
jdouble x2, jdouble y2,
@@ -804,11 +739,16 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
if (gr->debug)
- printf ("setGradientUnlocked (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
+ printf ("setGradient (%f,%f) -> (%f,%f); (%d,%d,%d,%d) -> (%d,%d,%d,%d)\n",
x1, y1,
x2, y2,
r1, g1, b1, a1,
@@ -907,35 +847,30 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setGradientUnlocked
gr->pattern = cairo_pattern_create_for_surface(surf);
cairo_set_source (gr->cr, gr->pattern);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
- (JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
- (env, obj, jarr, w, h, stride);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixels
(JNIEnv *env, jobject obj, jintArray jarr, jint w, jint h, jint stride)
{
struct graphics2d *gr = NULL;
jint *jpixels = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug)
- printf ("setTexturePixelsUnlocked (%d pixels, %dx%d, stride: %d)\n",
+ printf ("setTexturePixels (%d pixels, %dx%d, stride: %d)\n",
(*env)->GetArrayLength (env, jarr), w, h, stride);
if (gr->pattern)
@@ -967,6 +902,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_setTexturePixelsUnlocked
g_assert (gr->pattern != NULL);
cairo_pattern_set_extend (gr->pattern, CAIRO_EXTEND_REPEAT);
cairo_set_source (gr->cr, gr->pattern);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1079,34 +1016,22 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRestore
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
- (JNIEnv *env, jobject obj, jdoubleArray java_matrix)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
- (env, obj, java_matrix);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrix
(JNIEnv *env, jobject obj, jdoubleArray java_matrix)
{
struct graphics2d *gr = NULL;
jdouble *native_matrix = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
- /* cairoSetMatrix was called before this graphics object's component
- was realized. */
- if (gr == NULL)
- return;
-
native_matrix = (*env)->GetDoubleArrayElements (env, java_matrix, NULL);
g_assert (native_matrix != NULL);
g_assert ((*env)->GetArrayLength (env, java_matrix) == 6);
@@ -1130,6 +1055,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMatrixUnlocked
(*env)->ReleaseDoubleArrayElements (env, java_matrix, native_matrix, 0);
update_pattern_transform (gr);
+
+ gdk_threads_leave();
}
static void
@@ -1142,37 +1069,43 @@ install_font_peer(cairo_t *cr,
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);
-
- if (debug) printf ("install_font_peer made new cairo font for '%s' at %f\n",
+
+ if (debug) printf ("install_font_peer made new cairo font for '%s' at %f\n",
face->family_name,
- (pango_font_description_get_size (pfont->desc) /
+ (pango_font_description_get_size (pfont->desc) /
(double)PANGO_SCALE));
-
- cairo_set_font_face (cr, ft);
+
+ 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));
+ 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
{
- if (debug) printf ("install_font_peer reused existing font resource\n");
+ if (debug) printf ("install_font_peer reused existing font resource"
+ " for '%s' at %f\n",
+ pango_font_description_get_family(pfont->desc),
+ (pango_font_description_get_size (pfont->desc) /
+ (double)PANGO_SCALE));
ft = (cairo_font_face_t *) pfont->graphics_resource;
- cairo_set_font_face (cr, ft);
+ cairo_set_font_face (cr, ft);
+ cairo_set_font_size (cr,
+ (pango_font_description_get_size (pfont->desc) /
+ (double)PANGO_SCALE));
}
}
-
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_releasePeerGraphicsResource
(JNIEnv *env, jclass clazz __attribute__ ((unused)), jobject java_font)
@@ -1253,7 +1186,7 @@ paint_glyph_run(JNIEnv *env,
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
- (JNIEnv *env, jobject self,
+ (JNIEnv *env, jobject obj,
jobject font,
jfloat x, jfloat y, jint n,
jintArray java_codes,
@@ -1269,17 +1202,17 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
gdk_threads_enter ();
- g_assert (self != NULL);
- g_assert (java_codes != NULL);
- g_assert (java_positions != NULL);
-
- if (peer_is_disposed(env, self))
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
return;
}
- gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
+ g_assert (obj != NULL);
+ g_assert (java_codes != NULL);
+ g_assert (java_positions != NULL);
+
+ gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, font);
@@ -1314,7 +1247,7 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGlyphVector
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
- (JNIEnv *env, jobject self, jobject java_layout, jfloat x, jfloat y)
+ (JNIEnv *env, jobject obj, jobject java_layout, jfloat x, jfloat y)
{
/*
* FIXME: Some day we expect either cairo or pango will know how to make
@@ -1328,12 +1261,10 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
cairo_glyph_t *glyphs = NULL;
gint n_glyphs = 0;
- gdk_threads_enter ();
-
- g_assert (self != NULL);
+ g_assert (obj != NULL);
g_assert (java_layout != NULL);
- gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, self);
+ gr = (struct graphics2d *)NSA_GET_G2D_PTR (env, obj);
tl = (struct textlayout *)NSA_GET_TEXT_LAYOUT_PTR (env, java_layout);
g_assert (gr != NULL);
@@ -1342,7 +1273,9 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoDrawGdkTextLayout
if (gr->debug) printf ("painting pango layout\n");
- if (peer_is_disposed(env, self))
+ gdk_threads_enter ();
+
+ if (peer_is_disposed(env, obj))
{
gdk_threads_leave();
return;
@@ -1443,25 +1376,18 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetOperator
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor
- (JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
- (env, obj, r, g, b, a);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColor
(JNIEnv *env, jobject obj, jdouble r, jdouble g, jdouble b, jdouble a)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1478,6 +1404,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetRGBAColorUnlocked
cairo_set_source_rgba (gr->cr, b, g, r, a);
else
cairo_set_source_rgba (gr->cr, r, g, b, a);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1505,58 +1433,46 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetFillRule
case java_awt_geom_path_iterator_WIND_EVEN_ODD:
cairo_set_fill_rule (gr->cr, CAIRO_FILL_RULE_EVEN_ODD);
break;
- }
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
- (JNIEnv *env, jobject obj, jdouble width)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked
- (env, obj, width);
+ }
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidthUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineWidth
(JNIEnv *env, jobject obj, jdouble width)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_line_width %f\n", width);
cairo_set_line_width (gr->cr, width);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
- (JNIEnv *env, jobject obj, jint cap)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
- (env, obj, cap);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCap
(JNIEnv *env, jobject obj, jint cap)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1575,28 +1491,23 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineCapUnlocked
cairo_set_line_cap (gr->cr, CAIRO_LINE_CAP_SQUARE);
break;
}
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
- (JNIEnv *env, jobject obj, jint join)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
- (env, obj, join);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoin
(JNIEnv *env, jobject obj, jint join)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1615,29 +1526,24 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetLineJoinUnlocked
cairo_set_line_join (gr->cr, CAIRO_LINE_JOIN_BEVEL);
break;
}
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
- (JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
- (env, obj, dashes, ndash, offset);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDash
(JNIEnv *env, jobject obj, jdoubleArray dashes, jint ndash, jdouble offset)
{
struct graphics2d *gr = NULL;
jdouble *dasharr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -1646,33 +1552,30 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetDashUnlocked
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_GdkGraphics2D_cairoSetMiterLimit
- (JNIEnv *env, jobject obj, jdouble miter)
-{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked
- (env, obj, miter);
gdk_threads_leave();
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimitUnlocked
+Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSetMiterLimit
(JNIEnv *env, jobject obj, jdouble miter)
{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
if (gr->debug) printf ("cairo_set_miter_limit %f\n", miter);
cairo_set_miter_limit (gr->cr, miter);
+
+ gdk_threads_leave();
}
JNIEXPORT void JNICALL
@@ -1681,6 +1584,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath
{
struct graphics2d *gr = NULL;
+ gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
+
gdk_threads_enter();
if (peer_is_disposed(env, obj))
@@ -1689,14 +1594,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoNewPath
return;
}
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
-
- if (gr == NULL)
- {
- gdk_threads_leave ();
- return;
- }
-
if (gr->debug) printf ("cairo_new_path\n");
cairo_new_path (gr->cr);
@@ -1845,6 +1742,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRectangle
{
struct graphics2d *gr = NULL;
+ gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
+
gdk_threads_enter();
if (peer_is_disposed(env, obj))
@@ -1853,14 +1752,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoRectangle
return;
}
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
-
- if (gr == NULL)
- {
- gdk_threads_leave ();
- return;
- }
-
if (gr->debug)
printf ("cairo_rectangle (%f, %f) (%f, %f)\n", x, y, width, height);
cairo_rectangle (gr->cr, x, y, width, height);
@@ -1944,6 +1835,8 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip
{
struct graphics2d *gr = NULL;
+ gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
+
gdk_threads_enter();
if (peer_is_disposed(env, obj))
@@ -1952,14 +1845,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoClip
return;
}
- gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
-
- if (gr == NULL)
- {
- gdk_threads_leave ();
- return;
- }
-
if (gr->debug) printf ("cairo_clip\n");
begin_drawing_operation (env, gr);
cairo_reset_clip (gr->cr);
@@ -1973,22 +1858,15 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilter
(JNIEnv *env, jobject obj, jint filter)
{
- gdk_threads_enter();
-
- Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
- (env, obj, filter);
-
- gdk_threads_leave();
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
- (JNIEnv *env, jobject obj, jint filter)
-{
struct graphics2d *gr = NULL;
+ gdk_threads_enter();
+
if (peer_is_disposed(env, obj))
- return;
+ {
+ gdk_threads_leave();
+ return;
+ }
gr = (struct graphics2d *) NSA_GET_G2D_PTR (env, obj);
g_assert (gr != NULL);
@@ -2015,4 +1893,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics2D_cairoSurfaceSetFilterUnlocked
cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST);
break;
}
+
+ gdk_threads_leave();
}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
index f44361972..ef9ac1207 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCanvasPeer.c
+++ b/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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
index b0d4ab9b0..4cd80a73f 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
+++ b/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. */
@@ -749,6 +754,20 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetForeground
}
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)
{
@@ -793,30 +812,6 @@ Java_gnu_java_awt_peer_gtk_GtkComponentPeer_isEnabled
}
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/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
index b40e86289..dad6a1182 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+++ b/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
@@ -324,7 +326,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
jint x, jint y, jint width, jint height, jboolean composite)
{
GdkPixbuf* dst;
- struct graphics *g;
+ struct graphics2d *g;
guint32 bgColor;
gdk_threads_enter ();
@@ -338,7 +340,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
bgColor = ((bg_red & 0xFF) << 16) |
((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
- g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj);
+ g = (struct graphics2d *) NSA_GET_G2D_PTR (env, gc_obj);
if (!g || !GDK_IS_DRAWABLE (g->drawable))
{
@@ -365,24 +367,16 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
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_cairo_set_source_pixbuf (g->cr, dst, (double) x, (double) y);
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);
+ cairo_xlib_surface_set_drawable (g->surface,
+ GDK_PIXMAP_XID(pixmap),
+ width,
+ height);
}
gdk_threads_leave ();
@@ -408,7 +402,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
{
GdkPixbuf *pixbuf;
GdkPixbuf *tmp, *dst;
- struct graphics *g;
+ struct graphics2d *g;
guint32 bgColor;
gdk_threads_enter ();
@@ -423,7 +417,7 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
bgColor = ((bg_red & 0xFF) << 16) |
((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
- g = (struct graphics *) NSA_GET_G_PTR (env, gc_obj);
+ g = (struct graphics2d *) NSA_GET_G2D_PTR (env, gc_obj);
if (!g || !GDK_IS_DRAWABLE (g->drawable))
{
@@ -492,14 +486,8 @@ Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
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_cairo_set_source_pixbuf (g->cr, dst, (double) dstx,
+ (double) dsty);
gdk_pixbuf_unref (dst);
gdk_threads_leave ();
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
index b14330e5f..c966f6331 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
+++ b/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/native/jni/gtk-peer/gtkcairopeer.h b/native/jni/gtk-peer/gtkcairopeer.h
deleted file mode 100644
index dee843c8a..000000000
--- a/native/jni/gtk-peer/gtkcairopeer.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef __GTKCAIROPEER_H__
-#define __GTKCAIROPEER_H__
-
-/* gtkcairopeer.h -- Some global variables and #defines
- Copyright (C) 1998, 1999 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"
-#include <cairo.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-/*
- A graphics2d struct is both simpler and uglier than a graphics
- struct.
-
- Most of the graphics2d drawing state is held in the referenced cairo_t
- and corresponding cairo_surface_t, so we can ignore it.
-
- In addition to the cairo_t, we need to hold an extra reference to the
- underlying GdkDrawable so its refcount matches the lifecycle of the java
- Graphics object which is peering with us; also a reference to a byte
- buffer and cairo_surface_t which contain the pattern you're drawing from
- (if it exists).
-
- Finally, it is possible that we are using a non-RENDER capable X server,
- therefore we will be drawing to an cairo_surface_t which is actually a
- pixbuf. When this is the case, the pointer to a GdkPixbuf will be
- non-NULL and any drawing operation needs to be bracketed by pixbuf
- load/save operations. If the GdkPixbuf pointer is NULL, we will treat
- the cairo_surface_t as RENDER-capable.
- */
-
-struct graphics2d
-{
- cairo_t *cr;
- cairo_surface_t *surface;
- GdkDrawable *drawable;
- GdkWindow *win;
- GdkPixbuf *drawbuf;
- char *pattern_pixels;
- cairo_surface_t *pattern_surface;
- cairo_pattern_t *pattern;
- gboolean debug;
- enum
- {
- MODE_DRAWABLE_WITH_RENDER,
- MODE_DRAWABLE_NO_RENDER,
- MODE_JAVA_ARRAY
- }
- mode;
-
- /* Support for MODE_JAVA_ARRAY */
- jintArray jarray;
- jint width, height;
- jint *javabuf;
- jint *javabuf_copy;
- jboolean isCopy;
-};
-
-#endif /* __GTKCAIROPEER_H */
diff --git a/native/jni/gtk-peer/gtkpeer.h b/native/jni/gtk-peer/gtkpeer.h
index 9a1590b81..6ae7b06ae 100644
--- a/native/jni/gtk-peer/gtkpeer.h
+++ b/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,32 +86,66 @@ 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
+/*
+ A graphics2d struct is both simpler and uglier than a graphics
+ struct.
+
+ Most of the graphics2d drawing state is held in the referenced cairo_t
+ and corresponding cairo_surface_t, so we can ignore it.
+
+ In addition to the cairo_t, we need to hold an extra reference to the
+ underlying GdkDrawable so its refcount matches the lifecycle of the java
+ Graphics object which is peering with us; also a reference to a byte
+ buffer and cairo_surface_t which contain the pattern you're drawing from
+ (if it exists).
+
+ Finally, it is possible that we are using a non-RENDER capable X server,
+ therefore we will be drawing to an cairo_surface_t which is actually a
+ pixbuf. When this is the case, the pointer to a GdkPixbuf will be
+ non-NULL and any drawing operation needs to be bracketed by pixbuf
+ load/save operations. If the GdkPixbuf pointer is NULL, we will treat
+ the cairo_surface_t as RENDER-capable.
+ */
+struct graphics2d
{
+ cairo_t *cr;
+ cairo_surface_t *surface;
GdkDrawable *drawable;
- GdkGC *gc;
- GdkColormap *cm;
- PangoFontDescription *pango_font;
- PangoContext *pango_context;
- PangoLayout *pango_layout;
- jint x_offset, y_offset;
+ GdkWindow *win;
+ GdkPixbuf *drawbuf;
+ char *pattern_pixels;
+ cairo_surface_t *pattern_surface;
+ cairo_pattern_t *pattern;
+ gboolean debug;
+ enum
+ {
+ MODE_DRAWABLE_WITH_RENDER,
+ MODE_DRAWABLE_NO_RENDER,
+ MODE_JAVA_ARRAY
+ }
+ mode;
+
+ /* Support for MODE_JAVA_ARRAY */
+ jintArray jarray;
+ jint width, height;
+ jint *javabuf;
+ jint *javabuf_copy;
+ jboolean isCopy;
};
/* New-style event masks. */
@@ -196,10 +233,6 @@ GdkPixmap *cp_gtk_image_get_pixmap (JNIEnv *env, jobject obj);
jboolean cp_gtk_image_is_offscreen (JNIEnv *env, jobject obj);
/* 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);
diff --git a/native/jni/java-net/Makefile.am b/native/jni/java-net/Makefile.am
index e48173a16..26bb64f73 100644
--- a/native/jni/java-net/Makefile.am
+++ b/native/jni/java-net/Makefile.am
@@ -12,11 +12,12 @@ libjavanet_la_SOURCES = javanet.c \
javanet.h \
java_net_VMInetAddress.c \
java_net_VMNetworkInterface.c \
+ java_net_VMURLConnection.c \
gnu_java_net_VMPlainDatagramSocketImpl.c \
gnu_java_net_VMPlainSocketImpl.c \
$(local_sources)
-libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo
+libjavanet_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo $(LIBMAGIC)
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/native/jni/java-net/java_net_VMURLConnection.c b/native/jni/java-net/java_net_VMURLConnection.c
new file mode 100644
index 000000000..52fae0ccb
--- /dev/null
+++ b/native/jni/java-net/java_net_VMURLConnection.c
@@ -0,0 +1,102 @@
+/* VMURLConnection.c - native bits for URLConnection
+ 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 <config.h>
+
+#include <java_net_VMURLConnection.h>
+
+#ifdef HAVE_MAGIC_H
+
+#include <magic.h>
+
+static magic_t cookie;
+
+#endif /* HAVE_MAGIC_H */
+
+void
+Java_java_net_VMURLConnection_init (JNIEnv *env __attribute__ ((__unused__)),
+ jclass klass __attribute__ ((__unused__)))
+{
+#ifdef HAVE_MAGIC_H
+ cookie = magic_open (MAGIC_MIME);
+ if (cookie == (magic_t) NULL)
+ return;
+ if (magic_load (cookie, NULL) == -1)
+ {
+ magic_close (cookie);
+ cookie = (magic_t) NULL;
+ }
+#endif /* HAVE_MAGIC_H */
+}
+
+#ifdef HAVE_MAGIC_H
+jstring
+Java_java_net_VMURLConnection_guessContentTypeFromBuffer (JNIEnv *env,
+ jclass klass
+ __attribute__ ((__unused__)),
+ jbyteArray bytes,
+ jint valid)
+{
+ jbyte *elements;
+ const char *result;
+
+ if (cookie == (magic_t) NULL)
+ return NULL;
+
+ elements = (*env)->GetByteArrayElements (env, bytes, NULL);
+ result = magic_buffer (cookie, elements, valid);
+
+ /* The mode we use doesn't matter, since we don't change the array. */
+ (*env)->ReleaseByteArrayElements (env, bytes, elements, JNI_ABORT);
+
+ if (result == NULL)
+ return NULL;
+ return (*env)->NewStringUTF (env, result);
+#else
+jstring
+Java_java_net_VMURLConnection_guessContentTypeFromBuffer (JNIEnv *env
+ __attribute__ ((__unused__)),
+ jclass klass
+ __attribute__ ((__unused__)),
+ jbyteArray bytes
+ __attribute__ ((__unused__)),
+ jint valid
+ __attribute__ ((__unused__)))
+{
+ return NULL;
+#endif /* HAVE_MAGIC_H */
+}
diff --git a/native/jni/qt-peer/eventmethods.h b/native/jni/qt-peer/eventmethods.h
index ea5d45a5c..ae56da8e7 100644
--- a/native/jni/qt-peer/eventmethods.h
+++ b/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/resource/gnu/classpath/tools/jarsigner/MessageBundle.properties b/resource/gnu/classpath/tools/jarsigner/messages.properties
index 565041f21..4383256de 100644
--- a/resource/gnu/classpath/tools/jarsigner/MessageBundle.properties
+++ b/resource/gnu/classpath/tools/jarsigner/messages.properties
@@ -1,4 +1,42 @@
-# default locale messages for gnu.classpath.tools.jarsigner package
+# messages.properties -- English language messages and message formats
+# 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.
+#
+# for gnu.classpath.tools.jarsigner package
+#
Main.7=jarsigner:
Main.9=jarsigner error:
diff --git a/resource/gnu/classpath/tools/keytool/MessageBundle.properties b/resource/gnu/classpath/tools/keytool/messages.properties
index 2362d6a84..71b70a766 100644
--- a/resource/gnu/classpath/tools/keytool/MessageBundle.properties
+++ b/resource/gnu/classpath/tools/keytool/messages.properties
@@ -1,4 +1,42 @@
-# default locale messages for gnu.classpath.tools.keytool package
+# messages.properties -- English language messages and message formats
+# 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.
+#
+# for gnu.classpath.tools.keytool package
+#
Main.6=keytool: {0}
Main.8=keytool error: {0}
@@ -396,6 +434,7 @@ ImportCmd.10=Fully qualified class name of a Security Provider to add to the \
JVM in-use.
ImportCmd.9=PROVIDER_CLASS_NAME
ImportCmd.8=Emit more verbose messages.
+ImportCmd.7=Was unable to build a certificate-chain. Only {0,number} out of {1,number} certificates were processed
ExportCmd.17=Usage: keytool -export [OPTION]...\n\
Export a certificate stored in the key store to a designated output \
diff --git a/resource/gnu/classpath/tools/native2ascii/messages.properties b/resource/gnu/classpath/tools/native2ascii/messages.properties
new file mode 100644
index 000000000..ab860c8d2
--- /dev/null
+++ b/resource/gnu/classpath/tools/native2ascii/messages.properties
@@ -0,0 +1,43 @@
+# messages.properties -- English language messages
+# 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.
+
+Native2ASCII.TooManyFiles=too many files specified
+Native2ASCII.Usage=Usage: native2ascii [OPTIONS]... [INPUTFILE [OUTPUTFILE]]
+Native2ASCII.EncodingHelp=encoding to use
+Native2ASCII.EncodingArgName=NAME
+Native2ASCII.EncodingSpecified=encoding already specified
+Native2ASCII.ReversedHelp=convert from encoding to native
diff --git a/resource/gnu/classpath/tools/serialver/messages.properties b/resource/gnu/classpath/tools/serialver/messages.properties
new file mode 100644
index 000000000..8900795d4
--- /dev/null
+++ b/resource/gnu/classpath/tools/serialver/messages.properties
@@ -0,0 +1,44 @@
+# messages.properties -- English language messages
+# 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.
+
+SerialVer.NoClassesSpecd=no classes specified
+SerialVer.HelpHeader=serialver [OPTIONS]... CLASS...\n\nPrint the serialVersionUID of the specified classes
+SerialVer.5=classpath
+SerialVer.ClasspathHelp=class path to use to find classes
+SerialVer.ClassNotSerial=serialver: class {0} is not serializable
+SerialVer.ClassNotFound=serialver: class {0} not found
+SerialVer.DupClasspath=classpath already specified
diff --git a/scripts/check_jni_methods.sh b/scripts/check_jni_methods.sh
index 243bb7e4a..999e143ec 100755
--- a/scripts/check_jni_methods.sh
+++ b/scripts/check_jni_methods.sh
@@ -29,7 +29,7 @@ find native/jni -name \*.cpp | \
cut -f4 -d\ | \
LC_ALL=C sed -e 's,^\JNIEXPORT .* JNICALL \(Java_[a-z_A-Z0-9]*\) *(.*$,\1,' >> $TMPFILE2
mv $TMPFILE2 $TMPFILE3
-sort $TMPFILE3 > $TMPFILE2
+sort $TMPFILE3 | uniq > $TMPFILE2
rm $TMPFILE3
# Write temporary ignore file.
diff --git a/tools/Makefile.am b/tools/Makefile.am
index cd69bc04f..713c5827a 100755
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -13,8 +13,46 @@ error dunno how to setup the JCOMPILER and compile
endif
endif
+if CREATE_WRAPPERS
+bin_SCRIPTS =
+bin_PROGRAMS = appletviewer jarsigner keytool
+
+#if FOUND_GCJ
+#LIBJVM = -lgcj
+#else
+if FOUND_CACAO
+LIBJVM = -lcacaovm
+else
+LIBJVM =
+endif
+#endif
+
+appletviewer_SOURCES = toolwrapper.c
+appletviewer_CFLAGS = -Wall \
+ -DDATA_DIR="\"$(datadir)\"" \
+ -DPACKAGE="\"$(PACKAGE)\"" \
+ -DTOOLNAME="\"appletviewer\""
+appletviewer_LDFLAGS = $(LIBJVM)
+
+jarsigner_SOURCES = toolwrapper.c
+jarsigner_CFLAGS = -Wall \
+ -DDATA_DIR="\"$(datadir)\"" \
+ -DPACKAGE="\"$(PACKAGE)\"" \
+ -DTOOLNAME="\"jarsigner\""
+jarsigner_LDFLAGS = $(LIBJVM)
+
+keytool_SOURCES = toolwrapper.c
+keytool_CFLAGS = -Wall \
+ -DDATA_DIR="\"$(datadir)\"" \
+ -DPACKAGE="\"$(PACKAGE)\"" \
+ -DTOOLNAME="\"keytool\""
+keytool_LDFLAGS = $(LIBJVM)
+
+else
bin_SCRIPTS = appletviewer jarsigner keytool
-EXTRA_DIST = appletviewer.in appletviewer.c jarsigner.in keytool.in
+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
@@ -88,3 +126,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/tools/gnu/classpath/tools/appletviewer/AppletTag.java b/tools/gnu/classpath/tools/appletviewer/AppletTag.java
index b2d7ccb2b..4c3d01edb 100644
--- a/tools/gnu/classpath/tools/appletviewer/AppletTag.java
+++ b/tools/gnu/classpath/tools/appletviewer/AppletTag.java
@@ -451,15 +451,19 @@ class AppletTag
else
{
String dirname = documentbase.getFile();
-
- // 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);
+ if (!new File(dirname).isFile())
+ 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
diff --git a/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java b/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
index 0c44745c9..455389127 100644
--- a/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
+++ b/tools/gnu/classpath/tools/getopt/FileArgumentCallback.java
@@ -57,5 +57,6 @@ public abstract class FileArgumentCallback
*
* @param fileArgument the file name
*/
- public abstract void notifyFile(String fileArgument);
+ public abstract void notifyFile(String fileArgument)
+ throws OptionException;
}
diff --git a/tools/gnu/classpath/tools/jar/Extractor.java b/tools/gnu/classpath/tools/jar/Extractor.java
index ed647cbfe..203ff0566 100644
--- a/tools/gnu/classpath/tools/jar/Extractor.java
+++ b/tools/gnu/classpath/tools/jar/Extractor.java
@@ -45,9 +45,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -55,8 +52,7 @@ public class Extractor
extends Action
{
// This is a set of all the items specified on the command line.
- // It is null if none were specified.
- private HashSet allItems;
+ private WorkSet allItems;
private void copyFile(InputStream input, File output) throws IOException
{
@@ -72,43 +68,10 @@ public class Extractor
os.close();
}
- 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);
- }
- }
-
- private boolean shouldExtract(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;
- }
-
public void run(Main parameters) throws IOException
{
// Figure out what we want to extract.
- initSet(parameters.entries);
+ allItems = new WorkSet(parameters.entries);
// Open the input file.
ZipInputStream zis;
File zfile = parameters.archiveFile;
@@ -125,7 +88,7 @@ public class Extractor
ZipEntry entry = zis.getNextEntry();
if (entry == null)
break;
- if (! shouldExtract(entry.getName()))
+ if (! allItems.contains(entry.getName()))
continue;
File file = new File(entry.getName());
if (entry.isDirectory())
diff --git a/tools/gnu/classpath/tools/jar/Lister.java b/tools/gnu/classpath/tools/jar/Lister.java
index ee4fb725e..98275f789 100644
--- a/tools/gnu/classpath/tools/jar/Lister.java
+++ b/tools/gnu/classpath/tools/jar/Lister.java
@@ -42,6 +42,7 @@ 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;
@@ -50,6 +51,22 @@ 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;
@@ -60,11 +77,15 @@ public class Lister
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.
- long size = entry.getSize();
String s = " " + size;
int index = Math.min(s.length() - 5, 5);
System.out.print(s.substring(index));
@@ -79,6 +100,7 @@ public class Lister
public void run(Main parameters) throws IOException
{
+ allItems = new WorkSet(parameters.entries);
File file = parameters.archiveFile;
ZipInputStream zis;
if (file == null || "-".equals(file.getName()))
diff --git a/tools/gnu/classpath/tools/jar/WorkSet.java b/tools/gnu/classpath/tools/jar/WorkSet.java
new file mode 100644
index 000000000..ff0b48786
--- /dev/null
+++ b/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/tools/gnu/classpath/tools/jarsigner/Messages.java b/tools/gnu/classpath/tools/jarsigner/Messages.java
index 284639115..35f461669 100644
--- a/tools/gnu/classpath/tools/jarsigner/Messages.java
+++ b/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/tools/gnu/classpath/tools/keytool/ImportCmd.java b/tools/gnu/classpath/tools/keytool/ImportCmd.java
index 2d587be08..7a4b6dfb6 100644
--- a/tools/gnu/classpath/tools/keytool/ImportCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ImportCmd.java
@@ -52,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;
@@ -62,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;
@@ -186,6 +190,12 @@ import javax.security.auth.callback.UnsupportedCallbackException;
class ImportCmd extends Command
{
private static final Logger log = Logger.getLogger(ImportCmd.class.getName());
+ 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;
@@ -197,6 +207,20 @@ class ImportCmd extends Command
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
@@ -288,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
@@ -608,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)
@@ -664,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();
- // FIXME: really order it!
-
+ 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;
}
@@ -712,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)
{
@@ -737,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;
@@ -771,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"); //$NON-NLS-1$
- 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
{
@@ -810,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/tools/gnu/classpath/tools/keytool/Messages.java b/tools/gnu/classpath/tools/keytool/Messages.java
index e3308e021..7ecaa1c37 100644
--- a/tools/gnu/classpath/tools/keytool/Messages.java
+++ b/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/tools/gnu/classpath/tools/native2ascii/Messages.java b/tools/gnu/classpath/tools/native2ascii/Messages.java
new file mode 100644
index 000000000..4c6bae4dc
--- /dev/null
+++ b/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/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java b/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
new file mode 100644
index 000000000..9508c103e
--- /dev/null
+++ b/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/tools/gnu/classpath/tools/serialver/Messages.java b/tools/gnu/classpath/tools/serialver/Messages.java
new file mode 100644
index 000000000..a6ab67add
--- /dev/null
+++ b/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/tools/gnu/classpath/tools/serialver/SerialVer.java b/tools/gnu/classpath/tools/serialver/SerialVer.java
new file mode 100644
index 000000000..b5a12ec92
--- /dev/null
+++ b/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/tools/appletviewer.c b/tools/toolwrapper.c
index 2609ccaf6..de6556c63 100644
--- a/tools/appletviewer.c
+++ b/tools/toolwrapper.c
@@ -1,5 +1,5 @@
-/* appletviewer.c -- a native appletviewer wrapper for VMs that
- support the JNI invocation interface
+/* 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.
@@ -37,7 +37,6 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
#include <jni.h>
-#include <glib.h>
#include <string.h>
#include <stdlib.h>
#include "config.h"
@@ -93,41 +92,27 @@ main (int argc, const char** argv)
if (vm_args.options == NULL)
{
- g_printerr ("appletviewer: realloc failed.\n");
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
goto destroy;
}
if (strlen (argv[i]) == 2)
{
- g_printerr ("appletviewer: the -J option must not be followed by a space.\n");
+ fprintf (stderr, TOOLNAME ": the -J option must not be followed by a space.\n");
goto destroy;
}
else
- vm_args.options[vm_args.nOptions++].optionString = g_strdup (argv[i] + 2);
- }
- else if (!strncmp (argv[i], "--version", 9)
- && argv[i][9] == '\0')
- {
- g_print ("appletviewer (GCJ Applet Viewer) " PACKAGE_VERSION "\n");
- exit (0);
- }
- else if (!strncmp (argv[i], "-debug", 6)
- && argv[i][6] == '\0')
- {
- /* FIXME: Ignore for now. The debug option will be
- unsupported until we have the ability to debug
- bytecode. For now, just strip it out of the argument
- list. */
+ 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)
{
- g_printerr ("appletviewer: realloc failed.\n");
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
goto destroy;
}
- non_vm_argv[non_vm_argc++] = g_strdup (argv[i]);
+ non_vm_argv[non_vm_argc++] = strdup (argv[i]);
}
}
}
@@ -139,18 +124,18 @@ main (int argc, const char** argv)
if (vm_args.options == NULL)
{
- g_printerr ("appletviewer: realloc failed.\n");
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
goto destroy;
}
- vm_args.options[vm_args.nOptions++].optionString = "-Djava.class.path=" "@datadir@/@PACKAGE@/tools.zip";
+ 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)
{
- g_printerr ("appletviewer: realloc failed.\n");
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
goto destroy;
}
vm_args.options[vm_args.nOptions].optionString = NULL;
@@ -159,7 +144,7 @@ main (int argc, const char** argv)
non_vm_argv = (char**) realloc (non_vm_argv, (non_vm_argc + 1) * sizeof (char*));
if (non_vm_argv == NULL)
{
- g_printerr ("appletviewer: realloc failed.\n");
+ fprintf (stderr, TOOLNAME ": realloc failed.\n");
goto destroy;
}
non_vm_argv[non_vm_argc] = NULL;
@@ -171,7 +156,7 @@ main (int argc, const char** argv)
if (result < 0)
{
- g_printerr ("appletviewer: couldn't create virtual machine\n");
+ fprintf (stderr, TOOLNAME ": couldn't create virtual machine\n");
goto destroy;
}
@@ -180,14 +165,14 @@ main (int argc, const char** argv)
string_class_id = (*env)->FindClass (env, "java/lang/String");
if (string_class_id == NULL)
{
- g_printerr ("appletviewer: FindClass failed.\n");
+ fprintf (stderr, TOOLNAME ": FindClass failed.\n");
goto destroy;
}
args_array = (*env)->NewObjectArray (env, non_vm_argc, string_class_id, NULL);
if (args_array == NULL)
{
- g_printerr ("appletviewer: NewObjectArray failed.\n");
+ fprintf (stderr, TOOLNAME ": NewObjectArray failed.\n");
goto destroy;
}
@@ -196,17 +181,17 @@ main (int argc, const char** argv)
str = (*env)->NewStringUTF (env, non_vm_argv[i]);
if (str == NULL)
{
- g_printerr ("appletviewer: NewStringUTF failed.\n");
+ fprintf (stderr, TOOLNAME ": NewStringUTF failed.\n");
goto destroy;
}
(*env)->SetObjectArrayElement (env, args_array, i, str);
}
- class_id = (*env)->FindClass (env, "gnu/classpath/tools/appletviewer/Main");
+ class_id = (*env)->FindClass (env, "gnu/classpath/tools/" TOOLNAME "/Main");
if (class_id == NULL)
{
- g_printerr ("appletviewer: FindClass failed.\n");
+ fprintf (stderr, TOOLNAME ": FindClass failed.\n");
goto destroy;
}
@@ -214,7 +199,7 @@ main (int argc, const char** argv)
if (method_id == NULL)
{
- g_printerr ("appletviewer: GetStaticMethodID failed.\n");
+ fprintf (stderr, TOOLNAME ": GetStaticMethodID failed.\n");
goto destroy;
}
diff --git a/vm/reference/java/lang/VMClassLoader.java b/vm/reference/java/lang/VMClassLoader.java
index 4caa58c2a..897df5186 100644
--- a/vm/reference/java/lang/VMClassLoader.java
+++ b/vm/reference/java/lang/VMClassLoader.java
@@ -75,6 +75,10 @@ final class VMClassLoader
/** packages loaded by the bootstrap class loader */
static final HashMap definedPackages = new HashMap();
+ /** jars from property java.boot.class.path */
+ static final HashMap bootjars = new HashMap();
+
+
/**
* Converts the array string of native package names to
* Packages. The packages are then put into the
@@ -168,10 +172,6 @@ final class VMClassLoader
return (URL)e.nextElement();
return null;
}
-
- /** jars from property java.boot.class.path */
- static final HashMap bootjars = new HashMap();
-
/**
* Helper to get a list of resources from the bootstrap class loader.
*
diff --git a/vm/reference/java/net/VMURLConnection.java b/vm/reference/java/net/VMURLConnection.java
new file mode 100644
index 000000000..19bf5814e
--- /dev/null
+++ b/vm/reference/java/net/VMURLConnection.java
@@ -0,0 +1,79 @@
+/* VMURLConnection - VM code for URLConnection
+ 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 java.net;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+final class VMURLConnection
+{
+ public static final int LENGTH = 1024;
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("javanet");
+ init();
+ }
+
+ private static native void init();
+
+ private static native String guessContentTypeFromBuffer(byte[] b, int valid);
+
+ /**
+ * This is called from URLConnection to guess the mime type of a
+ * stream. This method may return null to indicate that it could
+ * not guess a type.
+ */
+ static String guessContentTypeFromStream(InputStream is)
+ throws IOException
+ {
+ if (! is.markSupported())
+ return null;
+ is.mark(LENGTH);
+ byte[] bytes = new byte[LENGTH];
+ int r = is.read(bytes);
+ if (r < 0)
+ return null;
+ is.reset();
+ return guessContentTypeFromBuffer(bytes, r);
+ }
+}