summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-10-05 02:44:18 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-10-05 02:44:18 +0000
commit2799793789d5b66c90efbd1a3eb56e0c1ec57f88 (patch)
tree9157197f502b6830af9cafe029fd3d47628a7ed6
parent7516107c5abe26f7a4378017344eb9e449ebc28e (diff)
downloadclasspath-2799793789d5b66c90efbd1a3eb56e0c1ec57f88.tar.gz
2006-10-05 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD-->generics for 2006/09/03-2006/10/04.
-rw-r--r--ChangeLog2139
-rw-r--r--INSTALL17
-rw-r--r--NEWS31
-rw-r--r--configure.ac36
-rw-r--r--examples/Makefile.am2
-rw-r--r--examples/gnu/classpath/examples/CORBA/NamingService/Demo.java3
-rw-r--r--gnu/CORBA/CDR/Vio.java5
-rw-r--r--gnu/CORBA/CollocatedOrbs.java164
-rw-r--r--gnu/CORBA/NamingService/Binding_iterator_impl.java6
-rw-r--r--gnu/CORBA/NamingService/Ext.java6
-rw-r--r--gnu/CORBA/NamingService/NameParser.java3
-rw-r--r--gnu/CORBA/NamingService/NameTransformer.java6
-rw-r--r--gnu/CORBA/NamingService/NamingServiceTransient.java42
-rw-r--r--gnu/CORBA/NamingService/TransientContext.java4
-rw-r--r--gnu/CORBA/OrbFunctional.java112
-rw-r--r--gnu/CORBA/Poa/LocalRequest.java7
-rw-r--r--gnu/CORBA/Poa/gnuPOA.java2
-rw-r--r--gnu/CORBA/Poa/gnuServantObject.java15
-rw-r--r--gnu/CORBA/SafeForDirectCalls.java50
-rw-r--r--gnu/CORBA/SimpleDelegate.java40
-rw-r--r--gnu/classpath/ListenerData.java136
-rw-r--r--gnu/java/awt/LowPriorityEvent.java (renamed from tools/gnu/classpath/tools/rmi/registry/package.html)22
-rw-r--r--gnu/java/awt/java2d/AbstractGraphics2D.java178
-rw-r--r--gnu/java/awt/java2d/ShapeCache.java85
-rw-r--r--gnu/java/awt/java2d/TexturePaintContext.java2
-rw-r--r--gnu/java/awt/peer/gtk/BufferedImageGraphics.java6
-rw-r--r--gnu/java/awt/peer/gtk/CairoGraphics2D.java213
-rw-r--r--gnu/java/awt/peer/gtk/CairoSurface.java51
-rw-r--r--gnu/java/awt/peer/gtk/FreetypeGlyphVector.java115
-rw-r--r--gnu/java/awt/peer/gtk/VolatileImageGraphics.java200
-rw-r--r--gnu/java/lang/management/MemoryMXBeanImpl.java45
-rw-r--r--gnu/java/net/PlainDatagramSocketImpl.java207
-rw-r--r--gnu/java/net/PlainSocketImpl.java352
-rw-r--r--gnu/java/net/protocol/http/HTTPURLConnection.java8
-rw-r--r--gnu/java/nio/DatagramChannelImpl.java165
-rw-r--r--gnu/java/nio/DatagramChannelSelectionKey.java13
-rw-r--r--gnu/java/nio/EpollSelectionKeyImpl.java122
-rw-r--r--gnu/java/nio/EpollSelectorImpl.java399
-rw-r--r--gnu/java/nio/FileChannelImpl.java (renamed from gnu/java/nio/channels/FileChannelImpl.java)173
-rw-r--r--gnu/java/nio/FileLockImpl.java2
-rw-r--r--gnu/java/nio/KqueueSelectionKeyImpl.java189
-rw-r--r--gnu/java/nio/KqueueSelectorImpl.java524
-rw-r--r--gnu/java/nio/NIOSocket.java29
-rw-r--r--gnu/java/nio/NIOSocketImpl.java110
-rw-r--r--gnu/java/nio/PipeImpl.java34
-rw-r--r--gnu/java/nio/SelectionKeyImpl.java1
-rw-r--r--gnu/java/nio/SelectorProviderImpl.java37
-rw-r--r--gnu/java/nio/ServerSocketChannelImpl.java39
-rw-r--r--gnu/java/nio/ServerSocketChannelSelectionKey.java13
-rw-r--r--gnu/java/nio/SocketChannelImpl.java262
-rw-r--r--gnu/java/nio/SocketChannelSelectionKey.java13
-rw-r--r--gnu/java/nio/SocketChannelSelectionKeyImpl.java11
-rw-r--r--gnu/java/nio/VMChannelOwner.java57
-rw-r--r--gnu/java/nio/charset/ByteCharset.java16
-rw-r--r--gnu/java/nio/charset/ISO_8859_1.java13
-rw-r--r--gnu/java/nio/charset/US_ASCII.java15
-rw-r--r--gnu/java/rmi/server/ActivatableRef.java8
-rw-r--r--gnu/java/util/prefs/GConfBasedPreferences.java27
-rw-r--r--gnu/java/util/prefs/gconf/GConfNativePeer.java53
-rw-r--r--gnu/java/util/regex/RETokenRepeated.java198
-rw-r--r--gnu/xml/dom/DomNode.java1
-rw-r--r--gnu/xml/dom/ls/SAXEventSink.java8
-rw-r--r--gnu/xml/transform/SAXTemplatesHandler.java97
-rw-r--r--gnu/xml/transform/SAXTransformerHandler.java111
-rw-r--r--gnu/xml/transform/StreamSerializer.java3
-rw-r--r--gnu/xml/transform/TransformerFactoryImpl.java52
-rw-r--r--gnu/xml/transform/XSLURIResolver.java21
-rw-r--r--gnu/xml/xpath/Expr.java35
-rw-r--r--include/Makefile.am17
-rw-r--r--include/gnu_java_awt_peer_gtk_CairoGraphics2D.h5
-rw-r--r--include/gnu_java_awt_peer_gtk_CairoSurface.h2
-rw-r--r--include/gnu_java_net_VMPlainSocketImpl.h161
-rw-r--r--include/gnu_java_nio_EpollSelectorImpl.h95
-rw-r--r--include/gnu_java_nio_FileChannelImpl.h25
-rw-r--r--include/gnu_java_nio_KqueueSelectorImpl.h97
-rw-r--r--include/gnu_java_nio_VMChannel.h293
-rw-r--r--include/gnu_java_nio_VMPipe.h22
-rw-r--r--include/gnu_java_util_prefs_gconf_GConfNativePeer.h6
-rw-r--r--include/java_net_VMInetAddress.h1
-rw-r--r--include/java_net_VMNetworkInterface.h28
-rw-r--r--java/awt/AWTEvent.java5
-rw-r--r--java/awt/Choice.java4
-rw-r--r--java/awt/Component.java438
-rw-r--r--java/awt/Container.java215
-rw-r--r--java/awt/EventQueue.java324
-rw-r--r--java/awt/Frame.java17
-rw-r--r--java/awt/GridLayout.java2
-rw-r--r--java/awt/LightweightDispatcher.java382
-rw-r--r--java/awt/List.java1745
-rw-r--r--java/awt/Menu.java641
-rw-r--r--java/awt/Rectangle.java22
-rw-r--r--java/awt/Window.java54
-rw-r--r--java/awt/geom/RoundRectangle2D.java415
-rw-r--r--java/awt/image/AffineTransformOp.java314
-rw-r--r--java/awt/image/BandCombineOp.java26
-rw-r--r--java/awt/image/BufferedImage.java1
-rw-r--r--java/awt/image/ColorModel.java40
-rw-r--r--java/awt/image/ComponentColorModel.java9
-rw-r--r--java/awt/image/ConvolveOp.java15
-rw-r--r--java/awt/image/DirectColorModel.java16
-rw-r--r--java/awt/image/IndexColorModel.java17
-rw-r--r--java/awt/image/LookupOp.java141
-rw-r--r--java/awt/image/MemoryImageSource.java70
-rw-r--r--java/awt/image/RescaleOp.java293
-rw-r--r--java/io/FileDescriptor.java2
-rw-r--r--java/io/FileInputStream.java20
-rw-r--r--java/io/FileOutputStream.java26
-rw-r--r--java/io/InputStreamReader.java2
-rw-r--r--java/io/ObjectStreamClass.java4
-rw-r--r--java/io/PipedInputStream.java4
-rw-r--r--java/io/PipedReader.java4
-rw-r--r--java/io/RandomAccessFile.java17
-rw-r--r--java/net/DatagramSocket.java37
-rw-r--r--java/net/Inet4Address.java68
-rw-r--r--java/net/Inet6Address.java9
-rw-r--r--java/net/InetAddress.java379
-rw-r--r--java/net/NetworkInterface.java148
-rw-r--r--java/net/ResolverCache.java269
-rw-r--r--java/net/ServerSocket.java81
-rw-r--r--java/net/Socket.java87
-rw-r--r--java/net/SocketPermission.java171
-rw-r--r--java/nio/channels/spi/AbstractSelectableChannel.java15
-rw-r--r--java/text/AttributedCharacterIterator.java24
-rw-r--r--java/text/AttributedString.java76
-rw-r--r--java/text/AttributedStringIterator.java27
-rw-r--r--java/util/IdentityHashMap.java230
-rw-r--r--java/util/Locale.java36
-rw-r--r--java/util/logging/LogManager.java33
-rw-r--r--javax/management/BadBinaryOpValueExpException.java102
-rw-r--r--javax/management/MBeanServer.java1199
-rw-r--r--javax/management/MBeanServerConnection.java768
-rw-r--r--javax/management/MBeanServerDelegate.java308
-rw-r--r--javax/management/MBeanServerDelegateMBean.java101
-rw-r--r--javax/management/MBeanServerNotification.java103
-rw-r--r--javax/management/ObjectInstance.java147
-rw-r--r--javax/management/ObjectName.java775
-rw-r--r--javax/management/QueryExp.java87
-rw-r--r--javax/management/ValueExp.java86
-rw-r--r--javax/management/loading/ClassLoaderRepository.java139
-rw-r--r--javax/rmi/CORBA/Tie.java6
-rw-r--r--javax/swing/AbstractButton.java7
-rw-r--r--javax/swing/AbstractSpinnerModel.java10
-rw-r--r--javax/swing/JButton.java2
-rw-r--r--javax/swing/JMenuBar.java33
-rw-r--r--javax/swing/JMenuItem.java9
-rw-r--r--javax/swing/JScrollBar.java113
-rw-r--r--javax/swing/JTabbedPane.java7
-rw-r--r--javax/swing/JTable.java37
-rw-r--r--javax/swing/JToggleButton.java5
-rw-r--r--javax/swing/JTree.java2
-rw-r--r--javax/swing/JViewport.java98
-rw-r--r--javax/swing/RepaintManager.java68
-rw-r--r--javax/swing/SizeSequence.java8
-rw-r--r--javax/swing/UIManager.java251
-rw-r--r--javax/swing/plaf/basic/BasicButtonUI.java46
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameTitlePane.java10
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameUI.java7
-rw-r--r--javax/swing/plaf/basic/BasicMenuItemUI.java65
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java5
-rw-r--r--javax/swing/plaf/basic/BasicScrollBarUI.java5
-rw-r--r--javax/swing/plaf/basic/BasicScrollPaneUI.java98
-rw-r--r--javax/swing/plaf/basic/BasicTableUI.java9
-rw-r--r--javax/swing/plaf/basic/BasicToolBarUI.java6
-rw-r--r--javax/swing/plaf/metal/DefaultMetalTheme.java100
-rw-r--r--javax/swing/plaf/metal/MetalIconFactory.java59
-rw-r--r--javax/swing/plaf/metal/MetalLookAndFeel.java29
-rw-r--r--javax/swing/plaf/metal/MetalScrollBarUI.java15
-rw-r--r--javax/swing/plaf/metal/OceanTheme.java2
-rw-r--r--javax/swing/text/html/HTMLEditorKit.java3
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java92
-rw-r--r--javax/swing/tree/DefaultTreeModel.java27
-rw-r--r--javax/swing/tree/VariableHeightLayoutCache.java6
-rw-r--r--native/fdlibm/mprec.c8
-rw-r--r--native/fdlibm/mprec.h2
-rw-r--r--native/jni/classpath/jcl.c131
-rw-r--r--native/jni/gconf-peer/GConfNativePeer.c117
-rw-r--r--native/jni/gconf-peer/Makefile.am2
-rw-r--r--native/jni/gtk-peer/cairographics2d.h3
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c75
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c24
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c22
-rw-r--r--native/jni/java-io/java_io_VMFile.c11
-rw-r--r--native/jni/java-lang/java_lang_VMDouble.c21
-rw-r--r--native/jni/java-lang/java_lang_VMProcess.c23
-rw-r--r--native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c875
-rw-r--r--native/jni/java-net/java_net_VMInetAddress.c87
-rw-r--r--native/jni/java-net/java_net_VMNetworkInterface.c204
-rw-r--r--native/jni/java-nio/Makefile.am10
-rw-r--r--native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c414
-rw-r--r--native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c387
-rw-r--r--native/jni/java-nio/gnu_java_nio_VMChannel.c1345
-rw-r--r--native/jni/java-nio/gnu_java_nio_VMPipe.c41
-rw-r--r--native/jni/java-nio/java_nio_MappedByteBufferImpl.c5
-rw-r--r--native/jni/java-nio/javanio.c122
-rw-r--r--native/jni/java-nio/javanio.h332
-rw-r--r--native/jni/native-lib/cpio.c20
-rw-r--r--native/jni/native-lib/cpio.h2
-rw-r--r--native/jni/native-lib/cpnet.c56
-rw-r--r--native/jni/native-lib/cpnet.h1
-rw-r--r--org/omg/CORBA/AnyHolder.java6
-rw-r--r--org/omg/CORBA/AnySeqHelper.java3
-rw-r--r--org/omg/CORBA/AnySeqHolder.java6
-rw-r--r--org/omg/CORBA/BooleanHolder.java6
-rw-r--r--org/omg/CORBA/BooleanSeqHelper.java3
-rw-r--r--org/omg/CORBA/BooleanSeqHolder.java6
-rw-r--r--org/omg/CORBA/ByteHolder.java6
-rw-r--r--org/omg/CORBA/CharHolder.java6
-rw-r--r--org/omg/CORBA/CharSeqHelper.java3
-rw-r--r--org/omg/CORBA/CharSeqHolder.java6
-rw-r--r--org/omg/CORBA/Context.java6
-rw-r--r--org/omg/CORBA/CurrentHelper.java5
-rw-r--r--org/omg/CORBA/CustomValue.java5
-rw-r--r--org/omg/CORBA/DataOutputStream.java28
-rw-r--r--org/omg/CORBA/DefinitionKindHelper.java5
-rw-r--r--org/omg/CORBA/DomainManagerOperations.java4
-rw-r--r--org/omg/CORBA/DoubleHolder.java6
-rw-r--r--org/omg/CORBA/DoubleSeqHelper.java3
-rw-r--r--org/omg/CORBA/DoubleSeqHolder.java6
-rw-r--r--org/omg/CORBA/DynAny.java10
-rw-r--r--org/omg/CORBA/DynSequence.java4
-rw-r--r--org/omg/CORBA/DynValue.java4
-rw-r--r--org/omg/CORBA/DynamicImplementation.java4
-rw-r--r--org/omg/CORBA/FieldNameHelper.java8
-rw-r--r--org/omg/CORBA/FixedHolder.java7
-rw-r--r--org/omg/CORBA/FloatHolder.java6
-rw-r--r--org/omg/CORBA/FloatSeqHelper.java3
-rw-r--r--org/omg/CORBA/FloatSeqHolder.java6
-rw-r--r--org/omg/CORBA/IdentifierHelper.java8
-rw-r--r--org/omg/CORBA/IntHolder.java6
-rw-r--r--org/omg/CORBA/LocalObject.java12
-rw-r--r--org/omg/CORBA/LongHolder.java6
-rw-r--r--org/omg/CORBA/LongLongSeqHelper.java3
-rw-r--r--org/omg/CORBA/LongLongSeqHolder.java6
-rw-r--r--org/omg/CORBA/LongSeqHelper.java3
-rw-r--r--org/omg/CORBA/LongSeqHolder.java10
-rw-r--r--org/omg/CORBA/ORB.java6
-rw-r--r--org/omg/CORBA/ObjectHelper.java3
-rw-r--r--org/omg/CORBA/ObjectHolder.java9
-rw-r--r--org/omg/CORBA/OctetSeqHelper.java3
-rw-r--r--org/omg/CORBA/OctetSeqHolder.java6
-rw-r--r--org/omg/CORBA/PolicyErrorCodeHelper.java10
-rw-r--r--org/omg/CORBA/PolicyErrorHelper.java6
-rw-r--r--org/omg/CORBA/PolicyHelper.java5
-rw-r--r--org/omg/CORBA/PolicyListHelper.java14
-rw-r--r--org/omg/CORBA/PolicyTypeHelper.java3
-rw-r--r--org/omg/CORBA/PrincipalHolder.java6
-rw-r--r--org/omg/CORBA/RepositoryIdHelper.java8
-rw-r--r--org/omg/CORBA/Request.java8
-rw-r--r--org/omg/CORBA/ShortHolder.java6
-rw-r--r--org/omg/CORBA/ShortSeqHelper.java3
-rw-r--r--org/omg/CORBA/ShortSeqHolder.java6
-rw-r--r--org/omg/CORBA/StringSeqHelper.java3
-rwxr-xr-xorg/omg/CORBA/StringSeqHolder.java6
-rw-r--r--org/omg/CORBA/ULongLongSeqHelper.java3
-rw-r--r--org/omg/CORBA/ULongLongSeqHolder.java6
-rw-r--r--org/omg/CORBA/ULongSeqHelper.java3
-rw-r--r--org/omg/CORBA/ULongSeqHolder.java6
-rw-r--r--org/omg/CORBA/UShortSeqHelper.java3
-rw-r--r--org/omg/CORBA/UShortSeqHolder.java6
-rw-r--r--org/omg/CORBA/ValueBaseHelper.java6
-rw-r--r--org/omg/CORBA/ValueBaseHolder.java3
-rw-r--r--org/omg/CORBA/VersionSpecHelper.java8
-rw-r--r--org/omg/CORBA/WCharSeqHelper.java3
-rw-r--r--org/omg/CORBA/WCharSeqHolder.java10
-rw-r--r--org/omg/CORBA/WStringSeqHelper.java3
-rwxr-xr-xorg/omg/CORBA/WStringSeqHolder.java6
-rw-r--r--org/omg/CORBA/WrongTransactionHelper.java3
-rw-r--r--org/omg/CORBA/_IDLTypeStub.java2
-rw-r--r--org/omg/CORBA/_PolicyStub.java4
-rw-r--r--org/omg/CORBA/portable/BoxedValueHelper.java6
-rw-r--r--org/omg/CORBA/portable/Delegate.java6
-rw-r--r--org/omg/CORBA/portable/ObjectImpl.java31
-rw-r--r--org/omg/CORBA/portable/ServantObject.java4
-rw-r--r--org/omg/CORBA/portable/StreamableValue.java4
-rw-r--r--org/omg/CORBA_2_3/ORB.java11
-rw-r--r--org/omg/CORBA_2_3/portable/InputStream.java8
-rw-r--r--org/omg/CORBA_2_3/portable/OutputStream.java12
-rw-r--r--org/omg/CosNaming/BindingIteratorHelper.java7
-rw-r--r--org/omg/CosNaming/BindingType.java8
-rw-r--r--org/omg/CosNaming/BindingTypeHelper.java3
-rw-r--r--org/omg/CosNaming/IstringHelper.java10
-rw-r--r--org/omg/CosNaming/NameComponentHelper.java4
-rw-r--r--org/omg/CosNaming/NameHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextExtHelper.java7
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java3
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java4
-rw-r--r--org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextHelper.java9
-rw-r--r--org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidName.java3
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java3
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java6
-rw-r--r--org/omg/DynamicAny/AnySeqHelper.java3
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryHelper.java10
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryOperations.java5
-rw-r--r--org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java3
-rw-r--r--org/omg/DynamicAny/DynAnyHelper.java10
-rw-r--r--org/omg/DynamicAny/DynAnyOperations.java10
-rw-r--r--org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java3
-rw-r--r--org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java3
-rw-r--r--org/omg/DynamicAny/DynAnySeqHelper.java6
-rw-r--r--org/omg/DynamicAny/DynArrayHelper.java12
-rw-r--r--org/omg/DynamicAny/DynEnumHelper.java10
-rw-r--r--org/omg/DynamicAny/DynFixedHelper.java10
-rw-r--r--org/omg/DynamicAny/DynSequenceHelper.java10
-rw-r--r--org/omg/DynamicAny/DynStructHelper.java10
-rw-r--r--org/omg/DynamicAny/DynStructOperations.java6
-rw-r--r--org/omg/DynamicAny/DynUnionHelper.java10
-rw-r--r--org/omg/DynamicAny/DynValueHelper.java10
-rw-r--r--org/omg/DynamicAny/FieldNameHelper.java8
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairHelper.java4
-rw-r--r--org/omg/DynamicAny/NameDynAnyPairSeqHelper.java6
-rw-r--r--org/omg/IOP/CodecFactoryHelper.java12
-rw-r--r--org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java3
-rw-r--r--org/omg/IOP/CodecOperations.java10
-rw-r--r--org/omg/IOP/CodecPackage/FormatMismatchHelper.java3
-rw-r--r--org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java3
-rw-r--r--org/omg/IOP/CodecPackage/TypeMismatchHelper.java3
-rw-r--r--org/omg/IOP/ComponentIdHelper.java3
-rw-r--r--org/omg/IOP/ExceptionDetailMessage.java4
-rw-r--r--org/omg/IOP/MultipleComponentProfileHelper.java5
-rw-r--r--org/omg/IOP/ProfileIdHelper.java3
-rw-r--r--org/omg/IOP/ServiceContextListHelper.java7
-rw-r--r--org/omg/IOP/ServiceIdHelper.java3
-rw-r--r--org/omg/IOP/TAG_CODE_SETS.java4
-rw-r--r--org/omg/PortableInterceptor/ClientRequestInfoOperations.java5
-rw-r--r--org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java4
-rw-r--r--org/omg/PortableInterceptor/CurrentHelper.java9
-rw-r--r--org/omg/PortableInterceptor/IORInfo.java4
-rw-r--r--org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java3
-rw-r--r--org/omg/PortableInterceptor/ORBIdHelper.java8
-rw-r--r--org/omg/PortableInterceptor/ORBInitInfoOperations.java12
-rw-r--r--org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java3
-rw-r--r--org/omg/PortableInterceptor/ORBInitializerOperations.java4
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java3
-rw-r--r--org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java3
-rw-r--r--org/omg/PortableInterceptor/RequestInfoOperations.java5
-rw-r--r--org/omg/PortableInterceptor/ServerIdHelper.java8
-rw-r--r--org/omg/PortableInterceptor/ServerRequestInfoOperations.java5
-rw-r--r--org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java18
-rw-r--r--org/omg/PortableServer/AdapterActivatorOperations.java4
-rw-r--r--org/omg/PortableServer/CurrentHelper.java4
-rw-r--r--org/omg/PortableServer/CurrentPackage/NoContextHelper.java3
-rw-r--r--org/omg/PortableServer/ForwardRequestHelper.java3
-rw-r--r--org/omg/PortableServer/IdAssignmentPolicyValue.java3
-rw-r--r--org/omg/PortableServer/IdUniquenessPolicyValue.java3
-rw-r--r--org/omg/PortableServer/ImplicitActivationPolicyValue.java3
-rw-r--r--org/omg/PortableServer/LifespanPolicyValue.java3
-rw-r--r--org/omg/PortableServer/POA.java6
-rw-r--r--org/omg/PortableServer/POAHelper.java6
-rw-r--r--org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java1
-rw-r--r--org/omg/PortableServer/POAManagerPackage/State.java6
-rw-r--r--org/omg/PortableServer/POAOperations.java32
-rw-r--r--org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/InvalidPolicy.java6
-rw-r--r--org/omg/PortableServer/POAPackage/NoServantHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/WrongAdapterHelper.java3
-rw-r--r--org/omg/PortableServer/POAPackage/WrongPolicyHelper.java3
-rw-r--r--org/omg/PortableServer/RequestProcessingPolicyValue.java3
-rw-r--r--org/omg/PortableServer/Servant.java9
-rw-r--r--org/omg/PortableServer/ServantActivatorHelper.java7
-rw-r--r--org/omg/PortableServer/ServantLocatorHelper.java8
-rw-r--r--org/omg/PortableServer/ServantLocatorOperations.java4
-rw-r--r--org/omg/PortableServer/ServantRetentionPolicyValue.java3
-rw-r--r--org/omg/PortableServer/ThreadPolicyValue.java3
-rw-r--r--org/omg/PortableServer/_ServantActivatorStub.java14
-rw-r--r--org/omg/PortableServer/_ServantLocatorStub.java2
-rw-r--r--resource/gnu/classpath/tools/common/Messages.properties40
-rw-r--r--resource/gnu/classpath/tools/getopt/Messages.properties3
-rw-r--r--resource/gnu/classpath/tools/orbd/messages.properties46
-rw-r--r--resource/gnu/classpath/tools/rmic/messages.properties61
-rw-r--r--resource/gnu/classpath/tools/rmid/messages.properties50
-rw-r--r--resource/gnu/classpath/tools/rmiregistry/messages.properties48
-rw-r--r--resource/gnu/classpath/tools/tnameserv/messages.properties43
-rwxr-xr-xscripts/check_jni_methods.sh3
-rw-r--r--tools/.cvsignore5
-rwxr-xr-xtools/Makefile.am78
-rw-r--r--tools/gnu/classpath/tools/HelpPrinter.java116
-rw-r--r--tools/gnu/classpath/tools/appletviewer/Main.java32
-rw-r--r--tools/gnu/classpath/tools/common/ClasspathToolParser.java (renamed from tools/gnu/classpath/tools/getopt/ClasspathToolParser.java)18
-rw-r--r--tools/gnu/classpath/tools/common/Messages.java67
-rw-r--r--tools/gnu/classpath/tools/common/Persistent.java (renamed from tools/gnu/classpath/tools/rmi/Persistent.java)2
-rw-r--r--tools/gnu/classpath/tools/getopt/Messages.java2
-rw-r--r--tools/gnu/classpath/tools/getopt/Option.java68
-rw-r--r--tools/gnu/classpath/tools/getopt/OptionGroup.java5
-rw-r--r--tools/gnu/classpath/tools/getopt/Parser.java99
-rw-r--r--tools/gnu/classpath/tools/giop/GRMIC.java189
-rw-r--r--tools/gnu/classpath/tools/giop/GRMIC.txt33
-rw-r--r--tools/gnu/classpath/tools/giop/IorParser.java109
-rw-r--r--tools/gnu/classpath/tools/giop/IorParser.txt10
-rw-r--r--tools/gnu/classpath/tools/giop/NameServicePersistent.txt28
-rw-r--r--tools/gnu/classpath/tools/giop/NamingService.txt21
-rw-r--r--tools/gnu/classpath/tools/giop/README19
-rw-r--r--tools/gnu/classpath/tools/jar/Main.java2
-rw-r--r--tools/gnu/classpath/tools/jarsigner/Main.java2
-rw-r--r--tools/gnu/classpath/tools/javah/CniIncludePrinter.java25
-rw-r--r--tools/gnu/classpath/tools/javah/CniStubPrinter.java38
-rw-r--r--tools/gnu/classpath/tools/javah/FieldHelper.java2
-rw-r--r--tools/gnu/classpath/tools/javah/JniIncludePrinter.java35
-rw-r--r--tools/gnu/classpath/tools/javah/JniStubPrinter.java34
-rw-r--r--tools/gnu/classpath/tools/javah/Main.java92
-rw-r--r--tools/gnu/classpath/tools/javah/PathOptionGroup.java2
-rw-r--r--tools/gnu/classpath/tools/javah/Printer.java89
-rw-r--r--tools/gnu/classpath/tools/keytool/CACertCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/CertReqCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/DeleteCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/ExportCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/GenKeyCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/IdentityDBCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/ImportCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/KeyCloneCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/ListCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/Main.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/PrintCertCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/SelfCertCmd.java2
-rw-r--r--tools/gnu/classpath/tools/keytool/StorePasswdCmd.java2
-rw-r--r--tools/gnu/classpath/tools/native2ascii/Native2ASCII.java2
-rw-r--r--tools/gnu/classpath/tools/orbd/Main.java (renamed from tools/gnu/classpath/tools/giop/NameServicePersistent.java)144
-rw-r--r--tools/gnu/classpath/tools/orbd/Messages.java67
-rw-r--r--tools/gnu/classpath/tools/orbd/PersistentContext.java (renamed from tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java)2
-rw-r--r--tools/gnu/classpath/tools/orbd/PersistentContextMap.java (renamed from tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java)2
-rw-r--r--tools/gnu/classpath/tools/orbd/PersistentMap.java (renamed from tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java)2
-rw-r--r--tools/gnu/classpath/tools/rmi/REGISTRY.txt28
-rw-r--r--tools/gnu/classpath/tools/rmi/RMIC.java186
-rw-r--r--tools/gnu/classpath/tools/rmi/RMIC.txt45
-rw-r--r--tools/gnu/classpath/tools/rmi/RMID.txt30
-rw-r--r--tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java (renamed from tools/gnu/classpath/tools/AbstractMethodGenerator.java)2
-rw-r--r--tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java1824
-rw-r--r--tools/gnu/classpath/tools/rmic/CompilationError.java (renamed from tools/gnu/classpath/tools/giop/grmic/CompilationError.java)2
-rw-r--r--tools/gnu/classpath/tools/rmic/Generator.java (renamed from tools/gnu/classpath/tools/giop/grmic/Generator.java)2
-rw-r--r--tools/gnu/classpath/tools/rmic/GiopIo.java (renamed from tools/gnu/classpath/tools/giop/grmic/GiopIo.java)6
-rw-r--r--tools/gnu/classpath/tools/rmic/HashFinder.java (renamed from tools/gnu/classpath/tools/giop/grmic/HashFinder.java)2
-rw-r--r--tools/gnu/classpath/tools/rmic/Main.java282
-rw-r--r--tools/gnu/classpath/tools/rmic/Messages.java67
-rw-r--r--tools/gnu/classpath/tools/rmic/MethodGenerator.java (renamed from tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java)8
-rw-r--r--tools/gnu/classpath/tools/rmic/RMICException.java49
-rw-r--r--tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java (renamed from tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java)8
-rw-r--r--tools/gnu/classpath/tools/rmic/RmicBackend.java31
-rw-r--r--tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java (renamed from tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java)113
-rw-r--r--tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java (renamed from tools/gnu/classpath/tools/rmi/rmic/RmicCompiler.java)18
-rw-r--r--tools/gnu/classpath/tools/rmic/Variables.java137
-rw-r--r--tools/gnu/classpath/tools/rmic/WrapUnWrapper.java (renamed from tools/gnu/classpath/tools/rmi/rmic/WrapUnWrapper.java)2
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/ImplTie.jav (renamed from tools/gnu/classpath/tools/giop/grmic/templates/ImplTie.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/Stub.jav (renamed from tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/StubMethod.jav (renamed from tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav (renamed from tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/Stub_12.jav (renamed from tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/Stub_12Method.jav (renamed from tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12Method.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav (renamed from tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12MethodVoid.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/Tie.jav (renamed from tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/TieMethod.jav (renamed from tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav (renamed from tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav)0
-rw-r--r--tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java (renamed from tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl.java)5
-rw-r--r--tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java (renamed from tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl_Stub.java)2
-rw-r--r--tools/gnu/classpath/tools/rmid/Main.java (renamed from tools/gnu/classpath/tools/rmi/RMID.java)152
-rw-r--r--tools/gnu/classpath/tools/rmid/Messages.java67
-rw-r--r--tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java (renamed from tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java)5
-rw-r--r--tools/gnu/classpath/tools/rmiregistry/Main.java (renamed from tools/gnu/classpath/tools/rmi/REGISTRY.java)155
-rw-r--r--tools/gnu/classpath/tools/rmiregistry/Messages.java67
-rw-r--r--tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java (renamed from tools/gnu/classpath/tools/rmi/PersistentHashTable.java)18
-rw-r--r--tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java (renamed from tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java)13
-rw-r--r--tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java (renamed from tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java)2
-rw-r--r--tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java (renamed from tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java)2
-rw-r--r--tools/gnu/classpath/tools/serialver/SerialVer.java2
-rw-r--r--tools/gnu/classpath/tools/tnameserv/Main.java (renamed from tools/gnu/classpath/tools/giop/NameService.java)76
-rw-r--r--tools/gnu/classpath/tools/tnameserv/Messages.java67
-rw-r--r--tools/gorbd.in47
-rw-r--r--tools/grmic.in47
-rw-r--r--tools/grmid.in47
-rw-r--r--tools/grmiregistry.in47
-rw-r--r--tools/gtnameserv.in47
-rw-r--r--vm/reference/gnu/java/net/VMPlainSocketImpl.java505
-rw-r--r--vm/reference/gnu/java/nio/VMChannel.java627
-rw-r--r--vm/reference/gnu/java/nio/VMPipe.java24
-rw-r--r--vm/reference/java/net/VMInetAddress.java10
-rw-r--r--vm/reference/java/net/VMNetworkInterface.java57
-rw-r--r--vm/reference/java/nio/channels/VMChannels.java2
487 files changed, 25159 insertions, 6872 deletions
diff --git a/ChangeLog b/ChangeLog
index df6b4a711..b60f4bc55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,2152 @@
+2006-10-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/tree/VariableHeightLayoutCache.java
+ (getBounds): When rect is null, create a new Rectangle.
+
+2006-10-04 Christian Thalinger <twisti@complang.tuwien.ac.at>
+
+ * native/jni/java-nio/javanio.c (cpnio_read, cpnio_readv)
+ (cpnio_write, cpnio_writev, cpnio_socket, cpnio_connect)
+ (cpnio_accept, cpnio_sendto, cpnio_recvfrom, cpnio_fcntl)
+ (cpnio_select): Use CPNIO_EXPORT.
+ * native/jni/java-nio/javanio.h (CPNIO_EXPORT): Define to static
+ inline instead of extern inline, as newer GCCs changed their
+ behavior.
+
+2006-10-04 Gary Benson <gbenson@redhat.com>
+
+ * java/net/InetAddress.java: Updated javadoc.
+ (<clinit>, getByLiteral): Throw InternalError on failures.
+
+2006-10-03 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (compCtx): New field for composite context.
+ (copy): Copy composite.
+ (dispose): Dispose of composite context.
+ (getNativeCM): New method.
+ (setComposite): Discard old composite context and set up new context.
+ (setRenderingHints): Update composite context.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (nativeColorModel): New field, renamed from nativeModel.
+ (nativeModel): Renamed field to nativeColorModel.
+ (CairoSurface(int, int)): Call new method to create sample model.
+ (createNativeSampleModel): New method.
+ (getBufferedImage): Updated variable name.
+ * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+ (buffer): New field.
+ (createBuffer): New method.
+ (draw): New method.
+ (drawComposite): New method.
+ (drawGlyphVector): New method.
+ (drawImage(Image, AffineTransform, Color, ImageObserver)): New method.
+ (drawImage(Image, int, int, ImageObserver)): Check composite.
+ (drawImage(Image, int, int, int, int, ImageObserver)): Check composite.
+ (fill): New method.
+ (getNativeCM): New method.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+ (Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeGetPixels): Use
+ intermediary pixbuf to grab on-screen pixels.
+
+2006-10-03 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/28987:
+ * java/util/IdentityHashMap.java (tombstone): Removed.
+ (emptyslot): Removed.
+ (nullslot): New field.
+ (IdentityHashMap): Don't fill array.
+ (clear): Fill with null.
+ (hash): Now final. Use linear probing.
+ (xform): New method.
+ (unxform): Likewise.
+ (removeAtIndex): Likewise.
+ (clone, containsKey, containsValue, entrySet, get, hashCode,
+ keySet, put, remove, values): Updated.
+ (IdentityIterator, IdentityEntry): Likewise.
+ (writeObject): Likewise.
+
+2006-10-03 Tom Tromey <tromey@redhat.com>
+
+ * java/util/Locale.java (hashcode): Updated javadoc.
+ (hashcodeCache): Removed.
+ (Locale): Updated.
+ (hashCode): Updated.
+ (writeObject): New method.
+ (readObject): Updated.
+
+2006-10-02 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (updateBufferedImage): Recognise that raw data is alpha-premultiplied.
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (clearRect): Paint background colour with AlphaComposite.SRC rule.
+ (drawImage(Image, AffineTransform, Color, ImageObserver)): Alpha
+ pre-multiply data before drawing.
+ (fillRect): Draw using regular fill() method.
+ (setComposite): Handle null case with AlphaComposite.SrcOver default.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (nativeModel): Use correct value for alpha premultiplication (true).
+ * java/awt/image/BufferedImage.java
+ (coerceData): Update isPremultiplied field.
+
+2006-10-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * gnu/classpath/ListenerData.java:
+ New class for holding listener data.
+ * gnu/java/lang/management/MemoryMXBeanImpl.java:
+ ListenerData class moved to its own file.
+ * javax/management/MBeanServerDelegate.java,
+ * javax/management/MBeanServerDelegateMBean.java,
+ * javax/management/MBeanServerNotification.java:
+ Implemented.
+
+2006-10-02 Tania Bento <tbento@redhat.com>
+
+ * java/ast/Rectangle.java:
+ (Rectangle(Rectangle)): Do not throw NPE.
+ (Rectangle(Point, Dimension)): Same.
+ (Rectangle(Point)): Same.
+ (Rectangle(Dimension)): Same.
+
+2006-09-29 Casey Marshall <csm@gnu.org>
+
+ PR 29190
+ * gnu/java/nio/EpollSelectionKeyImpl.java: extend
+ `AbstractSelectionKey.'
+ (cancel, isValid): removed.
+ * gnu/java/nio/EpollSelectorImpl.java (cancelledKeys): removed.
+ (events): new field.
+ (INITIAL_CAPACITY, MAX_DOUBLING_CAPACITY, CAPACITY_INCREMENT): new
+ fields.
+ (<clinit>): initialize those constants.
+ (<init>): don't initialize `cancelledKeys;' initialize `events.'
+ (doSelect): deregister cancelled keys; remove keys attached to
+ closed channels; wrap `epoll_wait' in `begin' and `end' calls; use
+ `events' buffer; reallocate `events' buffer if needed.
+ (register): reallocate `events' buffer if needed.
+ (reallocateBuffer): new method.
+ (cancel): removed.
+
+2006-09-29 Roman Kennke <kennke@aicas.com>
+
+ PR 28929
+ * javax/swing/JViewport.java
+ (cinit): Renamed system property to gnu.swing.scrollmode
+ to avoid bloat. Default to BACKINGSTORE, this is much
+ more reliable.
+ (repaint): Forward repaint() to parent as is specified.
+
+2006-09-29 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (getPreferredSize): The number of iterations for the for-loop should be
+ the number of columns in the table's column model, not the number of
+ columns of the table.
+ * javax/swing/JTable.java
+ (JTable(TableModel, TableColumnModel, ListSelectionModel): Removed 4
+ lines that are not needed.
+ (initializeLocalVars): dragEnabled should be set to false, not true.
+ (getCellRenderer): Added a check to prevent an
+ ArrayIndexOutOfBoundsException.
+ (doLayout): The number of iterations for the for-loops should be the
+ number of columns in the table's column model, not the number of columns
+ of the table.
+
+2006-09-29 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AbstractGraphics2D.java: Updated
+ API docs.
+ (isOptimized): Initialize with true.
+ (paintRaster): Removed unneeded field.
+ (shapeCache): New static field. Caches certain shapes for reuse.
+ (computeIntersection): Removed unneeded casts.
+ (drawArc): Use shape cache.
+ (drawImage): Removed unneeded statement.
+ (drawLine): Use shape cache. Pass untranslated coordinates
+ to rawDrawLine().
+ (drawOval): Use shape cache.
+ (drawPolygon): Use shape cache.
+ (drawRect): Overridden to provide accelerated rectangle drawing
+ if possible and to use the shape cache.
+ (drawRoundRect): Use shape cache.
+ (fillArc): Use shape cache.
+ (fillOval): Use shape cache.
+ (fillPolygon): Use shape cache.
+ (fillRect): Pass untranslated coordinates to rawFillRect().
+ Use shape cache.
+ (fillRoundRect): Use shape cache.
+ (fillScanlineAA): Removed unneeded statement.
+ (fillScanline): Updated API docs.
+ (fillShapeAntialias): Removed unnecessary cast.
+ (fillShapeImpl): Update API docs. Removed unnecessary cast.
+ (fillShape): Updated API docs.
+ (getShapeCache): New helper method.
+ * gnu/java/awt/java2d/ShapeCache.java: New class. Caches
+ certain shapes for reuse in AbstractGraphics2D.
+
+2006-09-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/BadBinaryOpValueExpException.java:
+ (getExp()): Implemented.
+ * javax/management/MBeanConnection.java:
+ Renamed to MBeanServerConnection.
+ * javax/management/MBeanServer.java:
+ (setAttribute(Attribute)): Fixed...
+ (setAttribute(ObjectName,Attribute)): to this.
+ * javax/management/MBeanServerConnection.java:
+ Renamed from MBeanConnection.
+ * javax/management/QueryExp.java:
+ Extend Serializable.
+ * javax/management/ValueExp.java:
+ Likewise.
+ * javax/management/loading/ClassLoaderRepository.java:
+ (loadClass(String)): Throw ClassNotFoundException.
+ (loadClassBefore(ClassLoader,String)): Likewise.
+ (loadClassWithout(String, ClassLoader): Fixed...
+ (loadClassWithout(ClassLoader,String)): to this.
+
+2006-09-28 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/tree/DefaultTreeCellRenderer.java
+ (DefaultTreeCellRenderer): Fetch drawsFocusBorderAroundIcon
+ property from UIManager.
+ (paint): Rewritten to use super's implementation and only paint
+ background and focus indicator before.
+ (paintFocus): New helper method.
+ (getXOffset): New helper method.
+
+2006-09-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/BadBinaryOpValueExpException.java,
+ * javax/management/MBeanConnection.java,
+ * javax/management/MBeanServer.java,
+ * javax/management/ObjectInstance.java:
+ Implemented.
+ * javax/management/ObjectName.java:
+ (setMBeanServer(MBeanServer)): Implemented.
+ * javax/management/QueryExp.java,
+ * javax/management/ValueExp.java,
+ * javax/management/loading/ClassLoaderRepository.java:
+ Implemented.
+
+2006-09-27 Robert Schuster <robertschuster@fsfe.org>
+
+ * gnu/java/nio/VMChannelOwner.java: Removed unneeded imports.
+
+2006-09-27 Robert Schuster <robertschuster@fsfe.org>
+
+ * vm/reference/gnu/java/nio/VMChannel.java: Removed unneeded imports.
+ * vm/reference/gnu/java/nio/VMPipe.java: Removed unneeded imports.
+ * gnu/java/nio/EpollSelectorImpl.java:
+ (doSelect): Use Integer.valueOf() instead of constructor call.
+ (register): Use Integer.valueOf() instead of constructor call.
+
+2006-09-27 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Container.java
+ (addContainerListener): Activate newEventsOnly for the component.
+ Ignore null listeners.
+
+2006-09-27 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/EventQueue.java
+ (Queue): New inner class. Implements the actual queue.
+ (LOW_PRIORITY): New constant field.
+ (NORM_PRIORITY): New constant field.
+ (queueHead): Removed. Moved into Queue.
+ (queueTail): Removed. Moved into Queue.
+ (queues): New field.
+ (EventQueue): Initialize two internal queues, one for
+ normal events, one for low priority events.
+ (getNextEventImpl): New helper method, fetches the next event.
+ (getNextEvent): Use getNextEventImpl() for fetching the event.
+ (peekEvent): Use getNextEventImpl() for fetching the event.
+ (peekEvent(int)): Search for event in all queues.
+ (postEventImpl(AWTEvent)): Moved actual posting into
+ postEventImpl(AWTEvent,int). Prioritize events here.
+ (postEventImpl(AWTEvent,int)): Take priority parameter and insert
+ event into correct queue. Re-enable event coalescing.
+ * gnu/java/awt/LowPriorityEvent.java: New marker interface.
+ * javax/swing/RepaintManager.java
+ (RepaintWorkerEvent): New internal class. This is a low priority
+ event for the repaint worker.
+ (addDirtyRegion): Use new internal invokeLater() for sending
+ a low priority event.
+ (addInvalidComponent): Use new internal invokeLater() for sending
+ a low priority event.
+ (commitBuffer): Added some null checks.
+ (invokeLater): New helper method. Sends a low priority
+ repaint worker event on the event queue.
+
+2006-09-27 Roman Kennke <kennke@aicas.com>
+
+ PR 29036
+ PR 29161
+ * javax/swing/plaf/basic/BasicButtonUI.java
+ (cachedInsets): New field.
+ (installListeners): Fire synthetic property change to initialize
+ TEXT_LAYOUT_CACHE for the button because the font has been
+ installed before.
+ (uninstallUI): Clear the TEXT_LAYOUT_CACHE for the button.
+ (paint): Use cached insets.
+ (paintText): Let new method forward to old one, not vice versa.
+ * javax/swing/plaf/basic/BasicMenuItemUI.java
+ (defaultAcceleratorLabelGap): Removed unused field.
+ (MenuGap): Removed unused field.
+ (propertyChangeListener): Made private.
+ (getAcceleratorRect): Removed unused method.
+ (getAcceleratorText): Removed unused method.
+ (getPath): Removed unnecessary cast.
+ (installListeners): Fire synthetic property change to initialize
+ TEXT_LAYOUT_CACHE for the button because the font has been
+ installed before.
+ (uninstallUI): Clear the TEXT_LAYOUT_CACHE for the button.
+ (layoutMenuItem): Removed unused statements.
+
+2006-09-27 Roman Kennke <kennke@aicas.com>
+
+ PR 29218
+ * javax/swing/tree/DefaultTreeModel.java
+ (isLeaf): Check if the node allows children when
+ asksAllowsChildren is true, otherwise fall back
+ to return the node's leaf property.
+
+2006-09-27 Mario Torre <neugens@limasoftware.net>
+
+ * scripts/check_jni_methods.sh: removed methods from the
+ ignore list:
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key
+ * native/jni/gconf-peer/GConfNativePeer.c: fixed coding style
+ to better follow the GNU style.
+ * include/gnu_java_util_prefs_gconf_GConfNativePeer.h.
+ regenerated header file for GConfNativePeer.
+
+2006-09-27 Robert Schuster <robertschuster@fsfe.org>
+
+ * INSTALL: Added information about grmic being built when ASM
+ is available, added information about gconf dependency, indented
+ Qt4 dependency section.
+ * configure.ac: Added information about grmic being built when ASM
+ is available.
+
+2006-09-27 Ian Rogers <ian.rogers@manchester.ac.uk>
+
+ * native/jni/classpath/jcl.c (JNI_OnLoad): Don't call
+ DeleteGlobalRef on a local ref.
+
+2006-09-24 Mario Torre <neugens@limasoftware.net>
+
+ * scripts/check_jni_methods.sh: added two new methods in the
+ ignore list:
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key
+ and
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key
+ * native/jni/gconf-peer/GConfNativePeer.c:
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1keys):
+ refacored method name, renamed from
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys.
+ Added code to unescape escaped GConf key names.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1nodes):
+ refacored method name, renamed from
+ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes.
+ Added code to unescape escaped GConf key names.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key):
+ new function.
+ (Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key):
+ new function.
+ * gnu/java/util/prefs/gconf/GConfNativePeer.java: removed
+ version javadoc tag.
+ (escapeString): new method.
+ (unescapeString): likewise.
+ (gconf_escape_key): new native method.
+ (gconf_unescape_key): likewise.
+ (gconf_client_suggest_sync): update native method signature, now
+ explicity throws BackingStoreException.
+ (gconf_client_all_nodes): update native method signature, now
+ explicity throws BackingStoreException. Refactored method name,
+ renamed from gconf_client_gconf_client_all_nodes.
+ (gconf_client_all_keys): update native method signature, now
+ explicity throws BackingStoreException. Refactored method name,
+ renamed from gconf_client_gconf_client_all_keys.
+ (getKeys): refactored to use the new method name
+ gconf_client_all_keys.
+ (getChildrenNodes): refactored to use the new method name
+ gconf_client_all_nodes.
+ * gnu/java/util/prefs/GConfBasedPreferences.java: removed
+ version javadoc tag.
+ (GConfBasedPreferences): Added code to escape node names from
+ invalid characters so that GConf now accept invalid node names.
+ (GConfBasedPreferences): Moved code to register the current
+ node to the list of nodes watched by GConf outside the constructor.
+ (childSpi): Added code to register the current node to the
+ list of nodes watched by GConf.
+ (getGConfKey): Added code to escape key names from
+ invalid characters so that GConf now accept invalid key names.
+
+2006-09-26 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/javah/Printer.java (Printer): Don't
+ call mkdirs in output-directory case.
+ (getPrintStream): Create output directory.
+ * tools/gnu/classpath/tools/javah/Main.java (makeOutputDirectory):
+ Don't call mkdirs.
+
+2006-09-27 Raif S. Naffah <raif@swiftdsl.com.au>
+
+ * tools/gnu/classpath/tools/javah/CniIncludePrinter.java (CniIncludePrinter):
+ Accept three additional arguments.
+ (writePreambleImpl): New method.
+ (getPrintStreamImpl): Likewise.
+ (printClass): Adapted to use new methods in Printer superclass.
+ * tools/gnu/classpath/tools/javah/CniStubPrinter.java: Likewise.
+ * tools/gnu/classpath/tools/javah/JniIncludePrinter.java: Likewise.
+ * tools/gnu/classpath/tools/javah/JniStubPrinter.java: Likewise.
+ * tools/gnu/classpath/tools/javah/Main.java (outFileName): New field.
+ (force): Likewise.
+ (getParser): Add support for -o option.
+ Check that only one of -d or -o is defined.
+ Add support for -jni option.
+ Add support for -force option.
+ (makeOutputFile): New method.
+ (writeHeaders): Removed File argument from signature.
+ (run): Take into account newly added fields.
+ Invoke concrete PrintStream implementations with augmented constructors.
+ * tools/gnu/classpath/tools/javah/Printer.java (outputFileObject): New field.
+ (isDirectory): Likewise.
+ (force): Likewise.
+ (wrotePreamble): Likewise.
+ (Printer): Changed ctor to accept three additional arguments.
+ (printClass): Changed signature to accept one ClassWrapper argument.
+ (writePreambleImpl): New abstract method.
+ (getPrintStreamImpl): Likewise.
+ (getPrintStream): New method.
+ (writePreamble): Likewise.
+
+2006-09-26 Tania Bento <tbento@redhat.com>
+
+ * java/awt/GridLayout.java
+ (toString): There is no common before hgap.
+ * java/awt/Rectangle.java
+ (Rectangle(Rectangle)): Throw NPE if Rectangle is null.
+ (Rectangle(Point, Rectangle)): Throw NPE if either Point or
+ Rectangle is null.
+ (Rectangle(Point)): Throw NPE if Point is null.
+ (Rectangle(Dimension)): Throw NPE if Dimension is null.
+
+2006-09-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (FileIcon16.paintIcon): Apply vertical shift by the number of pixels
+ returned by getShift(),
+ (FileIcon16.getShift): Updated API docs,
+ (FolderIcon16.paintIcon): Apply vertical shift by the number of pixels
+ returned by getShift(),
+ (FolderIcon16.getShift): Updated API docs,
+ (TreeFolderIcon.getShift): Likewise,
+ (TreeLeafIcon.getShift): Likewise.
+
+2006-09-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (FileIcon16.paintIcon): Fetch colors from look and feel,
+ (FolderIcon16.paintIcon): Likewise.
+
+2006-09-25 Casey Marshall <csm@gnu.org>
+
+ * gnu/java/nio/FileChannelImpl.java (read): revert back to using
+ `readScattering.'
+ (write): revert back to using `writeGathering.'
+ * vm/reference/gnu/java/nio/VMChannel.java (writeGathering): find
+ the first buffer that has data remaining, and start at that one.
+
+2006-09-25 Tom Tromey <tromey@redhat.com>
+
+ * native/jni/gconf-peer/Makefile.am (libgconfpeer_la_LDFLAGS): New
+ variable.
+
+2006-09-25 Tom Tromey <tromey@redhat.com>
+
+ * tools/.cvsignore: Updated.
+
+2006-09-25 Tom Tromey <tromey@redhat.com>
+
+ PR libgcj/29178:
+ * gnu/java/nio/charset/US_ASCII.java (Encoder.canEncode): New method.
+ (Encoder.canEncode): Likewise.
+ (Encoder.encodeLoop): Return unmappable for all non-ASCII characters.
+ * gnu/java/nio/charset/ByteCharset.java (Encoder.canEncode): New
+ method.
+ (Encoder.canEncode): Likewise.
+ * gnu/java/nio/charset/ISO_8859_1.java (Encoder.canEncode): New
+ method.
+ (Encoder.canEncode): Likewise.
+
+2006-09-25 Tom Tromey <tromey@redhat.com>
+
+ * native/fdlibm/mprec.c (mprec_calloc): Renamed.
+ (Balloc): Updated.
+
+2006-09-25 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/ColorModel.java
+ (coerceData): Made abstract.
+ (coerceDataWorker): New protected method.
+ * java/awt/image/ComponentColorModel.java
+ (coerceData): Return new instance of proper ColorModel.
+ * java/awt/image/DirectColorModel.java
+ (coerceData): Return new instance of proper ColorModel.
+ * java/awt/image/IndexColorModel.java
+ (coerceData): New method.
+
+2006-09-24 Casey Marshall <csm@gnu.org>
+
+ * gnu/java/nio/FileChannelImpl.java
+ (read): call `read' in a loop, don't use `readScattering.'
+ (write): call `write' in a loop, don't use `writeGathering.'
+
+2006-09-24 Mark Wielaard <mark@klomp.org>
+
+ * configure.ac: Move -pedantic from WARNING to STRICT flags.
+
+2006-09-24 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/nio/channels/spi/AbstractSelectableChannel.java
+ (register): Set interestOps and attachment when the key already
+ exists.
+
+2006-09-24 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/net/ServerSocket.java
+ (bind(SocketAddress,int)): Added support for null address.
+ Throw proper exception if already bound.
+ Handle unresolved addresses correctly. Ignore exceptions that
+ happen during close in error path (to prevent losing the original
+ exception.)
+
+2006-09-24 Mark Wielaard <mark@klomp.org>
+
+ Suggested by Aaron M. Ucko <ucko@debian.org>
+ Fixes bug #29203
+ * native/fdlibm/mprec.c (ulp): Define L as int32_t.
+
+2006-09-24 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/nio/channels/spi/AbstractSelectableChannel.java
+ (implCloseChannel): Cancel all keys after closing the channel.
+
+2006-09-22 Casey Marshall <csm@gnu.org>
+
+ * gnu/java/nio/EpollSelectorImpl.java (doSelect): remove keys
+ after we delete them.
+ (selectedKeys): return an empty set if nothing's been selected.
+ * native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c
+ (Java_gnu_java_nio_EpollSelectorImpl_epoll_1delete): don't
+ throw an exception on EBADF.
+ (Java_gnu_java_nio_EpollSelectorImpl_epoll_1wait): don't
+ throw exception on EINTR, just return 0.
+
+2006-09-22 Casey Marshall <csm@gnu.org>
+
+ * native/jni/java-io/java_io_VMFile.c (Java_java_io_VMFile_list):
+ remove `const' from `filename.'
+ * native/jni/native-lib/cpio.c (cpio_readDir): remove `const' from
+ `filename.'
+ * native/jni/native-lib/cpio.h (cpio_readDir): likewise.
+
+2006-09-22 Casey Marshall <csm@gnu.org>
+
+ * configure.ac (AC_CHECK_FUNCS): check for `readdir_r.'
+ * native/jni/java-io/java_io_VMFile.c (Java_java_io_VMFile_list):
+ allocate `filename,' and handle changes to `cpio_readDir.'
+ * native/jni/native-lib/cpio.c (cpio_readDir): use `readdir_r' if
+ available; copy the filename into the destination buffer; return
+ an error code if readdir returns NULL, but errno is 0.
+ * native/jni/native-lib/cpio.h (cpio_readDir): change second
+ parameter to `const char *.'
+
+2006-09-23 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/ObjectName.java:
+ Implemented.
+
+2006-09-22 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * resource/gnu/classpath/tools/orbd: New directory.
+ * resource/gnu/classpath/tools/rmic: Likewise.
+ * resource/gnu/classpath/tools/rmid: Likewise.
+ * resource/gnu/classpath/tools/rmiregistry: Likewise.
+ * resource/gnu/classpath/tools/tnameserv: Likewise.
+ * tools/gnu/classpath/tools/giop: Move contents to...
+ * tools/gnu/classpath/tools/orbd,
+ tools/gnu/classpath/tools/tnameserv: New directories.
+ * tools/gnu/classpath/tools/rmi/rmic: Move contents to...
+ * tools/gnu/classpath/tools/rmic: New directory.
+ * tools/gnu/classpath/tools/rmi/rmid: Move contents to...
+ * tools/gnu/classpath/tools/rmid: New directory.
+ * tools/gnu/classpath/tools/rmi/registry: Move contents to...
+ * tools/gnu/classpath/tools/rmiregistry: New directory.
+ * resource/gnu/classpath/tools/orbd/messages.properties: New file.
+ * resource/gnu/classpath/tools/rmic/messages.properties: Likewise.
+ * resource/gnu/classpath/tools/rmid/messages.properties: Likewise.
+ * resource/gnu/classpath/tools/rmiregistry/messages.properties:
+ Likewise.
+ * resource/gnu/classpath/tools/tnameserv/messages.properties:
+ Likewise.
+ * tools/gnu/classpath/tools/orbd/Main.java,
+ tools/gnu/classpath/tools/orbd/Messages.java,
+ tools/gnu/classpath/tools/orbd/PersistentContext.java,
+ tools/gnu/classpath/tools/orbd/PersistentContextMap.java,
+ tools/gnu/classpath/tools/orbd/PersistentMap.java,
+ tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java,
+ tools/gnu/classpath/tools/rmic/CompilationError.java,
+ tools/gnu/classpath/tools/rmic/Generator.java,
+ tools/gnu/classpath/tools/rmic/GiopIo.java,
+ tools/gnu/classpath/tools/rmic/HashFinder.java,
+ tools/gnu/classpath/tools/rmic/Main.java,
+ tools/gnu/classpath/tools/rmic/Messages.java,
+ tools/gnu/classpath/tools/rmic/MethodGenerator.java,
+ tools/gnu/classpath/tools/rmic/RMICException.java,
+ tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java,
+ tools/gnu/classpath/tools/rmic/RmicBackend.java,
+ tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java,
+ tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java,
+ tools/gnu/classpath/tools/rmic/Variables.java,
+ tools/gnu/classpath/tools/rmic/WrapUnWrapper.java,
+ tools/gnu/classpath/tools/rmic/templates,
+ tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java,
+ tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java,
+ tools/gnu/classpath/tools/rmid/Main.java,
+ tools/gnu/classpath/tools/rmid/Messages.java,
+ tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java,
+ tools/gnu/classpath/tools/rmiregistry/Main.java,
+ tools/gnu/classpath/tools/rmiregistry/Messages.java,
+ tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java,
+ tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java,
+ tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java,
+ tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java,
+ tools/gnu/classpath/tools/tnameserv/Main.java,
+ tools/gnu/classpath/tools/tnameserv/Messages.java: New files.
+ * tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java: Import
+ RMIC.java from cp-tools.
+ * configure.ac (AC_CONFIG_FILES): Add tools/grmiregistry,
+ tools/gtnameserv, tools/gorbd, tools/grmid and tools/grmic.
+ (AC_CONFIG_COMMANDS): Add grmiregistry, gtnameserv, gorbd, grmid
+ and grmic.
+ * examples/Makefile.am (GLIBJ_CLASSPATH): Add tools.zip.
+ * gnu/CORBA/NamingService/NamingServiceTransient.java (main):
+ Rename...
+ (start): New method.
+ * tools/Makefile.am: Add build support for new tool wrappers.
+ * tools/gorbd.in: New file.
+ * tools/grmic.in: Likewise.
+ * tools/grmid.in: Likewise.
+ * tools/grmiregistry.in: Likewise.
+ * tools/gtnameserv.in: Likewise.
+ * tools/gnu/classpath/tools/AbstractMethodGenerator.java: Move to...
+ * tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java: New
+ file.
+ * tools/gnu/classpath/tools/HelpPrinter.java: Remove file.
+ * tools/gnu/classpath/tools/rmi/Persistent.java: Move to...
+ * tools/gnu/classpath/tools/common/Persistent.java: New file.
+
+2006-09-22 Ito Kazumitsu <kaz@maczuka.gcd.org>
+
+ Fixes bug #29047
+ * gnu/java/util/regex/RETokenRepeated.java
+ (findMatch): Rewriten without using recursive calls,
+ (FindMatchControlStack): New class,
+ (FindMatchControl): New class,
+ (TryAnotherResult): New class,
+ (tryAnother): New method.
+
+2006-09-22 Gary Benson <gbenson@redhat.com>
+
+ * java/net/SocketPermission.java
+ (processHostport): Cope with IPv6 addresses with a
+ one-digit first component.
+
+2006-09-22 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (enableEvents): Set newEventsOnly flag.
+ * java/awt/Container.java
+ (dispatchEventImpl): Consume event if lightweight dispatcher
+ dispatched the event. Don't call processEvent() here, this
+ is already done in Component.dispatchEventImpl(). For
+ heavyweights or when the lightweight dispatcher could
+ not dispatch, fall back to calling super.
+ (dispatchNoLightweight): New helper method to avoid
+ recursivly calling the lightweight dispatcher.
+ * java/awt/LightweightDispatcher.java
+ (dragButton): Removed field.
+ (dragTarget): Removed field.
+ (mouseEventTarget): New field.
+ (convertPointToChild): Removed method.
+ (dispatchEvent): Don't depend on component beeing
+ a window.
+ (findTarget): Improved algorithm for finding a target.
+ Before we went down to the deepest component and went
+ up again to find a suitable target. Now we go
+ down only once, without going up.
+ (handleMouseEvent): Broke method down into some smaller
+ helper methods.
+ (isDragging): New helper method.
+ (isMouseListening): New helper method.
+ (redispatch): New helper method.
+ (trackEnterExit): New helper method.
+
+2006-09-22 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/SizeSequence.java
+ (getSize): Return 0 if index is out of bounds.
+
+2006-09-21 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/javah/PathOptionGroup.java
+ (PathOptionGroup): Make -I a joined option.
+ * tools/gnu/classpath/tools/keytool/CACertCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/CertReqCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/DeleteCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/ExportCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/GenKeyCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/IdentityDBCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/ImportCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/KeyCloneCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/ListCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/MainCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/PrintCertCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/SelfCertCmd.java: Updated.
+ * tools/gnu/classpath/tools/keytool/StorePasswdCmd.java: Updated.
+ * tools/gnu/classpath/tools/appletviewer/Main.java: Updated.
+ * tools/gnu/classpath/tools/jar/Main.java: Updated.
+ * tools/gnu/classpath/tools/jarsigner/Main.java: Updated.
+ * tools/gnu/classpath/tools/javah/Main.java: Updated.
+ * tools/gnu/classpath/tools/native2ascii/Main.java: Updated.
+ * tools/gnu/classpath/tools/serialver/SerialVer.java: Updated.
+ * resource/gnu/classpath/tools/getopt/Messages.properties: Removed
+ unused entries.
+ * resource/gnu/classpath/tools/common/Messages.properties: New file.
+ * tools/gnu/classpath/tools/common/Messages.java: New file.
+ * tools/gnu/classpath/tools/getopt/Messages.java: Now package-private.
+ * tools/gnu/classpath/tools/common/ClasspathToolParser.java: Moved
+ from getopt.
+ (ClasspathToolParser): Add -J option here.
+ (ClasspathToolParser): Call other constructor in this class.
+ * tools/gnu/classpath/tools/getopt/Parser.java (handleLongOption):
+ Handle joined options.
+ (handleShortOptions): Likewise.
+ (handleShortOption): Removed.
+ (finalGroup): New field.
+ (Parser): Initialize new field. Don't add -J option.
+ (addFinal): New method.
+ * tools/gnu/classpath/tools/getopt/OptionGroup.java (printHelp): Use
+ isJoined.
+ * tools/gnu/classpath/tools/getopt/Option.java (isJoined): New method.
+ (Option): Check short option for validity.
+ (Option): New constructors.
+ (joined): New field.
+
+2006-09-21 csm <csm@pollux.local>
+
+ * gnu/java/net/PlainDatagramSocketImpl.java (send): ignore
+ `InterruptedIOException;' try again if it gets thrown.
+ (receive): likewise, but re-throw `SocketTimeoutException.'
+ * gnu/java/nio/EpollSelectorImpl.java (doSelect): just return 0
+ if we have nothing to select.
+
+2006-09-21 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java:
+ (getLogicalBounds): Respect glyph transformations.
+ (getGlyphOutline): Added null pointer check.
+ (getGlyphTransform): Do not generate identity transform (API permits null).
+ (setGlyphPosition): Do not invalidate transform.
+ (setGlyphTransform): Do not modify glyph position.
+
+2006-09-21 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/ColorModel.java (coerceData): Set alpha premultiplied flag.
+
+2006-09-21 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/ColorModel.java (coerceData): Return proper colour model.
+ * java/awt/image/ComponentColorModel.java (coerceData): Likewise.
+ * java/awt/image/DirectColorModel.java (coerceData): Likewise.
+
+2006-09-21 Tania Bento <tbento@redhat.com>
+
+ * javax/swing/JTabbedPane.java:
+ (insertTab): Notify ChangeListeners if the tab inserted is selected.
+ (setModel): A ChangeListener should be created only if there does not
+ currently exist one.
+
+2006-09-21 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+ (MaximizeAction.actionPerformed): Change icon on maxButton.
+
+2006-09-21 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (syncScrollPaneWithViewport): Fixed typo (hsb vs. vsb).
+ Use more efficient getViewPosition() and getViewSize() methods
+ to avoid creating a rectangle.
+ (HSBChangeListener.stateChanged): Update the view position
+ unconditionally. Let the Viewport figure out if something
+ changed.
+ (VSBChangeListener.stateChanged): Update the view position
+ unconditionally. Let the Viewport figure out if something
+ changed.
+ * javax/swing/JViewport.java
+ (ViewListener.componentResized): Fire state change, because
+ the extentSize changes.
+ (extentSize): Removed unneeded field.
+ (viewSize): Removed unneeded field.
+ (getExtentSize): Return the viewport's size here.
+ (getViewRect): Reformatted.
+ (getViewSize): Reordered for only one return statement.
+ (paintImmediately2): Fixed up javadoc.
+ (paint): Removed unneeded statement.
+ (setExtentSize): Set viewport size and check for actual change
+ of value.
+ (setViewPosition): Simplified condition. Set scrollUnderway
+ true and don't set isViewSizeSet. Avoid creating one Point
+ object.
+ (setViewSize): Fixed != comparison with equals(). Set scrollUnderway
+ to false.
+ * javax/swing/JScrollBar.java
+ (ScrollBarListener): New class. Forwards change events from
+ the model as adjustment events.
+ (sbChangeListener): New field.
+ (JScrollBar): Install listener on new model.
+ (fireAdjustmentValueChanged(int,int,int)): Delegate to new helper
+ method.
+ (fireAdjustmentValueChanged(int,int,int,boolean)): New helper
+ method to allow custom isAdjusting value.
+ (setMaximum): Only forward to model.
+ (setMinimum): Only forward to model.
+ (setValue): Only forward to model.
+ (setVisibleAmount): Only forward to model.
+ (setValues): Only forward to model.
+ (setModel): Update the change listener.
+
2006-09-20 Christian Thalinger <twisti@complang.tuwien.ac.at>
* java/util/Formatter.java (basicIntegralConversion): Removed
check for ZERO && !LEFT_JUSTIFY.
+2006-09-20 Roman Kennke <kennke@aicas.com>
+
+ PR 29036
+ * javax/swing/plaf/metal/DefaultMetalTheme.java
+ (PLAIN_CONTROL_TEXT_FONT): New constant field.
+ (BOLD_CONTROL_TEXT_FONT): New constant field.
+ (PLAIN_MENU_TEXT_FONT): New constant field.
+ (BOLD_MENU_TEXT_FONT): New constant field.
+ (controlTextFont): Removed.
+ (menuTextFont): Removed.
+ (CONTROL_TEXT_FONT): New constant field.
+ (MENU_TEXT_FONT): New constant field.
+ (getControlTextFont): Use getFont() helper method for fetching
+ the correct font.
+ (getMenuTextFont): Use getFont() helper method for fetching
+ the correct font.
+ (getFont): New helper method.
+ (isBoldMetal): New helper method.
+
+2006-09-20 Casey Marshall <csm@gnu.org>
+
+ * NEWS: mention epoll selector along with the kqueue one.
+
+2006-09-20 Casey Marshall <csm@gnu.org>
+
+ * native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c
+ (Java_gnu_java_nio_EpollSelectorImpl_epoll_1delete): ignore ENOENT.
+
+2006-09-20 Francis Kung <fkung@redhat.com>
+
+ PR 29011
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java:
+ (getGlyphTransform): Use translation instead of scale.
+ (performDefaultLayout): Increment position values instead of resetting, and
+ pre-increment instead of post-increment.
+ (setGlyphTransform): Handle null case with identity transform.
+
+2006-09-20 Casey Marshall <csm@gnu.org>
+
+ * configure.ac (AC_CHECK_HEADERS): check for `sys/epoll.h.'
+ (AC_CHECK_FUNCS): check for `epoll_create.'
+ * gnu/java/nio/EpollSelectionKeyImpl.java: new file.
+ * gnu/java/nio/EpollSelectorImpl.java: new file.
+ * gnu/java/nio/SelectorProviderImpl.java (epoll_failed): new class
+ field.
+ (openSelector): return epoll selector if requested and available.
+ * include/Makefile.am (H_FILES): add gnu_java_nio_EpollSelectorImpl.h.
+ (gnu_java_nio_EpollSelectorImpl.h): new target.
+ * include/gnu_java_nio_EpollSelectorImpl.h: new file.
+ * native/jni/java-nio/Makefile.am (libjavanio_la_SOURCES): add
+ gnu_java_nio_EpollSelectorImpl.c.
+ * native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c: new file.
+
+2006-09-20 Casey Marshall <csm@gnu.org>
+
+ * gnu/java/nio/SocketChannelImpl.java (finishConnect): don't
+ call `isConnected.'
+ (isConnected): return false if `connectionPending' is true.
+
+2006-09-20 Francis Kung <fkung@redhat.com>
+
+ PR 29011
+ * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java:
+ (constructor): Expanded glyphPositions array to accomodate Y-coordinates.
+ (getGlyphOutline): Call getGylphTransform to generate transform.
+ (getGylphPosition): Read position directly out of array.
+ (getGlyphPositions): Read positions directly out of array.
+ (getGlyphTransform): Generate transform based on gylphPositions array.
+ (performDefaultLayout): Populate glyphPositions array instead of transforms.
+ (setGlyphPosition): Set position directly into array.
+ (setGlyphTransform): Update positions array as well.
+
+2006-09-20 David Daney <ddaney@avtrex.com>
+
+ PR classpath/28661
+ * gnu/java/net/protocol/http/HTTPURLConnection.java (connect): Add
+ default content-type for POST method.
+
+2006-09-20 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (BasicRadioButtonUI): Don't fetch icon here,
+ (installDefaults): Initialise icon here,
+ (getDefaultIcon): Just return icon.
+
+2006-09-20 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/java-nio/Makefile.am (libjavanio_la_SOURCES):
+ Add gnu_java_nio_channels_FileChannelImpl.c and javanio.h.
+ (EXTRA_DIST): Include javanio.c.
+
+2006-09-20 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/geom/RoundRectangle2D.java:
+ (getPathIterator): Reimplemented,
+ and updated various API doc comments.
+
+2006-09-20 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Container.java
+ (addImpl): Set the new component's parent after it has been
+ added to the array. Call addNotify() and invalidate()
+ after the component has been added, so that the peer
+ gets to know about the component structure when it is created.
+ * java/awt/Window.java
+ (dispatchEventImpl): Only revalidate when window is resized,
+ let the other stuff be processed by the superclass.
+ (dispose): Post WINDOW_CLOSED event only when some listener
+ is registered or event is explicitly enabled.
+ (show): Post WINDOW_OPENED event when appropriate.
+
+2006-09-20 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (addNotify): Invalidate here. Fetch peer font.
+ (getFont): Delegate to helper method, to protect from
+ overriding client code. Lock the tree while fetching the font.
+ (getFontImpl): New helper method. Moved code from getFont() in
+ here.
+ (removeNotify): Nullify peerFont too.
+ (setFont): Synchronize on tree and component to avoid threading
+ issues. Update the peerFont correctly.
+ (validate): Update the peer font if necessary, before validating.
+ (getGraphics): Revert to recursive graphics fetching.
+ Set component font on the Graphics object.
+ (translateEvent): Removed unnecessary cast.
+ * java/awt/Container.java
+ (invalidateTree): Made final and private. Made implementation
+ slightly more efficient.
+ (setFont): Get old and new font via getFont() to account for
+ the real font, and only invalidate the tree when they are not
+ the same and not equal.
+ (visitChild): Set the font of the child on the component graphics.
+ * java/awt/Frame.java
+ (setMenuBar): Create local reference of peer for thread safety.
+ Only call simple invalidate, not invalidateTree().
+
+2006-09-19 Cameron McCormack <cam@mcc.id.au>
+
+ PR 29012
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java:
+ (constructor): Copy image field.
+
+2006-09-19 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/JMenuBar.java
+ (getHelpMenu): Implemented to throw an Error, and added API docs,
+ (getMargin): Added API docs,
+ (setMargin): Likewise.
+
+2006-09-19 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Don't call updateUI(),
+ * javax/swing/JButton.java
+ (JButton(String, Icon)): Call setModel() before init(),
+ * javax/swing/JMenuItem.java
+ (JMenuItem()): Delegate to another constructor,
+ (JMenuItem(Icon)): Likewise,
+ (JMenuItem(Action)): Set model,
+ (JMenuItem(String, Icon)): Likewise,
+ * javax/swing/JToggleButton.java
+ (init): Call setModel() before init().
+
+2006-09-19 Mark Wielaard <mark@klomp.org>
+
+ Fixes bug #29137
+ * java/util/logging/LogManager.java (addLogger): Always check for
+ existing children of a new Logger.
+
+2006-09-19 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicScrollPaneUI.java
+ (HSBChangeListener.stateChanged): Moved handling of header to
+ syncScrollPaneWithViewport().
+ (VSBChangeListener.stateChanged): Moved handling of header to
+ syncScrollPaneWithViewport().
+ (ViewportChangedHandler.stateChanged): Removed unused statements.
+ (syncScrollPaneWithViewport): Added null checks. Use setValues
+ rather then the single setter methods to avoid multiple
+ adjustments and side effects. Also snyc the headers here.
+ (updateScrollBarDisplayPolicy): Revalidate and repaint here.
+ (uninstallUI): Removed unnecessary cast and this qualifier as well
+ as the call to super.
+
+2006-09-19 Gary Benson <gbenson@redhat.com>
+
+ * java/net/ResolverCache.java: New class (a DNS cache).
+ * java/net/InetAddress.java
+ (internalGetCanonicalHostName, getAllByName): Use the above.
+
+2006-09-19 Jeroen Frijters <jeroen@frijters.net>
+
+ * gnu/java/nio/SocketChannelImpl.java: Removed unused import.
+ * java/net/ServerSocket.java
+ (port): New field.
+ (bind): Set port field.
+ (close): Set impl to null.
+ (isClosed): Check impl and channel instead of using VMChannel.
+ (toString): Use port field and getLocalPort() method.
+ * java/net/Socket.java
+ (isClosed): Check impl and channel instead of using VMChannel.
+
2006-09-18 Tom Tromey <tromey@redhat.com>
* java/util/concurrent/CopyOnWriteArrayList.java
(CopyOnWriteArrayList): New constructor.
+2006-09-18 Casey Marshall <csm@gnu.org>
+
+ * native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
+ (Java_gnu_java_net_VMPlainSocketImpl_listen): remove debug printf.
+
+2006-09-18 Tom Tromey <tromey@redhat.com>
+
+ * gnu/javax/net/ssl/provider/SSLSocket.java (isBound, isClosed,
+ isConnected): Removed old comment.
+ (getRemoteSocketAddress): Uncommented.
+ (setOOBInline, getOOBInline, setKeepAlive, getKeepAlive,
+ setTrafficClass, getTrafficClass, setReuseAddress,
+ getReuseAddress, shutdownInput, shutdownOutput, isInputShutdown,
+ isOutputShutdown): Uncommented.
+
+2006-09-18 David Pirkle <dpirkle@symyx.com>
+
+ Fixes PR 28589
+ * gnu/xml/transform/XSLURIResolver.java: Test SAXSource for specific
+ input stream during resolution.
+
+2006-09-18 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/LightweightDispatcher.java
+ (findTarget): Correctly translate child coordinates.
+ Use Component.eventTypeEnabled() for checking if a component
+ has a certain event enabled.
+ (handleMouseEvent): Find the correct mouse event target.
+ Use Component.eventTypeEnabled() for checking if a component
+ has a certain event enabled.
+
+2006-09-18 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/Component.java
+ (show): Test for the peer beeing lightweight directly.
+ (paintAll): Validate before painting. Don't paint when not
+ showing. Call peer.paint() when the component is heavyweight.
+ (repaint): Delegate to the parent when lightweight, rather
+ than skipping to the nearest heavyweight.
+ (createImage): Added null check to prevent NPE.
+ (dispatchEvent): Moved old event dispatching and toolkit
+ event dispatching to dispatchEventImpl.
+ (addComponentListener): Don't enable event. Only add listener
+ when not null. Switch to new event dispatching only.
+ (addFocusListener): Likewise.
+ (addHierarchyListener): Likewise.
+ (addHierarchyBoundsListener): Likewise.
+ (addKeyListener): Likewise.
+ (addMouseListener): Likewise.
+ (addMouseMotionListener): Likewise.
+ (addMouseWheelListener): Likewise.
+ (addInputMethodListener): Likewise.
+ (coalesceEvents): For mouse events coalesce them only when
+ their modifiers are equal. For paint events coalesce the events
+ when one contains the other, without going through complicated
+ heuristics.
+ (dispatchEventImpl): Moved old event dispatching and toolkit
+ event dispatching to dispatchEventImpl.
+ (coalescePaintEvents): Removed.
+ (HeavyweightInLightweightListener.componentHidden):
+ Fixed condition.
+ * java/awt/Container.java
+ (addImpl): Don't enable events on lightweights.
+ (remove): Reordered operations. Don't remove any listeners.
+ Throw ArrayIndexOutOfBoundsException when index >= ncomponents.
+ Only removeNotify() when peer is != null. Only invalidate if
+ not already invalid. Only fire ContainerEvent if there is
+ an interested listener or the event is enabled. Dispatch this
+ event directly without the event queue.
+ (removeAll): Likewise.
+ (paintComponents): Only paint when showing. Also paint heavyweights.
+ Don't paint the container itself.
+ (removeNotify): Create local variables for improved thread safety.
+ (addNotifyContainerChildren): Don't enable events for lightweights.
+
+2006-09-18 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/EventQueue.java
+ (INITIAL_QUEUE_DEPTH): Removed obsolete field.
+ (next_in): Removed obsolete field.
+ (next_out): Removed obsolete field.
+ (queueHead): New field. Markes the head of the queue.
+ (queueTail): New field. Markes the tail of the queue.
+ (queue): Removed obsolete field.
+ (EventQueue): Documented empty block.
+ (getNextEvent): Changed array based implementation to single-linked
+ list based implementation.
+ (invokeAndWait): Use an Object as synchronization object rather
+ than the current thread.
+ (peekEvent(int)): Changed array based implementation to single-linked
+ list based implementation.
+ (peekEvent()): Changed array based implementation to single-linked
+ list based implementation.
+ (pop()): Changed array based implementation to single-linked
+ list based implementation.
+ (postEvent): Foward to postEventImpl.
+ (postEventImpl): Changed array based implementation to single-linked
+ list based implementation.
+ (push): Changed array based implementation to single-linked
+ list based implementation.
+ * java/awt/AWTEvent.java
+ (queueNext): New field. Implements a single-linked list for
+ the EventQueue.
+
+2006-09-17 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/text/html/HTMLEditorKit (getStyleSheet): Load
+ resource from HTMLEditorKit.class.
+
+2006-09-17 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/plaf/basic/BasicToolBarUI.java
+ (setBorderToNonRollover): Check whether border is null.
+ (setBorderToRollover): Likewise.
+
+2006-09-17 Mark Wielaard <mark@klomp.org>
+
+ * javax/swing/JTree.java (setLeadSelectionPath): Handle null path.
+
+2006-09-17 Mark Wielaard <mark@klomp.org>
+
+ * native/jni/java-nio/javanio.c (cpnio_fcntl): Last argument is long.
+ * native/jni/java-nio/javanio.h (cpnio_fcntl): Likewise.
+ * native/jni/java-nio/gnu_java_nio_VMChannel.c
+ (Java_gnu_java_nio_VMChannel_lock): Likewise.
+ (Java_gnu_java_nio_VMChannel_unlock): Likewise.
+
+2006-09-17 Casey Marshall <csm@gnu.org>
+
+ * native/jni/classpath/jcl.c (JNI_OnLoad): mark `reserved' as
+ unused.
+
+2006-09-17 Chris Burdess <dog@gnu.org>
+
+ Fixes PR 27610 27687.
+ * gnu/xml/dom/ls/SAXEventSink.java: Permit limited subclassing.
+ * gnu/xml/transform/SAXTemplatesHandler.java,
+ * gnu/xml/transform/SAXTransformerHandler.java: New files.
+ * gnu/xml/transform/TransformerFactoryImpl.java: Implement
+ SAXTransformerFactory.
+
+2006-09-16 Casey Marshall <csm@gnu.org>
+
+ * NEWS: updated.
+ * configure.ac (AC_CHECK_HEADERS): check for `sys/event.h'.
+ (AC_CHECK_FUNCS): add checks for readv, writev, getifaddrs,
+ kqueue, and kevent.
+ (HAVE_INET6): define if IPv6 is supported.
+ * gnu/java/net/PlainDatagramSocketImpl.java (channel): new field.
+ (native_fd): removed.
+ (impl): new field.
+ (<init>): throw IOException; initialize fields.
+ (finalize): removed.
+ (getNativeFD): removed.
+ (bind): use `PlainSocketImpl.bind.'
+ (create): use `PlainSocketImpl.initSocket.'
+ (disconnect): use `PlainSocketImpl.disconnect.'
+ (getLocalPort): new method.
+ (send): use `VMChannel.send.'
+ (receive): use `VMChannel.receive.'
+ (setOption): use `PlainSocketImpl.setOption.'
+ (getOption): use `PlainSocketImpl.getOption.'
+ (close): use `VMChannel.State.close.'
+ (join): use `PlainSocketImpl.join.'
+ (leave): use `PlainSocketImpl.leave.'
+ (joinGroup, leaveGroup): implemented.
+ * gnu/java/net/PlainSocketImpl.java: make non-final.
+ (native_fd): removed.
+ (impl): new field.
+ (channel): new field.
+ (<init>): initialize `impl.'
+ (finalize, getNativeFD): removed.
+ (setOption): use `PlainSocketImpl.setOption.'
+ (getOption): use `PlainSocketImpl.getOption.'
+ (shutdownInput): use `PlainSocketImpl.shutdownInput.'
+ (shutdownOutput): use `PlainSocketImpl.shutdownOutput.'
+ (create): create `channel,' initialize `impl's native state.
+ (connect): use `connect(SocketAddress, int).'
+ (connect): use `SocketChannelImpl.connect;' initialize `address'
+ and `port.'
+ (bind): use `VMPlainSocketImpl.bind.'
+ (listen): use `VMPlainSocketImpl.listen.'
+ (accept): use `SocketChannelImpl.accept.'
+ (available): use `VMChannel.available.'
+ (close): use `PlainSocketImpl.close.'
+ (sendUrgentData): use `PlainSocketImpl.sendUrgentData.'
+ (getVMChannel, getInetAddress, getLocalPort, getLocalAddress,
+ getPort): new methods.
+ (SocketInputStream.read): use `VMChannel.read.'
+ (SocketInputStream.read): use `SocketChannel.read.'
+ (SocketOutputStream.write): use `VMChannel.write.'
+ (SocketOutputStream.write): use `SocketChannel.write.'
+ * gnu/java/nio/DatagramChannelImpl.java: implement VMChannel.
+ (channel): new field.
+ (<init>): initialize `channel.'
+ (implCloseSelectableChannel): use `VMChannel.close.'
+ (implConfigureBlocking): use `VMChannel.setBlocking.'
+ (connect): use `VMChannel.connect.'
+ (disconnect): use `VMChannel.disconnect.'
+ (isConnected): use `VMChannel.getPeerAddress.'
+ (write): use `VMChannel.write.'
+ (write): use `VMChannel.writeGathering.'
+ (read): use `VMChannel.read.'
+ (read): use `VMChannel.readScattering.'
+ (receive): use `VMChannel.receive.'
+ (send): use `VMChannel.send.'
+ (getVMChannel): new method.
+ * gnu/java/nio/DatagramChannelSelectionKey.java (getNativeFD):
+ access native FD through VMChannel.State.
+ * gnu/java/nio/FileChannelImpl.java: moved from
+ gnu/java/nio/channels/FileChannelImpl.java.
+ * gnu/java/nio/FileLockImpl.java: fix imports.
+ * gnu/java/nio/KqueueSelectionKeyImpl.java: new file.
+ * gnu/java/nio/KqueueSelectorImpl.java: new file.
+ * gnu/java/nio/NIOSocket.java (impl): removed.
+ (channel): new field.
+ (<init>): init superclass with a `NIOSocketImpl;' init `channel.'
+ (getPlainSocketImpl, setChannel): removed.
+ (isConnected): new method.
+ * gnu/java/nio/NIOSocketImpl.java: new file.
+ * gnu/java/nio/PipeImpl.java (SourceChannelImpl): implement
+ `VMChannelOwner.'
+ (SourceChannelImpl.native_fd): removed.
+ (SourceChannelImpl.<init>): init with a `VMChannel.'
+ (SourceChannelImpl.getNativeFD): removed.
+ (SourceChannelImpl.getVMChannel): new method.
+ (SourceChannelImpl.implCloseSelectableChannel): implement.
+ (SinkChannelImpl): implement `VMChannelOwner.'
+ (SinkChannelImpl.native_fd): removed.
+ (SinkChannelImpl.<init>): init with a `VMChannel.'
+ (SinkChannelImpl.implCloseSelectableChannel): implement.
+ (SinkChannelImpl.getNativeFD): removed.
+ (SinkChannelImpl.getVMChannel): new method.
+ * gnu/java/nio/SelectionKeyImpl.java (getNativeFD): mark
+ deprecated.
+ * gnu/java/nio/SelectorProviderImpl.java (SELECTOR_IMPL_KQUEUE,
+ SELECTOR_IMPL_EPOLL, SELECTOR_IMPL): new constants.
+ (openSelector): return kqueue selector if available.
+ * gnu/java/nio/ServerSocketChannelImpl.java: implement
+ `VMChannelOwner.'
+ (channel): new field.
+ (<init>): init `channel.'
+ (finalizer): check if the `VMChannel.State' is valid.
+ (implCloseSelectableChannel): use `VMChannel.close.'
+ (implConfigureBlocking): use `VMChannel.setBlocking.'
+ (accept): use `VMChannel.accept.'
+ (getVMChannel): new method.
+ * gnu/java/nio/ServerSocketChannelSelectionKey.java (getNativeFD):
+ access native FD through `VMChannel.State.'
+ * gnu/java/nio/SocketChannelImpl.java: implement `VMChannelOwner.'
+ (impl): removed.
+ (channel, connected, connectAddress): new field.
+ (<init>): new constructors.
+ (getPlainSocketImpl): removed.
+ (implCloseSelectableChannel): use `VMChannel.close.'
+ (implConfigureBlocking): use `VMChannel.setBlocking.'
+ (connect): use `connect(SocketAddress,int).'
+ (connect): use `VMChannel.connect.'
+ (finishConnect): don't use a selector.
+ (isConnected): use `VMChannel.getPeerAddress.'
+ (read): use `VMChannel.read.'
+ (read): use `VMChannel.readScattering.'
+ (write): use `VMChannel.write.'
+ (write): use `VMChannel.writeGathering.'
+ (getVMChannel): new method.
+ * gnu/java/nio/SocketChannelSelectionKey.java (getNativeFD): get
+ native FD from `VMChannel.State.'
+ * gnu/java/nio/SocketChannelSelectionKeyImpl.java (getNativeFD):
+ get native FD from `VMChannel.State.'
+ * gnu/java/nio/VMChannelOwner.java: new file.
+ * gnu/java/nio/channels/FileChannelImpl.java: removed.
+ * include/Makefile.am: generate `gnu_java_nio_FileChannelImpl.h'
+ and `gnu_java_nio_KqueueSelectorImpl.h;' don't generate
+ `gnu_java_nio_channels_FileChannelImpl.h.'
+ * include/gnu_java_net_VMPlainSocketImpl.h: regenerated.
+ * include/gnu_java_nio_FileChannelImpl.h: new file.
+ * include/gnu_java_nio_KqueueSelectorImpl.h: new file.
+ * include/gnu_java_nio_VMChannel.h: regenerated.
+ * include/gnu_java_nio_VMPipe.h: regenerated.
+ * include/java_net_VMNetworkInterface.h: regenerated.
+ * java/io/FileDescriptor.java: fix imports.
+ * java/io/FileInputStream.java (<init>): handle exceptions.
+ (read): wrap the destination arary.
+ * java/io/FileOutputStream.java (<init>): handle exceptions.
+ (write): wrap the source array.
+ * java/io/RandomAccessFile.java (<init>): handle exceptions.
+ * java/net/DatagramSocket.java (<init>): handle exceptions.
+ (receive): handle length/port setting.
+ (connect): bind to any address/port if the argument is null.
+ * java/net/NetworkInterface.java (name, inetAddress): removed.
+ (netif): new field.
+ (<init>): make private.
+ (getName): return `netif.name.'
+ (getInetAddresses): access `netif.addresses.'
+ (getDisplayName): return `netif.name.'
+ (getByName, getByAddress): handle changes to `VMNetworkInterface.'
+ (condense): removed.
+ (getNetworkInterfaces): handle changes to `VMNetworkInterface.'
+ (equals): compare `netif' fields.
+ (hashCode): get hash codes from `netif.'
+ (toString): use a StringBuffer.
+ * java/net/ServerSocket.java (close): don't set `impl' to null.
+ (isClosed): use `VMChannel.State.isClosed.'
+ * java/net/Socket.java (getLocalAddress): don't use `getOption' if
+ the `SocketImpl' is a `PlainSocketImpl.'
+ (close): just close the `impl.'
+ (toString): use `super.toString' in the value we return.
+ (isConnected): just access `impl,' not `getImpl.'
+ (isBound): use `PlainSocketImpl' methods if we can.
+ (isClosed): look at `VMChannel.State.'
+ * native/jni/classpath/jcl.c (JNI_OnLoad): new function.
+ (JCL_NewRawDataObject): don't initialize cached fields here; throw
+ an exception if they were not.
+ (JCL_GetRawData): throw an exception if cached fields weren't
+ created.
+ * native/jni/java-lang/java_lang_VMProcess.c: handle
+ FileChannelImpl move.
+ * native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
+ (IO_EXCEPTION, SOCKET_EXCEPTION, BIND_EXCEPTION,
+ THROW_NO_NETWORK): new macros.
+ (Java_gnu_java_net_VMPlainSocketImpl_bind): reipmlemented.
+ (Java_gnu_java_net_VMPlainSocketImpl_bind6): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_listen): reimplemented.
+ (java_sockopt): new enum.
+ (Java_gnu_java_net_VMPlainSocketImpl_setOption): reimplemented.
+ (Java_gnu_java_net_VMPlainSocketImpl_getOption): reimplemented.
+ (Java_gnu_java_net_VMPlainSocketImpl_shutdownInput):
+ reimplemented.
+ (Java_gnu_java_net_VMPlainSocketImpl_shutdownOutput):
+ reimplemented.
+ (Java_gnu_java_net_VMPlainSocketImpl_sendUrgentData): new
+ function.
+ (Java_gnu_java_net_VMPlainSocketImpl_join): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_join6): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_read): removed.
+ (Java_gnu_java_net_VMPlainSocketImpl_leave): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_leave6): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_joinGroup): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_write): removed.
+ (Java_gnu_java_net_VMPlainSocketImpl_joinGroup6): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_leaveGroup): new function.
+ (Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6): new function.
+ (getif_address): new function.
+ (getif_index): new function.
+ * native/jni/java-net/java_net_VMNetworkInterface.c
+ (java_net_VMNetworkInterface_init,
+ java_net_VMNetworkInterface_addAddress): new file-scope globals.
+ (Java_java_net_VMNetworkInterface_initIds): new function.
+ (struct netif_entry): new struct.
+ (free_netif_list): new function.
+ (Java_java_net_VMNetworkInterface_getInterfaces): removed.
+ (Java_java_net_VMNetworkInterface_getVMInterfaces): new function.
+ * native/jni/java-nio/Makefile.am (libjavanio_la_SOURCES): remove
+ gnu_java_nio_channels_FileChannelImpl.c, add
+ gnu_java_nio_KqueueSelectorImpl.c.
+ * native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c: new file.
+ * native/jni/java-nio/gnu_java_nio_VMChannel.c
+ (INTERRUPTED_IO_EXCEPTION, SOCKET_TIMEOUT_EXCEPTION, ALIGN_UP,
+ ALIGN_DOWN): new macros.
+ (JCL_init_buffer): get the address through GetDirectBufferAddress
+ if possible.
+ (Java_gnu_java_nio_VMChannel_stdin_1fd,
+ Java_gnu_java_nio_VMChannel_stdout_1fd,
+ Java_gnu_java_nio_VMChannel_stderr_1fd): new functions.
+ (Java_gnu_java_nio_VMChannel_setBlocking): fix setting blocking
+ value.
+ (Java_gnu_java_nio_VMChannel_read): renamed...
+ (Java_gnu_java_nio_VMChannel_read__ILjava_nio_ByteBuffer_2): to
+ this; handle interrupted IO; add HAVE_READ check.
+ (Java_gnu_java_nio_VMChannel_write): renamed...
+ (Java_gnu_java_nio_VMChannel_write__ILjava_nio_ByteBuffer_2): to
+ this; handle zero-length write; add HAVE_WRITE check.
+ (Java_gnu_java_nio_VMChannel_receive): new function.
+ (Java_gnu_java_nio_VMChannel_send): new function.
+ (Java_gnu_java_nio_VMChannel_send6): new function.
+ (Java_gnu_java_nio_VMChannel_read__I): new function.
+ (Java_gnu_java_nio_VMChannel_write__II): new function.
+ (Java_gnu_java_nio_VMChannel_socket): new function.
+ (Java_gnu_java_nio_VMChannel_connect): new function.
+ (Java_gnu_java_nio_VMChannel_connect6): new function.
+ (Java_gnu_java_nio_VMChannel_getsockname): new function.
+ (Java_gnu_java_nio_VMChannel_getpeername): new function.
+ (Java_gnu_java_nio_VMChannel_accept): new function.
+ (Java_gnu_java_nio_VMChannel_disconnect): new function.
+ (Java_gnu_java_nio_VMChannel_close): new function.
+ (Java_gnu_java_nio_VMChannel_available): new function.
+ (FileChannel_mode): new enum.
+ (Java_gnu_java_nio_VMChannel_open): new function.
+ (Java_gnu_java_nio_VMChannel_position): new function.
+ (Java_gnu_java_nio_VMChannel_seek): new function.
+ (Java_gnu_java_nio_VMChannel_truncate): new funciton.
+ (Java_gnu_java_nio_VMChannel_lock): new function.
+ (Java_gnu_java_nio_VMChannel_unlock): new function.
+ (Java_gnu_java_nio_VMChannel_size): new function.
+ (Java_gnu_java_nio_VMChannel_map): new function.
+ (Java_gnu_java_nio_VMChannel_flush): new function.
+ * native/jni/java-nio/gnu_java_nio_VMPipe.c
+ (Java_gnu_java_nio_VMPipe_init): removed.
+ (Java_gnu_java_nio_VMPipe_pipe0): new function.
+ * native/jni/java-nio/javanio.c: new file.
+ * native/jni/java-nio/javanio.h: new file.
+ * native/jni/native-lib/cpnet.c (cpnet_getHostByName): fix for
+ systems without `gethostbyname_r.'
+ * vm/reference/gnu/java/net/VMPlainSocketImpl.java (nfd): new
+ field.
+ (<init>, <init>): new constructors.
+ (setOption, getOption): make instance methods; defer to native
+ implementation.
+ (connect): removed.
+ (bind): make an instance method; defer to native methods.
+ (accept): removed.
+ (available): removed.
+ (listen): make an instance method; defer to native method.
+ (read): removed.
+ (join, leave): new methods.
+ (write): removed.
+ (joinGroup, leaveGroup): new methods.
+ (shutdownInput, shutdownOutput): make instance methods.
+ (sendUrgentData): removed.
+ (State): new class.
+ * vm/reference/gnu/java/nio/VMChannel.java: make final.
+ (fd): removed.
+ (nfd): new field.
+ (<init>): new, public constructors.
+ (getVMChannel): methods removed.
+ (getState, getStdin, getStdout, getStderr, stdin_fd, stdout_fd,
+ stderr_fd): new methods.
+ (setBlocking): make an instance method.
+ (available): new method.
+ (read): get native fd from `nfd.'
+ (read): new single-byte read method.
+ (readScattering): get native fd from `nfd.'
+ (receive): new method.
+ (write, writeGathering): get native fd from `nfd.'
+ (send): new method.
+ (write): new single-byte write method.
+ (initSocket): new method.
+ (connect): new method.
+ (disconnect): new method.
+ (getLocalAddress): new method.
+ (getPeerAddress): new method.
+ (accept): new method.
+ (openFile): new method.
+ (position): new method.
+ (seek): new method.
+ (truncate): new method.
+ (lock): new method.
+ (unlock): new method.
+ (size): new method.
+ (map): new method.
+ (flush): new method.
+ (close): new method.
+ (State): new class.
+ (Kind): new class.
+ * vm/reference/gnu/java/nio/VMPipe.java (init): removed.
+ (pipe, pipe0): new method.
+ * vm/reference/java/net/VMNetworkInterface.java (name, addresses):
+ new fields.
+ (<clinit>): call `initIds.'
+ (initIds): new method.
+ (getInterfaces): removed.
+ (getVMInterfaces): new method.
+ (addAddress): new method.
+ * vm/reference/java/nio/channels/VMChannels.java: fix imports.
+
+2006-09-16 Chris Burdess <dog@gnu.org>
+
+ Fixes PR 28572.
+ * gnu/xml/transform/StreamSerializer.java: Don't escape XML entities
+ when in text output mode.
+
+2006-09-16 Chris Burdess <dog@gnu.org>
+
+ Fixes PR 27293.
+ * gnu/xml/dom/DomNode.java: Increment length of node during insert.
+
+2006-09-14 Michael Koch <konqueror@gmx.de>
+
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Recreated.
+
+2006-09-15 Chistian Elias Naur <elias@oddlabs.com>
+
+ * java/io/ObjectStreamClass.java (setClass(Class, ObjectStreamClass)):
+ Added !cl.isArray() to serialVersionUID mismatch check.
+
+2006-09-14 Francis Kung <fkung@redhat.com>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (gnu_java_awt_peer_gtk_CairoGraphics2D_setGradient): Updated constants to
+ be compatibe with Cairo 1.2.x.
+
+2006-09-14 Francis Kung <fkung@redhat.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java: Added interpolation constants.
+ (cairoSurfaceSetFilter): Removed method.
+ (drawImage): Pass interpolation type as argument to drawing methods.
+ (drawPixels): Added interpolation parameter.
+ (drawRaster): Pass interpolation type as argument to drawing method.
+ (getInterpolation): New method.
+ (setRenderingHint): Store hints, but do not set interpolation in cairo.
+ (setRenderingHints): Store hints, but do not set interpolation in cairo.
+ * gnu/java/awt/peer/gtk/CairoSurface.java
+ (drawSurface): Added interpolation parameter.
+ (nativeDrawSurface): Added interpolation parameter.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels): Added interpolation
+ parameter.
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter): Removed.
+ * native/jni/gtk-peer/cairographics2d.h
+ (java_awt_rendering_hints_filter): Added bicubic interpolation constant.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels): Added interpolation
+ parameter.
+ (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter): Removed.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+ (Java_gnu_java_awt_peer_gtk_CairoSurface_nativeDrawSurface): Added
+ interpolation parameter.
+
+2006-09-14 Gary Benson <gbenson@redhat.com>
+
+ * java/net/InetAddress.java
+ (internalGetCanonicalHostName): New method.
+ (getCanonicalHostName): Use internalGetCanonicalHostName.
+ (getByLiteral): New method.
+ (getAllByName): Use getByLiteral.
+ * java/net/SocketPermission.java
+ (host): Replaced with...
+ (hostname, address): New fields.
+ (equals, hashcode): Reflect the above.
+ (setHostPort): Parse host into hostname or address.
+ (implies): Rewrite host checks.
+
+2006-09-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ Fixes PR28699
+ * java/awt/Menu.java
+ (insert(MenuItem, int)): Fixed loop range,
+ (insert(String, int)): Updated API docs.
+
+2006-09-14 Christian Thalinger <twisti@complang.tuwien.ac.at>
+
+ Fixes PR22800
+ * native/fdlibm/mprec.h (Storeinc): Define correctly for LE
+ architectures (like Arm).
+ * native/jni/java-lang/java_lang_VMDouble.c (doubleToLongBits):
+ Reverted SWAP_DOUBLE patch.
+ (doubleToRawLongBits): Likewise.
+ (longBitsToDouble): Likewise.
+
+2006-09-14 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Menu.java: Reformatted source file.
+
+2006-09-14 Jeroen Frijters <jeroen@frijters.net>
+
+ * gnu/java/rmi/server/ActivatableRef.java
+ (readExternal, writeExternal): Partial fix for serialization format.
+
+2006-09-14 Jeroen Frijters <jeroen@frijters.net>
+
+ PR classpath/28984
+ * java/io/InputStreamReader.java
+ (read(char[],int,int)): Fixed bug.
+
+2006-09-13 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/BandCombineOp.java: Updated documentation.
+ (filter(Raster, WritableRaster)): Use int arrays, and added simple cache.
+
+2006-09-13 Tom Tromey <tromey@redhat.com>
+
+ PR classpath/29034:
+ * java/io/PipedReader.java (read): Return early if len==0.
+ * java/io/PipedInputStream.java (read): Return early if len==0.
+
+2006-09-13 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/ConvolveOp.java (filter(Raster, WritableRaster)):
+ Removed hard-coded max sample value.
+ * java/awt/image/RescaleOp.java (filter(Raster, WritableRaster)):
+ Fixed finding of max sample value.
+
+2006-09-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (setPaint): Check null argument ('p').
+
+2006-09-12 Francis Kung <fkung@redhat.com>
+
+ PR 27940
+ * gnu/java/awt/java2d/TexturePaintContext.java
+ (constructor): Fixed typo, getMinY instead of getMaxX.
+ * gnu/java/awt/peer/gtk/CairoGraphics2D.java
+ (setPaint): Implemented support for custom Paint classes.
+ (setPaintPixels): Renamed from setTexturePixels, added repeat parameter.
+ (setTexturePixels): Renamed to setPaintPixels, added repeat parameter.
+ * include/gnu_java_awt_peer_gtk_CairoGraphics2D.h: Renamed setTexturePixels
+ to setPaintPixels, and added repeat parameter.
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c:
+ Renamed setTexturePixels to setPaintPixels, and added repeat parameter.
+
+2006-09-12 Gary Benson <gbenson@redhat.com>
+
+ * java/net/NetworkInterface.java (getInetAddresses):
+ Fix port used in security check.
+
+2006-09-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/DefaultMetalTheme.java
+ (CONTROL_TEXT_FONT): Renamed 'controlTextFont',
+ (MENU_TEXT_FONT): Renamed 'menuTextFont',
+ (getControlTextFont): Check 'swing.boldMetal' setting before
+ initialising font,
+ (getMenuTextFont): Likewise.
+
+2006-09-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/OceanTheme.java
+ (addCustomEntriesToTable): Added 'List.focusCellHighlightBorder' entry.
+
+2006-09-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalIconFactory.java
+ (InternalFrameDefaultMenuIcon.paintIcon): Use theme colors.
+
+2006-09-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractSpinnerModel.java: API doc updates.
+
+2006-09-12 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/AbstractButton.java
+ (AbstractButton): Initialise textIconGap field.
+
+2006-09-11 Tom Tromey <tromey@redhat.com>
+
+ * tools/gnu/classpath/tools/javah/FieldHelper.java (print): Print
+ "volatile" when needed.
+
+2006-09-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/text/AttributedCharacterIterator.java
+ (LANGUAGE): Initialise with lower case string,
+ (INPUT_METHOD_SEGMENT): Likewise,
+ (READING): Likewise,
+ * java/text/AttributedStringIterator.java
+ (getRunLimit): Check all attributes for changes.
+
+2006-09-11 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/text/AttributedCharacterIterator.java: Added @since tag,
+ renamed some variables (no underscores) and removed some spaces to
+ match the common style,
+ * java/text/AttributedString.java: Likewise,
+ * java/text/AttributedStringIterator.java: Likewise.
+
+2006-09-11 Gary Benson <gbenson@redhat.com>
+
+ * java/net/Inet4Address.java
+ (FAMILY): Renamed back to AF_INET.
+ (<init>, writeReplace): Reflect the above.
+ * java/net/Inet6Address.java
+ (FAMILY): Renamed back to AF_INET6.
+ (<init>): Reflect the above.
+
+2006-09-11 Cameron McCormack <cam-gcc-bugzilla@aka.mcc.id.au>
+
+ Fixes PR29010
+ * java/text/AttributedString.java
+ (AttributedString(AttributedCharacterIterator, int, int,
+ AttributedCharacterIterator.Attribute[])): Fixed check for defined
+ attribute.
+
+2006-09-11 Gary Benson <gbenson@redhat.com>
+
+ * java/net/Inet4Address.java
+ (AF_INET): Renamed to FAMILY.
+ (<init>, writeReplace): Reflect the above.
+ * java/net/Inet6Address.java
+ (AF_INET6): Renamed to FAMILY.
+ (<init>): Reflect the above.
+
+2006-09-10 Ito Kazumitsu <kaz@maczuka.gcd.org>
+
+ Fixes bug #28867
+ Originally in Kaffe: 2004-04-16 Helmer Kraemer <hkraemer@freenet.de>
+ * java/net/ServerSocket.java(implAccept): Deleted socket.implCreated.
+ * java/net/Socket.java: Avoid creating a redundant file descriptor.
+ (implCreated): Deleted, (getImpl): Don't check impleCreated,
+ (bind): Call getImpl().create(true).
+
+2006-09-09 Chris Burdess <dog@gnu.org>
+
+ * gnu/xml/xpath/Expr.java: Ensure that node-set evaluation returns
+ an instance of org.w3c.dom.NodeList.
+
+2006-09-08 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * tools/gnu/classpath/tools/appletviewer/Main.java: Warn about
+ missing security manager when run in standalone mode.
+
+2006-09-08 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/AffineTransformOp.java: Updated documentation.
+ (createCompatibleDestRaster): Updated formatting.
+ (filter(BufferedImage, BufferedImage)): Updated formatting.
+ (filter(Raster, WritableRaster)): Delegated processing to native peers for
+ if colour model is compatible.
+ (filterBicubic): Get entire pixel at once, and use appropriate array type.
+ (filterBilinear): Get entire pixel at once, and use appropriate array type.
+
+2006-09-08 Gary Benson <gbenson@redhat.com>
+
+ * java/net/InetAddress.java
+ (family): Updated javadoc and made private.
+ (<init>): Add an address family argument.
+ (readObject): Don't overwrite family.
+ * java/net/Inet4Address.java
+ (AF_INET): New constant.
+ (<init>): Use AF_INET as the family.
+ (writeReplace): Likewise.
+ * java/net/Inet6Address.java
+ (AF_INET6): New constant.
+ (<init>): Use AF_INET6 as the family.
+
+2006-09-08 Gary Benson <gbenson@redhat.com>
+
+ * java/net/InetAddress.java
+ (getHostName): Move lookup into getCanonicalHostName.
+ (getCanonicalHostName): Move lookup from getHostName,
+ Perform security check on canonical name (ie after lookup).
+
+2006-09-08 Gary Benson <gbenson@redhat.com>
+
+ * java/net/Inet4Address.java (isMulticastAddress,
+ isLoopbackAddress, isAnyLocalAddress, isLinkLocalAddress,
+ isSiteLocalAddress, isMCGlobal, isMCNodeLocal, isMCLinkLocal,
+ isMCSiteLocal, isMCOrgLocal, getHostAddress): Moved
+ implementations from InetAddress.
+ * java/net/InetAddress.java (isMulticastAddress,
+ isLoopbackAddress, isAnyLocalAddress, isLinkLocalAddress,
+ isSiteLocalAddress, isMCGlobal, isMCNodeLocal, isMCLinkLocal,
+ isMCSiteLocal, isMCOrgLocal, getHostAddress): Replace
+ implementations with UnsupportedOperationExceptions.
+
+2006-09-08 Gary Benson <gbenson@redhat.com>
+
+ * java/net/InetAddress.java
+ (inaddr_any): Removed.
+ (ANY_IF, LOCALHOST): Create using getByAddress.
+ (<init>): Updated javadoc.
+ (getHostName): Cache hostname even if the lookup failed.
+ (getByAddress): Create Inet4Address objects when passed
+ IPv4-mapped IPv6 addresses.
+ (aton): Removed.
+ (getAllByName): Create address objects using getByAddress.
+ Do not perform security checks unless actually required.
+ Do not strip whitespace from the hostname.
+ (getInaddrAny): Removed.
+ (getLocalHost): Return the loopback address if getByName
+ throws a SecurityException.
+ (readResolve): Updated javadoc.
+ * vm/reference/java/net/VMInetAddress.java (aton): Declared.
+ * include/java_net_VMInetAddress.h
+ (Java_java_net_VMInetAddress_aton): Likewise.
+ * native/jni/java-net/java_net_VMInetAddress.c
+ (Java_java_net_VMInetAddress_aton): New method.
+ * native/jni/native-lib/cpnet.h (cpnet_aton): Declared.
+ * native/jni/native-lib/cpnet.c (cpnet_aton): New method.
+ * configure.ac (AC_CHECK_FUNCS): Checks for cpnet_aton.
+ * java/net/Inet4Address.java (writeReplace): Updated javadoc.
+ * NEWS: Added note about updated VM interface.
+
+2006-09-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (setNorthPane): Assign component to titlePane.
+
+2006-09-07 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/NamingService/NameParser.java (corbaloc):
+ Remove unused variable alt_addr.
+ * gnu/CORBA/NamingService/NameTransformer.java (toName):
+ Remove unused variables.
+
+2006-09-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ (installDefaults): Initialise scrollBarWidth from UI defaults here,
+ (createDecreaseButton): Don't fetch scrollBarWidth here,
+ (createIncreaseButton): Likewise.
+
+2006-09-07 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/MemoryImageSource.java: Added API docs.
+
+2006-09-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/basic/BasicScrollBarUI.java
+ (installDefaults): Call configureScrollBarColors().
+
+2006-09-06 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/RescaleOp.java: Updated documentation and formatting.
+ (constructor): Make copy of arrays.
+ (createCompatibleDestImage): Changed treatment of null ColorModel.
+ (filter(BufferedImage, BufferedImage)): Re-implemented.
+ (filter(Raster, WritableRaster, boolean[])): New method.
+ (filter(Raster, WritableRaster)): Re-implemented.
+ (getOffsets): Prevent ArrayIndexOutOfBoundsException.
+ (getPoint2D): Cleaned up formatting.
+ (getScaleFactors): Prevent ArrayIndexOutOfBoundsException.
+
+2006-09-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/UIManager.java
+ (getBoolean(Object)): Reimplemented,
+ (getBoolean(Object, Locale)): Likewise,
+ (getBorder(Object)): Likewise,
+ (getBorder(Object, Locale)): Likewise,
+ (getColor(Object)): Likewise,
+ (getColor(Object, Locale)): Likewise,
+ (getDimension(Object)): Likewise,
+ (getDimension(Object, Locale)): Likewise,
+ (getFont(Object)): Likewise,
+ (getFont(Object, Locale)): Likewise,
+ (getIcon(Object)): Likewise,
+ (getIcon(Object, Locale)): Likewise,
+ (getInsets(Object)): Updated API docs,
+ (getInsets(Object, Locale)): Likewise,
+ (getInt(Object)): Reimplemented,
+ (getInt(Object, Locale)): Likewise,
+ (getString(Object)): Likewise,
+ (getString(Object, Locale)): Likewise.
+
+2006-09-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/UIManager.java
+ (MultiplexUIDefaults.MultiplexUIDefaults()): Don't allow null fallback,
+ (getDefaults): Initialise MultiplexUIDefaults with empty fallback.
+
+2006-09-06 David Gilbert <david.gilbert@object-refinery.com>
+
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): Corrected various font defaults.
+
+2006-09-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/List.java: Added @since to various methods.
+
+2006-09-05 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * native/jni/native-lib/cpprocess.c:
+ (forkAndExec(char*,char*,int,int,pid_t,char*)):
+ Add redirection of stdout to stderr.
+ * native/jni/native-lib/cpprocess.h:
+ Added redirect argument.
+ * native/jni/java-lang/java_lang_VMProcess.c
+ (Java_java_lang_VMProcess_nativeSpawn): Readd redirect argument.
+ * vm/reference/java/lang/VMProcess.java: Likewise.
+ * include/java_lang_VMProcess.h: Regenerated.
+
+2006-09-05 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c: Adjust
+ __attribute to __attribute__.
+
+ * native/jni/java-nio/java_nio_MappedByteBufferImpl.c: Remove duplicate
+ header include.
+
+2006-09-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/List.java: Source code reformatted.
+
+2006-09-05 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CollocatedOrbs.java,
+ gnu/CORBA/SafeForDirectCalls.java: New files.
+ * gnu/CORBA/NamingService/Binding_iterator_impl.java:
+ Implement gnu.CORBA.SafeForDirectCalls.
+ * gnu/CORBA/NamingService/Ext.java: Likewise.
+ * gnu/CORBA/NamingService/TransientContext.java: Likewise.
+ * gnu/CORBA/OrbFunctional.java (createIor):Cache the address
+ of the local host. (ior_to_object): Return the local object
+ where possible. (run): Register/unregister this ORB.
+ * gnu/CORBA/Poa/LocalRequest.java (v_invoke): Call gnuPOA.checkDiscarding.
+ * gnu/CORBA/Poa/gnuPOA.java (checkDiscarding): Made package private.
+ * gnu/CORBA/Poa/gnuServantObject.java (noRetain): New field.
+ (constructors): Initialize noRetain. (_invoke): Drop servant
+ if noRetain is true. (getHandler): Always seach for the new servant
+ if noRetain is true.
+ * gnu/CORBA/SimpleDelegate.java (create_request): Implemented.
+ * NEWS: Added note about the new feature.
+
+2006-09-05 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Choice.java
+ (addItem): Fixed API doc glitch.
+
+2006-09-05 Francis Kung <fkung@redhat.com>
+
+ * java/awt/image/LookupOp.java: Updated documentation & formatting.
+ (createCompatibleDestImage): Re-implemented.
+ (filter(BufferedImage, BufferedImage)): Added check for src/dest image
+ compatibility, and use ColorConvertOp for color conversion if needed.
+ (filter(Raster, WritableRaster)): Made exceptions more descriptive.
+
+2006-09-05 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ gnu/CORBA/CDR/Vio.java,
+ org/omg/CORBA_2_3/ORB.java,
+ org/omg/CORBA_2_3/portable/InputStream.java,
+ org/omg/CORBA_2_3/portable/OutputStream.java,
+ org/omg/CosNaming/BindingIteratorHelper.java,
+ org/omg/CosNaming/BindingTypeHelper.java,
+ org/omg/CosNaming/NameComponentHelper.java,
+ org/omg/CosNaming/NameHelper.java,
+ org/omg/CosNaming/NamingContextExtHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java,
+ org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java,
+ org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java,
+ org/omg/CosNaming/NamingContextHelper.java,
+ org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidName.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java,
+ org/omg/DynamicAny/AnySeqHelper.java,
+ org/omg/DynamicAny/DynAnyFactoryHelper.java,
+ org/omg/DynamicAny/DynAnyFactoryOperations.java,
+ org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java,
+ org/omg/DynamicAny/DynAnyHelper.java,
+ org/omg/DynamicAny/DynAnyOperations.java,
+ org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java,
+ org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java,
+ org/omg/DynamicAny/DynAnySeqHelper.java,
+ org/omg/DynamicAny/DynArrayHelper.java,
+ org/omg/DynamicAny/DynEnumHelper.java,
+ org/omg/DynamicAny/DynFixedHelper.java,
+ org/omg/DynamicAny/DynSequenceHelper.java,
+ org/omg/DynamicAny/DynStructHelper.java,
+ org/omg/DynamicAny/DynStructOperations.java,
+ org/omg/DynamicAny/DynUnionHelper.java,
+ org/omg/DynamicAny/DynValueHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairHelper.java,
+ org/omg/DynamicAny/NameDynAnyPairSeqHelper.java,
+ org/omg/IOP/CodecFactoryHelper.java,
+ org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java,
+ org/omg/IOP/CodecOperations.java,
+ org/omg/IOP/CodecPackage/FormatMismatchHelper.java,
+ org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java,
+ org/omg/IOP/CodecPackage/TypeMismatchHelper.java,
+ org/omg/IOP/ComponentIdHelper.java,
+ org/omg/IOP/ExceptionDetailMessage.java,
+ org/omg/IOP/MultipleComponentProfileHelper.java,
+ org/omg/IOP/ProfileIdHelper.java,
+ org/omg/IOP/ServiceContextListHelper.java,
+ org/omg/IOP/ServiceIdHelper.java,
+ org/omg/IOP/TAG_CODE_SETS.java,
+ org/omg/PortableInterceptor/ClientRequestInfoOperations.java,
+ org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java,
+ org/omg/PortableInterceptor/CurrentHelper.java,
+ org/omg/PortableInterceptor/IORInfo.java,
+ org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java,
+ org/omg/PortableInterceptor/ORBIdHelper.java,
+ org/omg/PortableInterceptor/ORBInitInfoOperations.java,
+ org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java,
+ org/omg/PortableInterceptor/ORBInitializerOperations.java,
+ org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java,
+ org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java,
+ org/omg/PortableInterceptor/RequestInfoOperations.java,
+ org/omg/PortableInterceptor/ServerIdHelper.java,
+ org/omg/PortableInterceptor/ServerRequestInfoOperations.java,
+ org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java,
+ org/omg/PortableServer/AdapterActivatorOperations.java,
+ org/omg/PortableServer/CurrentHelper.java,
+ org/omg/PortableServer/CurrentPackage/NoContextHelper.java,
+ org/omg/PortableServer/ForwardRequestHelper.java,
+ org/omg/PortableServer/IdAssignmentPolicyValue.java,
+ org/omg/PortableServer/IdUniquenessPolicyValue.java,
+ org/omg/PortableServer/ImplicitActivationPolicyValue.java,
+ org/omg/PortableServer/LifespanPolicyValue.java,
+ org/omg/PortableServer/POA.java,
+ org/omg/PortableServer/POAHelper.java,
+ org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java,
+ org/omg/PortableServer/POAManagerPackage/State.java,
+ org/omg/PortableServer/POAOperations.java,
+ org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java,
+ org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java,
+ org/omg/PortableServer/POAPackage/InvalidPolicy.java,
+ org/omg/PortableServer/POAPackage/NoServantHelper.java,
+ org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java,
+ org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java,
+ org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java,
+ org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java,
+ org/omg/PortableServer/POAPackage/WrongAdapterHelper.java,
+ org/omg/PortableServer/POAPackage/WrongPolicyHelper.java,
+ org/omg/PortableServer/RequestProcessingPolicyValue.java,
+ org/omg/PortableServer/ServantActivatorHelper.java,
+ org/omg/PortableServer/ServantLocatorHelper.java,
+ org/omg/PortableServer/ServantLocatorOperations.java,
+ org/omg/PortableServer/ServantRetentionPolicyValue.java,
+ org/omg/PortableServer/ThreadPolicyValue.java,
+ org/omg/PortableServer/_ServantActivatorStub.java,
+ org/omg/PortableServer/_ServantLocatorStub.java,
+ org/omg/PortableServer/portable/Delegate.java: Documentation fixes.
+
+2006-09-05 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * javax/rmi/CORBA/Tie.java,
+ org/omg/CORBA/AnyHolder.java,
+ org/omg/CORBA/AnySeqHelper.java,
+ org/omg/CORBA/AnySeqHolder.java,
+ org/omg/CORBA/BooleanHolder.java,
+ org/omg/CORBA/BooleanSeqHelper.java,
+ org/omg/CORBA/BooleanSeqHolder.java,
+ org/omg/CORBA/ByteHolder.java,
+ org/omg/CORBA/CharHolder.java,
+ org/omg/CORBA/CharSeqHelper.java,
+ org/omg/CORBA/CharSeqHolder.java,
+ org/omg/CORBA/Context.java,
+ org/omg/CORBA/CurrentHelper.java,
+ org/omg/CORBA/CustomValue.java,
+ org/omg/CORBA/DataOutputStream.java,
+ org/omg/CORBA/DefinitionKindHelper.java,
+ org/omg/CORBA/DomainManagerOperations.java,
+ org/omg/CORBA/DoubleHolder.java,
+ org/omg/CORBA/DoubleSeqHelper.java,
+ org/omg/CORBA/DoubleSeqHolder.java,
+ org/omg/CORBA/DynAny.java,
+ org/omg/CORBA/DynSequence.java,
+ org/omg/CORBA/DynValue.java,
+ org/omg/CORBA/DynamicImplementation.java,
+ org/omg/CORBA/FieldNameHelper.java,
+ org/omg/CORBA/FixedHolder.java,
+ org/omg/CORBA/FloatHolder.java,
+ org/omg/CORBA/FloatSeqHelper.java,
+ org/omg/CORBA/FloatSeqHolder.java,
+ org/omg/CORBA/IdentifierHelper.java,
+ org/omg/CORBA/IntHolder.java,
+ org/omg/CORBA/LocalObject.java,
+ org/omg/CORBA/LongHolder.java,
+ org/omg/CORBA/LongLongSeqHelper.java,
+ org/omg/CORBA/LongLongSeqHolder.java,
+ org/omg/CORBA/LongSeqHelper.java,
+ org/omg/CORBA/LongSeqHolder.java,
+ org/omg/CORBA/ORB.java,
+ org/omg/CORBA/ObjectHelper.java,
+ org/omg/CORBA/ObjectHolder.java,
+ org/omg/CORBA/OctetSeqHelper.java,
+ org/omg/CORBA/OctetSeqHolder.java,
+ org/omg/CORBA/PolicyErrorCodeHelper.java,
+ org/omg/CORBA/PolicyErrorHelper.java,
+ org/omg/CORBA/PolicyHelper.java,
+ org/omg/CORBA/PolicyListHelper.java,
+ org/omg/CORBA/PolicyTypeHelper.java,
+ org/omg/CORBA/PrincipalHolder.java,
+ org/omg/CORBA/RepositoryIdHelper.java,
+ org/omg/CORBA/Request.java,
+ org/omg/CORBA/ShortHolder.java,
+ org/omg/CORBA/ShortSeqHelper.java,
+ org/omg/CORBA/ShortSeqHolder.java,
+ org/omg/CORBA/StringSeqHelper.java,
+ org/omg/CORBA/StringSeqHolder.java,
+ org/omg/CORBA/ULongLongSeqHelper.java,
+ org/omg/CORBA/ULongLongSeqHolder.java,
+ org/omg/CORBA/ULongSeqHelper.java,
+ org/omg/CORBA/ULongSeqHolder.java,
+ org/omg/CORBA/UShortSeqHelper.java,
+ org/omg/CORBA/UShortSeqHolder.java,
+ org/omg/CORBA/ValueBaseHelper.java,
+ org/omg/CORBA/ValueBaseHolder.java,
+ org/omg/CORBA/VersionSpecHelper.java,
+ org/omg/CORBA/WCharSeqHelper.java,
+ org/omg/CORBA/WCharSeqHolder.java,
+ org/omg/CORBA/WStringSeqHelper.java,
+ org/omg/CORBA/WStringSeqHolder.java,
+ org/omg/CORBA/WrongTransactionHelper.java,
+ org/omg/CORBA/_IDLTypeStub.java,
+ org/omg/CORBA/_PolicyStub.java,
+ org/omg/CORBA/portable/BoxedValueHelper.java,
+ org/omg/CORBA/portable/Delegate.java,
+ org/omg/CORBA/portable/ObjectImpl.java,
+ org/omg/CORBA/portable/ServantObject.java,
+ org/omg/CORBA/portable/StreamableValue.java,
+ org/omg/CosNaming/BindingType.java,
+ org/omg/CosNaming/IstringHelper.java,
+ org/omg/DynamicAny/FieldNameHelper.java,
+ org/omg/PortableServer/Servant.java: Documentation fixes.
+
+2006-09-04 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/Rectangle.java
+ (setRect(double, double, double, double)): Modified rounding of input
+ values.
+
2006-09-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* gnu/javax/swing/text/html/parser/HTML_401F.java (defineElements):
diff --git a/INSTALL b/INSTALL
index d2bb26621..00045f668 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
-Installing GNU Classpath - Last updated: September 7, 2005
+Installing GNU Classpath - Last updated: June 19, 2006
First, this is a development release only! Unless you are interested in
active development and debugging, or just like running random alpha code,
@@ -54,6 +54,11 @@ Suggested Software
For building gcjwebplugin you'll need the Mozilla plugin
support headers and libraries.
+ The GConf-based backend for java.util.prefs needs the following
+ library headers:
+
+ - gconf 2.11.2 (or higher)
+
For building the Qt AWT peer JNI native libraries you have to
specify --enable-qt-peer and need the following library:
@@ -65,10 +70,10 @@ Suggested Software
http://escher.sourceforge.net
Please note that at the moment most operating systems do not
- ship Qt4 by default. We recommend using GNU Classpath' Qt4
- support only for its developers and bug reporters. See
- http://developer.classpath.org/mediation/ClasspathShowcase
- for details on how to get it to work.
+ ship Qt4 by default. We recommend using GNU Classpath' Qt4
+ support only for its developers and bug reporters. See
+ http://developer.classpath.org/mediation/ClasspathShowcase
+ for details on how to get it to work.
For building the xmlj JAXP implementation (disabled by default, use
configure --enable-xmlj) you need the following installed:
@@ -80,7 +85,7 @@ Suggested Software
http://www.xmlsoft.org/XSLT/
Minimum version of libxslt required: 1.1.11
- For building the javah tool, you will need the ASM library.
+ For building the gjavah and grmic tool, you will need the ASM library.
Current version 2.2.1 is needed (other 2.2.x versions should
be ok; 3.x is not ok). You can get ASM from
http://asm.objectweb.org/
diff --git a/NEWS b/NEWS
index d85a84173..e1714e032 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
New in release 0.93 (UNRELEASED)
+* CORBA objects that exist on the same virtual machine and only are connected
+ to another ORB are now accessed directly and no longer via network. It is
+ the same feature that RMI implementation provides. These faster calls should
+ be completely transparent, as the parameters are cloned, where required.
+ Currently the direct calls are only possible for the non-deprecated objects
+ that are connected to the ORB via POA.
* The 'javah' tool has been added. It requires the ASM library
(see asm.objectweb.org); it can be enabled with the --with-asm
option to configure
@@ -10,6 +16,31 @@ New in release 0.93 (UNRELEASED)
* Added firstNonNullClassLoader method to
vm/reference/gnu/classpath/VMStackWalker.java. VMs are encouraged to
provide a more efficient implementation.
+* Added aton method to vm/reference/java/net/VMInetAddress.java.
+* NetworkInterface has been implemented for systems that provide the
+ `getifaddrs' function.
+* java.nio.channels.Selector implementations have been added that use
+ the kqueue notification mechanism on Mac OS X and *BSD, and that use
+ the epoll notification mechanism on Linux 2.6.
+* java.nio has been refactored to support more non-blocking operations
+ natively. Blocking IO classes have been refactored to call
+ non-blocking classes. Non-blocking accepts, connects, and
+ scatter-gather IO should now be better supported.
+
+Runtime interface changes:
+
+* java.net.VMNetworkInterface and java.net.NetworkInterface have been
+ updated to keep native-modified state in the former, and to simplify
+ the native code in our reference implementation.
+* gnu.java.nio.VMChannel has been expanded to better support native
+ non-blocking IO. Most native state data (such as file descriptor
+ integers) has been abstracted away into private state in the runtime
+ interface.
+* gnu.java.nio.VMPipe has been similarly changed.
+* gnu.java.net.VMPlainSocketImpl has been changed to remove some
+ functionality now provided by VMChannel; datagram socket-specific
+ methods have also been moved here, deprecating
+ VMPlainDatagramSocketImpl.
New in release 0.92 (Aug 9, 2006)
diff --git a/configure.ac b/configure.ac
index d31bb91b7..c1fb86c8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -356,7 +356,8 @@ if test "x${COMPILE_JNI}" = xyes; then
crt_externs.h \
fcntl.h \
sys/mman.h \
- magic.h])
+ magic.h \
+ sys/event.h sys/epoll.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]))
@@ -365,7 +366,7 @@ if test "x${COMPILE_JNI}" = xyes; then
AC_CHECK_FUNCS([ftruncate fsync select \
gethostname socket strerror fork pipe execve open close \
- lseek fstat read write htonl memset htons connect \
+ lseek fstat read readv write writev htonl memset htons connect \
getsockname getpeername bind listen accept \
recvfrom send sendto setsockopt getsockopt time mktime \
gethostbyname_r localtime_r \
@@ -373,12 +374,21 @@ if test "x${COMPILE_JNI}" = xyes; then
fcntl \
mmap munmap mincore msync madvise getpagesize sysconf \
lstat readlink \
- ])
+ inet_aton inet_addr inet_pton \
+ getifaddrs kqueue kevent epoll_create \
+ readdir_r ])
LIBMAGIC=
AC_CHECK_LIB(magic, magic_open, LIBMAGIC=-lmagic)
AC_SUBST(LIBMAGIC)
+ AC_MSG_CHECKING([whether struct sockaddr_in6 is in netinet/in.h])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[struct sockaddr_in6 addr6;]])],
+ [AC_DEFINE(HAVE_INET6, 1,
+ [Define if inet6 structures are defined in netinet/in.h.])
+ AC_MSG_RESULT(yes)],
+ [AC_MSG_RESULT(no)])
+
AC_HEADER_TIME
AC_STRUCT_TM
AC_STRUCT_TIMEZONE
@@ -413,17 +423,17 @@ if test "x${COMPILE_JNI}" = xyes; then
dnl When using gcc we want warnings, lots of warnings :-)
if test "x${GCC}" = xyes; then
- dnl We want ISO C90 pedantic ansi, but with longlong (jlong) support
+ dnl We want ISO C90 ansi, but with longlong (jlong) support
dnl and modern POSIX and BSD C library functions/prototypes.
dnl Warning flags for (almost) everybody.
dnl Should probably be configurable
- WARNING_CFLAGS='-pedantic -W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long'
+ WARNING_CFLAGS='-W -Wall -Wmissing-declarations -Wwrite-strings -Wmissing-prototypes -Wno-long-long'
AC_SUBST(WARNING_CFLAGS)
dnl Strict warning flags which not every module uses.
dnl Should probably be configurable.
- STRICT_WARNING_CFLAGS=-Wstrict-prototypes
+ STRICT_WARNING_CFLAGS='-Wstrict-prototypes -pedantic'
AC_SUBST(STRICT_WARNING_CFLAGS)
dnl Whether or not to add -Werror, also not used by all modueles.
@@ -799,7 +809,7 @@ dnl Build javah using ASM library
dnl -----------------------------------------------------------
AC_ARG_WITH([asm],
AS_HELP_STRING([--with-asm=ABS.PATH],
- [specify path to ASM jar for javah]))
+ [specify path to ASM jar to enable gjavah and grmic build]))
case "$with_asm" in
"")
use_asm=false
@@ -898,13 +908,23 @@ tools/gjarsigner
tools/gkeytool
tools/gjar
tools/gnative2ascii
-tools/gserialver])
+tools/gserialver
+tools/grmiregistry
+tools/gtnameserv
+tools/gorbd
+tools/grmid
+tools/grmic])
AC_CONFIG_COMMANDS([gappletviewer],[chmod 755 tools/gappletviewer])
AC_CONFIG_COMMANDS([gjarsigner],[chmod 755 tools/gjarsigner])
AC_CONFIG_COMMANDS([gkeytool],[chmod 755 tools/gkeytool])
AC_CONFIG_COMMANDS([gjar],[chmod 755 tools/gjar])
AC_CONFIG_COMMANDS([gnative2ascii],[chmod 755 tools/gnative2ascii])
AC_CONFIG_COMMANDS([gserialver],[chmod 755 tools/gserialver])
+AC_CONFIG_COMMANDS([grmiregistry],[chmod 755 tools/grmiregistry])
+AC_CONFIG_COMMANDS([gtnameserv],[chmod 755 tools/gtnameserv])
+AC_CONFIG_COMMANDS([gorbd],[chmod 755 tools/gorbd])
+AC_CONFIG_COMMANDS([grmid],[chmod 755 tools/grmid])
+AC_CONFIG_COMMANDS([grmic],[chmod 755 tools/grmic])
if test "$use_asm" = true; then
AC_CONFIG_FILES([tools/gjavah])
diff --git a/examples/Makefile.am b/examples/Makefile.am
index ee5f7dfba..43df1bdcf 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,5 @@
## Input file for automake to generate the Makefile.in used by configure
-GLIBJ_CLASSPATH='$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip'
+GLIBJ_CLASSPATH='$(top_builddir)/lib':'$(top_builddir)/lib/glibj.zip':'$(top_builddir)/tools/tools.zip'
# Setup the compiler to use the GNU Classpath library we just build
#if FOUND_GCJ
diff --git a/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java b/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
index fb5ebdbb5..38c4ecb98 100644
--- a/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
+++ b/examples/gnu/classpath/examples/CORBA/NamingService/Demo.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package gnu.classpath.examples.CORBA.NamingService;
import gnu.CORBA.IOR;
-import gnu.CORBA.NamingService.NamingServiceTransient;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
@@ -97,7 +96,7 @@ public class Demo
{
public void run()
{
- NamingServiceTransient.main(args);
+ gnu.classpath.tools.tnameserv.Main.main(args);
}
}.start();
diff --git a/gnu/CORBA/CDR/Vio.java b/gnu/CORBA/CDR/Vio.java
index fd878cb35..28f1c5672 100644
--- a/gnu/CORBA/CDR/Vio.java
+++ b/gnu/CORBA/CDR/Vio.java
@@ -155,7 +155,6 @@ public abstract class Vio
* read(InputStream, Class) or read(InputStream, Serializable).
*
* @param input a stream to read from.
- * @param repository_id a repository id of the object being read, may be null.
*
* @return the loaded value.
*
@@ -173,7 +172,7 @@ public abstract class Vio
* is known. Hence it may be faster to use the alternative methods,
* read(InputStream, Class) or read(InputStream, Serializable).
*
- * @param an_input a stream to read from.
+ * @param input a stream to read from.
* @param repository_id a repository id of the object being read, may be null.
*
* @return the loaded value.
@@ -904,7 +903,7 @@ public abstract class Vio
*
* @param output an output stream to write into.
* @param value a value to write.
- * @param id a value repository id (can be either single string or string
+ * @param ids a value repository id (can be either single string or string
* array).
* @param helper a helper, writing object - specifical part. Can be null if
* the value should be written using other methods.
diff --git a/gnu/CORBA/CollocatedOrbs.java b/gnu/CORBA/CollocatedOrbs.java
new file mode 100644
index 000000000..fc1e513ef
--- /dev/null
+++ b/gnu/CORBA/CollocatedOrbs.java
@@ -0,0 +1,164 @@
+/* CollocatedOrbs.java -- Handles collocations
+ 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.CORBA;
+
+import gnu.CORBA.Poa.gnuServantObject;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.portable.Delegate;
+import org.omg.CORBA.portable.ObjectImpl;
+
+/**
+ * This class provides support for the direct method invocations without
+ * involving the network in the case when both ORBs run on the same java
+ * virtual machine. Special attention is only needed when call is made
+ * between two independent ORBs, instantiated via ORB.init. The call to the
+ * object, obtained via IOR reference from the ORB where it was locally
+ * connected is always local anyway.
+ *
+ * For security reasons it may be sensible to keep this class and all support
+ * package private.
+ *
+ * @author Audrius Meskauskas
+ */
+class CollocatedOrbs
+{
+ /**
+ * This field is used in automated Classpath specific testing to disable
+ * the direct calls.
+ */
+ static boolean DIRECT_CALLS_ALLOWED = true;
+
+ /**
+ * Containts the references of the all running GNU Classpath ORBs in the
+ * local virtual machine. GNU Classpath ORBs register themselves here when
+ * created and unregister when either ORB.destroy is called or in the
+ * finalizer.
+ */
+ private static ArrayList orbs = new ArrayList();
+
+ /**
+ * The address of the local host.
+ */
+ static String localHost;
+
+ static
+ {
+ try
+ {
+ localHost = InetAddress.getLocalHost().getHostAddress();
+ }
+ catch (UnknownHostException ex)
+ {
+ throw new InternalError("Local host is not accessible:" + ex);
+ }
+ }
+
+ /**
+ * Register the new ORB
+ *
+ * @param orb the orb to register
+ */
+ static void registerOrb(OrbFunctional orb)
+ {
+ if (DIRECT_CALLS_ALLOWED)
+ synchronized (orbs)
+ {
+ assert ! orbs.contains(orb);
+ orbs.add(orb);
+ }
+ }
+
+ /**
+ * Unregister the ORB. The ORB will no longer be reacheable locally but may
+ * be reacheable via network as if it would be remote.
+ *
+ * @param orb the orb to unregister
+ */
+ static void unregisterOrb(OrbFunctional orb)
+ {
+ if (DIRECT_CALLS_ALLOWED)
+ synchronized (orbs)
+ {
+ assert orbs.contains(orb);
+ orbs.remove(orb);
+ }
+ }
+
+ /**
+ * Search the possibly local object. If the IOR is not local or none of the
+ * found ORBs of this virtual machine knows about it, null is returned.
+ *
+ * @param ior the IOR to search
+ * @return the found local CORBA object or null in not found.
+ */
+ static org.omg.CORBA.Object searchLocalObject(IOR ior)
+ {
+ if (! DIRECT_CALLS_ALLOWED && ! ior.Internet.host.equals(localHost))
+ return null;
+
+ synchronized (orbs)
+ {
+ OrbFunctional orb;
+ org.omg.CORBA.Object object;
+ for (int i = 0; i < orbs.size(); i++)
+ {
+ orb = (OrbFunctional) orbs.get(i);
+ object = orb.find_connected_object(ior.key, ior.Internet.port);
+ if (object != null)
+ {
+ if (object instanceof SafeForDirectCalls)
+ {
+ return object;
+ }
+ else if (object instanceof gnuServantObject)
+ {
+ return object;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/gnu/CORBA/NamingService/Binding_iterator_impl.java b/gnu/CORBA/NamingService/Binding_iterator_impl.java
index 79d787083..108ca270d 100644
--- a/gnu/CORBA/NamingService/Binding_iterator_impl.java
+++ b/gnu/CORBA/NamingService/Binding_iterator_impl.java
@@ -1,5 +1,5 @@
/* Binding_iterator.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.CORBA.NamingService;
+import gnu.CORBA.SafeForDirectCalls;
+
import org.omg.CosNaming.Binding;
import org.omg.CosNaming.BindingHolder;
import org.omg.CosNaming.BindingListHolder;
@@ -51,7 +53,7 @@ import org.omg.CosNaming._BindingIteratorImplBase;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class Binding_iterator_impl
- extends _BindingIteratorImplBase
+ extends _BindingIteratorImplBase implements SafeForDirectCalls
{
/**
* The value, returned by the {@link #next_one} when there
diff --git a/gnu/CORBA/NamingService/Ext.java b/gnu/CORBA/NamingService/Ext.java
index ee27e68cd..d339cb194 100644
--- a/gnu/CORBA/NamingService/Ext.java
+++ b/gnu/CORBA/NamingService/Ext.java
@@ -1,5 +1,5 @@
/* TransientContextExt.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.CORBA.NamingService;
+import gnu.CORBA.SafeForDirectCalls;
+
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.Object;
import org.omg.CORBA.portable.Delegate;
@@ -61,7 +63,7 @@ import org.omg.CosNaming._NamingContextExtImplBase;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class Ext
- extends _NamingContextExtImplBase
+ extends _NamingContextExtImplBase implements SafeForDirectCalls
{
/**
* The older version of the naming context, where all relevant calls
diff --git a/gnu/CORBA/NamingService/NameParser.java b/gnu/CORBA/NamingService/NameParser.java
index c750b2eb4..aa922b96a 100644
--- a/gnu/CORBA/NamingService/NameParser.java
+++ b/gnu/CORBA/NamingService/NameParser.java
@@ -193,9 +193,6 @@ public class NameParser
boolean corbaname;
- // The alternative addresses, if given.
- ArrayList alt_addr = new ArrayList();
-
// The version numbers with default values.
int major = 1;
int minor = 0;
diff --git a/gnu/CORBA/NamingService/NameTransformer.java b/gnu/CORBA/NamingService/NameTransformer.java
index 0e0782a57..d717b9d40 100644
--- a/gnu/CORBA/NamingService/NameTransformer.java
+++ b/gnu/CORBA/NamingService/NameTransformer.java
@@ -1,5 +1,5 @@
/* NameTransformer.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -75,10 +75,6 @@ public class NameTransformer
ArrayList components = new ArrayList();
StringTokenizer st = new StringTokenizer(a_name, "./\\", true);
- String id;
- String kind;
- String next;
-
// Create the buffer array, reserving the last element for null.
String[] n = new String[ st.countTokens() + 1 ];
diff --git a/gnu/CORBA/NamingService/NamingServiceTransient.java b/gnu/CORBA/NamingService/NamingServiceTransient.java
index 3669879f2..a8cd0b313 100644
--- a/gnu/CORBA/NamingService/NamingServiceTransient.java
+++ b/gnu/CORBA/NamingService/NamingServiceTransient.java
@@ -85,35 +85,26 @@ public class NamingServiceTransient
}
/**
- * Start the naming service on the current host at the given port. The
- * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
- * present, specifies the port, on that the service must be started. If this
- * key is not specified, the service starts at the port 900.
+ * Start the naming service on the current host at the given port.
*
- * The parameter -ior FILE_NAME, if present, forces to store the ior string of
- * this naming service to the specified file.
- *
- * @param args the parameter string.
+ * @param portArgument the port on which the service will be
+ * started, or -1 to use the default port, 900
+ * @param fileArgument if non-null, store the IOR string of this
+ * naming service in a file by this name
*/
- public static void main(String[] args)
+ public static void start(int portArgument, String fileArgument)
{
int port = PORT;
- String iorf = null;
+
+ if (portArgument > -1)
+ port = portArgument;
+
+ String iorf = fileArgument;
try
{
// Create and initialize the ORB
final OrbFunctional orb = new OrbFunctional();
- if (args.length > 1)
- for (int i = 0; i < args.length - 1; i++)
- {
- if (args[i].endsWith("ORBInitialPort"))
- port = Integer.parseInt(args[i + 1]);
-
- if (args[i].equals("-ior"))
- iorf = args[i + 1];
- }
-
OrbFunctional.setPort(port);
// Create the servant and register it with the ORB
@@ -133,15 +124,6 @@ public class NamingServiceTransient
p.close();
}
- System.out.println("GNU Classpath transient naming service "
- + "started at " + iorr.Internet.host + ":" + iorr.Internet.port
- + " key 'NameService'.\n\n"
- + "Copyright (C) 2006 Free Software Foundation\n"
- + "This tool comes with ABSOLUTELY NO WARRANTY. "
- + "This is free software, and you are\nwelcome to "
- + "redistribute it under conditions, defined in "
- + "GNU Classpath license.\n\n" + ior);
-
new Thread()
{
public void run()
@@ -154,7 +136,7 @@ public class NamingServiceTransient
catch (Exception e)
{
System.err.println("ERROR: " + e);
- e.printStackTrace(System.out);
+ e.printStackTrace(System.err);
}
// Restore the default value for allocating ports for the subsequent
diff --git a/gnu/CORBA/NamingService/TransientContext.java b/gnu/CORBA/NamingService/TransientContext.java
index c2d8275e0..cec87931e 100644
--- a/gnu/CORBA/NamingService/TransientContext.java
+++ b/gnu/CORBA/NamingService/TransientContext.java
@@ -54,6 +54,8 @@ import org.omg.CosNaming.NamingContextPackage.NotFound;
import org.omg.CosNaming.NamingContextPackage.NotFoundReason;
import org.omg.CosNaming._NamingContextImplBase;
+import gnu.CORBA.SafeForDirectCalls;
+
import java.util.Iterator;
import java.util.Map;
@@ -69,7 +71,7 @@ import java.util.Map;
*/
public class TransientContext
extends _NamingContextImplBase
- implements NamingContext, NamingContextOperations
+ implements NamingContext, NamingContextOperations, SafeForDirectCalls
{
/**
* Use serial version UID for interoperability.
diff --git a/gnu/CORBA/OrbFunctional.java b/gnu/CORBA/OrbFunctional.java
index 9695fdc82..bfb5e3d86 100644
--- a/gnu/CORBA/OrbFunctional.java
+++ b/gnu/CORBA/OrbFunctional.java
@@ -938,48 +938,55 @@ public class OrbFunctional extends OrbRestricted
/**
* Start the ORBs main working cycle (receive invocation - invoke on the local
- * object - send response - wait for another invocation).
- *
- * The method only returns after calling {@link #shutdown(boolean)}.
+ * object - send response - wait for another invocation). The method only
+ * returns after calling {@link #shutdown(boolean)}.
*/
public void run()
{
- running = true;
-
- // Instantiate the port server for each socket.
- Iterator iter = connected_objects.entrySet().iterator();
- Map.Entry m;
- Connected_objects.cObject obj;
-
- while (iter.hasNext())
+ CollocatedOrbs.registerOrb(this);
+ try
{
- m = (Map.Entry) iter.next();
- obj = (Connected_objects.cObject) m.getValue();
+ running = true;
- portServer subserver;
+ // Instantiate the port server for each socket.
+ Iterator iter = connected_objects.entrySet().iterator();
+ Map.Entry m;
+ Connected_objects.cObject obj;
- if (obj.identity == null)
+ while (iter.hasNext())
{
- subserver = new portServer(obj.port);
- portServers.add(subserver);
- }
- else
- subserver = (portServer) identities.get(obj.identity);
-
- if (!subserver.isAlive())
- {
- // Reuse the current thread for the last portServer.
- if (!iter.hasNext())
+ m = (Map.Entry) iter.next();
+ obj = (Connected_objects.cObject) m.getValue();
+
+ portServer subserver;
+
+ if (obj.identity == null)
{
- // Discard the iterator, eliminating lock checks.
- iter = null;
- subserver.run();
- return;
+ subserver = new portServer(obj.port);
+ portServers.add(subserver);
}
else
- subserver.start();
+ subserver = (portServer) identities.get(obj.identity);
+
+ if (! subserver.isAlive())
+ {
+ // Reuse the current thread for the last portServer.
+ if (! iter.hasNext())
+ {
+ // Discard the iterator, eliminating lock checks.
+ iter = null;
+ subserver.run();
+ return;
+ }
+ else
+ subserver.start();
+ }
}
}
+ finally
+ {
+ CollocatedOrbs.unregisterOrb(this);
+ }
}
/**
@@ -1051,22 +1058,26 @@ public class OrbFunctional extends OrbRestricted
org.omg.CORBA.Object object = find_local_object(ior);
if (object == null)
{
- ObjectImpl impl = StubLocator.search(this, ior);
- try
+ // Check maybe the local object on another ORB, but same VM.
+ object = CollocatedOrbs.searchLocalObject(ior);
+ if (object == null)
{
- if (impl._get_delegate() == null)
- impl._set_delegate(new IorDelegate(this, ior));
- }
- catch (BAD_OPERATION ex)
- {
- // Some colaborants may throw this exception
- // in response to the attempt to get the unset delegate.
- impl._set_delegate(new IorDelegate(this, ior));
- }
+ // Surely remote object.
+ ObjectImpl impl = StubLocator.search(this, ior);
+ try
+ {
+ if (impl._get_delegate() == null)
+ impl._set_delegate(new IorDelegate(this, ior));
+ }
+ catch (BAD_OPERATION ex)
+ {
+ // Some colaborants may throw this exception
+ // in response to the attempt to get the unset delegate.
+ impl._set_delegate(new IorDelegate(this, ior));
+ }
- object = impl;
- // TODO remove commented out code below.
- // connected_objects.add(ior.key, impl, ior.Internet.port, null);
+ object = impl;
+ }
}
return object;
}
@@ -1239,15 +1250,10 @@ public class OrbFunctional extends OrbRestricted
}
if (ior.Id == null)
ior.Id = ref.object.getClass().getName();
- try
- {
- ior.Internet.host = InetAddress.getLocalHost().getHostAddress();
- ior.Internet.port = ref.port;
- }
- catch (UnknownHostException ex)
- {
- throw new BAD_OPERATION("Cannot resolve the local host address");
- }
+
+ ior.Internet.host = CollocatedOrbs.localHost;
+ ior.Internet.port = ref.port;
+
return ior;
}
diff --git a/gnu/CORBA/Poa/LocalRequest.java b/gnu/CORBA/Poa/LocalRequest.java
index a2c0bb106..4a9ef8d90 100644
--- a/gnu/CORBA/Poa/LocalRequest.java
+++ b/gnu/CORBA/Poa/LocalRequest.java
@@ -193,11 +193,14 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
/**
* Make an invocation and return a stream from where the results can be read.
*
- * @param the invoke handler (can be null, then it is obtained self
+ * @param handler the invoke handler (can be null, then it is obtained self
* dependently).
*/
public org.omg.CORBA.portable.InputStream v_invoke(InvokeHandler handler)
{
+ // Check maybe POA is in the discarding mode (will throw TRANSIENT if it is).
+ poa.checkDiscarding();
+
// Local request must be intercepted both by server and request
// interceptors.
boolean s_intercept = false;
@@ -246,7 +249,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
s_interceptor.receive_request_service_contexts(s_info);
}
-
+
if (handler == null)
{
handler = object.getHandler(operation(), cookie, false);
diff --git a/gnu/CORBA/Poa/gnuPOA.java b/gnu/CORBA/Poa/gnuPOA.java
index 6ac4b4cdc..8ceec23d7 100644
--- a/gnu/CORBA/Poa/gnuPOA.java
+++ b/gnu/CORBA/Poa/gnuPOA.java
@@ -1582,7 +1582,7 @@ public class gnuPOA
*
* @throws TRANSIENT if the POA is in discarding mode.
*/
- private void checkDiscarding()
+ void checkDiscarding()
throws TRANSIENT
{
if (m_manager.get_state() == State.DISCARDING)
diff --git a/gnu/CORBA/Poa/gnuServantObject.java b/gnu/CORBA/Poa/gnuServantObject.java
index 020897a45..77b0ff467 100644
--- a/gnu/CORBA/Poa/gnuServantObject.java
+++ b/gnu/CORBA/Poa/gnuServantObject.java
@@ -129,6 +129,12 @@ public class gnuServantObject extends ObjectImpl
* ids are requested from the servant.
*/
public final String[] repository_ids;
+
+ /**
+ * True indicates that the NO_RETAIN policy applies for the servant.
+ * The servant must be discarded after the each call.
+ */
+ boolean noRetain;
/**
* Create an object with no connected servant. The servant must be set later.
@@ -147,6 +153,8 @@ public class gnuServantObject extends ObjectImpl
manager = a_poa.the_POAManager();
poa = a_poa;
orb = an_orb;
+
+ noRetain = poa.applies(ServantRetentionPolicyValue.NON_RETAIN);
}
/**
@@ -182,6 +190,8 @@ public class gnuServantObject extends ObjectImpl
}
repository_ids = null;
orb = an_orb;
+
+ noRetain = poa != null && poa.applies(ServantRetentionPolicyValue.NON_RETAIN);
}
/**
@@ -222,7 +232,7 @@ public class gnuServantObject extends ObjectImpl
boolean forwarding_allowed
) throws gnuForwardRequest
{
- if (servant != null)
+ if (servant != null && !noRetain)
{
return servantToHandler(servant);
}
@@ -641,13 +651,14 @@ public class gnuServantObject extends ObjectImpl
poa.servant_locator.postinvoke(Id, poa, method,
cookie.value, servant
);
- servant = null;
}
}
}
finally
{
orb.currents.remove(Thread.currentThread());
+ if (noRetain)
+ servant = null;
}
}
catch (ForwardRequest fex)
diff --git a/gnu/CORBA/SafeForDirectCalls.java b/gnu/CORBA/SafeForDirectCalls.java
new file mode 100644
index 000000000..f3efb6677
--- /dev/null
+++ b/gnu/CORBA/SafeForDirectCalls.java
@@ -0,0 +1,50 @@
+/* SafeForDirectCalls.java -- FIXME: briefly describe file purpose
+ 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.CORBA;
+
+/**
+ * This interface marks that the object does not modify the passed read only
+ * parameters and hence, if it is local, it is safe to call the methods
+ * directly, without cloning such parameters. Otherwise such parameters should
+ * be cloned.
+ */
+public interface SafeForDirectCalls
+{
+
+}
diff --git a/gnu/CORBA/SimpleDelegate.java b/gnu/CORBA/SimpleDelegate.java
index c6e20e173..cb0a7d603 100644
--- a/gnu/CORBA/SimpleDelegate.java
+++ b/gnu/CORBA/SimpleDelegate.java
@@ -98,22 +98,31 @@ public class SimpleDelegate
}
/**
- * Not implemented.
- *
- * @throws NO_IMPLEMENT, always.
+ * Create the request for the local call
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String operation, NVList parameters,
NamedValue returns
)
{
- throw new NO_IMPLEMENT();
+ if (orb instanceof OrbFunctional)
+ {
+ ((OrbFunctional) orb).ensureRunning();
+ }
+ gnuRequest g = new gnuRequest();
+ g.setORB(orb);
+ g.setOperation(operation);
+ g.setIor(ior);
+ g.m_target = target;
+ g.ctx(context);
+ g.set_args(parameters);
+ if (returns != null)
+ g.set_result(returns);
+ return g;
}
/**
- * Not implemented.
- *
- * @throws NO_IMPLEMENT, always.
+ * Create the request for the local call.
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String operation, NVList parameters,
@@ -121,7 +130,22 @@ public class SimpleDelegate
ContextList ctx_list
)
{
- throw new NO_IMPLEMENT();
+ if (orb instanceof OrbFunctional)
+ {
+ ((OrbFunctional) orb).ensureRunning();
+ }
+ gnuRequest g = new gnuRequest();
+ g.setORB(orb);
+ g.setOperation(operation);
+ g.setIor(ior);
+ g.m_target = target;
+ g.ctx(context);
+ g.set_args(parameters);
+ g.set_exceptions(exceptions);
+ g.set_context_list(ctx_list);
+ if (returns != null)
+ g.set_result(returns);
+ return g;
}
/**
diff --git a/gnu/classpath/ListenerData.java b/gnu/classpath/ListenerData.java
new file mode 100644
index 000000000..284fa02f1
--- /dev/null
+++ b/gnu/classpath/ListenerData.java
@@ -0,0 +1,136 @@
+/* ListenerData.java - Class to contain data about management bean listeners
+ 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.classpath;
+
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+
+/**
+ * Container for data on management listeners. Wraps
+ * a {@link javax.management.NotificationListener},
+ * {@link javax.management.NotificationFilter} and
+ * passback object in one class.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ListenerData
+{
+ /**
+ * The listener itself.
+ */
+ private NotificationListener listener;
+
+ /**
+ * A filter to apply to incoming events.
+ */
+ private NotificationFilter filter;
+
+ /**
+ * An object to pass back to the listener on an
+ * event occurring.
+ */
+ private Object passback;
+
+ /**
+ * Constructs a new {@link ListenerData} with the specified
+ * listener, filter and passback object.
+ *
+ * @param listener the listener itself.
+ * @param filter the filter for incoming events.
+ * @param passback the object to passback on an incoming event.
+ */
+ public ListenerData(NotificationListener listener,
+ NotificationFilter filter, Object passback)
+ {
+ this.listener = listener;
+ this.filter = filter;
+ this.passback = passback;
+ }
+
+ /**
+ * Returns the listener.
+ *
+ * @return the listener.
+ */
+ public NotificationListener getListener()
+ {
+ return listener;
+ }
+
+ /**
+ * Returns the filter.
+ *
+ * @return the filter.
+ */
+ public NotificationFilter getFilter()
+ {
+ return filter;
+ }
+
+ /**
+ * Returns the passback object.
+ *
+ * @return the passback object.
+ */
+ public Object getPassback()
+ {
+ return passback;
+ }
+
+ /**
+ * Returns true if the supplied object is an instance of
+ * {@link ListenerData} and has the same listener, filter
+ * and passback object.
+ *
+ * @param obj the object to check.
+ * @return true if <code>obj</code> is equal to this.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ListenerData)
+ {
+ ListenerData data = (ListenerData) obj;
+ return (data.getListener() == listener &&
+ data.getFilter() == filter &&
+ data.getPassback() == passback);
+ }
+ return false;
+ }
+
+}
diff --git a/tools/gnu/classpath/tools/rmi/registry/package.html b/gnu/java/awt/LowPriorityEvent.java
index 71df83b61..c1558f6ff 100644
--- a/tools/gnu/classpath/tools/rmi/registry/package.html
+++ b/gnu/java/awt/LowPriorityEvent.java
@@ -1,6 +1,5 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- package.html - describes classes in gnu.java.rmi.registry package.
- Copyright (C) 2005 Free Software Foundation, Inc.
+/* LowPriorityEvent.java -- Marks events with low priority
+ Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -34,13 +33,16 @@ 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. -->
+exception statement from your version. */
-<html>
-<head><title>GNU Classpath - gnu.classpath.tools.rmi.registry</title></head>
-<body>
-<p></p>
+package gnu.java.awt;
-</body>
-</html>
+/**
+ * A marker interface that marks events with low priority. LowPriority events
+ * are dispatched _after_ other (normal priority) events by the EventQueue.
+ */
+public interface LowPriorityEvent
+{
+ // Empty marker interface.
+}
diff --git a/gnu/java/awt/java2d/AbstractGraphics2D.java b/gnu/java/awt/java2d/AbstractGraphics2D.java
index 326863163..da2125398 100644
--- a/gnu/java/awt/java2d/AbstractGraphics2D.java
+++ b/gnu/java/awt/java2d/AbstractGraphics2D.java
@@ -100,6 +100,20 @@ import java.util.Map;
* {@link #updateRaster(Raster, int, int, int, int)} method, which always gets
* called after a chunk of data got painted into the raster.
* </p>
+ * <p>Alternativly the backend can provide a method for filling Shapes by
+ * overriding the protected method fillShape(). This can be accomplished
+ * by a polygon filling function of the backend. Keep in mind though that
+ * Shapes can be quite complex (i.e. non-convex and containing holes, etc)
+ * which is not supported by all polygon fillers. Also it must be noted
+ * that fillShape() is expected to handle painting and compositing as well as
+ * clipping and transformation. If your backend can't support this natively,
+ * then you can fallback to the implementation in this class. You'll need
+ * to provide a writable Raster then, see above.</p>
+ * <p>Another alternative is to implement fillScanline() which only requires
+ * the backend to be able to draw horizontal lines in device space,
+ * which is usually very cheap.
+ * The implementation should still handle painting and compositing,
+ * but no more clipping and transformation is required by the backend.</p>
* <p>The backend is free to provide implementations for the various raw*
* methods for optimized AWT 1.1 style painting of some primitives. This should
* accelerate painting of Swing greatly. When doing so, the backend must also
@@ -126,6 +140,9 @@ import java.util.Map;
* in plain Java because they involve lots of shuffling around with large
* arrays. In fact, you really would want to let the graphics card to the
* work, they are made for this.</li>
+ * <li>Provide an accelerated implementation for fillShape(). For instance,
+ * OpenGL can fill shapes very efficiently. There are some considerations
+ * to be made though, see above for details.</li>
* </ol>
* </p>
*
@@ -144,6 +161,12 @@ public abstract class AbstractGraphics2D
private static final int AA_SAMPLING = 8;
/**
+ * Caches certain shapes to avoid massive creation of such Shapes in
+ * the various draw* and fill* methods.
+ */
+ private static final ThreadLocal shapeCache = new ThreadLocal();
+
+ /**
* The transformation for this Graphics2D instance
*/
protected AffineTransform transform;
@@ -184,11 +207,6 @@ public abstract class AbstractGraphics2D
private RenderingHints renderingHints;
/**
- * The paint raster.
- */
- private Raster paintRaster;
-
- /**
* The raster of the destination surface. This is where the painting is
* performed.
*/
@@ -219,7 +237,7 @@ public abstract class AbstractGraphics2D
* AbstractGraphics2D object and will be the most commonly used setting
* in Swing rendering and should therefore be optimized as much as possible.
*/
- private boolean isOptimized;
+ private boolean isOptimized = true;
/**
* Creates a new AbstractGraphics2D instance.
@@ -270,7 +288,6 @@ public abstract class AbstractGraphics2D
public boolean drawImage(Image image, AffineTransform xform,
ImageObserver obs)
{
- boolean ret = false;
Rectangle areaOfInterest = new Rectangle(0, 0, image.getWidth(obs),
image.getHeight(obs));
return drawImageImpl(image, xform, obs, areaOfInterest);
@@ -1144,14 +1161,31 @@ public abstract class AbstractGraphics2D
{
if (isOptimized)
{
- int tx = (int) transform.getTranslateX();
- int ty = (int) transform.getTranslateY();
- rawDrawLine(x1 + tx, y1 + ty, x2 + tx, y2 + ty);
+ rawDrawLine(x1, y1, x2, y2);
}
else
{
- Line2D line = new Line2D.Double(x1, y1, x2, y2);
- draw(line);
+ ShapeCache sc = getShapeCache();
+ if (sc.line == null)
+ sc.line = new Line2D.Float();
+ sc.line.setLine(x1, y1, x2, y2);
+ draw(sc.line);
+ }
+ }
+
+ public void drawRect(int x, int y, int w, int h)
+ {
+ if (isOptimized)
+ {
+ rawDrawRect(x, y, w, h);
+ }
+ else
+ {
+ ShapeCache sc = getShapeCache();
+ if (sc.rect == null)
+ sc.rect = new Rectangle();
+ sc.rect.setBounds(x, y, w, h);
+ draw(sc.rect);
}
}
@@ -1167,13 +1201,15 @@ public abstract class AbstractGraphics2D
{
if (isOptimized)
{
- int tx = (int) transform.getTranslateX();
- int ty = (int) transform.getTranslateY();
- rawFillRect(x + tx, y + ty, width, height);
+ rawFillRect(x, y, width, height);
}
else
{
- fill(new Rectangle(x, y, width, height));
+ ShapeCache sc = getShapeCache();
+ if (sc.rect == null)
+ sc.rect = new Rectangle();
+ sc.rect.setBounds(x, y, width, height);
+ fill(sc.rect);
}
}
@@ -1214,8 +1250,11 @@ public abstract class AbstractGraphics2D
public void drawRoundRect(int x, int y, int width, int height, int arcWidth,
int arcHeight)
{
- draw(new RoundRectangle2D.Double(x, y, width, height, arcWidth,
- arcHeight));
+ ShapeCache sc = getShapeCache();
+ if (sc.roundRect == null)
+ sc.roundRect = new RoundRectangle2D.Float();
+ sc.roundRect.setRoundRect(x, y, width, height, arcWidth, arcHeight);
+ draw(sc.roundRect);
}
/**
@@ -1231,8 +1270,11 @@ public abstract class AbstractGraphics2D
public void fillRoundRect(int x, int y, int width, int height, int arcWidth,
int arcHeight)
{
- fill(new RoundRectangle2D.Double(x, y, width, height, arcWidth,
- arcHeight));
+ ShapeCache sc = getShapeCache();
+ if (sc.roundRect == null)
+ sc.roundRect = new RoundRectangle2D.Float();
+ sc.roundRect.setRoundRect(x, y, width, height, arcWidth, arcHeight);
+ fill(sc.roundRect);
}
/**
@@ -1245,7 +1287,11 @@ public abstract class AbstractGraphics2D
*/
public void drawOval(int x, int y, int width, int height)
{
- draw(new Ellipse2D.Double(x, y, width, height));
+ ShapeCache sc = getShapeCache();
+ if (sc.ellipse == null)
+ sc.ellipse = new Ellipse2D.Float();
+ sc.ellipse.setFrame(x, y, width, height);
+ draw(sc.ellipse);
}
/**
@@ -1258,7 +1304,11 @@ public abstract class AbstractGraphics2D
*/
public void fillOval(int x, int y, int width, int height)
{
- fill(new Ellipse2D.Double(x, y, width, height));
+ ShapeCache sc = getShapeCache();
+ if (sc.ellipse == null)
+ sc.ellipse = new Ellipse2D.Float();
+ sc.ellipse.setFrame(x, y, width, height);
+ fill(sc.ellipse);
}
/**
@@ -1267,8 +1317,11 @@ public abstract class AbstractGraphics2D
public void drawArc(int x, int y, int width, int height, int arcStart,
int arcAngle)
{
- draw(new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
- Arc2D.OPEN));
+ ShapeCache sc = getShapeCache();
+ if (sc.arc == null)
+ sc.arc = new Arc2D.Float();
+ sc.arc.setArc(x, y, width, height, arcStart, arcAngle, Arc2D.OPEN);
+ draw(sc.arc);
}
/**
@@ -1277,8 +1330,11 @@ public abstract class AbstractGraphics2D
public void fillArc(int x, int y, int width, int height, int arcStart,
int arcAngle)
{
- fill(new Arc2D.Double(x, y, width, height, arcStart, arcAngle,
- Arc2D.OPEN));
+ ShapeCache sc = getShapeCache();
+ if (sc.arc == null)
+ sc.arc = new Arc2D.Float();
+ sc.arc.setArc(x, y, width, height, arcStart, arcAngle, Arc2D.PIE);
+ draw(sc.arc);
}
public void drawPolyline(int[] xPoints, int[] yPoints, int npoints)
@@ -1292,7 +1348,13 @@ public abstract class AbstractGraphics2D
*/
public void drawPolygon(int[] xPoints, int[] yPoints, int npoints)
{
- draw(new Polygon(xPoints, yPoints, npoints));
+ ShapeCache sc = getShapeCache();
+ if (sc.polygon == null)
+ sc.polygon = new Polygon();
+ sc.polygon.xpoints = xPoints;
+ sc.polygon.ypoints = yPoints;
+ sc.polygon.npoints = npoints;
+ draw(sc.polygon);
}
/**
@@ -1300,7 +1362,13 @@ public abstract class AbstractGraphics2D
*/
public void fillPolygon(int[] xPoints, int[] yPoints, int npoints)
{
- fill(new Polygon(xPoints, yPoints, npoints));
+ ShapeCache sc = getShapeCache();
+ if (sc.polygon == null)
+ sc.polygon = new Polygon();
+ sc.polygon.xpoints = xPoints;
+ sc.polygon.ypoints = yPoints;
+ sc.polygon.npoints = npoints;
+ fill(sc.polygon);
}
/**
@@ -1461,8 +1529,12 @@ public abstract class AbstractGraphics2D
}
/**
- * Fills the specified shape. The shape has already been clipped against the
- * current clip.
+ * Fills the specified shape. Override this if your backend can efficiently
+ * fill shapes. This is possible on many systems via a polygon fill
+ * method or something similar. But keep in mind that Shapes can be quite
+ * complex (non-convex, with holes etc), which is not necessarily supported
+ * by all polygon fillers. Also note that you must perform clipping
+ * before filling the shape.
*
* @param s the shape to fill
* @param isFont <code>true</code> if the shape is a font outline
@@ -1534,6 +1606,11 @@ public abstract class AbstractGraphics2D
draw(new Line2D.Float(x0, y0, x1, y1));
}
+ protected void rawDrawRect(int x, int y, int w, int h)
+ {
+ draw(new Rectangle(x, y, w, h));
+ }
+
/**
* Draws a string in optimization mode. The implementation should respect the
* clip and translation. It can assume that the clip is a rectangle and that
@@ -1628,11 +1705,7 @@ public abstract class AbstractGraphics2D
}
/**
- * Fills the specified polygon. This should be overridden by backends
- * that support accelerated (native) polygon filling, which is the
- * case for most toolkit window and offscreen image implementations.
- *
- * The polygon is already clipped when this method is called.
+ * Fills the specified polygon without anti-aliasing.
*/
private void fillShapeImpl(ArrayList segs, Rectangle2D deviceBounds2D,
Rectangle2D userBounds,
@@ -1663,7 +1736,7 @@ public abstract class AbstractGraphics2D
for (Iterator i = segs.iterator(); i.hasNext();)
{
PolyEdge edge = (PolyEdge) i.next();
- int yindex = (int) ((int) Math.ceil(edge.y0) - (int) Math.ceil(icMinY));
+ int yindex = (int) Math.ceil(edge.y0) - (int) Math.ceil(icMinY);
if (edgeTable[yindex] == null) // Create bucket when needed.
edgeTable[yindex] = new ArrayList();
edgeTable[yindex].add(edge); // Add edge to the bucket of its line.
@@ -1767,7 +1840,8 @@ public abstract class AbstractGraphics2D
}
/**
- * Paints a scanline between x0 and x1.
+ * Paints a scanline between x0 and x1. Override this when your backend
+ * can efficiently draw/fill horizontal lines.
*
* @param x0 the left offset
* @param x1 the right offset
@@ -1973,8 +2047,7 @@ public abstract class AbstractGraphics2D
// Render full scanline.
//System.err.println("scanline: " + y);
if (! emptyScanline)
- fillScanlineAA(alpha, leftX, (int) y, rightX - leftX, pCtx,
- (int) minX);
+ fillScanlineAA(alpha, leftX, y, rightX - leftX, pCtx, (int) minX);
}
pCtx.dispose();
@@ -1987,7 +2060,7 @@ public abstract class AbstractGraphics2D
*
* @param alpha the alpha values in the scanline
* @param x0 the beginning of the scanline
- * @param y the y coordinate of the line
+ * @param yy the y coordinate of the line
*/
private void fillScanlineAA(int[] alpha, int x0, int yy, int numPixels,
PaintContext pCtx, int offs)
@@ -1998,7 +2071,6 @@ public abstract class AbstractGraphics2D
Raster paintRaster = pCtx.getRaster(x0, yy, numPixels, 1);
//System.err.println("paintColorModel: " + pCtx.getColorModel());
WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster();
- int numBands = paintRaster.getNumBands();
ColorModel cm = pCtx.getColorModel();
double lastAlpha = 0.;
int lastAlphaInt = 0;
@@ -2157,10 +2229,10 @@ public abstract class AbstractGraphics2D
private static 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 x2 = rect.x;
+ int y2 = rect.y;
+ int w2 = rect.width;
+ int h2 = rect.height;
int dx = (x > x2) ? x : x2;
int dy = (y > y2) ? y : y2;
@@ -2267,4 +2339,20 @@ public abstract class AbstractGraphics2D
deviceBounds.setRect(minX, minY, maxX - minX, maxY - minY);
return segs;
}
+
+ /**
+ * Returns the ShapeCache for the calling thread.
+ *
+ * @return the ShapeCache for the calling thread
+ */
+ private ShapeCache getShapeCache()
+ {
+ ShapeCache sc = (ShapeCache) shapeCache.get();
+ if (sc == null)
+ {
+ sc = new ShapeCache();
+ shapeCache.set(sc);
+ }
+ return sc;
+ }
}
diff --git a/gnu/java/awt/java2d/ShapeCache.java b/gnu/java/awt/java2d/ShapeCache.java
new file mode 100644
index 000000000..034b53cad
--- /dev/null
+++ b/gnu/java/awt/java2d/ShapeCache.java
@@ -0,0 +1,85 @@
+/* ShapeCache.java -- Caches certain Shapes for reuse in AbstractGraphics2D
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.java2d;
+
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.RoundRectangle2D;
+
+/**
+ * Caches certain Shape objects for reuse in AbstractGraphics2D. This avoids
+ * massive creation of such objects.
+ */
+public class ShapeCache
+{
+
+ /**
+ * A cached Line2D.
+ */
+ public Line2D line;
+
+ /**
+ * A cached Rectangle.
+ */
+ public Rectangle rect;
+
+ /**
+ * A cached RoundRectangle2D.
+ */
+ public RoundRectangle2D roundRect;
+
+ /**
+ * A cached Ellipse2D.
+ */
+ public Ellipse2D ellipse;
+
+ /**
+ * A cached Arc2D.
+ */
+ public Arc2D arc;
+
+ /**
+ * A cached Polygon.
+ */
+ public Polygon polygon;
+
+}
diff --git a/gnu/java/awt/java2d/TexturePaintContext.java b/gnu/java/awt/java2d/TexturePaintContext.java
index 1a782ce07..840b61456 100644
--- a/gnu/java/awt/java2d/TexturePaintContext.java
+++ b/gnu/java/awt/java2d/TexturePaintContext.java
@@ -104,7 +104,7 @@ public class TexturePaintContext
double scaleY = anchor.getHeight() / image.getHeight();
transform = (AffineTransform) xform.clone();
transform.scale(scaleX, scaleY);
- transform.translate(-anchor.getMinX(), -anchor.getMaxX());
+ transform.translate(-anchor.getMinX(), -anchor.getMinY());
transform = transform.createInverse();
}
catch (NoninvertibleTransformException ex)
diff --git a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
index 5412cbea9..e188d3fd0 100644
--- a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+++ b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
@@ -158,6 +158,7 @@ public class BufferedImageGraphics extends CairoGraphics2D
BufferedImageGraphics(BufferedImageGraphics copyFrom)
{
+ image = copyFrom.image;
surface = copyFrom.surface;
cairo_t = surface.newCairoContext();
imageWidth = copyFrom.imageWidth;
@@ -182,6 +183,9 @@ public class BufferedImageGraphics extends CairoGraphics2D
width = imageWidth - x;
if( y + height > imageHeight )
height = imageHeight - y;
+
+ boolean wasPremultiplied = image.isAlphaPremultiplied();
+ image.coerceData(true);
if( !hasFastCM )
image.setRGB(x, y, width, height, pixels,
@@ -190,6 +194,8 @@ public class BufferedImageGraphics extends CairoGraphics2D
System.arraycopy(pixels, y * imageWidth,
((DataBufferInt)image.getRaster().getDataBuffer()).
getData(), y * imageWidth, height * imageWidth);
+
+ image.coerceData(wasPremultiplied);
}
/**
diff --git a/gnu/java/awt/peer/gtk/CairoGraphics2D.java b/gnu/java/awt/peer/gtk/CairoGraphics2D.java
index 8fe04fe77..fd69c9b48 100644
--- a/gnu/java/awt/peer/gtk/CairoGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/CairoGraphics2D.java
@@ -45,6 +45,7 @@ import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
+import java.awt.CompositeContext;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GradientPaint;
@@ -53,6 +54,8 @@ import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Paint;
+import java.awt.PaintContext;
+import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
@@ -161,6 +164,7 @@ public abstract class CairoGraphics2D extends Graphics2D
* The current compositing context, if any.
*/
Composite comp;
+ CompositeContext compCtx;
/**
* Rendering hint map.
@@ -190,6 +194,18 @@ public abstract class CairoGraphics2D extends Graphics2D
0xFF000000);
/**
+ * Native constants for interpolation methods.
+ * Note, this corresponds to an enum in native/jni/gtk-peer/cairographics2d.h
+ */
+ public static final int INTERPOLATION_NEAREST = 0,
+ INTERPOLATION_BILINEAR = 1,
+ INTERPOLATION_BICUBIC = 5,
+ ALPHA_INTERPOLATION_SPEED = 2,
+ ALPHA_INTERPOLATION_QUALITY = 3,
+ ALPHA_INTERPOLATION_DEFAULT = 4;
+ // TODO: Does ALPHA_INTERPOLATION really correspond to CAIRO_FILTER_FAST/BEST/GOOD?
+
+ /**
* Constructor does nothing.
*/
public CairoGraphics2D()
@@ -220,6 +236,7 @@ public abstract class CairoGraphics2D extends Graphics2D
nativePointer = init(cairo_t_pointer);
paint = g.paint;
stroke = g.stroke;
+ comp = g.comp;
setRenderingHints(g.hints);
Color foreground;
@@ -254,6 +271,7 @@ public abstract class CairoGraphics2D extends Graphics2D
setStroke(stroke);
setTransformImpl(transform);
setClip(clip);
+ setComposite(comp);
}
/**
@@ -274,6 +292,8 @@ public abstract class CairoGraphics2D extends Graphics2D
{
disposeNative(nativePointer);
nativePointer = 0;
+ if (compCtx != null)
+ compCtx.dispose();
}
/**
@@ -309,15 +329,16 @@ public abstract class CairoGraphics2D extends Graphics2D
* @param i2u - affine transform array
*/
private native void drawPixels(long pointer, int[] pixels, int w, int h,
- int stride, double[] i2u, double alpha);
+ int stride, double[] i2u, double alpha,
+ int interpolation);
private native void setGradient(long pointer, double x1, double y1,
double x2, double y2,
int r1, int g1, int b1, int a1, int r2,
int g2, int b2, int a2, boolean cyclic);
- private native void setTexturePixels(long pointer, int[] pixels, int w,
- int h, int stride);
+ private native void setPaintPixels(long pointer, int[] pixels, int w,
+ int h, int stride, boolean repeat);
/**
* Set the current transform matrix
@@ -441,11 +462,6 @@ public abstract class CairoGraphics2D extends Graphics2D
private native void cairoResetClip(long pointer);
/**
- * Set interpolation types
- */
- private native void cairoSurfaceSetFilter(long pointer, int filter);
-
- /**
* Draws a line from (x1,y1) to (x2,y2).
*
* @param pointer the native pointer
@@ -666,7 +682,7 @@ public abstract class CairoGraphics2D extends Graphics2D
public void setPaint(Paint p)
{
- if (paint == null)
+ if (p == null)
return;
paint = p;
@@ -690,7 +706,7 @@ public abstract class CairoGraphics2D extends Graphics2D
AffineTransformOp op = new AffineTransformOp(at, getRenderingHints());
BufferedImage texture = op.filter(img, null);
int[] pixels = texture.getRGB(0, 0, width, height, null, 0, width);
- setTexturePixels(nativePointer, pixels, width, height, width);
+ setPaintPixels(nativePointer, pixels, width, height, width, true);
}
else if (paint instanceof GradientPaint)
{
@@ -705,7 +721,52 @@ public abstract class CairoGraphics2D extends Graphics2D
gp.isCyclic());
}
else
- throw new java.lang.UnsupportedOperationException();
+ {
+ // Get bounds in device space
+ int minX = 0;
+ int minY = 0;
+ int width = (int)getRealBounds().getWidth();
+ int height = (int)getRealBounds().getHeight();
+
+ Point2D origin = transform.transform(new Point2D.Double(minX, minY),
+ null);
+ Point2D extreme = transform.transform(new Point2D.Double(width + minX,
+ height + minY),
+ null);
+ minX = (int)origin.getX();
+ minY = (int)origin.getY();
+ width = (int)extreme.getX() - minX;
+ height = (int)extreme.getY() - minY;
+
+ // Get raster of the paint background
+ PaintContext pc = paint.createContext(ColorModel.getRGBdefault(),
+ new Rectangle(minX, minY,
+ width, height),
+ getRealBounds(),
+ transform, hints);
+
+ Raster raster = pc.getRaster(minX, minY, width, height);
+
+ // Work around colorspace issues, and force use of the
+ // BufferedImage.getRGB method... this can be improved upon.
+ WritableRaster wr = Raster.createWritableRaster(raster.getSampleModel(),
+ new Point(raster.getMinX(),
+ raster.getMinY()));
+ wr.setRect(raster);
+
+ BufferedImage img2 = new BufferedImage(pc.getColorModel(), wr,
+ pc.getColorModel().isAlphaPremultiplied(),
+ null);
+
+ // Set pixels in cairo
+ setPaintPixels(nativePointer,
+ img2.getRGB(0, 0, width, height, null, 0, width),
+ width, height, width, false);
+ // setPaintPixels(nativePointer,
+ // raster.getPixels(0, 0, width, height, (int[])null),
+ // width, height, width, false);
+ // doesn't work... but would be much more efficient!
+ }
}
public Stroke getStroke()
@@ -896,13 +957,23 @@ public abstract class CairoGraphics2D extends Graphics2D
*/
public void setComposite(Composite comp)
{
+ if (this.comp == comp)
+ return;
+
this.comp = comp;
+ if (compCtx != null)
+ compCtx.dispose();
+ compCtx = null;
+ if (comp == null)
+ comp = AlphaComposite.SrcOver;
+
if (comp instanceof AlphaComposite)
{
AlphaComposite a = (AlphaComposite) comp;
cairoSetOperator(nativePointer, a.getRule());
}
+
else
{
// FIXME: this check is only required "if this Graphics2D
@@ -912,9 +983,26 @@ public abstract class CairoGraphics2D extends Graphics2D
sm.checkPermission(new AWTPermission("readDisplayPixels"));
// FIXME: implement general Composite support
- throw new java.lang.UnsupportedOperationException();
+ //throw new java.lang.UnsupportedOperationException();
+ // this is in progress! yay!
+ compCtx = comp.createContext(getNativeCM(), getNativeCM(), hints);
}
}
+
+ /**
+ * Returns the Colour Model describing the native, raw image data for this
+ * specific peer.
+ *
+ * @return ColorModel the ColorModel of native data in this peer
+ */
+ /* protected abstract ColorModel getNativeCM(); */
+ protected ColorModel getNativeCM()
+ {
+ // This stub should be removed and the method made abstract once I'm done
+ // implementing custom composites across all the peers... but we need it
+ // for now, so that the build doesn't break.
+ return null;
+ }
///////////////////////// DRAWING PRIMITIVES ///////////////////////////////////
@@ -1006,8 +1094,14 @@ public abstract class CairoGraphics2D extends Graphics2D
{
if (bg != null)
cairoSetRGBAColor(nativePointer, bg.getRed() / 255.0,
- bg.getGreen() / 255.0, bg.getBlue() / 255.0, 1.0);
+ bg.getGreen() / 255.0, bg.getBlue() / 255.0,
+ bg.getAlpha() / 255.0);
+
+ Composite oldcomp = comp;
+ setComposite(AlphaComposite.Src);
fillRect(x, y, width, height);
+
+ setComposite(oldcomp);
updateColor();
}
@@ -1054,7 +1148,10 @@ public abstract class CairoGraphics2D extends Graphics2D
public void fillRect(int x, int y, int width, int height)
{
- cairoFillRect(nativePointer, x, y, width, height);
+ fill(new Rectangle(x, y, width, height));
+ // TODO: If we want to use the more efficient
+ //cairoFillRect(nativePointer, x, y, width, height);
+ // we need to override this method in subclasses
}
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
@@ -1150,32 +1247,10 @@ public abstract class CairoGraphics2D extends Graphics2D
///////////////////////// RENDERING HINTS ///////////////////////////////////
- /**
- * FIXME- support better
- */
public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
{
hints.put(hintKey, hintValue);
- if (hintKey.equals(RenderingHints.KEY_INTERPOLATION)
- || hintKey.equals(RenderingHints.KEY_ALPHA_INTERPOLATION))
- {
- if (hintValue.equals(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR))
- cairoSurfaceSetFilter(nativePointer, 0);
-
- else if (hintValue.equals(RenderingHints.VALUE_INTERPOLATION_BILINEAR))
- cairoSurfaceSetFilter(nativePointer, 1);
-
- else if (hintValue.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED))
- cairoSurfaceSetFilter(nativePointer, 2);
-
- else if (hintValue.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY))
- cairoSurfaceSetFilter(nativePointer, 3);
-
- else if (hintValue.equals(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT))
- cairoSurfaceSetFilter(nativePointer, 4);
- }
-
shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
|| hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
}
@@ -1189,30 +1264,15 @@ public abstract class CairoGraphics2D extends Graphics2D
{
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))
- cairoSurfaceSetFilter(nativePointer, 0);
-
- else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR))
- cairoSurfaceSetFilter(nativePointer, 1);
- }
-
- if (hints.containsKey(RenderingHints.KEY_ALPHA_INTERPOLATION))
- {
- if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED))
- cairoSurfaceSetFilter(nativePointer, 2);
-
- else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY))
- cairoSurfaceSetFilter(nativePointer, 3);
-
- else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT))
- cairoSurfaceSetFilter(nativePointer, 4);
- }
-
+
shiftDrawCalls = hints.containsValue(RenderingHints.VALUE_STROKE_NORMALIZE)
|| hints.containsValue(RenderingHints.VALUE_STROKE_DEFAULT);
+
+ if (compCtx != null)
+ {
+ compCtx.dispose();
+ compCtx = comp.createContext(getNativeCM(), getNativeCM(), this.hints);
+ }
}
public void addRenderingHints(Map hints)
@@ -1224,6 +1284,30 @@ public abstract class CairoGraphics2D extends Graphics2D
{
return hints;
}
+
+ private int getInterpolation()
+ {
+ if (this.hints.containsValue(RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR))
+ return INTERPOLATION_NEAREST;
+
+ else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BILINEAR))
+ return INTERPOLATION_BILINEAR;
+
+ else if (hints.containsValue(RenderingHints.VALUE_INTERPOLATION_BICUBIC))
+ return INTERPOLATION_BICUBIC;
+
+ else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED))
+ return ALPHA_INTERPOLATION_SPEED;
+
+ else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY))
+ return ALPHA_INTERPOLATION_QUALITY;
+
+ else if (hints.containsValue(RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT))
+ return ALPHA_INTERPOLATION_DEFAULT;
+
+ // Do bilinear interpolation as default
+ return INTERPOLATION_BILINEAR;
+ }
///////////////////////// IMAGE. METHODS ///////////////////////////////////
@@ -1273,6 +1357,9 @@ public abstract class CairoGraphics2D extends Graphics2D
double[] i2u = new double[6];
int width = b.getWidth();
int height = b.getHeight();
+
+ boolean wasPremultplied = b.isAlphaPremultiplied();
+ b.coerceData(true);
// If this BufferedImage has a BufferedImageGraphics object,
// use the cached CairoSurface that BIG is drawing onto
@@ -1290,8 +1377,10 @@ public abstract class CairoGraphics2D extends Graphics2D
if(raster instanceof CairoSurface)
{
- ((CairoSurface)raster).drawSurface(nativePointer, i2u, alpha);
+ ((CairoSurface)raster).drawSurface(nativePointer, i2u, alpha,
+ getInterpolation());
updateColor();
+ b.coerceData(wasPremultplied);
return true;
}
@@ -1310,10 +1399,12 @@ public abstract class CairoGraphics2D extends Graphics2D
int[] pixels = b.getRGB(0, 0, width, height, null, 0, width);
- drawPixels(nativePointer, pixels, width, height, width, i2u, alpha);
+ drawPixels(nativePointer, pixels, width, height, width, i2u, alpha,
+ getInterpolation());
// Cairo seems to lose the current color which must be restored.
updateColor();
+ b.coerceData(wasPremultplied);
return true;
}
@@ -1626,7 +1717,7 @@ public abstract class CairoGraphics2D extends Graphics2D
if (comp instanceof AlphaComposite)
alpha = ((AlphaComposite) comp).getAlpha();
drawPixels(nativePointer, pixels, r.getWidth(), r.getHeight(),
- r.getWidth(), i2u, alpha);
+ r.getWidth(), i2u, alpha, getInterpolation());
// Cairo seems to lose the current color which must be restored.
updateColor();
diff --git a/gnu/java/awt/peer/gtk/CairoSurface.java b/gnu/java/awt/peer/gtk/CairoSurface.java
index 3bf9a9ccf..91b10369d 100644
--- a/gnu/java/awt/peer/gtk/CairoSurface.java
+++ b/gnu/java/awt/peer/gtk/CairoSurface.java
@@ -38,15 +38,18 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
-import java.awt.Point;
+import gnu.java.awt.Buffers;
+
import java.awt.Graphics2D;
-import java.awt.image.DataBuffer;
-import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
+import java.awt.Point;
+import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
import java.awt.image.DirectColorModel;
+import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
+import java.awt.image.WritableRaster;
import java.nio.ByteOrder;
import java.util.Hashtable;
@@ -69,11 +72,15 @@ public class CairoSurface extends WritableRaster
*/
long bufferPointer;
- static ColorModel nativeModel = new DirectColorModel(32,
- 0x00FF0000,
- 0x0000FF00,
- 0x000000FF,
- 0xFF000000);
+ // nativeGetPixels will return [0]=red, [1]=green, [2]=blue, [3]=alpha
+ static ColorModel nativeColorModel = new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ 32,
+ 0x000000FF,
+ 0x0000FF00,
+ 0x00FF0000,
+ 0xFF000000,
+ true,
+ Buffers.smallestAppropriateTransferType(32));
/**
* Allocates and clears the buffer and creates the cairo surface.
@@ -102,11 +109,13 @@ public class CairoSurface extends WritableRaster
* with an affine transform given by i2u.
*/
public native void nativeDrawSurface(long surfacePointer, long contextPointer,
- double[] i2u, double alpha);
+ double[] i2u, double alpha,
+ int interpolation);
- public void drawSurface(long contextPointer, double[] i2u, double alpha)
+ public void drawSurface(long contextPointer, double[] i2u, double alpha,
+ int interpolation)
{
- nativeDrawSurface(surfacePointer, contextPointer, i2u, alpha);
+ nativeDrawSurface(surfacePointer, contextPointer, i2u, alpha, interpolation);
}
/**
@@ -138,10 +147,8 @@ public class CairoSurface extends WritableRaster
*/
public CairoSurface(int width, int height)
{
- super( new SinglePixelPackedSampleModel
- (DataBuffer.TYPE_INT, width, height,
- new int[]{ 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }),
- null, new Point(0, 0) );
+ super(createNativeSampleModel(width, height),
+ null, new Point(0, 0));
if(width <= 0 || height <= 0)
throw new IllegalArgumentException("Image must be at least 1x1 pixels.");
@@ -253,7 +260,7 @@ public class CairoSurface extends WritableRaster
*/
public static BufferedImage getBufferedImage(CairoSurface surface)
{
- return new BufferedImage(nativeModel, surface, true, new Hashtable());
+ return new BufferedImage(nativeColorModel, surface, true, new Hashtable());
}
private class CairoDataBuffer extends DataBuffer
@@ -315,4 +322,14 @@ public class CairoSurface extends WritableRaster
{
copyAreaNative2(bufferPointer, x, y, width, height, dx, dy, stride);
}
+
+ /**
+ * Creates a SampleModel that matches Cairo's native format
+ */
+ protected static SampleModel createNativeSampleModel(int w, int h)
+ {
+ return new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, w, h,
+ new int[]{0x000000FF, 0x0000FF00,
+ 0x00FF0000, 0xFF000000});
+ }
}
diff --git a/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java b/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
index 2c9d91793..44c1ad926 100644
--- a/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+++ b/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
@@ -39,14 +39,15 @@ package gnu.java.awt.peer.gtk;
import java.awt.Font;
import java.awt.Shape;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Point2D;
-import java.awt.geom.Rectangle2D;
-import java.awt.geom.GeneralPath;
+import java.awt.font.FontRenderContext;
import java.awt.font.GlyphJustificationInfo;
import java.awt.font.GlyphMetrics;
import java.awt.font.GlyphVector;
-import java.awt.font.FontRenderContext;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Arrays;
public class FreetypeGlyphVector extends GlyphVector
{
@@ -155,14 +156,15 @@ public class FreetypeGlyphVector extends GlyphVector
}
glyphCodes = new int[ nGlyphs ];
- glyphPositions = new float[ nGlyphs ];
+ glyphPositions = new float[(nGlyphs + 1) * 2];
glyphTransforms = new AffineTransform[ nGlyphs ];
for(int i = 0; i < nGlyphs; i++ )
{
- glyphTransforms[ i ] = new AffineTransform( gv.glyphTransforms[ i ] );
- glyphCodes[i] = gv.glyphCodes[ i ];
- glyphPositions[i] = gv.glyphPositions[ i ];
+ glyphTransforms[ i ] = new AffineTransform( gv.glyphTransforms[ i ] );
+ glyphCodes[i] = gv.glyphCodes[ i ];
}
+ System.arraycopy(gv.glyphPositions, 0, glyphPositions, 0,
+ glyphPositions.length);
}
/**
@@ -242,22 +244,31 @@ public class FreetypeGlyphVector extends GlyphVector
public void performDefaultLayout()
{
logicalBounds = null; // invalidate caches.
- glyphPositions = null;
-
- glyphTransforms = new AffineTransform[ nGlyphs ];
- double x = 0;
+ glyphTransforms = new AffineTransform[nGlyphs];
+ Arrays.fill(glyphTransforms, null);
+ glyphPositions = new float[(nGlyphs + 1) * 2];
+ GlyphMetrics gm = null;
+ float x = 0;
+ float y = 0;
for(int i = 0; i < nGlyphs; i++)
{
- GlyphMetrics gm = getGlyphMetrics( i );
- glyphTransforms[ i ] = AffineTransform.getTranslateInstance(x, 0);
- x += gm.getAdvanceX();
- if( i > 0 )
- {
- Point2D p = getKerning( glyphCodes[ i - 1 ], glyphCodes[ i ] );
- x += p.getX();
- }
+ gm = getGlyphMetrics( i );
+ glyphPositions[i*2] = x;
+ glyphPositions[i*2 + 1] = y;
+
+ x += gm.getAdvanceX();
+ y += gm.getAdvanceY();
+
+ if (i != nGlyphs-1)
+ {
+ Point2D p = getKerning(glyphCodes[i], glyphCodes[i + 1]);
+ x += p.getX();
+ y += p.getY();
+ }
}
+ glyphPositions[nGlyphs * 2] = x;
+ glyphPositions[nGlyphs * 2 + 1] = y;
}
/**
@@ -286,9 +297,6 @@ public class FreetypeGlyphVector extends GlyphVector
return rval;
}
- /**
- * FIXME: Implement me.
- */
public Shape getGlyphLogicalBounds(int glyphIndex)
{
GlyphMetrics gm = getGlyphMetrics( glyphIndex );
@@ -296,10 +304,17 @@ public class FreetypeGlyphVector extends GlyphVector
return null;
Rectangle2D r = gm.getBounds2D();
Point2D p = getGlyphPosition( glyphIndex );
- return new Rectangle2D.Double( p.getX() + r.getX() - gm.getLSB(),
- p.getY() + r.getY(),
- gm.getAdvanceX(),
- r.getHeight() );
+
+ double[] bounds = new double[] {p.getX() + r.getX() - gm.getLSB(),
+ p.getY() + r.getY(),
+ p.getX() + r.getX() - gm.getLSB() + gm.getAdvanceX(),
+ p.getY() + r.getY() + r.getHeight()};
+
+ if (glyphTransforms[glyphIndex] != null)
+ glyphTransforms[glyphIndex].transform(bounds, 0, bounds, 0, 4);
+
+ return new Rectangle2D.Double(bounds[0], bounds[1], bounds[2] - bounds[0],
+ bounds[3] - bounds[1]);
}
/*
@@ -352,7 +367,9 @@ public class FreetypeGlyphVector extends GlyphVector
public Shape getGlyphOutline(int glyphIndex)
{
GeneralPath gp = getGlyphOutlineNative( glyphCodes[ glyphIndex ] );
- gp.transform( glyphTransforms[ glyphIndex ] );
+ if (glyphTransforms[glyphIndex] != null)
+ gp.transform( glyphTransforms[glyphIndex]);
+
return gp;
}
@@ -361,8 +378,8 @@ public class FreetypeGlyphVector extends GlyphVector
*/
public Point2D getGlyphPosition(int glyphIndex)
{
- return glyphTransforms[ glyphIndex ].transform( new Point2D.Double(0, 0),
- null );
+ return new Point2D.Float(glyphPositions[glyphIndex*2],
+ glyphPositions[glyphIndex*2 + 1]);
}
/**
@@ -371,25 +388,12 @@ public class FreetypeGlyphVector extends GlyphVector
public float[] getGlyphPositions(int beginGlyphIndex, int numEntries,
float[] positionReturn)
{
- if( glyphPositions != null )
- return glyphPositions;
-
- float[] rval;
-
- if( positionReturn == null )
- rval = new float[2 * numEntries];
- else
- rval = positionReturn;
-
- for( int i = beginGlyphIndex; i < numEntries; i++ )
- {
- Point2D p = getGlyphPosition( i );
- rval[i * 2] = (float)p.getX();
- rval[i * 2 + 1] = (float)p.getY();
- }
-
- glyphPositions = rval;
- return rval;
+ if (positionReturn == null)
+ positionReturn = new float[numEntries*2];
+
+ System.arraycopy(glyphPositions, beginGlyphIndex*2, positionReturn, 0,
+ numEntries*2);
+ return positionReturn;
}
/**
@@ -397,7 +401,7 @@ public class FreetypeGlyphVector extends GlyphVector
*/
public AffineTransform getGlyphTransform(int glyphIndex)
{
- return new AffineTransform( glyphTransforms[ glyphIndex ] );
+ return glyphTransforms[glyphIndex];
}
/**
@@ -485,11 +489,9 @@ public class FreetypeGlyphVector extends GlyphVector
*/
public void setGlyphPosition(int glyphIndex, Point2D newPos)
{
- // FIXME: Scaling, etc.?
- glyphTransforms[ glyphIndex ].setToTranslation( newPos.getX(),
- newPos.getY() );
+ glyphPositions[glyphIndex*2] = (float)(newPos.getX());
+ glyphPositions[glyphIndex*2 + 1] = (float)(newPos.getY());
logicalBounds = null;
- glyphPositions = null;
}
/**
@@ -497,8 +499,7 @@ public class FreetypeGlyphVector extends GlyphVector
*/
public void setGlyphTransform(int glyphIndex, AffineTransform newTX)
{
- glyphTransforms[ glyphIndex ].setTransform( newTX );
logicalBounds = null;
- glyphPositions = null;
+ glyphTransforms[glyphIndex] = newTX;
}
}
diff --git a/gnu/java/awt/peer/gtk/VolatileImageGraphics.java b/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
index 584965593..560d31750 100644
--- a/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
+++ b/gnu/java/awt/peer/gtk/VolatileImageGraphics.java
@@ -38,15 +38,31 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import java.awt.AlphaComposite;
+import java.awt.Color;
import java.awt.Graphics;
+import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
+import java.awt.Point;
+import java.awt.Shape;
+import java.awt.Toolkit;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.util.Hashtable;
public class VolatileImageGraphics extends ComponentGraphics
{
private GtkVolatileImage owner;
+ private BufferedImage buffer;
public VolatileImageGraphics(GtkVolatileImage img)
{
@@ -77,10 +93,118 @@ public class VolatileImageGraphics extends ComponentGraphics
return new VolatileImageGraphics( this );
}
+ public void draw(Shape s)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ super.draw(s);
+
+ // Custom composite
+ else
+ {
+ // Draw operation to temporary buffer
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setColor(this.getColor());
+ g2d.setStroke(this.getStroke());
+ g2d.draw(s);
+
+ drawComposite(s.getBounds2D(), null);
+ }
+ }
+
+ public void fill(Shape s)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ super.fill(s);
+
+ // Custom composite
+ else
+ {
+ // Draw operation to temporary buffer
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setPaint(this.getPaint());
+ g2d.setColor(this.getColor());
+ g2d.fill(s);
+
+ drawComposite(s.getBounds2D(), null);
+ }
+ }
+
+ public void drawGlyphVector(GlyphVector gv, float x, float y)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ super.drawGlyphVector(gv, x, y);
+
+ // Custom composite
+ else
+ {
+ // Draw operation to temporary buffer
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+
+ g2d.setPaint(this.getPaint());
+ g2d.setColor(this.getColor());
+ g2d.drawGlyphVector(gv, x, y);
+
+ Rectangle2D bounds = gv.getLogicalBounds();
+ bounds = new Rectangle2D.Double(x + bounds.getX(), y + bounds.getY(),
+ bounds.getWidth(), bounds.getHeight());
+ drawComposite(bounds, null);
+ }
+ }
+
+ protected boolean drawImage(Image img, AffineTransform xform,
+ Color bgcolor, ImageObserver obs)
+ {
+ if (comp == null || comp instanceof AlphaComposite)
+ return super.drawImage(img, xform, bgcolor, obs);
+
+ // Custom composite
+ else
+ {
+ // Get buffered image of source
+ if( !(img instanceof BufferedImage) )
+ {
+ ImageProducer source = img.getSource();
+ if (source == null)
+ return false;
+ img = Toolkit.getDefaultToolkit().createImage(source);
+ }
+ BufferedImage bImg = (BufferedImage) img;
+
+ // Find dimensions of translation
+ Point2D origin = new Point2D.Double(bImg.getMinX(), bImg.getMinY());
+ Point2D pt = new Point2D.Double(bImg.getWidth(), bImg.getHeight());
+ if (xform != null)
+ {
+ origin = xform.transform(origin, origin);
+ pt = xform.transform(pt, pt);
+ }
+
+ // Create buffer and draw image
+ createBuffer();
+
+ Graphics2D g2d = (Graphics2D)buffer.getGraphics();
+ g2d.setRenderingHints(this.getRenderingHints());
+ g2d.drawImage(img, xform, obs);
+ // Perform compositing from buffer to screen
+ return drawComposite(new Rectangle2D.Double((int)origin.getX(),
+ (int)origin.getY(),
+ (int)pt.getX(),
+ (int)pt.getY()),
+ obs);
+ }
+ }
+
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
{
- if( img instanceof GtkVolatileImage )
+ if (img instanceof GtkVolatileImage
+ && (comp == null || comp instanceof AlphaComposite))
{
owner.drawVolatile( ((GtkVolatileImage)img).nativePointer,
x, y,
@@ -94,7 +218,8 @@ public class VolatileImageGraphics extends ComponentGraphics
public boolean drawImage(Image img, int x, int y, int width, int height,
ImageObserver observer)
{
- if( img instanceof GtkVolatileImage )
+ if ((img instanceof GtkVolatileImage)
+ && (comp == null || comp instanceof AlphaComposite))
{
owner.drawVolatile( ((GtkVolatileImage)img).nativePointer,
x, y, width, height );
@@ -107,5 +232,76 @@ public class VolatileImageGraphics extends ComponentGraphics
{
return new Rectangle2D.Double(0, 0, owner.width, owner.height);
}
+
+ private boolean drawComposite(Rectangle2D bounds, ImageObserver observer)
+ {
+ // Clip source to visible areas that need updating
+ Rectangle2D clip = this.getClipBounds();
+ Rectangle2D.intersect(bounds, clip, bounds);
+
+ BufferedImage buffer2 = buffer;
+ if (!bounds.equals(buffer2.getRaster().getBounds()))
+ buffer2 = buffer2.getSubimage((int)bounds.getX(), (int)bounds.getY(),
+ (int)bounds.getWidth(),
+ (int)bounds.getHeight());
+
+ // Get current on-screen pixels (destination) and clip to bounds
+ BufferedImage current = owner.getSnapshot();
+
+ double[] points = new double[] {bounds.getX(), bounds.getY(),
+ bounds.getMaxX(), bounds.getMaxY()};
+ transform.transform(points, 0, points, 0, 2);
+
+ Rectangle2D deviceBounds = new Rectangle2D.Double(points[0], points[1],
+ points[2] - points[0],
+ points[3] - points[1]);
+ Rectangle2D.intersect(deviceBounds, this.getClipInDevSpace(), deviceBounds);
+
+ current = current.getSubimage((int)deviceBounds.getX(),
+ (int)deviceBounds.getY(),
+ (int)deviceBounds.getWidth(),
+ (int)deviceBounds.getHeight());
+
+ // Perform actual composite operation
+ compCtx.compose(buffer2.getRaster(), current.getRaster(),
+ buffer2.getRaster());
+
+ // This MUST call directly into the "action" method in CairoGraphics2D,
+ // not one of the wrappers, to ensure that the composite isn't processed
+ // more than once!
+ boolean rv = super.drawImage(buffer2,
+ AffineTransform.getTranslateInstance(bounds.getX(),
+ bounds.getY()),
+ null, null);
+
+ return rv;
+ }
+
+ private void createBuffer()
+ {
+ if (buffer == null)
+ {
+ WritableRaster rst;
+ rst = Raster.createWritableRaster(CairoSurface.
+ createNativeSampleModel(owner.width,
+ owner.height),
+ new Point(0,0));
+
+ buffer = new BufferedImage(CairoSurface.nativeColorModel, rst, true,
+ new Hashtable());
+ }
+ else
+ {
+ Graphics2D g2d = ((Graphics2D)buffer.getGraphics());
+
+ g2d.setBackground(new Color(0,0,0,0));
+ g2d.clearRect(0, 0, buffer.getWidth(), buffer.getHeight());
+ }
+ }
+
+ protected ColorModel getNativeCM()
+ {
+ return CairoSurface.nativeColorModel;
+ }
}
diff --git a/gnu/java/lang/management/MemoryMXBeanImpl.java b/gnu/java/lang/management/MemoryMXBeanImpl.java
index 064e19a19..8cb104202 100644
--- a/gnu/java/lang/management/MemoryMXBeanImpl.java
+++ b/gnu/java/lang/management/MemoryMXBeanImpl.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package gnu.java.lang.management;
+import gnu.classpath.ListenerData;
+
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryNotificationInfo;
import java.lang.management.MemoryUsage;
@@ -168,49 +170,6 @@ public final class MemoryMXBeanImpl
VMMemoryMXBeanImpl.setVerbose(verbose);
}
- private class ListenerData
- {
- private NotificationListener listener;
- private NotificationFilter filter;
- private Object passback;
-
- public ListenerData(NotificationListener listener,
- NotificationFilter filter, Object passback)
- {
- this.listener = listener;
- this.filter = filter;
- this.passback = passback;
- }
-
- public NotificationListener getListener()
- {
- return listener;
- }
-
- public NotificationFilter getFilter()
- {
- return filter;
- }
-
- public Object getPassback()
- {
- return passback;
- }
-
- public boolean equals(Object obj)
- {
- if (obj instanceof ListenerData)
- {
- ListenerData data = (ListenerData) obj;
- return (data.getListener() == listener &&
- data.getFilter() == filter &&
- data.getPassback() == passback);
- }
- return false;
- }
-
- }
-
public void addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object passback)
diff --git a/gnu/java/net/PlainDatagramSocketImpl.java b/gnu/java/net/PlainDatagramSocketImpl.java
index 0fcd780df..be2fc796b 100644
--- a/gnu/java/net/PlainDatagramSocketImpl.java
+++ b/gnu/java/net/PlainDatagramSocketImpl.java
@@ -38,13 +38,20 @@ exception statement from your version. */
package gnu.java.net;
+import gnu.java.nio.VMChannel;
+
import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.lang.reflect.Field;
import java.net.DatagramPacket;
import java.net.DatagramSocketImpl;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.SocketAddress;
import java.net.SocketException;
+import java.net.SocketTimeoutException;
+import java.nio.ByteBuffer;
/**
* Written using on-line Java Platform 1.2 API Specification, as well
@@ -62,11 +69,13 @@ import java.net.SocketException;
*/
public final class PlainDatagramSocketImpl extends DatagramSocketImpl
{
-
+
+ private final VMChannel channel;
+
/**
- * This is the actual underlying file descriptor
+ * The platform-specific socket implementation.
*/
- int native_fd = -1;
+ private final VMPlainSocketImpl impl;
/**
* Lock object to serialize threads wanting to receive
@@ -81,25 +90,26 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
/**
* Default do nothing constructor
*/
- public PlainDatagramSocketImpl()
+ public PlainDatagramSocketImpl() throws IOException
{
- // Nothing to do here.
+ channel = new VMChannel();
+ impl = new VMPlainSocketImpl(channel);
}
- protected void finalize() throws Throwable
+ /*protected void finalize() throws Throwable
{
synchronized (this)
{
- if (native_fd != -1)
+ if (channel.getState().isValid())
close();
}
super.finalize();
- }
+ }*/
- public int getNativeFD()
+ /*public int getNativeFD()
{
return native_fd;
- }
+ }*/
/**
* Binds this socket to a particular port and interface
@@ -109,20 +119,46 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*
* @exception SocketException If an error occurs
*/
- protected synchronized void bind(int port, InetAddress addr)
+ protected synchronized void bind(int port, InetAddress addr)
throws SocketException
- {
- VMPlainDatagramSocketImpl.bind(this, port, addr);
- }
+ {
+ try
+ {
+ impl.bind(new InetSocketAddress(addr, port));
+ }
+ catch (SocketException se)
+ {
+ throw se;
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
/**
* Creates a new datagram socket
*
* @exception SocketException If an error occurs
*/
- protected synchronized void create() throws SocketException
+ protected synchronized void create() throws SocketException
{
- VMPlainDatagramSocketImpl.create(this);
+ try
+ {
+ channel.initSocket(false);
+ }
+ catch (SocketException se)
+ {
+ throw se;
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
}
/**
@@ -147,8 +183,14 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
{
synchronized (this)
{
- if (native_fd != -1)
- close();
+ try
+ {
+ if (channel.getState().isValid())
+ channel.disconnect();
+ }
+ catch (IOException ioe)
+ {
+ }
}
}
@@ -181,6 +223,23 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
return ((Integer) obj).intValue();
}
+ protected int getLocalPort()
+ {
+ if (channel == null)
+ return -1;
+
+ try
+ {
+ InetSocketAddress local = channel.getLocalAddress();
+ if (local == null)
+ return -1;
+ return local.getPort();
+ }
+ catch (IOException ioe)
+ {
+ return -1;
+ }
+ }
/**
* Sends a packet of data to a remote host
@@ -191,13 +250,30 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
protected void send(DatagramPacket packet) throws IOException
{
- if (native_fd != -1)
+ synchronized (SEND_LOCK)
{
- synchronized(SEND_LOCK)
+ ByteBuffer buf = ByteBuffer.wrap(packet.getData(),
+ packet.getOffset(),
+ packet.getLength());
+ InetAddress remote = packet.getAddress();
+ int port = packet.getPort();
+ if (remote == null)
+ throw new NullPointerException();
+ if (port <= 0)
+ throw new SocketException("invalid port " + port);
+ while (true)
{
- VMPlainDatagramSocketImpl.send(this, packet);
+ try
+ {
+ channel.send(buf, new InetSocketAddress(remote, port));
+ break;
+ }
+ catch (InterruptedIOException ioe)
+ {
+ // Ignore; interrupted system call.
+ }
}
- }
+ }
}
/**
@@ -210,10 +286,32 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
protected void receive(DatagramPacket packet)
throws IOException
{
- synchronized(RECEIVE_LOCK)
- {
- VMPlainDatagramSocketImpl.receive(this, packet);
- }
+ synchronized(RECEIVE_LOCK)
+ {
+ ByteBuffer buf = ByteBuffer.wrap(packet.getData(),
+ packet.getOffset(),
+ packet.getLength());
+ SocketAddress addr = null;
+ while (true)
+ {
+ try
+ {
+ addr = channel.receive(buf);
+ break;
+ }
+ catch (SocketTimeoutException ste)
+ {
+ throw ste;
+ }
+ catch (InterruptedIOException iioe)
+ {
+ // Ignore. Loop.
+ }
+ }
+ if (addr != null)
+ packet.setSocketAddress(addr);
+ packet.setLength(buf.position() - packet.getOffset());
+ }
}
@@ -227,9 +325,9 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
public synchronized void setOption(int option_id, Object val)
throws SocketException
- {
- VMPlainDatagramSocketImpl.setOption(this, option_id, val);
- }
+ {
+ impl.setOption(option_id, val);
+ }
/**
* Retrieves the value of an option on the socket
@@ -242,16 +340,43 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
public synchronized Object getOption(int option_id)
throws SocketException
- {
- return VMPlainDatagramSocketImpl.getOption(this, option_id);
- }
+ {
+ if (option_id == SO_BINDADDR)
+ {
+ try
+ {
+ InetSocketAddress local = channel.getLocalAddress();
+ if (local == null)
+ return null;
+ return local.getAddress();
+ }
+ catch (SocketException se)
+ {
+ throw se;
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+ return impl.getOption(option_id);
+ }
/**
* Closes the socket
*/
protected synchronized void close()
{
- VMPlainDatagramSocketImpl.close(this);
+ try
+ {
+ if (channel.getState().isValid())
+ channel.close();
+ }
+ catch (IOException ioe)
+ {
+ }
}
/**
@@ -291,7 +416,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
protected synchronized void join(InetAddress addr) throws IOException
{
- VMPlainDatagramSocketImpl.join(this,addr);
+ impl.join(addr);
}
/**
@@ -303,7 +428,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
*/
protected synchronized void leave(InetAddress addr) throws IOException
{
- VMPlainDatagramSocketImpl.leave(this, addr);
+ impl.leave(addr);
}
/**
@@ -323,12 +448,20 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
public void joinGroup(SocketAddress address, NetworkInterface netIf)
throws IOException
{
- VMPlainDatagramSocketImpl.joinGroup(this, address, netIf);
+ if (address == null)
+ throw new NullPointerException();
+ if (!(address instanceof InetSocketAddress))
+ throw new SocketException("unknown address type");
+ impl.joinGroup((InetSocketAddress) address, netIf);
}
public void leaveGroup(SocketAddress address, NetworkInterface netIf)
throws IOException
{
- VMPlainDatagramSocketImpl.leaveGroup(this, address, netIf);
+ if (address == null)
+ throw new NullPointerException();
+ if (!(address instanceof InetSocketAddress))
+ throw new SocketException("unknown address type");
+ impl.leaveGroup((InetSocketAddress) address, netIf);
}
}
diff --git a/gnu/java/net/PlainSocketImpl.java b/gnu/java/net/PlainSocketImpl.java
index 47d05aa41..750243d5d 100644
--- a/gnu/java/net/PlainSocketImpl.java
+++ b/gnu/java/net/PlainSocketImpl.java
@@ -39,13 +39,24 @@ exception statement from your version. */
package gnu.java.net;
+import gnu.java.nio.SelectorProviderImpl;
+import gnu.java.nio.SocketChannelImpl;
+import gnu.java.nio.VMChannel;
+import gnu.java.security.action.GetSecurityPropertyAction;
+
+import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;
+import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketImpl;
+import java.net.SocketTimeoutException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
/**
* Written using on-line Java Platform 1.2 API Specification, as well
@@ -63,17 +74,13 @@ import java.net.SocketImpl;
* @author Nic Ferrier (nferrier@tapsellferrier.co.uk)
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
-public final class PlainSocketImpl extends SocketImpl
+public class PlainSocketImpl extends SocketImpl
{
/**
- * The OS file handle representing the socket.
- * This is used for reads and writes to/from the socket and
- * to close it.
- *
- * When the socket is closed this is reset to -1.
+ * The underlying plain socket VM implementation.
*/
- int native_fd = -1;
+ protected VMPlainSocketImpl impl;
/**
* A cached copy of the in stream for reading from the socket.
@@ -90,7 +97,13 @@ public final class PlainSocketImpl extends SocketImpl
* is being invoked on this socket.
*/
private boolean inChannelOperation;
-
+
+ /**
+ * The socket channel we use for IO operation. Package-private for
+ * use by inner classes.
+ */
+ SocketChannelImpl channel;
+
/**
* Indicates whether we should ignore whether any associated
* channel is set to non-blocking mode. Certain operations
@@ -117,29 +130,7 @@ public final class PlainSocketImpl extends SocketImpl
*/
public PlainSocketImpl()
{
- // Nothing to do here.
- }
-
- protected void finalize() throws Throwable
- {
- synchronized (this)
- {
- if (native_fd != -1)
- try
- {
- close();
- }
- catch (IOException ex)
- {
- // Nothing we can do about it.
- }
- }
- super.finalize();
- }
-
- public int getNativeFD()
- {
- return native_fd;
+ this.impl = new VMPlainSocketImpl();
}
/**
@@ -155,7 +146,29 @@ public final class PlainSocketImpl extends SocketImpl
*/
public void setOption(int optionId, Object value) throws SocketException
{
- VMPlainSocketImpl.setOption(this, optionId, value);
+ switch (optionId)
+ {
+ case IP_MULTICAST_IF:
+ case IP_MULTICAST_IF2:
+ throw new UnsupportedOperationException("FIXME");
+
+ case IP_MULTICAST_LOOP:
+ case SO_BROADCAST:
+ case SO_KEEPALIVE:
+ case SO_OOBINLINE:
+ case TCP_NODELAY:
+ case IP_TOS:
+ case SO_LINGER:
+ case SO_RCVBUF:
+ case SO_SNDBUF:
+ case SO_TIMEOUT:
+ case SO_REUSEADDR:
+ impl.setOption(optionId, value);
+ return;
+
+ default:
+ throw new SocketException("cannot set option " + optionId);
+ }
}
/**
@@ -171,17 +184,33 @@ public final class PlainSocketImpl extends SocketImpl
*/
public Object getOption(int optionId) throws SocketException
{
- return VMPlainSocketImpl.getOption(this, optionId);
+ if (optionId == SO_BINDADDR)
+ {
+ try
+ {
+ return channel.getVMChannel().getLocalAddress().getAddress();
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+ if (optionId == IP_MULTICAST_IF || optionId == IP_MULTICAST_IF2)
+ throw new UnsupportedOperationException ("can't get option " +
+ optionId + " yet");
+ return impl.getOption(optionId);
}
public void shutdownInput() throws IOException
{
- VMPlainSocketImpl.shutdownInput(this);
+ impl.shutdownInput();
}
public void shutdownOutput() throws IOException
{
- VMPlainSocketImpl.shutdownOutput(this);
+ impl.shutdownOutput();
}
/**
@@ -195,7 +224,11 @@ public final class PlainSocketImpl extends SocketImpl
*/
protected synchronized void create(boolean stream) throws IOException
{
- VMPlainSocketImpl.create(this);
+ channel = new SocketChannelImpl(false);
+ VMChannel vmchannel = channel.getVMChannel();
+ vmchannel.initSocket(stream);
+ channel.configureBlocking(true);
+ impl.getState().setChannelFD(vmchannel.getState());
}
/**
@@ -222,7 +255,7 @@ public final class PlainSocketImpl extends SocketImpl
*/
protected void connect(InetAddress addr, int port) throws IOException
{
- VMPlainSocketImpl.connect(this, addr, port);
+ connect(new InetSocketAddress(addr, port), 0);
}
/**
@@ -236,7 +269,14 @@ public final class PlainSocketImpl extends SocketImpl
protected synchronized void connect(SocketAddress address, int timeout)
throws IOException
{
- VMPlainSocketImpl.connect(this, address, timeout);
+ if (channel == null)
+ create(true);
+ boolean connected = channel.connect(address, timeout);
+ if (!connected)
+ throw new SocketTimeoutException("connect timed out");
+ InetSocketAddress addr = channel.getVMChannel().getPeerAddress();
+ this.address = addr.getAddress();
+ this.port = addr.getPort();
}
/**
@@ -251,7 +291,10 @@ public final class PlainSocketImpl extends SocketImpl
protected synchronized void bind(InetAddress addr, int port)
throws IOException
{
- VMPlainSocketImpl.bind(this, addr, port);
+ if (channel == null)
+ create(true);
+ impl.bind(new InetSocketAddress(addr, port));
+ localport = channel.getVMChannel().getLocalAddress().getPort();
}
/**
@@ -267,7 +310,7 @@ public final class PlainSocketImpl extends SocketImpl
protected synchronized void listen(int queuelen)
throws IOException
{
- VMPlainSocketImpl.listen(this, queuelen);
+ impl.listen(queuelen);
}
/**
@@ -279,7 +322,16 @@ public final class PlainSocketImpl extends SocketImpl
protected synchronized void accept(SocketImpl impl)
throws IOException
{
- VMPlainSocketImpl.accept(this, impl);
+ if (channel == null)
+ create(true);
+ if (!(impl instanceof PlainSocketImpl))
+ throw new IOException("incompatible SocketImpl: "
+ + impl.getClass().getName());
+ PlainSocketImpl that = (PlainSocketImpl) impl;
+ VMChannel c = channel.getVMChannel().accept();
+ that.impl.getState().setChannelFD(c.getState());
+ that.channel = new SocketChannelImpl(c);
+ that.setOption(SO_REUSEADDR, Boolean.TRUE);
}
/**
@@ -292,7 +344,9 @@ public final class PlainSocketImpl extends SocketImpl
*/
protected int available() throws IOException
{
- return VMPlainSocketImpl.available(this);
+ if (channel == null)
+ throw new SocketException("not connected");
+ return channel.getVMChannel().available();
}
/**
@@ -308,65 +362,13 @@ public final class PlainSocketImpl extends SocketImpl
*/
protected void close() throws IOException
{
- VMPlainSocketImpl.close(this);
- }
-
- public void sendUrgentData(int data)
- {
- VMPlainSocketImpl.sendUrgendData(this, data);
- }
-
- /**
- * Internal method used by SocketInputStream for reading data from
- * the connection. Reads up to len bytes of data into the buffer
- * buf starting at offset bytes into the buffer.
- *
- * @return the actual number of bytes read or -1 if end of stream.
- *
- * @throws IOException if an error occurs
- */
- protected int read(byte[] buf, int offset, int len)
- throws IOException
- {
- return VMPlainSocketImpl.read(this, buf, offset, len);
+ if (impl.getState().isValid())
+ impl.close();
}
- /**
- * Internal method used by SocketInputStream for reading data from
- * the connection. Reads and returns one byte of data.
- *
- * @return the read byte
- *
- * @throws IOException if an error occurs
- */
- protected int read()
- throws IOException
+ public void sendUrgentData(int data) throws IOException
{
- return VMPlainSocketImpl.read(this);
- }
-
- /**
- * Internal method used by SocketOuputStream for writing data to
- * the connection. Writes up to len bytes of data from the buffer
- * buf starting at offset bytes into the buffer.
- *
- * @throws IOException If an error occurs
- */
- protected void write(byte[] buf, int offset, int len)
- throws IOException
- {
- VMPlainSocketImpl.write(this, buf, offset, len);
- }
-
- /**
- * Internal method used by SocketOuputStream for writing data to
- * the connection. Writes up one byte to the socket.
- *
- * @throws IOException If an error occurs
- */
- protected void write(int data) throws IOException
- {
- VMPlainSocketImpl.write(this, data);
+ impl.sendUrgentData(data);
}
/**
@@ -400,6 +402,87 @@ public final class PlainSocketImpl extends SocketImpl
return out;
}
+
+ public VMChannel getVMChannel()
+ {
+ if (channel == null)
+ return null;
+ return channel.getVMChannel();
+ }
+
+ /* (non-Javadoc)
+ * @see java.net.SocketImpl#getInetAddress()
+ */
+ protected InetAddress getInetAddress()
+ {
+ if (channel == null)
+ return null;
+ try
+ {
+ InetSocketAddress remote = channel.getVMChannel().getPeerAddress();
+ if (remote == null)
+ return null;
+ return remote.getAddress();
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.net.SocketImpl#getLocalPort()
+ */
+ protected int getLocalPort()
+ {
+ if (channel == null)
+ return -1;
+ try
+ {
+ InetSocketAddress local = channel.getVMChannel().getLocalAddress();
+ if (local == null)
+ return -1;
+ return local.getPort();
+ }
+ catch (IOException ioe)
+ {
+ return -1;
+ }
+ }
+
+ public InetSocketAddress getLocalAddress()
+ {
+ if (channel == null)
+ return null;
+ try
+ {
+ return channel.getVMChannel().getLocalAddress();
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.net.SocketImpl#getPort()
+ */
+ protected int getPort()
+ {
+ if (channel == null)
+ return -1;
+ try
+ {
+ InetSocketAddress remote = channel.getVMChannel().getPeerAddress();
+ if (remote == null)
+ return -1;
+ return remote.getPort();
+ }
+ catch (IOException ioe)
+ {
+ return -1;
+ }
+ }
/**
* This class contains an implementation of <code>InputStream</code> for
@@ -437,7 +520,23 @@ public final class PlainSocketImpl extends SocketImpl
*/
public int read() throws IOException
{
- return PlainSocketImpl.this.read();
+ if (channel == null)
+ throw new SocketException("not connected");
+ while (true)
+ {
+ try
+ {
+ return channel.getVMChannel().read();
+ }
+ catch (SocketTimeoutException ste)
+ {
+ throw ste;
+ }
+ catch (InterruptedIOException iioe)
+ {
+ // Ignore; NIO may throw this; net io shouldn't
+ }
+ }
}
/**
@@ -454,12 +553,24 @@ public final class PlainSocketImpl extends SocketImpl
*/
public int read (byte[] buf, int offset, int len) throws IOException
{
- int bytes_read = PlainSocketImpl.this.read (buf, offset, len);
-
- if (bytes_read == 0)
- return -1;
-
- return bytes_read;
+ if (channel == null)
+ throw new SocketException("not connected");
+ ByteBuffer b = ByteBuffer.wrap(buf, offset, len);
+ while (true)
+ {
+ try
+ {
+ return channel.read(b);
+ }
+ catch (SocketTimeoutException ste)
+ {
+ throw ste;
+ }
+ catch (InterruptedIOException iioe)
+ {
+ // Ignored; NIO may throw this; net IO not.
+ }
+ }
}
}
@@ -495,7 +606,20 @@ public final class PlainSocketImpl extends SocketImpl
*/
public void write(int b) throws IOException
{
- PlainSocketImpl.this.write(b);
+ if (channel == null)
+ throw new SocketException("not connected");
+ while (true)
+ {
+ try
+ {
+ channel.getVMChannel().write(b);
+ return;
+ }
+ catch (InterruptedIOException iioe)
+ {
+ // Ignored.
+ }
+ }
}
/**
@@ -510,7 +634,21 @@ public final class PlainSocketImpl extends SocketImpl
*/
public void write (byte[] buf, int offset, int len) throws IOException
{
- PlainSocketImpl.this.write (buf, offset, len);
+ if (channel == null)
+ throw new SocketException("not connected");
+ ByteBuffer b = ByteBuffer.wrap(buf, offset, len);
+ while (b.hasRemaining())
+ {
+ try
+ {
+ if (channel.write(b) == -1)
+ throw new IOException("channel has been closed");
+ }
+ catch (InterruptedIOException iioe)
+ {
+ // Ignored.
+ }
+ }
}
}
}
diff --git a/gnu/java/net/protocol/http/HTTPURLConnection.java b/gnu/java/net/protocol/http/HTTPURLConnection.java
index a46d1204b..cc68a3bac 100644
--- a/gnu/java/net/protocol/http/HTTPURLConnection.java
+++ b/gnu/java/net/protocol/http/HTTPURLConnection.java
@@ -149,6 +149,14 @@ public class HTTPURLConnection
final Credentials creds = (username == null) ? null :
new Credentials (username, password);
+ if ("POST".equals(method))
+ {
+ String contentType = requestHeaders.getValue("Content-Type");
+ if (null == contentType)
+ requestHeaders.addValue("Content-Type",
+ "application/x-www-form-urlencoded");
+ }
+
boolean retry;
do
{
diff --git a/gnu/java/nio/DatagramChannelImpl.java b/gnu/java/nio/DatagramChannelImpl.java
index 4687bf3f5..268ee0a8a 100644
--- a/gnu/java/nio/DatagramChannelImpl.java
+++ b/gnu/java/nio/DatagramChannelImpl.java
@@ -55,8 +55,10 @@ import java.nio.channels.spi.SelectorProvider;
* @author Michael Koch
*/
public final class DatagramChannelImpl extends DatagramChannel
+ implements VMChannelOwner
{
private NIODatagramSocket socket;
+ private VMChannel channel;
/**
* Indicates whether this channel initiated whatever operation
@@ -64,6 +66,16 @@ public final class DatagramChannelImpl extends DatagramChannel
*/
private boolean inChannelOperation;
+ protected DatagramChannelImpl (SelectorProvider provider)
+ throws IOException
+ {
+ super (provider);
+ socket = new NIODatagramSocket (new PlainDatagramSocketImpl(), this);
+ channel = new VMChannel();
+ channel.initSocket(false);
+ configureBlocking(true);
+ }
+
/**
* Indicates whether our datagram socket should ignore whether
* we are set to non-blocking mode. Certain operations on our
@@ -85,14 +97,6 @@ public final class DatagramChannelImpl extends DatagramChannel
inChannelOperation = b;
}
- protected DatagramChannelImpl (SelectorProvider provider)
- throws IOException
- {
- super (provider);
- socket = new NIODatagramSocket (new PlainDatagramSocketImpl(), this);
- configureBlocking(true);
- }
-
public DatagramSocket socket ()
{
return socket;
@@ -101,13 +105,13 @@ public final class DatagramChannelImpl extends DatagramChannel
protected void implCloseSelectableChannel ()
throws IOException
{
- socket.close ();
+ channel.close();
}
protected void implConfigureBlocking (boolean blocking)
throws IOException
{
- socket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT);
+ channel.setBlocking(blocking);
}
public DatagramChannel connect (SocketAddress remote)
@@ -116,20 +120,34 @@ public final class DatagramChannelImpl extends DatagramChannel
if (!isOpen())
throw new ClosedChannelException();
- socket.connect (remote);
+ try
+ {
+ channel.connect((InetSocketAddress) remote, 0);
+ }
+ catch (ClassCastException cce)
+ {
+ throw new IOException("unsupported socked address type");
+ }
return this;
}
public DatagramChannel disconnect ()
throws IOException
{
- socket.disconnect ();
+ channel.disconnect();
return this;
}
- public boolean isConnected ()
+ public boolean isConnected()
{
- return socket.isConnected ();
+ try
+ {
+ return channel.getPeerAddress() != null;
+ }
+ catch (IOException ioe)
+ {
+ return false;
+ }
}
public int write (ByteBuffer src)
@@ -138,7 +156,7 @@ public final class DatagramChannelImpl extends DatagramChannel
if (!isConnected ())
throw new NotYetConnectedException ();
- return send (src, socket.getRemoteSocketAddress());
+ return channel.write(src);
}
public long write (ByteBuffer[] srcs, int offset, int length)
@@ -152,13 +170,11 @@ public final class DatagramChannelImpl extends DatagramChannel
|| (length < 0)
|| (length > (srcs.length - offset)))
throw new IndexOutOfBoundsException();
-
- long result = 0;
-
- for (int index = offset; index < offset + length; index++)
- result += write (srcs [index]);
- return result;
+ /* We are connected, meaning we will write these bytes to
+ * the host we connected to, so we don't need to explicitly
+ * give the host. */
+ return channel.writeGathering(srcs, offset, length);
}
public int read (ByteBuffer dst)
@@ -167,9 +183,7 @@ public final class DatagramChannelImpl extends DatagramChannel
if (!isConnected ())
throw new NotYetConnectedException ();
- int remaining = dst.remaining();
- receive (dst);
- return remaining - dst.remaining();
+ return channel.read(dst);
}
public long read (ByteBuffer[] dsts, int offset, int length)
@@ -184,12 +198,8 @@ public final class DatagramChannelImpl extends DatagramChannel
|| (length > (dsts.length - offset)))
throw new IndexOutOfBoundsException();
- long result = 0;
-
- for (int index = offset; index < offset + length; index++)
- result += read (dsts [index]);
-
- return result;
+ /* Likewise, see the comment int write above. */
+ return channel.readScattering(dsts, offset, length);
}
public SocketAddress receive (ByteBuffer dst)
@@ -200,49 +210,12 @@ public final class DatagramChannelImpl extends DatagramChannel
try
{
- DatagramPacket packet;
- int len = dst.remaining();
-
- if (dst.hasArray())
- {
- packet = new DatagramPacket (dst.array(),
- dst.arrayOffset() + dst.position(),
- len);
- }
- else
- {
- packet = new DatagramPacket (new byte [len], len);
- }
-
- boolean completed = false;
-
- try
- {
- begin();
- setInChannelOperation(true);
- socket.receive (packet);
- completed = true;
- }
- finally
- {
- end (completed);
- setInChannelOperation(false);
- }
-
- if (!dst.hasArray())
- {
- dst.put (packet.getData(), packet.getOffset(), packet.getLength());
- }
- else
- {
- dst.position (dst.position() + packet.getLength());
- }
-
- return packet.getSocketAddress();
+ begin();
+ return channel.receive(dst);
}
- catch (SocketTimeoutException e)
+ finally
{
- return null;
+ end(true);
}
}
@@ -252,46 +225,18 @@ public final class DatagramChannelImpl extends DatagramChannel
if (!isOpen())
throw new ClosedChannelException();
- if (target instanceof InetSocketAddress
- && ((InetSocketAddress) target).isUnresolved())
- throw new IOException("Target address not resolved");
-
- byte[] buffer;
- int offset = 0;
- int len = src.remaining();
+ if (!(target instanceof InetSocketAddress))
+ throw new IOException("can only send to inet socket addresses");
- if (src.hasArray())
- {
- buffer = src.array();
- offset = src.arrayOffset() + src.position();
- }
- else
- {
- buffer = new byte [len];
- src.get (buffer);
- }
-
- DatagramPacket packet = new DatagramPacket (buffer, offset, len, target);
-
- boolean completed = false;
- try
- {
- begin();
- setInChannelOperation(true);
- socket.send(packet);
- completed = true;
- }
- finally
- {
- end (completed);
- setInChannelOperation(false);
- }
-
- if (src.hasArray())
- {
- src.position (src.position() + len);
- }
+ InetSocketAddress dst = (InetSocketAddress) target;
+ if (dst.isUnresolved())
+ throw new IOException("Target address not resolved");
- return len;
+ return channel.send(src, dst);
+ }
+
+ public VMChannel getVMChannel()
+ {
+ return channel;
}
}
diff --git a/gnu/java/nio/DatagramChannelSelectionKey.java b/gnu/java/nio/DatagramChannelSelectionKey.java
index 698e07e34..f192e5002 100644
--- a/gnu/java/nio/DatagramChannelSelectionKey.java
+++ b/gnu/java/nio/DatagramChannelSelectionKey.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.nio;
+import java.io.IOException;
import java.nio.channels.spi.AbstractSelectableChannel;
/**
@@ -52,10 +53,16 @@ public final class DatagramChannelSelectionKey
super (channel, selector);
}
+ // FIXME don't use file descriptor integers
public int getNativeFD()
{
- NIODatagramSocket socket =
- (NIODatagramSocket) ((DatagramChannelImpl) ch).socket();
- return socket.getPlainDatagramSocketImpl().getNativeFD();
+ try
+ {
+ return ((DatagramChannelImpl) ch).getVMChannel().getState().getNativeFD();
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalStateException(ioe);
+ }
}
}
diff --git a/gnu/java/nio/EpollSelectionKeyImpl.java b/gnu/java/nio/EpollSelectionKeyImpl.java
new file mode 100644
index 000000000..11113f397
--- /dev/null
+++ b/gnu/java/nio/EpollSelectionKeyImpl.java
@@ -0,0 +1,122 @@
+/* EpollSelectionKeyImpl.java -- selection key for the epoll selector.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+import java.io.IOException;
+import java.nio.channels.CancelledKeyException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.AbstractSelectionKey;
+
+/**
+ * @author Casey Marshall (csm@gnu.org)
+ */
+public class EpollSelectionKeyImpl extends AbstractSelectionKey
+{
+ final int fd;
+ private final EpollSelectorImpl selector;
+ private final SelectableChannel channel;
+ int interestOps;
+ int selectedOps;
+ int key;
+ boolean valid;
+ boolean cancelled;
+
+ EpollSelectionKeyImpl(EpollSelectorImpl selector,
+ SelectableChannel channel, int fd)
+ {
+ this.selector = selector;
+ this.channel = channel;
+ this.fd = fd;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#channel()
+ */
+ public SelectableChannel channel()
+ {
+ return channel;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#interestOps()
+ */
+ public int interestOps()
+ {
+ return interestOps;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#interestOps(int)
+ */
+ public SelectionKey interestOps(int ops)
+ {
+ if (cancelled)
+ throw new CancelledKeyException();
+ if ((ops & ~(channel.validOps())) != 0)
+ throw new IllegalArgumentException("unsupported channel ops");
+ try
+ {
+ selector.epoll_modify(this, ops);
+ interestOps = ops;
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalArgumentException(ioe);
+ }
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#readyOps()
+ */
+ public int readyOps()
+ {
+ return selectedOps;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#selector()
+ */
+ public Selector selector()
+ {
+ return selector;
+ }
+}
diff --git a/gnu/java/nio/EpollSelectorImpl.java b/gnu/java/nio/EpollSelectorImpl.java
new file mode 100644
index 000000000..2b3c9bbb1
--- /dev/null
+++ b/gnu/java/nio/EpollSelectorImpl.java
@@ -0,0 +1,399 @@
+/* EpollSelectorImpl.java -- selector implementation using epoll
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+import gnu.classpath.Configuration;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.AbstractSelector;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * An implementation of {@link Selector} that uses the epoll event
+ * notification mechanism on GNU/Linux.
+ *
+ * @author Casey Marshall (csm@gnu.org)
+ */
+public class EpollSelectorImpl extends AbstractSelector
+{
+ // XXX is this reasonable? Does it matter?
+ private static final int DEFAULT_EPOLL_SIZE = 128;
+ private static final int sizeof_struct_epoll_event;
+
+ private static final int OP_ACCEPT = SelectionKey.OP_ACCEPT;
+ private static final int OP_CONNECT = SelectionKey.OP_CONNECT;
+ private static final int OP_READ = SelectionKey.OP_READ;
+ private static final int OP_WRITE = SelectionKey.OP_WRITE;
+
+ /** our epoll file descriptor. */
+ private int epoll_fd;
+
+ private final HashMap keys;
+ private Set selectedKeys;
+ private Thread waitingThread;
+ private ByteBuffer events;
+
+ private static final int INITIAL_CAPACITY;
+ private static final int MAX_DOUBLING_CAPACITY;
+ private static final int CAPACITY_INCREMENT;
+
+ static
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("javanio");
+
+ if (epoll_supported())
+ sizeof_struct_epoll_event = sizeof_struct();
+ else
+ sizeof_struct_epoll_event = -1;
+
+ INITIAL_CAPACITY = 64 * sizeof_struct_epoll_event;
+ MAX_DOUBLING_CAPACITY = 1024 * sizeof_struct_epoll_event;
+ CAPACITY_INCREMENT = 128 * sizeof_struct_epoll_event;
+ }
+
+ public EpollSelectorImpl(SelectorProvider provider)
+ throws IOException
+ {
+ super(provider);
+ epoll_fd = epoll_create(DEFAULT_EPOLL_SIZE);
+ keys = new HashMap();
+ selectedKeys = null;
+ events = ByteBuffer.allocateDirect(INITIAL_CAPACITY);
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#keys()
+ */
+ public Set keys()
+ {
+ return new HashSet(keys.values());
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#select()
+ */
+ public int select() throws IOException
+ {
+ return doSelect(-1);
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#select(long)
+ */
+ public int select(long timeout) throws IOException
+ {
+ if (timeout > Integer.MAX_VALUE)
+ throw new IllegalArgumentException("timeout is too large");
+ if (timeout < 0)
+ throw new IllegalArgumentException("invalid timeout");
+ return doSelect((int) timeout);
+ }
+
+ private int doSelect(int timeout) throws IOException
+ {
+ synchronized (keys)
+ {
+ Set cancelledKeys = cancelledKeys();
+ synchronized (cancelledKeys)
+ {
+ for (Iterator it = cancelledKeys.iterator(); it.hasNext(); )
+ {
+ EpollSelectionKeyImpl key = (EpollSelectionKeyImpl) it.next();
+ epoll_delete(epoll_fd, key.fd);
+ key.valid = false;
+ keys.remove(Integer.valueOf(key.fd));
+ it.remove();
+ deregister(key);
+ }
+
+ // Clear out closed channels. The fds are removed from the epoll
+ // fd when closed, so there is no need to remove them manually.
+ for (Iterator it = keys.values().iterator(); it.hasNext(); )
+ {
+ EpollSelectionKeyImpl key = (EpollSelectionKeyImpl) it.next();
+ SelectableChannel ch = key.channel();
+ if (ch instanceof VMChannelOwner)
+ {
+ if (!((VMChannelOwner) ch).getVMChannel().getState().isValid())
+ it.remove();
+ }
+ }
+
+ // Don't bother if we have nothing to select.
+ if (keys.isEmpty())
+ return 0;
+
+ int ret;
+ try
+ {
+ begin();
+ waitingThread = Thread.currentThread();
+ ret = epoll_wait(epoll_fd, events, keys.size(), timeout);
+ }
+ finally
+ {
+ Thread.interrupted();
+ waitingThread = null;
+ end();
+ }
+
+ HashSet s = new HashSet(ret);
+ for (int i = 0; i < ret; i++)
+ {
+ events.position(i * sizeof_struct_epoll_event);
+ ByteBuffer b = events.slice();
+ int fd = selected_fd(b);
+ EpollSelectionKeyImpl key
+ = (EpollSelectionKeyImpl) keys.get(Integer.valueOf(fd));
+ if (key == null)
+ throw new IOException("fd was selected, but no key found");
+ key.selectedOps = selected_ops(b) & key.interestOps;
+ s.add(key);
+ }
+
+ reallocateBuffer();
+
+ selectedKeys = s;
+ return ret;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#selectedKeys()
+ */
+ public Set selectedKeys()
+ {
+ if (selectedKeys == null)
+ return Collections.EMPTY_SET;
+ return selectedKeys;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#selectNow()
+ */
+ public int selectNow() throws IOException
+ {
+ return doSelect(0);
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#wakeup()
+ */
+ public Selector wakeup()
+ {
+ try
+ {
+ waitingThread.interrupt();
+ }
+ catch (NullPointerException npe)
+ {
+ // Ignored, thrown if we are not in a blocking op.
+ }
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.spi.AbstractSelector#implCloseSelector()
+ */
+ protected void implCloseSelector() throws IOException
+ {
+ VMChannel.close(epoll_fd);
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.spi.AbstractSelector#register(java.nio.channels.spi.AbstractSelectableChannel, int, java.lang.Object)
+ */
+ protected SelectionKey register(AbstractSelectableChannel ch, int ops, Object att)
+ {
+ if (!(ch instanceof VMChannelOwner))
+ throw new IllegalArgumentException("unsupported channel type");
+
+ VMChannel channel = ((VMChannelOwner) ch).getVMChannel();
+ try
+ {
+ int native_fd = channel.getState().getNativeFD();
+ synchronized (keys)
+ {
+ if (keys.containsKey(Integer.valueOf(native_fd)))
+ throw new IllegalArgumentException("channel already registered");
+ EpollSelectionKeyImpl result =
+ new EpollSelectionKeyImpl(this, ch, native_fd);
+ if ((ops & ~(ch.validOps())) != 0)
+ throw new IllegalArgumentException("invalid ops for channel");
+ result.interestOps = ops;
+ result.selectedOps = 0;
+ result.valid = true;
+ result.attach(att);
+ result.key = System.identityHashCode(result);
+ epoll_add(epoll_fd, result.fd, ops);
+ keys.put(Integer.valueOf(native_fd), result);
+ reallocateBuffer();
+ return result;
+ }
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalArgumentException(ioe);
+ }
+ }
+
+ private void reallocateBuffer()
+ {
+ // Ensure we have enough space for all potential events that may be
+ // returned.
+ if (events.capacity() < keys.size() * sizeof_struct_epoll_event)
+ {
+ int cap = events.capacity();
+ if (cap < MAX_DOUBLING_CAPACITY)
+ cap <<= 1;
+ else
+ cap += CAPACITY_INCREMENT;
+ events = ByteBuffer.allocateDirect(cap);
+ }
+ // Ensure that the events buffer is not too large, given the number of
+ // events registered.
+ else if (events.capacity() > keys.size() * sizeof_struct_epoll_event * 2 + 1
+ && events.capacity() > INITIAL_CAPACITY)
+ {
+ int cap = events.capacity() >>> 1;
+ events = ByteBuffer.allocateDirect(cap);
+ }
+ }
+
+ void epoll_modify(EpollSelectionKeyImpl key, int ops) throws IOException
+ {
+ epoll_modify(epoll_fd, key.fd, ops);
+ }
+
+ /**
+ * Tell if epoll is supported by this system, and support was compiled in.
+ *
+ * @return True if this system supports event notification with epoll.
+ */
+ public static native boolean epoll_supported();
+
+
+ /**
+ * Returns the size of `struct epoll_event'.
+ *
+ * @return The size of `struct epoll_event'.
+ */
+ private static native int sizeof_struct();
+
+
+ /**
+ * Open a new epoll file descriptor.
+ *
+ * @param size The size hint for the new epoll descriptor.
+ * @return The new file descriptor integer.
+ * @throws IOException If allocating a new epoll descriptor fails.
+ */
+ private static native int epoll_create(int size) throws IOException;
+
+ /**
+ * Add a file descriptor to this selector.
+ *
+ * @param efd The epoll file descriptor.
+ * @param fd The file descriptor to add (or modify).
+ * @param ops The interest opts.
+ */
+ private static native void epoll_add(int efd, int fd, int ops)
+ throws IOException;
+
+ /**
+ * Modify the interest ops of the key selecting for the given FD.
+ *
+ * @param efd The epoll file descriptor.
+ * @param fd The file descriptor to modify.
+ * @param ops The ops.
+ * @throws IOException
+ */
+ private static native void epoll_modify(int efd, int fd, int ops)
+ throws IOException;
+
+ /**
+ * Remove a file descriptor from this selector.
+ *
+ * @param efd The epoll file descriptor.
+ * @param fd The file descriptor.
+ * @throws IOException
+ */
+ private static native void epoll_delete(int efd, int fd) throws IOException;
+
+ /**
+ * Select events.
+ *
+ * @param efd The epoll file descriptor.
+ * @param state The buffer to hold selected events.
+ * @param n The number of events that may be put in `state'.
+ * @param timeout The timeout.
+ * @return The number of events selected.
+ * @throws IOException
+ */
+ private static native int epoll_wait(int efd, ByteBuffer state, int n, int timeout)
+ throws IOException;
+
+ /**
+ * Fetch the fd value from a selected struct epoll_event.
+ *
+ * @param struct The direct buffer holding the struct.
+ * @return The fd value.
+ */
+ private static native int selected_fd(ByteBuffer struct);
+
+ /**
+ * Fetch the enabled operations from a selected struct epoll_event.
+ *
+ * @param struct The direct buffer holding the struct.
+ * @return The selected operations.
+ */
+ private static native int selected_ops(ByteBuffer struct);
+}
diff --git a/gnu/java/nio/channels/FileChannelImpl.java b/gnu/java/nio/FileChannelImpl.java
index ed439e141..419124050 100644
--- a/gnu/java/nio/channels/FileChannelImpl.java
+++ b/gnu/java/nio/FileChannelImpl.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.java.nio.channels;
+package gnu.java.nio;
import gnu.classpath.Configuration;
import gnu.java.nio.FileLockImpl;
@@ -74,11 +74,11 @@ public final class FileChannelImpl extends FileChannel
public static final int SYNC = 16;
public static final int DSYNC = 32;
- public static FileChannelImpl in;
- public static FileChannelImpl out;
- public static FileChannelImpl err;
+ public static final FileChannelImpl in;
+ public static final FileChannelImpl out;
+ public static final FileChannelImpl err;
- private static native void init();
+ //private static native void init();
static
{
@@ -87,22 +87,45 @@ public final class FileChannelImpl extends FileChannel
System.loadLibrary("javanio");
}
- init();
+ //init();
- in = new FileChannelImpl(0, READ);
- out = new FileChannelImpl(1, WRITE);
- err = new FileChannelImpl(2, WRITE);
+ FileChannelImpl ch = null;
+ try
+ {
+ ch = new FileChannelImpl(VMChannel.getStdin(), READ);
+ }
+ catch (IOException ioe)
+ {
+ throw new Error(ioe);
+ }
+ in = ch;
+
+ ch = null;
+ try
+ {
+ ch = new FileChannelImpl(VMChannel.getStdout(), WRITE);
+ }
+ catch (IOException ioe)
+ {
+ throw new Error(ioe);
+ }
+ out = ch;
+
+ ch = null;
+ try
+ {
+ ch = new FileChannelImpl(VMChannel.getStderr(), WRITE);
+ }
+ catch (IOException ioe)
+ {
+ throw new Error(ioe);
+ }
+ err = ch;
}
/**
* This is the actual native file descriptor value
*/
- // System's notion of file descriptor. It might seem redundant to
- // initialize this given that it is reassigned in the constructors.
- // However, this is necessary because if open() throws an exception
- // we want to make sure this has the value -1. This is the most
- // efficient way to accomplish that.
- private int fd = -1;
private VMChannel ch;
private int mode;
@@ -113,19 +136,19 @@ public final class FileChannelImpl extends FileChannel
/* This is a static factory method, so that VM implementors can decide
* substitute subclasses of FileChannelImpl. */
public static FileChannelImpl create(File file, int mode)
- throws FileNotFoundException
+ throws IOException
{
return new FileChannelImpl(file, mode);
}
private FileChannelImpl(File file, int mode)
- throws FileNotFoundException
+ throws IOException
{
String path = file.getPath();
description = path;
- fd = open (path, mode);
this.mode = mode;
- this.ch = VMChannel.getVMChannel(this);
+ this.ch = new VMChannel();
+ ch.openFile(path, mode);
// First open the file and then check if it is a a directory
// to avoid race condition.
@@ -133,11 +156,11 @@ public final class FileChannelImpl extends FileChannel
{
try
{
- close();
+ close();
}
catch (IOException e)
{
- /* ignore it */
+ /* ignore it */
}
throw new FileNotFoundException(description + " is a directory");
@@ -153,49 +176,59 @@ public final class FileChannelImpl extends FileChannel
*
* @param mode READ or WRITE
*/
- FileChannelImpl (int fd, int mode)
+ FileChannelImpl (VMChannel ch, int mode)
{
- this.fd = fd;
this.mode = mode;
- this.description = "descriptor(" + fd + ")";
- this.ch = VMChannel.getVMChannel(this);
+ this.description = "descriptor(" + ch.getState() + ")";
+ this.ch = ch;
}
- private native int open (String path, int mode) throws FileNotFoundException;
+ public int available() throws IOException
+ {
+ return ch.available();
+ }
+
+ private long implPosition() throws IOException
+ {
+ return ch.position();
+ }
- public native int available () throws IOException;
- private native long implPosition () throws IOException;
- private native void seek (long newPosition) throws IOException;
- private native void implTruncate (long size) throws IOException;
+ private void seek(long newPosition) throws IOException
+ {
+ ch.seek(newPosition);
+ }
+
+ private void implTruncate(long size) throws IOException
+ {
+ ch.truncate(size);
+ }
- public native void unlock (long pos, long len) throws IOException;
+ public void unlock(long pos, long len) throws IOException
+ {
+ ch.unlock(pos, len);
+ }
- public native long size () throws IOException;
+ public long size () throws IOException
+ {
+ return ch.size();
+ }
- protected native void implCloseChannel() throws IOException;
+ protected void implCloseChannel() throws IOException
+ {
+ ch.close();
+ }
/**
* Makes sure the Channel is properly closed.
*/
protected void finalize() throws IOException
{
- if (fd != -1)
+ if (ch.getState().isValid())
close();
}
public int read (ByteBuffer dst) throws IOException
{
- /*
- int result;
- byte[] buffer = new byte [dst.remaining ()];
-
- result = read (buffer, 0, buffer.length);
-
- if (result > 0)
- dst.put (buffer, 0, result);
-
- return result;
- */
return ch.read(dst);
}
@@ -212,11 +245,10 @@ public final class FileChannelImpl extends FileChannel
return result;
}
- public native int read ()
- throws IOException;
-
- public native int read (byte[] buffer, int offset, int length)
- throws IOException;
+ public int read() throws IOException
+ {
+ return ch.read();
+ }
public long read (ByteBuffer[] dsts, int offset, int length)
throws IOException
@@ -252,19 +284,16 @@ public final class FileChannelImpl extends FileChannel
return result;
}
- public native void write (byte[] buffer, int offset, int length)
- throws IOException;
-
- public native void write (int b) throws IOException;
+ public void write (int b) throws IOException
+ {
+ ch.write(b);
+ }
public long write(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
return ch.writeGathering(srcs, offset, length);
}
-
- public native MappedByteBuffer mapImpl (char mode, long position, int size)
- throws IOException;
public MappedByteBuffer map (FileChannel.MapMode mode,
long position, long size)
@@ -291,7 +320,7 @@ public final class FileChannelImpl extends FileChannel
if (position < 0 || size < 0 || size > Integer.MAX_VALUE)
throw new IllegalArgumentException ("position: " + position
+ ", size: " + size);
- return mapImpl(nmode, position, (int) size);
+ return ch.map(nmode, position, (int) size);
}
/**
@@ -302,11 +331,9 @@ public final class FileChannelImpl extends FileChannel
if (!isOpen ())
throw new ClosedChannelException ();
- force ();
+ ch.flush(metaData);
}
- private native void force ();
-
// like transferTo, but with a count of less than 2Gbytes
private int smallTransferTo (long position, int count,
WritableByteChannel target)
@@ -453,7 +480,7 @@ public final class FileChannelImpl extends FileChannel
try
{
begin();
- boolean lockable = lock(position, size, shared, false);
+ boolean lockable = ch.lock(position, size, shared, false);
completed = true;
return (lockable
? new FileLockImpl(this, position, size, shared)
@@ -464,14 +491,6 @@ public final class FileChannelImpl extends FileChannel
end(completed);
}
}
-
- /** Try to acquire a lock at the given position and size.
- * On success return true.
- * If wait as specified, block until we can get it.
- * Otherwise return false.
- */
- private native boolean lock(long position, long size,
- boolean shared, boolean wait) throws IOException;
public FileLock lock (long position, long size, boolean shared)
throws IOException
@@ -481,7 +500,7 @@ public final class FileChannelImpl extends FileChannel
boolean completed = false;
try
{
- boolean lockable = lock(position, size, shared, true);
+ boolean lockable = ch.lock(position, size, shared, true);
completed = true;
return (lockable
? new FileLockImpl(this, position, size, shared)
@@ -537,17 +556,17 @@ public final class FileChannelImpl extends FileChannel
public String toString()
{
- return (this.getClass()
- + "[fd=" + fd
- + ",mode=" + mode + ","
- + description + "]");
+ return (super.toString()
+ + "[ fd: " + ch.getState()
+ + "; mode: " + Integer.toOctalString(mode)
+ + "; " + description + " ]");
}
/**
* @return The native file descriptor.
- */
+ * /
public int getNativeFD()
{
return fd;
- }
+ }*/
}
diff --git a/gnu/java/nio/FileLockImpl.java b/gnu/java/nio/FileLockImpl.java
index 673ca2522..768906ce9 100644
--- a/gnu/java/nio/FileLockImpl.java
+++ b/gnu/java/nio/FileLockImpl.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package gnu.java.nio;
-import gnu.java.nio.channels.FileChannelImpl;
-
import java.io.IOException;
import java.nio.channels.FileLock;
diff --git a/gnu/java/nio/KqueueSelectionKeyImpl.java b/gnu/java/nio/KqueueSelectionKeyImpl.java
new file mode 100644
index 000000000..2f93c50cc
--- /dev/null
+++ b/gnu/java/nio/KqueueSelectionKeyImpl.java
@@ -0,0 +1,189 @@
+/* KqueueSelectionKeyImpl.java -- selection key for kqueue/kevent.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.AbstractSelectionKey;
+
+/**
+ * @author Casey Marshall (csm@gnu.org)
+ */
+public class KqueueSelectionKeyImpl extends AbstractSelectionKey
+{
+ int interestOps;
+ int readyOps;
+ int activeOps = 0;
+ int key;
+ int fd;
+
+ /** The selector we were created for. */
+ private final KqueueSelectorImpl selector;
+
+ /** The channel we are attached to. */
+ private final SelectableChannel channel;
+
+ private final VMChannelOwner natChannel;
+
+ public KqueueSelectionKeyImpl(KqueueSelectorImpl selector,
+ SelectableChannel channel)
+ {
+ this.selector = selector;
+ this.channel = channel;
+ natChannel = (VMChannelOwner) channel;
+ interestOps = 0;
+ readyOps = 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#channel()
+ */
+ //@Override
+ public SelectableChannel channel()
+ {
+ return channel;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#interestOps()
+ */
+ //@Override
+ public int interestOps()
+ {
+ return interestOps;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#interestOps(int)
+ */
+ //@Override
+ public SelectionKey interestOps(int ops)
+ {
+ if (!isValid())
+ throw new IllegalStateException("key is invalid");
+ if ((ops & ~channel.validOps()) != 0)
+ throw new IllegalArgumentException("channel does not support all operations");
+
+ selector.setInterestOps(this, ops);
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#readyOps()
+ */
+ //@Override
+ public int readyOps()
+ {
+ return readyOps;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.SelectionKey#selector()
+ */
+ //@Override
+ public Selector selector()
+ {
+ return selector;
+ }
+
+ public String toString()
+ {
+ if (!isValid())
+ return super.toString() + " [ fd: " + fd + " <<invalid>> ]";
+ return super.toString() + " [ fd: " + fd + " interest ops: {"
+ + ((interestOps & OP_ACCEPT) != 0 ? " OP_ACCEPT" : "")
+ + ((interestOps & OP_CONNECT) != 0 ? " OP_CONNECT" : "")
+ + ((interestOps & OP_READ) != 0 ? " OP_READ" : "")
+ + ((interestOps & OP_WRITE) != 0 ? " OP_WRITE" : "")
+ + " }; ready ops: {"
+ + ((readyOps & OP_ACCEPT) != 0 ? " OP_ACCEPT" : "")
+ + ((readyOps & OP_CONNECT) != 0 ? " OP_CONNECT" : "")
+ + ((readyOps & OP_READ) != 0 ? " OP_READ" : "")
+ + ((readyOps & OP_WRITE) != 0 ? " OP_WRITE" : "")
+ + " } ]";
+ }
+
+ public int hashCode()
+ {
+ return fd;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof KqueueSelectionKeyImpl))
+ return false;
+ KqueueSelectionKeyImpl that = (KqueueSelectionKeyImpl) o;
+ return that.fd == this.fd && that.channel.equals(this.channel);
+ }
+
+
+ boolean isReadActive()
+ {
+ return (activeOps & (OP_READ | OP_ACCEPT)) != 0;
+ }
+
+ boolean isReadInterested()
+ {
+ return (interestOps & (OP_READ | OP_ACCEPT)) != 0;
+ }
+
+ boolean isWriteActive()
+ {
+ return (activeOps & (OP_WRITE | OP_CONNECT)) != 0;
+ }
+
+ boolean isWriteInterested()
+ {
+ return (interestOps & (OP_WRITE | OP_CONNECT)) != 0;
+ }
+
+ boolean needCommitRead()
+ {
+ return isReadActive() == (!isReadInterested());
+ }
+
+ boolean needCommitWrite()
+ {
+ return isWriteActive() == (!isWriteInterested());
+ }
+}
diff --git a/gnu/java/nio/KqueueSelectorImpl.java b/gnu/java/nio/KqueueSelectorImpl.java
new file mode 100644
index 000000000..eed86119c
--- /dev/null
+++ b/gnu/java/nio/KqueueSelectorImpl.java
@@ -0,0 +1,524 @@
+/* KqueueSelectorImpl.java -- Selector for systems with kqueue event notification.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.ClosedSelectorException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.AbstractSelectableChannel;
+import java.nio.channels.spi.AbstractSelector;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A {@link Selector} implementation that uses the <code>kqueue</code>
+ * event notification facility.
+ *
+ * @author Casey Marshall (csm@gnu.org)
+ */
+public class KqueueSelectorImpl extends AbstractSelector
+{
+ private static final int sizeof_struct_kevent;
+ private static final int MAX_DOUBLING_CAPACITY = 16384;
+ private static final int CAP_INCREMENT = 1024;
+ private static final int INITIAL_CAPACITY;
+
+ static
+ {
+ try
+ {
+ System.loadLibrary("javanio");
+ }
+ catch (Exception x)
+ {
+ x.printStackTrace();
+ }
+
+ if (kqueue_supported ())
+ sizeof_struct_kevent = sizeof_struct_kevent();
+ else
+ sizeof_struct_kevent = -1;
+ INITIAL_CAPACITY = 16 * sizeof_struct_kevent;
+ }
+
+ /**
+ * Tell if kqueue-based selectors are supported on this system.
+ *
+ * @return True if this system has kqueue support, and support for it was
+ * compiled in to Classpath.
+ */
+ public static native boolean kqueue_supported();
+
+ /* Our native file descriptor. */
+ private int kq;
+
+ private HashMap/*<Integer,KqueueSelectionKeyImpl>*/ keys;
+ private HashSet/*<KqueueSelectionKeyImpl>*/ selected;
+ private Thread blockedThread;
+ private ByteBuffer events;
+
+ private static final int OP_ACCEPT = SelectionKey.OP_ACCEPT;
+ private static final int OP_CONNECT = SelectionKey.OP_CONNECT;
+ private static final int OP_READ = SelectionKey.OP_READ;
+ private static final int OP_WRITE = SelectionKey.OP_WRITE;
+
+ public KqueueSelectorImpl(SelectorProvider provider) throws IOException
+ {
+ super(provider);
+ kq = implOpen();
+ keys = new HashMap/*<KqueueSelectionKeyImpl>*/();
+ events = ByteBuffer.allocateDirect(INITIAL_CAPACITY);
+ }
+
+ protected void implCloseSelector() throws IOException
+ {
+ implClose(kq);
+ kq = -1;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#keys()
+ */
+ public Set keys()
+ {
+ if (!isOpen())
+ throw new ClosedSelectorException();
+
+ return new HashSet(keys.values());
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#select()
+ */
+ public int select() throws IOException
+ {
+ return doSelect(-1);
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#select(long)
+ */
+ public int select(long timeout) throws IOException
+ {
+ if (timeout == 0)
+ timeout = -1;
+ return doSelect(timeout);
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#selectedKeys()
+ */
+ public Set selectedKeys()
+ {
+ if (!isOpen())
+ throw new ClosedSelectorException();
+
+ return selected;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#selectNow()
+ */
+ public int selectNow() throws IOException
+ {
+ return doSelect(0);
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.Selector#wakeup()
+ */
+ public Selector wakeup()
+ {
+ if (blockedThread != null)
+ blockedThread.interrupt();
+ return this;
+ }
+
+ public String toString()
+ {
+ return super.toString() + " [ fd: " + kq + " ]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof KqueueSelectorImpl))
+ return false;
+
+ return ((KqueueSelectorImpl) o).kq == kq;
+ }
+
+ int doSelect(long timeout) throws IOException
+ {
+ Set cancelled = cancelledKeys();
+ synchronized (cancelled)
+ {
+ synchronized (keys)
+ {
+ for (Iterator it = cancelled.iterator(); it.hasNext(); )
+ {
+ KqueueSelectionKeyImpl key = (KqueueSelectionKeyImpl) it.next();
+ key.interestOps = 0;
+ }
+
+ int events_size = (2 * sizeof_struct_kevent) * keys.size();
+ int num_events = 0;
+
+ for (Iterator it = keys.entrySet().iterator(); it.hasNext(); )
+ {
+ Map.Entry e = (Map.Entry) it.next();
+ KqueueSelectionKeyImpl key = (KqueueSelectionKeyImpl) e.getValue();
+
+ SelectableChannel ch = key.channel();
+ if (ch instanceof VMChannelOwner)
+ {
+ if (!((VMChannelOwner) ch).getVMChannel().getState().isValid())
+ {
+ // closed channel; removed from kqueue automatically.
+ it.remove();
+ continue;
+ }
+ }
+
+ // If this key is registering a read filter, add it to the buffer.
+ if (key.needCommitRead())
+ {
+ kevent_set(events, num_events, key.fd,
+ key.interestOps & (OP_READ | OP_ACCEPT),
+ key.activeOps & (OP_READ | OP_ACCEPT), key.key);
+ num_events++;
+ }
+
+ // If this key is registering a write filter, add it to the buffer.
+ if (key.needCommitWrite())
+ {
+ kevent_set(events, num_events, key.fd,
+ key.interestOps & (OP_WRITE | OP_CONNECT),
+ key.activeOps & (OP_WRITE | OP_CONNECT), key.key);
+ num_events++;
+ }
+ }
+ events.rewind().limit(events.capacity());
+
+ //System.out.println("dump of keys to select:");
+ //dump_selection_keys(events.duplicate());
+
+ int n = 0;
+ try
+ {
+ //System.out.println("[" + kq + "] kevent enter selecting from " + keys.size());
+ begin();
+ blockedThread = Thread.currentThread();
+ if (blockedThread.isInterrupted())
+ timeout = 0;
+ n = kevent(kq, events, num_events,
+ events.capacity() / sizeof_struct_kevent, timeout);
+ }
+ finally
+ {
+ end();
+ blockedThread = null;
+ Thread.interrupted();
+ //System.out.println("[" + kq + "kevent exit selected " + n);
+ }
+
+ //System.out.println("dump of keys selected:");
+ //dump_selection_keys((ByteBuffer) events.duplicate().limit(n * sizeof_struct_kevent));
+
+ // Commit the operations we've just added in the call to kevent.
+ for (Iterator it = keys.values().iterator(); it.hasNext(); )
+ {
+ KqueueSelectionKeyImpl key = (KqueueSelectionKeyImpl) it.next();
+ key.activeOps = key.interestOps;
+ }
+
+ selected = new HashSet/*<KqueueSelectionKeyImpl>*/(n);
+ int x = 0;
+ for (int i = 0; i < n; i++)
+ {
+ events.position(x).limit(x + sizeof_struct_kevent);
+ x += sizeof_struct_kevent;
+ int y = fetch_key(events.slice());
+ KqueueSelectionKeyImpl key =
+ (KqueueSelectionKeyImpl) keys.get(new Integer(y));
+
+ if (key == null)
+ {
+ System.out.println("WARNING! no key found for selected key " + y);
+ continue;
+ }
+ // Keys that have been cancelled may be returned here; don't
+ // add them to the selected set.
+ if (!key.isValid())
+ continue;
+ key.readyOps = ready_ops(events.slice(), key.interestOps);
+ selected.add(key);
+ }
+
+ // Finally, remove the cancelled keys.
+ for (Iterator it = cancelled.iterator(); it.hasNext(); )
+ {
+ KqueueSelectionKeyImpl key = (KqueueSelectionKeyImpl) it.next();
+ keys.remove(new Integer(key.key));
+ deregister(key);
+ it.remove();
+ }
+
+ reallocateBuffer();
+
+ return selected.size();
+ }
+ }
+ }
+
+ protected SelectionKey register(AbstractSelectableChannel channel,
+ int interestOps,
+ Object attachment)
+ {
+ int native_fd = -1;
+ try
+ {
+ if (channel instanceof VMChannelOwner)
+ native_fd = ((VMChannelOwner) channel).getVMChannel()
+ .getState().getNativeFD();
+ else
+ throw new IllegalArgumentException("cannot handle channel type " +
+ channel.getClass().getName());
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalArgumentException("channel is closed or invalid");
+ }
+
+ KqueueSelectionKeyImpl result = new KqueueSelectionKeyImpl(this, channel);
+ result.interestOps = interestOps;
+ result.attach(attachment);
+ result.fd = native_fd;
+ result.key = System.identityHashCode(result);
+ synchronized (keys)
+ {
+ while (keys.containsKey(new Integer(result.key)))
+ result.key++;
+ keys.put(new Integer(result.key), result);
+ reallocateBuffer();
+ }
+ return result;
+ }
+
+ void setInterestOps(KqueueSelectionKeyImpl key, int ops)
+ {
+ synchronized (keys)
+ {
+ key.interestOps = ops;
+ }
+ }
+
+ /**
+ * Reallocate the events buffer. This is the destination buffer for
+ * events returned by kevent. This method will:
+ *
+ * * Grow the buffer if there is insufficent space for all registered
+ * events.
+ * * Shrink the buffer if it is more than twice the size needed.
+ *
+ */
+ private void reallocateBuffer()
+ {
+ synchronized (keys)
+ {
+ if (events.capacity() < (2 * sizeof_struct_kevent) * keys.size())
+ {
+ int cap = events.capacity();
+ if (cap >= MAX_DOUBLING_CAPACITY)
+ cap += CAP_INCREMENT;
+ else
+ cap = cap << 1;
+
+ events = ByteBuffer.allocateDirect(cap);
+ }
+ else if (events.capacity() > 4 * (sizeof_struct_kevent) * keys.size() + 1
+ && events.capacity() > INITIAL_CAPACITY)
+ {
+ int cap = events.capacity();
+ cap = cap >>> 1;
+ events = ByteBuffer.allocateDirect(cap);
+ }
+ }
+ }
+
+ //synchronized void updateOps(KqueueSelectionKeyImpl key, int interestOps)
+ //{
+ // updateOps(key, interestOps, 0, false);
+ //}
+
+ /*void updateOps(KqueueSelectionKeyImpl key, int interestOps,
+ int activeOps, int fd)
+ {
+ //System.out.println(">> updating kqueue selection key:");
+ //dump_selection_keys(key.nstate.duplicate());
+ //System.out.println("<<");
+ synchronized (keys)
+ {
+ kevent_set(key.nstate, fd, interestOps, activeOps, key.key);
+ }
+ //System.out.println(">> updated kqueue selection key:");
+ //dump_selection_keys(key.nstate.duplicate());
+ //System.out.println("<<");
+ }*/
+
+ private void dump_selection_keys(ByteBuffer keys)
+ {
+ // WARNING! This method is not guaranteed to be portable! This works
+ // on darwin/x86, but the sizeof and offsetof these fields may be
+ // different on other platforms!
+ int i = 0;
+ keys.order(ByteOrder.nativeOrder());
+ while (keys.hasRemaining())
+ {
+ System.out.println("struct kevent { ident: "
+ + Integer.toString(keys.getInt())
+ + " filter: "
+ + Integer.toHexString(keys.getShort() & 0xFFFF)
+ + " flags: "
+ + Integer.toHexString(keys.getShort() & 0xFFFF)
+ + " fflags: "
+ + Integer.toHexString(keys.getInt())
+ + " data: "
+ + Integer.toHexString(keys.getInt())
+ + " udata: "
+ + Integer.toHexString(keys.getInt())
+ + " }");
+ }
+ }
+
+ /**
+ * Return the size of a <code>struct kevent</code> on this system.
+ *
+ * @return The size of <code>struct kevent</code>.
+ */
+ private static native int sizeof_struct_kevent();
+
+ /**
+ * Opens a kqueue descriptor.
+ *
+ * @return The new kqueue descriptor.
+ * @throws IOException If opening fails.
+ */
+ private static native int implOpen() throws IOException;
+
+ /**
+ * Closes the kqueue file descriptor.
+ *
+ * @param kq The kqueue file descriptor.
+ * @throws IOException
+ */
+ private static native void implClose(int kq) throws IOException;
+
+ /**
+ * Initialize the specified native state for the given interest ops.
+ *
+ * @param nstate The native state structures; in this buffer should be
+ * the <code>struct kevent</code>s created for a key.
+ * @param fd The file descriptor. If 0, the native FD is unmodified.
+ * @param interestOps The operations to enable.
+ * @param key A unique key that will reference the associated key later.
+ * @param delete Set to true if this event should be deleted from the
+ * kqueue (if false, this event is added/updated).
+ */
+ private static native void kevent_set(ByteBuffer nstate, int i, int fd,
+ int interestOps, int activeOps, int key);
+
+ /**
+ * Poll for events. The source events are stored in <code>events</code>,
+ * which is also where polled events will be placed.
+ *
+ * @param events The events to poll. This buffer is also the destination
+ * for events read from the queue.
+ * @param nevents The number of events to poll (that is, the number of
+ * events in the <code>events</code> buffer).
+ * @param nout The maximum number of events that may be returned.
+ * @param timeout The timeout. A timeout of -1 returns immediately; a timeout
+ * of 0 waits indefinitely.
+ * @return The number of events read.
+ */
+ private static native int kevent(int kq, ByteBuffer events, int nevents,
+ int nout, long timeout);
+
+ /**
+ * Fetch a polled key from a native state buffer. For each kevent key we
+ * create, we put the native state info (one or more <code>struct
+ * kevent</code>s) in that key's {@link KqueueSelectionKeyImpl#nstate}
+ * buffer, and place the pointer of the key in the <code>udata</code> field
+ * of that structure. This method fetches that pointer from the given
+ * buffer (assumed to be a <code>struct kqueue</code>) and returns it.
+ *
+ * @param nstate The buffer containing the <code>struct kqueue</code> to read.
+ * @return The key object.
+ */
+ private static native int fetch_key(ByteBuffer nstate);
+
+ /**
+ * Fetch the ready ops of the associated native state. That is, this
+ * inspects the first argument as a <code>struct kevent</code>, looking
+ * at its operation (the input is assumed to have been returned via a
+ * previous call to <code>kevent</code>), and translating that to the
+ * appropriate Java bit set, based on the second argument.
+ *
+ * @param nstate The native state.
+ * @param interestOps The enabled operations for the key.
+ * @return The bit set representing the ready operations.
+ */
+ private static native int ready_ops(ByteBuffer nstate, int interestOps);
+
+ /**
+ * Check if kevent returned EV_EOF for a selection key.
+ *
+ * @param nstate The native state.
+ * @return True if the kevent call returned EOF.
+ */
+ private static native boolean check_eof(ByteBuffer nstate);
+}
diff --git a/gnu/java/nio/NIOSocket.java b/gnu/java/nio/NIOSocket.java
index 4d812bf44..060a3a89c 100644
--- a/gnu/java/nio/NIOSocket.java
+++ b/gnu/java/nio/NIOSocket.java
@@ -48,30 +48,33 @@ import java.nio.channels.SocketChannel;
*/
public final class NIOSocket extends Socket
{
- private PlainSocketImpl impl;
private SocketChannelImpl channel;
- protected NIOSocket (PlainSocketImpl impl, SocketChannelImpl channel)
+ protected NIOSocket (SocketChannelImpl channel)
throws IOException
{
- super (impl);
- this.impl = impl;
+ super (new NIOSocketImpl(channel));
this.channel = channel;
}
- public final PlainSocketImpl getPlainSocketImpl()
- {
- return impl;
- }
+ //public final PlainSocketImpl getPlainSocketImpl()
+ //{
+ // return impl;
+ //}
- final void setChannel (SocketChannelImpl channel)
- {
- this.impl = channel.getPlainSocketImpl();
- this.channel = channel;
- }
+ //final void setChannel (SocketChannelImpl channel)
+ //{
+ // this.impl = channel.getPlainSocketImpl();
+ // this.channel = channel;
+ //}
public final SocketChannel getChannel()
{
return channel;
}
+
+ public boolean isConnected()
+ {
+ return channel.isConnected();
+ }
}
diff --git a/gnu/java/nio/NIOSocketImpl.java b/gnu/java/nio/NIOSocketImpl.java
new file mode 100644
index 000000000..4b26561a2
--- /dev/null
+++ b/gnu/java/nio/NIOSocketImpl.java
@@ -0,0 +1,110 @@
+/* NIOSocketImpl.java -- subclass of PlainSocketImpl for NIO.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+import gnu.java.net.PlainSocketImpl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+
+/**
+ * @author Casey Marshall (csm@gnu.org)
+ */
+public class NIOSocketImpl extends PlainSocketImpl
+{
+
+ private final SocketChannelImpl channel;
+
+ NIOSocketImpl(SocketChannelImpl channel) throws IOException
+ {
+ this.channel = channel;
+ impl.getState().setChannelFD(channel.getVMChannel().getState());
+ }
+
+ /* (non-Javadoc)
+ * @see java.net.SocketImpl#getInetAddress()
+ */
+ //@Override
+ protected InetAddress getInetAddress()
+ {
+ try
+ {
+ return channel.getVMChannel().getPeerAddress().getAddress();
+ }
+ catch (IOException ioe)
+ {
+ return null;
+ }
+ catch (NullPointerException npe)
+ {
+ // Socket is not connected yet.
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.net.SocketImpl#getPort()
+ */
+ //@Override
+ protected int getPort()
+ {
+ try
+ {
+ return channel.getVMChannel().getPeerAddress().getPort();
+ }
+ catch (IOException ioe)
+ {
+ return -1;
+ }
+ catch (NullPointerException npe)
+ {
+ // Socket is not connected yet.
+ return -1;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see gnu.java.net.PlainSocketImpl#create(boolean)
+ */
+ //@Override
+ protected synchronized void create(boolean stream)
+ {
+ // Ignored; the socket has already been created.
+ }
+}
diff --git a/gnu/java/nio/PipeImpl.java b/gnu/java/nio/PipeImpl.java
index cccaa3988..8a95b9622 100644
--- a/gnu/java/nio/PipeImpl.java
+++ b/gnu/java/nio/PipeImpl.java
@@ -46,22 +46,21 @@ import java.nio.channels.spi.SelectorProvider;
class PipeImpl extends Pipe
{
public static final class SourceChannelImpl extends Pipe.SourceChannel
+ implements VMChannelOwner
{
- private int native_fd;
private VMChannel vmch;
public SourceChannelImpl (SelectorProvider selectorProvider,
- int native_fd)
+ VMChannel channel)
{
super (selectorProvider);
- this.native_fd = native_fd;
- vmch = VMChannel.getVMChannel(this);
+ vmch = channel;
}
protected final void implCloseSelectableChannel()
throws IOException
{
- throw new Error ("Not implemented");
+ vmch.close();
}
protected void implConfigureBlocking (boolean blocking)
@@ -94,30 +93,29 @@ class PipeImpl extends Pipe
return vmch.readScattering(srcs, offset, len);
}
-
- public final int getNativeFD()
+
+ public VMChannel getVMChannel()
{
- return native_fd;
+ return vmch;
}
}
public static final class SinkChannelImpl extends Pipe.SinkChannel
+ implements VMChannelOwner
{
- private int native_fd;
private VMChannel vmch;
public SinkChannelImpl (SelectorProvider selectorProvider,
- int native_fd)
+ VMChannel channel)
{
super (selectorProvider);
- this.native_fd = native_fd;
- vmch = VMChannel.getVMChannel(this);
+ vmch = channel;
}
protected final void implCloseSelectableChannel()
throws IOException
{
- throw new Error ("Not implemented");
+ vmch.close();
}
protected final void implConfigureBlocking (boolean blocking)
@@ -149,10 +147,10 @@ class PipeImpl extends Pipe
return vmch.writeGathering(srcs, offset, len);
}
-
- public final int getNativeFD()
+
+ public VMChannel getVMChannel()
{
- return native_fd;
+ return vmch;
}
}
@@ -163,7 +161,9 @@ class PipeImpl extends Pipe
throws IOException
{
super();
- VMPipe.init (this, provider);
+ VMChannel[] pipe = VMPipe.pipe();
+ sink = new SinkChannelImpl(provider, pipe[0]);
+ source = new SourceChannelImpl(provider, pipe[1]);
}
public Pipe.SinkChannel sink()
diff --git a/gnu/java/nio/SelectionKeyImpl.java b/gnu/java/nio/SelectionKeyImpl.java
index 8745377c5..c927f3196 100644
--- a/gnu/java/nio/SelectionKeyImpl.java
+++ b/gnu/java/nio/SelectionKeyImpl.java
@@ -106,5 +106,6 @@ public abstract class SelectionKeyImpl extends AbstractSelectionKey
return impl;
}
+ /* @deprecated */
public abstract int getNativeFD();
}
diff --git a/gnu/java/nio/SelectorProviderImpl.java b/gnu/java/nio/SelectorProviderImpl.java
index 47521107e..56167b69e 100644
--- a/gnu/java/nio/SelectorProviderImpl.java
+++ b/gnu/java/nio/SelectorProviderImpl.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package gnu.java.nio;
+
+import gnu.classpath.SystemProperties;
+
import java.io.IOException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.Pipe;
@@ -47,6 +50,11 @@ import java.nio.channels.spi.SelectorProvider;
public class SelectorProviderImpl extends SelectorProvider
{
+ private static final String SELECTOR_IMPL_KQUEUE = "kqueue";
+ private static final String SELECTOR_IMPL_EPOLL = "epoll";
+ private static final String SELECTOR_IMPL = "gnu.java.nio.selectorImpl";
+ private static boolean epoll_failed = false;
+
public SelectorProviderImpl ()
{
}
@@ -66,6 +74,35 @@ public class SelectorProviderImpl extends SelectorProvider
public AbstractSelector openSelector ()
throws IOException
{
+ String selectorImpl = "default";
+ if (KqueueSelectorImpl.kqueue_supported())
+ selectorImpl = SELECTOR_IMPL_KQUEUE;
+ if (EpollSelectorImpl.epoll_supported() && !epoll_failed)
+ selectorImpl = SELECTOR_IMPL_EPOLL;
+ selectorImpl = SystemProperties.getProperty(SELECTOR_IMPL, selectorImpl);
+
+ if (selectorImpl.equals(SELECTOR_IMPL_KQUEUE))
+ return new KqueueSelectorImpl(this);
+
+ if (selectorImpl.equals(SELECTOR_IMPL_EPOLL))
+ {
+ // We jump through these hoops because even though epoll may look
+ // like it's available (sys/epoll.h exists, and you can link against
+ // all the epoll functions) it may not be available in the kernel
+ // (especially 2.4 kernels), meaning you will get ENOSYS at run time.
+ //
+ // Madness!
+ try
+ {
+ return new EpollSelectorImpl(this);
+ }
+ catch (InternalError e)
+ {
+ // epoll_create throws this on ENOSYS.
+ epoll_failed = true;
+ }
+ }
+
return new SelectorImpl (this);
}
diff --git a/gnu/java/nio/ServerSocketChannelImpl.java b/gnu/java/nio/ServerSocketChannelImpl.java
index c538ea802..1e8e0901d 100644
--- a/gnu/java/nio/ServerSocketChannelImpl.java
+++ b/gnu/java/nio/ServerSocketChannelImpl.java
@@ -48,7 +48,9 @@ import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
public final class ServerSocketChannelImpl extends ServerSocketChannel
+ implements VMChannelOwner
{
+ private VMChannel channel;
private NIOServerSocket serverSocket;
private boolean connected;
@@ -56,13 +58,15 @@ public final class ServerSocketChannelImpl extends ServerSocketChannel
throws IOException
{
super (provider);
- serverSocket = new NIOServerSocket (this);
+ serverSocket = new NIOServerSocket(this);
+ channel = serverSocket.getPlainSocketImpl().getVMChannel();
configureBlocking(true);
}
+ // XXX do we need this?
public void finalizer()
{
- if (connected)
+ if (channel.getState().isValid())
{
try
{
@@ -77,12 +81,12 @@ public final class ServerSocketChannelImpl extends ServerSocketChannel
protected void implCloseSelectableChannel () throws IOException
{
connected = false;
- serverSocket.close();
+ channel.close();
}
protected void implConfigureBlocking (boolean blocking) throws IOException
{
- serverSocket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT);
+ channel.setBlocking(blocking);
}
public SocketChannel accept () throws IOException
@@ -98,27 +102,28 @@ public final class ServerSocketChannelImpl extends ServerSocketChannel
try
{
begin();
- serverSocket.getPlainSocketImpl().setInChannelOperation(true);
- // indicate that a channel is initiating the accept operation
- // so that the socket ignores the fact that we might be in
- // non-blocking mode.
- NIOSocket socket = (NIOSocket) serverSocket.accept();
- completed = true;
- return socket.getChannel();
- }
- catch (SocketTimeoutException e)
- {
- return null;
+ VMChannel client = channel.accept();
+ if (client == null)
+ return null;
+ else
+ {
+ completed = true;
+ return new SocketChannelImpl(provider(), client, false);
+ }
}
finally
{
- serverSocket.getPlainSocketImpl().setInChannelOperation(false);
end (completed);
}
}
- public ServerSocket socket ()
+ public ServerSocket socket()
{
return serverSocket;
}
+
+ public VMChannel getVMChannel()
+ {
+ return channel;
+ }
}
diff --git a/gnu/java/nio/ServerSocketChannelSelectionKey.java b/gnu/java/nio/ServerSocketChannelSelectionKey.java
index d00c2b748..5b510cb6f 100644
--- a/gnu/java/nio/ServerSocketChannelSelectionKey.java
+++ b/gnu/java/nio/ServerSocketChannelSelectionKey.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.nio;
+import java.io.IOException;
import java.nio.channels.spi.AbstractSelectableChannel;
public final class ServerSocketChannelSelectionKey
@@ -49,10 +50,16 @@ public final class ServerSocketChannelSelectionKey
super (channel, selector);
}
+ // FIXME don't use file descriptor integers
public int getNativeFD()
{
- NIOServerSocket socket =
- (NIOServerSocket) ((ServerSocketChannelImpl) ch).socket();
- return socket.getPlainSocketImpl().getNativeFD();
+ try
+ {
+ return ((ServerSocketChannelImpl) ch).getVMChannel().getState().getNativeFD();
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalStateException(ioe);
+ }
}
}
diff --git a/gnu/java/nio/SocketChannelImpl.java b/gnu/java/nio/SocketChannelImpl.java
index 680eba2f9..1c563ac09 100644
--- a/gnu/java/nio/SocketChannelImpl.java
+++ b/gnu/java/nio/SocketChannelImpl.java
@@ -39,15 +39,20 @@ exception statement from your version. */
package gnu.java.nio;
import gnu.java.net.PlainSocketImpl;
+import gnu.java.net.VMPlainSocketImpl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
+import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
+import java.nio.ReadOnlyBufferException;
import java.nio.channels.AlreadyConnectedException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ConnectionPendingException;
@@ -61,28 +66,57 @@ import java.nio.channels.UnsupportedAddressTypeException;
import java.nio.channels.spi.SelectorProvider;
public final class SocketChannelImpl extends SocketChannel
+ implements VMChannelOwner
{
- private PlainSocketImpl impl;
+ private VMChannel channel;
+ //private PlainSocketImpl impl;
private NIOSocket socket;
private boolean connectionPending;
+ private boolean connected;
+ private InetSocketAddress connectAddress;
+
+ public SocketChannelImpl(boolean create) throws IOException
+ {
+ // XXX consider adding security check; this is used by
+ // PlainSocketImpl.
+ this(new SelectorProviderImpl(), create);
+ }
+
+ public SocketChannelImpl(VMChannel channel) throws IOException
+ {
+ this(new SelectorProviderImpl(), channel, false);
+ }
+
+ SocketChannelImpl(SelectorProvider provider) throws IOException
+ {
+ this(provider, true);
+ }
- SocketChannelImpl (SelectorProvider provider)
+ SocketChannelImpl(SelectorProvider provider, boolean create)
+ throws IOException
+ {
+ this(provider, new VMChannel(), create);
+ }
+
+ SocketChannelImpl(SelectorProvider provider, VMChannel channel, boolean create)
throws IOException
{
super (provider);
- impl = new PlainSocketImpl();
- socket = new NIOSocket (impl, this);
+ this.channel = channel;
+ if (create)
+ channel.initSocket(true);
+ socket = new NIOSocket(this);
configureBlocking(true);
}
- SocketChannelImpl (SelectorProvider provider,
+ /*SocketChannelImpl (SelectorProvider provider,
NIOSocket socket)
throws IOException
{
super (provider);
this.impl = socket.getPlainSocketImpl();
this.socket = socket;
- }
+ }*/
public void finalizer()
{
@@ -98,23 +132,28 @@ public final class SocketChannelImpl extends SocketChannel
}
}
- PlainSocketImpl getPlainSocketImpl()
- {
- return impl;
- }
+ //PlainSocketImpl getPlainSocketImpl()
+ //{
+ // return null; // XXX
+ //}
- protected void implCloseSelectableChannel () throws IOException
+ protected void implCloseSelectableChannel() throws IOException
{
- socket.close();
+ channel.close();
}
protected void implConfigureBlocking (boolean blocking) throws IOException
{
- socket.setSoTimeout (blocking ? 0 : NIOConstants.DEFAULT_TIMEOUT);
+ channel.setBlocking(blocking);
}
public boolean connect (SocketAddress remote) throws IOException
{
+ return connect(remote, 0);
+ }
+
+ public boolean connect (SocketAddress remote, int timeout) throws IOException
+ {
if (!isOpen())
throw new ClosedChannelException();
@@ -126,79 +165,52 @@ public final class SocketChannelImpl extends SocketChannel
if (!(remote instanceof InetSocketAddress))
throw new UnsupportedAddressTypeException();
+
+ connectAddress = (InetSocketAddress) remote;
- if (((InetSocketAddress) remote).isUnresolved())
+ if (connectAddress.isUnresolved())
throw new UnresolvedAddressException();
- try
- {
- socket.getPlainSocketImpl().setInChannelOperation(true);
- // indicate that a channel is initiating the accept operation
- // so that the socket ignores the fact that we might be in
- // non-blocking mode.
-
- if (isBlocking())
- {
- // Do blocking connect.
- socket.connect (remote);
- return true;
- }
-
- // Do non-blocking connect.
- try
- {
- socket.connect (remote, NIOConstants.DEFAULT_TIMEOUT);
- return true;
- }
- catch (SocketTimeoutException e)
- {
- connectionPending = true;
- return false;
- }
- }
- finally
- {
- socket.getPlainSocketImpl().setInChannelOperation(false);
- }
+ connected = channel.connect(connectAddress, timeout);
+ connectionPending = !connected;
+ return connected;
}
-
- public boolean finishConnect ()
+
+ public boolean finishConnect()
throws IOException
{
if (!isOpen())
throw new ClosedChannelException();
-
- if (!isConnected() && !connectionPending)
- throw new NoConnectionPendingException();
-
- if (isConnected())
- return true;
- // FIXME: Handle blocking/non-blocking mode.
-
- Selector selector = provider().openSelector();
- register(selector, SelectionKey.OP_CONNECT);
-
- if (isBlocking())
+ InetSocketAddress remote = channel.getPeerAddress();
+ if (remote != null)
{
- selector.select(); // blocking until channel is connected.
connectionPending = false;
return true;
}
-
- int ready = selector.selectNow(); // non-blocking
- if (ready == 1)
- {
- connectionPending = false;
- return true;
- }
-
+
+ if (!connectionPending)
+ throw new NoConnectionPendingException();
+
return false;
}
- public boolean isConnected ()
+ public boolean isConnected()
{
- return socket.isConnected();
+ // Wait until finishConnect is called before transitioning to
+ // connected.
+ if (connectionPending)
+ return false;
+ try
+ {
+ InetSocketAddress remote = channel.getPeerAddress();
+ return remote != null;
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace(System.out);
+ return false;
+ }
}
public boolean isConnectionPending ()
@@ -216,52 +228,7 @@ public final class SocketChannelImpl extends SocketChannel
if (!isConnected())
throw new NotYetConnectedException();
- byte[] data;
- int offset = 0;
- InputStream input = socket.getInputStream();
- int available = input.available();
- int len = dst.remaining();
-
- if ((! isBlocking()) && available == 0)
- return 0;
-
- if (dst.hasArray())
- {
- offset = dst.arrayOffset() + dst.position();
- data = dst.array();
- }
- else
- {
- data = new byte [len];
- }
-
- int readBytes = 0;
- boolean completed = false;
-
- try
- {
- begin();
- socket.getPlainSocketImpl().setInChannelOperation(true);
- readBytes = input.read (data, offset, len);
- completed = true;
- }
- finally
- {
- end (completed);
- socket.getPlainSocketImpl().setInChannelOperation(false);
- }
-
- if (readBytes > 0)
- if (dst.hasArray())
- {
- dst.position (dst.position() + readBytes);
- }
- else
- {
- dst.put (data, offset, readBytes);
- }
-
- return readBytes;
+ return channel.read(dst);
}
public long read (ByteBuffer[] dsts, int offset, int length)
@@ -275,61 +242,19 @@ public final class SocketChannelImpl extends SocketChannel
|| (length < 0)
|| (length > (dsts.length - offset)))
throw new IndexOutOfBoundsException();
-
- long readBytes = 0;
-
- for (int index = offset; index < length; index++)
- readBytes += read (dsts [index]);
-
- return readBytes;
+
+ return channel.readScattering(dsts, offset, length);
}
- public int write (ByteBuffer src)
- throws IOException
+ public int write(ByteBuffer src) throws IOException
{
if (!isConnected())
throw new NotYetConnectedException();
-
- byte[] data;
- int offset = 0;
- int len = src.remaining();
-
- if (!src.hasArray())
- {
- data = new byte [len];
- src.get (data, 0, len);
- }
- else
- {
- offset = src.arrayOffset() + src.position();
- data = src.array();
- }
- OutputStream output = socket.getOutputStream();
- boolean completed = false;
-
- try
- {
- begin();
- socket.getPlainSocketImpl().setInChannelOperation(true);
- output.write (data, offset, len);
- completed = true;
- }
- finally
- {
- end (completed);
- socket.getPlainSocketImpl().setInChannelOperation(false);
- }
-
- if (src.hasArray())
- {
- src.position (src.position() + len);
- }
-
- return len;
+ return channel.write(src);
}
- public long write (ByteBuffer[] srcs, int offset, int length)
+ public long write(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
if (!isConnected())
@@ -340,12 +265,13 @@ public final class SocketChannelImpl extends SocketChannel
|| (length < 0)
|| (length > (srcs.length - offset)))
throw new IndexOutOfBoundsException();
-
- long writtenBytes = 0;
-
- for (int index = offset; index < length; index++)
- writtenBytes += write (srcs [index]);
- return writtenBytes;
+ return channel.writeGathering(srcs, offset, length);
+ }
+
+ public VMChannel getVMChannel()
+ {
+ // XXX security check?
+ return channel;
}
}
diff --git a/gnu/java/nio/SocketChannelSelectionKey.java b/gnu/java/nio/SocketChannelSelectionKey.java
index 75b4dfd87..9ceebdec9 100644
--- a/gnu/java/nio/SocketChannelSelectionKey.java
+++ b/gnu/java/nio/SocketChannelSelectionKey.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.nio;
+import java.io.IOException;
import java.nio.channels.spi.AbstractSelectableChannel;
public final class SocketChannelSelectionKey
@@ -49,10 +50,16 @@ public final class SocketChannelSelectionKey
super (channel, selector);
}
+ // FIXME don't use file descriptor integers
public int getNativeFD()
{
- NIOSocket socket =
- (NIOSocket) ((SocketChannelImpl) ch).socket();
- return socket.getPlainSocketImpl().getNativeFD();
+ try
+ {
+ return ((SocketChannelImpl) ch).getVMChannel().getState().getNativeFD();
+ }
+ catch (IOException ioe)
+ {
+ throw new IllegalStateException(ioe);
+ }
}
}
diff --git a/gnu/java/nio/SocketChannelSelectionKeyImpl.java b/gnu/java/nio/SocketChannelSelectionKeyImpl.java
index 30fb2dfba..31a96ed7d 100644
--- a/gnu/java/nio/SocketChannelSelectionKeyImpl.java
+++ b/gnu/java/nio/SocketChannelSelectionKeyImpl.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.java.nio;
+import java.io.IOException;
+
/**
* @author Michael Barker <mike@middlesoft.co.uk>
@@ -63,7 +65,14 @@ public class SocketChannelSelectionKeyImpl extends SelectionKeyImpl
*/
public int getNativeFD()
{
- return ch.getPlainSocketImpl().getNativeFD();
+ try
+ {
+ return ch.getVMChannel().getState().getNativeFD();
+ }
+ catch (IOException ioe)
+ {
+ return 0; // FIXME
+ }
}
}
diff --git a/gnu/java/nio/VMChannelOwner.java b/gnu/java/nio/VMChannelOwner.java
new file mode 100644
index 000000000..363dea2b2
--- /dev/null
+++ b/gnu/java/nio/VMChannelOwner.java
@@ -0,0 +1,57 @@
+/* NativeFD.java -- interface for Channels that have an underlying file descriptor.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.nio;
+
+/**
+ * This interface is meant to be implemented by any {@link Channel}
+ * implementation we support that uses a platform-specific {@link VMChannel}
+ * at their core. This is primarily used by {@link Selector} implementations,
+ * for easier access to the native state.
+ *
+ * @author Casey Marshall (csm@gnu.org)
+ */
+interface VMChannelOwner
+{
+ /**
+ * Return the underlying platform-specific Channel instance.
+ *
+ * @return The platform channel object.
+ */
+ VMChannel getVMChannel();
+}
diff --git a/gnu/java/nio/charset/ByteCharset.java b/gnu/java/nio/charset/ByteCharset.java
index 2cc91b850..da0fdcbcd 100644
--- a/gnu/java/nio/charset/ByteCharset.java
+++ b/gnu/java/nio/charset/ByteCharset.java
@@ -156,6 +156,22 @@ abstract class ByteCharset extends Charset
}
}
+ public boolean canEncode(char c)
+ {
+ byte b = (c < lookup.length) ? lookup[c] : 0;
+ return b != 0 || c == 0;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ {
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
diff --git a/gnu/java/nio/charset/ISO_8859_1.java b/gnu/java/nio/charset/ISO_8859_1.java
index cc06ecd5a..2a3073a32 100644
--- a/gnu/java/nio/charset/ISO_8859_1.java
+++ b/gnu/java/nio/charset/ISO_8859_1.java
@@ -128,6 +128,19 @@ final class ISO_8859_1 extends Charset
super (cs, 1.0f, 1.0f);
}
+ public boolean canEncode(char c)
+ {
+ return c <= 0xff;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
diff --git a/gnu/java/nio/charset/US_ASCII.java b/gnu/java/nio/charset/US_ASCII.java
index d26f7ffc9..8888416be 100644
--- a/gnu/java/nio/charset/US_ASCII.java
+++ b/gnu/java/nio/charset/US_ASCII.java
@@ -134,6 +134,19 @@ final class US_ASCII extends Charset
super (cs, 1.0f, 1.0f);
}
+ public boolean canEncode(char c)
+ {
+ return c <= 0x7f;
+ }
+
+ public boolean canEncode(CharSequence cs)
+ {
+ for (int i = 0; i < cs.length(); ++i)
+ if (! canEncode(cs.charAt(i)))
+ return false;
+ return true;
+ }
+
protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
{
// TODO: Optimize this in the case in.hasArray() / out.hasArray()
@@ -141,7 +154,7 @@ final class US_ASCII extends Charset
{
char c = in.get ();
- if (c > Byte.MAX_VALUE)
+ if (c > 0x7f)
{
in.position (in.position () - 1);
return CoderResult.unmappableForLength (1);
diff --git a/gnu/java/rmi/server/ActivatableRef.java b/gnu/java/rmi/server/ActivatableRef.java
index d191c0c17..e7580bcd7 100644
--- a/gnu/java/rmi/server/ActivatableRef.java
+++ b/gnu/java/rmi/server/ActivatableRef.java
@@ -112,8 +112,10 @@ public class ActivatableRef extends UnicastRef
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
{
- super.readExternal(in);
actId = (ActivationID) in.readObject();
+ String type = in.readUTF();
+ // XXX handle type.equals("") (null reference)
+ super.readExternal(in);
}
/**
@@ -121,8 +123,10 @@ public class ActivatableRef extends UnicastRef
*/
public void writeExternal(ObjectOutput out) throws IOException
{
- super.writeExternal(out);
out.writeObject(actId);
+ // XXX write a "" if the "nested" reference is a null reference
+ out.writeUTF("UnicastRef2");
+ super.writeExternal(out);
}
/**
diff --git a/gnu/java/util/prefs/GConfBasedPreferences.java b/gnu/java/util/prefs/GConfBasedPreferences.java
index 5702751cf..a7e2322b5 100644
--- a/gnu/java/util/prefs/GConfBasedPreferences.java
+++ b/gnu/java/util/prefs/GConfBasedPreferences.java
@@ -72,7 +72,6 @@ import java.util.prefs.BackingStoreException;
* <br />
*
* @author Mario Torre <neugens@limasoftware.net>
- * @version 1.0.1
*/
public class GConfBasedPreferences
extends AbstractPreferences
@@ -136,12 +135,20 @@ public class GConfBasedPreferences
absolutePath = absolutePath.substring(0, absolutePath.length() - 1);
}
+ // strip invalid characters
+ // please, note that all names are unescaped into the native peer
+ int index = absolutePath.lastIndexOf('/');
+ if (index > -1)
+ {
+ absolutePath = absolutePath.substring(0, index + 1);
+ absolutePath = absolutePath + GConfNativePeer.escapeString(name);
+ }
+
this.node = this.getRealRoot(isUser) + absolutePath;
boolean nodeExist = backend.nodeExist(this.node);
this.newNode = !nodeExist;
- backend.startWatchingNode(this.node);
}
/**
@@ -156,7 +163,15 @@ public class GConfBasedPreferences
// we don't check anything here, if the node is a new node this will be
// detected in the constructor, so we simply return a new reference to
// the requested node.
- return new GConfBasedPreferences(this, name, this.isUser);
+
+ GConfBasedPreferences preferenceNode
+ = new GConfBasedPreferences(this, name, this.isUser);
+
+ // register the node for to GConf so that it can listen
+ // events outside the scope of the application
+ backend.startWatchingNode(this.node);
+
+ return preferenceNode;
}
/**
@@ -365,6 +380,10 @@ public class GConfBasedPreferences
{
String nodeName = "";
+ // strip key
+ // please, note that all names are unescaped into the native peer
+ key = GConfNativePeer.escapeString(key);
+
if (this.node.endsWith("/"))
{
nodeName = this.node + key;
@@ -373,7 +392,7 @@ public class GConfBasedPreferences
{
nodeName = this.node + "/" + key;
}
-
+
return nodeName;
}
diff --git a/gnu/java/util/prefs/gconf/GConfNativePeer.java b/gnu/java/util/prefs/gconf/GConfNativePeer.java
index f1cb62787..6049863e9 100644
--- a/gnu/java/util/prefs/gconf/GConfNativePeer.java
+++ b/gnu/java/util/prefs/gconf/GConfNativePeer.java
@@ -45,7 +45,6 @@ import java.util.prefs.BackingStoreException;
* Native peer for GConf based preference backend.
*
* @author Mario Torre <neugens@limasoftware.net>
- * @version 1.0.1
*/
public final class GConfNativePeer
{
@@ -150,7 +149,7 @@ public final class GConfNativePeer
*/
public List getKeys(String node) throws BackingStoreException
{
- return gconf_client_gconf_client_all_keys(node);
+ return gconf_client_all_keys(node);
}
/**
@@ -162,10 +161,26 @@ public final class GConfNativePeer
*/
public List getChildrenNodes(String node) throws BackingStoreException
{
- return gconf_client_gconf_client_all_nodes(node);
+ return gconf_client_all_nodes(node);
}
/**
+ * Escape the given string so the it is a valid GConf name.
+ */
+ public static String escapeString(String plain)
+ {
+ return gconf_escape_key(plain);
+ }
+
+ /**
+ * Unescape a string escaped with {@link #escapeString}.
+ */
+ public static String unescapeString(String escaped)
+ {
+ return gconf_unescape_key(escaped);
+ }
+
+ /**
* Suggest to the backend GConf daemon to synch with the database.
*/
public void suggestSync() throws BackingStoreException
@@ -270,8 +285,9 @@ public final class GConfNativePeer
* Suggest to the GConf native peer a sync with the database.
*
*/
- native static final protected void gconf_client_suggest_sync();
-
+ native static final protected void gconf_client_suggest_sync()
+ throws BackingStoreException;
+
/**
* Returns a list of all nodes under the given node.
*
@@ -279,8 +295,9 @@ public final class GConfNativePeer
* @return A list of nodes under the given source node.
*/
native
- static final protected List gconf_client_gconf_client_all_nodes(String node);
-
+ static final protected List gconf_client_all_nodes(String node)
+ throws BackingStoreException;
+
/**
* Returns a list of all keys stored in the given node.
*
@@ -288,8 +305,28 @@ public final class GConfNativePeer
* @return A list of all keys stored in the given node.
*/
native
- static final protected List gconf_client_gconf_client_all_keys(String node);
+ static final protected List gconf_client_all_keys(String node)
+ throws BackingStoreException;
+ /**
+ * Escape the input String so that it's a valid element for GConf.
+ *
+ * @param plain the String to escape.
+ * @return An escaped String for use with GConf.
+ */
+ native
+ static final protected String gconf_escape_key(String plain);
+
+ /**
+ * Converts a string escaped with gconf_escape_key back into its
+ * original form.
+ *
+ * @param escaped key as returned by gconf_escape_key
+ * @return An unescaped key.
+ */
+ native
+ static final protected String gconf_unescape_key(String escaped);
+
static
{
System.loadLibrary("gconfpeer");
diff --git a/gnu/java/util/regex/RETokenRepeated.java b/gnu/java/util/regex/RETokenRepeated.java
index b32a316c4..7f5e5626f 100644
--- a/gnu/java/util/regex/RETokenRepeated.java
+++ b/gnu/java/util/regex/RETokenRepeated.java
@@ -38,8 +38,7 @@ exception statement from your version. */
package gnu.java.util.regex;
-// import java.util.Vector;
-// import java.util.Stack;
+import java.util.ArrayList;
final class RETokenRepeated extends REToken {
private REToken token;
@@ -168,19 +167,63 @@ final class RETokenRepeated extends REToken {
}
}
+ private static class FindMatchControlStack extends ArrayList {
+ private void push(FindMatchControl control) {
+ add(control);
+ }
+ private FindMatchControl pop() {
+ return (FindMatchControl)remove(size()-1);
+ }
+ private boolean empty() {
+ return isEmpty();
+ }
+ }
+
+ private static class FindMatchControl {
+ DoablesFinder finder;
+ FindMatchControl(DoablesFinder finder) {
+ this.finder = finder;
+ }
+ }
+
private REMatch findMatch(BacktrackStack stack) {
- // Avoid using recursive calls.
+ return findMatch(stack, new FindMatchControlStack());
+ }
+
+ private REMatch findMatch(BacktrackStack stack,
+ FindMatchControlStack controlStack) {
+ REMatch result = null;
+ StackedInfo si = null;
+ CharIndexed input = null;
+ int numRepeats = 0;
+ REMatch mymatch = null;
+ int[] visited = null;
+ DoablesFinder finder = null;
+
+ // Avoid using recursive calls because a match can be very long.
+
+ // This is the first entry point of this method.
+ // If you want to call this method recursively and you need the
+ // result returned, save necessary information in a FindMatchControl
+ // object and push it to controlStack, then continue from this point.
+ // You can check the result after exiting MAIN_LOOP.
+ MAIN_LOOP0:
+ while (true) {
+
+ // This is the second entry point of this method.
+ // If you want to call this method recursively but you do not need the
+ // result returned, just continue from this point.
MAIN_LOOP:
while (true) {
- if (stack.empty()) return null;
- StackedInfo si = (StackedInfo)(stack.peek());
- CharIndexed input = si.input;
- int numRepeats = si.numRepeats;
- REMatch mymatch = si.match;
- int[] visited = si.visited;
- DoablesFinder finder = si.finder;
-
+ if (stack.empty()) break MAIN_LOOP;
+ si = (StackedInfo)(stack.peek());
+ input = si.input;
+ numRepeats = si.numRepeats;
+ mymatch = si.match;
+ visited = si.visited;
+ finder = si.finder;
+
if (mymatch.backtrackStack == null)
mymatch.backtrackStack = new BacktrackStack();
@@ -192,12 +235,13 @@ final class RETokenRepeated extends REToken {
m1.backtrackStack.push(new BacktrackStack.Backtrack(
this, input, mymatch, stack));
}
- return m1;
+ result = m1;
+ break MAIN_LOOP;
}
if (stingy) {
continue MAIN_LOOP;
}
- return null;
+ break MAIN_LOOP;
}
if (finder == null) {
@@ -238,7 +282,8 @@ final class RETokenRepeated extends REToken {
m1.backtrackStack.push(new BacktrackStack.Backtrack(
this, input, mymatch, stack));
}
- return m1;
+ result = m1;
+ break MAIN_LOOP;
}
else {
continue MAIN_LOOP;
@@ -247,8 +292,82 @@ final class RETokenRepeated extends REToken {
visited = addVisited(mymatch.index, visited);
+ TryAnotherResult taresult = tryAnother(stack, input, mymatch, numRepeats, finder, visited);
+ visited = taresult.visited;
+ switch (taresult.status) {
+ case TryAnotherResult.TRY_FURTHER:
+ controlStack.push(new FindMatchControl(
+ finder));
+ continue MAIN_LOOP0;
+ case TryAnotherResult.RESULT_FOUND:
+ result = taresult.result;
+ break MAIN_LOOP;
+ }
+
+ if (!stack.empty()) {
+ stack.pop();
+ }
+ if (possessive) {
+ stack.clear();
+ }
+ REMatch m1 = matchRest(input, mymatch);
+ if (m1 != null) {
+ if (! stack.empty()) {
+ m1.backtrackStack.push(new BacktrackStack.Backtrack(
+ this, input, mymatch, stack));
+ }
+ result = m1;
+ break MAIN_LOOP;
+ }
+
+ } // MAIN_LOOP
+
+ if (controlStack.empty()) return result;
+ FindMatchControl control = controlStack.pop();
+ if (possessive) {
+ return result;
+ }
+ if (result != null) {
+ result.backtrackStack.push(new BacktrackStack.Backtrack(
+ this, input, mymatch, stack));
+ return result;
+ }
+
+ finder = control.finder;
+
+ TryAnotherResult taresult = tryAnother(stack, input, mymatch, numRepeats, finder, visited);
+ visited = taresult.visited;
+ switch (taresult.status) {
+ case TryAnotherResult.TRY_FURTHER:
+ controlStack.push(new FindMatchControl(
+ finder));
+ continue MAIN_LOOP0;
+ case TryAnotherResult.RESULT_FOUND:
+ return taresult.result;
+ }
+ continue MAIN_LOOP0;
+
+ } // MAIN_LOOP0
+ }
+
+ private static class TryAnotherResult {
+ REMatch result;
+ int status;
+ static final int RESULT_FOUND = 1;
+ static final int TRY_FURTHER = 2;
+ static final int NOTHING_FOUND = 3;
+ int[] visited;
+ }
+
+ private TryAnotherResult tryAnother(BacktrackStack stack,
+ CharIndexed input, REMatch mymatch, int numRepeats,
+ DoablesFinder finder, int[] visited) {
+
+ TryAnotherResult taresult = new TryAnotherResult();
+ taresult.visited = visited;
+
DO_THIS:
- do {
+ {
boolean emptyMatchFound = false;
@@ -263,58 +382,41 @@ final class RETokenRepeated extends REToken {
if (!emptyMatchFound) {
int n = doable.index;
- if (! visitedContains(n, visited)) {
- visited = addVisited(n, visited);
- }
- else {
+ if (visitedContains(n, visited)) {
continue DO_ONE_DOABLE;
}
+ visited = addVisited(n, visited);
stack.push(new StackedInfo(
- input, numRepeats + 1, doable, visited, null));
- REMatch m1 = findMatch(stack);
- if (possessive) {
- return m1;
- }
- if (m1 != null) {
- m1.backtrackStack.push(new BacktrackStack.Backtrack(
- this, input, mymatch, stack));
- return m1;
- }
+ input, numRepeats + 1, doable, visited, null));
+ taresult.visited = visited;
+ taresult.status = TryAnotherResult.TRY_FURTHER;
+ return taresult;
}
else {
REMatch m1 = matchRest(input, doable);
if (possessive) {
- return m1;
+ taresult.result = m1;
+ taresult.status = TryAnotherResult.RESULT_FOUND;
+ return taresult;
}
if (m1 != null) {
if (! stack.empty()) {
m1.backtrackStack.push(new BacktrackStack.Backtrack(
this, input, mymatch, stack));
- }
- return m1;
+ }
+ taresult.result = m1;
+ taresult.status = TryAnotherResult.RESULT_FOUND;
+ return taresult;
}
}
} // DO_ONE_DOABLE
- } while (false); // DO_THIS only once;
+ } // DO_THIS
- if (!stack.empty()) {
- stack.pop();
- }
- if (possessive) {
- stack.clear();
- }
- REMatch m1 = matchRest(input, mymatch);
- if (m1 != null) {
- if (! stack.empty()) {
- m1.backtrackStack.push(new BacktrackStack.Backtrack(
- this, input, mymatch, stack));
- }
- return m1;
- }
+ taresult.status = TryAnotherResult.NOTHING_FOUND;
+ return taresult;
- } // MAIN_LOOP
}
boolean match(CharIndexed input, REMatch mymatch) {
diff --git a/gnu/xml/dom/DomNode.java b/gnu/xml/dom/DomNode.java
index f0915eb5e..269038aa7 100644
--- a/gnu/xml/dom/DomNode.java
+++ b/gnu/xml/dom/DomNode.java
@@ -668,6 +668,7 @@ public abstract class DomNode
{
insertionEvent(null, child);
}
+ length++;
}
return child;
diff --git a/gnu/xml/dom/ls/SAXEventSink.java b/gnu/xml/dom/ls/SAXEventSink.java
index aad5ac76e..8c5b104b9 100644
--- a/gnu/xml/dom/ls/SAXEventSink.java
+++ b/gnu/xml/dom/ls/SAXEventSink.java
@@ -43,6 +43,7 @@ import java.util.LinkedList;
import java.util.List;
import javax.xml.XMLConstants;
import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.Entity;
@@ -72,7 +73,7 @@ import gnu.xml.dom.DomNode;
*
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
*/
-class SAXEventSink
+public class SAXEventSink
implements ContentHandler, LexicalHandler, DTDHandler, DeclHandler
{
@@ -110,6 +111,11 @@ class SAXEventSink
interrupted = true;
}
+ protected Document getDocument()
+ {
+ return doc;
+ }
+
// -- ContentHandler2 --
public void setDocumentLocator(Locator locator)
diff --git a/gnu/xml/transform/SAXTemplatesHandler.java b/gnu/xml/transform/SAXTemplatesHandler.java
new file mode 100644
index 000000000..2c5a4686f
--- /dev/null
+++ b/gnu/xml/transform/SAXTemplatesHandler.java
@@ -0,0 +1,97 @@
+/* SAXTemplatesHandler.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.transform;
+
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.TemplatesHandler;
+import org.w3c.dom.Document;
+import gnu.xml.dom.ls.SAXEventSink;
+
+/**
+ * A content handler that acts as a sink for SAX parse events,
+ * constructing an XSL stylesheet.
+ * Internally, this class simply creates a DOM tree from the events,
+ * and then parses the DOM into a Templates object.
+ *
+ * @author Chris Burdess (dog@gnu.org)
+ */
+class SAXTemplatesHandler
+ extends SAXEventSink
+ implements TemplatesHandler
+{
+
+ final TransformerFactoryImpl factory;
+ String systemId;
+
+ SAXTemplatesHandler(TransformerFactoryImpl factory)
+ {
+ this.factory = factory;
+ }
+
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+ public void setSystemId(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ public Templates getTemplates()
+ {
+ Document doc = getDocument();
+ if (doc == null)
+ throw new IllegalStateException("Parsing of stylesheet incomplete");
+ DOMSource ds = new DOMSource(doc, systemId);
+ try
+ {
+ return factory.newTemplates(ds);
+ }
+ catch (TransformerConfigurationException e)
+ {
+ String msg = "Unable to construct templates from this event stream";
+ IllegalStateException e2 = new IllegalStateException(msg);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
diff --git a/gnu/xml/transform/SAXTransformerHandler.java b/gnu/xml/transform/SAXTransformerHandler.java
new file mode 100644
index 000000000..83cc3754b
--- /dev/null
+++ b/gnu/xml/transform/SAXTransformerHandler.java
@@ -0,0 +1,111 @@
+/* SAXTransformerHandler.java --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.xml.transform;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.TransformerHandler;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+import gnu.xml.dom.ls.SAXEventSink;
+
+/**
+ * A SAX event sink that processes an XML source represented as a stream of
+ * SAX events into a result tree.
+ * This works by simply buffering all the events into a DOM tree and then
+ * using this DOM tree as the source of the transformation.
+ *
+ * @author Chris Burdess (dog@gnu.org)
+ */
+class SAXTransformerHandler
+ extends SAXEventSink
+ implements TransformerHandler
+{
+
+ final TransformerFactoryImpl factory;
+ final Transformer transformer;
+ String systemId;
+ Result result;
+
+ SAXTransformerHandler(TransformerFactoryImpl factory, Transformer transformer)
+ {
+ this.factory = factory;
+ this.transformer = transformer;
+ }
+
+ public String getSystemId()
+ {
+ return systemId;
+ }
+
+ public void setSystemId(String systemId)
+ {
+ this.systemId = systemId;
+ }
+
+ public Transformer getTransformer()
+ {
+ return transformer;
+ }
+
+ public void setResult(Result result)
+ {
+ this.result = result;
+ }
+
+ public void endDocument()
+ throws SAXException
+ {
+ super.endDocument();
+ try
+ {
+ Document doc = getDocument();
+ DOMSource ds = new DOMSource(doc, systemId);
+ transformer.transform(ds, result);
+ }
+ catch (TransformerException e)
+ {
+ SAXException e2 = new SAXException(e.getMessage());
+ e2.initCause(e);
+ throw e2;
+ }
+ }
+
+}
diff --git a/gnu/xml/transform/StreamSerializer.java b/gnu/xml/transform/StreamSerializer.java
index fb8b1a601..26bdda8b3 100644
--- a/gnu/xml/transform/StreamSerializer.java
+++ b/gnu/xml/transform/StreamSerializer.java
@@ -324,7 +324,8 @@ public class StreamSerializer
break;
case Node.TEXT_NODE:
value = node.getNodeValue();
- if (!"yes".equals(node.getUserData("disable-output-escaping")))
+ if (!"yes".equals(node.getUserData("disable-output-escaping")) &&
+ mode != Stylesheet.OUTPUT_TEXT)
value = encode(value, false, false);
out.write(encodeText(value));
break;
diff --git a/gnu/xml/transform/TransformerFactoryImpl.java b/gnu/xml/transform/TransformerFactoryImpl.java
index 16e3363f8..1e8fea3e3 100644
--- a/gnu/xml/transform/TransformerFactoryImpl.java
+++ b/gnu/xml/transform/TransformerFactoryImpl.java
@@ -60,11 +60,15 @@ import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TemplatesHandler;
+import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.xml.sax.XMLFilter;
import gnu.xml.dom.DomDocument;
/**
@@ -73,7 +77,7 @@ import gnu.xml.dom.DomDocument;
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
*/
public class TransformerFactoryImpl
- extends TransformerFactory
+ extends SAXTransformerFactory
{
final XPathFactory xpathFactory;
@@ -316,7 +320,8 @@ public class TransformerFactoryImpl
StreamSource.FEATURE.equals(name) ||
StreamResult.FEATURE.equals(name) ||
DOMSource.FEATURE.equals(name) ||
- DOMResult.FEATURE.equals(name))
+ DOMResult.FEATURE.equals(name) ||
+ SAXTransformerFactory.FEATURE.equals(name))
{
return true;
}
@@ -346,6 +351,49 @@ public class TransformerFactoryImpl
return userListener;
}
+ // -- SAXTransformerFactory --
+
+ public TemplatesHandler newTemplatesHandler()
+ throws TransformerConfigurationException
+ {
+ return new SAXTemplatesHandler(this);
+ }
+
+ public TransformerHandler newTransformerHandler()
+ throws TransformerConfigurationException
+ {
+ Transformer transformer = newTransformer();
+ return new SAXTransformerHandler(this, transformer);
+ }
+
+ public TransformerHandler newTransformerHandler(Source source)
+ throws TransformerConfigurationException
+ {
+ Transformer transformer = newTransformer(source);
+ return new SAXTransformerHandler(this, transformer);
+ }
+
+ public TransformerHandler newTransformerHandler(Templates templates)
+ throws TransformerConfigurationException
+ {
+ Transformer transformer = templates.newTransformer();
+ return new SAXTransformerHandler(this, transformer);
+ }
+
+ public XMLFilter newXMLFilter(Source source)
+ throws TransformerConfigurationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public XMLFilter newXMLFilter(Templates templates)
+ throws TransformerConfigurationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ // -- SAXTransformerFactory end --
+
/**
* Syntax: TransformerFactoryImpl [<stylesheet> [<input> [<output>]]]
*/
diff --git a/gnu/xml/transform/XSLURIResolver.java b/gnu/xml/transform/XSLURIResolver.java
index 6a49caab4..8d7e3fcb4 100644
--- a/gnu/xml/transform/XSLURIResolver.java
+++ b/gnu/xml/transform/XSLURIResolver.java
@@ -53,6 +53,7 @@ import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
@@ -118,10 +119,9 @@ class XSLURIResolver
try
{
- URL url = resolveURL(systemId, base, href);
Node node = null;
InputStream in = null;
- if (source instanceof StreamSource)
+ if (source != null && source instanceof StreamSource)
{
StreamSource ss = (StreamSource) source;
in = ss.getInputStream();
@@ -134,8 +134,25 @@ class XSLURIResolver
}
}
}
+ else if (source != null && source instanceof SAXSource)
+ {
+ SAXSource ss = (SAXSource) source;
+ if (ss.getInputSource() != null)
+ {
+ in = ss.getInputSource().getByteStream();
+ if (in == null)
+ {
+ Reader reader = ss.getInputSource().getCharacterStream();
+ if (reader != null)
+ {
+ in = new ReaderInputStream(reader);
+ }
+ }
+ }
+ }
if (in == null)
{
+ URL url = resolveURL(systemId, base, href);
if (url != null)
{
systemId = url.toString();
diff --git a/gnu/xml/xpath/Expr.java b/gnu/xml/xpath/Expr.java
index 76fd49eef..cafc83b0d 100644
--- a/gnu/xml/xpath/Expr.java
+++ b/gnu/xml/xpath/Expr.java
@@ -59,6 +59,7 @@ import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -80,6 +81,38 @@ public abstract class Expr
".####################################################",
new DecimalFormatSymbols(Locale.US));
+ static class ExprNodeSet implements NodeList
+ {
+
+ private ArrayList list;
+
+ ExprNodeSet(Collection collection)
+ {
+ if (collection instanceof ArrayList)
+ list = (ArrayList) collection;
+ else
+ list = new ArrayList(collection);
+ }
+
+ public int getLength()
+ {
+ return list.size();
+ }
+
+ public Node item(int index)
+ {
+ try
+ {
+ return (Node) list.get(index);
+ }
+ catch (ArrayIndexOutOfBoundsException e)
+ {
+ return null;
+ }
+ }
+
+ }
+
public Object evaluate(Object item, QName returnType)
throws XPathExpressionException
{
@@ -132,6 +165,8 @@ public abstract class Expr
{
throw new XPathExpressionException("return value is not a node-set");
}
+ if (ret != null)
+ ret = new ExprNodeSet((Collection) ret);
}
}
return ret;
diff --git a/include/Makefile.am b/include/Makefile.am
index c36ff0687..baa6fc0bd 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -128,10 +128,12 @@ $(GCONF_PREFS_FILES) \
$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h \
$(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h \
+$(top_srcdir)/include/gnu_java_nio_EpollSelectorImpl.h \
+$(top_srcdir)/include/gnu_java_nio_FileChannelImpl.h \
+$(top_srcdir)/include/gnu_java_nio_KqueueSelectorImpl.h \
$(top_srcdir)/include/gnu_java_nio_VMChannel.h \
$(top_srcdir)/include/gnu_java_nio_VMPipe.h \
$(top_srcdir)/include/gnu_java_nio_VMSelector.h \
-$(top_srcdir)/include/gnu_java_nio_channels_FileChannelImpl.h \
$(top_srcdir)/include/gnu_java_nio_charset_iconv_IconvEncoder.h \
$(top_srcdir)/include/gnu_java_nio_charset_iconv_IconvDecoder.h \
$(top_srcdir)/include/java_io_VMFile.h \
@@ -214,12 +216,21 @@ $(top_srcdir)/include/java_net_VMNetworkInterface.h: $(top_srcdir)/vm/reference/
$(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
$(JAVAH) -o $@ java.nio.MappedByteBufferImpl
-$(top_srcdir)/include/gnu_java_nio_channels_FileChannelImpl.h: $(top_srcdir)/gnu/java/nio/channels/FileChannelImpl.java
- $(JAVAH) -o $@ gnu.java.nio.channels.FileChannelImpl
+
+$(top_srcdir)/include/gnu_java_nio_FileChannelImpl.h: $(top_srcdir)/gnu/java/nio/FileChannelImpl.java
+ $(JAVAH) -o $@ gnu.java.nio.FileChannelImpl
+
+$(top_srcdir)/include/gnu_java_nio_KqueueSelectorImpl.h: $(top_srcdir)/gnu/java/nio/KqueueSelectorImpl.java
+ $(JAVAH) -o $@ gnu.java.nio.KqueueSelectorImpl
+
+$(top_srcdir)/include/gnu_java_nio_EpollSelectorImpl.h: $(top_srcdir)/gnu/java/nio/EpollSelectorImpl.java
+ $(JAVAH) -o $@ gnu.java.nio.EpollSelectorImpl
+
$(top_srcdir)/include/gnu_java_nio_charset_iconv_IconvDecoder.h: $(top_srcdir)/gnu/java/nio/charset/iconv/IconvDecoder.java
$(JAVAH) -o $@ gnu.java.nio.charset.iconv.IconvDecoder
$(top_srcdir)/include/gnu_java_nio_charset_iconv_IconvEncoder.h: $(top_srcdir)/gnu/java/nio/charset/iconv/IconvEncoder.java
diff --git a/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h b/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
index a54c7117e..50912e8b5 100644
--- a/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
+++ b/include/gnu_java_awt_peer_gtk_CairoGraphics2D.h
@@ -12,9 +12,9 @@ extern "C"
JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_init (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_disposeNative (JNIEnv *env, jobject, jlong);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels (JNIEnv *env, jobject, jlong, jintArray, jint, jint, jint, jdoubleArray, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels (JNIEnv *env, jobject, jlong, jintArray, jint, jint, jint, jdoubleArray, jdouble, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setGradient (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setTexturePixels (JNIEnv *env, jobject, jlong, jintArray, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setPaintPixels (JNIEnv *env, jobject, jlong, jintArray, jint, jint, jint, jboolean);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetMatrix (JNIEnv *env, jobject, jlong, jdoubleArray);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoScale (JNIEnv *env, jobject, jlong, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSetOperator (JNIEnv *env, jobject, jlong, jint);
@@ -40,7 +40,6 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFill (JNI
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoClip (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoPreserveClip (JNIEnv *env, jobject, jlong);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoResetClip (JNIEnv *env, jobject, jlong);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter (JNIEnv *env, jobject, jlong, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawLine (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawRect (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoFillRect (JNIEnv *env, jobject, jlong, jdouble, jdouble, jdouble, jdouble);
diff --git a/include/gnu_java_awt_peer_gtk_CairoSurface.h b/include/gnu_java_awt_peer_gtk_CairoSurface.h
index 88000095d..388570710 100644
--- a/include/gnu_java_awt_peer_gtk_CairoSurface.h
+++ b/include/gnu_java_awt_peer_gtk_CairoSurface.h
@@ -14,7 +14,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_create (JNIEnv *e
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_destroy (JNIEnv *env, jobject, jlong, jlong);
JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeGetElem (JNIEnv *env, jobject, jlong, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeSetElem (JNIEnv *env, jobject, jlong, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeDrawSurface (JNIEnv *env, jobject, jlong, jlong, jdoubleArray, jdouble);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeDrawSurface (JNIEnv *env, jobject, jlong, jlong, jdoubleArray, jdouble, jint);
JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeGetPixels (JNIEnv *env, jobject, jlong, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_nativeSetPixels (JNIEnv *env, jobject, jlong, jintArray);
JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_gtk_CairoSurface_getFlippedBuffer (JNIEnv *env, jobject, jlong, jint);
diff --git a/include/gnu_java_net_VMPlainSocketImpl.h b/include/gnu_java_net_VMPlainSocketImpl.h
index f7616c2c3..b274ce0fb 100644
--- a/include/gnu_java_net_VMPlainSocketImpl.h
+++ b/include/gnu_java_net_VMPlainSocketImpl.h
@@ -1,31 +1,152 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_net_VMPlainSocketImpl__
-#define __gnu_java_net_VMPlainSocketImpl__
-
#include <jni.h>
+/* Header for class gnu_java_net_VMPlainSocketImpl */
+#ifndef _Included_gnu_java_net_VMPlainSocketImpl
+#define _Included_gnu_java_net_VMPlainSocketImpl
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: setOption
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_setOption
+ (JNIEnv *, jclass, jint, jint, jint);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: getOption
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_net_VMPlainSocketImpl_getOption
+ (JNIEnv *, jclass, jint, jint);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: bind
+ * Signature: (I[BI)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_bind
+ (JNIEnv *, jclass, jint, jbyteArray, jint);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: bind6
+ * Signature: (I[BI)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_bind6
+ (JNIEnv *, jclass, jint, jbyteArray, jint);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: listen
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_listen
+ (JNIEnv *, jclass, jint, jint);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: join
+ * Signature: (I[B)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_join
+ (JNIEnv *, jclass, jint, jbyteArray);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: join6
+ * Signature: (I[B)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_join6
+ (JNIEnv *, jclass, jint, jbyteArray);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leave
+ * Signature: (I[B)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leave
+ (JNIEnv *, jclass, jint, jbyteArray);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leave6
+ * Signature: (I[B)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leave6
+ (JNIEnv *, jclass, jint, jbyteArray);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: joinGroup
+ * Signature: (I[BLjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_joinGroup
+ (JNIEnv *, jclass, jint, jbyteArray, jstring);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: joinGroup6
+ * Signature: (I[BLjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_joinGroup6
+ (JNIEnv *, jclass, jint, jbyteArray, jstring);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_setOption (JNIEnv *env, jclass, jobject, jint, jobject);
-JNIEXPORT jobject JNICALL Java_gnu_java_net_VMPlainSocketImpl_getOption (JNIEnv *env, jclass, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_create (JNIEnv *env, jclass, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_connect (JNIEnv *env, jclass, jobject, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_bind (JNIEnv *env, jclass, jobject, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_listen (JNIEnv *env, jclass, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_accept (JNIEnv *env, jclass, jobject, jobject);
-JNIEXPORT jint JNICALL Java_gnu_java_net_VMPlainSocketImpl_available (JNIEnv *env, jclass, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_close (JNIEnv *env, jclass, jobject);
-JNIEXPORT jint JNICALL Java_gnu_java_net_VMPlainSocketImpl_read (JNIEnv *env, jclass, jobject, jbyteArray, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_write (JNIEnv *env, jclass, jobject, jbyteArray, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownInput (JNIEnv *env, jclass, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownOutput (JNIEnv *env, jclass, jobject);
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leaveGroup
+ * Signature: (I[BLjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leaveGroup
+ (JNIEnv *, jclass, jint, jbyteArray, jstring);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leaveGroup6
+ * Signature: (I[BLjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6
+ (JNIEnv *, jclass, jint, jbyteArray, jstring);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: shutdownInput
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownInput
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: shutdownOutput
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_shutdownOutput
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: sendUrgentData
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainSocketImpl_sendUrgentData
+ (JNIEnv *, jclass, jint, jint);
#ifdef __cplusplus
}
#endif
+#endif
+/* Header for class gnu_java_net_VMPlainSocketImpl_State */
-#endif /* __gnu_java_net_VMPlainSocketImpl__ */
+#ifndef _Included_gnu_java_net_VMPlainSocketImpl_State
+#define _Included_gnu_java_net_VMPlainSocketImpl_State
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/gnu_java_nio_EpollSelectorImpl.h b/include/gnu_java_nio_EpollSelectorImpl.h
new file mode 100644
index 000000000..188cdf9d5
--- /dev/null
+++ b/include/gnu_java_nio_EpollSelectorImpl.h
@@ -0,0 +1,95 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class gnu_java_nio_EpollSelectorImpl */
+
+#ifndef _Included_gnu_java_nio_EpollSelectorImpl
+#define _Included_gnu_java_nio_EpollSelectorImpl
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef gnu_java_nio_EpollSelectorImpl_DEFAULT_EPOLL_SIZE
+#define gnu_java_nio_EpollSelectorImpl_DEFAULT_EPOLL_SIZE 128L
+#undef gnu_java_nio_EpollSelectorImpl_OP_ACCEPT
+#define gnu_java_nio_EpollSelectorImpl_OP_ACCEPT 16L
+#undef gnu_java_nio_EpollSelectorImpl_OP_CONNECT
+#define gnu_java_nio_EpollSelectorImpl_OP_CONNECT 8L
+#undef gnu_java_nio_EpollSelectorImpl_OP_READ
+#define gnu_java_nio_EpollSelectorImpl_OP_READ 1L
+#undef gnu_java_nio_EpollSelectorImpl_OP_WRITE
+#define gnu_java_nio_EpollSelectorImpl_OP_WRITE 4L
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_supported
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1supported
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: sizeof_struct
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_sizeof_1struct
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_create
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1create
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_add
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1add
+ (JNIEnv *, jclass, jint, jint, jint);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_modify
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1modify
+ (JNIEnv *, jclass, jint, jint, jint);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_delete
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1delete
+ (JNIEnv *, jclass, jint, jint);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_wait
+ * Signature: (ILjava/nio/ByteBuffer;II)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_epoll_1wait
+ (JNIEnv *, jclass, jint, jobject, jint, jint);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: selected_fd
+ * Signature: (Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_selected_1fd
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: selected_ops
+ * Signature: (Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_EpollSelectorImpl_selected_1ops
+ (JNIEnv *, jclass, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/gnu_java_nio_FileChannelImpl.h b/include/gnu_java_nio_FileChannelImpl.h
new file mode 100644
index 000000000..ebf466ccc
--- /dev/null
+++ b/include/gnu_java_nio_FileChannelImpl.h
@@ -0,0 +1,25 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class gnu_java_nio_FileChannelImpl */
+
+#ifndef _Included_gnu_java_nio_FileChannelImpl
+#define _Included_gnu_java_nio_FileChannelImpl
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef gnu_java_nio_FileChannelImpl_READ
+#define gnu_java_nio_FileChannelImpl_READ 1L
+#undef gnu_java_nio_FileChannelImpl_WRITE
+#define gnu_java_nio_FileChannelImpl_WRITE 2L
+#undef gnu_java_nio_FileChannelImpl_APPEND
+#define gnu_java_nio_FileChannelImpl_APPEND 4L
+#undef gnu_java_nio_FileChannelImpl_EXCL
+#define gnu_java_nio_FileChannelImpl_EXCL 8L
+#undef gnu_java_nio_FileChannelImpl_SYNC
+#define gnu_java_nio_FileChannelImpl_SYNC 16L
+#undef gnu_java_nio_FileChannelImpl_DSYNC
+#define gnu_java_nio_FileChannelImpl_DSYNC 32L
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/gnu_java_nio_KqueueSelectorImpl.h b/include/gnu_java_nio_KqueueSelectorImpl.h
new file mode 100644
index 000000000..f9716f38c
--- /dev/null
+++ b/include/gnu_java_nio_KqueueSelectorImpl.h
@@ -0,0 +1,97 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class gnu_java_nio_KqueueSelectorImpl */
+
+#ifndef _Included_gnu_java_nio_KqueueSelectorImpl
+#define _Included_gnu_java_nio_KqueueSelectorImpl
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef gnu_java_nio_KqueueSelectorImpl_MAX_DOUBLING_CAPACITY
+#define gnu_java_nio_KqueueSelectorImpl_MAX_DOUBLING_CAPACITY 16384L
+#undef gnu_java_nio_KqueueSelectorImpl_CAP_INCREMENT
+#define gnu_java_nio_KqueueSelectorImpl_CAP_INCREMENT 1024L
+#undef gnu_java_nio_KqueueSelectorImpl_OP_ACCEPT
+#define gnu_java_nio_KqueueSelectorImpl_OP_ACCEPT 16L
+#undef gnu_java_nio_KqueueSelectorImpl_OP_CONNECT
+#define gnu_java_nio_KqueueSelectorImpl_OP_CONNECT 8L
+#undef gnu_java_nio_KqueueSelectorImpl_OP_READ
+#define gnu_java_nio_KqueueSelectorImpl_OP_READ 1L
+#undef gnu_java_nio_KqueueSelectorImpl_OP_WRITE
+#define gnu_java_nio_KqueueSelectorImpl_OP_WRITE 4L
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: kqueue_supported
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kqueue_1supported
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: sizeof_struct_kevent
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_sizeof_1struct_1kevent
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: implOpen
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_implOpen
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: implClose
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_KqueueSelectorImpl_implClose
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: kevent_set
+ * Signature: (Ljava/nio/ByteBuffer;IIIII)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kevent_1set
+ (JNIEnv *, jclass, jobject, jint, jint, jint, jint, jint);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: kevent
+ * Signature: (ILjava/nio/ByteBuffer;IIJ)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_kevent
+ (JNIEnv *, jclass, jint, jobject, jint, jint, jlong);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: fetch_key
+ * Signature: (Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_fetch_1key
+ (JNIEnv *, jclass, jobject);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: ready_ops
+ * Signature: (Ljava/nio/ByteBuffer;I)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_KqueueSelectorImpl_ready_1ops
+ (JNIEnv *, jclass, jobject, jint);
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: check_eof
+ * Signature: (Ljava/nio/ByteBuffer;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_KqueueSelectorImpl_check_1eof
+ (JNIEnv *, jclass, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/gnu_java_nio_VMChannel.h b/include/gnu_java_nio_VMChannel.h
index 28f9048d2..969e3298a 100644
--- a/include/gnu_java_nio_VMChannel.h
+++ b/include/gnu_java_nio_VMChannel.h
@@ -1,24 +1,291 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_nio_VMChannel__
-#define __gnu_java_nio_VMChannel__
-
#include <jni.h>
+/* Header for class gnu_java_nio_VMChannel */
+#ifndef _Included_gnu_java_nio_VMChannel
+#define _Included_gnu_java_nio_VMChannel
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: stdin_fd
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stdin_1fd
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: stdout_fd
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stdout_1fd
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: stderr_fd
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_stderr_1fd
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: setBlocking
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_setBlocking
+ (JNIEnv *, jclass, jint, jboolean);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: available
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_available
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: read
+ * Signature: (ILjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read__ILjava_nio_ByteBuffer_2
+ (JNIEnv *, jclass, jint, jobject);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: read
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read__I
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: readScattering
+ * Signature: (I[Ljava/nio/ByteBuffer;II)J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_readScattering
+ (JNIEnv *, jclass, jint, jobjectArray, jint, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: receive
+ * Signature: (ILjava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_receive
+ (JNIEnv *, jclass, jint, jobject, jobject);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: write
+ * Signature: (ILjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_write__ILjava_nio_ByteBuffer_2
+ (JNIEnv *, jobject, jint, jobject);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: writeGathering
+ * Signature: (I[Ljava/nio/ByteBuffer;II)J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_writeGathering
+ (JNIEnv *, jobject, jint, jobjectArray, jint, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: send
+ * Signature: (ILjava/nio/ByteBuffer;[BI)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_send
+ (JNIEnv *, jclass, jint, jobject, jbyteArray, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: send6
+ * Signature: (ILjava/nio/ByteBuffer;[BI)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_send6
+ (JNIEnv *, jclass, jint, jobject, jbyteArray, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: write
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_write__II
+ (JNIEnv *, jclass, jint, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_initIDs
+ (JNIEnv *, jclass);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: socket
+ * Signature: (Z)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_socket
+ (JNIEnv *, jclass, jboolean);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: connect
+ * Signature: (I[BII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_connect
+ (JNIEnv *, jclass, jint, jbyteArray, jint, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: connect6
+ * Signature: (I[BII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_connect6
+ (JNIEnv *, jclass, jint, jbyteArray, jint, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: disconnect
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_disconnect
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: getsockname
+ * Signature: (ILjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_getsockname
+ (JNIEnv *, jclass, jint, jobject);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: getpeername
+ * Signature: (ILjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_getpeername
+ (JNIEnv *, jclass, jint, jobject);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: accept
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_accept
+ (JNIEnv *, jclass, jint);
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_setBlocking (JNIEnv *env, jobject, jint, jboolean);
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_read (JNIEnv *env, jobject, jint, jobject);
-JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env, jobject, jint, jobjectArray, jint, jint);
-JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_write (JNIEnv *env, jobject, jint, jobject);
-JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_writeGathering (JNIEnv *env, jobject, jint, jobjectArray, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_initIDs (JNIEnv *env, jclass);
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: open
+ * Signature: (Ljava/lang/String;I)I
+ */
+JNIEXPORT jint JNICALL Java_gnu_java_nio_VMChannel_open
+ (JNIEnv *, jclass, jstring, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: position
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_position
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: seek
+ * Signature: (IJ)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_seek
+ (JNIEnv *, jclass, jint, jlong);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: truncate
+ * Signature: (IJ)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_truncate
+ (JNIEnv *, jclass, jint, jlong);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: lock
+ * Signature: (IJJZZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_lock
+ (JNIEnv *, jclass, jint, jlong, jlong, jboolean, jboolean);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: unlock
+ * Signature: (IJJ)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_unlock
+ (JNIEnv *, jclass, jint, jlong, jlong);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: size
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL Java_gnu_java_nio_VMChannel_size
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: map
+ * Signature: (ICJI)Ljava/nio/MappedByteBuffer;
+ */
+JNIEXPORT jobject JNICALL Java_gnu_java_nio_VMChannel_map
+ (JNIEnv *, jclass, jint, jchar, jlong, jint);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: flush
+ * Signature: (IZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_gnu_java_nio_VMChannel_flush
+ (JNIEnv *, jclass, jint, jboolean);
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: close
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_gnu_java_nio_VMChannel_close
+ (JNIEnv *, jclass, jint);
#ifdef __cplusplus
}
#endif
+#endif
+/* Header for class gnu_java_nio_VMChannel_State */
-#endif /* __gnu_java_nio_VMChannel__ */
+#ifndef _Included_gnu_java_nio_VMChannel_State
+#define _Included_gnu_java_nio_VMChannel_State
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
+/* Header for class gnu_java_nio_VMChannel_Kind */
+
+#ifndef _Included_gnu_java_nio_VMChannel_Kind
+#define _Included_gnu_java_nio_VMChannel_Kind
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/include/gnu_java_nio_VMPipe.h b/include/gnu_java_nio_VMPipe.h
index afa563ac8..06d8001b7 100644
--- a/include/gnu_java_nio_VMPipe.h
+++ b/include/gnu_java_nio_VMPipe.h
@@ -1,19 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_nio_VMPipe__
-#define __gnu_java_nio_VMPipe__
-
#include <jni.h>
+/* Header for class gnu_java_nio_VMPipe */
+#ifndef _Included_gnu_java_nio_VMPipe
+#define _Included_gnu_java_nio_VMPipe
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_nio_VMPipe_init (JNIEnv *env, jclass, jobject, jobject);
+/*
+ * Class: gnu_java_nio_VMPipe
+ * Method: pipe0
+ * Signature: ()[I
+ */
+JNIEXPORT jintArray JNICALL Java_gnu_java_nio_VMPipe_pipe0
+ (JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
-
-#endif /* __gnu_java_nio_VMPipe__ */
+#endif
diff --git a/include/gnu_java_util_prefs_gconf_GConfNativePeer.h b/include/gnu_java_util_prefs_gconf_GConfNativePeer.h
index ec902cbb8..cc71b4097 100644
--- a/include/gnu_java_util_prefs_gconf_GConfNativePeer.h
+++ b/include/gnu_java_util_prefs_gconf_GConfNativePeer.h
@@ -20,8 +20,10 @@ JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_
JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1get_1string (JNIEnv *env, jclass, jstring);
JNIEXPORT jboolean JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1unset (JNIEnv *env, jclass, jstring);
JNIEXPORT void JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1suggest_1sync (JNIEnv *env, jclass);
-JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes (JNIEnv *env, jclass, jstring);
-JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys (JNIEnv *env, jclass, jstring);
+JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1nodes (JNIEnv *env, jclass, jstring);
+JNIEXPORT jobject JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1keys (JNIEnv *env, jclass, jstring);
+JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key (JNIEnv *env, jclass, jstring);
+JNIEXPORT jstring JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key (JNIEnv *env, jclass, jstring);
#ifdef __cplusplus
}
diff --git a/include/java_net_VMInetAddress.h b/include/java_net_VMInetAddress.h
index 54b57f220..66f473577 100644
--- a/include/java_net_VMInetAddress.h
+++ b/include/java_net_VMInetAddress.h
@@ -14,6 +14,7 @@ JNIEXPORT jstring JNICALL Java_java_net_VMInetAddress_getLocalHostname (JNIEnv *
JNIEXPORT jbyteArray JNICALL Java_java_net_VMInetAddress_lookupInaddrAny (JNIEnv *env, jclass);
JNIEXPORT jstring JNICALL Java_java_net_VMInetAddress_getHostByAddr (JNIEnv *env, jclass, jbyteArray);
JNIEXPORT jobjectArray JNICALL Java_java_net_VMInetAddress_getHostByName (JNIEnv *env, jclass, jstring);
+JNIEXPORT jbyteArray JNICALL Java_java_net_VMInetAddress_aton (JNIEnv *env, jclass, jstring);
#ifdef __cplusplus
}
diff --git a/include/java_net_VMNetworkInterface.h b/include/java_net_VMNetworkInterface.h
index c309357f3..4d5192d28 100644
--- a/include/java_net_VMNetworkInterface.h
+++ b/include/java_net_VMNetworkInterface.h
@@ -1,19 +1,29 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __java_net_VMNetworkInterface__
-#define __java_net_VMNetworkInterface__
-
#include <jni.h>
+/* Header for class java_net_VMNetworkInterface */
+#ifndef _Included_java_net_VMNetworkInterface
+#define _Included_java_net_VMNetworkInterface
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
+/*
+ * Class: java_net_VMNetworkInterface
+ * Method: initIds
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_java_net_VMNetworkInterface_initIds
+ (JNIEnv *, jclass);
-JNIEXPORT jobject JNICALL Java_java_net_VMNetworkInterface_getInterfaces (JNIEnv *env, jclass);
+/*
+ * Class: java_net_VMNetworkInterface
+ * Method: getVMInterfaces
+ * Signature: ()[Ljava/net/VMNetworkInterface;
+ */
+JNIEXPORT jobjectArray JNICALL Java_java_net_VMNetworkInterface_getVMInterfaces
+ (JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
-
-#endif /* __java_net_VMNetworkInterface__ */
+#endif
diff --git a/java/awt/AWTEvent.java b/java/awt/AWTEvent.java
index a6151b424..3f4027c2c 100644
--- a/java/awt/AWTEvent.java
+++ b/java/awt/AWTEvent.java
@@ -97,6 +97,11 @@ public abstract class AWTEvent extends EventObject
protected boolean consumed;
/**
+ * Used for implementing a simple linked list in EventQueue.
+ */
+ transient AWTEvent queueNext;
+
+ /**
* Who knows? It's in the serial version.
*
* @serial No idea what this is for.
diff --git a/java/awt/Choice.java b/java/awt/Choice.java
index 3113c599c..ae89b9e99 100644
--- a/java/awt/Choice.java
+++ b/java/awt/Choice.java
@@ -255,8 +255,8 @@ public class Choice extends Component
/**
* Adds the specified item to this choice box.
*
- * This method is oboslete since Java 2 platform 1.1. Please use @see add
- * instead.
+ * This method is oboslete since Java 2 platform 1.1. Please use
+ * {@link #add(String)} instead.
*
* @param item The item to add.
*
diff --git a/java/awt/Component.java b/java/awt/Component.java
index 26ba605b5..7688e2618 100644
--- a/java/awt/Component.java
+++ b/java/awt/Component.java
@@ -971,14 +971,14 @@ public abstract class Component
// case lightweight components are not initially painted --
// Container.paint first calls isShowing () before painting itself
// and its children.
- if(!isVisible())
+ if(! visible)
{
// Need to lock the tree here to avoid races and inconsistencies.
synchronized (getTreeLock())
{
visible = true;
// Avoid NullPointerExceptions by creating a local reference.
- ComponentPeer currentPeer=peer;
+ ComponentPeer currentPeer = peer;
if (currentPeer != null)
{
currentPeer.show();
@@ -990,7 +990,7 @@ public abstract class Component
// The JDK repaints the component before invalidating the parent.
// So do we.
- if (isLightweight())
+ if (peer instanceof LightweightPeer)
repaint();
}
@@ -1037,7 +1037,7 @@ public abstract class Component
*/
public void hide()
{
- if (isVisible())
+ if (visible)
{
// Need to lock the tree here to avoid races and inconsistencies.
synchronized (getTreeLock())
@@ -1180,31 +1180,78 @@ public abstract class Component
*/
public Font getFont()
{
- Font f = font;
- if (f != null)
- return f;
+ Font f;
+ synchronized (getTreeLock())
+ {
+ f = getFontImpl();
+ }
+ return f;
+ }
- Component p = parent;
- if (p != null)
- return p.getFont();
- return null;
+ /**
+ * Implementation of getFont(). This is pulled out of getFont() to prevent
+ * client programs from overriding this. This method is executed within
+ * a tree lock, so we can assume that the hierarchy doesn't change in
+ * between.
+ *
+ * @return the font of this component
+ */
+ private final Font getFontImpl()
+ {
+ Font f = font;
+ if (f == null)
+ {
+ Component p = parent;
+ if (p != null)
+ f = p.getFontImpl();
+ }
+ return f;
}
/**
* Sets the font for this component to the specified font. This is a bound
* property.
*
- * @param newFont the new font for this component
+ * @param f the new font for this component
*
* @see #getFont()
*/
- public void setFont(Font newFont)
+ public void setFont(Font f)
{
- Font oldFont = font;
- font = newFont;
- if (peer != null)
- peer.setFont(font);
+ Font oldFont;
+ Font newFont;
+ // Synchronize on the tree because getFontImpl() relies on the hierarchy
+ // not beeing changed.
+ synchronized (getTreeLock())
+ {
+ // Synchronize on this here to guarantee thread safety wrt to the
+ // property values.
+ synchronized (this)
+ {
+ oldFont = font;
+ font = f;
+ newFont = f;
+ }
+ // Create local variable here for thread safety.
+ ComponentPeer p = peer;
+ if (p != null)
+ {
+ // The peer receives the real font setting, which can depend on
+ // the parent font when this component's font has been set to null.
+ f = getFont();
+ if (f != null)
+ {
+ p.setFont(f);
+ peerFont = f;
+ }
+ }
+ }
+
+ // Fire property change event.
firePropertyChange("font", oldFont, newFont);
+
+ // Invalidate when necessary as font changes can change the size of the
+ // component.
if (valid)
invalidate();
}
@@ -2036,7 +2083,32 @@ public abstract class Component
*/
public void validate()
{
- valid = true;
+ if (! valid)
+ {
+ // Synchronize on the tree here as this might change the layout
+ // of the hierarchy.
+ synchronized (getTreeLock())
+ {
+ // Create local variables for thread safety.
+ ComponentPeer p = peer;
+ if (p != null)
+ {
+ // Possibly update the peer's font.
+ Font newFont = getFont();
+ Font oldFont = peerFont;
+ // Only update when the font really changed.
+ if (newFont != oldFont
+ && (oldFont == null || ! oldFont.equals(newFont)))
+ {
+ p.setFont(newFont);
+ peerFont = newFont;
+ }
+ // Let the peer perform any layout.
+ p.layout();
+ }
+ }
+ valid = true;
+ }
}
/**
@@ -2078,27 +2150,26 @@ public abstract class Component
{
// Only heavyweight peers can handle this.
ComponentPeer p = peer;
- Component comp = this;
- int offsX = 0;
- int offsY = 0;
- while (p instanceof LightweightPeer)
+ Graphics g = null;
+ if (p instanceof LightweightPeer)
{
- offsX += comp.x;
- offsY += comp.y;
- comp = comp.parent;
- p = comp == null ? null : comp.peer;
+ if (parent != null)
+ {
+ g = parent.getGraphics();
+ if (g != null)
+ {
+ g.translate(x, y);
+ g.setClip(0, 0, width, height);
+ g.setFont(getFont());
+ }
+ }
}
-
- Graphics gfx = null;
- if (p != null)
+ else
{
- assert ! (p instanceof LightweightPeer);
- gfx = p.getGraphics();
- gfx.translate(offsX, offsY);
- gfx.clipRect(0, 0, width, height);
- gfx.setFont(font);
+ if (p != null)
+ g = p.getGraphics();
}
- return gfx;
+ return g;
}
/**
@@ -2229,9 +2300,14 @@ public abstract class Component
*/
public void paintAll(Graphics g)
{
- if (! visible)
- return;
- paint(g);
+ if (isShowing())
+ {
+ validate();
+ if (peer instanceof LightweightPeer)
+ paint(g);
+ else
+ peer.paint(g);
+ }
}
/**
@@ -2302,36 +2378,32 @@ public abstract class Component
// Let the nearest heavyweight parent handle repainting for lightweight
// components.
- // This goes up the hierarchy until we hit
- // a heavyweight component that handles this and translates the
- // rectangle while doing so.
-
- // We perform some boundary checking to restrict the paint
- // region to this component.
- int px = (x < 0 ? 0 : x);
- int py = (y < 0 ? 0 : y);
- int pw = width;
- int ph = height;
- Component par = this;
- while (par != null && p instanceof LightweightPeer)
+ // We need to recursivly call repaint() on the parent here, since
+ // a (lightweight) parent component might have overridden repaint()
+ // to perform additional custom tasks.
+
+ if (p instanceof LightweightPeer)
{
- px += par.x;
- py += par.y;
// We perform some boundary checking to restrict the paint
// region to this component.
- pw = Math.min(pw, par.width);
- ph = Math.min(ph, par.height);
- par = par.parent;
- p = par == null ? null : par.peer;
+ if (parent != null)
+ {
+ int px = this.x + Math.max(0, x);
+ int py = this.y + Math.max(0, y);
+ int pw = Math.min(this.width, width);
+ int ph = Math.min(this.height, height);
+ parent.repaint(tm, px, py, pw, ph);
+ }
}
-
- // Now send an UPDATE event to the heavyweight component that we've found.
- if (par != null && par.isVisible() && p != null && pw > 0 && ph > 0)
+ else
{
- assert ! (p instanceof LightweightPeer);
- PaintEvent pe = new PaintEvent(par, PaintEvent.UPDATE,
- new Rectangle(px, py, pw, ph));
- getToolkit().getSystemEventQueue().postEvent(pe);
+ // Now send an UPDATE event to the heavyweight component that we've found.
+ if (isVisible() && p != null && width > 0 && height > 0)
+ {
+ PaintEvent pe = new PaintEvent(this, PaintEvent.UPDATE,
+ new Rectangle(x, y, width, height));
+ getToolkit().getSystemEventQueue().postEvent(pe);
+ }
}
}
@@ -2459,7 +2531,8 @@ public abstract class Component
p = comp == null ? null : comp.peer;
}
- returnValue = p.createImage(width, height);
+ if (p != null)
+ returnValue = p.createImage(width, height);
}
return returnValue;
}
@@ -2756,14 +2829,6 @@ public abstract class Component
*/
public final void dispatchEvent(AWTEvent e)
{
- Event oldEvent = translateEvent(e);
- if (oldEvent != null)
- postEvent (oldEvent);
-
- // Give toolkit a chance to dispatch the event
- // to globally registered listeners.
- Toolkit.getDefaultToolkit().globalDispatchEvent(e);
-
// Some subclasses in the AWT package need to override this behavior,
// hence the use of dispatchEventImpl().
dispatchEventImpl(e);
@@ -2814,9 +2879,12 @@ public abstract class Component
*/
public synchronized void addComponentListener(ComponentListener listener)
{
- componentListener = AWTEventMulticaster.add(componentListener, listener);
- if (componentListener != null)
- enableEvents(AWTEvent.COMPONENT_EVENT_MASK);
+ if (listener != null)
+ {
+ componentListener = AWTEventMulticaster.add(componentListener,
+ listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -2862,9 +2930,11 @@ public abstract class Component
*/
public synchronized void addFocusListener(FocusListener listener)
{
- focusListener = AWTEventMulticaster.add(focusListener, listener);
- if (focusListener != null)
- enableEvents(AWTEvent.FOCUS_EVENT_MASK);
+ if (listener != null)
+ {
+ focusListener = AWTEventMulticaster.add(focusListener, listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -2909,16 +2979,19 @@ public abstract class Component
*/
public synchronized void addHierarchyListener(HierarchyListener listener)
{
- hierarchyListener = AWTEventMulticaster.add(hierarchyListener, listener);
- if (hierarchyListener != null)
- enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);
-
- // Need to lock the tree, otherwise we might end up inconsistent.
- synchronized (getTreeLock())
+ if (listener != null)
{
- numHierarchyListeners++;
- if (parent != null)
- parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK, 1);
+ hierarchyListener = AWTEventMulticaster.add(hierarchyListener,
+ listener);
+ newEventsOnly = true;
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ 1);
+ }
}
}
@@ -2975,19 +3048,20 @@ public abstract class Component
public synchronized void
addHierarchyBoundsListener(HierarchyBoundsListener listener)
{
- hierarchyBoundsListener =
- AWTEventMulticaster.add(hierarchyBoundsListener, listener);
- if (hierarchyBoundsListener != null)
- enableEvents(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
-
- // Need to lock the tree, otherwise we might end up inconsistent.
- synchronized (getTreeLock())
+ if (listener != null)
{
- numHierarchyBoundsListeners++;
- if (parent != null)
- parent.updateHierarchyListenerCount
- (AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
- 1);
+ hierarchyBoundsListener =
+ AWTEventMulticaster.add(hierarchyBoundsListener, listener);
+ newEventsOnly = true;
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyBoundsListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount
+ (AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK, 1);
+ }
}
}
@@ -3080,9 +3154,11 @@ public abstract class Component
*/
public synchronized void addKeyListener(KeyListener listener)
{
- keyListener = AWTEventMulticaster.add(keyListener, listener);
- if (keyListener != null)
- enableEvents(AWTEvent.KEY_EVENT_MASK);
+ if (listener != null)
+ {
+ keyListener = AWTEventMulticaster.add(keyListener, listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -3127,9 +3203,11 @@ public abstract class Component
*/
public synchronized void addMouseListener(MouseListener listener)
{
- mouseListener = AWTEventMulticaster.add(mouseListener, listener);
- if (mouseListener != null)
- enableEvents(AWTEvent.MOUSE_EVENT_MASK);
+ if (listener != null)
+ {
+ mouseListener = AWTEventMulticaster.add(mouseListener, listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -3174,9 +3252,12 @@ public abstract class Component
*/
public synchronized void addMouseMotionListener(MouseMotionListener listener)
{
- mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, listener);
- if (mouseMotionListener != null)
- enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
+ if (listener != null)
+ {
+ mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener,
+ listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -3223,9 +3304,12 @@ public abstract class Component
*/
public synchronized void addMouseWheelListener(MouseWheelListener listener)
{
- mouseWheelListener = AWTEventMulticaster.add(mouseWheelListener, listener);
- if (mouseWheelListener != null)
- enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
+ if (listener != null)
+ {
+ mouseWheelListener = AWTEventMulticaster.add(mouseWheelListener,
+ listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -3273,9 +3357,12 @@ public abstract class Component
*/
public synchronized void addInputMethodListener(InputMethodListener listener)
{
- inputMethodListener = AWTEventMulticaster.add(inputMethodListener, listener);
- if (inputMethodListener != null)
- enableEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);
+ if (listener != null)
+ {
+ inputMethodListener = AWTEventMulticaster.add(inputMethodListener,
+ listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -3430,6 +3517,7 @@ public abstract class Component
}
eventMask |= eventsToEnable;
+ newEventsOnly = true;
// Only heavyweight peers handle this.
ComponentPeer p = peer;
@@ -3512,19 +3600,36 @@ public abstract class Component
*/
protected AWTEvent coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)
{
+ AWTEvent coalesced = null;
switch (existingEvent.id)
{
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
// Just drop the old (intermediate) event and return the new one.
- return newEvent;
+ MouseEvent me1 = (MouseEvent) existingEvent;
+ MouseEvent me2 = (MouseEvent) newEvent;
+ if (me1.getModifiers() == me2.getModifiers())
+ coalesced = newEvent;
+ break;
case PaintEvent.PAINT:
case PaintEvent.UPDATE:
- return coalescePaintEvents((PaintEvent) existingEvent,
- (PaintEvent) newEvent);
+ // For heavyweights the EventQueue should ask the peer.
+ if (peer == null || peer instanceof LightweightPeer)
+ {
+ PaintEvent pe1 = (PaintEvent) existingEvent;
+ PaintEvent pe2 = (PaintEvent) newEvent;
+ Rectangle r1 = pe1.getUpdateRect();
+ Rectangle r2 = pe2.getUpdateRect();
+ if (r1.contains(r2))
+ coalesced = existingEvent;
+ else if (r2.contains(r1))
+ coalesced = newEvent;
+ }
+ break;
default:
- return null;
+ coalesced = null;
}
+ return coalesced;
}
/**
@@ -4046,23 +4151,29 @@ public abstract class Component
peer = getToolkit().createComponent(this);
else if (parent != null && parent.isLightweight())
new HeavyweightInLightweightListener(parent);
- /* Now that all the children has gotten their peers, we should
- have the event mask needed for this component and its
- lightweight subcomponents. */
+ // Now that all the children has gotten their peers, we should
+ // have the event mask needed for this component and its
+ //lightweight subcomponents.
peer.setEventMask(eventMask);
- /* We do not invalidate here, but rather leave that job up to
- the peer. For efficiency, the peer can choose not to
- invalidate if it is happy with the current dimensions,
- etc. */
- if (dropTarget != null)
- dropTarget.addNotify(peer);
-
- // Notify hierarchy listeners.
- long flags = HierarchyEvent.DISPLAYABILITY_CHANGED;
- if (isHierarchyVisible())
- flags |= HierarchyEvent.SHOWING_CHANGED;
- fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, this, parent,
- flags);
+
+ // We used to leave the invalidate() to the peer. However, I put it
+ // back here for 2 reasons: 1) The RI does call invalidate() from
+ // addNotify(); 2) The peer shouldn't be bother with validation too
+ // much.
+ invalidate();
+
+ if (dropTarget != null)
+ dropTarget.addNotify(peer);
+
+ // Fetch the peerFont for later installation in validate().
+ peerFont = getFont();
+
+ // Notify hierarchy listeners.
+ long flags = HierarchyEvent.DISPLAYABILITY_CHANGED;
+ if (isHierarchyVisible())
+ flags |= HierarchyEvent.SHOWING_CHANGED;
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, this, parent,
+ flags);
}
}
@@ -4087,6 +4198,7 @@ public abstract class Component
ComponentPeer tmp = peer;
peer = null;
+ peerFont = null;
if (tmp != null)
{
tmp.hide();
@@ -5542,7 +5654,7 @@ p * <li>the set of backward traversal keys
oldKey = Event.UP;
break;
default:
- oldKey = (int) ((KeyEvent) e).getKeyChar();
+ oldKey = ((KeyEvent) e).getKeyChar();
}
translated = new Event (target, when, oldID,
@@ -5585,7 +5697,6 @@ p * <li>the set of backward traversal keys
*
* @param e the event to dispatch
*/
-
void dispatchEventImpl(AWTEvent e)
{
// Retarget focus events before dispatching it to the KeyboardFocusManager
@@ -5600,11 +5711,21 @@ p * <li>the set of backward traversal keys
if (! dispatched)
{
- if (eventTypeEnabled (e.id))
+ // Give toolkit a chance to dispatch the event
+ // to globally registered listeners.
+ Toolkit.getDefaultToolkit().globalDispatchEvent(e);
+
+ if (newEventsOnly)
{
- if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE)
+ if (eventTypeEnabled(e.id))
processEvent(e);
}
+ else
+ {
+ Event oldEvent = translateEvent(e);
+ if (oldEvent != null)
+ postEvent (oldEvent);
+ }
if (peer != null)
peer.handleEvent(e);
}
@@ -5697,45 +5818,6 @@ p * <li>the set of backward traversal keys
}
/**
- * Coalesce paint events. Current heuristic is: Merge if the union of
- * areas is less than twice that of the sum of the areas. The X server
- * tend to create a lot of paint events that are adjacent but not
- * overlapping.
- *
- * <pre>
- * +------+
- * | +-----+ ...will be merged
- * | | |
- * | | |
- * +------+ |
- * +-----+
- *
- * +---------------+--+
- * | | | ...will not be merged
- * +---------------+ |
- * | |
- * | |
- * | |
- * | |
- * | |
- * +--+
- * </pre>
- *
- * @param queuedEvent the first paint event
- * @param newEvent the second paint event
- * @return the combined paint event, or null
- */
- private PaintEvent coalescePaintEvents(PaintEvent queuedEvent,
- PaintEvent newEvent)
- {
- Rectangle r1 = queuedEvent.getUpdateRect();
- Rectangle r2 = newEvent.getUpdateRect();
- Rectangle union = r1.union(r2);
- newEvent.setUpdateRect(union);
- return newEvent;
- }
-
- /**
* This method is used to implement transferFocus(). CHILD is the child
* making the request. This is overridden by Container; when called for an
* ordinary component there is no child and so we always return null.
@@ -5875,7 +5957,7 @@ p * <li>the set of backward traversal keys
*/
public void componentHidden(ComponentEvent event)
{
- if (!isShowing())
+ if (isShowing())
peer.hide();
}
}
diff --git a/java/awt/Container.java b/java/awt/Container.java
index 17ca3e0ad..3d460baaf 100644
--- a/java/awt/Container.java
+++ b/java/awt/Container.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package java.awt;
-import java.awt.event.ComponentListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.HierarchyEvent;
@@ -325,23 +324,6 @@ public class Container extends Component
// we are.
if (comp.parent != null)
comp.parent.remove(comp);
- comp.parent = this;
-
- if (peer != null)
- {
- // Notify the component that it has a new parent.
- comp.addNotify();
-
- if (comp.isLightweight ())
- {
- enableEvents (comp.eventMask);
- if (!isLightweight ())
- enableEvents (AWTEvent.PAINT_EVENT_MASK);
- }
- }
-
- // Invalidate the layout of the added component and its ancestors.
- comp.invalidate();
if (component == null)
component = new Component[4]; // FIXME, better initial size?
@@ -366,6 +348,9 @@ public class Container extends Component
++ncomponents;
}
+ // Give the new component a parent.
+ comp.parent = this;
+
// Update the counter for Hierarchy(Bounds)Listeners.
int childHierarchyListeners = comp.numHierarchyListeners;
if (childHierarchyListeners > 0)
@@ -376,6 +361,18 @@ public class Container extends Component
updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
childHierarchyListeners);
+ // Invalidate the layout of this container.
+ if (valid)
+ invalidate();
+
+ // Create the peer _after_ the component has been added, so that
+ // the peer gets to know about the component hierarchy.
+ if (peer != null)
+ {
+ // Notify the component that it has a new parent.
+ comp.addNotify();
+ }
+
// Notify the layout manager.
if (layoutMgr != null)
{
@@ -395,13 +392,15 @@ public class Container extends Component
// We previously only sent an event when this container is showing.
// Also, the event was posted to the event queue. A Mauve test shows
// that this event is not delivered using the event queue and it is
- // also sent when the container is not showing.
- ContainerEvent ce = new ContainerEvent(this,
- ContainerEvent.COMPONENT_ADDED,
- comp);
- ContainerListener[] listeners = getContainerListeners();
- for (int i = 0; i < listeners.length; i++)
- listeners[i].componentAdded(ce);
+ // also sent when the container is not showing.
+ if (containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
+ {
+ ContainerEvent ce = new ContainerEvent(this,
+ ContainerEvent.COMPONENT_ADDED,
+ comp);
+ dispatchEvent(ce);
+ }
// Notify hierarchy listeners.
comp.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, comp,
@@ -418,17 +417,15 @@ public class Container extends Component
{
synchronized (getTreeLock ())
{
- Component r = component[index];
+ if (index < 0 || index >= ncomponents)
+ throw new ArrayIndexOutOfBoundsException();
- ComponentListener[] list = r.getComponentListeners();
- for (int j = 0; j < list.length; j++)
- r.removeComponentListener(list[j]);
-
- r.removeNotify();
+ Component r = component[index];
+ if (peer != null)
+ r.removeNotify();
- System.arraycopy(component, index + 1, component, index,
- ncomponents - index - 1);
- component[--ncomponents] = null;
+ if (layoutMgr != null)
+ layoutMgr.removeLayoutComponent(r);
// Update the counter for Hierarchy(Bounds)Listeners.
int childHierarchyListeners = r.numHierarchyListeners;
@@ -440,20 +437,23 @@ public class Container extends Component
updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
-childHierarchyListeners);
- invalidate();
+ r.parent = null;
- if (layoutMgr != null)
- layoutMgr.removeLayoutComponent(r);
+ System.arraycopy(component, index + 1, component, index,
+ ncomponents - index - 1);
+ component[--ncomponents] = null;
- r.parent = null;
+ if (valid)
+ invalidate();
- if (isShowing ())
+ if (containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
{
// Post event to notify of removing the component.
ContainerEvent ce = new ContainerEvent(this,
- ContainerEvent.COMPONENT_REMOVED,
- r);
- getToolkit().getSystemEventQueue().postEvent(ce);
+ ContainerEvent.COMPONENT_REMOVED,
+ r);
+ dispatchEvent(ce);
}
// Notify hierarchy listeners.
@@ -497,25 +497,14 @@ public class Container extends Component
// super.removeAll() ).
// By doing it this way, user code cannot prevent the correct
// removal of components.
- for ( int index = 0; index < ncomponents; index++)
+ while (ncomponents > 0)
{
- Component r = component[index];
-
- ComponentListener[] list = r.getComponentListeners();
- for (int j = 0; j < list.length; j++)
- r.removeComponentListener(list[j]);
-
- r.removeNotify();
+ ncomponents--;
+ Component r = component[ncomponents];
+ component[ncomponents] = null;
- // Update the counter for Hierarchy(Bounds)Listeners.
- int childHierarchyListeners = r.numHierarchyListeners;
- if (childHierarchyListeners > 0)
- updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
- -childHierarchyListeners);
- int childHierarchyBoundsListeners = r.numHierarchyBoundsListeners;
- if (childHierarchyBoundsListeners > 0)
- updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
- -childHierarchyListeners);
+ if (peer != null)
+ r.removeNotify();
if (layoutMgr != null)
layoutMgr.removeLayoutComponent(r);
@@ -534,6 +523,17 @@ public class Container extends Component
dispatchEvent(ce);
}
+ // Update the counter for Hierarchy(Bounds)Listeners.
+ int childHierarchyListeners = r.numHierarchyListeners;
+ if (childHierarchyListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ -childHierarchyListeners);
+ int childHierarchyBoundsListeners = r.numHierarchyBoundsListeners;
+ if (childHierarchyBoundsListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ -childHierarchyListeners);
+
+
// Send HierarchyEvent if necessary.
fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, r, this,
HierarchyEvent.PARENT_CHANGED);
@@ -542,8 +542,6 @@ public class Container extends Component
if (valid)
invalidate();
-
- ncomponents = 0;
}
}
@@ -620,24 +618,20 @@ public class Container extends Component
/**
* Recursively invalidates the container tree.
*/
- void invalidateTree()
+ private final void invalidateTree()
{
synchronized (getTreeLock())
{
- super.invalidate(); // Clean cached layout state.
for (int i = 0; i < ncomponents; i++)
{
Component comp = component[i];
- comp.invalidate();
if (comp instanceof Container)
((Container) comp).invalidateTree();
+ else if (comp.valid)
+ comp.invalidate();
}
-
- if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
- {
- LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
- lm2.invalidateLayout(this);
- }
+ if (valid)
+ invalidate();
}
}
@@ -688,13 +682,11 @@ public class Container extends Component
public void setFont(Font f)
{
- if( (f != null && (font == null || !font.equals(f)))
- || f == null)
+ Font oldFont = getFont();
+ super.setFont(f);
+ Font newFont = getFont();
+ if (newFont != oldFont && (oldFont == null || ! oldFont.equals(newFont)))
{
- super.setFont(f);
- // FIXME: Although it might make more sense to invalidate only
- // those children whose font == null, Sun invalidates all children.
- // So we'll do the same.
invalidateTree();
}
}
@@ -796,8 +788,9 @@ public class Container extends Component
LayoutManager l = layoutMgr;
if (l instanceof LayoutManager2)
maxSize = ((LayoutManager2) l).maximumLayoutSize(this);
- else
+ else {
maxSize = super.maximumSizeImpl();
+ }
size = maxSize;
}
}
@@ -932,8 +925,8 @@ public class Container extends Component
*/
public void paintComponents(Graphics g)
{
- paint(g);
- visitChildren(g, GfxPaintAllVisitor.INSTANCE, true);
+ if (isShowing())
+ visitChildren(g, GfxPaintAllVisitor.INSTANCE, false);
}
/**
@@ -955,7 +948,12 @@ public class Container extends Component
*/
public synchronized void addContainerListener(ContainerListener listener)
{
- containerListener = AWTEventMulticaster.add(containerListener, listener);
+ if (listener != null)
+ {
+ containerListener = AWTEventMulticaster.add(containerListener,
+ listener);
+ newEventsOnly = true;
+ }
}
/**
@@ -1259,8 +1257,14 @@ public class Container extends Component
{
synchronized (getTreeLock ())
{
- for (int i = 0; i < ncomponents; ++i)
- component[i].removeNotify();
+ int ncomps = ncomponents;
+ Component[] comps = component;
+ for (int i = ncomps - 1; i >= 0; --i)
+ {
+ Component comp = comps[i];
+ if (comp != null)
+ comp.removeNotify();
+ }
super.removeNotify();
}
}
@@ -1880,6 +1884,7 @@ public class Container extends Component
bounds.height);
try
{
+ g2.setFont(comp.getFont());
visitor.visit(comp, g2);
}
finally
@@ -1888,20 +1893,40 @@ public class Container extends Component
}
}
+ /**
+ * Overridden to dispatch events to lightweight descendents.
+ *
+ * @param e the event to dispatch.
+ */
void dispatchEventImpl(AWTEvent e)
{
- boolean dispatched =
- LightweightDispatcher.getInstance().dispatchEvent(e);
- if (! dispatched)
+ LightweightDispatcher dispatcher = LightweightDispatcher.getInstance();
+ if (! isLightweight() && dispatcher.dispatchEvent(e))
{
- if ((e.id <= ContainerEvent.CONTAINER_LAST
- && e.id >= ContainerEvent.CONTAINER_FIRST)
- && (containerListener != null
- || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
- processEvent(e);
- else
- super.dispatchEventImpl(e);
+ // Some lightweight descendent got this event dispatched. Consume
+ // it and let the peer handle it.
+ e.consume();
+ ComponentPeer p = peer;
+ if (p != null)
+ p.handleEvent(e);
}
+ else
+ {
+ super.dispatchEventImpl(e);
+ }
+ }
+
+ /**
+ * This is called by the lightweight dispatcher to avoid recursivly
+ * calling into the lightweight dispatcher.
+ *
+ * @param e the event to dispatch
+ *
+ * @see LightweightDispatcher#redispatch(MouseEvent, Component, int)
+ */
+ void dispatchNoLightweight(AWTEvent e)
+ {
+ super.dispatchEventImpl(e);
}
/**
@@ -2062,12 +2087,6 @@ public class Container extends Component
for (int i = ncomponents; --i >= 0; )
{
component[i].addNotify();
- if (component[i].isLightweight ())
- {
- enableEvents(component[i].eventMask);
- if (peer != null && !isLightweight ())
- enableEvents (AWTEvent.PAINT_EVENT_MASK);
- }
}
}
}
diff --git a/java/awt/EventQueue.java b/java/awt/EventQueue.java
index 235ad2ac1..e1f109098 100644
--- a/java/awt/EventQueue.java
+++ b/java/awt/EventQueue.java
@@ -38,10 +38,15 @@ exception statement from your version. */
package java.awt;
+import gnu.java.awt.LowPriorityEvent;
+
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.InputMethodEvent;
import java.awt.event.InvocationEvent;
+import java.awt.event.PaintEvent;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
import java.lang.reflect.InvocationTargetException;
import java.util.EmptyStackException;
@@ -61,11 +66,47 @@ import java.util.EmptyStackException;
*/
public class EventQueue
{
- private static final int INITIAL_QUEUE_DEPTH = 8;
- private AWTEvent[] queue = new AWTEvent[INITIAL_QUEUE_DEPTH];
+ /**
+ * Indicates events that are processed with normal priority. This is normally
+ * all events except PaintEvents.
+ */
+ private static final int NORM_PRIORITY = 0;
+
+ /**
+ * Indicates events that are processed with lowes priority. This is normally
+ * all PaintEvents and LowPriorityEvents.
+ */
+ private static final int LOW_PRIORITY = 1;
+
+ /**
+ * Implements the actual queue. EventQueue has 2 internal queues for
+ * different priorities:
+ * 1 PaintEvents are always dispatched with low priority.
+ * 2. All other events are dispatched with normal priority.
+ *
+ * This makes sure that the actual painting (output) is performed _after_ all
+ * available input has been processed and that the paint regions are
+ * coalesced as much as possible.
+ */
+ private class Queue
+ {
+ /**
+ * The first item in the queue. This is where events are popped from.
+ */
+ AWTEvent queueHead;
+
+ /**
+ * The last item. This is where events are posted to.
+ */
+ AWTEvent queueTail;
+ }
- private int next_in = 0; // Index where next event will be added to queue
- private int next_out = 0; // Index of next event to be removed from queue
+ /**
+ * The three internal event queues.
+ *
+ * @see Queue
+ */
+ private Queue[] queues;
private EventQueue next;
private EventQueue prev;
@@ -105,6 +146,9 @@ public class EventQueue
*/
public EventQueue()
{
+ queues = new Queue[2];
+ queues[NORM_PRIORITY] = new Queue();
+ queues[LOW_PRIORITY] = new Queue();
}
/**
@@ -122,7 +166,8 @@ public class EventQueue
if (next != null)
return next.getNextEvent();
- while (next_in == next_out)
+ AWTEvent res = getNextEventImpl(true);
+ while (res == null)
{
// We are not allowed to return null from this method, yet it
// is possible that we actually have run out of native events
@@ -137,16 +182,47 @@ public class EventQueue
throw new InterruptedException();
wait();
+ res = getNextEventImpl(true);
}
- AWTEvent res = queue[next_out];
-
- if (++next_out == queue.length)
- next_out = 0;
return res;
}
/**
+ * Fetches and possibly removes the next event from the internal queues.
+ * This method returns immediately. When all queues are empty, this returns
+ * <code>null</code>:
+ *
+ * @param remove <true> when the event should be removed from the queue,
+ * <code>false</code> otherwise
+ *
+ * @return the next event or <code>null</code> when all internal queues
+ * are empty
+ */
+ private AWTEvent getNextEventImpl(boolean remove)
+ {
+ AWTEvent next = null;
+ for (int i = 0; i < queues.length && next == null; i++)
+ {
+ Queue q = queues[i];
+ if (q.queueHead != null)
+ {
+ // Got an event, remove it.
+ next = q.queueHead;
+ if (remove)
+ {
+ // Unlink event from the queue.
+ q.queueHead = next.queueNext;
+ if (q.queueHead == null)
+ q.queueTail = null;
+ next.queueNext = null;
+ }
+ }
+ }
+ return next;
+ }
+
+ /**
* Returns the next event in the queue without removing it from the queue.
* This method will block until an event is available or until the thread
* is interrupted.
@@ -160,10 +236,7 @@ public class EventQueue
if (next != null)
return next.peekEvent();
- if (next_in != next_out)
- return queue[next_out];
- else
- return null;
+ return getNextEventImpl(false);
}
/**
@@ -184,14 +257,18 @@ public class EventQueue
if (next != null)
return next.peekEvent(id);
- int i = next_out;
- while (i != next_in)
+ AWTEvent evt = null;
+ for (int i = 0; i < queues.length && evt == null; i++)
{
- AWTEvent qevt = queue[i];
- if (qevt.id == id)
- return qevt;
+ Queue q = queues[i];
+ evt = q.queueHead;
+ while (evt != null && evt.id != id)
+ evt = evt.queueNext;
+ // At this point we either have found an event (evt != null -> exit
+ // for loop), or we have found no event (evt == null -> search next
+ // internal queue).
}
- return null;
+ return evt;
}
/**
@@ -201,7 +278,36 @@ public class EventQueue
*
* @exception NullPointerException If event is null.
*/
- public synchronized void postEvent(AWTEvent evt)
+ public void postEvent(AWTEvent evt)
+ {
+ postEventImpl(evt);
+ }
+
+ /**
+ * Sorts events to their priority and calls
+ * {@link #postEventImpl(AWTEvent, int)}.
+ *
+ * @param evt the event to post
+ */
+ private synchronized final void postEventImpl(AWTEvent evt)
+ {
+ int priority = NORM_PRIORITY;
+ if (evt instanceof PaintEvent || evt instanceof LowPriorityEvent)
+ priority = LOW_PRIORITY;
+ // TODO: Maybe let Swing RepaintManager events also be processed with
+ // low priority.
+ postEventImpl(evt, priority);
+ }
+
+ /**
+ * Actually performs the event posting. This is needed because the
+ * RI doesn't use the public postEvent() method when transferring events
+ * between event queues in push() and pop().
+ *
+ * @param evt the event to post
+ * @param priority the priority of the event
+ */
+ private final void postEventImpl(AWTEvent evt, int priority)
{
if (evt == null)
throw new NullPointerException();
@@ -212,52 +318,71 @@ public class EventQueue
return;
}
- /* Check for any events already on the queue with the same source
- and ID. */
- int i = next_out;
- while (i != next_in)
+ Object source = evt.getSource();
+
+ Queue q = queues[priority];
+ if (source instanceof Component)
{
- AWTEvent qevt = queue[i];
- Object src;
- if (qevt.id == evt.id
- && (src = qevt.getSource()) == evt.getSource()
- && src instanceof Component)
+ // For PaintEvents, ask the ComponentPeer to coalesce the event
+ // when the component is heavyweight.
+ Component comp = (Component) source;
+ ComponentPeer peer = comp.peer;
+ if (peer != null && evt instanceof PaintEvent
+ && ! (peer instanceof LightweightPeer))
+ peer.coalescePaintEvent((PaintEvent) evt);
+
+ // Check for any events already on the queue with the same source
+ // and ID.
+ AWTEvent previous = null;
+ for (AWTEvent qevt = q.queueHead; qevt != null; qevt = qevt.queueNext)
{
- /* If there are, call coalesceEvents on the source component
- to see if they can be combined. */
- Component srccmp = (Component) src;
- AWTEvent coalesced_evt = srccmp.coalesceEvents(qevt, evt);
- if (coalesced_evt != null)
+ Object src = qevt.getSource();
+ if (qevt.id == evt.id && src == comp)
{
- /* Yes. Replace the existing event with the combined event. */
- queue[i] = coalesced_evt;
- return;
+ // If there are, call coalesceEvents on the source component
+ // to see if they can be combined.
+ Component srccmp = (Component) src;
+ AWTEvent coalescedEvt = srccmp.coalesceEvents(qevt, evt);
+ if (coalescedEvt != null)
+ {
+ // Yes. Replace the existing event with the combined event.
+ if (qevt != coalescedEvt)
+ {
+ if (previous != null)
+ {
+ assert previous.queueNext == qevt;
+ previous.queueNext = coalescedEvt;
+ }
+ else
+ {
+ assert q.queueHead == qevt;
+ q.queueHead = coalescedEvt;
+ }
+ coalescedEvt.queueNext = qevt.queueNext;
+ if (q.queueTail == qevt)
+ q.queueTail = coalescedEvt;
+ qevt.queueNext = null;
+ }
+ return;
+ }
}
- break;
+ previous = qevt;
}
- if (++i == queue.length)
- i = 0;
}
- queue[next_in] = evt;
- if (++next_in == queue.length)
- next_in = 0;
-
- if (next_in == next_out)
+ if (q.queueHead == null)
{
- /* Queue is full. Extend it. */
- AWTEvent[] oldQueue = queue;
- queue = new AWTEvent[queue.length * 2];
-
- int len = oldQueue.length - next_out;
- System.arraycopy(oldQueue, next_out, queue, 0, len);
- if (next_out != 0)
- System.arraycopy(oldQueue, 0, queue, len, next_out);
-
- next_out = 0;
- next_in = oldQueue.length;
+ // We have an empty queue. Set this event both as head and as tail.
+ q.queueHead = evt;
+ q.queueTail = evt;
}
-
+ else
+ {
+ // Note: queueTail should not be null here.
+ q.queueTail.queueNext = evt;
+ q.queueTail = evt;
+ }
+
if (dispatchThread == null || !dispatchThread.isAlive())
{
dispatchThread = new EventDispatchThread(this);
@@ -287,15 +412,15 @@ public class EventQueue
throw new Error("Can't call invokeAndWait from event dispatch thread");
EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
- Thread current = Thread.currentThread();
+ Object notifyObject = new Object();
- InvocationEvent ie =
- new InvocationEvent(eq, runnable, current, true);
+ InvocationEvent ie =
+ new InvocationEvent(eq, runnable, notifyObject, true);
- synchronized (current)
+ synchronized (notifyObject)
{
eq.postEvent(ie);
- current.wait();
+ notifyObject.wait();
}
Exception exception;
@@ -387,17 +512,26 @@ public class EventQueue
if (dispatchThread == null)
dispatchThread = new EventDispatchThread(this);
- int i = next_out;
- while (i != next_in)
+ synchronized (newEventQueue)
{
- newEventQueue.postEvent(queue[i]);
- next_out = i;
- if (++i == queue.length)
- i = 0;
+ // The RI transfers the events without calling the new eventqueue's
+ // push(), but using getNextEvent().
+ while (peekEvent() != null)
+ {
+ try
+ {
+ newEventQueue.postEventImpl(getNextEvent());
+ }
+ catch (InterruptedException ex)
+ {
+ // What should we do with this?
+ ex.printStackTrace();
+ }
+ }
+ newEventQueue.prev = this;
}
next = newEventQueue;
- newEventQueue.prev = this;
}
/** Transfer any pending events from this queue back to the parent queue that
@@ -408,36 +542,46 @@ public class EventQueue
*/
protected void pop() throws EmptyStackException
{
- if (prev == null)
- throw new EmptyStackException();
-
/* The order is important here, we must get the prev lock first,
or deadlock could occur as callers usually get here following
prev's next pointer, and thus obtain prev's lock before trying
to get this lock. */
- synchronized (prev)
+ EventQueue previous = prev;
+ if (previous == null)
+ throw new EmptyStackException();
+ synchronized (previous)
{
- prev.next = next;
- if (next != null)
- next.prev = prev;
-
synchronized (this)
{
- int i = next_out;
- while (i != next_in)
+ EventQueue nextQueue = next;
+ if (nextQueue != null)
{
- prev.postEvent(queue[i]);
- next_out = i;
- if (++i == queue.length)
- i = 0;
+ nextQueue.pop();
+ }
+ else
+ {
+ previous.next = null;
+
+ // The RI transfers the events without calling the new eventqueue's
+ // push(), so this should be OK and most effective.
+ while (peekEvent() != null)
+ {
+ try
+ {
+ previous.postEventImpl(getNextEvent());
+ }
+ catch (InterruptedException ex)
+ {
+ // What should we do with this?
+ ex.printStackTrace();
+ }
+ }
+
+ prev = null;
+ setShutdown(true);
+ dispatchThread = null;
+ this.notifyAll();
}
- // Empty the queue so it can be reused
- next_in = 0;
- next_out = 0;
-
- setShutdown(true);
- dispatchThread = null;
- this.notifyAll();
}
}
}
diff --git a/java/awt/Frame.java b/java/awt/Frame.java
index 542013671..e0c0d1ff3 100644
--- a/java/awt/Frame.java
+++ b/java/awt/Frame.java
@@ -340,13 +340,16 @@ public class Frame extends Window implements MenuContainer
parent.remove(menuBar);
menuBar.setParent(this);
- if (peer != null)
- {
- if (menuBar != null)
- menuBar.addNotify();
- invalidateTree();
- ((FramePeer) peer).setMenuBar(menuBar);
- }
+ // Create local copy for thread safety.
+ FramePeer p = (FramePeer) peer;
+ if (p != null)
+ {
+ if (menuBar != null)
+ menuBar.addNotify();
+ if (valid)
+ invalidate();
+ p.setMenuBar(menuBar);
+ }
}
}
diff --git a/java/awt/GridLayout.java b/java/awt/GridLayout.java
index a6836681d..65e09aa59 100644
--- a/java/awt/GridLayout.java
+++ b/java/awt/GridLayout.java
@@ -289,7 +289,7 @@ public class GridLayout implements LayoutManager, Serializable
public String toString ()
{
return (getClass ().getName () + "["
- + ",hgap=" + hgap + ",vgap=" + vgap
+ + "hgap=" + hgap + ",vgap=" + vgap
+ ",rows=" + rows + ",cols=" + cols
+ "]");
}
diff --git a/java/awt/LightweightDispatcher.java b/java/awt/LightweightDispatcher.java
index 3ea3f90a6..4360f592d 100644
--- a/java/awt/LightweightDispatcher.java
+++ b/java/awt/LightweightDispatcher.java
@@ -38,7 +38,10 @@ exception statement from your version. */
package java.awt;
+import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.peer.LightweightPeer;
import java.util.WeakHashMap;
/**
@@ -49,7 +52,7 @@ import java.util.WeakHashMap;
*
* @author Roman Kennke (kennke@aicas.com)
*/
-class LightweightDispatcher
+final class LightweightDispatcher
{
/**
@@ -60,26 +63,17 @@ class LightweightDispatcher
private static WeakHashMap instances = new WeakHashMap();
/**
- * The component that is the start of a mouse dragging. All MOUSE_DRAGGED
- * events that follow the initial press must have the source set to this,
- * as well as the MOUSE_RELEASED event following the dragging.
- */
- private Component dragTarget;
-
- /**
- * Stores the button number which started the drag operation. This is needed
- * because we want to handle only one drag operation and only the button that
- * started the dragging should be able to stop it (by a button release).
- */
- private int dragButton;
-
- /**
* The last mouse event target. If the target changes, additional
* MOUSE_ENTERED and MOUSE_EXITED events must be dispatched.
*/
private Component lastTarget;
/**
+ * The current mouseEventTarget.
+ */
+ private Component mouseEventTarget;
+
+ /**
* Returns an instance of LightweightDispatcher for the current thread's
* thread group.
*
@@ -113,9 +107,9 @@ class LightweightDispatcher
*
* @param event the event
*/
- public boolean dispatchEvent(AWTEvent event)
+ public boolean dispatchEvent(final AWTEvent event)
{
- if (event instanceof MouseEvent && event.getSource() instanceof Window)
+ if (event instanceof MouseEvent)
{
MouseEvent mouseEvent = (MouseEvent) event;
return handleMouseEvent(mouseEvent);
@@ -130,151 +124,47 @@ class LightweightDispatcher
* @param ev the mouse event
* @return whether or not we found a lightweight that handled the event.
*/
- private boolean handleMouseEvent(MouseEvent ev)
+ private boolean handleMouseEvent(final MouseEvent ev)
{
- Window window = (Window) ev.getSource();
- // Find the target for the mouse event. We first seach the deepest
- // component at the specified location. The we go up to its parent and
- // try to find a neighbor of the deepest component that is suitable as
- // mouse event target (it must be showing, at that location and have either
- // a MouseListener or MouseMotionListener installed). If no such component
- // is found, then we walk up the container hierarchy and find the next
- // container that has a MouseListener or MouseMotionListener installed.
- Component deepest = window.findComponentAt(ev.getX(), ev.getY());
- if (deepest == null)
- return false;
- Container parent = deepest.getParent();
- Point loc = ev.getPoint();
- loc = convertPointToChild(window, loc, parent);
- Component target = null;
- if (parent != null)
- {
- target = findTarget(parent, loc);
- while (target == null && parent != null)
- {
- if (parent.mouseListener != null
- || parent.mouseMotionListener != null
- || (parent.eventMask
- & (AWTEvent.MOUSE_EVENT_MASK
- | AWTEvent.MOUSE_MOTION_EVENT_MASK)) != 0)
- {
- target = parent;
- }
- else
- parent = parent.getParent();
- }
- }
- if (target == null || target.isLightweight())
+ Container container = (Container) ev.getSource();
+ Component target = findTarget(container, ev.getX(), ev.getY());
+ trackEnterExit(target, ev);
+ int id = ev.getID();
+
+ // Dont update the mouseEventTarget when dragging. Also, MOUSE_CLICKED
+ // must be dispatched to the original target of MOUSE_PRESSED, so don't
+ // update in this case either.
+ if (! isDragging(ev) && id != MouseEvent.MOUSE_CLICKED)
+ mouseEventTarget = (target != container) ? target : null;
+
+ if (mouseEventTarget != null)
{
- // Dispatch additional MOUSE_EXITED and MOUSE_ENTERED if event target
- // is different from the last event target.
- if (target != lastTarget)
+ switch (id)
{
- if (lastTarget != null)
- {
- Point p1 = convertPointToChild(window, ev.getPoint(),
- lastTarget);
- MouseEvent mouseExited =
- new MouseEvent(lastTarget, MouseEvent.MOUSE_EXITED,
- ev.getWhen(), ev.getModifiers(), p1.x, p1.y,
- ev.getClickCount(), ev.isPopupTrigger());
- //System.err.println("event: " + mouseExited);
- lastTarget.dispatchEvent(mouseExited);
- }
-
- // If a target exists dispatch the MOUSE_ENTERED event.
- // Experimenting shows that the MOUSE_ENTERED is also dispatched
- // when the mouse is dragging.
- if (target != null)
- {
- Point p = convertPointToChild(window, ev.getPoint(), target);
- MouseEvent mouseEntered =
- new MouseEvent(target,
- MouseEvent.MOUSE_ENTERED, ev.getWhen(),
- ev.getModifiers(), p.x, p.y, ev.getClickCount(),
- ev.isPopupTrigger());
- //System.err.println("event: " + mouseEntered);
- target.dispatchEvent(mouseEntered);
- }
- }
-
- switch (ev.getID())
- {
- case MouseEvent.MOUSE_PRESSED:
- // Handle the start of a drag operation or discard the event if
- // one is already in progress. This prevents focus changes with the
- // other mouse buttons when one is used for dragging.
- if (dragTarget == null)
- {
- lastTarget = dragTarget = target;
-
- // Save the button that started the drag operation.
- dragButton = ev.getButton();
- }
- else
- return false;
-
+ case MouseEvent.MOUSE_ENTERED:
+ case MouseEvent.MOUSE_EXITED:
+ // This is already handled in trackEnterExit().
break;
+ case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
- // Stop the drag operation only when the button that started
- // it was released.
- if (dragTarget != null && dragButton == ev.getButton())
- {
- // Only post MOUSE_RELEASED to dragTarget (set in
- // MOUSE_PRESSED) when the dragTarget is actually visible.
- // Otherwise post the event to the normal target.
- if (dragTarget.isVisible())
- target = dragTarget;
- dragTarget = null;
- }
-
- lastTarget = target;
+ case MouseEvent.MOUSE_MOVED:
+ redispatch(ev, mouseEventTarget, id);
break;
case MouseEvent.MOUSE_CLICKED:
- // When we receive a MOUSE_CLICKED, we set the target to the
- // previous target, which must have been a MOUSE_RELEASED event.
- // This is necessary for the case when the MOUSE_RELEASED has
- // caused the original target (like an internal component) go
- // away.
- // This line is the reason why it is not possible to move the
- // 'lastTarget = target' assignment before the switch-statement.
- target = lastTarget;
+ // MOUSE_CLICKED must be dispatched to the original target of
+ // MOUSE_PRESSED.
+ if (target == mouseEventTarget)
+ redispatch(ev, mouseEventTarget, id);
break;
case MouseEvent.MOUSE_DRAGGED:
- // We consider only dragTarget for redispatching the event still
- // we have to act in a way that the newly found target component
- // was handled.
- lastTarget = target;
- target = dragTarget;
+ if (isDragging(ev))
+ redispatch(ev, mouseEventTarget, id);
break;
- default:
- // Only declare current target as the old value in all other
- // cases.
- lastTarget = target;
- break;
- }
-
- if (target != null)
- {
- Point targetCoordinates = convertPointToChild(window,
- ev.getPoint(),
- target);
- int dx = targetCoordinates.x - ev.getX();
- int dy = targetCoordinates.y - ev.getY();
- ev.translatePoint(dx, dy);
- ev.setSource(target);
- target.dispatchEvent(ev);
-
- // We reset the event, so that the normal event dispatching is not
- // influenced by this modified event.
- ev.setSource(window);
- ev.translatePoint(-dx, -dy);
}
-
- return true;
+ ev.consume();
}
- else
- return false;
+
+ return ev.isConsumed();
}
/**
@@ -290,58 +180,180 @@ class LightweightDispatcher
* @return the actual receiver of the mouse event, or null, if no such
* component has been found
*/
- private Component findTarget(Container c, Point loc)
+ private Component findTarget(final Container c, final int x, final int y)
{
- int numComponents = c.getComponentCount();
Component target = null;
- if (c != null)
+
+ // First we check the children of the container.
+
+ // Note: It is important that we use the package private Container
+ // fields ncomponents and component here. There are applications
+ // that override getComponentCount()
+ // and getComponent() to hide internal components, which makes
+ // the LightweightDispatcher not work correctly in these cases.
+ // As a positive sideeffect this is slightly more efficient.
+ int nChildren = c.ncomponents;
+ for (int i = 0; i < nChildren && target == null; i++)
{
- for (int i = 0; i < numComponents; i++)
+ Component child = c.component[i];
+ int childX = x - child.x;
+ int childY = y - child.y;
+ if (child != null && child.visible
+ && child.peer instanceof LightweightPeer
+ && child.contains(childX, childY))
{
- Component child = c.getComponent(i);
- if (child.isShowing())
+ // Check if there's a deeper possible target.
+ if (child instanceof Container)
{
- if (child.contains(loc.x - child.getX(), loc.y - child.getY())
- && (child.mouseListener != null
- || child.mouseMotionListener != null
- || (child.eventMask
- & (AWTEvent.MOUSE_EVENT_MASK
- | AWTEvent.MOUSE_MOTION_EVENT_MASK)) != 0))
- {
- target = child;
- break;
- }
+ Component deeper = findTarget((Container) child,
+ childX, childY);
+ if (deeper != null)
+ target = deeper;
}
+ // Check if the child itself is interested in mouse events.
+ else if (isMouseListening(child))
+ target = child;
}
}
+
+ // Check the container itself, if we didn't find a target yet.
+ if (target == null && c.contains(x, y) && isMouseListening(c))
+ target = c;
+
return target;
}
/**
- * Converts a point in the parent's coordinate system to a child coordinate
- * system. The resulting point is stored in the same Point object and
- * returned.
+ * Checks if the specified component would be interested in a mouse event.
+ *
+ * @param c the component to check
+ *
+ * @return <code>true</code> if the component has mouse listeners installed,
+ * <code>false</code> otherwise
+ */
+ private boolean isMouseListening(final Component c)
+ {
+ // Note: It is important to NOT check if the component is listening
+ // for a specific event (for instance, mouse motion events). The event
+ // gets dispatched to the component if the component is listening
+ // for ANY mouse event, even when the component is not listening for the
+ // specific type of event. There are applications that depend on this
+ // (sadly).
+ return c.mouseListener != null
+ || c.mouseMotionListener != null
+ || c.mouseWheelListener != null
+ || (c.eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0
+ || (c.eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0
+ || (c.eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0;
+ }
+
+ /**
+ * Tracks MOUSE_ENTERED and MOUSE_EXIT as well as MOUSE_MOVED and
+ * MOUSE_DRAGGED and creates synthetic MOUSE_ENTERED and MOUSE_EXITED for
+ * lightweight component.s
+ *
+ * @param target the current mouse event target
+ * @param ev the mouse event
+ */
+ private void trackEnterExit(final Component target, final MouseEvent ev)
+ {
+ int id = ev.getID();
+ if (target != lastTarget)
+ {
+ if (lastTarget != null)
+ redispatch(ev, lastTarget, MouseEvent.MOUSE_EXITED);
+ if (id == MouseEvent.MOUSE_EXITED)
+ ev.consume();
+ if (target != null)
+ redispatch(ev, target, MouseEvent.MOUSE_ENTERED);
+ if (id == MouseEvent.MOUSE_ENTERED)
+ ev.consume();
+ lastTarget = target;
+ }
+
+ }
+
+ /**
+ * Redispatches the specified mouse event to the specified target with the
+ * specified id.
*
- * @param parent the parent component
- * @param p the point
- * @param child the child component
+ * @param ev the mouse event
+ * @param target the new target
+ * @param id the new id
+ */
+ private void redispatch(MouseEvent ev, Component target, int id)
+ {
+ Component source = ev.getComponent();
+ if (target != null)
+ {
+ // Translate coordinates.
+ int x = ev.getX();
+ int y = ev.getY();
+ for (Component c = target; c != null && c != source; c = c.getParent())
+ {
+ x -= c.x;
+ y -= c.y;
+ }
+
+ // Retarget event.
+ MouseEvent retargeted;
+ if (id == MouseEvent.MOUSE_WHEEL)
+ {
+ MouseWheelEvent mwe = (MouseWheelEvent) ev;
+ retargeted = new MouseWheelEvent(target, id, ev.getWhen(),
+ ev.getModifiers()
+ | ev.getModifiersEx(), x, y,
+ ev.getClickCount(),
+ ev.isPopupTrigger(),
+ mwe.getScrollType(),
+ mwe.getScrollAmount(),
+ mwe.getWheelRotation());
+ }
+ else
+ {
+ retargeted = new MouseEvent(target, id, ev.getWhen(),
+ ev.getModifiers() | ev.getModifiersEx(),
+ x, y, ev.getClickCount(),
+ ev.isPopupTrigger());
+ }
+
+ if (target == source)
+ ((Container) target).dispatchNoLightweight(retargeted);
+ else
+ target.dispatchEvent(retargeted);
+ }
+ }
+
+ /**
+ * Determines if we are in the middle of a drag operation, that is, if
+ * any of the buttons is held down.
+ *
+ * @param ev the mouse event to check
*
- * @return the translated point
+ * @return <code>true</code> if we are in the middle of a drag operation,
+ * <code>false</code> otherwise
*/
- private Point convertPointToChild(Component parent, Point p,
- Component child)
+ private boolean isDragging(MouseEvent ev)
{
- int offX = 0;
- int offY = 0;
- Component comp = child;
- while (comp != null && comp != parent)
+ int mods = ev.getModifiersEx();
+ int id = ev.getID();
+ if (id == MouseEvent.MOUSE_PRESSED || id == MouseEvent.MOUSE_RELEASED)
{
- offX += comp.getX();
- offY += comp.getY();
- comp = comp.getParent();
+ switch (ev.getButton())
+ {
+ case MouseEvent.BUTTON1:
+ mods ^= InputEvent.BUTTON1_DOWN_MASK;
+ break;
+ case MouseEvent.BUTTON2:
+ mods ^= InputEvent.BUTTON2_DOWN_MASK;
+ break;
+ case MouseEvent.BUTTON3:
+ mods ^= InputEvent.BUTTON3_DOWN_MASK;
+ break;
+ }
}
- p.x -= offX;
- p.y -= offY;
- return p;
+ return (mods & (InputEvent.BUTTON1_DOWN_MASK
+ | InputEvent.BUTTON2_DOWN_MASK
+ | InputEvent.BUTTON3_DOWN_MASK)) != 0;
}
}
diff --git a/java/awt/List.java b/java/awt/List.java
index 7b6524171..df8bffa19 100644
--- a/java/awt/List.java
+++ b/java/awt/List.java
@@ -1,5 +1,5 @@
/* List.java -- A listbox widget
- Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,826 +54,718 @@ import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
/**
- * Class that implements a listbox widget
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
+ * Class that implements a listbox widget
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
public class List extends Component
implements ItemSelectable, Accessible
{
-/*
- * Static Variables
- */
-
-/**
- * The number used to generate the name returned by getName.
- */
-private static transient long next_list_number;
-
-// Serialization constant
-private static final long serialVersionUID = -3304312411574666869L;
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-// FIXME: Need read/writeObject
-
-/**
- * @serial The items in the list.
- */
-private Vector items = new Vector();
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_list_number;
-/**
- * @serial Indicates whether or not multiple items can be selected
- * simultaneously.
- */
-private boolean multipleMode;
+ // Serialization constant
+ private static final long serialVersionUID = -3304312411574666869L;
-/**
- * @serial The number of rows in the list. This is set on creation
- * only and cannot be modified.
- */
-private int rows;
+ // FIXME: Need read/writeObject
-/**
- * @serial An array of the item indices that are selected.
- */
-private int[] selected;
-
-/**
- * @serial An index value used by <code>makeVisible()</code> and
- * <code>getVisibleIndex</code>.
- */
-private int visibleIndex = -1;
+ /**
+ * @serial The items in the list.
+ */
+ private Vector items = new Vector();
-// The list of ItemListeners for this object.
-private ItemListener item_listeners;
+ /**
+ * @serial Indicates whether or not multiple items can be selected
+ * simultaneously.
+ */
+ private boolean multipleMode;
-// The list of ActionListeners for this object.
-private ActionListener action_listeners;
+ /**
+ * @serial The number of rows in the list. This is set on creation
+ * only and cannot be modified.
+ */
+ private int rows;
-/*************************************************************************/
+ /**
+ * @serial An array of the item indices that are selected.
+ */
+ private int[] selected;
-/*
- * Constructors
- */
+ /**
+ * @serial An index value used by <code>makeVisible()</code> and
+ * <code>getVisibleIndex</code>.
+ */
+ private int visibleIndex = -1;
-/**
- * Initializes a new instance of <code>List</code> with no visible lines
- * and multi-select disabled.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-List()
-{
- this(4, false);
-}
+ // The list of ItemListeners for this object.
+ private ItemListener item_listeners;
-/*************************************************************************/
+ // The list of ActionListeners for this object.
+ private ActionListener action_listeners;
-/**
- * Initializes a new instance of <code>List</code> with the specified
- * number of visible lines and multi-select disabled.
- *
- * @param rows The number of visible rows in the list.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-List(int rows)
-{
- this(rows, false);
-}
+ /**
+ * Initializes a new instance of <code>List</code> with no visible lines
+ * and multi-select disabled.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ * @since 1.1
+ */
+ public List()
+ {
+ this(4, false);
+ }
-/*************************************************************************/
+ /**
+ * Initializes a new instance of <code>List</code> with the specified
+ * number of visible lines and multi-select disabled.
+ *
+ * @param rows The number of visible rows in the list.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public List(int rows)
+ {
+ this(rows, false);
+ }
-/**
- * Initializes a new instance of <code>List</code> with the specified
- * number of lines and the specified multi-select setting.
- *
- * @param rows The number of visible rows in the list.
- * @param multipleMode <code>true</code> if multiple lines can be selected
- * simultaneously, <code>false</code> otherwise.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-List(int rows, boolean multipleMode)
-{
- if (rows == 0)
- this.rows = 4;
- else
- this.rows = rows;
+ /**
+ * Initializes a new instance of <code>List</code> with the specified
+ * number of lines and the specified multi-select setting.
+ *
+ * @param rows The number of visible rows in the list.
+ * @param multipleMode <code>true</code> if multiple lines can be selected
+ * simultaneously, <code>false</code> otherwise.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public List(int rows, boolean multipleMode)
+ {
+ if (rows == 0)
+ this.rows = 4;
+ else
+ this.rows = rows;
- this.multipleMode = multipleMode;
- selected = new int[0];
+ this.multipleMode = multipleMode;
+ selected = new int[0];
- if (GraphicsEnvironment.isHeadless())
- throw new HeadlessException ();
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
-}
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
- * Returns the number of items in this list.
- *
- * @return The number of items in this list.
- */
-public int
-getItemCount()
-{
- return countItems ();
-}
-
-/*************************************************************************/
+ }
-/**
- * Returns the number of items in this list.
- *
- * @return The number of items in this list.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getItemCount()</code>
- */
-public int
-countItems()
-{
- return items.size ();
-}
+ /**
+ * Returns the number of items in this list.
+ *
+ * @return The number of items in this list.
+ *
+ * @since 1.1
+ */
+ public int getItemCount()
+ {
+ return countItems();
+ }
-/*************************************************************************/
+ /**
+ * Returns the number of items in this list.
+ *
+ * @return The number of items in this list.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getItemCount()</code>
+ */
+ public int countItems()
+ {
+ return items.size();
+ }
-/**
- * Returns the complete list of items.
- *
- * @return The complete list of items in the list.
- */
-public synchronized String[]
-getItems()
-{
- String[] l_items = new String[getItemCount()];
+ /**
+ * Returns the complete list of items.
+ *
+ * @return The complete list of items in the list.
+ *
+ * @since 1.1
+ */
+ public synchronized String[] getItems()
+ {
+ String[] l_items = new String[getItemCount()];
- items.copyInto(l_items);
- return(l_items);
-}
-
-/*************************************************************************/
-
-/**
- * Returns the item at the specified index.
- *
- * @param index The index of the item to retrieve.
- *
- * @exception IndexOutOfBoundsException If the index value is not valid.
- */
-public String
-getItem(int index)
-{
- return((String)items.elementAt(index));
-}
-
-/*************************************************************************/
-
-/**
- * Returns the number of visible rows in the list.
- *
- * @return The number of visible rows in the list.
- */
-public int
-getRows()
-{
- return(rows);
-}
-
-/*************************************************************************/
+ items.copyInto(l_items);
+ return(l_items);
+ }
-/**
- * Tests whether or not multi-select mode is enabled.
- *
- * @return <code>true</code> if multi-select mode is enabled,
- * <code>false</code> otherwise.
- */
-public boolean
-isMultipleMode()
-{
- return allowsMultipleSelections ();
-}
+ /**
+ * Returns the item at the specified index.
+ *
+ * @param index The index of the item to retrieve.
+ *
+ * @exception IndexOutOfBoundsException If the index value is not valid.
+ */
+ public String getItem(int index)
+ {
+ return((String) items.elementAt(index));
+ }
-/*************************************************************************/
+ /**
+ * Returns the number of visible rows in the list.
+ *
+ * @return The number of visible rows in the list.
+ */
+ public int getRows()
+ {
+ return(rows);
+ }
-/**
- * Tests whether or not multi-select mode is enabled.
- *
- * @return <code>true</code> if multi-select mode is enabled,
- * <code>false</code> otherwise.
- *
- * @deprecated This method is deprecated in favor of
- * <code>isMultipleMode()</code>.
- */
-public boolean
-allowsMultipleSelections()
-{
- return multipleMode;
-}
+ /**
+ * Tests whether or not multi-select mode is enabled.
+ *
+ * @return <code>true</code> if multi-select mode is enabled,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.1
+ */
+ public boolean isMultipleMode()
+ {
+ return allowsMultipleSelections ();
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not multi-select mode is enabled.
+ *
+ * @return <code>true</code> if multi-select mode is enabled,
+ * <code>false</code> otherwise.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>isMultipleMode()</code>.
+ */
+ public boolean allowsMultipleSelections()
+ {
+ return multipleMode;
+ }
-/**
- * This method enables or disables multiple selection mode for this
- * list.
- *
- * @param multipleMode <code>true</code> to enable multiple mode,
- * <code>false</code> otherwise.
- */
-public void
-setMultipleMode(boolean multipleMode)
-{
- setMultipleSelections (multipleMode);
-}
+ /**
+ * This method enables or disables multiple selection mode for this
+ * list.
+ *
+ * @param multipleMode <code>true</code> to enable multiple mode,
+ * <code>false</code> otherwise.
+ *
+ * @since 1.1
+ */
+ public void setMultipleMode(boolean multipleMode)
+ {
+ setMultipleSelections (multipleMode);
+ }
-/*************************************************************************/
+ /**
+ * This method enables or disables multiple selection mode for this
+ * list.
+ *
+ * @param multipleMode <code>true</code> to enable multiple mode,
+ * <code>false</code> otherwise.
+ *
+ * @deprecated
+ */
+ public void setMultipleSelections(boolean multipleMode)
+ {
+ this.multipleMode = multipleMode;
-/**
- * This method enables or disables multiple selection mode for this
- * list.
- *
- * @param multipleMode <code>true</code> to enable multiple mode,
- * <code>false</code> otherwise.
- *
- * @deprecated
- */
-public void
-setMultipleSelections(boolean multipleMode)
-{
- this.multipleMode = multipleMode;
-
- ListPeer peer = (ListPeer) getPeer ();
- if (peer != null)
- peer.setMultipleMode (multipleMode);
+ ListPeer peer = (ListPeer) getPeer();
+ if (peer != null)
+ peer.setMultipleMode(multipleMode);
-}
-
-/*************************************************************************/
-
-/**
- * Returns the minimum size of this component.
- *
- * @return The minimum size of this component.
- */
-public Dimension
-getMinimumSize()
-{
- return getMinimumSize (getRows ());
-}
-
-/*************************************************************************/
-
-/**
- * Returns the minimum size of this component.
- *
- * @return The minimum size of this component.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getMinimumSize</code>.
- */
-public Dimension
-minimumSize()
-{
- return minimumSize (getRows ());
-}
-
-/*************************************************************************/
-
-/**
- * Returns the minimum size of this component assuming it had the specified
- * number of rows.
- *
- * @param rows The number of rows to size for.
- *
- * @return The minimum size of this component.
- */
-public Dimension
-getMinimumSize(int rows)
-{
- return minimumSize (rows);
-}
-
-/*************************************************************************/
-
-/**
- * Returns the minimum size of this component assuming it had the specified
- * number of rows.
- *
- * @param rows The number of rows to size for.
- *
- * @return The minimum size of this component.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getMinimumSize(int)</code>>
- */
-public Dimension
-minimumSize(int rows)
-{
- ListPeer peer = (ListPeer) getPeer ();
- if (peer != null)
- return peer.minimumSize (rows);
- else
- return new Dimension (0, 0);
-}
-
-/*************************************************************************/
-
-/**
- * Returns the preferred size of this component.
- *
- * @return The preferred size of this component.
- */
-public Dimension
-getPreferredSize()
-{
- return getPreferredSize (getRows ());
-}
-
-/*************************************************************************/
-
-/**
- * Returns the preferred size of this component.
- *
- * @return The preferred size of this component.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getPreferredSize</code>.
- */
-public Dimension
-preferredSize()
-{
- return preferredSize (getRows ());
-}
+ }
-/*************************************************************************/
+ /**
+ * Returns the minimum size of this component.
+ *
+ * @return The minimum size of this component.
+ *
+ * @since 1.1
+ */
+ public Dimension getMinimumSize()
+ {
+ return getMinimumSize(getRows());
+ }
-/**
- * Returns the preferred size of this component assuming it had the specified
- * number of rows.
- *
- * @param rows The number of rows to size for.
- *
- * @return The preferred size of this component.
- */
-public Dimension
-getPreferredSize(int rows)
-{
- return preferredSize (rows);
-}
+ /**
+ * Returns the minimum size of this component.
+ *
+ * @return The minimum size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize</code>.
+ */
+ public Dimension minimumSize()
+ {
+ return minimumSize(getRows());
+ }
-/*************************************************************************/
+ /**
+ * Returns the minimum size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The minimum size of this component.
+ *
+ * @since 1.1
+ */
+ public Dimension getMinimumSize(int rows)
+ {
+ return minimumSize(rows);
+ }
-/**
- * Returns the preferred size of this component assuming it had the specified
- * number of rows.
- *
- * @param rows The number of rows to size for.
- *
- * @return The preferred size of this component.
- *
- * @deprecated This method is deprecated in favor of
- * <code>getPreferredSize(int)</code>>
- */
-public Dimension
-preferredSize(int rows)
-{
- ListPeer peer = (ListPeer) getPeer ();
- if (peer != null)
- return peer.preferredSize (rows);
- else
- return getSize();
-}
+ /**
+ * Returns the minimum size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The minimum size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize(int)</code>>
+ */
+ public Dimension minimumSize(int rows)
+ {
+ ListPeer peer = (ListPeer) getPeer();
+ if (peer != null)
+ return peer.minimumSize(rows);
+ else
+ return new Dimension(0, 0);
+ }
-/*************************************************************************/
+ /**
+ * Returns the preferred size of this component.
+ *
+ * @return The preferred size of this component.
+ *
+ * @since 1.1
+ */
+ public Dimension getPreferredSize()
+ {
+ return getPreferredSize(getRows());
+ }
-/**
- * This method adds the specified item to the end of the list.
- *
- * @param item The item to add to the list.
- */
-public void
-add(String item)
-{
- add (item, -1);
-}
+ /**
+ * Returns the preferred size of this component.
+ *
+ * @return The preferred size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize</code>.
+ */
+ public Dimension preferredSize()
+ {
+ return preferredSize(getRows());
+ }
-/*************************************************************************/
+ /**
+ * Returns the preferred size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The preferred size of this component.
+ *
+ * @since 1.1
+ */
+ public Dimension getPreferredSize(int rows)
+ {
+ return preferredSize(rows);
+ }
-/**
- * This method adds the specified item to the end of the list.
- *
- * @param item The item to add to the list.
- *
- * @deprecated Use add() instead.
- */
-public void
-addItem(String item)
-{
- addItem (item, -1);
-}
+ /**
+ * Returns the preferred size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The preferred size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize(int)</code>>
+ */
+ public Dimension preferredSize(int rows)
+ {
+ ListPeer peer = (ListPeer)getPeer();
+ if (peer != null)
+ return peer.preferredSize(rows);
+ else
+ return getSize();
+ }
-/*************************************************************************/
+ /**
+ * This method adds the specified item to the end of the list.
+ *
+ * @param item The item to add to the list.
+ *
+ * @since 1.1
+ */
+ public void add(String item)
+ {
+ add (item, -1);
+ }
-/**
- * Adds the specified item to the specified location in the list.
- * If the desired index is -1 or greater than the number of rows
- * in the list, then the item is added to the end.
- *
- * @param item The item to add to the list.
- * @param index The location in the list to add the item, or -1 to add
- * to the end.
- */
-public void
-add(String item, int index)
-{
- addItem (item, index);
-}
+ /**
+ * This method adds the specified item to the end of the list.
+ *
+ * @param item The item to add to the list.
+ *
+ * @deprecated Use add() instead.
+ */
+ public void addItem(String item)
+ {
+ addItem(item, -1);
+ }
-/*************************************************************************/
+ /**
+ * Adds the specified item to the specified location in the list.
+ * If the desired index is -1 or greater than the number of rows
+ * in the list, then the item is added to the end.
+ *
+ * @param item The item to add to the list.
+ * @param index The location in the list to add the item, or -1 to add
+ * to the end.
+ *
+ * @since 1.1
+ */
+ public void add(String item, int index)
+ {
+ addItem(item, index);
+ }
-/**
- * Adds the specified item to the specified location in the list.
- * If the desired index is -1 or greater than the number of rows
- * in the list, then the item is added to the end.
- *
- * @param item The item to add to the list.
- * @param index The location in the list to add the item, or -1 to add
- * to the end.
- *
- * @deprecated Use add() instead.
- */
-public void
-addItem(String item, int index)
-{
- if (item == null)
- item = "";
+ /**
+ * Adds the specified item to the specified location in the list.
+ * If the desired index is -1 or greater than the number of rows
+ * in the list, then the item is added to the end.
+ *
+ * @param item The item to add to the list.
+ * @param index The location in the list to add the item, or -1 to add
+ * to the end.
+ *
+ * @deprecated Use add() instead.
+ */
+ public void addItem(String item, int index)
+ {
+ if (item == null)
+ item = "";
- if (index < -1)
- index = -1;
+ if (index < -1)
+ index = -1;
- if ((index == -1) || (index >= items.size ()))
- items.addElement (item);
- else
- items.insertElementAt (item, index);
-
- ListPeer peer = (ListPeer) getPeer ();
- if (peer != null)
- peer.add (item, index);
-}
-
-/*************************************************************************/
+ if ((index == -1) || (index >= items.size ()))
+ items.addElement (item);
+ else
+ items.insertElementAt(item, index);
+
+ ListPeer peer = (ListPeer) getPeer();
+ if (peer != null)
+ peer.add (item, index);
+ }
-/**
- * Deletes the item at the specified index.
- *
- * @param index The index of the item to delete.
- *
- * @exception IllegalArgumentException If the index is not valid
- *
- * @deprecated
- */
-public void
-delItem(int index) throws IllegalArgumentException
-{
- boolean selected = false;
- if (isSelected(index))
- {
- selected = true;
- deselect(index);
- }
+ /**
+ * Deletes the item at the specified index.
+ *
+ * @param index The index of the item to delete.
+ *
+ * @exception IllegalArgumentException If the index is not valid
+ *
+ * @deprecated
+ */
+ public void delItem(int index) throws IllegalArgumentException
+ {
+ boolean selected = false;
+ if (isSelected(index))
+ {
+ selected = true;
+ deselect(index);
+ }
- items.removeElementAt (index);
+ items.removeElementAt (index);
- if (selected)
- select(index);
-
- ListPeer peer = (ListPeer) getPeer ();
- if (peer != null)
- peer.delItems (index, index);
-}
-
-/*************************************************************************/
-
-/**
- * Deletes the item at the specified index.
- *
- * @param index The index of the item to delete.
- *
- * @exception IllegalArgumentException If the index is not valid
- */
-public void
-remove(int index) throws IllegalArgumentException
-{
- delItem (index);
-}
-
-/*************************************************************************/
-
-/**
- * Deletes all items in the specified index range.
- *
- * @param start The beginning index of the range to delete.
- * @param end The ending index of the range to delete.
- *
- * @exception IllegalArgumentException If the indexes are not valid
- *
- * @deprecated This method is deprecated for some unknown reason.
- */
-public synchronized void
-delItems(int start, int end) throws IllegalArgumentException
-{
- // We must run the loop in reverse direction.
- for (int i = end; i >= start; --i)
- items.removeElementAt (i);
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.delItems (start, end);
- }
-}
+ if (selected)
+ select(index);
-/*************************************************************************/
+ ListPeer peer = (ListPeer) getPeer();
+ if (peer != null)
+ peer.delItems (index, index);
+ }
-/**
- * Deletes the first occurrence of the specified item from the list.
- *
- * @param item The item to delete.
- *
- * @exception IllegalArgumentException If the specified item does not exist.
- */
-public synchronized void
-remove(String item) throws IllegalArgumentException
-{
- int index = items.indexOf(item);
- if (index == -1)
- throw new IllegalArgumentException("List element to delete not found");
+ /**
+ * Deletes the item at the specified index.
+ *
+ * @param index The index of the item to delete.
+ *
+ * @exception IllegalArgumentException If the index is not valid
+ *
+ * @since 1.1
+ */
+ public void remove(int index) throws IllegalArgumentException
+ {
+ delItem(index);
+ }
- remove(index);
-}
+ /**
+ * Deletes all items in the specified index range.
+ *
+ * @param start The beginning index of the range to delete.
+ * @param end The ending index of the range to delete.
+ *
+ * @exception IllegalArgumentException If the indexes are not valid
+ *
+ * @deprecated This method is deprecated for some unknown reason.
+ */
+ public synchronized void delItems(int start, int end)
+ throws IllegalArgumentException
+ {
+ // We must run the loop in reverse direction.
+ for (int i = end; i >= start; --i)
+ items.removeElementAt (i);
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ l.delItems (start, end);
+ }
+ }
-/*************************************************************************/
+ /**
+ * Deletes the first occurrence of the specified item from the list.
+ *
+ * @param item The item to delete.
+ *
+ * @exception IllegalArgumentException If the specified item does not exist.
+ *
+ * @since 1.1
+ */
+ public synchronized void remove(String item) throws IllegalArgumentException
+ {
+ int index = items.indexOf(item);
+ if (index == -1)
+ throw new IllegalArgumentException("List element to delete not found");
-/**
- * Deletes all of the items from the list.
- */
-public synchronized void
-removeAll()
-{
- clear ();
-}
+ remove(index);
+ }
-/*************************************************************************/
+ /**
+ * Deletes all of the items from the list.
+ *
+ * @since 1.1
+ */
+ public synchronized void removeAll()
+ {
+ clear();
+ }
-/**
- * Deletes all of the items from the list.
- *
- * @deprecated This method is deprecated in favor of <code>removeAll()</code>.
- */
-public void
-clear()
-{
- items.clear();
+ /**
+ * Deletes all of the items from the list.
+ *
+ * @deprecated This method is deprecated in favor of <code>removeAll()</code>.
+ */
+ public void clear()
+ {
+ items.clear();
- ListPeer peer = (ListPeer) getPeer ();
- if (peer != null)
- peer.removeAll ();
+ ListPeer peer = (ListPeer) getPeer();
+ if (peer != null)
+ peer.removeAll();
- selected = new int[0];
-}
-
-/*************************************************************************/
-
-/**
- * Replaces the item at the specified index with the specified item.
- *
- * @param item The new item value.
- * @param index The index of the item to replace.
- *
- * @exception ArrayIndexOutOfBoundsException If the index is not valid.
- */
-public synchronized void
-replaceItem(String item, int index) throws ArrayIndexOutOfBoundsException
-{
- if ((index < 0) || (index >= items.size()))
- throw new ArrayIndexOutOfBoundsException("Bad list index: " + index);
-
- items.insertElementAt(item, index + 1);
- items.removeElementAt (index);
-
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
+ selected = new int[0];
+ }
- /* We add first and then remove so that the selected
- item remains the same */
- l.add (item, index + 1);
- l.delItems (index, index);
- }
-}
+ /**
+ * Replaces the item at the specified index with the specified item.
+ *
+ * @param item The new item value.
+ * @param index The index of the item to replace.
+ *
+ * @exception ArrayIndexOutOfBoundsException If the index is not valid.
+ */
+ public synchronized void replaceItem(String item, int index)
+ throws ArrayIndexOutOfBoundsException
+ {
+ if ((index < 0) || (index >= items.size()))
+ throw new ArrayIndexOutOfBoundsException("Bad list index: " + index);
-/*************************************************************************/
+ items.insertElementAt(item, index + 1);
+ items.removeElementAt (index);
-/**
- * Returns the index of the currently selected item. -1 will be returned
- * if there are no selected rows or if there are multiple selected rows.
- *
- * @return The index of the selected row.
- */
-public synchronized int
-getSelectedIndex()
-{
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- selected = l.getSelectedIndexes ();
- }
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
- if (selected == null || selected.length != 1)
- return -1;
-
- return selected[0];
-}
+ /* We add first and then remove so that the selected
+ item remains the same */
+ l.add (item, index + 1);
+ l.delItems (index, index);
+ }
+ }
-/*************************************************************************/
+ /**
+ * Returns the index of the currently selected item. -1 will be returned
+ * if there are no selected rows or if there are multiple selected rows.
+ *
+ * @return The index of the selected row.
+ */
+ public synchronized int getSelectedIndex()
+ {
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ selected = l.getSelectedIndexes ();
+ }
-/**
- * Returns an array containing the indexes of the rows that are
- * currently selected.
- *
- * @return A list of indexes of selected rows.
- */
-public synchronized int[]
-getSelectedIndexes()
-{
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- selected = l.getSelectedIndexes ();
- }
+ if (selected == null || selected.length != 1)
+ return -1;
- return selected;
-}
-
-/*************************************************************************/
-
-/**
- * Returns the item that is currently selected, or <code>null</code> if there
- * is no item selected. FIXME: What happens if multiple items selected?
- *
- * @return The selected item, or <code>null</code> if there is no
- * selected item.
- */
-public synchronized String
-getSelectedItem()
-{
- int index = getSelectedIndex();
- if (index == -1)
- return(null);
-
- return((String)items.elementAt(index));
-}
-
-/*************************************************************************/
-
-/**
- * Returns the list of items that are currently selected in this list.
- *
- * @return The list of currently selected items.
- */
-public synchronized String[]
-getSelectedItems()
-{
- int[] indexes = getSelectedIndexes();
- if (indexes == null)
- return(new String[0]);
-
- String[] retvals = new String[indexes.length];
- if (retvals.length > 0)
- for (int i = 0 ; i < retvals.length; i++)
- retvals[i] = (String)items.elementAt(indexes[i]);
-
- return(retvals);
-}
+ return selected[0];
+ }
-/*************************************************************************/
+ /**
+ * Returns an array containing the indexes of the rows that are
+ * currently selected.
+ *
+ * @return A list of indexes of selected rows.
+ */
+ public synchronized int[] getSelectedIndexes()
+ {
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ selected = l.getSelectedIndexes();
+ }
+
+ return selected;
+ }
-/**
- * Returns the list of items that are currently selected in this list as
- * an array of type <code>Object[]</code> instead of <code>String[]</code>.
- *
- * @return The list of currently selected items.
- */
-public synchronized Object[]
-getSelectedObjects()
-{
- int[] indexes = getSelectedIndexes();
- if (indexes == null)
- return(new Object[0]);
+ /**
+ * Returns the item that is currently selected, or <code>null</code> if there
+ * is no item selected. FIXME: What happens if multiple items selected?
+ *
+ * @return The selected item, or <code>null</code> if there is no
+ * selected item.
+ */
+ public synchronized String getSelectedItem()
+ {
+ int index = getSelectedIndex();
+ if (index == -1)
+ return(null);
- Object[] retvals = new Object[indexes.length];
- if (retvals.length > 0)
- for (int i = 0 ; i < retvals.length; i++)
- retvals[i] = items.elementAt(indexes[i]);
+ return((String) items.elementAt(index));
+ }
- return(retvals);
-}
+ /**
+ * Returns the list of items that are currently selected in this list.
+ *
+ * @return The list of currently selected items.
+ */
+ public synchronized String[] getSelectedItems()
+ {
+ int[] indexes = getSelectedIndexes();
+ if (indexes == null)
+ return(new String[0]);
-/*************************************************************************/
+ String[] retvals = new String[indexes.length];
+ if (retvals.length > 0)
+ for (int i = 0 ; i < retvals.length; i++)
+ retvals[i] = (String)items.elementAt(indexes[i]);
-/**
- * Tests whether or not the specified index is selected.
- *
- * @param index The index to test.
- *
- * @return <code>true</code> if the index is selected, <code>false</code>
- * otherwise.
- */
-public boolean
-isIndexSelected(int index)
-{
- return isSelected (index);
-}
+ return(retvals);
+ }
-/*************************************************************************/
+ /**
+ * Returns the list of items that are currently selected in this list as
+ * an array of type <code>Object[]</code> instead of <code>String[]</code>.
+ *
+ * @return The list of currently selected items.
+ */
+ public synchronized Object[] getSelectedObjects()
+ {
+ int[] indexes = getSelectedIndexes();
+ if (indexes == null)
+ return(new Object[0]);
-/**
- * Tests whether or not the specified index is selected.
- *
- * @param index The index to test.
- *
- * @return <code>true</code> if the index is selected, <code>false</code>
- * otherwise.
- *
- * @deprecated This method is deprecated in favor of
- * <code>isIndexSelected(int)</code>.
- */
-public boolean
-isSelected(int index)
-{
- int[] indexes = getSelectedIndexes ();
+ Object[] retvals = new Object[indexes.length];
+ if (retvals.length > 0)
+ for (int i = 0 ; i < retvals.length; i++)
+ retvals[i] = items.elementAt(indexes[i]);
- for (int i = 0; i < indexes.length; i++)
- if (indexes[i] == index)
- return true;
+ return(retvals);
+ }
- return false;
-}
+ /**
+ * Tests whether or not the specified index is selected.
+ *
+ * @param index The index to test.
+ *
+ * @return <code>true</code> if the index is selected, <code>false</code>
+ * otherwise.
+ *
+ * @since 1.1
+ */
+ public boolean isIndexSelected(int index)
+ {
+ return isSelected(index);
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not the specified index is selected.
+ *
+ * @param index The index to test.
+ *
+ * @return <code>true</code> if the index is selected, <code>false</code>
+ * otherwise.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>isIndexSelected(int)</code>.
+ */
+ public boolean isSelected(int index)
+ {
+ int[] indexes = getSelectedIndexes();
-/**
- * This method ensures that the item at the specified index is visible.
- *
- * @param index The index of the item to be made visible.
- */
-public synchronized void
-makeVisible(int index) throws IllegalArgumentException
-{
- visibleIndex = index;
- if (peer != null)
- {
- ListPeer l = (ListPeer) peer;
- l.makeVisible (index);
- }
-}
+ for (int i = 0; i < indexes.length; i++)
+ if (indexes[i] == index)
+ return true;
-/*************************************************************************/
+ return false;
+ }
-/**
- * Returns the index of the last item that was made visible via the
- * <code>makeVisible()</code> method.
- *
- * @return The index of the last item made visible via the
- * <code>makeVisible()</code> method.
- */
-public int
-getVisibleIndex()
-{
- return(visibleIndex);
-}
+ /**
+ * This method ensures that the item at the specified index is visible.
+ *
+ * @param index The index of the item to be made visible.
+ */
+ public synchronized void makeVisible(int index)
+ throws IllegalArgumentException
+ {
+ visibleIndex = index;
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ l.makeVisible (index);
+ }
+ }
-/*************************************************************************/
+ /**
+ * Returns the index of the last item that was made visible via the
+ * <code>makeVisible()</code> method.
+ *
+ * @return The index of the last item made visible via the
+ * <code>makeVisible()</code> method.
+ */
+ public int getVisibleIndex()
+ {
+ return visibleIndex;
+ }
-/**
- * Makes the item at the specified index selected.
- *
- * @param index The index of the item to select.
- */
+ /**
+ * Makes the item at the specified index selected.
+ *
+ * @param index The index of the item to select.
+ */
public synchronized void select(int index)
{
ListPeer lp = (ListPeer) getPeer();
@@ -900,213 +792,194 @@ getVisibleIndex()
temp[selected.length] = index;
selected = temp;
}
- } else
- {
- selected = new int[1];
- selected[0] = index;
- }
+ }
+ else
+ {
+ selected = new int[1];
+ selected[0] = index;
+ }
}
-/*************************************************************************/
-
-/**
- * Makes the item at the specified index not selected.
- *
- * @param index The index of the item to unselect.
- */
-public synchronized void
-deselect(int index)
-{
- if (isSelected(index))
- {
- ListPeer lp = (ListPeer)getPeer();
- if (lp != null)
- lp.deselect(index);
-
- int[] temp = new int[selected.length - 1];
- for (int i = 0; i < temp.length; i++)
- {
- if (selected[i] != index)
- temp[i] = selected[i];
- else
- {
- System.arraycopy(selected, i + 1, temp, i,
- selected.length - i - 1);
- break;
- }
- }
- selected = temp;
- }
-}
-
-/*************************************************************************/
-
-/**
- * Notifies this object to create its native peer.
- */
-public void
-addNotify()
-{
- if (peer == null)
- peer = getToolkit ().createList (this);
- super.addNotify ();
-}
-
-/*************************************************************************/
-
-/**
- * Notifies this object to destroy its native peer.
- */
-public void
-removeNotify()
-{
- super.removeNotify();
-}
-
-/*************************************************************************/
-
-/**
- * Adds the specified <code>ActionListener</code> to the list of
- * registered listeners for this object.
- *
- * @param listener The listener to add.
- */
-public synchronized void
-addActionListener(ActionListener listener)
-{
- action_listeners = AWTEventMulticaster.add(action_listeners, listener);
-}
-
-/*************************************************************************/
-
-/**
- * Removes the specified <code>ActionListener</code> from the list of
- * registers listeners for this object.
- *
- * @param listener The listener to remove.
- */
-public synchronized void
-removeActionListener(ActionListener listener)
-{
- action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
-}
-
-/*************************************************************************/
+ /**
+ * Makes the item at the specified index not selected.
+ *
+ * @param index The index of the item to unselect.
+ */
+ public synchronized void deselect(int index)
+ {
+ if (isSelected(index))
+ {
+ ListPeer lp = (ListPeer)getPeer();
+ if (lp != null)
+ lp.deselect(index);
+
+ int[] temp = new int[selected.length - 1];
+ for (int i = 0; i < temp.length; i++)
+ {
+ if (selected[i] != index)
+ temp[i] = selected[i];
+ else
+ {
+ System.arraycopy(selected, i + 1, temp, i,
+ selected.length - i - 1);
+ break;
+ }
+ }
+ selected = temp;
+ }
+ }
-/**
- * Adds the specified <code>ItemListener</code> to the list of
- * registered listeners for this object.
- *
- * @param listener The listener to add.
- */
-public synchronized void
-addItemListener(ItemListener listener)
-{
- item_listeners = AWTEventMulticaster.add(item_listeners, listener);
-}
+ /**
+ * Notifies this object to create its native peer.
+ */
+ public void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit ().createList(this);
+ super.addNotify ();
+ }
-/*************************************************************************/
+ /**
+ * Notifies this object to destroy its native peer.
+ */
+ public void removeNotify()
+ {
+ super.removeNotify();
+ }
-/**
- * Removes the specified <code>ItemListener</code> from the list of
- * registers listeners for this object.
- *
- * @param listener The listener to remove.
- */
-public synchronized void
-removeItemListener(ItemListener listener)
-{
- item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
-}
+ /**
+ * Adds the specified <code>ActionListener</code> to the list of
+ * registered listeners for this object.
+ *
+ * @param listener The listener to add.
+ *
+ * @since 1.1
+ */
+ public synchronized void addActionListener(ActionListener listener)
+ {
+ action_listeners = AWTEventMulticaster.add(action_listeners, listener);
+ }
-/*************************************************************************/
+ /**
+ * Removes the specified <code>ActionListener</code> from the list of
+ * registers listeners for this object.
+ *
+ * @param listener The listener to remove.
+ *
+ * @since 1.1
+ */
+ public synchronized void removeActionListener(ActionListener listener)
+ {
+ action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
+ }
-/**
- * Processes the specified event for this object. If the event is an
- * instance of <code>ActionEvent</code> then the
- * <code>processActionEvent()</code> method is called. Similarly, if the
- * even is an instance of <code>ItemEvent</code> then the
- * <code>processItemEvent()</code> method is called. Otherwise the
- * superclass method is called to process this event.
- *
- * @param event The event to process.
- */
-protected void
-processEvent(AWTEvent event)
-{
- if (event instanceof ActionEvent)
- processActionEvent((ActionEvent)event);
- else if (event instanceof ItemEvent)
- processItemEvent((ItemEvent)event);
- else
- super.processEvent(event);
-}
+ /**
+ * Adds the specified <code>ItemListener</code> to the list of
+ * registered listeners for this object.
+ *
+ * @param listener The listener to add.
+ *
+ * @since 1.1
+ */
+ public synchronized void addItemListener(ItemListener listener)
+ {
+ item_listeners = AWTEventMulticaster.add(item_listeners, listener);
+ }
-/*************************************************************************/
+ /**
+ * Removes the specified <code>ItemListener</code> from the list of
+ * registers listeners for this object.
+ *
+ * @param listener The listener to remove.
+ *
+ * @since 1.1
+ */
+ public synchronized void removeItemListener(ItemListener listener)
+ {
+ item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
+ }
-/**
- * This method processes the specified event by dispatching it to any
- * registered listeners. Note that this method will only get called if
- * action events are enabled. This will happen automatically if any
- * listeners are added, or it can be done "manually" by calling
- * the <code>enableEvents()</code> method.
- *
- * @param event The event to process.
- */
-protected void
-processActionEvent(ActionEvent event)
-{
- if (action_listeners != null)
- action_listeners.actionPerformed(event);
-}
+ /**
+ * Processes the specified event for this object. If the event is an
+ * instance of <code>ActionEvent</code> then the
+ * <code>processActionEvent()</code> method is called. Similarly, if the
+ * even is an instance of <code>ItemEvent</code> then the
+ * <code>processItemEvent()</code> method is called. Otherwise the
+ * superclass method is called to process this event.
+ *
+ * @param event The event to process.
+ *
+ * @since 1.1
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ if (event instanceof ActionEvent)
+ processActionEvent((ActionEvent)event);
+ else if (event instanceof ItemEvent)
+ processItemEvent((ItemEvent)event);
+ else
+ super.processEvent(event);
+ }
-/*************************************************************************/
+ /**
+ * This method processes the specified event by dispatching it to any
+ * registered listeners. Note that this method will only get called if
+ * action events are enabled. This will happen automatically if any
+ * listeners are added, or it can be done "manually" by calling
+ * the <code>enableEvents()</code> method.
+ *
+ * @param event The event to process.
+ *
+ * @since 1.1
+ */
+ protected void processActionEvent(ActionEvent event)
+ {
+ if (action_listeners != null)
+ action_listeners.actionPerformed(event);
+ }
-/**
- * This method processes the specified event by dispatching it to any
- * registered listeners. Note that this method will only get called if
- * item events are enabled. This will happen automatically if any
- * listeners are added, or it can be done "manually" by calling
- * the <code>enableEvents()</code> method.
- *
- * @param event The event to process.
- */
-protected void
-processItemEvent(ItemEvent event)
-{
- if (item_listeners != null)
- item_listeners.itemStateChanged(event);
-}
+ /**
+ * This method processes the specified event by dispatching it to any
+ * registered listeners. Note that this method will only get called if
+ * item events are enabled. This will happen automatically if any
+ * listeners are added, or it can be done "manually" by calling
+ * the <code>enableEvents()</code> method.
+ *
+ * @param event The event to process.
+ *
+ * @since 1.1
+ */
+ protected void processItemEvent(ItemEvent event)
+ {
+ if (item_listeners != null)
+ item_listeners.itemStateChanged(event);
+ }
-void
-dispatchEventImpl(AWTEvent e)
-{
- if (e.id <= ItemEvent.ITEM_LAST
- && e.id >= ItemEvent.ITEM_FIRST
- && (item_listeners != null
- || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
- processEvent(e);
- else if (e.id <= ActionEvent.ACTION_LAST
+ void dispatchEventImpl(AWTEvent e)
+ {
+ if (e.id <= ItemEvent.ITEM_LAST
+ && e.id >= ItemEvent.ITEM_FIRST
+ && (item_listeners != null
+ || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
+ processEvent(e);
+ else if (e.id <= ActionEvent.ACTION_LAST
&& e.id >= ActionEvent.ACTION_FIRST
&& (action_listeners != null
- || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
- processEvent(e);
- else
- super.dispatchEventImpl(e);
-}
-
-/*************************************************************************/
+ || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+ }
-/**
- * Returns a debugging string for this object.
- *
- * @return A debugging string for this object.
- */
-protected String
-paramString()
-{
- return "multiple=" + multipleMode + ",rows=" + rows + super.paramString();
-}
+ /**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+ protected String paramString()
+ {
+ return "multiple=" + multipleMode + ",rows=" + rows + super.paramString();
+ }
/**
* Returns an array of all the objects currently registered as FooListeners
@@ -1115,6 +988,8 @@ paramString()
*
* @exception ClassCastException If listenerType doesn't specify a class or
* interface that implements java.util.EventListener.
+ *
+ * @since 1.3
*/
public <T extends EventListener> T[] getListeners (Class<T> listenerType)
{
@@ -1129,6 +1004,8 @@ paramString()
/**
* Returns all action listeners registered to this object.
+ *
+ * @since 1.4
*/
public ActionListener[] getActionListeners ()
{
@@ -1137,6 +1014,8 @@ paramString()
/**
* Returns all action listeners registered to this object.
+ *
+ * @since 1.4
*/
public ItemListener[] getItemListeners ()
{
diff --git a/java/awt/Menu.java b/java/awt/Menu.java
index f900d9295..cef04a38e 100644
--- a/java/awt/Menu.java
+++ b/java/awt/Menu.java
@@ -54,38 +54,28 @@ import javax.accessibility.AccessibleRole;
public class Menu extends MenuItem implements MenuContainer, Serializable
{
-/*
- * Static Variables
- */
-
-/**
- * The number used to generate the name returned by getName.
- */
-private static transient long next_menu_number;
-
-// Serialization Constant
-private static final long serialVersionUID = -8809584163345499784L;
-
-/*************************************************************************/
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_menu_number;
-/*
- * Instance Variables
- */
+ // Serialization Constant
+ private static final long serialVersionUID = -8809584163345499784L;
-/**
- * @serial The actual items in the menu
- */
-private Vector items = new Vector();
+ /**
+ * @serial The actual items in the menu
+ */
+ private Vector items = new Vector();
-/**
- * @serial Flag indicating whether or not this menu is a tear off
- */
-private boolean tearOff;
+ /**
+ * @serial Flag indicating whether or not this menu is a tear off
+ */
+ private boolean tearOff;
-/**
- * @serial Indicates whether or not this is a help menu.
- */
-private boolean isHelpMenu;
+ /**
+ * @serial Indicates whether or not this is a help menu.
+ */
+ private boolean isHelpMenu;
/*
* @serial Unused in this implementation, but present in Sun's
@@ -93,371 +83,316 @@ private boolean isHelpMenu;
*/
private int menuSerializedDataVersion = 1;
-static final transient String separatorLabel = "-";
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * Initializes a new instance of <code>Menu</code> with no label and that
- * is not a tearoff;
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-Menu()
-{
-}
-
-/*************************************************************************/
-
-/**
- * Initializes a new instance of <code>Menu</code> that is not a tearoff and
- * that has the specified label.
- *
- * @param label The menu label.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-Menu(String label)
-{
- this(label, false);
-}
-
-/*************************************************************************/
-
-/**
- * Initializes a new instance of <code>Menu</code> with the specified
- * label and tearoff status.
- *
- * @param label The label for this menu
- * @param isTearOff <code>true</code> if this menu is a tear off menu,
- * <code>false</code> otherwise.
- *
- * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
- */
-public
-Menu(String label, boolean isTearOff)
-{
- super(label);
+ static final transient String separatorLabel = "-";
- tearOff = isTearOff;
+ /**
+ * Initializes a new instance of <code>Menu</code> with no label and that
+ * is not a tearoff;
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Menu()
+ {
+ }
- if (label.equals("Help"))
- isHelpMenu = true;
+ /**
+ * Initializes a new instance of <code>Menu</code> that is not a tearoff and
+ * that has the specified label.
+ *
+ * @param label The menu label.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Menu(String label)
+ {
+ this(label, false);
+ }
- if (GraphicsEnvironment.isHeadless())
- throw new HeadlessException ();
-}
+ /**
+ * Initializes a new instance of <code>Menu</code> with the specified
+ * label and tearoff status.
+ *
+ * @param label The label for this menu
+ * @param isTearOff <code>true</code> if this menu is a tear off menu,
+ * <code>false</code> otherwise.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Menu(String label, boolean isTearOff)
+ {
+ super(label);
-/*************************************************************************/
+ tearOff = isTearOff;
-/*
- * Instance Methods
- */
+ if (label.equals("Help"))
+ isHelpMenu = true;
-/**
- * Tests whether or not this menu is a tearoff.
- *
- * @return <code>true</code> if this menu is a tearoff, <code>false</code>
- * otherwise.
- */
-public boolean
-isTearOff()
-{
- return(tearOff);
-}
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+ }
-/*************************************************************************/
+ /**
+ * Tests whether or not this menu is a tearoff.
+ *
+ * @return <code>true</code> if this menu is a tearoff, <code>false</code>
+ * otherwise.
+ */
+ public boolean isTearOff()
+ {
+ return(tearOff);
+ }
-/**
- * Returns the number of items in this menu.
- *
- * @return The number of items in this menu.
- */
-public int
-getItemCount()
-{
- return countItems ();
-}
+ /**
+ * Returns the number of items in this menu.
+ *
+ * @return The number of items in this menu.
+ */
+ public int getItemCount()
+ {
+ return countItems();
+ }
-/**
- * Returns the number of items in this menu.
- *
- * @return The number of items in this menu.
- *
- * @deprecated As of JDK 1.1, replaced by getItemCount().
- */
-public int countItems ()
-{
- return items.size ();
-}
+ /**
+ * Returns the number of items in this menu.
+ *
+ * @return The number of items in this menu.
+ *
+ * @deprecated As of JDK 1.1, replaced by getItemCount().
+ */
+ public int countItems()
+ {
+ return items.size();
+ }
-/*************************************************************************/
-
-/**
- * Returns the item at the specified index.
- *
- * @return The item at the specified index.
- *
- * @exception ArrayIndexOutOfBoundsException If the index value is not valid.
- */
-public MenuItem
-getItem(int index)
-{
- return((MenuItem)items.elementAt(index));
-}
-
-/*************************************************************************/
-
-/**
- * Adds the specified item to this menu. If it was previously part of
- * another menu, it is first removed from that menu.
- *
- * @param item The new item to add.
- *
- * @return The item that was added.
- */
-public MenuItem
-add(MenuItem item)
-{
- MenuContainer parent = item.getParent();
- if (parent != null)
- parent.remove(item);
-
- items.addElement(item);
- item.setParent(this);
+ /**
+ * Returns the item at the specified index.
+ *
+ * @param index the item index.
+ *
+ * @return The item at the specified index.
+ *
+ * @exception ArrayIndexOutOfBoundsException If the index value is not valid.
+ */
+ public MenuItem getItem(int index)
+ {
+ return((MenuItem) items.elementAt(index));
+ }
- if (peer != null)
- {
- item.addNotify();
- MenuPeer mp = (MenuPeer) peer;
- mp.addItem(item);
- }
+ /**
+ * Adds the specified item to this menu. If it was previously part of
+ * another menu, it is first removed from that menu.
+ *
+ * @param item The new item to add.
+ *
+ * @return The item that was added.
+ */
+ public MenuItem add(MenuItem item)
+ {
+ MenuContainer parent = item.getParent();
+ if (parent != null)
+ parent.remove(item);
- return item;
-}
+ items.addElement(item);
+ item.setParent(this);
-/*************************************************************************/
+ if (peer != null)
+ {
+ item.addNotify();
+ MenuPeer mp = (MenuPeer) peer;
+ mp.addItem(item);
+ }
-/**
- * Add an item with the specified label to this menu.
- *
- * @param label The label of the menu item to add.
- */
-public void
-add(String label)
-{
- add(new MenuItem(label));
-}
-
-/*************************************************************************/
-
-/**
- * Inserts the specified menu item into this menu at the specified index.
- *
- * @param item The menu item to add.
- * @param index The index of the menu item.
- *
- * @exception IllegalArgumentException If the index is less than zero.
- * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
- */
-public void
-insert(MenuItem item, int index)
-{
- if (index < 0)
- throw new IllegalArgumentException("Index is less than zero");
+ return item;
+ }
- int count = getItemCount ();
+ /**
+ * Add an item with the specified label to this menu.
+ *
+ * @param label The label of the menu item to add.
+ */
+ public void add(String label)
+ {
+ add(new MenuItem(label));
+ }
- if (index >= count)
- add(item);
- else
- {
- MenuContainer parent = item.getParent();
- if (parent != null)
- parent.remove(item);
+ /**
+ * Inserts the specified menu item into this menu at the specified index. If
+ * the index is greater than or equal to the number of items already in the
+ * menu, the new item is added as the last item in the menu.
+ *
+ * @param item The menu item to add (<code>null</code> not permitted).
+ * @param index The index of the menu item (>= 0).
+ *
+ * @throws IllegalArgumentException if the index is less than zero.
+ * @throws NullPointerException if <code>item</code> is <code>null</code>.
+ */
+ public void insert(MenuItem item, int index)
+ {
+ if (index < 0)
+ throw new IllegalArgumentException("Index is less than zero");
+
+ int count = getItemCount();
+
+ if (index >= count)
+ add(item);
+ else
+ {
+ MenuContainer parent = item.getParent();
+ if (parent != null)
+ parent.remove(item);
- items.insertElementAt(item, index);
- item.setParent(this);
-
- MenuPeer peer = (MenuPeer) getPeer();
- if (peer == null)
- return;
+ items.insertElementAt(item, index);
+ item.setParent(this);
- for (int i = count - 1; i >= index; i--)
- peer.delItem(i);
+ MenuPeer peer = (MenuPeer) getPeer();
+ if (peer == null)
+ return;
- item.addNotify();
- peer.addItem(item);
+ for (int i = count - 1; i >= index; i--)
+ peer.delItem(i);
- for (int i = index; i < count; i++)
- peer.addItem((MenuItem) items.elementAt (i));
- }
-
-}
+ item.addNotify();
+ peer.addItem(item);
-/*************************************************************************/
+ // bear in mind that count is the number of items *before* the new
+ // item was added
+ for (int i = index + 1; i <= count; i++)
+ peer.addItem((MenuItem) items.elementAt(i));
+ }
-/**
- * Inserts an item with the specified label into this menu at the specified index.
- *
- * @param label The label of the item to add.
- * @param index The index of the menu item.
- *
- * @exception IllegalArgumentException If the index is less than zero.
- * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
- */
-public void
-insert(String label, int index)
-{
- insert(new MenuItem(label), index);
-}
-
-/*************************************************************************/
-
-/**
- * Adds a separator bar at the current menu location.
- */
-public void
-addSeparator()
-{
- add(new MenuItem(separatorLabel));
-}
-
-/*************************************************************************/
-
-/**
- * Inserts a separator bar at the specified index value.
- *
- * @param index The index at which to insert a separator bar.
- *
- * @exception IllegalArgumentException If the index is less than zero.
- * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
- */
-public void
-insertSeparator(int index)
-{
- insert(new MenuItem(separatorLabel), index);
-}
+ }
-/*************************************************************************/
+ /**
+ * Inserts an item with the specified label into this menu at the specified
+ * index. If the index is greater than or equal to the number of items
+ * already in the menu, the new item is added as the last item in the menu.
+ *
+ * @param label The label of the item to add.
+ * @param index The index of the menu item (>= 0).
+ *
+ * @throws IllegalArgumentException If the index is less than zero.
+ */
+ public void insert(String label, int index)
+ {
+ insert(new MenuItem(label), index);
+ }
-/**
- * Deletes the item at the specified index from this menu.
- *
- * @param index The index of the item to remove.
- *
- * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
- */
-public synchronized void
-remove(int index)
-{
- MenuItem item = (MenuItem) items.remove(index);
+ /**
+ * Adds a separator bar at the current menu location.
+ */
+ public void addSeparator()
+ {
+ add(new MenuItem(separatorLabel));
+ }
- MenuPeer mp = (MenuPeer) getPeer();
- if (mp != null)
- {
- mp.delItem(index);
- item.removeNotify();
- }
- item.setParent(null);
-}
+ /**
+ * Inserts a separator bar at the specified index value.
+ *
+ * @param index The index at which to insert a separator bar.
+ *
+ * @exception IllegalArgumentException If the index is less than zero.
+ * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
+ */
+ public void insertSeparator(int index)
+ {
+ insert(new MenuItem(separatorLabel), index);
+ }
-/*************************************************************************/
+ /**
+ * Deletes the item at the specified index from this menu.
+ *
+ * @param index The index of the item to remove.
+ *
+ * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
+ */
+ public synchronized void remove(int index)
+ {
+ MenuItem item = (MenuItem) items.remove(index);
+
+ MenuPeer mp = (MenuPeer) getPeer();
+ if (mp != null)
+ {
+ mp.delItem(index);
+ item.removeNotify();
+ }
+ item.setParent(null);
+ }
-/**
- * Removes the specifed item from the menu. If the specified component
- * does not exist, this method does nothing.
- *
- * @param item The component to remove.
- */
-public void
-remove(MenuComponent item)
-{
- int index = items.indexOf(item);
- if (index == -1)
- return;
+ /**
+ * Removes the specifed item from the menu. If the specified component
+ * does not exist, this method does nothing.
+ *
+ * @param item The component to remove.
+ */
+ public void remove(MenuComponent item)
+ {
+ int index = items.indexOf(item);
+ if (index == -1)
+ return;
- remove(index);
-}
+ remove(index);
+ }
-/*************************************************************************/
+ /**
+ * Removes all the elements from this menu.
+ */
+ public synchronized void removeAll()
+ {
+ int count = getItemCount();
+ for(int i = 0; i < count; i++)
+ {
+ // We must always remove item 0.
+ remove(0);
+ }
+ }
-/**
- * Removes all the elements from this menu.
- */
-public synchronized void
-removeAll()
-{
- int count = getItemCount();
- for(int i = 0; i < count; i++)
+ /**
+ * Creates the native peer for this object.
+ */
+ public void addNotify()
+ {
+ MenuPeer peer = (MenuPeer) getPeer();
+ if (peer == null)
+ {
+ peer = getToolkit().createMenu(this);
+ setPeer(peer);
+ }
+
+ Enumeration e = items.elements();
+ while (e.hasMoreElements())
{
- // We must always remove item 0.
- remove(0);
+ MenuItem mi = (MenuItem)e.nextElement();
+ mi.addNotify();
+ peer.addItem(mi);
}
-}
-/*************************************************************************/
+ super.addNotify();
+ }
-/**
- * Creates the native peer for this object.
- */
-public void
-addNotify()
-{
- MenuPeer peer = (MenuPeer) getPeer();
- if (peer == null)
+ /**
+ * Destroys the native peer for this object.
+ */
+ public void removeNotify()
+ {
+ Enumeration e = items.elements();
+ while (e.hasMoreElements())
{
- peer = getToolkit().createMenu(this);
- setPeer(peer);
+ MenuItem mi = (MenuItem) e.nextElement();
+ mi.removeNotify();
}
-
- Enumeration e = items.elements();
- while (e.hasMoreElements())
- {
- MenuItem mi = (MenuItem)e.nextElement();
- mi.addNotify();
- peer.addItem(mi);
+ super.removeNotify();
}
- super.addNotify ();
-}
-
-/*************************************************************************/
-
-/**
- * Destroys the native peer for this object.
- */
-public void
-removeNotify()
-{
- Enumeration e = items.elements();
- while (e.hasMoreElements())
+ /**
+ * Returns a debugging string for this menu.
+ *
+ * @return A debugging string for this menu.
+ */
+ public String paramString()
{
- MenuItem mi = (MenuItem) e.nextElement();
- mi.removeNotify();
+ return (",tearOff=" + tearOff + ",isHelpMenu=" + isHelpMenu
+ + super.paramString());
}
- super.removeNotify();
-}
-
-/*************************************************************************/
-
-/**
- * Returns a debugging string for this menu.
- *
- * @return A debugging string for this menu.
- */
-public String
-paramString()
-{
- return (",tearOff=" + tearOff + ",isHelpMenu=" + isHelpMenu
- + super.paramString());
-}
/**
* Basic Accessibility class for Menu. Details get provided in derived
diff --git a/java/awt/Rectangle.java b/java/awt/Rectangle.java
index c4ba6ba14..ac2494ee0 100644
--- a/java/awt/Rectangle.java
+++ b/java/awt/Rectangle.java
@@ -1,5 +1,5 @@
/* Rectangle.java -- represents a graphics rectangle
- Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
+ Copyright (C) 1999, 2000, 2001, 2002, 2006, Free Software Foundation
This file is part of GNU Classpath.
@@ -119,7 +119,6 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
* coordinates of the specified rectangle.
*
* @param r the rectangle to copy from
- * @throws NullPointerException if r is null
* @since 1.1
*/
public Rectangle(Rectangle r)
@@ -168,7 +167,6 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*
* @param p the upper left corner of the rectangle
* @param d the width and height of the rectangle
- * @throws NullPointerException if p or d is null
*/
public Rectangle(Point p, Dimension d)
{
@@ -185,7 +183,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
* @param p the upper left corner of the rectangle
*/
public Rectangle(Point p)
- {
+ {
x = p.x;
y = p.y;
}
@@ -198,7 +196,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
* @param d the width and height of the rectangle
*/
public Rectangle(Dimension d)
- {
+ {
width = d.width;
height = d.height;
}
@@ -299,8 +297,10 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
}
/**
- * Updates this rectangle to have the specified dimensions, as rounded to
- * integers.
+ * Updates this rectangle to have the specified dimensions, rounded to the
+ * integer precision used by this class (the values are rounded "outwards" so
+ * that the stored rectangle completely encloses the specified double
+ * precision rectangle).
*
* @param x the new X coordinate of the upper left hand corner
* @param y the new Y coordinate of the upper left hand corner
@@ -310,10 +310,10 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public void setRect(double x, double y, double width, double height)
{
- this.x = (int) x;
- this.y = (int) y;
- this.width = (int) width;
- this.height = (int) height;
+ this.x = (int) Math.floor(x);
+ this.y = (int) Math.floor(y);
+ this.width = (int) Math.ceil(x + width) - this.x;
+ this.height = (int) Math.ceil(y + height) - this.y;
}
/**
diff --git a/java/awt/Window.java b/java/awt/Window.java
index 322fbdeb0..7a3092f81 100644
--- a/java/awt/Window.java
+++ b/java/awt/Window.java
@@ -140,7 +140,7 @@ public class Window extends Container implements Accessible
this();
graphicsConfiguration = gc;
}
-
+
/**
* Initializes a new instance of <code>Window</code> with the specified
* parent. The window will initially be invisible.
@@ -257,8 +257,6 @@ public class Window extends Container implements Accessible
{
synchronized (getTreeLock())
{
- if (parent != null && ! parent.isDisplayable())
- parent.addNotify();
if (peer == null)
addNotify();
@@ -300,6 +298,15 @@ public class Window extends Container implements Accessible
if (initialFocusOwner != null)
initialFocusOwner.requestFocusInWindow();
+ // Post WINDOW_OPENED from here.
+ if (windowListener != null
+ || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
+ {
+ WindowEvent ev = new WindowEvent(this,
+ WindowEvent.WINDOW_OPENED);
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ tk.getSystemEventQueue().postEvent(ev);
+ }
shown = true;
}
}
@@ -355,9 +362,15 @@ public class Window extends Container implements Accessible
component[i].removeNotify();
this.removeNotify();
- // Post a WINDOW_CLOSED event.
- WindowEvent we = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
- getToolkit().getSystemEventQueue().postEvent(we);
+ // Post WINDOW_CLOSED from here.
+ if (windowListener != null
+ || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
+ {
+ WindowEvent ev = new WindowEvent(this,
+ WindowEvent.WINDOW_OPENED);
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ tk.getSystemEventQueue().postEvent(ev);
+ }
}
}
@@ -592,33 +605,12 @@ public class Window extends Container implements Accessible
void dispatchEventImpl(AWTEvent e)
{
- // Make use of event id's in order to avoid multiple instanceof tests.
- if (e.id <= WindowEvent.WINDOW_LAST
- && e.id >= WindowEvent.WINDOW_FIRST
- && (windowListener != null
- || windowFocusListener != null
- || windowStateListener != null
- || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
- processEvent(e);
- else
+ if (e.getID() == ComponentEvent.COMPONENT_RESIZED)
{
- if (peer != null && (e.id == ComponentEvent.COMPONENT_RESIZED
- || e.id == ComponentEvent.COMPONENT_MOVED))
- {
- Rectangle bounds = peer.getBounds();
- x = bounds.x;
- y = bounds.y;
- height = bounds.height;
- width = bounds.width;
-
- if (e.id == ComponentEvent.COMPONENT_RESIZED)
- {
- invalidate();
- validate();
- }
- }
- super.dispatchEventImpl(e);
+ invalidate();
+ validate();
}
+ super.dispatchEventImpl(e);
}
/**
diff --git a/java/awt/geom/RoundRectangle2D.java b/java/awt/geom/RoundRectangle2D.java
index ac0e6f812..ac4d89fff 100644
--- a/java/awt/geom/RoundRectangle2D.java
+++ b/java/awt/geom/RoundRectangle2D.java
@@ -1,5 +1,5 @@
/* RoundRectangle2D.java -- represents a rectangle with rounded corners
- Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation
+ Copyright (C) 2000, 2002, 2003, 2004, 2006, Free Software Foundation
This file is part of GNU Classpath.
@@ -37,7 +37,6 @@ exception statement from your version. */
package java.awt.geom;
-import java.util.NoSuchElementException;
/** This class implements a rectangle with rounded corners.
@@ -46,13 +45,29 @@ import java.util.NoSuchElementException;
*/
public abstract class RoundRectangle2D extends RectangularShape
{
- /** Return the arc height of this round rectangle. */
+ /**
+ * Return the arc height of this round rectangle. The arc height and width
+ * control the roundness of the corners of the rectangle.
+ *
+ * @return The arc height.
+ *
+ * @see #getArcWidth()
+ */
public abstract double getArcHeight();
- /** Return the arc width of this round rectangle. */
+ /**
+ * Return the arc width of this round rectangle. The arc width and height
+ * control the roundness of the corners of the rectangle.
+ *
+ * @return The arc width.
+ *
+ * @see #getArcHeight()
+ */
public abstract double getArcWidth();
- /** Set the values of this round rectangle
+ /**
+ * Set the values of this round rectangle.
+ *
* @param x The x coordinate
* @param y The y coordinate
* @param w The width
@@ -63,14 +78,16 @@ public abstract class RoundRectangle2D extends RectangularShape
public abstract void setRoundRect(double x, double y, double w, double h,
double arcWidth, double arcHeight);
- /** Create a RoundRectangle2D. This is protected because this class
+ /**
+ * Create a RoundRectangle2D. This is protected because this class
* is abstract and cannot be instantiated.
*/
protected RoundRectangle2D()
{
}
- /** Return true if this object contains the specified point.
+ /**
+ * Return true if this object contains the specified point.
* @param x The x coordinate
* @param y The y coordinate
*/
@@ -106,7 +123,8 @@ public abstract class RoundRectangle2D extends RectangularShape
return dx * dx + dy * dy <= 1.0;
}
- /** Return true if this object contains the specified rectangle
+ /**
+ * Return true if this object contains the specified rectangle
* @param x The x coordinate
* @param y The y coordinate
* @param w The width
@@ -120,176 +138,185 @@ public abstract class RoundRectangle2D extends RectangularShape
&& contains(x + w, y));
}
- /** Return a new path iterator which iterates over this rectangle.
+ /**
+ * Return a new path iterator which iterates over this rectangle.
+ *
* @param at An affine transform to apply to the object
*/
- public PathIterator getPathIterator(final AffineTransform at)
+ public PathIterator getPathIterator(final AffineTransform at)
{
- final double minx = getX();
- final double miny = getY();
- final double maxx = minx + getWidth();
- final double maxy = miny + getHeight();
- final double arcwidth = getArcWidth();
- final double archeight = getArcHeight();
- return new PathIterator()
+ double arcW = Math.min(getArcWidth(), getWidth());
+ double arcH = Math.min(getArcHeight(), getHeight());
+
+ // check for special cases...
+ if (arcW <= 0 || arcH <= 0)
+ {
+ Rectangle2D r = new Rectangle2D.Double(getX(), getY(), getWidth(),
+ getHeight());
+ return r.getPathIterator(at);
+ }
+ else if (arcW >= getWidth() && arcH >= getHeight())
+ {
+ Ellipse2D e = new Ellipse2D.Double(getX(), getY(), getWidth(),
+ getHeight());
+ return e.getPathIterator(at);
+ }
+
+ // otherwise return the standard case...
+ return new PathIterator()
+ {
+ double x = getX();
+ double y = getY();
+ double w = getWidth();
+ double h = getHeight();
+ double arcW = Math.min(getArcWidth(), w);
+ double arcH = Math.min(getArcHeight(), h);
+ Arc2D.Double arc = new Arc2D.Double();
+ PathIterator corner;
+ int step = -1;
+
+ public int currentSegment(double[] coords)
+ {
+ if (corner != null) // steps 1, 3, 5 and 7
+ {
+ int r = corner.currentSegment(coords);
+ if (r == SEG_MOVETO)
+ r = SEG_LINETO;
+ return r;
+ }
+ if (step == -1)
+ {
+ // move to the start position
+ coords[0] = x + w - arcW / 2;
+ coords[1] = y;
+ }
+ else if (step == 0)
+ {
+ // top line
+ coords[0] = x + arcW / 2;
+ coords[1] = y;
+ }
+ else if (step == 2)
+ {
+ // left line
+ coords[0] = x;
+ coords[1] = y + h - arcH / 2;
+ }
+ else if (step == 4)
+ {
+ // bottom line
+ coords[0] = x + w - arcW / 2;
+ coords[1] = y + h;
+ }
+ else if (step == 6)
+ {
+ // right line
+ coords[0] = x + w;
+ coords[1] = y + arcH / 2;
+ }
+ if (at != null)
+ at.transform(coords, 0, coords, 0, 1);
+ return step == -1 ? SEG_MOVETO : SEG_LINETO;
+ }
+
+ public int currentSegment(float[] coords) {
+ if (corner != null) // steps 1, 3, 5 and 7
+ {
+ int r = corner.currentSegment(coords);
+ if (r == SEG_MOVETO)
+ r = SEG_LINETO;
+ return r;
+ }
+ if (step == -1)
+ {
+ // move to the start position
+ coords[0] = (float) (x + w - arcW / 2);
+ coords[1] = (float) y;
+ }
+ else if (step == 0)
+ {
+ // top line
+ coords[0] = (float) (x + arcW / 2);
+ coords[1] = (float) y;
+ }
+ else if (step == 2)
+ {
+ // left line
+ coords[0] = (float) x;
+ coords[1] = (float) (y + h - arcH / 2);
+ }
+ else if (step == 4)
+ {
+ // bottom line
+ coords[0] = (float) (x + w - arcW / 2);
+ coords[1] = (float) (y + h);
+ }
+ else if (step == 6)
+ {
+ // right line
+ coords[0] = (float) (x + w);
+ coords[1] = (float) (y + arcH / 2);
+ }
+ if (at != null)
+ at.transform(coords, 0, coords, 0, 1);
+ return step == -1 ? SEG_MOVETO : SEG_LINETO;
+ }
+
+ public int getWindingRule() {
+ return WIND_NON_ZERO;
+ }
+
+ public boolean isDone() {
+ return step >= 8;
+ }
+
+ public void next()
{
- /** We iterate counterclockwise around the rectangle, starting in the
- * upper right. This variable tracks our current point, which
- * can be on either side of a given corner. */
- private int current = 0;
-
- /** Child path iterator, used for corners. */
- private PathIterator corner;
-
- /** This is used when rendering the corners. We re-use the arc
- * for each corner. */
- private Arc2D arc = new Arc2D.Double();
-
- /** Temporary array used by getPoint. */
- private double[] temp = new double[2];
-
- public int getWindingRule()
- {
- return WIND_NON_ZERO;
- }
-
- public boolean isDone()
- {
- return current > 9;
- }
-
- private void getPoint(int val)
- {
- switch (val)
- {
- case 0:
- case 8:
- temp[0] = maxx;
- temp[1] = miny + archeight;
- break;
- case 7:
- temp[0] = maxx;
- temp[1] = maxy - archeight;
- break;
- case 6:
- temp[0] = maxx - arcwidth;
- temp[1] = maxy;
- break;
- case 5:
- temp[0] = minx + arcwidth;
- temp[1] = maxy;
- break;
- case 4:
- temp[0] = minx;
- temp[1] = maxy - archeight;
- break;
- case 3:
- temp[0] = minx;
- temp[1] = miny + archeight;
- break;
- case 2:
- temp[0] = minx + arcwidth;
- temp[1] = miny;
- break;
- case 1:
- temp[0] = maxx - arcwidth;
- temp[1] = miny;
- break;
- }
- }
-
- public void next()
- {
- if (current >= 8)
- ++current;
- else if (corner != null)
- {
- // We're iterating through the corner. Work on the child
- // iterator; if it finishes, reset and move to the next
- // point along the rectangle.
- corner.next();
- if (corner.isDone())
- {
- corner = null;
- ++current;
- }
- }
- else
- {
- // Make an arc between this point on the rectangle and
- // the next one, and then iterate over this arc.
- getPoint(current);
- double x1 = temp[0];
- double y1 = temp[1];
- getPoint(current + 1);
- Rectangle2D.Double r = new Rectangle2D.Double(Math.min(x1,
- temp[0]),
- Math.min(y1,
- temp[1]),
- Math.abs(x1
- - temp[0]),
- Math.abs(y1
- - temp[1]));
- arc.setArc(r, (current >> 1) * 90.0, 90.0, Arc2D.OPEN);
- corner = arc.getPathIterator(at);
- }
- }
-
- public int currentSegment(float[] coords)
- {
- if (corner != null)
- {
- int r = corner.currentSegment(coords);
- if (r == SEG_MOVETO)
- r = SEG_LINETO;
- return r;
- }
-
- if (current < 9)
- {
- getPoint(current);
- coords[0] = (float) temp[0];
- coords[1] = (float) temp[1];
- }
- else if (current == 9)
- return SEG_CLOSE;
- else
- throw new NoSuchElementException("rect iterator out of bounds");
-
- if (at != null)
- at.transform(coords, 0, coords, 0, 1);
- return current == 0 ? SEG_MOVETO : SEG_LINETO;
- }
-
- public int currentSegment(double[] coords)
- {
- if (corner != null)
- {
- int r = corner.currentSegment(coords);
- if (r == SEG_MOVETO)
- r = SEG_LINETO;
- return r;
- }
-
- if (current < 9)
- {
- getPoint(current);
- coords[0] = temp[0];
- coords[1] = temp[1];
- }
- else if (current == 9)
- return SEG_CLOSE;
- else
- throw new NoSuchElementException("rect iterator out of bounds");
-
- if (at != null)
- at.transform(coords, 0, coords, 0, 1);
- return current == 0 ? SEG_MOVETO : SEG_LINETO;
- }
- };
+ if (corner != null)
+ {
+ corner.next();
+ if (corner.isDone())
+ {
+ corner = null;
+ step++;
+ }
+ }
+ else
+ {
+ step++;
+ if (step == 1)
+ {
+ // create top left corner
+ arc.setArc(x, y, arcW, arcH, 90, 90, Arc2D.OPEN);
+ corner = arc.getPathIterator(at);
+ }
+ else if (step == 3)
+ {
+ // create bottom left corner
+ arc.setArc(x, y + h - arcH, arcW, arcH, 180, 90,
+ Arc2D.OPEN);
+ corner = arc.getPathIterator(at);
+ }
+ else if (step == 5)
+ {
+ // create bottom right corner
+ arc.setArc(x + w - arcW, y + h - arcH, arcW, arcH, 270, 90,
+ Arc2D.OPEN);
+ corner = arc.getPathIterator(at);
+ }
+ else if (step == 7)
+ {
+ // create top right corner
+ arc.setArc(x + w - arcW, y, arcW, arcH, 0, 90, Arc2D.OPEN);
+ corner = arc.getPathIterator(at);
+ }
+ }
+ }
+ };
}
- /** Return true if the given rectangle intersects this shape.
+ /**
+ * Return true if the given rectangle intersects this shape.
* @param x The x coordinate
* @param y The y coordinate
* @param w The width
@@ -302,7 +329,8 @@ public abstract class RoundRectangle2D extends RectangularShape
|| contains(x + w, y));
}
- /** Set the boundary of this round rectangle.
+ /**
+ * Set the boundary of this round rectangle.
* @param x The x coordinate
* @param y The y coordinate
* @param w The width
@@ -314,7 +342,8 @@ public abstract class RoundRectangle2D extends RectangularShape
setRoundRect(x, y, w, h, getArcWidth(), getArcHeight());
}
- /** Set the values of this round rectangle to be the same as those
+ /**
+ * Set the values of this round rectangle to be the same as those
* of the argument.
* @param rr The round rectangle to copy
*/
@@ -324,8 +353,10 @@ public abstract class RoundRectangle2D extends RectangularShape
rr.getArcWidth(), rr.getArcHeight());
}
- /** A subclass of RoundRectangle which keeps its parameters as
- * doubles. */
+ /**
+ * A subclass of RoundRectangle which keeps its parameters as
+ * doubles.
+ */
public static class Double extends RoundRectangle2D
{
/** The height of the corner arc. */
@@ -346,12 +377,15 @@ public abstract class RoundRectangle2D extends RectangularShape
/** The height of this object. */
public double height;
- /** Construct a new instance, with all parameters set to 0. */
+ /**
+ * Construct a new instance, with all parameters set to 0.
+ */
public Double()
{
}
- /** Construct a new instance with the given arguments.
+ /**
+ * Construct a new instance with the given arguments.
* @param x The x coordinate
* @param y The y coordinate
* @param w The width
@@ -422,8 +456,10 @@ public abstract class RoundRectangle2D extends RectangularShape
}
} // class Double
- /** A subclass of RoundRectangle which keeps its parameters as
- * floats. */
+ /**
+ * A subclass of RoundRectangle which keeps its parameters as
+ * floats.
+ */
public static class Float extends RoundRectangle2D
{
/** The height of the corner arc. */
@@ -444,12 +480,15 @@ public abstract class RoundRectangle2D extends RectangularShape
/** The height of this object. */
public float height;
- /** Construct a new instance, with all parameters set to 0. */
+ /**
+ * Construct a new instance, with all parameters set to 0.
+ */
public Float()
{
}
- /** Construct a new instance with the given arguments.
+ /**
+ * Construct a new instance with the given arguments.
* @param x The x coordinate
* @param y The y coordinate
* @param w The width
@@ -508,6 +547,18 @@ public abstract class RoundRectangle2D extends RectangularShape
return width <= 0 || height <= 0;
}
+ /**
+ * Sets the dimensions for this rounded rectangle.
+ *
+ * @param x the x-coordinate of the top left corner.
+ * @param y the y-coordinate of the top left corner.
+ * @param w the width of the rectangle.
+ * @param h the height of the rectangle.
+ * @param arcWidth the arc width.
+ * @param arcHeight the arc height.
+ *
+ * @see #setRoundRect(double, double, double, double, double, double)
+ */
public void setRoundRect(float x, float y, float w, float h,
float arcWidth, float arcHeight)
{
diff --git a/java/awt/image/AffineTransformOp.java b/java/awt/image/AffineTransformOp.java
index 7820684d2..849c5b050 100644
--- a/java/awt/image/AffineTransformOp.java
+++ b/java/awt/image/AffineTransformOp.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt.image;
import java.awt.Graphics2D;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
@@ -48,8 +49,11 @@ import java.awt.geom.Rectangle2D;
import java.util.Arrays;
/**
- * This class performs affine transformation between two images or
- * rasters in 2 dimensions.
+ * AffineTransformOp performs matrix-based transformations (translations,
+ * scales, flips, rotations, and shears).
+ *
+ * If interpolation is required, nearest neighbour, bilinear, and bicubic
+ * methods are available.
*
* @author Olga Rodimina (rodimina@redhat.com)
* @author Francis Kung (fkung@redhat.com)
@@ -115,14 +119,14 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
}
/**
- * Creates empty BufferedImage with the size equal to that of the
- * transformed image and correct number of bands. The newly created
+ * Creates a new BufferedImage with the size equal to that of the
+ * transformed image and the correct number of bands. The newly created
* image is created with the specified ColorModel.
- * If the ColorModel is equal to null, an appropriate ColorModel is used.
+ * If a ColorModel is not specified, an appropriate ColorModel is used.
*
- * @param src source image
- * @param destCM color model for the destination image
- * @return new compatible destination image
+ * @param src the source image.
+ * @param destCM color model for the destination image (can be null).
+ * @return a new compatible destination image.
*/
public BufferedImage createCompatibleDestImage (BufferedImage src,
ColorModel destCM)
@@ -145,21 +149,18 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
}
/**
- * Creates empty WritableRaster with the size equal to the transformed
- * source raster and correct number of bands
+ * Creates a new WritableRaster with the size equal to the transformed
+ * source raster and correct number of bands .
*
- * @param src source raster
- * @throws RasterFormatException if resulting width or height of raster is 0
- * @return new compatible raster
+ * @param src the source raster.
+ * @throws RasterFormatException if resulting width or height of raster is 0.
+ * @return a new compatible raster.
*/
public WritableRaster createCompatibleDestRaster (Raster src)
{
Rectangle2D rect = getBounds2D(src);
- // throw RasterFormatException if resulting width or height of the
- // transformed raster is 0
-
- if (rect.getWidth () == 0 || rect.getHeight () == 0)
+ if (rect.getWidth() == 0 || rect.getHeight() == 0)
throw new RasterFormatException("width or height is 0");
return src.createCompatibleWritableRaster((int) rect.getWidth(),
@@ -175,24 +176,22 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
* @param dst destination image
* @throws IllegalArgumentException if the source and destination image are
* the same
- * @return transformed source image
+ * @return transformed source image.
*/
public final BufferedImage filter (BufferedImage src, BufferedImage dst)
{
-
if (dst == src)
- throw new IllegalArgumentException ("src image cannot be the same as " +
- "the dst image");
+ throw new IllegalArgumentException("src image cannot be the same as "
+ + "the dst image");
- // If the destination image is null, then use a compatible BufferedImage
+ // If the destination image is null, then use a compatible BufferedImage
if (dst == null)
dst = createCompatibleDestImage(src, null);
- Graphics2D gr = (Graphics2D) dst.createGraphics ();
- gr.setRenderingHints (hints);
- gr.drawImage (src, transform, null);
+ Graphics2D gr = (Graphics2D) dst.createGraphics();
+ gr.setRenderingHints(hints);
+ gr.drawImage(src, transform, null);
return dst;
-
}
/**
@@ -204,21 +203,40 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
* @param dst destination raster
* @throws IllegalArgumentException if the source and destination are not
* compatible
- * @return transformed raster
+ * @return transformed raster.
*/
- public final WritableRaster filter (Raster src, WritableRaster dst)
+ public final WritableRaster filter(Raster src, WritableRaster dst)
{
+ // Initial checks
if (dst == src)
throw new IllegalArgumentException("src image cannot be the same as"
- + " the dst image");
+ + " the dst image");
if (dst == null)
dst = createCompatibleDestRaster(src);
if (src.getNumBands() != dst.getNumBands())
throw new IllegalArgumentException("src and dst must have same number"
- + " of bands");
+ + " of bands");
+ // Optimization for rasters that can be represented in the RGB colormodel:
+ // wrap the rasters in images, and let Cairo do the transformation
+ if (ColorModel.getRGBdefault().isCompatibleSampleModel(src.getSampleModel())
+ && ColorModel.getRGBdefault().isCompatibleSampleModel(dst.getSampleModel()))
+ {
+ WritableRaster src2 = Raster.createWritableRaster(src.getSampleModel(),
+ src.getDataBuffer(),
+ new Point(src.getMinX(),
+ src.getMinY()));
+ BufferedImage iSrc = new BufferedImage(ColorModel.getRGBdefault(),
+ src2, false, null);
+ BufferedImage iDst = new BufferedImage(ColorModel.getRGBdefault(), dst,
+ false, null);
+
+ return filter(iSrc, iDst).getRaster();
+ }
+
+ // Otherwise, we need to do the transformation in java code...
// Create arrays to hold all the points
double[] dstPts = new double[dst.getHeight() * dst.getWidth() * 2];
double[] srcPts = new double[dst.getHeight() * dst.getWidth() * 2];
@@ -287,7 +305,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
}
/**
- * Returns interpolation type used during transformations
+ * Returns interpolation type used during transformations.
*
* @return interpolation type
*/
@@ -319,7 +337,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
/**
* Returns rendering hints that are used during transformation.
*
- * @return rendering hints
+ * @return the rendering hints used in this Op.
*/
public final RenderingHints getRenderingHints ()
{
@@ -330,7 +348,7 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
* Returns transform used in transformation between source and destination
* image.
*
- * @return transform
+ * @return the transform used in this Op.
*/
public final AffineTransform getTransform ()
{
@@ -377,6 +395,18 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
{
Rectangle srcbounds = src.getBounds();
+ Object xyarr = null;
+ Object xp1arr = null;
+ Object yp1arr = null;
+ Object xyp1arr = null;
+
+ double xy;
+ double xp1;
+ double yp1;
+ double xyp1;
+
+ double[] result = new double[src.getNumBands()];
+
// For all points in the destination raster, use bilinear interpolation
// to find the value from the corrosponding source points
for (int i = 0; i < dpts.length; i += 2)
@@ -400,22 +430,65 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
int y = (int) Math.floor(pts[i + 1] + src.getMinY());
double xdiff = pts[i] + src.getMinX() - x;
double ydiff = pts[i + 1] + src.getMinY() - y;
-
- // Run the interpolation for each band
+
+ // Get surrounding pixels used in interpolation... optimized
+ // to use the smallest datatype possible.
+ if (src.getTransferType() == DataBuffer.TYPE_DOUBLE
+ || src.getTransferType() == DataBuffer.TYPE_FLOAT)
+ {
+ xyarr = src.getPixel(x, y, (double[])xyarr);
+ xp1arr = src.getPixel(x+1, y, (double[])xp1arr);
+ yp1arr = src.getPixel(x, y+1, (double[])yp1arr);
+ xyp1arr = src.getPixel(x+1, y+1, (double[])xyp1arr);
+ }
+ else
+ {
+ xyarr = src.getPixel(x, y, (int[])xyarr);
+ xp1arr = src.getPixel(x+1, y, (int[])xp1arr);
+ yp1arr = src.getPixel(x, y+1, (int[])yp1arr);
+ xyp1arr = src.getPixel(x+1, y+1, (int[])xyp1arr);
+ }
+ // using
+ // array[] pixels = src.getPixels(x, y, 2, 2, pixels);
+ // instead of doing four individual src.getPixel() calls
+ // should be faster, but benchmarking shows that it's not...
+
+ // Run interpolation for each band
for (int j = 0; j < src.getNumBands(); j++)
{
- double result = (src.getSampleDouble(x, y, j) * (1 - xdiff)
- + src.getSampleDouble(x + 1, y, j) * xdiff)
- * (1 - ydiff)
- + (src.getSampleDouble(x, y + 1, j)
- * (1 - xdiff)
- + src.getSampleDouble(x + 1, y + 1, j)
- * xdiff)
- * ydiff;
- dst.setSample((int) dpts[i] + dst.getMinX(),
- (int) dpts[i + 1] + dst.getMinY(),
- j, result);
+ // Pull individual sample values out of array
+ if (src.getTransferType() == DataBuffer.TYPE_DOUBLE
+ || src.getTransferType() == DataBuffer.TYPE_FLOAT)
+ {
+ xy = ((double[])xyarr)[j];
+ xp1 = ((double[])xp1arr)[j];
+ yp1 = ((double[])yp1arr)[j];
+ xyp1 = ((double[])xyp1arr)[j];
+ }
+ else
+ {
+ xy = ((int[])xyarr)[j];
+ xp1 = ((int[])xp1arr)[j];
+ yp1 = ((int[])yp1arr)[j];
+ xyp1 = ((int[])xyp1arr)[j];
+ }
+
+ // If all four samples are identical, there's no need to
+ // calculate anything
+ if (xy == xp1 && xy == yp1 && xy == xyp1)
+ result[j] = xy;
+
+ // Run bilinear interpolation formula
+ else
+ result[j] = (xy * (1-xdiff) + xp1 * xdiff)
+ * (1-ydiff)
+ + (yp1 * (1-xdiff) + xyp1 * xdiff)
+ * ydiff;
}
+
+ dst.setPixel((int)dpts[i] + dst.getMinX(),
+ (int)dpts[i+1] + dst.getMinY(),
+ result);
}
}
}
@@ -434,10 +507,11 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
double[] pts)
{
Rectangle srcbounds = src.getBounds();
-
+ double[] result = new double[src.getNumBands()];
+ Object pixels = null;
+
// For all points on the destination raster, perform bicubic interpolation
// from corrosponding source points
- double[] result = new double[src.getNumBands()];
for (int i = 0; i < dpts.length; i += 2)
{
if (srcbounds.contains((int) Math.round(pts[i]) + src.getMinX(),
@@ -450,76 +524,84 @@ public class AffineTransformOp implements BufferedImageOp, RasterOp
Arrays.fill(result, 0);
for (int m = - 1; m < 3; m++)
- {
- for (int n = - 1; n < 3; n++)
- {
- // R(x) = ( P(x+2)^3 - 4 P(x+1)^3 + 6 P(x)^3 - 4 P(x-1)^3 ) / 6
- double r1 = 0;
- double r2 = 0;
-
- // Calculate R(m - dx)
- double rx = m - dx + 2;
- if (rx > 0)
- r1 += rx * rx * rx;
-
- rx = m - dx + 1;
- if (rx > 0)
- r1 -= 4 * rx * rx * rx;
-
- rx = m - dx;
- if (rx > 0)
- r1 += 6 * rx * rx * rx;
-
- rx = m - dx - 1;
- if (rx > 0)
- r1 -= 4 * rx * rx * rx;
-
- r1 /= 6;
-
- // Calculate R(dy - n);
- rx = dy - n + 2;
- if (rx > 0)
- r2 += rx * rx * rx;
-
- rx = dy - n + 1;
- if (rx > 0)
- r2 -= 4 * rx * rx * rx;
-
- rx = dy - n;
- if (rx > 0)
- r2 += 6 * rx * rx * rx;
-
- rx = dy - n - 1;
- if (rx > 0)
- r2 -= 4 * rx * rx * rx;
-
- r2 /= 6;
-
- // Calculate F(i+m, j+n) R(m - dx) R(dy - n)
- // Check corner cases
- int srcX = x + m;
- if (srcX >= src.getMinX() + src.getWidth())
- srcX = src.getMinX() + src.getWidth() - 1;
- else if (srcX < src.getMinX())
- srcX = src.getMinX();
-
- int srcY = y + n;
- if (srcY >= src.getMinY() + src.getHeight())
- srcY = src.getMinY() + src.getHeight() - 1;
- else if (srcY < src.getMinY())
- srcY = src.getMinY();
-
- // Calculate once for each band
- for (int j = 0; j < result.length; j++)
- result[j] += src.getSample(srcX, srcY, j) * r1 * r2;
- }
- }
+ for (int n = - 1; n < 3; n++)
+ {
+ // R(x) = ( P(x+2)^3 - 4 P(x+1)^3 + 6 P(x)^3 - 4 P(x-1)^3 ) / 6
+ double r1 = 0;
+ double r2 = 0;
+
+ // Calculate R(m - dx)
+ double rx = m - dx + 2;
+ r1 += rx * rx * rx;
+
+ rx = m - dx + 1;
+ if (rx > 0)
+ r1 -= 4 * rx * rx * rx;
+
+ rx = m - dx;
+ if (rx > 0)
+ r1 += 6 * rx * rx * rx;
+
+ rx = m - dx - 1;
+ if (rx > 0)
+ r1 -= 4 * rx * rx * rx;
+
+ r1 /= 6;
+
+ // Calculate R(dy - n);
+ rx = dy - n + 2;
+ if (rx > 0)
+ r2 += rx * rx * rx;
+
+ rx = dy - n + 1;
+ if (rx > 0)
+ r2 -= 4 * rx * rx * rx;
+
+ rx = dy - n;
+ if (rx > 0)
+ r2 += 6 * rx * rx * rx;
+
+ rx = dy - n - 1;
+ if (rx > 0)
+ r2 -= 4 * rx * rx * rx;
+
+ r2 /= 6;
+
+ // Calculate F(i+m, j+n) R(m - dx) R(dy - n)
+ // Check corner cases
+ int srcX = x + m;
+ if (srcX >= src.getMinX() + src.getWidth())
+ srcX = src.getMinX() + src.getWidth() - 1;
+ else if (srcX < src.getMinX())
+ srcX = src.getMinX();
+
+ int srcY = y + n;
+ if (srcY >= src.getMinY() + src.getHeight())
+ srcY = src.getMinY() + src.getHeight() - 1;
+ else if (srcY < src.getMinY())
+ srcY = src.getMinY();
+
+ // Calculate once for each band, using the smallest
+ // datatype possible
+ if (src.getTransferType() == DataBuffer.TYPE_DOUBLE
+ || src.getTransferType() == DataBuffer.TYPE_FLOAT)
+ {
+ pixels = src.getPixel(srcX, srcY, (double[])pixels);
+ for (int j = 0; j < result.length; j++)
+ result[j] += ((double[])pixels)[j] * r1 * r2;
+ }
+ else
+ {
+ pixels = src.getPixel(srcX, srcY, (int[])pixels);
+ for (int j = 0; j < result.length; j++)
+ result[j] += ((int[])pixels)[j] * r1 * r2;
+ }
+ }
// Put it all together
- for (int j = 0; j < result.length; j++)
- dst.setSample((int) dpts[i] + dst.getMinX(),
- (int) dpts[i + 1] + dst.getMinY(),
- j, result[j]);
+ dst.setPixel((int)dpts[i] + dst.getMinX(),
+ (int)dpts[i+1] + dst.getMinY(),
+ result);
}
}
}
diff --git a/java/awt/image/BandCombineOp.java b/java/awt/image/BandCombineOp.java
index c4e2d5810..d9ce16fad 100644
--- a/java/awt/image/BandCombineOp.java
+++ b/java/awt/image/BandCombineOp.java
@@ -40,6 +40,7 @@ package java.awt.image;
import java.awt.RenderingHints;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.util.Arrays;
/**
* Filter Raster pixels by applying a matrix.
@@ -53,6 +54,9 @@ import java.awt.geom.Rectangle2D;
* for the destination. Therefore the destination Raster must contain the
* same number of bands as the number of rows in the filter matrix.
*
+ * This Op assumes that samples are integers; floating point sample types will
+ * be rounded to their nearest integer value during filtering.
+ *
* @author Jerry Quinn (jlquinn@optonline.net)
*/
public class BandCombineOp implements RasterOp
@@ -109,19 +113,27 @@ public class BandCombineOp implements RasterOp
throw new IllegalArgumentException("Destination raster is incompatible with source raster");
// Filter the pixels
- float[] spix = new float[matrix[0].length - 1];
- float[] dpix = new float[matrix.length];
+ int[] spix = new int[matrix[0].length - 1];
+ int[] spix2 = new int[matrix[0].length - 1];
+ int[] dpix = new int[matrix.length];
for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
{
// In case matrix rows have implicit translation
- spix[spix.length - 1] = 1.0f;
+ spix[spix.length - 1] = 1;
src.getPixel(x, y, spix);
- for (int i = 0; i < matrix.length; i++)
+
+ // Do not re-calculate if pixel is identical to the last one
+ // (ie, blocks of the same colour)
+ if (!Arrays.equals(spix, spix2))
{
- dpix[i] = 0;
- for (int j = 0; j < matrix[0].length - 1; j++)
- dpix[i] += spix[j] * matrix[i][j];
+ System.arraycopy(spix, 0, spix2, 0, spix.length);
+ for (int i = 0; i < matrix.length; i++)
+ {
+ dpix[i] = 0;
+ for (int j = 0; j < matrix[0].length - 1; j++)
+ dpix[i] += spix[j] * (int)matrix[i][j];
+ }
}
dest.setPixel(x, y, dpix);
}
diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java
index 1e94ad66d..0a78bf223 100644
--- a/java/awt/image/BufferedImage.java
+++ b/java/awt/image/BufferedImage.java
@@ -347,6 +347,7 @@ public class BufferedImage extends Image
public void coerceData(boolean premultiplied)
{
colorModel = colorModel.coerceData(raster, premultiplied);
+ isPremultiplied = premultiplied;
}
public WritableRaster copyData(WritableRaster dest)
diff --git a/java/awt/image/ColorModel.java b/java/awt/image/ColorModel.java
index fc413d0b4..ea3d1b64c 100644
--- a/java/awt/image/ColorModel.java
+++ b/java/awt/image/ColorModel.java
@@ -624,40 +624,36 @@ public abstract class ColorModel implements Transparency
return cspace;
}
- // Typically overridden
- public ColorModel coerceData(WritableRaster raster,
- boolean isAlphaPremultiplied)
- {
- if (this.isAlphaPremultiplied == isAlphaPremultiplied || ! hasAlpha)
- return this;
+ public abstract ColorModel coerceData(WritableRaster raster,
+ boolean isAlphaPremultiplied);
+ protected void coerceDataWorker(WritableRaster raster,
+ boolean isAlphaPremultiplied)
+ {
int w = raster.getWidth();
int h = raster.getHeight();
int x = raster.getMinX();
int y = raster.getMinY();
- int size = w*h;
+ int size = w * h;
int numColors = getNumColorComponents();
int numComponents = getNumComponents();
- int alphaScale = (1<<getComponentSize(numColors)) - 1;
+ int alphaScale = (1 << getComponentSize(numColors)) - 1;
double[] pixels = raster.getPixels(x, y, w, h, (double[]) null);
- for (int i=0; i<size; i++)
+ for (int i = 0; i < size; i++)
{
- double alpha = pixels[i*numComponents+numColors]*alphaScale;
- for (int c=0; c<numColors; c++)
- {
- int offset = i*numComponents+c;
- if (isAlphaPremultiplied)
- pixels[offset] = pixels[offset]/alpha;
- else
- pixels[offset] = pixels[offset]*alpha;
- }
+ double alpha = pixels[i * numComponents + numColors] / alphaScale;
+ for (int c = 0; c < numColors; c++)
+ {
+ int offset = i * numComponents + c;
+ if (isAlphaPremultiplied)
+ pixels[offset] = Math.round(pixels[offset] * alpha);
+ else
+ pixels[offset] = Math.round(pixels[offset] / alpha);
+ }
}
-
- raster.setPixels(0, 0, w, h, pixels);
- // FIXME: what can we return?
- return null;
+ raster.setPixels(0, 0, w, h, pixels);
}
/**
diff --git a/java/awt/image/ComponentColorModel.java b/java/awt/image/ComponentColorModel.java
index f3f3e374b..2096800b2 100644
--- a/java/awt/image/ComponentColorModel.java
+++ b/java/awt/image/ComponentColorModel.java
@@ -306,17 +306,16 @@ public class ComponentColorModel extends ColorModel
public ColorModel coerceData(WritableRaster raster,
boolean isAlphaPremultiplied) {
- if (this.isAlphaPremultiplied == isAlphaPremultiplied)
+ if (this.isAlphaPremultiplied == isAlphaPremultiplied || !hasAlpha())
return this;
/* TODO: provide better implementation based on the
assumptions we can make due to the specific type of the
color model. */
- super.coerceData(raster, isAlphaPremultiplied);
+ super.coerceDataWorker(raster, isAlphaPremultiplied);
- return new ComponentColorModel(cspace, bits, hasAlpha(),
- isAlphaPremultiplied, // argument
- transparency, transferType);
+ return new ComponentColorModel(cspace, hasAlpha, isAlphaPremultiplied,
+ transparency, transferType);
}
public boolean isCompatibleRaster(Raster raster)
diff --git a/java/awt/image/ConvolveOp.java b/java/awt/image/ConvolveOp.java
index cd3b01131..cf30e7625 100644
--- a/java/awt/image/ConvolveOp.java
+++ b/java/awt/image/ConvolveOp.java
@@ -249,6 +249,11 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
int top = kernel.getYOrigin();
int bottom = Math.max(kHeight - top - 1, 0);
+ // Calculate max sample values for clipping
+ int[] maxValue = src.getSampleModel().getSampleSize();
+ for (int i = 0; i < maxValue.length; i++)
+ maxValue[i] = (int)Math.pow(2, maxValue[i]) - 1;
+
// process the region that is reachable...
int regionW = src.width - left - right;
int regionH = src.height - top - bottom;
@@ -270,12 +275,10 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
// the samples array to make the tests pass. I haven't worked
// out why this is necessary.
- // This clipping is pretty strange, and seems to be hard-coded
- // at 255 (regardless of the raster's datatype or transfertype).
- // But it's what the reference does.
- if (v > 255)
- v = 255;
- if (v < 0)
+ // This clipping is is undocumented, but determined by testing.
+ if (v > maxValue[b])
+ v = maxValue[b];
+ else if (v < 0)
v = 0;
dest.setSample(x + kernel.getXOrigin(), y + kernel.getYOrigin(),
diff --git a/java/awt/image/DirectColorModel.java b/java/awt/image/DirectColorModel.java
index 579dc97df..dab15319f 100644
--- a/java/awt/image/DirectColorModel.java
+++ b/java/awt/image/DirectColorModel.java
@@ -393,20 +393,20 @@ public class DirectColorModel extends PackedColorModel
return Buffers.getData(buffer);
}
- public final ColorModel coerceData (WritableRaster raster,
- boolean isAlphaPremultiplied)
+ public ColorModel coerceData (WritableRaster raster,
+ boolean isAlphaPremultiplied)
{
- if (this.isAlphaPremultiplied == isAlphaPremultiplied)
+ if (this.isAlphaPremultiplied == isAlphaPremultiplied || !hasAlpha())
return this;
/* TODO: provide better implementation based on the
assumptions we can make due to the specific type of the
color model. */
- super.coerceData(raster, isAlphaPremultiplied);
-
- return new ComponentColorModel(cspace, bits, hasAlpha(),
- isAlphaPremultiplied, // argument
- transparency, transferType);
+ super.coerceDataWorker(raster, isAlphaPremultiplied);
+
+ return new DirectColorModel(cspace, pixel_bits, getRedMask(),
+ getGreenMask(), getBlueMask(), getAlphaMask(),
+ isAlphaPremultiplied, transferType);
}
public boolean isCompatibleRaster(Raster raster)
diff --git a/java/awt/image/IndexColorModel.java b/java/awt/image/IndexColorModel.java
index 299b4dc0d..701362d53 100644
--- a/java/awt/image/IndexColorModel.java
+++ b/java/awt/image/IndexColorModel.java
@@ -694,4 +694,21 @@ public class IndexColorModel extends ColorModel
return im;
}
+
+ public ColorModel coerceData (WritableRaster raster,
+ boolean isAlphaPremultiplied)
+ {
+ if (this.isAlphaPremultiplied == isAlphaPremultiplied || !hasAlpha())
+ return this;
+
+ /* TODO: provide better implementation based on the
+ assumptions we can make due to the specific type of the
+ color model. */
+ super.coerceDataWorker(raster, isAlphaPremultiplied);
+
+ ColorModel cm = new IndexColorModel(pixel_bits, map_size, rgb, 0, hasAlpha, trans,
+ transferType);
+ cm.isAlphaPremultiplied = !(cm.isAlphaPremultiplied);
+ return cm;
+ }
}
diff --git a/java/awt/image/LookupOp.java b/java/awt/image/LookupOp.java
index 46e72fe61..5b0cf7831 100644
--- a/java/awt/image/LookupOp.java
+++ b/java/awt/image/LookupOp.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.awt.image;
-import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
@@ -67,7 +66,8 @@ public class LookupOp implements BufferedImageOp, RasterOp
private LookupTable lut;
private RenderingHints hints;
- /** Construct a new LookupOp.
+ /**
+ * Construct a new LookupOp using the given LookupTable.
*
* @param lookup LookupTable to use.
* @param hints Rendering hints (can be null).
@@ -78,16 +78,40 @@ public class LookupOp implements BufferedImageOp, RasterOp
this.hints = hints;
}
- /* (non-Javadoc)
- * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
+ /**
+ * Converts the source image using the lookup table specified in the
+ * constructor. The resulting image is stored in the destination image if one
+ * is provided; otherwise a new BufferedImage is created and returned.
+ *
+ * The source image cannot use an IndexColorModel, and the destination image
+ * (if one is provided) must have the same size.
+ *
+ * @param src The source image.
+ * @param dst The destination image.
+ * @throws IllegalArgumentException if the rasters and/or color spaces are
+ * incompatible.
+ * @throws ArrayIndexOutOfBoundsException if a pixel in the source is not
+ * contained in the LookupTable.
+ * @return The convolved image.
*/
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
{
if (src.getColorModel() instanceof IndexColorModel)
throw new IllegalArgumentException("LookupOp.filter: IndexColorModel "
+ "not allowed");
+
+ if (lut.getNumComponents() != 1
+ && lut.getNumComponents() != src.getColorModel().getNumComponents()
+ && lut.getNumComponents() != src.getColorModel().getNumColorComponents())
+ throw new IllegalArgumentException("LookupOp.filter: Incompatible " +
+ "lookup table and source image");
+
if (dst == null)
- dst = createCompatibleDestImage(src, src.getColorModel());
+ dst = createCompatibleDestImage(src, null);
+
+ else if (src.getHeight() != dst.getHeight() || src.getWidth() != dst.getWidth())
+ throw new IllegalArgumentException("Source and destination images are " +
+ "different sizes.");
// Set up for potential colormodel mismatch
BufferedImage tgt;
@@ -116,33 +140,35 @@ public class LookupOp implements BufferedImageOp, RasterOp
sr.getPixel(x, y, dbuf);
System.arraycopy(dbuf, 0, tmp, 0, tmpBands);
dr.setPixel(x, y, lut.lookupPixel(tmp, dbuf));
+
+ /* The reference implementation does not use LookupTable.lookupPixel,
+ * but rather it seems to copy the table into a native array. The
+ * effect of this (a probable bug in their implementation) is that
+ * an out-of-bounds lookup on a ByteLookupTable will *not* throw an
+ * out of bounds exception, but will instead return random garbage.
+ * A bad lookup on a ShortLookupTable, however, will throw an
+ * exception.
+ *
+ * Instead of mimicing this behaviour, we always throw an
+ * ArrayOutofBoundsException by virtue of using
+ * LookupTable.lookupPixle.
+ */
}
}
- else if (lut.getNumComponents() != 1
- &&
- lut.getNumComponents() != src.getColorModel().getNumComponents())
- throw new IllegalArgumentException("LookupOp.filter: "
- + "Incompatible lookup "
- + "table and source image");
-
- // No alpha to ignore
- int[] dbuf = new int[src.getColorModel().getNumComponents()];
-
- // Filter the pixels
- for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
- for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
- dr.setPixel(x, y, lut.lookupPixel(sr.getPixel(x, y, dbuf), dbuf));
-
- if (tgt != dst)
+ else
{
- // Convert between color models.
- // TODO Check that premultiplied alpha is handled correctly here.
- Graphics2D gg = dst.createGraphics();
- gg.setRenderingHints(hints);
- gg.drawImage(tgt, 0, 0, null);
- gg.dispose();
+ // No alpha to ignore
+ int[] dbuf = new int[src.getColorModel().getNumComponents()];
+
+ // Filter the pixels
+ for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
+ for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
+ dr.setPixel(x, y, lut.lookupPixel(sr.getPixel(x, y, dbuf), dbuf));
}
+ if (tgt != dst)
+ new ColorConvertOp(hints).filter(tgt, dst);
+
return dst;
}
@@ -160,18 +186,27 @@ public class LookupOp implements BufferedImageOp, RasterOp
public BufferedImage createCompatibleDestImage(BufferedImage src,
ColorModel dstCM)
{
- // FIXME: set properties to those in src
- return new BufferedImage(dstCM,
- src.getRaster().createCompatibleWritableRaster(),
- src.isPremultiplied, null);
+ if (dstCM != null)
+ return new BufferedImage(dstCM,
+ src.getRaster().createCompatibleWritableRaster(),
+ src.isAlphaPremultiplied(), null);
+
+ // This is a strange exception, done for compatibility with the reference
+ // (as demonstrated by a mauve testcase)
+ int imgType = src.getType();
+ if (imgType == BufferedImage.TYPE_USHORT_GRAY)
+ imgType = BufferedImage.TYPE_BYTE_GRAY;
+
+ return new BufferedImage(src.getWidth(), src.getHeight(), imgType);
}
- /** Return corresponding destination point for source point.
+ /**
+ * Returns the corresponding destination point for a given source point.
+ *
+ * This Op will return the source point unchanged.
*
- * LookupOp will return the value of src unchanged.
* @param src The source point.
* @param dst The destination point.
- * @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D)
*/
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
@@ -182,7 +217,11 @@ public class LookupOp implements BufferedImageOp, RasterOp
return dst;
}
- /** Return the LookupTable for this op. */
+ /**
+ * Return the LookupTable for this op.
+ *
+ * @return The lookup table.
+ */
public final LookupTable getTable()
{
return lut;
@@ -196,7 +235,8 @@ public class LookupOp implements BufferedImageOp, RasterOp
return hints;
}
- /** Filter a raster through a lookup table.
+ /**
+ * Filter a raster through a lookup table.
*
* Applies the lookup table for this Rasterop to each pixel of src and
* puts the results in dest. If dest is null, a new Raster is created and
@@ -206,8 +246,9 @@ public class LookupOp implements BufferedImageOp, RasterOp
* @param dest The destination raster.
* @return The WritableRaster with the filtered pixels.
* @throws IllegalArgumentException if lookup table has more than one
- * component but not the same as src and dest.
- * @see java.awt.image.RasterOp#filter(java.awt.image.Raster, java.awt.image.WritableRaster)
+ * component but not the same as src and dest.
+ * @throws ArrayIndexOutOfBoundsException if a pixel in the source is not
+ * contained in the LookupTable.
*/
public final WritableRaster filter(Raster src, WritableRaster dest)
{
@@ -216,12 +257,13 @@ public class LookupOp implements BufferedImageOp, RasterOp
dest = createCompatibleDestRaster(src);
else
if (src.getNumBands() != dest.getNumBands())
- throw new IllegalArgumentException();
-
- if (lut.getNumComponents() != 1
- && lut.getNumComponents() != src.getNumBands())
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Source and destination rasters " +
+ "are incompatible.");
+ if (lut.getNumComponents() != 1
+ && lut.getNumComponents() != src.getNumBands())
+ throw new IllegalArgumentException("Lookup table is incompatible with " +
+ "this raster.");
// Allocate pixel storage.
int[] tmp = new int[src.getNumBands()];
@@ -230,6 +272,19 @@ public class LookupOp implements BufferedImageOp, RasterOp
for (int y = src.getMinY(); y < src.getHeight() + src.getMinY(); y++)
for (int x = src.getMinX(); x < src.getWidth() + src.getMinX(); x++)
dest.setPixel(x, y, lut.lookupPixel(src.getPixel(x, y, tmp), tmp));
+
+ /* The reference implementation does not use LookupTable.lookupPixel,
+ * but rather it seems to copy the table into a native array. The
+ * effect of this (a probable bug in their implementation) is that
+ * an out-of-bounds lookup on a ByteLookupTable will *not* throw an
+ * out of bounds exception, but will instead return random garbage.
+ * A bad lookup on a ShortLookupTable, however, will throw an
+ * exception.
+ *
+ * Instead of mimicing this behaviour, we always throw an
+ * ArrayOutofBoundsException by virtue of using
+ * LookupTable.lookupPixle.
+ */
return dest;
}
diff --git a/java/awt/image/MemoryImageSource.java b/java/awt/image/MemoryImageSource.java
index cb3526f6e..83a03ca44 100644
--- a/java/awt/image/MemoryImageSource.java
+++ b/java/awt/image/MemoryImageSource.java
@@ -1,5 +1,5 @@
/* MemoryImageSource.java -- Java class for providing image data
- Copyright (C) 1999, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,9 @@ package java.awt.image;
import java.util.Hashtable;
import java.util.Vector;
+/**
+ * An image producer that delivers image data from an array.
+ */
public class MemoryImageSource implements ImageProducer
{
private boolean animated = false;
@@ -73,7 +76,16 @@ public class MemoryImageSource implements ImageProducer
}
/**
- * Constructs an ImageProducer from memory
+ * Constructs an ImageProducer from memory.
+ *
+ * @param w the image width.
+ * @param h the image height.
+ * @param cm the color model.
+ * @param pix the image data.
+ * @param off the offset to the first pixel in the array.
+ * @param scan the number of array elements from a pixel on one row to the
+ * corresponding pixel on the next row.
+ * @param props image properties (<code>null</code> permitted).
*/
public MemoryImageSource(int w, int h, ColorModel cm, byte[] pix, int off,
int scan, Hashtable<?,?> props)
@@ -106,8 +118,17 @@ public class MemoryImageSource implements ImageProducer
}
/**
- Constructs an ImageProducer from memory
- */
+ * Constructs an ImageProducer from memory
+ *
+ * @param w the image width.
+ * @param h the image height.
+ * @param cm the color model.
+ * @param pix the image data.
+ * @param off the offset to the first pixel in the array.
+ * @param scan the number of array elements from a pixel on one row to the
+ * corresponding pixel on the next row.
+ * @param props image properties (<code>null</code> permitted).
+ */
public MemoryImageSource(int w, int h, ColorModel cm, int[] pix, int off,
int scan, Hashtable<?,?> props)
{
@@ -122,7 +143,16 @@ public class MemoryImageSource implements ImageProducer
}
/**
- * Constructs an ImageProducer from memory using the default RGB ColorModel
+ * Constructs an ImageProducer from memory using the default RGB ColorModel.
+ *
+ * @param w the image width.
+ * @param h the image height.
+ * @param pix the image data.
+ * @param off the offset to the first pixel in the array.
+ * @param scan the number of array elements from a pixel on one row to the
+ * corresponding pixel on the next row.
+ * @param props image properties (<code>null</code> permitted).
+
*/
public MemoryImageSource(int w, int h, int[] pix, int off, int scan,
Hashtable<?,?> props)
@@ -131,7 +161,14 @@ public class MemoryImageSource implements ImageProducer
}
/**
- * Constructs an ImageProducer from memory using the default RGB ColorModel
+ * Constructs an ImageProducer from memory using the default RGB ColorModel.
+ *
+ * @param w the image width.
+ * @param h the image height.
+ * @param pix the image data.
+ * @param off the offset to the first pixel in the array.
+ * @param scan the number of array elements from a pixel on one row to the
+ * corresponding pixel on the next row.
*/
public MemoryImageSource(int w, int h, int[] pix, int off, int scan)
{
@@ -141,6 +178,8 @@ public class MemoryImageSource implements ImageProducer
/**
* Used to register an <code>ImageConsumer</code> with this
* <code>ImageProducer</code>.
+ *
+ * @param ic the image consumer.
*/
public synchronized void addConsumer(ImageConsumer ic)
{
@@ -153,6 +192,8 @@ public class MemoryImageSource implements ImageProducer
/**
* Used to determine if the given <code>ImageConsumer</code> is
* already registered with this <code>ImageProducer</code>.
+ *
+ * @param ic the image consumer.
*/
public synchronized boolean isConsumer(ImageConsumer ic)
{
@@ -164,6 +205,8 @@ public class MemoryImageSource implements ImageProducer
/**
* Used to remove an <code>ImageConsumer</code> from the list of
* registered consumers for this <code>ImageProducer</code>.
+ *
+ * @param ic the image consumer.
*/
public synchronized void removeConsumer(ImageConsumer ic)
{
@@ -197,6 +240,8 @@ public class MemoryImageSource implements ImageProducer
* Used to register an <code>ImageConsumer</code> with this
* <code>ImageProducer</code> and then request that this producer
* resend the image data in the order top-down, left-right.
+ *
+ * @param ic the image consumer.
*/
public void requestTopDownLeftRightResend(ImageConsumer ic)
{
@@ -219,7 +264,7 @@ public class MemoryImageSource implements ImageProducer
* sending animation. If this flag is set then full buffers are sent
* in the newPixels methods instead of just regions.
*
- * @param fullbuffers - a flag indicating whether to send the full buffers
+ * @param fullbuffers a flag indicating whether to send the full buffers
*/
public synchronized void setFullBufferUpdates(boolean fullbuffers)
{
@@ -260,6 +305,11 @@ public class MemoryImageSource implements ImageProducer
/**
* Send an animation frame to the image consumers containing the specified
* pixels unless setFullBufferUpdates is set.
+ *
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
*/
public synchronized void newPixels(int x, int y, int w, int h)
{
@@ -306,6 +356,12 @@ public class MemoryImageSource implements ImageProducer
*
* If framenotify is set then a notification is sent when the frame
* is sent otherwise no status is sent.
+ *
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
+ * @param framenotify send notification?
*/
public synchronized void newPixels(int x, int y, int w, int h,
boolean framenotify)
diff --git a/java/awt/image/RescaleOp.java b/java/awt/image/RescaleOp.java
index d5b29693c..d56b12cb9 100644
--- a/java/awt/image/RescaleOp.java
+++ b/java/awt/image/RescaleOp.java
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Free Software Foundation
+/* Copyright (C) 2004, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -43,7 +43,23 @@ import java.awt.geom.Rectangle2D;
import java.util.Arrays;
/**
+ * RescaleOp is a filter that changes each pixel by a scaling factor and offset.
+ *
+ * For filtering Rasters, either one scaling factor and offset can be specified,
+ * which will be applied to all bands; or a scaling factor and offset can be
+ * specified for each band.
+ *
+ * For BufferedImages, the scaling may apply to both color and alpha components.
+ * If only one scaling factor is provided, or if the number of factors provided
+ * equals the number of color components, the scaling is performed on all color
+ * components. Otherwise, the scaling is performed on all components including
+ * alpha. Alpha premultiplication is ignored.
+ *
+ * After filtering, if color conversion is necessary, the conversion happens,
+ * taking alpha premultiplication into account.
+ *
* @author Jerry Quinn (jlquinn@optonline.net)
+ * @author Francis Kung (fkung@redhat.com)
*/
public class RescaleOp implements BufferedImageOp, RasterOp
{
@@ -51,15 +67,43 @@ public class RescaleOp implements BufferedImageOp, RasterOp
private float[] offsets;
private RenderingHints hints = null;
+ /**
+ * Create a new RescaleOp object using the given scale factors and offsets.
+ *
+ * The length of the arrays must be equal to the number of bands (or number of
+ * data or color components) of the raster/image that this Op will be used on,
+ * otherwise an IllegalArgumentException will be thrown when calling the
+ * filter method.
+ *
+ * @param scaleFactors an array of scale factors.
+ * @param offsets an array of offsets.
+ * @param hints any rendering hints to use (can be null).
+ * @throws NullPointerException if the scaleFactors or offsets array is null.
+ */
public RescaleOp(float[] scaleFactors,
float[] offsets,
RenderingHints hints)
{
- this.scale = scaleFactors;
- this.offsets = offsets;
+ int length = Math.min(scaleFactors.length, offsets.length);
+
+ scale = new float[length];
+ System.arraycopy(scaleFactors, 0, this.scale, 0, length);
+
+ this.offsets = new float[length];
+ System.arraycopy(offsets, 0, this.offsets, 0, length);
+
this.hints = hints;
}
+ /**
+ * Create a new RescaleOp object using the given scale factor and offset.
+ *
+ * The same scale factor and offset will be used on all bands/components.
+ *
+ * @param scaleFactor the scale factor to use.
+ * @param offset the offset to use.
+ * @param hints any rendering hints to use (can be null).
+ */
public RescaleOp(float scaleFactor,
float offset,
RenderingHints hints)
@@ -69,22 +113,47 @@ public class RescaleOp implements BufferedImageOp, RasterOp
this.hints = hints;
}
+ /**
+ * Returns the scaling factors. This method accepts an optional array, which
+ * will be used to store the factors if not null (this avoids allocating a
+ * new array). If this array is too small to hold all the scaling factors,
+ * the array will be filled and the remaining factors discarded.
+ *
+ * @param scaleFactors array to store the scaling factors in (can be null).
+ * @return an array of scaling factors.
+ */
public final float[] getScaleFactors(float[] scaleFactors)
{
if (scaleFactors == null)
scaleFactors = new float[scale.length];
- System.arraycopy(scale, 0, scaleFactors, 0, scale.length);
+ System.arraycopy(scale, 0, scaleFactors, 0, Math.min(scale.length,
+ scaleFactors.length));
return scaleFactors;
}
+ /**
+ * Returns the offsets. This method accepts an optional array, which
+ * will be used to store the offsets if not null (this avoids allocating a
+ * new array). If this array is too small to hold all the offsets, the array
+ * will be filled and the remaining factors discarded.
+ *
+ * @param offsets array to store the offsets in (can be null).
+ * @return an array of offsets.
+ */
public final float[] getOffsets(float[] offsets)
{
if (offsets == null)
offsets = new float[this.offsets.length];
- System.arraycopy(this.offsets, 0, offsets, 0, this.offsets.length);
+ System.arraycopy(this.offsets, 0, offsets, 0, Math.min(this.offsets.length,
+ offsets.length));
return offsets;
}
+ /**
+ * Returns the number of scaling factors / offsets.
+ *
+ * @return the number of scaling factors / offsets.
+ */
public final int getNumFactors()
{
return scale.length;
@@ -98,36 +167,74 @@ public class RescaleOp implements BufferedImageOp, RasterOp
return hints;
}
- /* (non-Javadoc)
- * @see java.awt.image.BufferedImageOp#filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)
+ /**
+ * Converts the source image using the scale factors and offsets specified in
+ * the constructor. The resulting image is stored in the destination image if
+ * one is provided; otherwise a new BufferedImage is created and returned.
+ *
+ * The source image cannot use an IndexColorModel, and the destination image
+ * (if one is provided) must have the same size.
+ *
+ * If the final value of a sample is beyond the range of the color model, it
+ * will be clipped to the appropriate maximum / minimum.
+ *
+ * @param src The source image.
+ * @param dst The destination image.
+ * @throws IllegalArgumentException if the rasters and/or color spaces are
+ * incompatible.
+ * @return The rescaled image.
*/
public final BufferedImage filter(BufferedImage src, BufferedImage dst)
{
- // TODO Make sure premultiplied alpha is handled correctly.
- // TODO See that color conversion is handled.
- // TODO figure out how to use rendering hints.
- if (scale.length != offsets.length)
- throw new IllegalArgumentException();
+ // Initial checks
+ if (scale.length != 1
+ && scale.length != src.getColorModel().getNumComponents()
+ && (scale.length != src.getColorModel().getNumColorComponents()))
+ throw new IllegalArgumentException("Source image has wrong number of "
+ + "bands for these scaling factors.");
- ColorModel scm = src.getColorModel();
- if (dst == null) dst = createCompatibleDestImage(src, null);
+ if (dst == null)
+ dst = createCompatibleDestImage(src, null);
+ else if (src.getHeight() != dst.getHeight()
+ || src.getWidth() != dst.getWidth())
+ throw new IllegalArgumentException("Source and destination images are "
+ + "different sizes.");
- WritableRaster wsrc = src.getRaster();
- WritableRaster wdst = dst.getRaster();
-
- // Share constant across colors except alpha
- if (scale.length == 1 || scale.length == scm.getNumColorComponents())
+ // Prepare for possible colorspace conversion
+ BufferedImage dst2 = dst;
+ if (dst.getColorModel().getColorSpace().getType() != src.getColorModel().getColorSpace().getType())
+ dst2 = createCompatibleDestImage(src, src.getColorModel());
+
+ // Figure out how many bands to scale
+ int numBands = scale.length;
+ if (scale.length == 1)
+ numBands = src.getColorModel().getNumColorComponents();
+ boolean[] bands = new boolean[numBands];
+ // this assumes the alpha, if present, is the last band
+ Arrays.fill(bands, true);
+
+ // Perform rescaling
+ filter(src.getRaster(), dst2.getRaster(), bands);
+
+ // Copy alpha band if needed (ie if it exists and wasn't scaled)
+ // NOTE: This assumes the alpha component is the last band!
+ if (src.getColorModel().hasAlpha()
+ && numBands == src.getColorModel().getNumColorComponents())
{
- // Construct a raster that doesn't include an alpha band.
- int[] subbands = new int[scm.getNumColorComponents()];
- for (int i=0; i < subbands.length; i++) subbands[i] = i;
- wsrc =
- wsrc.createWritableChild(wsrc.minX, wsrc.minY, wsrc.width, wsrc.height,
- wsrc.minX, wsrc.minY, subbands);
+
+ dst2.getRaster().setSamples(0, 0, src.getWidth(), src.getHeight(),
+ numBands,
+ src.getRaster().getSamples(0, 0,
+ src.getWidth(),
+ src.getHeight(),
+ numBands,
+ (int[]) null));
}
- // else all color bands
- filter(wsrc, wdst);
+ // Perform colorspace conversion if needed
+ if (dst != dst2)
+ new ColorConvertOp(hints).filter(dst2, dst);
+
return dst;
}
@@ -136,50 +243,106 @@ public class RescaleOp implements BufferedImageOp, RasterOp
*/
public final WritableRaster filter(Raster src, WritableRaster dest)
{
- if (dest == null) dest = src.createCompatibleWritableRaster();
-
// Required sanity checks
- if (src.numBands != dest.numBands || scale.length != offsets.length)
- throw new IllegalArgumentException();
if (scale.length != 1 && scale.length != src.numBands)
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Number of rasters is incompatible "
+ + "with the number of scaling "
+ + "factors provided.");
- // Create scaling arrays if needed
- float[] lscale = scale;
- float[] loff = offsets;
- if (scale.length == 1)
- {
- lscale = new float[src.numBands];
- Arrays.fill(lscale, scale[0]);
- loff = new float[src.numBands];
- Arrays.fill(loff, offsets[0]);
- }
+ if (dest == null)
+ dest = src.createCompatibleWritableRaster();
+ else if (src.getHeight() != dest.getHeight()
+ || src.getWidth() != dest.getWidth())
+ throw new IllegalArgumentException("Source and destination rasters are "
+ + "different sizes.");
+ else if (src.numBands != dest.numBands)
+ throw new IllegalArgumentException("Source and destination rasters "
+ + "are incompatible.");
+
+ // Filter all bands
+ boolean[] bands = new boolean[src.getNumBands()];
+ Arrays.fill(bands, true);
+ return filter(src, dest, bands);
+ }
+
+ /**
+ * Perform raster-based filtering on a selected number of bands.
+ *
+ * The length of the bands array should equal the number of bands; a true
+ * element indicates filtering should happen on the corresponding band, while
+ * a false element will skip the band.
+ *
+ * The rasters are assumed to be compatible and non-null.
+ *
+ * @param src the source raster.
+ * @param dest the destination raster.
+ * @param bands an array indicating which bands to filter.
+ * @throws NullPointerException if any parameter is null.
+ * @throws ArrayIndexOutOfBoundsException if the bands array is too small.
+ * @return the destination raster.
+ */
+ private WritableRaster filter(Raster src, WritableRaster dest, boolean[] bands)
+ {
+ int[] values = new int[src.getHeight() * src.getWidth()];
+ float scaleFactor, offset;
+
+ // Find max sample value, to be used for clipping later
+ int[] maxValue = src.getSampleModel().getSampleSize();
+ for (int i = 0; i < maxValue.length; i++)
+ maxValue[i] = (int)Math.pow(2, maxValue[i]) - 1;
+
+ // TODO: can this be optimized further?
+ // Filter all samples of all requested bands
+ for (int band = 0; band < bands.length; band++)
+ if (bands[band])
+ {
+ values = src.getSamples(src.getMinX(), src.getMinY(), src.getWidth(),
+ src.getHeight(), band, values);
- // TODO The efficiency here can be improved for various data storage
- // patterns, aka SampleModels.
- float[] pixel = new float[src.numBands];
- for (int y = src.minY; y < src.height + src.minY; y++)
- for (int x = src.minX; x < src.width + src.minX; x++)
- {
- src.getPixel(x, y, pixel);
- for (int b = 0; b < src.numBands; b++)
- pixel[b] = pixel[b] * lscale[b] + loff[b];
- dest.setPixel(x, y, pixel);
- }
+ if (scale.length == 1)
+ {
+ scaleFactor = scale[0];
+ offset = offsets[0];
+ }
+ else
+ {
+ scaleFactor = scale[band];
+ offset = offsets[band];
+ }
+
+ for (int i = 0; i < values.length; i++)
+ {
+ values[i] = (int) (values[i] * scaleFactor + offset);
+
+ // Clip if needed
+ if (values[i] < 0)
+ values[i] = 0;
+ if (values[i] > maxValue[band])
+ values[i] = maxValue[band];
+ }
+
+ dest.setSamples(dest.getMinX(), dest.getMinY(), dest.getWidth(),
+ dest.getHeight(), band, values);
+ }
+
return dest;
}
- /* (non-Javadoc)
- * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel)
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.awt.image.BufferedImageOp#createCompatibleDestImage(java.awt.image.BufferedImage,
+ * java.awt.image.ColorModel)
*/
public BufferedImage createCompatibleDestImage(BufferedImage src,
ColorModel dstCM)
{
- if (dstCM == null) dstCM = src.getColorModel();
- WritableRaster wr = src.getRaster().createCompatibleWritableRaster();
- BufferedImage image
- = new BufferedImage(dstCM, wr, src.isPremultiplied, null);
- return image;
+ if (dstCM == null)
+ return new BufferedImage(src.getWidth(), src.getHeight(), src.getType());
+
+ return new BufferedImage(dstCM,
+ src.getRaster().createCompatibleWritableRaster(),
+ src.isAlphaPremultiplied(), null);
}
/* (non-Javadoc)
@@ -209,9 +372,13 @@ public class RescaleOp implements BufferedImageOp, RasterOp
/* (non-Javadoc)
* @see java.awt.image.BufferedImageOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D)
*/
- public final Point2D getPoint2D(Point2D src, Point2D dst) {
- if (dst == null) dst = (Point2D) src.clone();
- else dst.setLocation(src);
+ public final Point2D getPoint2D(Point2D src, Point2D dst)
+ {
+ if (dst == null)
+ dst = (Point2D) src.clone();
+ else
+ dst.setLocation(src);
+
return dst;
}
diff --git a/java/io/FileDescriptor.java b/java/io/FileDescriptor.java
index dd3db1c74..cf9ff20d5 100644
--- a/java/io/FileDescriptor.java
+++ b/java/io/FileDescriptor.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package java.io;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.FileChannelImpl;
import java.nio.channels.ByteChannel;
import java.nio.channels.FileChannel;
diff --git a/java/io/FileInputStream.java b/java/io/FileInputStream.java
index 8ca38b02f..8217668b4 100644
--- a/java/io/FileInputStream.java
+++ b/java/io/FileInputStream.java
@@ -38,8 +38,9 @@ exception statement from your version. */
package java.io;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.FileChannelImpl;
+import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
@@ -107,7 +108,20 @@ public class FileInputStream extends InputStream
if (s != null)
s.checkRead(file.getPath());
- ch = FileChannelImpl.create(file, FileChannelImpl.READ);
+ try
+ {
+ ch = FileChannelImpl.create(file, FileChannelImpl.READ);
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ throw fnfe;
+ }
+ catch (IOException ioe)
+ {
+ FileNotFoundException fnfe = new FileNotFoundException(file.getPath());
+ fnfe.initCause(ioe);
+ throw fnfe;
+ }
}
/**
@@ -266,7 +280,7 @@ public class FileInputStream extends InputStream
|| offset + len > buf.length)
throw new ArrayIndexOutOfBoundsException();
- return ch.read(buf, offset, len);
+ return ch.read(ByteBuffer.wrap(buf, offset, len));
}
/**
diff --git a/java/io/FileOutputStream.java b/java/io/FileOutputStream.java
index 10ea6b536..d7561a9d7 100644
--- a/java/io/FileOutputStream.java
+++ b/java/io/FileOutputStream.java
@@ -38,8 +38,9 @@ exception statement from your version. */
package java.io;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.FileChannelImpl;
+import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
@@ -155,10 +156,23 @@ public class FileOutputStream extends OutputStream
if (s != null)
s.checkWrite(file.getPath());
- ch = FileChannelImpl.create(file, (append
- ? FileChannelImpl.WRITE
- | FileChannelImpl.APPEND
- : FileChannelImpl.WRITE));
+ try
+ {
+ ch = FileChannelImpl.create(file, (append
+ ? FileChannelImpl.WRITE
+ | FileChannelImpl.APPEND
+ : FileChannelImpl.WRITE));
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ throw fnfe;
+ }
+ catch (IOException ioe)
+ {
+ FileNotFoundException fnfe = new FileNotFoundException(file.getPath());
+ fnfe.initCause(ioe);
+ throw fnfe;
+ }
}
/**
@@ -266,7 +280,7 @@ public class FileOutputStream extends OutputStream
|| offset + len > buf.length)
throw new ArrayIndexOutOfBoundsException ();
- ch.write (buf, offset, len);
+ ch.write(ByteBuffer.wrap(buf, offset, len));
}
/**
diff --git a/java/io/InputStreamReader.java b/java/io/InputStreamReader.java
index 8d97799d5..6c5297f6b 100644
--- a/java/io/InputStreamReader.java
+++ b/java/io/InputStreamReader.java
@@ -368,6 +368,8 @@ public class InputStreamReader extends Reader
if(decoder != null)
{
int totalBytes = (int)((double) length * maxBytesPerChar);
+ if (byteBuffer != null)
+ totalBytes = Math.max(totalBytes, byteBuffer.remaining());
byte[] bytes;
// Fetch cached bytes array if available and big enough.
synchronized(cacheLock)
diff --git a/java/io/ObjectStreamClass.java b/java/io/ObjectStreamClass.java
index 21a80c392..52a1ad428 100644
--- a/java/io/ObjectStreamClass.java
+++ b/java/io/ObjectStreamClass.java
@@ -323,8 +323,8 @@ public class ObjectStreamClass implements Serializable
else
{
// Check that the actual UID of the resolved class matches the UID from
- // the stream.
- if (uid != class_uid)
+ // the stream. Mismatches for array classes are ignored.
+ if (!cl.isArray() && uid != class_uid)
{
String msg = cl +
": Local class not compatible: stream serialVersionUID="
diff --git a/java/io/PipedInputStream.java b/java/io/PipedInputStream.java
index 523ae2c70..c0396d206 100644
--- a/java/io/PipedInputStream.java
+++ b/java/io/PipedInputStream.java
@@ -279,6 +279,10 @@ public class PipedInputStream extends InputStream
if (closed)
throw new IOException ("Pipe closed");
+ // Don't block if nothing was requested.
+ if (len == 0)
+ return 0;
+
// If the buffer is empty, wait until there is something in the pipe
// to read.
try
diff --git a/java/io/PipedReader.java b/java/io/PipedReader.java
index 90fc10f67..8a3363a60 100644
--- a/java/io/PipedReader.java
+++ b/java/io/PipedReader.java
@@ -261,6 +261,10 @@ public class PipedReader extends Reader
if (closed)
throw new IOException ("Pipe closed");
+ // Don't block if nothing was requested.
+ if (len == 0)
+ return 0;
+
// If the buffer is empty, wait until there is something in the pipe
// to read.
try
diff --git a/java/io/RandomAccessFile.java b/java/io/RandomAccessFile.java
index d719a1e3b..036fc8c6b 100644
--- a/java/io/RandomAccessFile.java
+++ b/java/io/RandomAccessFile.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.io;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.FileChannelImpl;
import java.nio.channels.FileChannel;
@@ -122,7 +122,20 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable
s.checkWrite(fileName);
}
- ch = FileChannelImpl.create(file, fdmode);
+ try
+ {
+ ch = FileChannelImpl.create(file, fdmode);
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ throw fnfe;
+ }
+ catch (IOException ioe)
+ {
+ FileNotFoundException fnfe = new FileNotFoundException(file.getPath());
+ fnfe.initCause(ioe);
+ throw fnfe;
+ }
fd = new FileDescriptor(ch);
if ((fdmode & FileChannelImpl.WRITE) != 0)
out = new DataOutputStream (new FileOutputStream (fd));
diff --git a/java/net/DatagramSocket.java b/java/net/DatagramSocket.java
index d8837c006..974827cbb 100644
--- a/java/net/DatagramSocket.java
+++ b/java/net/DatagramSocket.java
@@ -1,5 +1,5 @@
/* DatagramSocket.java -- A class to model UDP sockets
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -180,7 +180,18 @@ public class DatagramSocket
if (factory != null)
impl = factory.createDatagramSocketImpl();
else
- impl = new PlainDatagramSocketImpl();
+ {
+ try
+ {
+ impl = new PlainDatagramSocketImpl();
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
}
else
try
@@ -194,7 +205,16 @@ public class DatagramSocket
{
System.err.println("Could not instantiate class: java.net."
+ propVal + "DatagramSocketImpl");
- impl = new PlainDatagramSocketImpl();
+ try
+ {
+ impl = new PlainDatagramSocketImpl();
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
}
if (address != null)
@@ -578,7 +598,13 @@ public class DatagramSocket
&& ! ((DatagramChannelImpl) getChannel()).isInChannelOperation())
throw new IllegalBlockingModeException();
- getImpl().receive(p);
+ DatagramPacket p2 = new DatagramPacket(p.getData(), p.getOffset(), p.maxlen);
+ getImpl().receive(p2);
+ p.length = p2.length;
+ if (p2.getAddress() != null)
+ p.setAddress(p2.getAddress());
+ if (p2.getPort() != -1)
+ p.setPort(p2.getPort());
SecurityManager s = System.getSecurityManager();
if (s != null && isConnected())
@@ -649,6 +675,9 @@ public class DatagramSocket
{
if (isClosed())
throw new SocketException("socket is closed");
+
+ if (address == null)
+ address = new InetSocketAddress(InetAddress.ANY_IF, 0);
if (! (address instanceof InetSocketAddress))
throw new IllegalArgumentException("unsupported address type");
diff --git a/java/net/Inet4Address.java b/java/net/Inet4Address.java
index c80f1f175..a8a726ecf 100644
--- a/java/net/Inet4Address.java
+++ b/java/net/Inet4Address.java
@@ -1,5 +1,5 @@
/* Inet4Address.java --
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,11 +57,16 @@ public final class Inet4Address extends InetAddress
static final long serialVersionUID = 3286316764910316507L;
/**
- * needed for serialization
+ * The address family of these addresses (used for serialization).
+ */
+ private static final int AF_INET = 2;
+
+ /**
+ * Inet4Address objects are serialized as InetAddress objects.
*/
private Object writeReplace() throws ObjectStreamException
{
- return new InetAddress(addr, hostName);
+ return new InetAddress(addr, hostName, AF_INET);
}
/**
@@ -74,7 +79,7 @@ public final class Inet4Address extends InetAddress
*/
Inet4Address(byte[] addr, String host)
{
- super(addr, host);
+ super(addr, host, AF_INET);
}
/**
@@ -84,7 +89,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMulticastAddress()
{
- return super.isMulticastAddress();
+ return (addr[0] & 0xf0) == 0xe0;
}
/**
@@ -92,7 +97,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isLoopbackAddress()
{
- return super.isLoopbackAddress();
+ return (addr[0] & 0xff) == 0x7f;
}
/**
@@ -102,7 +107,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isAnyLocalAddress()
{
- return super.isAnyLocalAddress();
+ return equals(InetAddress.ANY_IF);
}
/**
@@ -112,7 +117,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isLinkLocalAddress()
{
- return super.isLinkLocalAddress();
+ return false;
}
/**
@@ -122,7 +127,19 @@ public final class Inet4Address extends InetAddress
*/
public boolean isSiteLocalAddress()
{
- return super.isSiteLocalAddress();
+ // 10.0.0.0/8
+ if ((addr[0] & 0xff) == 0x0a)
+ return true;
+
+ // 172.16.0.0/12
+ if ((addr[0] & 0xff) == 0xac && (addr[1] & 0xf0) == 0x10)
+ return true;
+
+ // 192.168.0.0/16
+ if ((addr[0] & 0xff) == 0xc0 && (addr[1] & 0xff) == 0xa8)
+ return true;
+
+ return false;
}
/**
@@ -132,7 +149,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCGlobal()
{
- return super.isMCGlobal();
+ return false;
}
/**
@@ -142,7 +159,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCNodeLocal()
{
- return super.isMCNodeLocal();
+ return false;
}
/**
@@ -152,7 +169,12 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCLinkLocal()
{
- return super.isMCLinkLocal();
+ if (! isMulticastAddress())
+ return false;
+
+ return ((addr[0] & 0xff) == 0xe0
+ && (addr[1] & 0xff) == 0x00
+ && (addr[2] & 0xff) == 0x00);
}
/**
@@ -162,7 +184,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCSiteLocal()
{
- return super.isMCSiteLocal();
+ return false;
}
/**
@@ -172,7 +194,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCOrgLocal()
{
- return super.isMCOrgLocal();
+ return false;
}
/**
@@ -190,7 +212,23 @@ public final class Inet4Address extends InetAddress
*/
public String getHostAddress()
{
- return super.getHostAddress();
+ StringBuffer sb = new StringBuffer(40);
+
+ int len = addr.length;
+ int i = 0;
+
+ for ( ; ; )
+ {
+ sb.append(addr[i] & 0xff);
+ i++;
+
+ if (i == len)
+ break;
+
+ sb.append('.');
+ }
+
+ return sb.toString();
}
/**
diff --git a/java/net/Inet6Address.java b/java/net/Inet6Address.java
index 8d834a6fd..ef3c4431a 100644
--- a/java/net/Inet6Address.java
+++ b/java/net/Inet6Address.java
@@ -1,5 +1,5 @@
/* Inet6Address.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -93,6 +93,11 @@ public final class Inet6Address extends InetAddress
private transient NetworkInterface nif;
/**
+ * The address family of these addresses (used for serialization).
+ */
+ private static final int AF_INET6 = 10;
+
+ /**
* Create an Inet6Address object
*
* @param addr The IP address
@@ -100,7 +105,7 @@ public final class Inet6Address extends InetAddress
*/
Inet6Address(byte[] addr, String host)
{
- super(addr, host);
+ super(addr, host, AF_INET6);
// Super constructor clones the addr. Get a reference to the clone.
this.ipaddress = this.addr;
ifname = null;
diff --git a/java/net/InetAddress.java b/java/net/InetAddress.java
index ce65bc773..1f2667980 100644
--- a/java/net/InetAddress.java
+++ b/java/net/InetAddress.java
@@ -1,5 +1,6 @@
/* InetAddress.java -- Class to model an Internet address
- Copyright (C) 1998, 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2002, 2004, 2005, 2006
+ Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +44,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
-import java.util.StringTokenizer;
/**
* This class models an Internet address. It does not have a public
@@ -57,45 +57,56 @@ import java.util.StringTokenizer;
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Per Bothner
+ * @author Gary Benson (gbenson@redhat.com)
*
- * @specnote This class is not final since JK 1.4
+ * @specnote This class is not final since JDK 1.4
*/
public class InetAddress implements Serializable
{
private static final long serialVersionUID = 3286316764910316507L;
/**
- * The special IP address INADDR_ANY.
- */
- private static InetAddress inaddr_any;
-
- /**
* Dummy InetAddress, used to bind socket to any (all) network interfaces.
*/
static InetAddress ANY_IF;
-
+ static
+ {
+ byte[] addr;
+ try
+ {
+ addr = VMInetAddress.lookupInaddrAny();
+ }
+ catch (UnknownHostException e)
+ {
+ // Make one up and hope it works.
+ addr = new byte[] {0, 0, 0, 0};
+ }
+ try
+ {
+ ANY_IF = getByAddress(addr);
+ }
+ catch (UnknownHostException e)
+ {
+ throw (InternalError) new InternalError().initCause(e);
+ }
+ ANY_IF.hostName = ANY_IF.getHostName();
+ }
+
/**
* Stores static localhost address object.
*/
static InetAddress LOCALHOST;
-
static
{
- // precompute the ANY_IF address
try
{
- ANY_IF = getInaddrAny();
-
- byte[] ip_localhost = { 127, 0, 0, 1 };
- LOCALHOST = new Inet4Address(ip_localhost, "localhost");
+ LOCALHOST = getByAddress("localhost", new byte[] {127, 0, 0, 1});
}
- catch (UnknownHostException uhe)
+ catch (UnknownHostException e)
{
- // Hmmm, make one up and hope that it works.
- byte[] zeros = { 0, 0, 0, 0 };
- ANY_IF = new Inet4Address(zeros, "0.0.0.0");
+ throw (InternalError) new InternalError().initCause(e);
}
- }
+ }
/**
* The Serialized Form specifies that an int 'address' is saved/restored.
@@ -115,28 +126,28 @@ public class InetAddress implements Serializable
String hostName;
/**
- * The field 'family' seems to be the AF_ value.
- * FIXME: Much of the code in the other java.net classes does not make
- * use of this family field. A better implementation would be to make
- * use of getaddrinfo() and have other methods just check the family
- * field rather than examining the length of the address each time.
+ * Needed for serialization.
*/
- int family;
+ private int family;
/**
- * Initializes this object's addr instance variable from the passed in
- * byte array. Note that this constructor is protected and is called
- * only by static methods in this class.
+ * Constructor. Prior to the introduction of IPv6 support in 1.4,
+ * methods such as InetAddress.getByName() would return InetAddress
+ * objects. From 1.4 such methods returned either Inet4Address or
+ * Inet6Address objects, but for compatibility Inet4Address objects
+ * are serialized as InetAddresses. As such, there are only two
+ * places where it is appropriate to invoke this constructor: within
+ * subclasses constructors and within Inet4Address.writeReplace().
*
* @param ipaddr The IP number of this address as an array of bytes
* @param hostname The hostname of this IP address.
+ * @param family The address family of this IP address.
*/
- InetAddress(byte[] ipaddr, String hostname)
+ InetAddress(byte[] ipaddr, String hostname, int family)
{
addr = (null == ipaddr) ? null : (byte[]) ipaddr.clone();
hostName = hostname;
-
- family = 2; /* AF_INET */
+ this.family = family;
}
/**
@@ -144,150 +155,144 @@ public class InetAddress implements Serializable
* An address is multicast if the high four bits are "1110". These are
* also known as "Class D" addresses.
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @return true if mulitcast, false if not
*
* @since 1.1
*/
public boolean isMulticastAddress()
{
- // Mask against high order bits of 1110
- if (addr.length == 4)
- return (addr[0] & 0xf0) == 0xe0;
-
- return false;
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if the InetAddress in a wildcard address
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isAnyLocalAddress()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- return equals(ANY_IF);
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if the InetAddress is a loopback address
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isLoopbackAddress()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- return (addr[0] & 0xff) == 0x7f;
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if InetAddress is a link local address
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isLinkLocalAddress()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- // XXX: This seems to not exist with IPv4 addresses
- return false;
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if InetAddress is a site local address
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isSiteLocalAddress()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
-
- // 10.0.0.0/8
- if ((addr[0] & 0xff) == 0x0a)
- return true;
-
- // 172.16.0.0/12
- if ((addr[0] & 0xff) == 0xac && (addr[1] & 0xf0) == 0x10)
- return true;
-
- // 192.168.0.0/16
- if ((addr[0] & 0xff) == 0xc0 && (addr[1] & 0xff) == 0xa8)
- return true;
-
- // XXX: Do we need to check more addresses here ?
- return false;
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if InetAddress is a global multicast address
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isMCGlobal()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- // XXX: This seems to not exist with IPv4 addresses
- return false;
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if InetAddress is a node local multicast address.
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isMCNodeLocal()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- // XXX: This seems to not exist with IPv4 addresses
- return false;
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if InetAddress is a link local multicast address.
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isMCLinkLocal()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- if (! isMulticastAddress())
- return false;
-
- return ((addr[0] & 0xff) == 0xe0
- && (addr[1] & 0xff) == 0x00
- && (addr[2] & 0xff) == 0x00);
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if InetAddress is a site local multicast address.
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isMCSiteLocal()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- // XXX: This seems to not exist with IPv4 addresses
- return false;
+ throw new UnsupportedOperationException();
}
/**
* Utility routine to check if InetAddress is a organization local
* multicast address.
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @since 1.4
*/
public boolean isMCOrgLocal()
{
- // This is the IPv4 implementation.
- // Any class derived from InetAddress should override this.
- // XXX: This seems to not exist with IPv4 addresses
- return false;
+ throw new UnsupportedOperationException();
}
/**
@@ -298,13 +303,20 @@ public class InetAddress implements Serializable
*/
public String getHostName()
{
- if (hostName != null)
- return hostName;
+ if (hostName == null)
+ hostName = getCanonicalHostName();
+ return hostName;
+ }
+
+ /**
+ * Returns the canonical hostname represented by this InetAddress
+ */
+ String internalGetCanonicalHostName()
+ {
try
{
- hostName = VMInetAddress.getHostByAddr(addr);
- return hostName;
+ return ResolverCache.getHostByAddr(addr);
}
catch (UnknownHostException e)
{
@@ -319,12 +331,14 @@ public class InetAddress implements Serializable
*/
public String getCanonicalHostName()
{
+ String hostname = internalGetCanonicalHostName();
+
SecurityManager sm = System.getSecurityManager();
if (sm != null)
{
try
{
- sm.checkConnect(hostName, -1);
+ sm.checkConnect(hostname, -1);
}
catch (SecurityException e)
{
@@ -332,16 +346,7 @@ public class InetAddress implements Serializable
}
}
- // Try to find the FDQN now
- InetAddress address;
- byte[] ipaddr = getAddress();
-
- if (ipaddr.length == 16)
- address = new Inet6Address(getAddress(), null);
- else
- address = new Inet4Address(getAddress(), null);
-
- return address.getHostName();
+ return hostname;
}
/**
@@ -357,32 +362,19 @@ public class InetAddress implements Serializable
}
/**
- * Returns the IP address of this object as a String. The address is in
- * the dotted octet notation, for example, "127.0.0.1".
+ * Returns the IP address of this object as a String.
*
+ * <p>This method cannot be abstract for backward compatibility reasons. By
+ * default it always throws {@link UnsupportedOperationException} unless
+ * overridden.</p>
+ *
* @return The IP address of this object in String form
*
* @since 1.0.2
*/
public String getHostAddress()
{
- StringBuffer sb = new StringBuffer(40);
-
- int len = addr.length;
- int i = 0;
-
- for ( ; ; )
- {
- sb.append(addr[i] & 0xff);
- i++;
-
- if (i == len)
- break;
-
- sb.append('.');
- }
-
- return sb.toString();
+ throw new UnsupportedOperationException();
}
/**
@@ -488,48 +480,50 @@ public class InetAddress implements Serializable
return new Inet4Address(addr, host);
if (addr.length == 16)
- return new Inet6Address(addr, host);
+ {
+ for (int i = 0; i < 12; i++)
+ {
+ if (addr[i] != (i < 10 ? 0 : (byte) 0xFF))
+ return new Inet6Address(addr, host);
+ }
+
+ byte[] ip4addr = new byte[4];
+ ip4addr[0] = addr[12];
+ ip4addr[1] = addr[13];
+ ip4addr[2] = addr[14];
+ ip4addr[3] = addr[15];
+ return new Inet4Address(ip4addr, host);
+ }
throw new UnknownHostException("IP address has illegal length");
}
/**
- * If hostname is a valid numeric IP address, return the numeric address.
- * Otherwise, return null.
+ * Returns an InetAddress object representing the IP address of
+ * the given literal IP address in dotted decimal format such as
+ * "127.0.0.1". This is used by SocketPermission.setHostPort()
+ * to parse literal IP addresses without performing a DNS lookup.
+ *
+ * @param literal The literal IP address to create the InetAddress
+ * object from
*
- * @param hostname the name of the host
+ * @return The address of the host as an InetAddress object, or
+ * null if the IP address is invalid.
*/
- private static byte[] aton(String hostname)
+ static InetAddress getByLiteral(String literal)
{
- StringTokenizer st = new StringTokenizer(hostname, ".");
-
- if (st.countTokens() == 4)
+ byte[] address = VMInetAddress.aton(literal);
+ if (address == null)
+ return null;
+
+ try
{
- int index;
- byte[] address = new byte[4];
-
- for (index = 0; index < 4; index++)
- {
- try
- {
- short n = Short.parseShort(st.nextToken());
-
- if ((n < 0) || (n > 255))
- break;
-
- address[index] = (byte) n;
- }
- catch (NumberFormatException e)
- {
- break;
- }
- }
-
- if (index == 4)
- return address;
+ return getByAddress(address);
+ }
+ catch (UnknownHostException e)
+ {
+ throw (InternalError) new InternalError().initCause(e);
}
-
- return null;
}
/**
@@ -577,63 +571,34 @@ public class InetAddress implements Serializable
public static InetAddress[] getAllByName(String hostname)
throws UnknownHostException
{
- SecurityManager s = System.getSecurityManager();
- if (s != null)
- s.checkConnect(hostname, -1);
-
- InetAddress[] addresses;
-
- if (hostname != null)
- hostname = hostname.trim();
+ // If null or the empty string is supplied, the loopback address
+ // is returned.
+ if (hostname == null || hostname.length() == 0)
+ return new InetAddress[] {LOCALHOST};
- // Default to current host if necessary
- if (hostname == null || hostname.equals(""))
- {
- addresses = new InetAddress[1];
- addresses[0] = LOCALHOST;
- return addresses;
- }
+ // Check if hostname is an IP address
+ InetAddress address = getByLiteral(hostname);
+ if (address != null)
+ return new InetAddress[] {address};
- // Not in cache, try the lookup
- byte[][] iplist = VMInetAddress.getHostByName(hostname);
+ // Perform security check before resolving
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkConnect(hostname, -1);
+ // Resolve the hostname
+ byte[][] iplist = ResolverCache.getHostByName(hostname);
if (iplist.length == 0)
throw new UnknownHostException(hostname);
- addresses = new InetAddress[iplist.length];
-
+ InetAddress[] addresses = new InetAddress[iplist.length];
for (int i = 0; i < iplist.length; i++)
- {
- if (iplist[i].length != 4)
- throw new UnknownHostException(hostname);
-
- addresses[i] = new Inet4Address(iplist[i], hostname);
- }
+ addresses[i] = getByAddress(hostname, iplist[i]);
return addresses;
}
/**
- * Returns the special address INADDR_ANY used for binding to a local
- * port on all IP addresses hosted by a the local host.
- *
- * @return An InetAddress object representing INDADDR_ANY
- *
- * @exception UnknownHostException If an error occurs
- */
- static InetAddress getInaddrAny() throws UnknownHostException
- {
- if (inaddr_any == null)
- {
- byte[] tmp = VMInetAddress.lookupInaddrAny();
- inaddr_any = new Inet4Address(tmp, null);
- inaddr_any.hostName = inaddr_any.getHostName();
- }
-
- return inaddr_any;
- }
-
- /**
* Returns an InetAddress object representing the address of the current
* host.
*
@@ -645,11 +610,19 @@ public class InetAddress implements Serializable
public static InetAddress getLocalHost() throws UnknownHostException
{
String hostname = VMInetAddress.getLocalHostname();
- return getByName(hostname);
+ try
+ {
+ return getByName(hostname);
+ }
+ catch (SecurityException e)
+ {
+ return LOCALHOST;
+ }
}
- /*
- * Needed for serialization
+ /**
+ * Inet4Address objects are serialized as InetAddress objects.
+ * This deserializes them back into Inet4Address objects.
*/
private Object readResolve() throws ObjectStreamException
{
@@ -665,8 +638,6 @@ public class InetAddress implements Serializable
for (int i = 2; i >= 0; --i)
addr[i] = (byte) (address >>= 8);
-
- family = 2; /* AF_INET */
}
private void writeObject(ObjectOutputStream oos) throws IOException
diff --git a/java/net/NetworkInterface.java b/java/net/NetworkInterface.java
index 7ad62a713..af595a1ee 100644
--- a/java/net/NetworkInterface.java
+++ b/java/net/NetworkInterface.java
@@ -1,5 +1,5 @@
/* NetworkInterface.java --
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.net;
+import gnu.classpath.SystemProperties;
+
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
@@ -58,25 +60,13 @@ import java.util.Vector;
*/
public final class NetworkInterface
{
- private String name;
- private Vector<InetAddress> inetAddresses;
-
- NetworkInterface(String name, InetAddress address)
- {
- this.name = name;
- this.inetAddresses = new Vector(1, 1);
- this.inetAddresses.add(address);
- }
-
- NetworkInterface(String name, InetAddress[] addresses)
- {
- this.name = name;
- this.inetAddresses = new Vector(addresses.length, 1);
-
- for (int i = 0; i < addresses.length; i++)
- this.inetAddresses.add(addresses[i]);
- }
-
+ private final VMNetworkInterface netif;
+
+ private NetworkInterface(VMNetworkInterface netif)
+ {
+ this.netif = netif;
+ }
+
/**
* Returns the name of the network interface
*
@@ -84,7 +74,7 @@ public final class NetworkInterface
*/
public String getName()
{
- return name;
+ return netif.name;
}
/**
@@ -100,6 +90,7 @@ public final class NetworkInterface
public Enumeration<InetAddress> getInetAddresses()
{
SecurityManager s = System.getSecurityManager();
+ Vector inetAddresses = new Vector(netif.addresses);
if (s == null)
return inetAddresses.elements();
@@ -112,7 +103,7 @@ public final class NetworkInterface
InetAddress addr = addresses.nextElement();
try
{
- s.checkConnect(addr.getHostAddress(), 58000);
+ s.checkConnect(addr.getHostAddress(), -1);
tmpInetAddresses.add(addr);
}
catch (SecurityException e)
@@ -131,7 +122,7 @@ public final class NetworkInterface
*/
public String getDisplayName()
{
- return name;
+ return netif.name;
}
/**
@@ -148,15 +139,14 @@ public final class NetworkInterface
public static NetworkInterface getByName(String name)
throws SocketException
{
- for (Enumeration e = getNetworkInterfaces(); e.hasMoreElements();)
+ if (name == null)
+ throw new NullPointerException();
+ VMNetworkInterface[] netifs = VMNetworkInterface.getVMInterfaces();
+ for (int i = 0; i < netifs.length; i++)
{
- NetworkInterface tmp = (NetworkInterface) e.nextElement();
-
- if (name.equals(tmp.getName()))
- return tmp;
+ if (netifs[i].name.equals(name))
+ return new NetworkInterface(netifs[i]);
}
-
- // No interface with the given name found.
return null;
}
@@ -173,55 +163,15 @@ public final class NetworkInterface
public static NetworkInterface getByInetAddress(InetAddress addr)
throws SocketException
{
- for (Enumeration interfaces = getNetworkInterfaces();
- interfaces.hasMoreElements();)
+ if (addr == null)
+ throw new NullPointerException();
+ VMNetworkInterface[] netifs = VMNetworkInterface.getVMInterfaces();
+ for (int i = 0; i < netifs.length; i++)
{
- NetworkInterface tmp = (NetworkInterface) interfaces.nextElement();
-
- for (Enumeration addresses = tmp.inetAddresses.elements();
- addresses.hasMoreElements();)
- {
- if (addr.equals((InetAddress) addresses.nextElement()))
- return tmp;
- }
+ if (netifs[i].addresses.contains(addr))
+ return new NetworkInterface(netifs[i]);
}
-
- throw new SocketException("no network interface is bound to such an IP address");
- }
-
- static private Collection condense(Collection interfaces)
- {
- final Map condensed = new HashMap();
-
- final Iterator interfs = interfaces.iterator();
- while (interfs.hasNext()) {
-
- final NetworkInterface face = (NetworkInterface) interfs.next();
- final String name = face.getName();
-
- if (condensed.containsKey(name))
- {
- final NetworkInterface conface = (NetworkInterface) condensed.get(name);
- if (!conface.inetAddresses.containsAll(face.inetAddresses))
- {
- final Iterator faceAddresses = face.inetAddresses.iterator();
- while (faceAddresses.hasNext())
- {
- final InetAddress faceAddress = (InetAddress) faceAddresses.next();
- if (!conface.inetAddresses.contains(faceAddress))
- {
- conface.inetAddresses.add(faceAddress);
- }
- }
- }
- }
- else
- {
- condensed.put(name, face);
- }
- }
-
- return condensed.values();
+ return null;
}
/**
@@ -234,15 +184,15 @@ public final class NetworkInterface
public static Enumeration<NetworkInterface> getNetworkInterfaces()
throws SocketException
{
- Vector<NetworkInterface> networkInterfaces =
- VMNetworkInterface.getInterfaces();
-
- if (networkInterfaces.isEmpty())
- return null;
-
- Collection condensed = condense(networkInterfaces);
-
- return Collections.enumeration(condensed);
+ VMNetworkInterface[] netifs = VMNetworkInterface.getVMInterfaces();
+ Vector<NetworkInterface> networkInterfaces =
+ new Vector<NetworkInterface>(netifs.length);
+ for (int i = 0; i < netifs.length; i++)
+ {
+ if (!netifs[i].addresses.isEmpty())
+ networkInterfaces.add(new NetworkInterface(netifs[i]));
+ }
+ return networkInterfaces.elements();
}
/**
@@ -259,7 +209,8 @@ public final class NetworkInterface
NetworkInterface tmp = (NetworkInterface) obj;
- return (name.equals(tmp.name) && inetAddresses.equals(tmp.inetAddresses));
+ return (netif.name.equals(tmp.netif.name)
+ && (netif.addresses.equals(tmp.netif.addresses)));
}
/**
@@ -270,7 +221,7 @@ public final class NetworkInterface
public int hashCode()
{
// FIXME: hash correctly
- return name.hashCode() + inetAddresses.hashCode();
+ return netif.name.hashCode() + netif.addresses.hashCode();
}
/**
@@ -281,19 +232,22 @@ public final class NetworkInterface
public String toString()
{
// FIXME: check if this is correct
- String result;
- String separator = System.getProperty("line.separator");
+ StringBuffer result;
+ String separator = SystemProperties.getProperty("line.separator");
- result =
- "name: " + getDisplayName() + " (" + getName() + ") addresses:"
- + separator;
+ result = new StringBuffer();
+
+ result.append("name: ");
+ result.append(getDisplayName());
+ result.append(" (").append(getName()).append(") addresses:");
+ result.append(separator);
- for (Enumeration e = inetAddresses.elements(); e.hasMoreElements();)
+ for (Iterator it = netif.addresses.iterator(); it.hasNext(); )
{
- InetAddress address = (InetAddress) e.nextElement();
- result += address.toString() + ";" + separator;
+ InetAddress address = (InetAddress) it.next();
+ result.append(address.toString()).append(";").append(separator);
}
- return result;
+ return result.toString();
}
}
diff --git a/java/net/ResolverCache.java b/java/net/ResolverCache.java
new file mode 100644
index 000000000..f8790666a
--- /dev/null
+++ b/java/net/ResolverCache.java
@@ -0,0 +1,269 @@
+/* ResolverCache.java -- A cache of resolver lookups for InetAddress.
+ 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 java.security.Security;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * This class provides a cache of name service resolutions. By
+ * default successful resolutions are cached forever to guard
+ * against DNS spoofing attacks and failed resolutions are cached
+ * for 10 seconds to improve performance. The length of time that
+ * results remain in the cache is determined by the following
+ * security properties:
+ * <dl>
+ * <dt><code>networkaddress.cache.ttl</code></dt>
+ * <dd>
+ * This property specifies the length of time in seconds that
+ * successful resolutions remain in the cache. The default is
+ * -1, indicating to cache forever.
+ * </dd>
+ * <dt><code>networkaddress.cache.negative.ttl</code></dt>
+ * <dd>
+ * This property specifies the length of time in seconds that
+ * unsuccessful resolutions remain in the cache. The default
+ * is 10, indicating to cache for 10 seconds.
+ * </dd>
+ * In both cases, a value of -1 indicates to cache forever and a
+ * value of 0 indicates not to cache.
+ *
+ * @author Gary Benson (gbenson@redhat.com)
+ */
+class ResolverCache
+{
+ /**
+ * The time in seconds for which successful lookups are cached.
+ */
+ private static final int POSITIVE_TTL =
+ getTTL("networkaddress.cache.ttl", -1);
+
+ /**
+ * The time in seconds for which unsuccessful lookups are cached.
+ */
+ private static final int NEGATIVE_TTL =
+ getTTL("networkaddress.cache.negative.ttl", 10);
+
+ /**
+ * Helper function to set the TTLs.
+ */
+ private static int getTTL(String propName, int defaultValue)
+ {
+ String propValue = Security.getProperty(propName);
+ if (propValue == null)
+ return defaultValue;
+
+ return Integer.parseInt(propValue);
+ }
+
+ /**
+ * The cache itself.
+ */
+ private static HashMap cache = new HashMap();
+
+ /**
+ * List of entries which may expire.
+ */
+ private static LinkedList killqueue = new LinkedList();
+
+ /**
+ * Return the hostname for the specified IP address.
+ *
+ * @param ip The IP address as a byte array
+ *
+ * @return The hostname
+ *
+ * @exception UnknownHostException If the reverse lookup fails
+ */
+ public static String getHostByAddr(byte[] addr) throws UnknownHostException
+ {
+ Object key = makeHashableAddress(addr);
+ Entry entry = (Entry) get(key);
+ if (entry != null)
+ {
+ if (entry.value == null)
+ throw new UnknownHostException();
+ return (String) entry.value;
+ }
+
+ try
+ {
+ String hostname = VMInetAddress.getHostByAddr(addr);
+ put(new Entry(key, hostname));
+ return hostname;
+ }
+ catch (UnknownHostException e)
+ {
+ put(new Entry(key, null));
+ throw e;
+ }
+ }
+
+ /**
+ * Return a list of all IP addresses for the specified hostname.
+ *
+ * @param hostname The hostname
+ *
+ * @return An list of IP addresses as byte arrays
+ *
+ * @exception UnknownHostException If the lookup fails
+ */
+ public static byte[][] getHostByName(String hostname)
+ throws UnknownHostException
+ {
+ Entry entry = (Entry) get(hostname);
+ if (entry != null)
+ {
+ if (entry.value == null)
+ throw new UnknownHostException();
+ return (byte[][]) entry.value;
+ }
+
+ try
+ {
+ byte[][] addrs = VMInetAddress.getHostByName(hostname);
+ put(new Entry(hostname, addrs));
+ return addrs;
+ }
+ catch (UnknownHostException e)
+ {
+ put(new Entry(hostname, null));
+ throw e;
+ }
+ }
+
+ /**
+ * Convert an IP address expressed as a byte array into something
+ * we can use as a hashtable key.
+ */
+ private static Object makeHashableAddress(byte[] addr)
+ {
+ char[] chars = new char[addr.length];
+ for (int i = 0; i < addr.length; i++)
+ chars[i] = (char) addr[i];
+ return new String(chars);
+ }
+
+ /**
+ * Return the entry in the cache associated with the supplied key,
+ * or <code>null</code> if the cache does not contain an entry
+ * associated with this key.
+ */
+ private static synchronized Entry get(Object key)
+ {
+ reap();
+ return (Entry) cache.get(key);
+ }
+
+ /**
+ * Insert the supplied entry into the cache.
+ */
+ private static synchronized void put(Entry entry)
+ {
+ reap();
+ if (entry.expires != 0)
+ {
+ if (entry.expires != -1)
+ killqueue.add(entry);
+ cache.put(entry.key, entry);
+ }
+ }
+
+ /**
+ * Clear expired entries. This method is not synchronized, so
+ * it must only be called by methods that are.
+ */
+ private static void reap()
+ {
+ if (!killqueue.isEmpty())
+ {
+ long now = System.currentTimeMillis();
+
+ Iterator iter = killqueue.iterator();
+ while (iter.hasNext())
+ {
+ Entry entry = (Entry) iter.next();
+ if (entry.expires > now)
+ break;
+ cache.remove(entry.key);
+ iter.remove();
+ }
+ }
+ }
+
+ /**
+ * An entry in the cache.
+ */
+ private static class Entry
+ {
+ /**
+ * The key by which this entry is referenced.
+ */
+ public final Object key;
+
+ /**
+ * The entry itself. A null value indicates a failed lookup.
+ */
+ public final Object value;
+
+ /**
+ * The time when this cache entry expires. If set to -1 then
+ * this entry will never expire. If set to 0 then this entry
+ * expires immediately and will not be inserted into the cache.
+ */
+ public final long expires;
+
+ /**
+ * Constructor.
+ */
+ public Entry(Object key, Object value)
+ {
+ this.key = key;
+ this.value = value;
+
+ int ttl = value != null ? POSITIVE_TTL : NEGATIVE_TTL;
+ if (ttl < 1)
+ expires = ttl;
+ else
+ expires = System.currentTimeMillis() + ttl * 1000;
+ }
+ }
+}
diff --git a/java/net/ServerSocket.java b/java/net/ServerSocket.java
index 2b889531a..533626e0b 100644
--- a/java/net/ServerSocket.java
+++ b/java/net/ServerSocket.java
@@ -79,6 +79,7 @@ public class ServerSocket
* We need to retain the local address even after the socket is closed.
*/
private InetSocketAddress local;
+ private int port;
/*
* This constructor is only used by java.nio.
@@ -93,6 +94,7 @@ public class ServerSocket
this.impl = impl;
this.impl.create(true);
+ setReuseAddress(true);
}
/*
@@ -219,43 +221,53 @@ public class ServerSocket
if (isClosed())
throw new SocketException("ServerSocket is closed");
- if (! (endpoint instanceof InetSocketAddress))
- throw new IllegalArgumentException("Address type not supported");
+ if (isBound())
+ throw new SocketException("Already bound");
- InetSocketAddress tmp = (InetSocketAddress) endpoint;
+ InetAddress addr;
+ int port;
+
+ if (endpoint == null)
+ {
+ addr = InetAddress.ANY_IF;
+ port = 0;
+ }
+ else if (! (endpoint instanceof InetSocketAddress))
+ {
+ throw new IllegalArgumentException("Address type not supported");
+ }
+ else
+ {
+ InetSocketAddress tmp = (InetSocketAddress) endpoint;
+ if (tmp.isUnresolved())
+ throw new SocketException("Unresolved address");
+ addr = tmp.getAddress();
+ port = tmp.getPort();
+ }
SecurityManager s = System.getSecurityManager();
if (s != null)
- s.checkListen(tmp.getPort());
-
- InetAddress addr = tmp.getAddress();
-
- // Initialize addr with 0.0.0.0.
- if (addr == null)
- addr = InetAddress.ANY_IF;
+ s.checkListen(port);
try
{
- impl.bind(addr, tmp.getPort());
+ impl.bind(addr, port);
impl.listen(backlog);
- local = new InetSocketAddress(
+ this.port = port;
+ local = new InetSocketAddress(
(InetAddress) impl.getOption(SocketOptions.SO_BINDADDR),
impl.getLocalPort());
}
- catch (IOException exception)
+ finally
{
- close();
- throw exception;
- }
- catch (RuntimeException exception)
- {
- close();
- throw exception;
- }
- catch (Error error)
- {
- close();
- throw error;
+ try
+ {
+ if (local == null)
+ close();
+ }
+ catch (IOException _)
+ {
+ }
}
}
@@ -367,7 +379,6 @@ public class ServerSocket
throw new IllegalBlockingModeException();
impl.accept(socket.impl);
- socket.implCreated = true;
socket.bound = true;
}
@@ -378,14 +389,11 @@ public class ServerSocket
*/
public void close() throws IOException
{
- if (isClosed())
- return;
-
- impl.close();
- impl = null;
-
- if (getChannel() != null)
- getChannel().close();
+ if (impl != null)
+ {
+ impl.close();
+ impl = null;
+ }
}
/**
@@ -425,7 +433,8 @@ public class ServerSocket
*/
public boolean isClosed()
{
- return impl == null;
+ ServerSocketChannel channel = getChannel();
+ return impl == null || (channel != null && ! channel.isOpen());
}
/**
@@ -573,7 +582,7 @@ public class ServerSocket
return "ServerSocket[unbound]";
return ("ServerSocket[addr=" + getInetAddress() + ",port="
- + impl.getPort() + ",localport=" + impl.getLocalPort() + "]");
+ + port + ",localport=" + getLocalPort() + "]");
}
/**
diff --git a/java/net/Socket.java b/java/net/Socket.java
index b2249ffaa..63ba43727 100644
--- a/java/net/Socket.java
+++ b/java/net/Socket.java
@@ -1,5 +1,5 @@
/* Socket.java -- Client socket implementation
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2006
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -83,13 +83,6 @@ public class Socket
SocketImpl impl;
/**
- * True if socket implementation was created by calling their
- * create() method.
- */
- // package-private because ServerSocket.implAccept() needs to access it.
- boolean implCreated;
-
- /**
* True if the socket is bound.
* Package private so it can be set from ServerSocket when accept is called.
*/
@@ -315,21 +308,6 @@ public class Socket
private SocketImpl getImpl() throws SocketException
{
- try
- {
- if (! implCreated)
- {
- impl.create(true);
- implCreated = true;
- }
- }
- catch (IOException e)
- {
- SocketException se = new SocketException(e.toString());
- se.initCause(e);
- throw se;
- }
-
return impl;
}
@@ -363,6 +341,7 @@ public class Socket
// bind to address/port
try
{
+ getImpl().create(true);
getImpl().bind(tmp.getAddress(), tmp.getPort());
bound = true;
}
@@ -479,16 +458,22 @@ public class Socket
InetAddress addr = null;
- try
- {
- addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
- }
- catch (SocketException e)
+ if (impl instanceof PlainSocketImpl)
+ addr = ((PlainSocketImpl) impl).getLocalAddress().getAddress();
+
+ if (addr == null)
{
- // (hopefully) shouldn't happen
- // throw new java.lang.InternalError
- // ("Error in PlainSocketImpl.getOption");
- return null;
+ try
+ {
+ addr = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
+ }
+ catch (SocketException e)
+ {
+ // (hopefully) shouldn't happen
+ // throw new java.lang.InternalError
+ // ("Error in PlainSocketImpl.getOption");
+ return null;
+ }
}
// FIXME: According to libgcj, checkConnect() is supposed to be called
@@ -1001,12 +986,8 @@ public class Socket
if (isClosed())
return;
- getImpl().close();
+ impl.close();
impl = null;
- bound = false;
-
- if (getChannel() != null)
- getChannel().close();
}
/**
@@ -1019,16 +1000,17 @@ public class Socket
try
{
if (isConnected())
- return ("Socket[addr=" + getImpl().getInetAddress() + ",port="
- + getImpl().getPort() + ",localport="
- + getImpl().getLocalPort() + "]");
+ return (super.toString()
+ + " [addr=" + getImpl().getInetAddress() + ",port="
+ + getImpl().getPort() + ",localport="
+ + getImpl().getLocalPort() + "]");
}
catch (SocketException e)
{
// This cannot happen as we are connected.
}
- return "Socket[unconnected]";
+ return super.toString() + " [unconnected]";
}
/**
@@ -1206,17 +1188,10 @@ public class Socket
*/
public boolean isConnected()
{
- try
- {
- if (getImpl() == null)
- return false;
+ if (impl == null)
+ return false;
- return getImpl().getInetAddress() != null;
- }
- catch (SocketException e)
- {
- return false;
- }
+ return impl.getInetAddress() != null;
}
/**
@@ -1228,6 +1203,13 @@ public class Socket
*/
public boolean isBound()
{
+ if (isClosed())
+ return false;
+ if (impl instanceof PlainSocketImpl)
+ {
+ InetSocketAddress addr = ((PlainSocketImpl) impl).getLocalAddress();
+ return addr != null && addr.getAddress() != null;
+ }
return bound;
}
@@ -1240,7 +1222,8 @@ public class Socket
*/
public boolean isClosed()
{
- return impl == null;
+ SocketChannel channel = getChannel();
+ return impl == null || (channel != null && ! channel.isOpen());
}
/**
diff --git a/java/net/SocketPermission.java b/java/net/SocketPermission.java
index 97e93dcbb..64885438a 100644
--- a/java/net/SocketPermission.java
+++ b/java/net/SocketPermission.java
@@ -117,11 +117,18 @@ public final class SocketPermission extends Permission implements Serializable
static final long serialVersionUID = -7204263841984476862L;
/**
- * A hostname (possibly wildcarded) or IP address (IPv4 or IPv6).
+ * A hostname (possibly wildcarded). Will be set if and only if
+ * this object was initialized with a hostname.
*/
- private transient String host;
+ private transient String hostname = null;
/**
+ * An IP address (IPv4 or IPv6). Will be set if and only if this
+ * object was initialized with a single literal IP address.
+ */
+ private transient InetAddress address = null;
+
+ /**
* A range of ports.
*/
private transient int minport;
@@ -186,16 +193,19 @@ public final class SocketPermission extends Permission implements Serializable
if (hostport.charAt(0) == '[')
return hostport;
- int colons = 0, last_colon = 0;
+ int colons = 0;
+ boolean colon_allowed = true;
for (int i = 0; i < hostport.length(); i++)
{
if (hostport.charAt(i) == ':')
{
- if (i - last_colon == 1)
+ if (!colon_allowed)
throw new IllegalArgumentException("Ambiguous hostport part");
colons++;
- last_colon = i;
+ colon_allowed = false;
}
+ else
+ colon_allowed = true;
}
switch (colons)
@@ -211,6 +221,7 @@ public final class SocketPermission extends Permission implements Serializable
case 8:
// an IPv6 address with ports
+ int last_colon = hostport.lastIndexOf(':');
return "[" + hostport.substring(0, last_colon) + "]"
+ hostport.substring(last_colon);
@@ -225,7 +236,7 @@ public final class SocketPermission extends Permission implements Serializable
private void setHostPort(String hostport)
{
// Split into host and ports
- String ports;
+ String host, ports;
if (hostport.charAt(0) == '[')
{
// host is a bracketed IPv6 address
@@ -234,6 +245,10 @@ public final class SocketPermission extends Permission implements Serializable
throw new IllegalArgumentException("Unmatched '['");
host = hostport.substring(1, end);
+ address = InetAddress.getByLiteral(host);
+ if (address == null)
+ throw new IllegalArgumentException("Bad IPv6 address");
+
if (end == hostport.length() - 1)
ports = "";
else if (hostport.charAt(end + 1) == ':')
@@ -255,6 +270,15 @@ public final class SocketPermission extends Permission implements Serializable
host = hostport.substring(0, sep);
ports = hostport.substring(sep + 1);
}
+
+ address = InetAddress.getByLiteral(host);
+ if (address == null)
+ {
+ if (host.lastIndexOf('*') > 0)
+ throw new IllegalArgumentException("Bad hostname");
+
+ hostname = host;
+ }
}
// Parse and validate the ports
@@ -362,10 +386,25 @@ public final class SocketPermission extends Permission implements Serializable
else
return false;
- return p.actionmask == actionmask &&
- p.minport == minport &&
- p.maxport == maxport &&
- p.host.equals(host);
+ if (p.actionmask != actionmask ||
+ p.minport != minport ||
+ p.maxport != maxport)
+ return false;
+
+ if (address != null)
+ {
+ if (p.address == null)
+ return false;
+ else
+ return p.address.equals(address);
+ }
+ else
+ {
+ if (p.hostname == null)
+ return false;
+ else
+ return p.hostname.equals(hostname);
+ }
}
/**
@@ -376,7 +415,12 @@ public final class SocketPermission extends Permission implements Serializable
*/
public int hashCode()
{
- return actionmask + minport + maxport + host.hashCode();
+ int code = actionmask + minport + maxport;
+ if (address != null)
+ code += address.hashCode();
+ else
+ code += hostname.hashCode();
+ return code;
}
/**
@@ -416,6 +460,44 @@ public final class SocketPermission extends Permission implements Serializable
}
/**
+ * Returns an array of all IP addresses represented by this object.
+ */
+ private InetAddress[] getAddresses()
+ {
+ if (address != null)
+ return new InetAddress[] {address};
+
+ try
+ {
+ return InetAddress.getAllByName(hostname);
+ }
+ catch (UnknownHostException e)
+ {
+ return new InetAddress[0];
+ }
+ }
+
+ /**
+ * Returns the canonical hostname represented by this object,
+ * or null if this object represents a wildcarded domain.
+ */
+ private String getCanonicalHostName()
+ {
+ if (address != null)
+ return address.internalGetCanonicalHostName();
+ if (hostname.charAt(0) == '*')
+ return null;
+ try
+ {
+ return InetAddress.getByName(hostname).internalGetCanonicalHostName();
+ }
+ catch (UnknownHostException e)
+ {
+ return null;
+ }
+ }
+
+ /**
* Returns true if the permission object passed it is implied by the
* this permission. This will be true if:
*
@@ -450,6 +532,11 @@ public final class SocketPermission extends Permission implements Serializable
else
return false;
+ // If p was initialised with an empty hostname then we do not
+ // imply it. This is not part of the spec, but it seems necessary.
+ if (p.hostname != null && p.hostname.length() == 0)
+ return false;
+
// Next check the actions
if ((p.actionmask & actionmask) != p.actionmask)
return false;
@@ -459,36 +546,54 @@ public final class SocketPermission extends Permission implements Serializable
return false;
// Finally check the hosts
- if (host.equals(p.host))
- return true;
+ String p_canon = null;
- // Try the canonical names
- String ourcanonical = null;
- String theircanonical = null;
- try
+ // Return true if this object was initialized with a single
+ // IP address which one of p's IP addresses is equal to.
+ if (address != null)
{
- ourcanonical = InetAddress.getByName(host).getHostName();
- theircanonical = InetAddress.getByName(p.host).getHostName();
+ InetAddress[] addrs = p.getAddresses();
+ for (int i = 0; i < addrs.length; i++)
+ {
+ if (address.equals(addrs[i]))
+ return true;
+ }
}
- catch (UnknownHostException e)
+
+ // Return true if this object is a wildcarded domain that
+ // p's canonical name matches.
+ if (hostname != null && hostname.charAt(0) == '*')
{
- // Who didn't resolve? Just assume current address is canonical enough
- // Is this ok to do?
- if (ourcanonical == null)
- ourcanonical = host;
- if (theircanonical == null)
- theircanonical = p.host;
+ p_canon = p.getCanonicalHostName();
+ if (p_canon != null && p_canon.endsWith(hostname.substring(1)))
+ return true;
+
}
- if (ourcanonical.equals(theircanonical))
- return true;
+ // Return true if this one of this object's IP addresses
+ // is equal to one of p's.
+ if (address == null)
+ {
+ InetAddress[] addrs = p.getAddresses();
+ InetAddress[] p_addrs = p.getAddresses();
+
+ for (int i = 0; i < addrs.length; i++)
+ {
+ for (int j = 0; j < p_addrs.length; j++)
+ {
+ if (addrs[i].equals(p_addrs[j]))
+ return true;
+ }
+ }
+ }
- // Well, last chance. Try for a wildcard
- if (host.indexOf("*.") != -1)
+ // Return true if this object's canonical name equals p's.
+ String canon = getCanonicalHostName();
+ if (canon != null)
{
- String wild_domain =
- host.substring(host.indexOf("*" + 1));
- if (theircanonical.endsWith(wild_domain))
+ if (p_canon == null)
+ p_canon = p.getCanonicalHostName();
+ if (p_canon != null && canon.equals(p_canon))
return true;
}
diff --git a/java/nio/channels/spi/AbstractSelectableChannel.java b/java/nio/channels/spi/AbstractSelectableChannel.java
index 847c02cce..5d5277b4a 100644
--- a/java/nio/channels/spi/AbstractSelectableChannel.java
+++ b/java/nio/channels/spi/AbstractSelectableChannel.java
@@ -44,6 +44,7 @@ import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.IllegalBlockingModeException;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
@@ -106,7 +107,15 @@ public abstract class AbstractSelectableChannel extends SelectableChannel
*/
protected final void implCloseChannel() throws IOException
{
- implCloseSelectableChannel();
+ try
+ {
+ implCloseSelectableChannel();
+ }
+ finally
+ {
+ for (Iterator it = keys.iterator(); it.hasNext(); )
+ ((SelectionKey) it.next()).cancel();
+ }
}
/**
@@ -234,8 +243,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel
if (key != null && key.isValid())
{
- if (att != null)
- key.attach(att);
+ key.interestOps(ops);
+ key.attach(att);
}
else
{
diff --git a/java/text/AttributedCharacterIterator.java b/java/text/AttributedCharacterIterator.java
index 7a87cc556..4f9c762b3 100644
--- a/java/text/AttributedCharacterIterator.java
+++ b/java/text/AttributedCharacterIterator.java
@@ -1,5 +1,5 @@
/* AttributedCharacterIterator.java -- Iterate over attributes
- Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,6 +53,8 @@ import java.util.Set;
* that is defined for a particular value across an entire range of
* characters or which is undefined over a range of characters.
*
+ * @since 1.2
+ *
* @author Aaron M. Renn (arenn@urbanophile.com)
* @since 1.2
*/
@@ -69,7 +71,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* This is the attribute for the language of the text. The value of
* attributes of this key type are instances of <code>Locale</code>.
*/
- public static final Attribute LANGUAGE = new Attribute ("LANGUAGE");
+ public static final Attribute LANGUAGE = new Attribute("language");
/**
* This is the attribute for the reading form of text. This is used
@@ -78,7 +80,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* instances of <code>Annotation</code> which wrappers a
* <code>String</code>.
*/
- public static final Attribute READING = new Attribute ("READING");
+ public static final Attribute READING = new Attribute("reading");
/**
* This is the attribute for input method segments. The value of attributes
@@ -86,7 +88,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* a <code>String</code>.
*/
public static final Attribute INPUT_METHOD_SEGMENT =
- new Attribute ("INPUT_METHOD_SEGMENT");
+ new Attribute("input_method_segment");
/**
* The name of the attribute key
@@ -99,7 +101,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @param name The name of this attribute key.
*/
- protected Attribute (String name)
+ protected Attribute(String name)
{
this.name = name;
}
@@ -157,7 +159,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
* @return <code>true</code> if the specified object is equal to this one,
* <code>false</code> otherwise.
*/
- public final boolean equals (Object obj)
+ public final boolean equals(Object obj)
{
if (obj == this)
return true;
@@ -212,7 +214,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The value of the specified attribute
*/
- Object getAttribute (AttributedCharacterIterator.Attribute attrib);
+ Object getAttribute(AttributedCharacterIterator.Attribute attrib);
/**
* Returns the index of the first character in the run that
@@ -231,7 +233,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The start index of the run.
*/
- int getRunStart (Set<? extends Attribute> attribs);
+ int getRunStart(Set<? extends Attribute> attribs);
/**
* Returns the index of the first character in the run that
@@ -241,7 +243,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The start index of the run.
*/
- int getRunStart (AttributedCharacterIterator.Attribute attrib);
+ int getRunStart(AttributedCharacterIterator.Attribute attrib);
/**
* Returns the index of the character after the end of the run
@@ -260,7 +262,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The end index of the run.
*/
- int getRunLimit (Set<? extends Attribute> attribs);
+ int getRunLimit(Set<? extends Attribute> attribs);
/**
* Returns the index of the character after the end of the run
@@ -270,6 +272,6 @@ public interface AttributedCharacterIterator extends CharacterIterator
*
* @return The end index of the run.
*/
- int getRunLimit (AttributedCharacterIterator.Attribute attrib);
+ int getRunLimit(AttributedCharacterIterator.Attribute attrib);
} // interface AttributedCharacterIterator
diff --git a/java/text/AttributedString.java b/java/text/AttributedString.java
index c220f6025..6785bd3c5 100644
--- a/java/text/AttributedString.java
+++ b/java/text/AttributedString.java
@@ -1,5 +1,5 @@
/* AttributedString.java -- Models text with attributes
- Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,6 +50,8 @@ import java.util.Set;
* This class models a <code>String</code> with attributes over various
* subranges of the string. It allows applications to access this
* information via the <code>AttributedCharacterIterator</code> interface.
+ *
+ * @since 1.2
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @since 1.2
@@ -67,23 +69,23 @@ public class AttributedString
Map attribs;
/** The beginning index of the attributes */
- int begin_index;
+ int beginIndex;
/** The ending index of the attributes */
- int end_index;
+ int endIndex;
/**
* Creates a new attribute range.
*
* @param attribs the attributes.
- * @param begin_index the start index.
- * @param end_index the end index.
+ * @param beginIndex the start index.
+ * @param endIndex the end index.
*/
- AttributeRange(Map attribs, int begin_index, int end_index)
+ AttributeRange(Map attribs, int beginIndex, int endIndex)
{
this.attribs = attribs;
- this.begin_index = begin_index;
- this.end_index = end_index;
+ this.beginIndex = beginIndex;
+ this.endIndex = endIndex;
}
} // Inner class AttributeRange
@@ -149,13 +151,13 @@ public class AttributedString
*
* @param aci The <code>AttributedCharacterIterator</code> containing the
* text and attribute information.
- * @param begin_index The beginning index of the text subrange.
- * @param end_index The ending index of the text subrange.
+ * @param beginIndex The beginning index of the text subrange.
+ * @param endIndex The ending index of the text subrange.
*/
- public AttributedString(AttributedCharacterIterator aci, int begin_index,
- int end_index)
+ public AttributedString(AttributedCharacterIterator aci, int beginIndex,
+ int endIndex)
{
- this(aci, begin_index, end_index, null);
+ this(aci, beginIndex, endIndex, null);
}
/**
@@ -183,9 +185,9 @@ public class AttributedString
StringBuffer sb = new StringBuffer("");
// Get the valid attribute list
- Set all_attribs = aci.getAllAttributeKeys();
+ Set allAttribs = aci.getAllAttributeKeys();
if (attributes != null)
- all_attribs.retainAll(Arrays.asList(attributes));
+ allAttribs.retainAll(Arrays.asList(attributes));
// Loop through and extract the attributes
char c = aci.setIndex(begin);
@@ -195,7 +197,7 @@ public class AttributedString
{
sb.append(c);
- Iterator iter = all_attribs.iterator();
+ Iterator iter = allAttribs.iterator();
while(iter.hasNext())
{
Object obj = iter.next();
@@ -208,9 +210,10 @@ public class AttributedString
(AttributedCharacterIterator.Attribute)obj;
// Make sure the attribute is defined.
- int rl = aci.getRunLimit(attrib);
- if (rl == -1)
+ Object attribObj = aci.getAttribute(attrib);
+ if (attribObj == null)
continue;
+ int rl = aci.getRunLimit(attrib);
if (rl > end)
rl = end;
rl -= begin;
@@ -222,22 +225,21 @@ public class AttributedString
// If the attribute run starts before the beginning index, we
// need to junk it if it is an Annotation.
- Object attrib_obj = aci.getAttribute(attrib);
- rs -= begin;
+ rs -= begin;
if (rs < 0)
{
- if (attrib_obj instanceof Annotation)
+ if (attribObj instanceof Annotation)
continue;
rs = 0;
}
// Create a map object. Yes this will only contain one attribute
- Map new_map = new Hashtable();
- new_map.put(attrib, attrib_obj);
+ Map newMap = new Hashtable();
+ newMap.put(attrib, attribObj);
// Add it to the attribute list.
- accum.add(new AttributeRange(new_map, rs, rl));
+ accum.add(new AttributeRange(newMap, rs, rl));
}
c = aci.next();
@@ -292,28 +294,28 @@ public class AttributedString
* specified subrange of the string.
*
* @param attributes The list of attributes.
- * @param begin_index The beginning index.
- * @param end_index The ending index
+ * @param beginIndex The beginning index.
+ * @param endIndex The ending index
*
* @throws NullPointerException if <code>attributes</code> is
* <code>null</code>.
* @throws IllegalArgumentException if the subrange is not valid.
*/
public void addAttributes(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes,
- int begin_index, int end_index)
+ int beginIndex, int endIndex)
{
if (attributes == null)
throw new NullPointerException("null attribute");
- if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
- (end_index <= begin_index))
+ if ((beginIndex < 0) || (endIndex > sci.getEndIndex()) ||
+ (endIndex <= beginIndex))
throw new IllegalArgumentException("bad range");
AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
System.arraycopy(attribs, 0, new_list, 0, attribs.length);
attribs = new_list;
- attribs[attribs.length - 1] = new AttributeRange(attributes, begin_index,
- end_index);
+ attribs[attribs.length - 1] = new AttributeRange(attributes, beginIndex,
+ endIndex);
}
/**
@@ -354,20 +356,20 @@ public class AttributedString
* returned.
*
* @param attributes A list of attributes to include in the returned iterator.
- * @param begin_index The beginning index of the subrange.
- * @param end_index The ending index of the subrange.
+ * @param beginIndex The beginning index of the subrange.
+ * @param endIndex The ending index of the subrange.
*
* @return An <code>AttributedCharacterIterator</code> for this string.
*/
public AttributedCharacterIterator getIterator(
AttributedCharacterIterator.Attribute[] attributes,
- int begin_index, int end_index)
+ int beginIndex, int endIndex)
{
- if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
- (end_index < begin_index))
+ if ((beginIndex < 0) || (endIndex > sci.getEndIndex()) ||
+ (endIndex < beginIndex))
throw new IllegalArgumentException("bad range");
- return(new AttributedStringIterator(sci, attribs, begin_index, end_index,
+ return(new AttributedStringIterator(sci, attribs, beginIndex, endIndex,
attributes));
}
diff --git a/java/text/AttributedStringIterator.java b/java/text/AttributedStringIterator.java
index f6b9b1868..422876c09 100644
--- a/java/text/AttributedStringIterator.java
+++ b/java/text/AttributedStringIterator.java
@@ -1,5 +1,5 @@
/* AttributedStringIterator.java -- Class to iterate over AttributedString
- Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -71,12 +71,21 @@ class AttributedStringIterator implements AttributedCharacterIterator
/*************************************************************************/
+ /**
+ * Creates a new instance.
+ *
+ * @param sci an iterator for the string content.
+ * @param attribs the attribute ranges.
+ * @param beginIndex the start index.
+ * @param endIndex the end index.
+ * @param restricts the attributes that the user is interested in.
+ */
AttributedStringIterator(StringCharacterIterator sci,
AttributedString.AttributeRange[] attribs,
- int begin_index, int end_index,
+ int beginIndex, int endIndex,
AttributedCharacterIterator.Attribute[] restricts)
{
- this.ci = new StringCharacterIterator(sci, begin_index, end_index);
+ this.ci = new StringCharacterIterator(sci, beginIndex, endIndex);
this.attribs = attribs;
this.restricts = restricts;
}
@@ -154,8 +163,8 @@ class AttributedStringIterator implements AttributedCharacterIterator
for (int i = 0; i < attribs.length; i++)
{
- if (attribs[i].begin_index > getEndIndex()
- || attribs[i].end_index <= getBeginIndex())
+ if (attribs[i].beginIndex > getEndIndex()
+ || attribs[i].endIndex <= getBeginIndex())
continue;
Set key_set = attribs[i].attribs.keySet();
@@ -178,7 +187,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
public int getRunLimit()
{
- return(getRunLimit(getAttributes().keySet()));
+ return getRunLimit(getAllAttributeKeys());
}
public int getRunLimit(AttributedCharacterIterator.Attribute attrib)
@@ -333,7 +342,7 @@ class AttributedStringIterator implements AttributedCharacterIterator
return null;
for (int i = attribs.length - 1; i >= 0; i--)
{
- if (pos >= attribs[i].begin_index && pos < attribs[i].end_index)
+ if (pos >= attribs[i].beginIndex && pos < attribs[i].endIndex)
{
Set keys = attribs[i].attribs.keySet();
if (keys.contains(key))
@@ -373,8 +382,8 @@ class AttributedStringIterator implements AttributedCharacterIterator
for (int i = 0; i < attribs.length; i++)
{
- if ((ci.getIndex() >= attribs[i].begin_index) &&
- (ci.getIndex() < attribs[i].end_index))
+ if ((ci.getIndex() >= attribs[i].beginIndex) &&
+ (ci.getIndex() < attribs[i].endIndex))
m.putAll(attribs[i].attribs);
}
diff --git a/java/util/IdentityHashMap.java b/java/util/IdentityHashMap.java
index e64f7d532..8dead96c1 100644
--- a/java/util/IdentityHashMap.java
+++ b/java/util/IdentityHashMap.java
@@ -97,16 +97,13 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
private static final int DEFAULT_CAPACITY = 21;
/**
- * This object is used to mark deleted items. Package visible for use by
- * nested classes.
+ * This object is used to mark a slot whose key or value is 'null'.
+ * This is more efficient than using a special value to mark an empty
+ * slot, because null entries are rare, empty slots are common, and
+ * the JVM will clear new arrays for us.
+ * Package visible for use by nested classes.
*/
- static final Object tombstone = new Object();
-
- /**
- * This object is used to mark empty slots. We need this because
- * using null is ambiguous. Package visible for use by nested classes.
- */
- static final Object emptyslot = new Object();
+ static final Object nullslot = new Object();
/**
* Compatible with JDK 1.4.
@@ -166,7 +163,6 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
if (max < 2)
max = 2;
table = new Object[max << 1];
- Arrays.fill(table, emptyslot);
threshold = (max >> 2) * 3;
}
@@ -191,7 +187,7 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
if (size != 0)
{
modCount++;
- Arrays.fill(table, emptyslot);
+ Arrays.fill(table, null);
size = 0;
}
}
@@ -227,6 +223,7 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public boolean containsKey(Object key)
{
+ key = xform(key);
return key == table[hash(key)];
}
@@ -241,6 +238,7 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public boolean containsValue(Object value)
{
+ value = xform(value);
for (int i = table.length - 1; i > 0; i -= 2)
if (table[i] == value)
return true;
@@ -299,7 +297,9 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
if (! (o instanceof Map.Entry))
return false;
Map.Entry m = (Map.Entry) o;
- return m.getValue() == table[hash(m.getKey()) + 1];
+ Object value = xform(m.getValue());
+ Object key = xform(m.getKey());
+ return value == table[hash(key) + 1];
}
public int hashCode()
@@ -311,14 +311,13 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
{
if (! (o instanceof Map.Entry))
return false;
- Object key = ((Map.Entry) o).getKey();
+ Object key = xform(((Map.Entry) o).getKey());
int h = hash(key);
if (table[h] == key)
{
size--;
modCount++;
- table[h] = tombstone;
- table[h + 1] = tombstone;
+ IdentityHashMap.this.removeAtIndex(h);
return true;
}
return false;
@@ -360,8 +359,9 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public V get(Object key)
{
+ key = xform(key);
int h = hash(key);
- return (V) (table[h] == key ? table[h + 1] : null);
+ return (V) (table[h] == key ? unxform(table[h + 1]) : null);
}
/**
@@ -378,10 +378,11 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
for (int i = table.length - 2; i >= 0; i -= 2)
{
Object key = table[i];
- if (key == emptyslot || key == tombstone)
+ if (key == null)
continue;
- hash += (System.identityHashCode(key)
- ^ System.identityHashCode(table[i + 1]));
+ // FIXME: this is a lame computation.
+ hash += (System.identityHashCode(unxform(key))
+ ^ System.identityHashCode(unxform(table[i + 1])));
}
return hash;
}
@@ -445,23 +446,22 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
for (int i = table.length - 2; i >= 0; i -= 2)
{
Object key = table[i];
- if (key == emptyslot || key == tombstone)
+ if (key == null)
continue;
- hash += System.identityHashCode(key);
+ hash += System.identityHashCode(unxform(key));
}
return hash;
-
}
public boolean remove(Object o)
{
+ o = xform(o);
int h = hash(o);
if (table[h] == o)
{
size--;
modCount++;
- table[h] = tombstone;
- table[h + 1] = tombstone;
+ removeAtIndex(h);
return true;
}
return false;
@@ -486,6 +486,18 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public V put(K key, V value)
{
+ key = (K) xform(key);
+ value = (V) xform(value);
+
+ // We don't want to rehash if we're overwriting an existing slot.
+ int h = hash(key);
+ if (table[h] == key)
+ {
+ V r = (V) unxform(table[h + 1]);
+ table[h + 1] = value;
+ return r;
+ }
+
// Rehash if the load factor is too high.
if (size > threshold)
{
@@ -493,25 +505,25 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
// This isn't necessarily prime, but it is an odd number of key/value
// slots, which has a higher probability of fewer collisions.
table = new Object[(old.length * 2) + 2];
- Arrays.fill(table, emptyslot);
size = 0;
threshold = (table.length >>> 3) * 3;
for (int i = old.length - 2; i >= 0; i -= 2)
{
K oldkey = (K) old[i];
- if (oldkey != tombstone && oldkey != emptyslot)
- // Just use put. This isn't very efficient, but it is ok.
- put(oldkey, (V) old[i + 1]);
+ if (oldkey != null)
+ {
+ h = hash(oldkey);
+ table[h] = oldkey;
+ table[h + 1] = old[i + 1];
+ ++size;
+ // No need to update modCount here, we'll do it
+ // just after the loop.
+ }
}
- }
- int h = hash(key);
- if (table[h] == key)
- {
- Object r = table[h + 1];
- table[h + 1] = value;
- return (V) r;
+ // Now that we've resize, recompute the hash value.
+ h = hash(key);
}
// At this point, we add a new mapping.
@@ -536,6 +548,40 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
}
/**
+ * Remove the element at index and update the table to compensate.
+ * This is package-private for use by inner classes.
+ * @param i index of the removed element
+ */
+ final void removeAtIndex(int i)
+ {
+ // This is Algorithm R from Knuth, section 6.4.
+ // Variable names are taken directly from the text.
+ while (true)
+ {
+ table[i] = null;
+ table[i + 1] = null;
+ int j = i;
+ int r;
+ do
+ {
+ i -= 2;
+ if (i < 0)
+ i = table.length - 2;
+ Object key = table[i];
+ if (key == null)
+ return;
+ r = Math.abs(System.identityHashCode(key)
+ % (table.length >> 1)) << 1;
+ }
+ while ((i <= r && r < j)
+ || (r < j && j < i)
+ || (j < i && i <= r));
+ table[j] = table[i];
+ table[j + 1] = table[i + 1];
+ }
+ }
+
+ /**
* Removes from the HashMap and returns the value which is mapped by
* the supplied key. If the key maps to nothing, then the HashMap
* remains unchanged, and <code>null</code> is returned.
@@ -551,14 +597,14 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public V remove(Object key)
{
+ key = xform(key);
int h = hash(key);
if (table[h] == key)
{
modCount++;
size--;
- Object r = table[h + 1];
- table[h] = tombstone;
- table[h + 1] = tombstone;
+ Object r = unxform(table[h + 1]);
+ removeAtIndex(h);
return (V) r;
}
return null;
@@ -613,13 +659,14 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
public boolean remove(Object o)
{
+ o = xform(o);
+ // This approach may look strange, but it is ok.
for (int i = table.length - 1; i > 0; i -= 2)
if (table[i] == o)
{
modCount++;
- table[i - 1] = tombstone;
- table[i] = tombstone;
size--;
+ IdentityHashMap.this.removeAtIndex(i - 1);
return true;
}
return false;
@@ -629,8 +676,31 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
}
/**
+ * Transform a reference from its external form to its internal form.
+ * This is package-private for use by inner classes.
+ */
+ final Object xform(Object o)
+ {
+ if (o == null)
+ o = nullslot;
+ return o;
+ }
+
+ /**
+ * Transform a reference from its internal form to its external form.
+ * This is package-private for use by inner classes.
+ */
+ final Object unxform(Object o)
+ {
+ if (o == nullslot)
+ o = null;
+ return o;
+ }
+
+ /**
* Helper method which computes the hash code, then traverses the table
- * until it finds the key, or the spot where the key would go.
+ * until it finds the key, or the spot where the key would go. the key
+ * must already be in its internal form.
*
* @param key the key to check
* @return the index where the key belongs
@@ -638,36 +708,23 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
* @see #put(Object, Object)
*/
// Package visible for use by nested classes.
- int hash(Object key)
+ final int hash(Object key)
{
- // Implementation note: it is feasible for the table to have no
- // emptyslots, if it is full with entries and tombstones, so we must
- // remember where we started. If we encounter the key or an emptyslot,
- // we are done. If we encounter a tombstone, the key may still be in
- // the array. If we don't encounter the key, we use the first emptyslot
- // or tombstone we encountered as the location where the key would go.
- // By requiring at least 2 key/value slots, and rehashing at 75%
- // capacity, we guarantee that there will always be either an emptyslot
- // or a tombstone somewhere in the table.
int h = Math.abs(System.identityHashCode(key) % (table.length >> 1)) << 1;
- int del = -1;
- int save = h;
- do
+ while (true)
{
- if (table[h] == key)
+ // By requiring at least 2 key/value slots, and rehashing at 75%
+ // capacity, we guarantee that there will always be either an empty
+ // slot somewhere in the table.
+ if (table[h] == key || table[h] == null)
return h;
- if (table[h] == emptyslot)
- break;
- if (table[h] == tombstone && del < 0)
- del = h;
+ // We use linear probing as it is friendlier to the cache and
+ // it lets us efficiently remove entries.
h -= 2;
if (h < 0)
h = table.length - 2;
}
- while (h != save);
-
- return del < 0 ? h : del;
}
/**
@@ -731,10 +788,11 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
loc -= 2;
key = table[loc];
}
- while (key == emptyslot || key == tombstone);
-
- return (I) (type == KEYS ? key : (type == VALUES ? table[loc + 1]
- : new IdentityEntry(loc)));
+ while (key == null);
+
+ return (I) (type == KEYS ? unxform(key)
+ : (type == VALUES ? unxform(table[loc + 1])
+ : new IdentityEntry(loc)));
}
/**
@@ -748,12 +806,11 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
{
if (knownMod != modCount)
throw new ConcurrentModificationException();
- if (loc == table.length || table[loc] == tombstone)
+ if (loc == table.length)
throw new IllegalStateException();
modCount++;
size--;
- table[loc] = tombstone;
- table[loc + 1] = tombstone;
+ removeAtIndex(loc);
knownMod++;
}
} // class IdentityIterator
@@ -797,12 +854,13 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public boolean equals(Object o)
{
- if (knownMod != modCount || table[loc] == tombstone)
+ if (knownMod != modCount)
throw new ConcurrentModificationException();
if (! (o instanceof Map.Entry))
return false;
Map.Entry e = (Map.Entry) o;
- return table[loc] == e.getKey() && table[loc + 1] == e.getValue();
+ return table[loc] == xform(e.getKey())
+ && table[loc + 1] == xform(e.getValue());
}
/**
@@ -814,9 +872,9 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public EK getKey()
{
- if (knownMod != modCount || table[loc] == tombstone)
+ if (knownMod != modCount)
throw new ConcurrentModificationException();
- return (EK) table[loc];
+ return (EK) unxform(table[loc]);
}
/**
@@ -828,9 +886,9 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public EV getValue()
{
- if (knownMod != modCount || table[loc] == tombstone)
+ if (knownMod != modCount)
throw new ConcurrentModificationException();
- return (EV) table[loc + 1];
+ return (EV) unxform(table[loc + 1]);
}
/**
@@ -844,10 +902,10 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public int hashCode()
{
- if (knownMod != modCount || table[loc] == tombstone)
+ if (knownMod != modCount)
throw new ConcurrentModificationException();
- return (System.identityHashCode(table[loc])
- ^ System.identityHashCode(table[loc + 1]));
+ return (System.identityHashCode(unxform(table[loc]))
+ ^ System.identityHashCode(unxform(table[loc + 1])));
}
/**
@@ -860,10 +918,10 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public EV setValue(EV value)
{
- if (knownMod != modCount || table[loc] == tombstone)
+ if (knownMod != modCount)
throw new ConcurrentModificationException();
- EV r = (EV) table[loc + 1];
- table[loc + 1] = value;
+ EV r = (EV) unxform(table[loc + 1]);
+ table[loc + 1] = xform(value);
return r;
}
@@ -877,9 +935,9 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
*/
public String toString()
{
- if (knownMod != modCount || table[loc] == tombstone)
+ if (knownMod != modCount)
throw new ConcurrentModificationException();
- return table[loc] + "=" + table[loc + 1];
+ return unxform(table[loc]) + "=" + unxform(table[loc + 1]);
}
} // class IdentityEntry
@@ -922,10 +980,10 @@ public class IdentityHashMap<K,V> extends AbstractMap<K,V>
for (int i = table.length - 2; i >= 0; i -= 2)
{
Object key = table[i];
- if (key != tombstone && key != emptyslot)
+ if (key != null)
{
- s.writeObject(key);
- s.writeObject(table[i + 1]);
+ s.writeObject(unxform(key));
+ s.writeObject(unxform(table[i + 1]));
}
}
}
diff --git a/java/util/Locale.java b/java/util/Locale.java
index 001c7afde..4c91eeb0a 100644
--- a/java/util/Locale.java
+++ b/java/util/Locale.java
@@ -1,5 +1,5 @@
/* Locale.java -- i18n locales
- Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -188,17 +188,11 @@ public final class Locale implements Serializable, Cloneable
private String variant;
/**
- * This is where the JDK caches its hashcode. This is is only here
- * for serialization purposes. The actual cache is hashcodeCache
+ * This is the cached hashcode. When writing to stream, we write -1.
*
* @serial should be -1 in serial streams
*/
- private int hashcode = -1;
-
- /**
- * This is the cached hashcode.
- */
- private transient int hashcodeCache;
+ private int hashcode;
/**
* Array storing all available locales.
@@ -330,7 +324,7 @@ public final class Locale implements Serializable, Cloneable
this.language = language;
this.country = country;
this.variant = variant;
- hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
+ hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}
/**
@@ -905,7 +899,7 @@ public final class Locale implements Serializable, Cloneable
*/
public int hashCode()
{
- return hashcodeCache;
+ return hashcode;
}
/**
@@ -929,6 +923,24 @@ public final class Locale implements Serializable, Cloneable
}
/**
+ * Write the locale to an object stream.
+ *
+ * @param s the stream to write to
+ * @throws IOException if the write fails
+ * @serialData The first three fields are Strings representing language,
+ * country, and variant. The fourth field is a placeholder for
+ * the cached hashcode, but this is always written as -1, and
+ * recomputed when reading it back.
+ */
+ private void writeObject(ObjectOutputStream s)
+ throws IOException
+ {
+ ObjectOutputStream.PutField fields = s.putFields();
+ fields.put("hashcode", -1);
+ s.defaultWriteObject();
+ }
+
+ /**
* Reads a locale from the input stream.
*
* @param s the stream to read from
@@ -943,6 +955,6 @@ public final class Locale implements Serializable, Cloneable
language = language.intern();
country = country.intern();
variant = variant.intern();
- hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
+ hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}
} // class Locale
diff --git a/java/util/logging/LogManager.java b/java/util/logging/LogManager.java
index 444ab6a26..7ff8c509d 100644
--- a/java/util/logging/LogManager.java
+++ b/java/util/logging/LogManager.java
@@ -318,26 +318,23 @@ public class LogManager
* When adding "foo.bar", the logger "foo.bar.baz" should change
* its parent to "foo.bar".
*/
- if (parent != Logger.root)
+ for (Iterator iter = loggers.keySet().iterator(); iter.hasNext();)
{
- for (Iterator<String> iter = loggers.keySet().iterator();
- iter.hasNext(); )
- {
- Logger possChild = loggers.get(iter.next()).get();
- if ((possChild == null) || (possChild == logger)
- || (possChild.getParent() != parent))
- continue;
-
- if (! possChild.getName().startsWith(name))
- continue;
-
- if (possChild.getName().charAt(name.length()) != '.')
- continue;
-
- possChild.setParent(logger);
- }
+ Logger possChild = (Logger) ((WeakReference) loggers.get(iter.next()))
+ .get();
+ if ((possChild == null) || (possChild == logger)
+ || (possChild.getParent() != parent))
+ continue;
+
+ if (! possChild.getName().startsWith(name))
+ continue;
+
+ if (possChild.getName().charAt(name.length()) != '.')
+ continue;
+
+ possChild.setParent(logger);
}
-
+
return true;
}
diff --git a/javax/management/BadBinaryOpValueExpException.java b/javax/management/BadBinaryOpValueExpException.java
new file mode 100644
index 000000000..5e1f5dbbe
--- /dev/null
+++ b/javax/management/BadBinaryOpValueExpException.java
@@ -0,0 +1,102 @@
+/* BadBinaryOpValueExpException.java -- Thrown by invalid query expressions.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+/**
+ * Thrown when the expression passed to a method for constructing a
+ * query proves to be invalid. This exception is only used internally
+ * by the Java management API and is not exposed to user code.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class BadBinaryOpValueExpException
+ extends Exception
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 5068475589449021227L;
+
+ /**
+ * The value expression that caused the exception.
+ */
+ private ValueExp exp;
+
+ /**
+ * Constructs a new <code>BadBinaryOpValueExpException</code>
+ * using the specified expression to represent the invalid one.
+ *
+ * @param exp the inappropriate value expression.
+ */
+ public BadBinaryOpValueExpException(ValueExp exp)
+ {
+ super();
+ this.exp = exp;
+ }
+
+ /**
+ * Returns the inappropriate value expression associated
+ * with this exception.
+ *
+ * @return the value expression.
+ */
+ public ValueExp getExp()
+ {
+ return exp;
+ }
+
+ /**
+ * Returns a textual representation of this instance. This
+ * is constructed using the class name
+ * (<code>javax.management.BadBinaryOpValueExpException</code>)
+ * and the invalid value expression.
+ *
+ * @return a @link{java.lang.String} instance representing
+ * the instance in textual form.
+ */
+ public String toString()
+ {
+ return getClass().getName()
+ + "[exp=" + exp
+ + "]";
+ }
+
+}
+
diff --git a/javax/management/MBeanServer.java b/javax/management/MBeanServer.java
new file mode 100644
index 000000000..73a28e3b8
--- /dev/null
+++ b/javax/management/MBeanServer.java
@@ -0,0 +1,1199 @@
+/* MBeanServer.java -- Represents a management server.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.io.ObjectInputStream;
+
+import java.util.Set;
+
+import javax.management.loading.ClassLoaderRepository;
+
+/**
+ * <p>
+ * This interface represents a server for management beans,
+ * providing facilities for the creation, registration and
+ * removal of such beans. This interface is central to the
+ * Java management architecture. Users do not usually implement
+ * this class. Instead, implementations of this class
+ * may be obtained using an {@link MBeanServerFactory}.
+ * </p>
+ * <p>
+ * Registering a bean with the server makes its attributes and
+ * operations accessible via the server. Only JMX compliant
+ * beans may be registered with the server. When a bean
+ * is registered or unregistered, an {@link MBeanServerNotification}
+ * is emitted by the server's {@link MBeanServerDelegate}.
+ * Listeners may be registered with this bean in order to
+ * obtain such notifications. It has the {@link ObjectName}
+ * <code>JMImplementation:type=MBeanServerDelegate</code>.
+ * </p>
+ * <p>
+ * Security checks are applied on the methods of the server,
+ * as detailed below, if it is obtained using the
+ * {@link MBeanServerFactory#createMBeanServer()} or
+ * {@link MBeanServerFactory#newMBeanServer()} methods and
+ * {@link System.getSecurityManager()} returns a non-<code>null</code>
+ * value. If a check fails, a {@link SecurityException}
+ * is thrown. Note than the class name used in the exception
+ * is that of the bean, and thus, as a result, an
+ * {@link InstanceNotFoundException}
+ * precludes these security checks, due to the class name
+ * that would be used in the exception being unavailable.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MBeanServer
+ extends MBeanServerConnection
+{
+
+ /**
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the listener which will handle notifications from
+ * the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "addNotificationListener")</code>}.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, NotificationListener listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ * </p>
+ * <p>
+ * The listener that receives notifications will be the one that is
+ * registered with the given name at the time this method is called.
+ * Even if it later unregisters and ceases to use that name, it will
+ * still receive notifications.
+ * </p>
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the name of the listener which will handle
+ * notifications from the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws RuntimeOperationsException if the bean associated with the given
+ * object name is not a
+ * {@link NotificationListener}. This
+ * exception wraps an
+ * {@link IllegalArgumentException}.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "addNotificationListener")</code>}.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, ObjectName listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, Object[], String[])
+ * <code>createMBean(className, name, (Object[]) null,
+ * (String[]) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ * @see #createMBean(String, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ Object[] params, String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, ObjectName, Object[], String)
+ * <code>createMBean(className, name, loaderName, (Object[]) null,
+ * (String) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ * @see #createMBean(String, ObjectName, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply the
+ * use of the <code>instantiate</code>
+ * and <code>registerMBean</code> methods.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName, Object[] params,
+ String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException;
+
+ /**
+ * Deserializes a byte array using the class loader of the specified
+ * management bean as its context.
+ *
+ * @param name the name of the bean whose class loader should be used.
+ * @param data the byte array to be deserialized.
+ * @return the deserialized object stream.
+ * @deprecated {@link #getClassLoaderFor(ObjectName)} should be used
+ * to obtain the class loader of the bean, which can then
+ * be used to perform deserialization in the user's code.
+ * @throws InstanceNotFoundException if the specified bean is not
+ * registered with the server.
+ * @throws OperationsException if any I/O error is thrown by the
+ * deserialization process.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getClassLoaderFor")</code>
+ */
+ ObjectInputStream deserialize(ObjectName name, byte[] data)
+ throws InstanceNotFoundException, OperationsException;
+
+ /**
+ * Deserializes a byte array using the same class loader for its context
+ * as was used to load the given class. This class loader is obtained by
+ * loading the specified class using the {@link
+ * javax.management.loading.ClassLoaderRepository Class Loader Repository}
+ * and then using the class loader of the resulting {@link Class} instance.
+ *
+ * @param name the name of the class which should be loaded to obtain the
+ * class loader.
+ * @param data the byte array to be deserialized.
+ * @return the deserialized object stream.
+ * @deprecated {@link #getClassLoaderRepository} should be used
+ * to obtain the class loading repository, which can then
+ * be used to obtain the {@link Class} instance and deserialize
+ * the array using its class loader.
+ * @throws OperationsException if any I/O error is thrown by the
+ * deserialization process.
+ * @throws ReflectionException if an error occurs in obtaining the
+ * {@link Class} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, null,
+ * "getClassLoaderRepository")</code>
+ */
+ ObjectInputStream deserialize(String name, byte[] data)
+ throws OperationsException, ReflectionException;
+
+ /**
+ * Deserializes a byte array using the same class loader for its context
+ * as was used to load the given class. The name of the class loader to
+ * be used is supplied, and may be <code>null</code> if the server's
+ * class loader should be used instead.
+ *
+ * @param name the name of the class which should be loaded to obtain the
+ * class loader.
+ * @param loader the name of the class loader to use, or <code>null</code>
+ * if the class loader of the server should be used.
+ * @param data the byte array to be deserialized.
+ * @return the deserialized object stream.
+ * @deprecated {@link #getClassLoader(ObjectName} can be used to obtain
+ * the named class loader and deserialize the array.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws OperationsException if any I/O error is thrown by the
+ * deserialization process.
+ * @throws ReflectionException if an error occurs in obtaining the
+ * {@link Class} instance.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, loader,
+ * "getClassLoader")</code>
+ */
+ ObjectInputStream deserialize(String name, ObjectName loader, byte[] data)
+ throws InstanceNotFoundException, ReflectionException,
+ OperationsException;
+
+ /**
+ * Returns the value of the supplied attribute from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param name the name of the attribute to retrieve.
+ * @return the value of the attribute.
+ * @throws AttributeNotFoundException if the attribute could not be
+ * accessed from the bean.
+ * @throws MBeanException if the management bean's accessor throws
+ * an exception.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, name, bean,
+ * "getAttribute")</code>}.
+ * @see DynamicMBean#getAttribute(String)
+ */
+ Object getAttribute(ObjectName bean, String name)
+ throws MBeanException, AttributeNotFoundException,
+ InstanceNotFoundException, ReflectionException;
+
+ /**
+ * Returns the values of the named attributes from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param names the names of the attributes to retrieve.
+ * @return the values of the attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, bean,
+ * "getAttribute")</code>}. Additionally,
+ * for an attribute name, <code>n</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, n, bean,
+ * "getAttribute")</code>} or that attribute will
+ * not be included.
+ *
+ * @see DynamicMBean#getAttributes(String[])
+ */
+ AttributeList getAttributes(ObjectName bean, String[] names)
+ throws InstanceNotFoundException, ReflectionException;
+
+ /**
+ * Returns the specified class loader. If the specified value is
+ * <code>null</code>, then the class loader of the server will be
+ * returned. If <code>l</code> is the requested class loader,
+ * and <code>r</code> is the actual class loader returned, then
+ * either <code>l</code> and <code>r</code> will be identical,
+ * or they will at least return the same class from
+ * {@link ClassLoader#loadClass(String)} for any given string.
+ * They may not be identical due to one or the other
+ * being wrapped in another class loader (e.g. for security).
+ *
+ * @param name the name of the class loader to return.
+ * @return the class loader.
+ * @throws InstanceNotFoundException if the class loader can not
+ * be found.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getClassLoader")</code>
+ */
+ ClassLoader getClassLoader(ObjectName name)
+ throws InstanceNotFoundException;
+
+ /**
+ * Returns the class loader of the specified management bean. If
+ * <code>l</code> is the requested class loader, and <code>r</code>
+ * is the actual class loader returned, then either <code>l</code>
+ * and <code>r</code> will be identical, or they will at least
+ * return the same class from {@link ClassLoader#loadClass(String)}
+ * for any given string. They may not be identical due to one or
+ * the other being wrapped in another class loader (e.g. for
+ * security).
+ *
+ * @param name the name of the bean whose class loader should be
+ * returned.
+ * @return the class loader.
+ * @throws InstanceNotFoundException if the bean is not registered
+ * with the server.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getClassLoaderFor")</code>
+ */
+ ClassLoader getClassLoaderFor(ObjectName name)
+ throws InstanceNotFoundException;
+
+ /**
+ * Returns the class loader repository used by this server.
+ *
+ * @return the class loader repository.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, null,
+ * "getClassLoaderRepository")</code>
+ */
+ ClassLoaderRepository getClassLoaderRepository();
+
+ /**
+ * Returns the default domain this server applies to beans that have
+ * no specified domain.
+ *
+ * @return the default domain.
+ */
+ String getDefaultDomain();
+
+ /**
+ * Returns an array containing all the domains used by beans registered
+ * with this server. The ordering of the array is undefined.
+ *
+ * @return the list of domains.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, name,
+ * "getDomains")</code>}. Additionally,
+ * for an domain, <code>d</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null,
+ * new ObjectName("d:x=x"), "getDomains")</code>}
+ * or that domain will not be included. Note
+ * that "x=x" is an arbitrary key-value pair
+ * provided to satisfy the constructor.
+ * @see ObjectName#getDomain()
+ */
+ String[] getDomains();
+
+ /**
+ * Returns the number of management beans registered with this server.
+ * This may be less than the real number if the caller's access is
+ * restricted.
+ *
+ * @return the number of registered beans.
+ */
+ Integer getMBeanCount();
+
+ /**
+ * Returns information on the given management bean.
+ *
+ * @param name the name of the management bean.
+ * @return an instance of {@link MBeanInfo} for the bean.
+ * @throws IntrospectionException if an exception occurs in examining
+ * the bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurs when trying
+ * to invoke {@link DynamicMBean#getMBeanInfo()}
+ * on the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getMBeanInfo")</code>}.
+ * @see DynamicMBean#getMBeanInfo()
+ */
+ MBeanInfo getMBeanInfo(ObjectName name)
+ throws InstanceNotFoundException, IntrospectionException,
+ ReflectionException;
+
+ /**
+ * Returns the {@link ObjectInstance} created for the specified
+ * management bean on registration.
+ *
+ * @param name the name of the bean.
+ * @return the corresponding {@link ObjectInstance} instance.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "getObjectInstance")</code>
+ * @see #createMBean(String, ObjectName)
+ */
+ ObjectInstance getObjectInstance(ObjectName name)
+ throws InstanceNotFoundException;
+
+ /**
+ * <p>
+ * Creates an instance of the specified class using the list of
+ * class loaders from the {@link
+ * javax.management.loading.ClassLoaderRepository Class Loader
+ * Repository}. The class should have a public constructor
+ * with no arguments. A reference to the new instance is returned,
+ * but the instance is not yet registered with the server.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #instantiate(String, Object[], String[])
+ * <code>instantiate(name, (Object[]) null, (String[]) null)</code>}
+ * with <code>null</code> parameters and signature.
+ * </p>
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @return an instance of the given class.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ * @see #instantiate(String, Object[], String[])
+ */
+ Object instantiate(String name)
+ throws ReflectionException, MBeanException;
+
+ /**
+ * Creates an instance of the specified class using the list of
+ * class loaders from the {@link
+ * javax.management.loading.ClassLoaderRepository Class Loader
+ * Repository}. The class should have a public constructor
+ * matching the supplied signature. A reference to the new
+ * instance is returned, but the instance is not yet
+ * registered with the server.
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @param params the parameters for the constructor.
+ * @param sig the signature of the constructor.
+ * @return an instance of the given class.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ */
+ Object instantiate(String name, Object[] params, String[] sig)
+ throws ReflectionException, MBeanException;
+
+ /**
+ * <p>
+ * Creates an instance of the specified class using the supplied
+ * class loader. If the class loader given is <code>null</code>,
+ * then the class loader of the server will be used. The class
+ * should have a public constructor with no arguments. A reference
+ * to the new instance is returned, but the instance is not yet
+ * registered with the server.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #instantiate(String, ObjectName, Object[], String[])
+ * <code>instantiate(name, loaderName, (Object[]) null,
+ * (String[]) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @param loaderName the name of the class loader to use.
+ * @return an instance of the given class.
+ * @throws InstanceNotFoundException if the class loader is not
+ * registered with the server.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ * @see #instantiate(String, Object[], String[])
+ */
+ Object instantiate(String name, ObjectName loaderName)
+ throws InstanceNotFoundException, ReflectionException,
+ MBeanException;
+
+ /**
+ * Creates an instance of the specified class using the supplied
+ * class loader. If the class loader given is <code>null</code>,
+ * then the class loader of the server will be used. The class
+ * should have a public constructor matching the supplied
+ * signature. A reference to the new instance is returned,
+ * but the instance is not yet registered with the server.
+ *
+ * @param name the name of the class of bean to be instantiated.
+ * @param loaderName the name of the class loader to use.
+ * @param params the parameters for the constructor.
+ * @param sig the signature of the constructor.
+ * @return an instance of the given class.
+ * @throws InstanceNotFoundException if the class loader is not
+ * registered with the server.
+ * @throws ReflectionException if an exception is thrown during
+ * loading the class or calling the
+ * constructor.
+ * @throws MBeanException if the constructor throws an exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, null,
+ * "instantiate")</code>}.
+ */
+ Object instantiate(String name, ObjectName loaderName,
+ Object[] params, String[] sig)
+ throws InstanceNotFoundException, ReflectionException,
+ MBeanException;
+
+ /**
+ * Invokes the supplied operation on the specified management
+ * bean. The class objects specified in the signature are loaded
+ * using the same class loader as was used for the management bean.
+ *
+ * @param bean the management bean whose operation should be invoked.
+ * @param name the name of the operation to invoke.
+ * @param params the parameters of the operation.
+ * @param sig the signature of the operation.
+ * @return the return value of the method.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanException if the method invoked throws an exception.
+ * @throws ReflectionException if an exception is thrown in invoking the
+ * method.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, name, bean,
+ * "invoke")</code>}.
+ * @see DynamicMBean#invoke(String, Object[], String[])
+ */
+ Object invoke(ObjectName bean, String name, Object[] params, String[] sig)
+ throws InstanceNotFoundException, MBeanException,
+ ReflectionException;
+
+ /**
+ * <p>
+ * Returns true if the specified management bean is an instance
+ * of the supplied class.
+ * </p>
+ * <p>
+ * A bean, B, is an instance of a class, C, if either of the following
+ * conditions holds:
+ * </p>
+ * <ul>
+ * <li>The class name in B's {@link MBeanInfo} is equal to the supplied
+ * name.</li>
+ * <li>Both the class of B and C were loaded by the same class loader,
+ * and B is assignable to C.</li>
+ * </ul>
+ *
+ * @param name the name of the management bean.
+ * @param className the name of the class to test if <code>name</code> is
+ * an instance of.
+ * @return true if either B is directly an instance of the named class,
+ * or B is assignable to the class, given that both it and B's
+ * current class were loaded using the same class loader.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "isInstanceOf")</code>
+ */
+ boolean isInstanceOf(ObjectName name, String className)
+ throws InstanceNotFoundException;
+
+ /**
+ * Returns true if the specified management bean is registered with
+ * the server.
+ *
+ * @param name the name of the management bean.
+ * @return true if the bean is registered.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name.
+ */
+ boolean isRegistered(ObjectName name);
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectInstance}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectInstance}s matching the filtered beans.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, name,
+ * "queryMBeans")</code>}. Additionally,
+ * for an bean, <code>b</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, b, name,
+ * "queryMBeans")</code>} or that bean will
+ * not be included. Such an exception may also
+ * arise from the execution of the query, in which
+ * case that particular bean will again be excluded.
+ */
+ Set queryMBeans(ObjectName name, QueryExp query);
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectName}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectName}s matching the filtered beans.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(null, null, name,
+ * "queryNames")</code>}. Additionally,
+ * for an name, <code>n</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, n, name,
+ * "queryNames")</code>} or that name will
+ * not be included. Such an exception may also
+ * arise from the execution of the query, in which
+ * case that particular bean will again be excluded.
+ * Note that these permissions are implied if the
+ * <code>queryMBeans</code> permissions are available.
+ */
+ Set queryNames(ObjectName name, QueryExp query);
+
+ /**
+ * Registers the supplied instance with the server, using the specified
+ * {@link ObjectName}. If the name given is <code>null</code>, then
+ * the bean supplied is expected to implement the {@link MBeanRegistration}
+ * interface and provide the name via the
+ * {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface.
+ *
+ * @param obj the object to register with the server.
+ * @param name the name under which to register the object,
+ * or <code>null</code> if the {@link MBeanRegistration}
+ * interface should be used.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> object.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "registerMBean")</code>}. <code>className</code>
+ * here corresponds to the result of
+ * {@link MBeanInfo#getClassName()} for objects of
+ * this class. If this check succeeds, a check
+ * is also made on its
+ * {@link java.security.ProtectionDomain} to ensure
+ * it implies {@link MBeanTrustPermission(String)
+ * <code>MBeanTrustPermission("register")</code>}.
+ * The use of the {@link MBeanRegistration} interface
+ * results in another {@link MBeanPermission} check
+ * being made on the returned {@link ObjectName}.
+ */
+ ObjectInstance registerMBean(Object obj, ObjectName name)
+ throws InstanceAlreadyExistsException, MBeanRegistrationException,
+ NotCompliantMBeanException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * NotificationListener,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, NotificationListener)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * ObjectName,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name, ObjectName listener)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, ObjectName)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "removeNotificationListener")</code>}.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ ObjectName listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException;
+
+ /**
+ * Sets the value of the specified attribute of the supplied
+ * management bean.
+ *
+ * @param name the name of the management bean.
+ * @param attribute the attribute to set.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws AttributeNotFoundException if the attribute does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws InvalidAttributeValueException if the value is invalid
+ * for this particular
+ * attribute of the bean.
+ * @throws MBeanException if setting the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, name, bean,
+ * "setAttribute")</code>}.
+ * @see #getAttribute(ObjectName, String)
+ * @see DynamicMBean#setAttribute(Attribute)
+ */
+ void setAttribute(ObjectName name, Attribute attribute)
+ throws InstanceNotFoundException, AttributeNotFoundException,
+ InvalidAttributeValueException, MBeanException,
+ ReflectionException;
+
+ /**
+ * Sets the value of each of the specified attributes
+ * of the supplied management bean to that specified by
+ * the {@link Attribute} object. The returned list contains
+ * the attributes that were set and their new values.
+ *
+ * @param name the name of the management bean.
+ * @param attributes the attributes to set.
+ * @return a list of the changed attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * list.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, bean,
+ * "setAttribute")</code>}. Additionally,
+ * for an attribute name, <code>n</code>, the
+ * caller's permission must imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, n, bean,
+ * "setAttribute")</code>} or that attribute will
+ * not be included.
+ * @see #getAttributes(ObjectName, String[])
+ * @see DynamicMBean#setAttributes(AttributeList)
+ */
+ AttributeList setAttributes(ObjectName name, AttributeList attributes)
+ throws InstanceNotFoundException, ReflectionException;
+
+ /**
+ * Unregisters the specified management bean. Following this operation,
+ * the bean instance is no longer accessible from the server via this
+ * name. Prior to unregistering the bean, the
+ * {@link MBeanRegistration#preDeregister()} method will be called if
+ * the bean implements the {@link MBeanRegistration} interface.
+ *
+ * @param name the name of the management bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preDeregister
+ * method.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name or a
+ * request being made to unregister the
+ * {@link MBeanServerDelegate} bean.
+ * @throws SecurityException if a security manager exists and the
+ * caller's permissions don't imply {@link
+ * MBeanPermission(String,String,ObjectName,String)
+ * <code>MBeanPermission(className, null, name,
+ * "unregisterMBean")</code>}.
+ */
+ void unregisterMBean(ObjectName name)
+ throws InstanceNotFoundException, MBeanRegistrationException;
+
+}
diff --git a/javax/management/MBeanServerConnection.java b/javax/management/MBeanServerConnection.java
new file mode 100644
index 000000000..dff03e8c0
--- /dev/null
+++ b/javax/management/MBeanServerConnection.java
@@ -0,0 +1,768 @@
+/* MBeanServerConnection.java -- Represents a connection to a management server.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.io.IOException;
+
+import java.util.Set;
+
+/**
+ * This interface represents a communication mechanism which may
+ * be used to access an MBean server, whether this be local or
+ * remote. The {@link MBeanServer} interface extends this with
+ * additional methods that apply only to local servers.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MBeanServerConnection
+{
+
+ /**
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the listener which will handle notifications from
+ * the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, NotificationListener listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException, IOException;
+
+ /**
+ * <p>
+ * Registers the supplied listener with the specified management
+ * bean. Notifications emitted by the management bean are forwarded
+ * to the listener via the server, which will convert any MBean
+ * references in the source to portable {@link ObjectName}
+ * instances. The notification is otherwise unchanged.
+ * </p>
+ * <p>
+ * The listener that receives notifications will be the one that is
+ * registered with the given name at the time this method is called.
+ * Even if it later unregisters and ceases to use that name, it will
+ * still receive notifications.
+ * </p>
+ *
+ * @param name the name of the management bean with which the listener
+ * should be registered.
+ * @param listener the name of the listener which will handle
+ * notifications from the bean.
+ * @param filter the filter to apply to incoming notifications, or
+ * <code>null</code> if no filtering should be applied.
+ * @param passback an object to be passed to the listener when a
+ * notification is emitted.
+ * @throws InstanceNotFoundException if the name of the management bean
+ * could not be resolved.
+ * @throws RuntimeOperationsException if the bean associated with the given
+ * object name is not a
+ * {@link NotificationListener}. This
+ * exception wraps an
+ * {@link IllegalArgumentException}.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #removeNotificationListener(ObjectName, NotificationListener)
+ * @see #removeNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationBroadcaster#addNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void addNotificationListener(ObjectName name, ObjectName listener,
+ NotificationFilter filter, Object passback)
+ throws InstanceNotFoundException, RuntimeOperationsException, IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, Object[], String[])
+ * <code>createMBean(className, name, (Object[]) null,
+ * (String[]) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #createMBean(String, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * {@link javax.management.loading.ClassLoaderRepository default
+ * loader repository} of the server.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ Object[] params, String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the default constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ * <p>
+ * This method is equivalent to calling {@link
+ * #createMBean(String, ObjectName, ObjectName, Object[], String)
+ * <code>createMBean(className, name, loaderName, (Object[]) null,
+ * (String) null)</code>} with <code>null</code> parameters
+ * and signature.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #createMBean(String, ObjectName, ObjectName, Object[], String[])
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException,
+ IOException;
+
+ /**
+ * <p>
+ * Instantiates a new instance of the specified management bean
+ * using the given constructor and registers it with the server
+ * under the supplied name. The class is loaded using the
+ * given class loader. If this argument is <code>null</code>,
+ * then the same class loader as was used to load the server
+ * is used.
+ * </p>
+ * <p>
+ * If the name supplied is <code>null</code>, then the bean is
+ * expected to implement the {@link MBeanRegistration} interface.
+ * The {@link MBeanRegistration#preRegister preRegister} method
+ * of this interface will be used to obtain the name in this case.
+ * </p>
+ *
+ * @param className the class of the management bean, of which
+ * an instance should be created.
+ * @param name the name to register the new bean with.
+ * @param loaderName the name of the class loader.
+ * @param params the parameters for the bean's constructor.
+ * @param sig the signature of the constructor to use.
+ * @return an {@link ObjectInstance} containing the {@link ObjectName}
+ * and Java class name of the created instance.
+ * @throws ReflectionException if an exception occurs in creating
+ * an instance of the bean.
+ * @throws InstanceAlreadyExistsException if a matching instance
+ * already exists.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preRegister
+ * method.
+ * @throws MBeanException if the bean's constructor throws an exception.
+ * @throws NotCompliantMBeanException if the created bean is not
+ * compliant with the JMX specification.
+ * @throws InstanceNotFoundException if the specified class loader is not
+ * registered with the server.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> class name or object
+ * name or if the object name is a pattern.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ ObjectInstance createMBean(String className, ObjectName name,
+ ObjectName loaderName, Object[] params,
+ String[] sig)
+ throws ReflectionException, InstanceAlreadyExistsException,
+ MBeanRegistrationException, MBeanException,
+ NotCompliantMBeanException, InstanceNotFoundException,
+ IOException;
+
+ /**
+ * Returns the value of the supplied attribute from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param name the name of the attribute to retrieve.
+ * @return the value of the attribute.
+ * @throws AttributeNotFoundException if the attribute could not be
+ * accessed from the bean.
+ * @throws MBeanException if the management bean's accessor throws
+ * an exception.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#getAttribute(String)
+ */
+ Object getAttribute(ObjectName bean, String name)
+ throws MBeanException, AttributeNotFoundException,
+ InstanceNotFoundException, ReflectionException,
+ IOException;
+
+ /**
+ * Returns the values of the named attributes from the specified
+ * management bean.
+ *
+ * @param bean the bean to retrieve the value from.
+ * @param names the names of the attributes to retrieve.
+ * @return the values of the attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception was thrown in trying
+ * to invoke the bean's accessor.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#getAttributes(String[])
+ */
+ AttributeList getAttributes(ObjectName bean, String[] names)
+ throws InstanceNotFoundException, ReflectionException,
+ IOException;
+
+ /**
+ * Returns the default domain this server applies to beans that have
+ * no specified domain.
+ *
+ * @return the default domain.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ String getDefaultDomain()
+ throws IOException;
+
+ /**
+ * Returns an array containing all the domains used by beans registered
+ * with this server. The ordering of the array is undefined.
+ *
+ * @return the list of domains.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see ObjectName#getDomain()
+ */
+ String[] getDomains()
+ throws IOException;
+
+ /**
+ * Returns the number of management beans registered with this server.
+ *
+ * @return the number of registered beans.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ Integer getMBeanCount()
+ throws IOException;
+
+ /**
+ * Returns information on the given management bean.
+ *
+ * @param name the name of the management bean.
+ * @return an instance of {@link MBeanInfo} for the bean.
+ * @throws IntrospectionException if an exception occurs in examining
+ * the bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurs when trying
+ * to invoke {@link DynamicMBean#getMBeanInfo()}
+ * on the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#getMBeanInfo()
+ */
+ MBeanInfo getMBeanInfo(ObjectName name)
+ throws InstanceNotFoundException, IntrospectionException,
+ ReflectionException, IOException;
+
+ /**
+ * Returns the {@link ObjectInstance} created for the specified
+ * management bean on registration.
+ *
+ * @param name the name of the bean.
+ * @return the corresponding {@link ObjectInstance} instance.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #createMBean(String, ObjectName)
+ */
+ ObjectInstance getObjectInstance(ObjectName name)
+ throws InstanceNotFoundException, IOException;
+
+ /**
+ * Invokes the supplied operation on the specified management
+ * bean. The class objects specified in the signature are loaded
+ * using the same class loader as was used for the management bean.
+ *
+ * @param bean the management bean whose operation should be invoked.
+ * @param name the name of the operation to invoke.
+ * @param params the parameters of the operation.
+ * @param sig the signature of the operation.
+ * @return the return value of the method.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanException if the method invoked throws an exception.
+ * @throws ReflectionException if an exception is thrown in invoking the
+ * method.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see DynamicMBean#invoke(String, Object[], String[])
+ */
+ Object invoke(ObjectName bean, String name, Object[] params, String[] sig)
+ throws InstanceNotFoundException, MBeanException,
+ ReflectionException, IOException;
+
+ /**
+ * <p>
+ * Returns true if the specified management bean is an instance
+ * of the supplied class.
+ * </p>
+ * <p>
+ * A bean, B, is an instance of a class, C, if either of the following
+ * conditions holds:
+ * </p>
+ * <ul>
+ * <li>The class name in B's {@link MBeanInfo} is equal to the supplied
+ * name.</li>
+ * <li>Both the class of B and C were loaded by the same class loader,
+ * and B is assignable to C.</li>
+ * </ul>
+ *
+ * @param name the name of the management bean.
+ * @param className the name of the class to test if <code>name</code> is
+ * an instance of.
+ * @return true if either B is directly an instance of the named class,
+ * or B is assignable to the class, given that both it and B's
+ * current class were loaded using the same class loader.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ boolean isInstanceOf(ObjectName name, String className)
+ throws InstanceNotFoundException, IOException;
+
+ /**
+ * Returns true if the specified management bean is registered with
+ * the server.
+ *
+ * @param name the name of the management bean.
+ * @return true if the bean is registered.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ boolean isRegistered(ObjectName name)
+ throws IOException;
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectInstance}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectInstance}s matching the filtered beans.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ Set queryMBeans(ObjectName name, QueryExp query)
+ throws IOException;
+
+ /**
+ * <p>
+ * Returns a set of {@link ObjectName}s matching the specified
+ * criteria. The full set of beans registered with the server
+ * are passed through two filters:
+ * </p>
+ * <ol>
+ * <li>Pattern matching is performed using the supplied
+ * {@link ObjectName}.</li>
+ * <li>The supplied query expression is applied.</li>
+ * </ol>
+ * <p>
+ * If both the object name and the query expression are <code>null</code>,
+ * or the object name has no domain and no key properties,
+ * no filtering will be performed and all beans are returned.
+ * </p>
+ *
+ * @param name an {@link ObjectName} to use as a filter.
+ * @param query a query expression to apply to each of the beans that match
+ * the given object name.
+ * @return a set of {@link ObjectName}s matching the filtered beans.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ Set queryNames(ObjectName name, QueryExp query)
+ throws IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * NotificationListener,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, NotificationListener)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. This includes all
+ * combinations of filters and passback objects registered for
+ * this listener. For more specific removal of listeners, see
+ * {@link #removeNotificationListener(ObjectName,
+ * ObjectName,NotificationFilter,Object)}
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see NotificationBroadcaster#removeNotificationListener(NotificationListener)
+ */
+ void removeNotificationListener(ObjectName name, ObjectName listener)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from the supplied bean. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(ObjectName, ObjectName)}.
+ *
+ * @param name the name of the management bean from which the
+ * listener should be removed.
+ * @param listener the name of the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws InstanceNotFoundException if a name doesn't match a registered
+ * bean.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with the bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #addNotificationListener(ObjectName, NotificationListener,
+ * NotificationFilter, Object)
+ * @see NotificationEmitter#removeNotificationListener(NotificationListener,
+ * NotificationFilter,
+ * Object)
+ */
+ void removeNotificationListener(ObjectName name,
+ ObjectName listener,
+ NotificationFilter filter,
+ Object passback)
+ throws InstanceNotFoundException, ListenerNotFoundException,
+ IOException;
+
+ /**
+ * Sets the value of the specified attribute of the supplied
+ * management bean.
+ *
+ * @param name the name of the management bean.
+ * @param attribute the attribute to set.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws AttributeNotFoundException if the attribute does not
+ * correspond to an attribute
+ * of the bean.
+ * @throws InvalidAttributeValueException if the value is invalid
+ * for this particular
+ * attribute of the bean.
+ * @throws MBeanException if setting the attribute causes
+ * the bean to throw an exception (which
+ * becomes the cause of this exception).
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * name.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #getAttribute(ObjectName, String)
+ * @see DynamicMBean#setAttribute(Attribute)
+ */
+ void setAttribute(ObjectName name, Attribute attribute)
+ throws InstanceNotFoundException, AttributeNotFoundException,
+ InvalidAttributeValueException, MBeanException,
+ ReflectionException, IOException;
+
+ /**
+ * Sets the value of each of the specified attributes
+ * of the supplied management bean to that specified by
+ * the {@link Attribute} object. The returned list contains
+ * the attributes that were set and their new values.
+ *
+ * @param name the name of the management bean.
+ * @param attributes the attributes to set.
+ * @return a list of the changed attributes.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws ReflectionException if an exception occurred in trying
+ * to use the reflection interface
+ * to lookup the attribute. The
+ * thrown exception is the cause of
+ * this exception.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean or attribute
+ * list.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ * @see #getAttributes(ObjectName, String[])
+ * @see DynamicMBean#setAttributes(AttributeList)
+ */
+ AttributeList setAttributes(ObjectName name, AttributeList attributes)
+ throws InstanceNotFoundException, ReflectionException,
+ IOException;
+
+ /**
+ * Unregisters the specified management bean. Following this operation,
+ * the bean instance is no longer accessible from the server via this
+ * name. Prior to unregistering the bean, the
+ * {@link MBeanRegistration#preDeregister()} method will be called if
+ * the bean implements the {@link MBeanRegistration} interface.
+ *
+ * @param name the name of the management bean.
+ * @throws InstanceNotFoundException if the bean can not be found.
+ * @throws MBeanRegistrationException if an exception occurs in
+ * calling the preDeregister
+ * method.
+ * @throws RuntimeOperationsException if an {@link IllegalArgumentException}
+ * is thrown by the server due to a
+ * <code>null</code> bean name or a
+ * request being made to unregister the
+ * {@link MBeanServerDelegate} bean.
+ * @throws IOException if an I/O error occurred in communicating with
+ * the bean server.
+ */
+ void unregisterMBean(ObjectName name)
+ throws InstanceNotFoundException, MBeanRegistrationException,
+ IOException;
+
+}
diff --git a/javax/management/MBeanServerDelegate.java b/javax/management/MBeanServerDelegate.java
new file mode 100644
index 000000000..bf3f5f894
--- /dev/null
+++ b/javax/management/MBeanServerDelegate.java
@@ -0,0 +1,308 @@
+/* MBeanServerDelegate.java -- The management server delegate.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import gnu.classpath.ListenerData;
+import gnu.classpath.SystemProperties;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Provides an implementation of a delegate bean, which is associated
+ * with a management server. The delegate bean is responsible
+ * for providing metadata about the server and handling the
+ * registration and deregistration notifications.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanServerDelegate
+ implements MBeanServerDelegateMBean, NotificationEmitter
+{
+
+ /**
+ * The identifier of the server associated with this delegate.
+ */
+ private String id;
+
+ /**
+ * The listeners registered with the delegate.
+ */
+ private List listeners;
+
+ /**
+ * The sequence identifier used by the delegate.
+ */
+ private long seqNo;
+
+ /**
+ * Default constructor which generates the id.
+ */
+ public MBeanServerDelegate()
+ {
+ String hostName;
+ try
+ {
+ hostName = InetAddress.getLocalHost().getHostName();
+ }
+ catch (UnknownHostException e)
+ {
+ hostName = "Unknown host";
+ }
+ id = hostName + "_" + new Date().getTime();
+ }
+
+ /**
+ * Registers the specified listener as a new recipient of
+ * notifications from the delegate. If non-null, the filter
+ * argument will be used to select which notifications are
+ * delivered. The supplied object will also be passed to
+ * the recipient with each notification. This should not
+ * be modified by the broadcaster, but instead should be
+ * passed unmodified to the listener.
+ *
+ * @param listener the new listener, who will receive
+ * notifications from this broadcasting bean.
+ * @param filter a filter to determine which notifications are
+ * delivered to the listener, or <code>null</code>
+ * if no filtering is required.
+ * @param passback an object to be passed to the listener with
+ * each notification.
+ * @throws IllegalArgumentException if <code>listener</code> is
+ * <code>null</code>.
+ * @see #removeNotificationListener(NotificationListener)
+ */
+ public void addNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws IllegalArgumentException
+ {
+ if (listener == null)
+ throw new IllegalArgumentException("A null listener was supplied.");
+ if (listeners == null)
+ listeners = new ArrayList();
+ listeners.add(new ListenerData(listener, filter, passback));
+ }
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation name.
+ */
+ public String getImplementationName()
+ {
+ return "GNU JMX";
+ }
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation vendor.
+ */
+ public String getImplementationVendor()
+ {
+ return "The GNU Classpath Project";
+ }
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation version.
+ */
+ public String getImplementationVersion()
+ {
+ return SystemProperties.getProperty("gnu.classpath.version");
+ }
+
+ /**
+ * Returns the unique identifier for this management server.
+ *
+ * @return the unique id of the server.
+ */
+ public String getMBeanServerId()
+ {
+ return id;
+ }
+
+ /**
+ * Returns an array describing the notifications this
+ * bean may send to its registered listeners. Ideally, this
+ * array should be complete, but in some cases, this may
+ * not be possible. However, be aware that some listeners
+ * may expect this to be so.
+ *
+ * @return the array of possible notifications.
+ */
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ return new MBeanNotificationInfo[]
+ {
+ new MBeanNotificationInfo(new String[]
+ {
+ MBeanServerNotification.REGISTRATION_NOTIFICATION,
+ MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
+ },
+ MBeanServerNotification.class.getName(),
+ "Server registration notifications")
+ };
+ }
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification name.
+ */
+ public String getSpecificationName()
+ {
+ return "JMX";
+ }
+
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification vendor.
+ */
+ public String getSpecificationVendor()
+ {
+ return "Sun Microsystems";
+ }
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification version.
+ */
+ public String getSpecificationVersion()
+ {
+ return "1.2";
+ }
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from this bean. This includes all combinations
+ * of filters and passback objects registered for this listener.
+ * For more specific removal of listeners, see
+ * {@link #removeNotificationListener(NotificationListener,
+ * NotificationFilter, java.lang.Object)}
+ *
+ * @param listener the listener to remove.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with this bean.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ */
+ public void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException
+ {
+ Iterator it = listeners.iterator();
+ boolean foundOne = false;
+ while (it.hasNext())
+ {
+ ListenerData data = (ListenerData) it.next();
+ if (data.getListener() == listener)
+ {
+ it.remove();
+ foundOne = true;
+ }
+ }
+ if (!foundOne)
+ throw new ListenerNotFoundException("The specified listener, " + listener +
+ "is not registered with this bean.");
+ }
+
+ /**
+ * Removes the specified listener from the list of recipients
+ * of notifications from this delegate. Only the first instance with
+ * the supplied filter and passback object is removed.
+ * <code>null</code> is used as a valid value for these parameters,
+ * rather than as a way to remove all registration instances for
+ * the specified listener; for this behaviour instead, see
+ * {@link #removeNotificationListener(NotificationListener)}.
+ *
+ * @param listener the listener to remove.
+ * @param filter the filter of the listener to remove.
+ * @param passback the passback object of the listener to remove.
+ * @throws ListenerNotFoundException if the specified listener
+ * is not registered with this bean.
+ * @see #addNotificationListener(NotificationListener, NotificationFilter,
+ * java.lang.Object)
+ * @see #removeNotificationListener(NotificationListener)
+ */
+ public void removeNotificationListener(NotificationListener listener,
+ NotificationFilter filter,
+ Object passback)
+ throws ListenerNotFoundException
+ {
+ if (!(listeners.remove(new ListenerData(listener, filter, passback))))
+ {
+ throw new ListenerNotFoundException("The specified listener, " + listener +
+ " with filter " + filter +
+ "and passback " + passback +
+ ", is not registered with this bean.");
+ }
+ }
+
+ /**
+ * Allows the server to use the delegate to send a notification.
+ * If the supplied notification has a sequence number <= 0, then
+ * it is replaced with the delegate's own sequence number.
+ *
+ * @param notification the notification to send.
+ */
+ public void sendNotification(Notification notification)
+ {
+ if (notification.getSequenceNumber() <= 0)
+ notification.setSequenceNumber(++seqNo);
+ Iterator it = listeners.iterator();
+ while (it.hasNext())
+ {
+ ListenerData ldata = (ListenerData) it.next();
+ NotificationFilter filter = ldata.getFilter();
+ if (filter == null || filter.isNotificationEnabled(notification))
+ ldata.getListener().handleNotification(notification, ldata.getPassback());
+ }
+ }
+
+}
diff --git a/javax/management/MBeanServerDelegateMBean.java b/javax/management/MBeanServerDelegateMBean.java
new file mode 100644
index 000000000..aa7b27300
--- /dev/null
+++ b/javax/management/MBeanServerDelegateMBean.java
@@ -0,0 +1,101 @@
+/* MBeanServerDelegateMBean.java -- The interface of a management server delegate.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+/**
+ * Defines the interface for the delegate bean associated
+ * with a management server. The delegate bean is responsible
+ * for providing metadata about the server and handling the
+ * registration and deregistration notifications.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface MBeanServerDelegateMBean
+{
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation name.
+ */
+ String getImplementationName();
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation vendor.
+ */
+ String getImplementationVendor();
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) implementation.
+ *
+ * @return the implementation version.
+ */
+ String getImplementationVersion();
+
+ /**
+ * Returns the unique identifier for this management server.
+ *
+ * @return the unique id of the server.
+ */
+ String getMBeanServerId();
+
+ /**
+ * Returns the name of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification name.
+ */
+ String getSpecificationName();
+
+ /**
+ * Returns the vendor of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification vendor.
+ */
+ String getSpecificationVendor();
+
+ /**
+ * Returns the version of this Java Management eXtensions (JMX) specification.
+ *
+ * @return the specification version.
+ */
+ String getSpecificationVersion();
+
+}
diff --git a/javax/management/MBeanServerNotification.java b/javax/management/MBeanServerNotification.java
new file mode 100644
index 000000000..820fd61b3
--- /dev/null
+++ b/javax/management/MBeanServerNotification.java
@@ -0,0 +1,103 @@
+/* MBeanServerNotification.java -- The registration notification.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+/**
+ * The notification emitted by a management server on a registration
+ * or de-registration event. Events are emitted via the delegate
+ * management bean of the server. Other objects can listen for
+ * such events by registering their interest with the delegate
+ * bean. The bean can be obtained via the {@link ObjectName}
+ * <code>JMImplementation:type=MBeanServerDelegate</code>.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class MBeanServerNotification
+ extends Notification
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = 2876477500475969677L;
+
+ /**
+ * Notification type for the registration event.
+ */
+ public static final String REGISTRATION_NOTIFICATION = "JMX.mbean.registered";
+
+ /**
+ * Notification type for the de-registration event.
+ */
+ public static final String UNREGISTRATION_NOTIFICATION = "JMX.mbean.unregistered";
+
+ /**
+ * The name of the bean which forms the subject of this notification.
+ */
+ private ObjectName objectName;
+
+ /**
+ * Constructs a new {@link MBeanServerNotification} of the specified
+ * type for an event relating to the supplied bean, with the given
+ * source and sequence number.
+ *
+ * @param type the type of notification (registration or de-registration).
+ * @param source the source of the notification.
+ * @param seqNo the sequence number of this notification, used to order
+ * multiple such notifications.
+ * @param name the name of the bean concerned by this event.
+ */
+ public MBeanServerNotification(String type, Object source, long seqNo,
+ ObjectName name)
+ {
+ super(type, source, seqNo);
+ objectName = name;
+ }
+
+ /**
+ * Returns the name of the bean this notification concerns.
+ *
+ * @return the name of the bean.
+ */
+ public ObjectName getMBeanName()
+ {
+ return objectName;
+ }
+
+}
diff --git a/javax/management/ObjectInstance.java b/javax/management/ObjectInstance.java
new file mode 100644
index 000000000..df364cffc
--- /dev/null
+++ b/javax/management/ObjectInstance.java
@@ -0,0 +1,147 @@
+/* ObjectInstance.java -- Represent the bean instance used by a server.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.io.Serializable;
+
+/**
+ * A simple class used to link a bean instance to its class name.
+ * If the bean is a {@link DynamicMBean}, the class name may be
+ * obtained using {@link MBeanInfo#getClassName()}.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ObjectInstance
+ implements Serializable
+{
+
+ /**
+ * Compatible with JDK 1.5
+ */
+ private static final long serialVersionUID = -4099952623687795850L;
+
+ /**
+ * The name of the bean.
+ */
+ private ObjectName name;
+
+ /**
+ * The class name of the bean.
+ */
+ private String className;
+
+ /**
+ * Constructs a new {@link ObjectInstance} for the specified bean
+ * with the supplied class name. The class name should include
+ * the full package name.
+ *
+ * @param name the name of the bean.
+ * @param className the class name of the bean.
+ */
+ public ObjectInstance(ObjectName name, String className)
+ {
+ this.name = name;
+ this.className = className;
+ }
+
+ /**
+ * Constructs a new {@link ObjectInstance} for the specified bean
+ * with the supplied class name. The class name should include
+ * the full package name.
+ *
+ * @param name the name of the bean.
+ * @param className the class name of the bean.
+ * @throws MalformedObjectNameException if the name of the bean
+ * does not match the syntax
+ * of an {@link ObjectName}.
+ */
+ public ObjectInstance(String name, String className)
+ throws MalformedObjectNameException
+ {
+ this(new ObjectName(name), className);
+ }
+
+ /**
+ * Returns true if the supplied object is also an {@link ObjectInstance}
+ * with the same bean and class name.
+ *
+ * @param obj the object to compare.
+ * @return true if the the supplied object is equal to <code>this</code>.
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof ObjectInstance))
+ return false;
+ ObjectInstance i = (ObjectInstance) obj;
+ return (i.getClassName().equals(className) &&
+ i.getObjectName().equals(name));
+ }
+
+ /**
+ * Returns the class name of the bean.
+ *
+ * @return the class name.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Returns the name of the bean.
+ *
+ * @return the name of the bean.
+ */
+ public ObjectName getObjectName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns a hash code for this instance. This is calculated as
+ * the sum of the hashcodes for the bean's name and the class name.
+ *
+ * @return the hash code of this instance.
+ */
+ public int hashCode()
+ {
+ return name.hashCode() + className.hashCode();
+ }
+
+}
diff --git a/javax/management/ObjectName.java b/javax/management/ObjectName.java
new file mode 100644
index 000000000..0e6bf2fd9
--- /dev/null
+++ b/javax/management/ObjectName.java
@@ -0,0 +1,775 @@
+/* ObjectName.java -- Represent the name of a bean, or a pattern for a name.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.io.Serializable;
+
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * <p>
+ * An {@link ObjectName} instance represents the name of a management
+ * bean, or a pattern which may match the name of one or more
+ * management beans. Patterns are distinguished from names by the
+ * presence of the '?' and '*' characters (which match a single
+ * character and a series of zero or more characters, respectively).
+ * </p>
+ * <p>
+ * Each name begins with a domain element, which is terminated by
+ * a ':' character. The domain may be empty. If so, it will be
+ * replaced by the default domain of the bean server in certain
+ * contexts. The domain is a pattern, if it contains either '?'
+ * or '*'. To avoid collisions, it is usual to use reverse
+ * DNS names for the domain, as in Java package and property names.
+ * </p>
+ * <p>
+ * Following the ':' character is a series of properties. The list
+ * is separated by commas, and largely consists of unordered key-value
+ * pairs, separated by an equals sign ('='). At most one element may
+ * be an asterisk ('*'), which turns the {@link ObjectName} instance
+ * into a <emph>property pattern</emph>. In this situation, the pattern
+ * matches a name if the name contains at least those key-value pairs
+ * given and has the same domain.
+ * </p>
+ * <p>
+ * A <emph>key</emph> is a string of characters which doesn't include
+ * any of those used as delimiters or in patterns (':', '=', ',', '?'
+ * and '*'). Keys must be unique.
+ * </p>
+ * <p>
+ * A value may be <emph>quoted</emph> or <emph>unquoted</emph>. Unquoted
+ * values obey the same rules as given for keys above. Quoted values are
+ * surrounded by quotation marks ("), and use a backslash ('\') character
+ * to include quotes ('\"'), backslashes ('\\'), newlines ('\n'), and
+ * the pattern characters ('\?' and '\*'). The quotes and backslashes
+ * (after expansion) are considered part of the value.
+ * </p>
+ * <p>
+ * Spaces are maintained within the different parts of the name. Thus,
+ * '<code>domain: key1 = value1 </code>' has a key ' key1 ' with value
+ * ' value1 '. Newlines are disallowed, except where escaped in quoted
+ * values.
+ * </p>
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public class ObjectName
+ implements Serializable, QueryExp
+{
+
+ /**
+ * The domain of the name.
+ */
+ private String domain;
+
+ /**
+ * The properties, as key-value pairs.
+ */
+ private TreeMap properties;
+
+ /**
+ * The properties as a string (stored for ordering).
+ */
+ private String propertyListString;
+
+ /**
+ * True if this object name is a property pattern.
+ */
+ private boolean propertyPattern;
+
+ /**
+ * The management server associated with this object name.
+ */
+ private MBeanServer server;
+
+ /**
+ * Constructs an {@link ObjectName} instance from the given string,
+ * which should be of the form
+ * &lt;domain&gt;:&lt;properties&gt;&lt;wild&gt;. &lt;domain&gt;
+ * represents the domain section of the name. &lt;properties&gt;
+ * represents the key-value pairs, as returned by {@link
+ * #getKeyPropertyListString()}. &lt;wild&gt; is the optional
+ * asterisk present in the property list. If the string doesn't
+ * represent a property pattern, it will be empty. If it does,
+ * it will be either ',*' or '*', depending on whether other
+ * properties are present or not, respectively.
+ *
+ * @param name the string to use to construct this instance.
+ * @throws MalformedObjectNameException if the string is of the
+ * wrong format.
+ * @throws NullPointerException if <code>name</code> is
+ * <code>null</code>.
+ */
+ public ObjectName(String name)
+ throws MalformedObjectNameException
+ {
+ int domainSep = name.indexOf(':');
+ if (domainSep == -1)
+ throw new MalformedObjectNameException("No domain separator was found.");
+ domain = name.substring(0, domainSep);
+ String rest = name.substring(domainSep + 1);
+ if (rest.equals("*"))
+ propertyPattern = true;
+ else
+ {
+ if (rest.endsWith(",*"))
+ {
+ propertyPattern = true;
+ propertyListString = rest.substring(0, rest.length() - 2);
+ }
+ else
+ propertyListString = rest;
+ String[] pairs = propertyListString.split(",");
+ if (pairs.length == 0 && !isPattern())
+ throw new MalformedObjectNameException("A name that is not a " +
+ "pattern must contain at " +
+ "least one key-value pair.");
+ properties = new TreeMap();
+ for (int a = 0; a < pairs.length; ++a)
+ {
+ int sep = pairs[a].indexOf('=');
+ String key = pairs[a].substring(0, sep);
+ if (properties.containsKey(key))
+ throw new MalformedObjectNameException("The same key occurs " +
+ "more than once.");
+ properties.put(key, pairs[a].substring(sep + 1));
+ }
+ }
+ checkComponents();
+ }
+
+ /**
+ * Constructs an {@link ObjectName} instance using the given
+ * domain and the one specified property.
+ *
+ * @param domain the domain part of the object name.
+ * @param key the key of the property.
+ * @param value the value of the property.
+ * @throws MalformedObjectNameException the domain, key or value
+ * contains an illegal
+ * character or the value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if one of the parameters is
+ * <code>null</code>.
+ */
+ public ObjectName(String domain, String key, String value)
+ throws MalformedObjectNameException
+ {
+ this.domain = domain;
+ properties = new TreeMap();
+ properties.put(key, value);
+ checkComponents();
+ }
+
+ /**
+ * Constructs an {@link ObjectName} instance using the given
+ * domain and properties.
+ *
+ * @param domain the domain part of the object name.
+ * @param properties the key-value property pairs.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if one of the parameters is
+ * <code>null</code>.
+ */
+ public ObjectName(String domain, Hashtable properties)
+ throws MalformedObjectNameException
+ {
+ this.domain = domain;
+ this.properties.putAll(properties);
+ checkComponents();
+ }
+
+ /**
+ * Checks the legality of the domain and the properties.
+ *
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ */
+ private void checkComponents()
+ throws MalformedObjectNameException
+ {
+ if (domain.indexOf(':') != -1)
+ throw new MalformedObjectNameException("The domain includes a ':' " +
+ "character.");
+ if (domain.indexOf('\n') != -1)
+ throw new MalformedObjectNameException("The domain includes a newline " +
+ "character.");
+ char[] chars = new char[] { ':', ',', '*', '?', '=' };
+ Iterator i = properties.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ String key = (String) entry.getKey();
+ for (int a = 0; a < chars.length; ++a)
+ if (key.indexOf(chars[a]) != -1)
+ throw new MalformedObjectNameException("A key contains a '" +
+ chars[a] + "' " +
+ "character.");
+ String value = (String) entry.getValue();
+ int quote = value.indexOf('"');
+ if (quote == 0)
+ {
+ try
+ {
+ unquote(value);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new MalformedObjectNameException("The quoted value is " +
+ "invalid.");
+ }
+ }
+ else if (quote != -1)
+ throw new MalformedObjectNameException("A value contains " +
+ "a '\"' character.");
+ else
+ {
+ for (int a = 0; a < chars.length; ++a)
+ if (value.indexOf(chars[a]) != -1)
+ throw new MalformedObjectNameException("A value contains " +
+ "a '" + chars[a] + "' " +
+ "character.");
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * Attempts to find a match between this name and the one supplied.
+ * The following criteria are used:
+ * </p>
+ * <ul>
+ * <li>If the supplied name is a pattern, <code>false</code> is
+ * returned.</li>
+ * <li>If this name is a pattern, this method returns <code>true</code>
+ * if the supplied name matches the pattern.</li>
+ * <li>If this name is not a pattern, the result of
+ * <code>equals(name)</code> is returned.
+ * </ul>
+ *
+ * @param name the name to find a match with.
+ * @return true if the name either matches this pattern or is
+ * equivalent to this name under the criteria of
+ * {@link #equals(java.lang.Object)}
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public boolean apply(ObjectName name)
+ {
+ if (name.isPattern())
+ return false;
+ if (isPattern())
+ {
+ boolean domainMatch, propMatch;
+ if (isDomainPattern())
+ {
+ String oDomain = name.getDomain();
+ int oLength = oDomain.length();
+ for (int a = 0; a < domain.length(); ++a)
+ {
+ char n = domain.charAt(a);
+ if (oLength == a && n != '*')
+ return false;
+ if (n == '?')
+ continue;
+ if (n == '*')
+ if ((a + 1) < domain.length())
+ {
+ if (oLength == a)
+ return false;
+ char next;
+ do
+ {
+ next = domain.charAt(a + 1);
+ } while (next == '*');
+ if (next == '?')
+ continue;
+ int pos = a;
+ while (oDomain.charAt(pos) != next)
+ {
+ ++pos;
+ if (pos == oLength)
+ return false;
+ }
+ }
+ if (n != oDomain.charAt(a))
+ return false;
+ }
+ domainMatch = true;
+ }
+ else
+ domainMatch = domain.equals(name.getDomain());
+ if (isPropertyPattern())
+ {
+ Hashtable oProps = name.getKeyPropertyList();
+ Iterator i = properties.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ String key = (String) entry.getKey();
+ if (!(oProps.containsKey(key)))
+ return false;
+ String val = (String) entry.getValue();
+ if (!(val.equals(oProps.get(key))))
+ return false;
+ }
+ propMatch = true;
+ }
+ else
+ propMatch =
+ getCanonicalKeyPropertyListString().equals
+ (name.getCanonicalKeyPropertyListString());
+ return domainMatch && propMatch;
+ }
+ return equals(name);
+ }
+
+ /**
+ * Compares the specified object with this one. The two
+ * are judged to be equivalent if the given object is an
+ * instance of {@link ObjectName} and has an equal canonical
+ * form (as returned by {@link #getCanonicalName()}).
+ *
+ * @param obj the object to compare with this.
+ * @return true if the object is also an {@link ObjectName}
+ * with an equivalent canonical form.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ObjectName)
+ {
+ ObjectName o = (ObjectName) obj;
+ return getCanonicalName().equals(o.getCanonicalName());
+ }
+ return false;
+ }
+
+ /**
+ * Returns the property list in canonical form. The keys
+ * are ordered using the lexicographic ordering used by
+ * {@link java.lang.String#compareTo(java.lang.Object)}.
+ *
+ * @return the property list, with the keys in lexicographic
+ * order.
+ */
+ public String getCanonicalKeyPropertyListString()
+ {
+ StringBuilder builder = new StringBuilder();
+ Iterator i = properties.entrySet().iterator();
+ while (i.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ builder.append(entry.getKey() + "=" + entry.getValue());
+ if (i.hasNext())
+ builder.append(",");
+ }
+ return builder.toString();
+ }
+
+ /**
+ * <p>
+ * Returns the name as a string in canonical form. More precisely,
+ * this returns a string of the format
+ * &lt;domain&gt;:&lt;properties&gt;&lt;wild&gt;. &lt;properties&gt;
+ * is the same value as returned by
+ * {@link #getCanonicalKeyPropertyListString()}. &lt;wild&gt;
+ * is:
+ * </p>
+ * <ul>
+ * <li>an empty string, if the object name is not a property pattern.</li>
+ * <li>'*' if &lt;properties&gt; is empty.</li>
+ * <li>',*' if there is at least one key-value pair.</li>
+ * </ul>
+ *
+ * @return the canonical string form of the object name, as specified
+ * above.
+ */
+ public String getCanonicalName()
+ {
+ return domain + ":" +
+ getCanonicalKeyPropertyListString() +
+ (isPropertyPattern() ? (properties.isEmpty() ? "*" : ",*") : "");
+ }
+
+ /**
+ * Returns the domain part of the object name.
+ *
+ * @return the domain.
+ */
+ public String getDomain()
+ {
+ return domain;
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance that is substitutable for the
+ * one given. The instance returned may be a subclass of {@link ObjectName},
+ * but is not guaranteed to be of the same type as the given name, if that
+ * should also turn out to be a subclass. The returned instance may or may
+ * not be equivalent to the one given. The purpose of this method is to provide
+ * an instance of {@link ObjectName} with a well-defined semantics, such as may
+ * be used in cases where the given name is not trustworthy.
+ *
+ * @param name the {@link ObjectName} to provide a substitute for.
+ * @return a substitute for the given name, which may or may not be a subclass
+ * of {@link ObjectName}. In either case, the returned object is
+ * guaranteed to have the semantics defined here.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(ObjectName name)
+ {
+ try
+ {
+ return new ObjectName(name.getCanonicalName());
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw (InternalError)
+ (new InternalError("The canonical name of " +
+ "the given name is invalid.").initCause(e));
+ }
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance for the specified name, represented
+ * as a {@link java.lang.String}. The instance returned may be a subclass of
+ * {@link ObjectName} and may or may not be equivalent to earlier instances
+ * returned by this method for the same string.
+ *
+ * @param name the {@link ObjectName} to provide an instance of.
+ * @return a instance for the given name, which may or may not be a subclass
+ * of {@link ObjectName}.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(String name)
+ throws MalformedObjectNameException
+ {
+ return new ObjectName(name);
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance for the specified name, represented
+ * as a series of {@link java.lang.String} objects for the domain and a single
+ * property, as a key-value pair. The instance returned may be a subclass of
+ * {@link ObjectName} and may or may not be equivalent to earlier instances
+ * returned by this method for the same parameters.
+ *
+ * @param domain the domain part of the object name.
+ * @param key the key of the property.
+ * @param value the value of the property.
+ * @return a instance for the given name, which may or may not be a subclass
+ * of {@link ObjectName}.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(String domain, String key, String value)
+ throws MalformedObjectNameException
+ {
+ return new ObjectName(domain, key, value);
+ }
+
+ /**
+ * Returns an {@link ObjectName} instance for the specified name, represented
+ * as a domain {@link java.lang.String} and a table of properties. The
+ * instance returned may be a subclass of {@link ObjectName} and may or may
+ * not be equivalent to earlier instances returned by this method for the
+ * same string.
+ *
+ * @param domain the domain part of the object name.
+ * @param properties the key-value property pairs.
+ * @return a instance for the given name, which may or may not be a subclass
+ * of {@link ObjectName}.
+ * @throws MalformedObjectNameException the domain, a key or a value
+ * contains an illegal
+ * character or a value
+ * does not follow the quoting
+ * specifications.
+ * @throws NullPointerException if <code>name</code> is <code>null</code>.
+ */
+ public static ObjectName getInstance(String domain, Hashtable properties)
+ throws MalformedObjectNameException
+ {
+ return new ObjectName(domain, properties);
+ }
+
+ /**
+ * Returns the property value corresponding to the given key.
+ *
+ * @param key the key of the property to be obtained.
+ * @return the value of the specified property.
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ */
+ public String getKeyProperty(String key)
+ {
+ if (key == null)
+ throw new NullPointerException("Null key given in request for a value.");
+ return (String) properties.get(key);
+ }
+
+ /**
+ * Returns the properties in a {@link java.util.Hashtable}. The table
+ * contains each of the properties as keys mapped to their value. The
+ * returned table may be unmodifiable. If the case that the table is
+ * modifiable, changes made to it will not be reflected in the object
+ * name.
+ *
+ * @return a {@link java.util.Hashtable}, containing each of the object
+ * name's properties.
+ */
+ public Hashtable getKeyPropertyList()
+ {
+ return (Hashtable) Collections.unmodifiableMap(new Hashtable(properties));
+ }
+
+ /**
+ * Returns a {@link java.lang.String} representation of the property
+ * list. If the object name was created using {@link
+ * ObjectName(String)}, then this string will contain the properties
+ * in the same order they were given in at creation.
+ *
+ * @return the property list.
+ */
+ public String getKeyPropertyListString()
+ {
+ if (propertyListString != null)
+ return propertyListString;
+ return getCanonicalKeyPropertyListString();
+ }
+
+ /**
+ * Returns a hash code for this object name. This is calculated as the
+ * summation of the hash codes of the domain and the properties.
+ *
+ * @return a hash code for this object name.
+ */
+ public int hashCode()
+ {
+ return domain.hashCode() + properties.hashCode();
+ }
+
+ /**
+ * Returns true if the domain of this object name is a pattern.
+ * This is the case if it contains one or more wildcard characters
+ * ('*' or '?').
+ *
+ * @return true if the domain is a pattern.
+ */
+ public boolean isDomainPattern()
+ {
+ return domain.contains("?") || domain.contains("*");
+ }
+
+ /**
+ * Returns true if this is an object name pattern. An object
+ * name pattern has a domain containing a wildcard character
+ * ('*' or '?') and/or a '*' in the list of properties.
+ * This method will return true if either {@link #isDomainPattern()}
+ * or {@link #isPropertyPattern()} does.
+ *
+ * @return true if this is an object name pattern.
+ */
+ public boolean isPattern()
+ {
+ return isDomainPattern() || isPropertyPattern();
+ }
+
+ /**
+ * Returns true if this object name is a property pattern. This is
+ * the case if the list of properties contains an '*'.
+ *
+ * @return true if this is a property pattern.
+ */
+ public boolean isPropertyPattern()
+ {
+ return propertyPattern;
+ }
+
+ /**
+ * <p>
+ * Returns a quoted version of the supplied string. The string may
+ * contain any character. The resulting quoted version is guaranteed
+ * to be usable as the value of a property, so this method provides
+ * a good way of ensuring that a value is legal.
+ * </p>
+ * <p>
+ * The string is transformed as follows:
+ * </p>
+ * <ul>
+ * <li>The string is prefixed with an opening quote character, '"'.
+ * <li>For each character, s:
+ * <ul>
+ * <li>If s is a quote ('"'), it is replaced by a backslash
+ * followed by a quote.</li>
+ * <li>If s is a star ('*'), it is replaced by a backslash followed
+ * by a star.</li>
+ * <li>If s is a question mark ('?'), it is replaced by a backslash
+ * followed by a question mark.</li>
+ * <li>If s is a backslash ('\'), it is replaced by two backslashes.</li>
+ * <li>If s is a newline character, it is replaced by a backslash followed by
+ * a '\n'.</li>
+ * <li>Otherwise, s is used verbatim.
+ * </ul></li>
+ * <li>The string is terminated with a closing quote character, '"'.</li>
+ * </ul>
+ *
+ * @param string the string to quote.
+ * @return a quoted version of the supplied string.
+ * @throws NullPointerException if <code>string</code> is <code>null</code>.
+ */
+ public static String quote(String string)
+ {
+ StringBuilder builder = new StringBuilder('"');
+ for (int a = 0; a < string.length(); ++a)
+ {
+ char s = string.charAt(a);
+ switch (s)
+ {
+ case '"':
+ builder.append("\\\"");
+ break;
+ case '*':
+ builder.append("\\*");
+ break;
+ case '?':
+ builder.append("\\?");
+ break;
+ case '\\':
+ builder.append("\\\\");
+ break;
+ case '\n':
+ builder.append("\\\n");
+ break;
+ default:
+ builder.append(s);
+ }
+ }
+ builder.append('"');
+ return builder.toString();
+ }
+
+ /**
+ * Changes the {@link MBeanServer} on which this query is performed.
+ *
+ * @param server the new server to use.
+ */
+ public void setMBeanServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ /**
+ * Returns a textual representation of the object name.
+ * The format is unspecified, but it should be expected that
+ * two equivalent object names will return the same string
+ * from this method.
+ *
+ * @return a textual representation of the object name.
+ */
+ public String toString()
+ {
+ return getClass().toString() +
+ "[domain = " + domain +
+ ",properties = " + properties +
+ ",propertyPattern = " + propertyPattern +
+ "]";
+ }
+
+ /**
+ * Unquotes the supplied string. The quotation marks are removed as
+ * are the backslashes preceding the escaped characters ('"', '?',
+ * '*', '\n', '\\'). A one-to-one mapping exists between quoted and
+ * unquoted values. As a result, a string <code>s</code> should be
+ * equal to <code>unquote(quote(s))</code>.
+ *
+ * @param q the quoted string to unquote.
+ * @return the unquoted string.
+ * @throws NullPointerException if <code>q</code> is <code>null</code>.
+ * @throws IllegalArgumentException if the string is not a valid
+ * quoted string i.e. it is not
+ * surrounded by quotation marks
+ * and/or characters are not properly
+ * escaped.
+ */
+ public static String unquote(String q)
+ {
+ if (q.charAt(0) != '"')
+ throw new IllegalArgumentException("The string does " +
+ "not start with a quote.");
+ if (q.charAt(q.length() - 1) != '"')
+ throw new IllegalArgumentException("The string does " +
+ "not end with a quote.");
+ StringBuilder builder = new StringBuilder();
+ for (int a = 1; a < (q.length() - 1); ++a)
+ {
+ char n = q.charAt(a);
+ if (n == '\\')
+ {
+ n = q.charAt(++a);
+ if (n != '"' && n != '?' && n != '*' &&
+ n != '\n' && n != '\\')
+ throw new IllegalArgumentException("Illegal escaped character: "
+ + n);
+ }
+ builder.append(n);
+ }
+
+ return builder.toString();
+ }
+
+}
diff --git a/javax/management/QueryExp.java b/javax/management/QueryExp.java
new file mode 100644
index 000000000..124228c78
--- /dev/null
+++ b/javax/management/QueryExp.java
@@ -0,0 +1,87 @@
+/* QueryExp.java -- Represents a query expression.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.io.Serializable;
+
+/**
+ * Applies the type of relational constraints seen in the
+ * <code>where</code> clauses of databases to an
+ * {@link ObjectName}. Instances of this class are usually
+ * returned by the static methods of the {@link Query} classes.
+ * If a custom implementation is required, it is better to
+ * extend the {@link QueryEval} class, rather than simply
+ * implementing this interface, in order to ensure that
+ * the {@link #setMBeanServer(MBeanServer)} method functions
+ * correctly.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface QueryExp
+ extends Serializable
+{
+
+ /**
+ * Applies the query to the specified management bean.
+ *
+ * @param name the name of the management bean.
+ * @return true if the query was applied successfully.
+ * @throws BadStringOperationException if an invalid string
+ * operation is used by
+ * the query.
+ * @throws BadBinaryOpValueExpException if an invalid expression
+ * is used by the query.
+ * @throws BadAttributeValueExpException if an invalid attribute
+ * is used by the query.
+ * @throws InvalidApplicationException if the query is applied
+ * to the wrong type of bean.
+ */
+ boolean apply(ObjectName name)
+ throws BadStringOperationException, BadBinaryOpValueExpException,
+ BadAttributeValueExpException, InvalidApplicationException;
+
+ /**
+ * Changes the {@link MBeanServer} on which this query is performed.
+ *
+ * @param server the new server to use.
+ */
+ void setMBeanServer(MBeanServer server);
+
+}
+
diff --git a/javax/management/ValueExp.java b/javax/management/ValueExp.java
new file mode 100644
index 000000000..503f23221
--- /dev/null
+++ b/javax/management/ValueExp.java
@@ -0,0 +1,86 @@
+/* ValueExp.java -- Represents values that can be passed to queries.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management;
+
+import java.io.Serializable;
+
+/**
+ * Represents values that may be passed as arguments to
+ * {@link QueryExp}s. Strings, numbers and bean attributes
+ * are all valid argument types for query expressions, and
+ * so should be represented as implementations of this
+ * interface.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ */
+public interface ValueExp
+ extends Serializable
+{
+
+ /**
+ * Applies the value expression to the specified management bean.
+ *
+ * @param name the name of the management bean.
+ * @return the value expression.
+ * @throws BadStringOperationException if an invalid string
+ * operation is used by
+ * the value expression.
+ * @throws BadBinaryOpValueExpException if an invalid expression
+ * is used by the value expression.
+ * @throws BadAttributeValueExpException if an invalid attribute
+ * is used by the value expression.
+ * @throws InvalidApplicationException if the value expression is applied
+ * to the wrong type of bean.
+ */
+ ValueExp apply(ObjectName name)
+ throws BadStringOperationException, BadBinaryOpValueExpException,
+ BadAttributeValueExpException, InvalidApplicationException;
+
+ /**
+ * Changes the {@link MBeanServer} on which this query is performed.
+ *
+ * @param server the new server to use.
+ * @deprecated This method is superfluous, as the {@link ValueExp}
+ * can access the server using
+ * {@link QueryEval#getMBeanServer()}.
+ */
+ void setMBeanServer(MBeanServer server);
+
+}
+
diff --git a/javax/management/loading/ClassLoaderRepository.java b/javax/management/loading/ClassLoaderRepository.java
new file mode 100644
index 000000000..e2c8b7c5b
--- /dev/null
+++ b/javax/management/loading/ClassLoaderRepository.java
@@ -0,0 +1,139 @@
+/* ClassLoaderRepository.java -- Represents a collection of class loadersx.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.management.loading;
+
+/**
+ * Implementations of this interface maintain a list of
+ * {@link ClassLoader}s for use by the management servers,
+ * allowing classes to be loaded by the first {@link ClassLoader}
+ * that will do so. A class loader is added to the list
+ * whenever a {@link ClassLoader} instance is registered with
+ * the management server, and it does not implement the
+ * {@link PrivateClassLoader} interface. They are removed when
+ * unregistered. The first class loader in the list is always
+ * the one which was used to load the management server itself.
+ *
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.5
+ * @see MBeanServerFactory
+ */
+public interface ClassLoaderRepository
+{
+
+ /**
+ * Attempts to load the given class using class loaders
+ * supplied by the list. The {@link ClassLoader#loadClass(String)}
+ * method of each class loader is called. If the method
+ * returns successfully, then the returned {@link Class} instance
+ * is returned. If a {@link ClassNotFoundException} is thrown,
+ * then the next loader is tried. Any other exception thrown
+ * by the method is passed back to the caller. This method
+ * throws a {@link ClassNotFoundException} itself if all the
+ * class loaders listed prove fruitless.
+ *
+ * @param name the name of the class to load.
+ * @return the loaded class.
+ * @throws ClassNotFoundException if all the class loaders fail
+ * to load the class.
+ */
+ Class loadClass(String name)
+ throws ClassNotFoundException;
+
+ /**
+ * <p>
+ * Attempts to load the given class using class loaders
+ * supplied by the list, stopping when the specified
+ * loader is reached. The {@link ClassLoader#loadClass(String)}
+ * method of each class loader is called. If the method
+ * returns successfully, then the returned {@link Class} instance
+ * is returned. If a {@link ClassNotFoundException} is thrown,
+ * then the next loader is tried. Any other exception thrown
+ * by the method is passed back to the caller. This method
+ * throws a {@link ClassNotFoundException} itself if all the
+ * class loaders listed prove fruitless.
+ * </p>
+ * <p>
+ * This method is usually used by the class loader specified
+ * by the <code>stop</code> argument to load classes using the
+ * loaders that appear before it in the list. By stopping when
+ * the loader is reached, the deadlock that occurs when the loader
+ * is merely skipped is avoided.
+ * </p>
+ *
+ * @param stop the class loader at which to stop, or <code>null</code>
+ * to obtain the same behaviour as {@link #loadClass(String)}.
+ * @param name the name of the class to load.
+ * @return the loaded class.
+ * @throws ClassNotFoundException if all the class loaders fail
+ * to load the class.
+ */
+ Class loadClassBefore(ClassLoader stop, String name)
+ throws ClassNotFoundException;
+
+ /**
+ * <p>
+ * Attempts to load the given class using class loaders
+ * supplied by the list, excluding the one specified.
+ * The {@link ClassLoader#loadClass(String)}
+ * method of each class loader is called. If the method
+ * returns successfully, then the returned {@link Class} instance
+ * is returned. If a {@link ClassNotFoundException} is thrown,
+ * then the next loader is tried. Any other exception thrown
+ * by the method is passed back to the caller. This method
+ * throws a {@link ClassNotFoundException} itself if all the
+ * class loaders listed prove fruitless.
+ * </p>
+ * <p>
+ * Note that this method may deadlock if called simultaneously
+ * by two class loaders in the list.
+ * {@link loadClassBefore(ClassLoader, String)} should be used
+ * in preference to this method to avoid this.
+ * </p>
+ *
+ * @param exclude the class loader to exclude, or <code>null</code>
+ * to obtain the same behaviour as {@link #loadClass(String)}.
+ * @param name the name of the class to load.
+ * @return the loaded class.
+ * @throws ClassNotFoundException if all the class loaders fail
+ * to load the class.
+ */
+ Class loadClassWithout(ClassLoader exclude, String name)
+ throws ClassNotFoundException;
+
+}
+
diff --git a/javax/rmi/CORBA/Tie.java b/javax/rmi/CORBA/Tie.java
index b86118388..af9ddd3d4 100644
--- a/javax/rmi/CORBA/Tie.java
+++ b/javax/rmi/CORBA/Tie.java
@@ -103,7 +103,7 @@ public interface Tie
/**
* Get the object that delegates calls to this tie.
*
- * @see org.omg.PortableServer.Servant#_this_object
+ * @see org.omg.PortableServer.Servant#_this_object()
*/
org.omg.CORBA.Object thisObject();
@@ -112,12 +112,12 @@ public interface Tie
* Depending on the POA policies, it may be possible to activate the Tie
* again. The ties that are not derived from
* {@link org.omg.PortableServer.Servant} deactivate themselves by
- * {@link ORB.disconnect}.
+ * {@link ORB#disconnect}.
*
* @throws NoSuchObjectException if there are no objects served by this Tie,
* or if the these objects are already deactivated.
*
- * @see org.omg.PortableServer.POA#deactivate_object
+ * @see org.omg.PortableServer.POAOperations#deactivate_object
*/
void deactivate()
throws NoSuchObjectException;
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index ed8daca27..c2c894c06 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -904,7 +904,10 @@ public abstract class AbstractButton extends JComponent
setDisplayedMnemonicIndex(-1);
setOpaque(true);
text = "";
- updateUI();
+ // testing on JRE1.5 shows that the iconTextGap default value is
+ // hard-coded here and the 'Button.iconTextGap' setting in the
+ // UI defaults is ignored, at least by the MetalLookAndFeel
+ iconTextGap = 4;
}
/**
@@ -965,6 +968,8 @@ public abstract class AbstractButton extends JComponent
if (icon != null)
default_icon = icon;
+
+ updateUI();
}
/**
diff --git a/javax/swing/AbstractSpinnerModel.java b/javax/swing/AbstractSpinnerModel.java
index b3b3f29d5..d247a3313 100644
--- a/javax/swing/AbstractSpinnerModel.java
+++ b/javax/swing/AbstractSpinnerModel.java
@@ -1,5 +1,5 @@
/* AbstractSpinnerModel.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,6 +47,8 @@ import javax.swing.event.EventListenerList;
/**
* Provides standard implementations for some of the methods in
* {@link SpinnerModel}.
+ *
+ * @since 1.4
*
* @author Ka-Hing Cheung
*/
@@ -54,6 +56,7 @@ public abstract class AbstractSpinnerModel implements SpinnerModel
{
private ChangeEvent changeEvent = new ChangeEvent(this);
+ /** Stores the listeners registered with the model. */
protected EventListenerList listenerList = new EventListenerList();
/**
@@ -65,9 +68,10 @@ public abstract class AbstractSpinnerModel implements SpinnerModel
}
/**
- * Adds a <code>ChangeListener</code>.
+ * Registers a <code>ChangeListener</code> with the model so that it will
+ * receive {@link ChangeEvent} notifications when the model changes.
*
- * @param listener the listener to add
+ * @param listener the listener to add (<code>null</code> is ignored).
*/
public void addChangeListener(ChangeListener listener)
{
diff --git a/javax/swing/JButton.java b/javax/swing/JButton.java
index 787adb87c..878cfa683 100644
--- a/javax/swing/JButton.java
+++ b/javax/swing/JButton.java
@@ -132,8 +132,8 @@ public class JButton extends AbstractButton
public JButton(String text, Icon icon)
{
super();
- init(text, icon);
setModel(new DefaultButtonModel());
+ init(text, icon);
defaultCapable = true;
}
diff --git a/javax/swing/JMenuBar.java b/javax/swing/JMenuBar.java
index 35f129377..73b409e42 100644
--- a/javax/swing/JMenuBar.java
+++ b/javax/swing/JMenuBar.java
@@ -298,19 +298,25 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
- * DOCUMENT ME!
+ * This method is not implemented and will throw an {@link Error} if called.
*
- * @return DOCUMENT ME!
+ * @return This method never returns anything, it throws an exception.
*/
public JMenu getHelpMenu()
{
- return null;
+ // the following error matches the behaviour of the reference
+ // implementation...
+ throw new Error("getHelpMenu() is not implemented");
}
/**
- * Returns margin betweeen menu bar's border and its menues
+ * Returns the margin between the menu bar's border and its menus. If the
+ * margin is <code>null</code>, this method returns
+ * <code>new Insets(0, 0, 0, 0)</code>.
*
- * @return margin between menu bar's border and its menues
+ * @return The margin (never <code>null</code>).
+ *
+ * @see #setMargin(Insets)
*/
public Insets getMargin()
{
@@ -617,21 +623,20 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
- * Sets the menu bar's "margin" bound property, which represents
- * distance between the menubar's border and its menus.
- * icon. When marging property is modified, PropertyChangeEvent will
- * be fired to menuBar's PropertyChangeListener's.
- *
- * @param m distance between the menubar's border and its menus.
+ * Sets the margin between the menu bar's border and its menus (this is a
+ * bound property with the name 'margin').
*
+ * @param m the margin (<code>null</code> permitted).
+ *
+ * @see #getMargin()
*/
public void setMargin(Insets m)
{
if (m != margin)
{
- Insets oldMargin = margin;
- margin = m;
- firePropertyChange("margin", oldMargin, margin);
+ Insets oldMargin = margin;
+ margin = m;
+ firePropertyChange("margin", oldMargin, margin);
}
}
diff --git a/javax/swing/JMenuItem.java b/javax/swing/JMenuItem.java
index 324d61cd4..4231e4fa6 100644
--- a/javax/swing/JMenuItem.java
+++ b/javax/swing/JMenuItem.java
@@ -81,8 +81,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem()
{
- super();
- init(null, null);
+ this(null, null);
}
/**
@@ -94,8 +93,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
{
// FIXME: The requestedFocusEnabled property should
// be set to false, when only icon is set for menu item.
- super();
- init(null, icon);
+ this(null, icon);
}
/**
@@ -117,6 +115,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
{
super();
super.setAction(action);
+ setModel(new DefaultButtonModel());
init(null, null);
if (action != null)
{
@@ -148,6 +147,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
public JMenuItem(String text, Icon icon)
{
super();
+ setModel(new DefaultButtonModel());
init(text, icon);
}
@@ -174,7 +174,6 @@ public class JMenuItem extends AbstractButton implements Accessible,
protected void init(String text, Icon icon)
{
super.init(text, icon);
- setModel(new DefaultButtonModel());
// Initializes properties for this menu item, that are different
// from Abstract button properties.
diff --git a/javax/swing/JScrollBar.java b/javax/swing/JScrollBar.java
index bf0803ab5..1f21aa13f 100644
--- a/javax/swing/JScrollBar.java
+++ b/javax/swing/JScrollBar.java
@@ -50,6 +50,8 @@ import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
import javax.accessibility.AccessibleValue;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.plaf.ScrollBarUI;
/**
@@ -172,6 +174,28 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
}
}
+ /**
+ * Listens for changes on the model and fires them to interested
+ * listeners on the JScrollBar, after re-sourcing them.
+ */
+ private class ScrollBarChangeListener
+ implements ChangeListener
+ {
+
+ public void stateChanged(ChangeEvent event)
+ {
+ Object o = event.getSource();
+ if (o instanceof BoundedRangeModel)
+ {
+ BoundedRangeModel m = (BoundedRangeModel) o;
+ fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
+ AdjustmentEvent.TRACK, m.getValue(),
+ m.getValueIsAdjusting());
+ }
+ }
+
+ }
+
private static final long serialVersionUID = -8195169869225066566L;
/** How much the thumb moves when moving in a block. */
@@ -186,6 +210,12 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
/** How much the thumb moves when moving in a unit. */
protected int unitIncrement = 1;
+ /**
+ * This ChangeListener forwards events fired from the model and re-sources
+ * them to originate from this JScrollBar.
+ */
+ private ChangeListener sbChangeListener;
+
/**
* Creates a new horizontal JScrollBar object with a minimum
* of 0, a maxmium of 100, a value of 0 and an extent of 10.
@@ -220,6 +250,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
public JScrollBar(int orientation, int value, int extent, int min, int max)
{
model = new DefaultBoundedRangeModel(value, extent, min, max);
+ sbChangeListener = new ScrollBarChangeListener();
+ model.addChangeListener(sbChangeListener);
if (orientation != SwingConstants.HORIZONTAL
&& orientation != SwingConstants.VERTICAL)
throw new IllegalArgumentException(orientation
@@ -319,12 +351,13 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public void setModel(BoundedRangeModel newModel)
{
- if (model != newModel)
- {
- BoundedRangeModel oldModel = model;
- model = newModel;
- firePropertyChange("model", oldModel, model);
- }
+ BoundedRangeModel oldModel = model;
+ if (oldModel != null)
+ oldModel.removeChangeListener(sbChangeListener);
+ model = newModel;
+ if (model != null)
+ model.addChangeListener(sbChangeListener);
+ firePropertyChange("model", oldModel, model);
}
/**
@@ -424,12 +457,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public void setValue(int value)
{
- if (isEnabled() && value != getValue())
- {
- model.setValue(value);
- fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
- AdjustmentEvent.TRACK, value);
- }
+ model.setValue(value);
}
/**
@@ -451,12 +479,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public void setVisibleAmount(int extent)
{
- if (extent != getVisibleAmount())
- {
- model.setExtent(extent);
- fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
- AdjustmentEvent.TRACK, extent);
- }
+ model.setExtent(extent);
}
/**
@@ -476,12 +499,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public void setMinimum(int minimum)
{
- if (minimum != getMinimum())
- {
- model.setMinimum(minimum);
- fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
- AdjustmentEvent.TRACK, minimum);
- }
+ model.setMinimum(minimum);
}
/**
@@ -501,12 +519,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public void setMaximum(int maximum)
{
- if (maximum != getMaximum())
- {
- model.setMaximum(maximum);
- fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
- AdjustmentEvent.TRACK, maximum);
- }
+ model.setMaximum(maximum);
}
/**
@@ -540,17 +553,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public void setValues(int newValue, int newExtent, int newMin, int newMax)
{
- if (!isEnabled())
- newValue = model.getValue();
- // It seems to be that on any change the value is fired.
- if (newValue != getValue() || newExtent != getVisibleAmount() ||
- newMin != getMinimum() || newMax != getMaximum())
- {
- model.setRangeProperties(newValue, newExtent, newMin, newMax,
- model.getValueIsAdjusting());
- fireAdjustmentValueChanged(AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
- AdjustmentEvent.TRACK, newValue);
- }
+ model.setRangeProperties(newValue, newExtent, newMin, newMax,
+ model.getValueIsAdjusting());
}
/**
@@ -596,15 +600,30 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
protected void fireAdjustmentValueChanged(int id, int type, int value)
{
+ fireAdjustmentValueChanged(id, type, value, getValueIsAdjusting());
+ }
+
+ /**
+ * Helper method for firing adjustment events that can have their
+ * isAdjusting field modified.
+ *
+ * This is package private to avoid an accessor method.
+ *
+ * @param id the ID of the event
+ * @param type the type of the event
+ * @param value the value
+ * @param isAdjusting if the scrollbar is adjusting or not
+ */
+ void fireAdjustmentValueChanged(int id, int type, int value,
+ boolean isAdjusting)
+ {
Object[] adjustmentListeners = listenerList.getListenerList();
- AdjustmentEvent adjustmentEvent = new AdjustmentEvent(this,
- AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
- AdjustmentEvent.TRACK,
- value);
+ AdjustmentEvent adjustmentEvent = new AdjustmentEvent(this, id, type,
+ value, isAdjusting);
for (int i = adjustmentListeners.length - 2; i >= 0; i -= 2)
{
- if (adjustmentListeners[i] == AdjustmentListener.class)
- ((AdjustmentListener) adjustmentListeners[i + 1]).adjustmentValueChanged(adjustmentEvent);
+ if (adjustmentListeners[i] == AdjustmentListener.class)
+ ((AdjustmentListener) adjustmentListeners[i + 1]).adjustmentValueChanged(adjustmentEvent);
}
}
diff --git a/javax/swing/JTabbedPane.java b/javax/swing/JTabbedPane.java
index a500b9264..c7244bf2b 100644
--- a/javax/swing/JTabbedPane.java
+++ b/javax/swing/JTabbedPane.java
@@ -887,7 +887,7 @@ public class JTabbedPane extends JComponent implements Serializable,
if (model != null)
{
- if (changeListener != null)
+ if (changeListener == null)
changeListener = createChangeListener();
model.addChangeListener(changeListener);
}
@@ -1054,7 +1054,10 @@ public class JTabbedPane extends JComponent implements Serializable,
}
if (getSelectedIndex() == -1)
- setSelectedIndex(0);
+ {
+ setSelectedIndex(0);
+ fireStateChanged();
+ }
revalidate();
repaint();
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index 28cc6728d..42563e6a2 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -2635,6 +2635,7 @@ public class JTable
setModel(dm == null ? createDefaultDataModel() : dm);
setAutoCreateColumnsFromModel(autoCreate);
initializeLocalVars();
+
// The following four lines properly set the lead selection indices.
// After this, the UI will handle the lead selection indices.
// FIXME: this should probably not be necessary, if the UI is installed
@@ -2642,11 +2643,13 @@ public class JTable
// own, but certain variables need to be set before the UI can be installed
// so we must get the correct order for all the method calls in this
// constructor.
- selectionModel.setAnchorSelectionIndex(0);
- selectionModel.setLeadSelectionIndex(0);
- columnModel.getSelectionModel().setAnchorSelectionIndex(0);
- columnModel.getSelectionModel().setLeadSelectionIndex(0);
- updateUI();
+ // These four lines are not needed. A Mauve test that shows this is
+ // gnu.testlet.javax.swing.JTable.constructors(linesNotNeeded).
+ // selectionModel.setAnchorSelectionIndex(-1);
+ // selectionModel.setLeadSelectionIndex(-1);
+ // columnModel.getSelectionModel().setAnchorSelectionIndex(-1);
+ // columnModel.getSelectionModel().setLeadSelectionIndex(-1);
+ updateUI();
}
/**
@@ -2675,10 +2678,12 @@ public class JTable
setRowHeight(16);
this.rowMargin = 1;
this.rowSelectionAllowed = true;
+
// this.accessibleContext = new AccessibleJTable();
this.cellEditor = null;
+
// COMPAT: Both Sun and IBM have drag enabled
- this.dragEnabled = true;
+ this.dragEnabled = false;
this.preferredViewportSize = new Dimension(450,400);
this.showHorizontalLines = true;
this.showVerticalLines = true;
@@ -3267,7 +3272,7 @@ public class JTable
cellRect.x += cMargin / 2;
cellRect.width -= cMargin;
}
- }
+ }
return cellRect;
}
@@ -3446,7 +3451,9 @@ public class JTable
*/
public TableCellRenderer getCellRenderer(int row, int column)
{
- TableCellRenderer renderer = columnModel.getColumn(column).getCellRenderer();
+ TableCellRenderer renderer = null;
+ if (columnModel.getColumnCount() > 0)
+ renderer = columnModel.getColumn(column).getCellRenderer();
if (renderer == null)
{
int mcolumn = convertColumnIndexToModel(column);
@@ -3563,7 +3570,7 @@ public class JTable
return renderer.getTableCellRendererComponent(this,
dataModel.getValueAt(row,
- convertColumnIndexToModel(column)),
+ convertColumnIndexToModel(column)),
isSel,
hasFocus,
row, column);
@@ -4441,7 +4448,7 @@ public class JTable
{
TableColumn resizingColumn = null;
- int ncols = getColumnCount();
+ int ncols = columnModel.getColumnCount();
if (ncols < 1)
return;
@@ -4450,7 +4457,7 @@ public class JTable
if (tableHeader != null)
resizingColumn = tableHeader.getResizingColumn();
-
+
for (int i = 0; i < ncols; ++i)
{
TableColumn col = columnModel.getColumn(i);
@@ -4459,7 +4466,7 @@ public class JTable
if (resizingColumn == col)
rCol = i;
}
-
+
int spill = getWidth() - prefSum;
if (resizingColumn != null)
@@ -4525,9 +4532,11 @@ public class JTable
}
else
{
- TableColumn [] cols = new TableColumn[ncols];
+ TableColumn[] cols = new TableColumn[ncols];
+
for (int i = 0; i < ncols; ++i)
cols[i] = columnModel.getColumn(i);
+
distributeSpill(cols, spill);
}
@@ -4740,7 +4749,7 @@ public class JTable
if ((index0 < 0 || index0 > (getRowCount()-1)
|| index1 < 0 || index1 > (getRowCount()-1)))
throw new IllegalArgumentException("Row index out of range.");
-
+
getSelectionModel().addSelectionInterval(index0, index1);
}
diff --git a/javax/swing/JToggleButton.java b/javax/swing/JToggleButton.java
index 1769c5ee0..60c448960 100644
--- a/javax/swing/JToggleButton.java
+++ b/javax/swing/JToggleButton.java
@@ -1,5 +1,5 @@
/* JToggleButton.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.
@@ -291,9 +291,8 @@ public class JToggleButton extends AbstractButton implements Accessible
public JToggleButton (String text, Icon icon, boolean selected)
{
super();
+ setModel(new ToggleButtonModel());
init(text, icon);
-
- setModel(new ToggleButtonModel());
model.setSelected(selected);
setAlignmentX(LEFT_ALIGNMENT);
}
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index c76a9b783..7d093e3d0 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -2355,7 +2355,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
if (selectionModel != null)
{
TreePath oldValue = selectionModel.getLeadSelectionPath();
- if (path.equals(oldValue))
+ if (path == oldValue || path != null && path.equals(oldValue))
return;
// Repaint the previous and current rows with the lead selection path.
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index babffb7ce..9fd14e80a 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -157,6 +157,9 @@ public class JViewport extends JComponent implements Accessible
*/
public void componentResized(ComponentEvent ev)
{
+ // Fire state change, because resizing the view means changing the
+ // extentSize.
+ fireStateChanged();
revalidate();
}
}
@@ -198,22 +201,6 @@ public class JViewport extends JComponent implements Accessible
int scrollMode;
- /**
- * The width and height of the Viewport's area in terms of view
- * coordinates. Typically this will be the same as the width and height
- * of the viewport's bounds, unless the viewport transforms units of
- * width and height, which it may do, for example if it magnifies or
- * rotates its view.
- *
- * @see #toViewCoordinates(Dimension)
- */
- Dimension extentSize;
-
- /**
- * The width and height of the view in its own coordinate space.
- */
- Dimension viewSize;
-
/**
* The ViewListener instance.
*/
@@ -265,8 +252,7 @@ public class JViewport extends JComponent implements Accessible
static
{
String scrollModeProp =
- SystemProperties.getProperty("gnu.javax.swing.JViewport.scrollMode",
- "BLIT");
+ SystemProperties.getProperty("gnu.swing.scrollmode", "BACKINGSTORE");
if (scrollModeProp.equalsIgnoreCase("simple"))
defaultScrollMode = SIMPLE_SCROLL_MODE;
else if (scrollModeProp.equalsIgnoreCase("backingstore"))
@@ -290,10 +276,7 @@ public class JViewport extends JComponent implements Accessible
public Dimension getExtentSize()
{
- if (extentSize == null)
- return toViewCoordinates(getSize());
- else
- return extentSize;
+ return getSize();
}
public Dimension toViewCoordinates(Dimension size)
@@ -310,8 +293,12 @@ public class JViewport extends JComponent implements Accessible
public void setExtentSize(Dimension newSize)
{
- extentSize = newSize;
- fireStateChanged();
+ Dimension oldExtent = getExtentSize();
+ if (! newSize.equals(oldExtent))
+ {
+ setSize(newSize);
+ fireStateChanged();
+ }
}
/**
@@ -321,32 +308,34 @@ public class JViewport extends JComponent implements Accessible
*/
public Dimension getViewSize()
{
- if (isViewSizeSet)
- return viewSize;
- else
+ Dimension size;
+ Component view = getView();
+ if (view != null)
{
- Component view = getView();
- if (view != null)
- return view.getPreferredSize();
- else
- return new Dimension();
+ if (isViewSizeSet)
+ size = view.getSize();
+ else
+ size = view.getPreferredSize();
}
+ else
+ size = new Dimension(0, 0);
+ return size;
}
public void setViewSize(Dimension newSize)
{
- viewSize = newSize;
Component view = getView();
if (view != null)
{
- if (newSize != view.getSize())
+ if (! newSize.equals(view.getSize()))
{
- view.setSize(viewSize);
+ scrollUnderway = false;
+ view.setSize(newSize);
+ isViewSizeSet = true;
fireStateChanged();
}
}
- isViewSizeSet = true;
}
/**
@@ -371,23 +360,18 @@ public class JViewport extends JComponent implements Accessible
public void setViewPosition(Point p)
{
- if (getViewPosition().equals(p))
- return;
Component view = getView();
- if (view != null)
+ if (view != null && ! p.equals(getViewPosition()))
{
- Point q = new Point(-p.x, -p.y);
- view.setLocation(q);
- isViewSizeSet = false;
+ scrollUnderway = true;
+ view.setLocation(-p.x, -p.y);
fireStateChanged();
}
- repaint();
}
public Rectangle getViewRect()
{
- return new Rectangle(getViewPosition(),
- getExtentSize());
+ return new Rectangle(getViewPosition(), getExtentSize());
}
/**
@@ -495,7 +479,6 @@ public class JViewport extends JComponent implements Accessible
if (view == null)
return;
- Point pos = getViewPosition();
Rectangle viewBounds = view.getBounds();
Rectangle portBounds = getBounds();
@@ -643,19 +626,11 @@ public class JViewport extends JComponent implements Accessible
*/
public void repaint(long tm, int x, int y, int w, int h)
{
-// Component parent = getParent();
-// if (parent != null)
-// parent.repaint(tm, x + getX(), y + getY(), w, h);
-// else
-// super.repaint(tm, x, y, w, h);
-
- // The specs suggest to implement something like the above. This however
- // breaks blit painting, because the parent (most likely a JScrollPane)
- // clears the background of the offscreen area of the JViewport, thus
- // destroying the pieces that we want to clip. So we simply call super here
- // instead.
- super.repaint(tm, x, y, w, h);
-
+ Component parent = getParent();
+ if (parent != null)
+ parent.repaint(tm, x + getX(), y + getY(), w, h);
+ else
+ super.repaint(tm, x, y, w, h);
}
protected void addImpl(Component comp, Object constraints, int index)
@@ -940,7 +915,10 @@ public class JViewport extends JComponent implements Accessible
/**
* Overridden from JComponent to set the {@link #isPaintRoot} flag.
*
- * @param r the rectangle to paint
+ * @param x the rectangle to paint, X coordinate
+ * @param y the rectangle to paint, Y coordinate
+ * @param w the rectangle to paint, width
+ * @param h the rectangle to paint, height
*/
void paintImmediately2(int x, int y, int w, int h)
{
diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java
index 2d29e9076..fa374a34f 100644
--- a/javax/swing/RepaintManager.java
+++ b/javax/swing/RepaintManager.java
@@ -38,13 +38,18 @@ exception statement from your version. */
package javax.swing;
+import gnu.java.awt.LowPriorityEvent;
+
import java.applet.Applet;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
+import java.awt.Toolkit;
import java.awt.Window;
+import java.awt.event.InvocationEvent;
import java.awt.image.VolatileImage;
import java.util.ArrayList;
import java.util.HashMap;
@@ -72,6 +77,32 @@ import java.util.WeakHashMap;
public class RepaintManager
{
/**
+ * An InvocationEvent subclass that implements LowPriorityEvent. This is used
+ * to defer the execution of RepaintManager requests as long as possible on
+ * the event queue. This way we make sure that all available input is
+ * processed before getting active with the RepaintManager. This allows
+ * for better optimization (more validate and repaint requests can be
+ * coalesced) and thus has a positive effect on performance for GUI
+ * applications under heavy load.
+ */
+ private static class RepaintWorkerEvent
+ extends InvocationEvent
+ implements LowPriorityEvent
+ {
+
+ /**
+ * Creates a new RepaintManager event.
+ *
+ * @param source the source
+ * @param runnable the runnable to execute
+ */
+ public RepaintWorkerEvent(Object source, Runnable runnable)
+ {
+ super(source, runnable);
+ }
+ }
+
+ /**
* The current repaint managers, indexed by their ThreadGroups.
*/
static WeakHashMap currentRepaintManagers;
@@ -340,7 +371,7 @@ public class RepaintManager
if (! repaintWorker.isLive())
{
repaintWorker.setLive(true);
- SwingUtilities.invokeLater(repaintWorker);
+ invokeLater(repaintWorker);
}
}
@@ -405,7 +436,7 @@ public class RepaintManager
if (! repaintWorker.isLive())
{
repaintWorker.setLive(true);
- SwingUtilities.invokeLater(repaintWorker);
+ invokeLater(repaintWorker);
}
}
}
@@ -693,13 +724,18 @@ public class RepaintManager
root = root.getParent();
}
- Graphics g = root.getGraphics();
- Image buffer = (Image) offscreenBuffers.get(root);
-
- // Make sure we have a sane clip at this point.
- g.clipRect(x, y, w, h);
- g.drawImage(buffer, 0, 0, root);
- g.dispose();
+ if (root != null)
+ {
+ Graphics g = root.getGraphics();
+ Image buffer = (Image) offscreenBuffers.get(root);
+ if (buffer != null)
+ {
+ // Make sure we have a sane clip at this point.
+ g.clipRect(x, y, w, h);
+ g.drawImage(buffer, 0, 0, root);
+ g.dispose();
+ }
+ }
}
/**
@@ -791,4 +827,18 @@ public class RepaintManager
{
return "RepaintManager";
}
+
+ /**
+ * Sends an RepaintManagerEvent to the event queue with the specified
+ * runnable. This is similar to SwingUtilities.invokeLater(), only that the
+ * event is a low priority event in order to defer the execution a little
+ * more.
+ */
+ private void invokeLater(Runnable runnable)
+ {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ EventQueue evQueue = tk.getSystemEventQueue();
+ InvocationEvent ev = new RepaintWorkerEvent(this, runnable);
+ evQueue.postEvent(ev);
+ }
}
diff --git a/javax/swing/SizeSequence.java b/javax/swing/SizeSequence.java
index a5f34710c..cb6c8bc25 100644
--- a/javax/swing/SizeSequence.java
+++ b/javax/swing/SizeSequence.java
@@ -129,14 +129,18 @@ public class SizeSequence
}
/**
- * Returns the size of the specified element.
+ * Returns the size of the specified element, or 0 if the element index is
+ * outside the defined range.
*
* @param index the element index.
*
- * @return The size of the specified element.
+ * @return The size of the specified element, or 0 if the element index is
+ * outside the defined range.
*/
public int getSize(int index)
{
+ if (index < 0 || index >= sizes.length)
+ return 0;
return sizes[index];
}
diff --git a/javax/swing/UIManager.java b/javax/swing/UIManager.java
index 77be44afc..3b1b3f72b 100644
--- a/javax/swing/UIManager.java
+++ b/javax/swing/UIManager.java
@@ -154,8 +154,16 @@ public class UIManager implements Serializable
UIDefaults fallback;
+ /**
+ * Creates a new <code>MultiplexUIDefaults</code> instance with
+ * <code>d</code> as the fallback defaults.
+ *
+ * @param d the fallback defaults (<code>null</code> not permitted).
+ */
MultiplexUIDefaults(UIDefaults d)
{
+ if (d == null)
+ throw new NullPointerException();
fallback = d;
}
@@ -400,6 +408,8 @@ public class UIManager implements Serializable
* @param key the key.
*
* @return The object.
+ *
+ * @since 1.4
*/
public static Object get(Object key, Locale locale)
{
@@ -407,61 +417,120 @@ public class UIManager implements Serializable
}
/**
- * Returns a boolean value from the defaults table,
- * <code>false</code> if key is not present.
+ * Returns a boolean value from the defaults table. If there is no value
+ * for the specified key, or the value is not an instance of {@link Boolean},
+ * this method returns <code>false</code>.
+ *
+ * @param key the key (<code>null</code> not permitted).
*
+ * @return The boolean value associated with the specified key.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ *
* @since 1.4
*/
public static boolean getBoolean(Object key)
{
- Boolean value = (Boolean) get(key);
- return value != null ? value.booleanValue() : false;
+ Object value = get(key);
+ if (value instanceof Boolean)
+ return ((Boolean) value).booleanValue();
+ return false;
}
/**
- * Returns a boolean value from the defaults table,
- * <code>false</code> if key is not present.
+ * Returns a boolean value from the defaults table. If there is no value
+ * for the specified key, or the value is not an instance of {@link Boolean},
+ * this method returns <code>false</code>.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
*
+ * @return The boolean value associated with the specified key.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ *
* @since 1.4
*/
public static boolean getBoolean(Object key, Locale locale)
{
- Boolean value = (Boolean) get(key, locale);
- return value != null ? value.booleanValue() : false;
+ Object value = get(key, locale);
+ if (value instanceof Boolean)
+ return ((Boolean) value).booleanValue();
+ return false;
}
/**
* Returns a border from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return The border associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
*/
public static Border getBorder(Object key)
{
- return (Border) get(key);
+ Object value = get(key);
+ if (value instanceof Border)
+ return (Border) value;
+ return null;
}
/**
- * Returns a border from the defaults table.
+ * Returns a border from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
+ *
+ * @return The border associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
*
* @since 1.4
*/
public static Border getBorder(Object key, Locale locale)
{
- return (Border) get(key, locale);
+ Object value = get(key, locale);
+ if (value instanceof Border)
+ return (Border) value;
+ return null;
}
/**
* Returns a drawing color from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return The color associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
*/
public static Color getColor(Object key)
{
- return (Color) get(key);
+ Object value = get(key);
+ if (value instanceof Color)
+ return (Color) value;
+ return null;
}
/**
* Returns a drawing color from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
+ *
+ * @return The color associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ *
+ * @since 1.4
*/
public static Color getColor(Object key, Locale locale)
{
- return (Color) get(key);
+ Object value = get(key, locale);
+ if (value instanceof Color)
+ return (Color) value;
+ return null;
}
/**
@@ -483,24 +552,44 @@ public class UIManager implements Serializable
public static UIDefaults getDefaults()
{
if (currentUIDefaults == null)
- currentUIDefaults = new MultiplexUIDefaults(null);
+ currentUIDefaults = new MultiplexUIDefaults(new UIDefaults());
return currentUIDefaults;
}
/**
* Returns a dimension from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return The color associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
*/
public static Dimension getDimension(Object key)
{
- return (Dimension) get(key);
+ Object value = get(key);
+ if (value instanceof Dimension)
+ return (Dimension) value;
+ return null;
}
/**
* Returns a dimension from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
+ *
+ * @return The color associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ * @since 1.4
*/
public static Dimension getDimension(Object key, Locale locale)
{
- return (Dimension) get(key, locale);
+ Object value = get(key, locale);
+ if (value instanceof Dimension)
+ return (Dimension) value;
+ return null;
}
/**
@@ -510,10 +599,17 @@ public class UIManager implements Serializable
* @param key an Object that specifies the font. Typically,
* this is a String such as
* <code>TitledBorder.font</code>.
+ *
+ * @return The font associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
*/
public static Font getFont(Object key)
{
- return (Font) get(key);
+ Object value = get(key);
+ if (value instanceof Font)
+ return (Font) value;
+ return null;
}
/**
@@ -523,30 +619,66 @@ public class UIManager implements Serializable
* @param key an Object that specifies the font. Typically,
* this is a String such as
* <code>TitledBorder.font</code>.
+ * @param locale the locale.
+ *
+ * @return The font associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ *
+ * @since 1.4
*/
public static Font getFont(Object key, Locale locale)
{
- return (Font) get(key, locale);
+ Object value = get(key, locale);
+ if (value instanceof Font)
+ return (Font) value;
+ return null;
}
/**
- * Returns an Icon from the defaults table.
+ * Returns an icon from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return The icon associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
*/
public static Icon getIcon(Object key)
{
- return (Icon) get(key);
+ Object value = get(key);
+ if (value instanceof Icon)
+ return (Icon) value;
+ return null;
}
/**
- * Returns an Icon from the defaults table.
+ * Returns an icon from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
+ *
+ * @return The icon associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ * @since 1.4
*/
public static Icon getIcon(Object key, Locale locale)
{
- return (Icon) get(key, locale);
+ Object value = get(key, locale);
+ if (value instanceof Icon)
+ return (Icon) value;
+ return null;
}
/**
* Returns an Insets object from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return The insets associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
*/
public static Insets getInsets(Object key)
{
@@ -559,6 +691,14 @@ public class UIManager implements Serializable
/**
* Returns an Insets object from the defaults table.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
+ *
+ * @return The insets associated with the given key, or <code>null</code>.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ * @since 1.4
*/
public static Insets getInsets(Object key, Locale locale)
{
@@ -580,20 +720,41 @@ public class UIManager implements Serializable
return installed;
}
+ /**
+ * Returns the integer value of the {@link Integer} associated with the
+ * given key. If there is no value, or the value is not an instance of
+ * {@link Integer}, this method returns 0.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return The integer value associated with the given key, or 0.
+ */
public static int getInt(Object key)
{
- Integer x = (Integer) get(key);
- if (x == null)
- return 0;
- return x.intValue();
+ Object x = get(key);
+ if (x instanceof Integer)
+ return ((Integer) x).intValue();
+ return 0;
}
+ /**
+ * Returns the integer value of the {@link Integer} associated with the
+ * given key. If there is no value, or the value is not an instance of
+ * {@link Integer}, this method returns 0.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
+ *
+ * @return The integer value associated with the given key, or 0.
+ *
+ * @since 1.4
+ */
public static int getInt(Object key, Locale locale)
{
- Integer x = (Integer) get(key, locale);
- if (x == null)
- return 0;
- return x.intValue();
+ Object x = get(key, locale);
+ if (x instanceof Integer)
+ return ((Integer) x).intValue();
+ return 0;
}
/**
@@ -620,19 +781,38 @@ public class UIManager implements Serializable
}
/**
- * Returns a string from the defaults table.
+ * Returns the {@link String} associated with the given key. If the value
+ * is not a {@link String}, this method returns <code>null</code>.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return The string associated with the given key, or <code>null</code>.
*/
public static String getString(Object key)
{
- return (String) get(key);
+ Object s = get(key);
+ if (s instanceof String)
+ return (String) s;
+ return null;
}
/**
- * Returns a string from the defaults table.
+ * Returns the {@link String} associated with the given key. If the value
+ * is not a {@link String}, this method returns <code>null</code>.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ * @param locale the locale.
+ *
+ * @return The string associated with the given key, or <code>null</code>.
+ *
+ * @since 1.4
*/
public static String getString(Object key, Locale locale)
{
- return (String) get(key, locale);
+ Object s = get(key, locale);
+ if (s instanceof String)
+ return (String) s;
+ return null;
}
/**
@@ -686,6 +866,9 @@ public class UIManager implements Serializable
/**
* Stores an object in the defaults table.
+ *
+ * @param key the key.
+ * @param value the value.
*/
public static Object put(Object key, Object value)
{
diff --git a/javax/swing/plaf/basic/BasicButtonUI.java b/javax/swing/plaf/basic/BasicButtonUI.java
index e2493d156..9f685bb7b 100644
--- a/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/javax/swing/plaf/basic/BasicButtonUI.java
@@ -44,6 +44,7 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractButton;
@@ -83,6 +84,11 @@ public class BasicButtonUI extends ButtonUI
static Rectangle textR = new Rectangle();
/**
+ * Cached Insets instance, used in paint().
+ */
+ static Insets cachedInsets;
+
+ /**
* The shared button UI.
*/
private static BasicButtonUI sharedUI;
@@ -257,6 +263,10 @@ public class BasicButtonUI extends ButtonUI
b.addMouseListener(listener);
b.addMouseMotionListener(listener);
}
+ // Fire synthetic property change event to let the listener update
+ // the TextLayout cache.
+ listener.propertyChange(new PropertyChangeEvent(b, "font", null,
+ b.getFont()));
}
/**
@@ -329,6 +339,7 @@ public class BasicButtonUI extends ButtonUI
uninstallListeners(b);
uninstallDefaults(b);
BasicHTML.updateRenderer(b, "");
+ b.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, null);
}
}
@@ -433,7 +444,7 @@ public class BasicButtonUI extends ButtonUI
{
AbstractButton b = (AbstractButton) c;
- Insets i = c.getInsets();
+ Insets i = c.getInsets(cachedInsets);
viewR.x = i.left;
viewR.y = i.top;
viewR.width = c.getWidth() - i.left - i.right;
@@ -558,22 +569,7 @@ public class BasicButtonUI extends ButtonUI
protected void paintText(Graphics g, JComponent c, Rectangle textRect,
String text)
{
- paintText(g, (AbstractButton) c, textRect, text);
- }
-
- /**
- * Paints the "text" property of an {@link AbstractButton}.
- *
- * @param g The graphics context to paint with
- * @param b The button to paint the state of
- * @param textRect The area in which to paint the text
- * @param text The text to paint
- *
- * @since 1.4
- */
- protected void paintText(Graphics g, AbstractButton b, Rectangle textRect,
- String text)
- {
+ AbstractButton b = (AbstractButton) c;
Font f = b.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
@@ -593,6 +589,22 @@ public class BasicButtonUI extends ButtonUI
BasicGraphicsUtils.drawString(b, g, text, -1, textRect.x,
textRect.y + fm.getAscent());
}
+ }
+
+ /**
+ * Paints the "text" property of an {@link AbstractButton}.
+ *
+ * @param g The graphics context to paint with
+ * @param b The button to paint the state of
+ * @param textRect The area in which to paint the text
+ * @param text The text to paint
+ *
+ * @since 1.4
+ */
+ protected void paintText(Graphics g, AbstractButton b, Rectangle textRect,
+ String text)
+ {
+ paintText(g, (JComponent) b, textRect, text);
}
/**
diff --git a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index 11980f6ca..ea8b46036 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -177,9 +177,15 @@ public class BasicInternalFrameTitlePane extends JComponent
try
{
if (frame.isMaximizable() && ! frame.isMaximum())
- frame.setMaximum(true);
+ {
+ frame.setMaximum(true);
+ maxButton.setIcon(minIcon);
+ }
else if (frame.isMaximum())
- frame.setMaximum(false);
+ {
+ frame.setMaximum(false);
+ maxButton.setIcon(maxIcon);
+ }
}
catch (PropertyVetoException pve)
{
diff --git a/javax/swing/plaf/basic/BasicInternalFrameUI.java b/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 8161df29f..87c5268c8 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -1594,6 +1594,13 @@ public class BasicInternalFrameUI extends InternalFrameUI
{
replacePane(northPane, c);
northPane = c;
+ // the following is needed to make internal frames draggable when using
+ // the JGoodies PlasticLookAndFeel, because it overrides the
+ // createNorthPane() method and doesn't assign anything to the titlePane
+ // field. It is possible there is another way to make this work, but
+ // I didn't find it...
+ if (c instanceof BasicInternalFrameTitlePane)
+ titlePane = (BasicInternalFrameTitlePane) c;
}
/**
diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java
index 85eefb9ee..87dce2ef4 100644
--- a/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -180,17 +180,9 @@ public class BasicMenuItemUI extends MenuItemUI
private ItemListener itemListener;
/**
- * Number of spaces between accelerator and menu item's label.
+ * A PropertyChangeListener to make UI updates after property changes.
*/
- private int defaultAcceleratorLabelGap = 10;
-
- /**
- * The gap between different menus on the MenuBar.
- */
- private int MenuGap = 10;
-
- /** A PropertyChangeListener to make UI updates after property changes **/
- PropertyChangeHandler propertyChangeListener;
+ private PropertyChangeHandler propertyChangeListener;
/**
* The view rectangle used for layout of the menu item.
@@ -262,7 +254,6 @@ public class BasicMenuItemUI extends MenuItemUI
|| property.equals("font"))
&& SystemProperties.getProperty("gnu.javax.swing.noGraphics2D")
== null)
-
{
AbstractButton b = (AbstractButton) e.getSource();
String text = b.getText();
@@ -414,7 +405,7 @@ public class BasicMenuItemUI extends MenuItemUI
Component c = menuItem;
while (c instanceof MenuElement)
{
- path.add(0, (MenuElement) c);
+ path.add(0, c);
if (c instanceof JPopupMenu)
c = ((JPopupMenu) c).getInvoker();
@@ -603,6 +594,11 @@ public class BasicMenuItemUI extends MenuItemUI
menuItem.addMenuKeyListener(menuKeyListener);
menuItem.addItemListener(itemListener);
menuItem.addPropertyChangeListener(propertyChangeListener);
+ // Fire synthetic property change event to let the listener update
+ // the TextLayout cache.
+ propertyChangeListener.propertyChange(new PropertyChangeEvent(menuItem,
+ "font", null,
+ menuItem.getFont()));
}
/**
@@ -935,6 +931,7 @@ public class BasicMenuItemUI extends MenuItemUI
uninstallListeners();
uninstallDefaults();
uninstallComponents(menuItem);
+ c.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, null);
menuItem = null;
}
@@ -952,47 +949,6 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * Return text representation of the specified accelerator
- *
- * @param accelerator
- * Accelerator for which to return string representation
- * @return $String$ Text representation of the given accelerator
- */
- private String getAcceleratorText(KeyStroke accelerator)
- {
- // convert keystroke into string format
- String modifiersText = "";
- int modifiers = accelerator.getModifiers();
- char keyChar = accelerator.getKeyChar();
- int keyCode = accelerator.getKeyCode();
-
- if (modifiers != 0)
- modifiersText = KeyEvent.getKeyModifiersText(modifiers)
- + acceleratorDelimiter;
-
- if (keyCode == KeyEvent.VK_UNDEFINED)
- return modifiersText + keyChar;
- else
- return modifiersText + KeyEvent.getKeyText(keyCode);
- }
-
- /**
- * Calculates and return rectange in which accelerator should be displayed
- *
- * @param accelerator
- * accelerator for which to return the display rectangle
- * @param fm
- * The font metrics used to measure the text
- * @return $Rectangle$ reactangle which will be used to display accelerator
- */
- private Rectangle getAcceleratorRect(KeyStroke accelerator, FontMetrics fm)
- {
- int width = fm.stringWidth(getAcceleratorText(accelerator));
- int height = fm.getHeight();
- return new Rectangle(0, 0, width, height);
- }
-
- /**
* This class handles mouse events occuring inside the menu item. Most of the
* events are forwarded for processing to MenuSelectionManager of the current
* menu hierarchy.
@@ -1309,9 +1265,6 @@ public class BasicMenuItemUI extends MenuItemUI
*/
private void layoutMenuItem(JMenuItem m, String accelText)
{
- int width = m.getWidth();
- int height = m.getHeight();
-
// Fetch the fonts.
Font font = m.getFont();
FontMetrics fm = m.getFontMetrics(font);
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
index 802b25339..fb84cf443 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -81,7 +81,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
*/
public BasicRadioButtonUI()
{
- icon = getDefaultIcon();
+ // nothing to do
}
/**
@@ -93,6 +93,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
protected void installDefaults(AbstractButton b)
{
super.installDefaults(b);
+ icon = UIManager.getIcon(getPropertyPrefix() + "icon");
}
/**
@@ -116,7 +117,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
*/
public Icon getDefaultIcon()
{
- return UIManager.getIcon(getPropertyPrefix() + "icon");
+ return icon;
}
/**
diff --git a/javax/swing/plaf/basic/BasicScrollBarUI.java b/javax/swing/plaf/basic/BasicScrollBarUI.java
index ee246cbba..5205724b5 100644
--- a/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -760,10 +760,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
scrollbar.setOpaque(true);
scrollbar.setLayout(this);
- thumbColor = UIManager.getColor("ScrollBar.thumb");
- thumbDarkShadowColor = UIManager.getColor("ScrollBar.thumbDarkShadow");
- thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight");
- thumbLightShadowColor = UIManager.getColor("ScrollBar.thumbShadow");
+ configureScrollBarColors();
maximumThumbSize = UIManager.getDimension("ScrollBar.maximumThumbSize");
minimumThumbSize = UIManager.getDimension("ScrollBar.minimumThumbSize");
diff --git a/javax/swing/plaf/basic/BasicScrollPaneUI.java b/javax/swing/plaf/basic/BasicScrollPaneUI.java
index 69e352711..236eac073 100644
--- a/javax/swing/plaf/basic/BasicScrollPaneUI.java
+++ b/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -101,19 +101,8 @@ public class BasicScrollPaneUI extends ScrollPaneUI
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
JViewport vp = scrollpane.getViewport();
Point viewPosition = vp.getViewPosition();
- int xpos = hsb.getValue();
-
- if (xpos != viewPosition.x)
- {
- viewPosition.x = xpos;
- vp.setViewPosition(viewPosition);
- }
-
- viewPosition.y = 0;
- JViewport columnHeader = scrollpane.getColumnHeader();
- if (columnHeader != null
- && !columnHeader.getViewPosition().equals(viewPosition))
- columnHeader.setViewPosition(viewPosition);
+ viewPosition.x = hsb.getValue();
+ vp.setViewPosition(viewPosition);
}
}
@@ -138,18 +127,8 @@ public class BasicScrollPaneUI extends ScrollPaneUI
JScrollBar vsb = scrollpane.getVerticalScrollBar();
JViewport vp = scrollpane.getViewport();
Point viewPosition = vp.getViewPosition();
- int ypos = vsb.getValue();
- if (ypos != viewPosition.y)
- {
- viewPosition.y = ypos;
- vp.setViewPosition(viewPosition);
- }
-
- viewPosition.x = 0;
- JViewport rowHeader = scrollpane.getRowHeader();
- if (rowHeader != null
- && !rowHeader.getViewPosition().equals(viewPosition))
- rowHeader.setViewPosition(viewPosition);
+ viewPosition.y = vsb.getValue();
+ vp.setViewPosition(viewPosition);
}
}
@@ -173,9 +152,6 @@ public class BasicScrollPaneUI extends ScrollPaneUI
*/
public void stateChanged(ChangeEvent event)
{
- JViewport vp = scrollpane.getViewport();
- JScrollBar hsb = scrollpane.getHorizontalScrollBar();
- JScrollBar vsb = scrollpane.getVerticalScrollBar();
syncScrollPaneWithViewport();
}
@@ -777,9 +753,8 @@ public class BasicScrollPaneUI extends ScrollPaneUI
public void uninstallUI(final JComponent c)
{
- super.uninstallUI(c);
- this.uninstallDefaults((JScrollPane) c);
- uninstallListeners((JScrollPane) c);
+ uninstallDefaults((JScrollPane) c);
+ uninstallListeners(c);
installKeyboardActions((JScrollPane) c);
}
@@ -815,7 +790,7 @@ public class BasicScrollPaneUI extends ScrollPaneUI
}
public void paint(Graphics g, JComponent c)
- {
+ {
Border vpBorder = scrollpane.getViewportBorder();
if (vpBorder != null)
{
@@ -825,23 +800,55 @@ public class BasicScrollPaneUI extends ScrollPaneUI
}
/**
- * Synchronizes the scrollbars with the viewport's extents.
+ * Synchronizes the scrollbar and header settings positions and extent
+ * with the viewport's view position and extent.
*/
protected void syncScrollPaneWithViewport()
{
JViewport vp = scrollpane.getViewport();
- // Update the horizontal scrollbar.
- JScrollBar hsb = scrollpane.getHorizontalScrollBar();
- hsb.setMaximum(vp.getViewSize().width);
- hsb.setValue(vp.getViewPosition().x);
- hsb.setVisibleAmount(vp.getExtentSize().width);
-
- // Update the vertical scrollbar.
- JScrollBar vsb = scrollpane.getVerticalScrollBar();
- vsb.setMaximum(vp.getViewSize().height);
- vsb.setValue(vp.getViewPosition().y);
- vsb.setVisibleAmount(vp.getExtentSize().height);
+ if (vp != null)
+ {
+ Dimension extentSize = vp.getExtentSize();
+ Point viewPos = vp.getViewPosition();
+ Dimension viewSize = vp.getViewSize();
+
+ // Update the vertical scrollbar.
+ JScrollBar vsb = scrollpane.getVerticalScrollBar();
+ if (vsb != null)
+ {
+ int extent = extentSize.height;
+ int max = viewSize.height;
+ int val = Math.max(0, Math.min(viewPos.y, max - extent));
+ vsb.setValues(val, extent, 0, max);
+ }
+
+ // Update the horizontal scrollbar.
+ JScrollBar hsb = scrollpane.getHorizontalScrollBar();
+ if (hsb != null)
+ {
+ int extent = extentSize.width;
+ int max = viewSize.width;
+ int val = Math.max(0, Math.min(viewPos.x, max - extent));
+ hsb.setValues(val, extent, 0, max);
+ }
+
+ // Update the row header.
+ JViewport rowHeader = scrollpane.getRowHeader();
+ if (rowHeader != null)
+ {
+ Point p = new Point(0, viewPos.y);
+ rowHeader.setViewPosition(p);
+ }
+
+ // Update the column header.
+ JViewport colHeader = scrollpane.getColumnHeader();
+ if (colHeader != null)
+ {
+ Point p = new Point(viewPos.x, 0);
+ colHeader.setViewPosition(p);
+ }
+ }
}
/**
@@ -874,7 +881,8 @@ public class BasicScrollPaneUI extends ScrollPaneUI
*/
protected void updateScrollBarDisplayPolicy(PropertyChangeEvent ev)
{
- // TODO: Find out what should be done here. Or is this only a hook?
+ scrollpane.revalidate();
+ scrollpane.repaint();
}
/**
diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java
index 15be4d57e..a672173c7 100644
--- a/javax/swing/plaf/basic/BasicTableUI.java
+++ b/javax/swing/plaf/basic/BasicTableUI.java
@@ -443,11 +443,14 @@ public class BasicTableUI extends TableUI
public Dimension getPreferredSize(JComponent comp)
{
int prefTotalColumnWidth = 0;
- for (int i = 0; i < table.getColumnCount(); i++)
+ TableColumnModel tcm = table.getColumnModel();
+
+ for (int i = 0; i < tcm.getColumnCount(); i++)
{
- TableColumn col = table.getColumnModel().getColumn(i);
+ TableColumn col = tcm.getColumn(i);
prefTotalColumnWidth += col.getPreferredWidth();
}
+
return new Dimension(prefTotalColumnWidth, getHeight());
}
@@ -455,7 +458,7 @@ public class BasicTableUI extends TableUI
* Returns the table height. This helper method is used by
* {@link #getMinimumSize(JComponent)}, {@link #getPreferredSize(JComponent)}
* and {@link #getMaximumSize(JComponent)} to determine the table height.
- *
+ *
* @return the table height
*/
private int getHeight()
diff --git a/javax/swing/plaf/basic/BasicToolBarUI.java b/javax/swing/plaf/basic/BasicToolBarUI.java
index 1c36b408d..7be69ec25 100644
--- a/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -898,7 +898,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
b.setRolloverEnabled(false);
// Save old border in hashtable.
- borders.put(b, b.getBorder());
+ if (b.getBorder() != null)
+ borders.put(b, b.getBorder());
b.setBorder(nonRolloverBorder);
}
@@ -932,7 +933,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
b.setRolloverEnabled(false);
// Save old border in hashtable.
- borders.put(b, b.getBorder());
+ if (b.getBorder() != null)
+ borders.put(b, b.getBorder());
b.setBorder(rolloverBorder);
}
diff --git a/javax/swing/plaf/metal/DefaultMetalTheme.java b/javax/swing/plaf/metal/DefaultMetalTheme.java
index 673aec1e4..672676fa0 100644
--- a/javax/swing/plaf/metal/DefaultMetalTheme.java
+++ b/javax/swing/plaf/metal/DefaultMetalTheme.java
@@ -38,8 +38,11 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import gnu.classpath.SystemProperties;
+
import java.awt.Font;
+import javax.swing.UIManager;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
@@ -63,10 +66,6 @@ public class DefaultMetalTheme extends MetalTheme
private static final ColorUIResource SECONDARY3 =
new ColorUIResource(204, 204, 204);
- private static final FontUIResource CONTROL_TEXT_FONT =
- new FontUIResource("Dialog", Font.BOLD, 12);
- private static final FontUIResource MENU_TEXT_FONT =
- new FontUIResource("Dialog", Font.BOLD, 12);
private static final FontUIResource SUB_TEXT_FONT =
new FontUIResource("Dialog", Font.PLAIN, 10);
private static final FontUIResource SYSTEM_TEXT_FONT =
@@ -77,6 +76,40 @@ public class DefaultMetalTheme extends MetalTheme
new FontUIResource("Dialog", Font.BOLD, 12);
/**
+ * The control text font for swing.boldMetal=false.
+ */
+ private static final FontUIResource PLAIN_CONTROL_TEXT_FONT =
+ new FontUIResource("Dialog", Font.PLAIN, 12);
+
+ /**
+ * The standard control text font.
+ */
+ private static final FontUIResource BOLD_CONTROL_TEXT_FONT =
+ new FontUIResource("Dialog", Font.BOLD, 12);
+
+ /**
+ * The menu text font for swing.boldMetal=false.
+ */
+ private static final FontUIResource PLAIN_MENU_TEXT_FONT =
+ new FontUIResource("Dialog", Font.PLAIN, 12);
+
+ /**
+ * The menu control text font.
+ */
+ private static final FontUIResource BOLD_MENU_TEXT_FONT =
+ new FontUIResource("Dialog", Font.BOLD, 12);
+
+ /**
+ * Indicates the control text font.
+ */
+ static final int CONTROL_TEXT_FONT = 1;
+
+ /**
+ * Indicates the menu text font.
+ */
+ static final int MENU_TEXT_FONT = 2;
+
+ /**
* Creates a new instance of this theme.
*/
public DefaultMetalTheme()
@@ -156,23 +189,28 @@ public class DefaultMetalTheme extends MetalTheme
/**
* Returns the font used for text on controls. In this case, the font is
- * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>.
+ * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>, unless the
+ * <code>swing.boldMetal</code> UI default is set to {@link Boolean#FALSE}
+ * in which case it is <code>FontUIResource("Dialog", Font.PLAIN, 12)</code>.
*
* @return The font.
*/
public FontUIResource getControlTextFont()
{
- return CONTROL_TEXT_FONT;
+ return getFont(CONTROL_TEXT_FONT);
}
+
/**
* Returns the font used for text in menus. In this case, the font is
- * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>.
+ * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>, unless the
+ * <code>swing.boldMetal</code> UI default is set to {@link Boolean#FALSE}
+ * in which case it is <code>FontUIResource("Dialog", Font.PLAIN, 12)</code>.
*
* @return The font used for text in menus.
*/
public FontUIResource getMenuTextFont()
{
- return MENU_TEXT_FONT;
+ return getFont(MENU_TEXT_FONT);
}
/**
@@ -218,4 +256,50 @@ public class DefaultMetalTheme extends MetalTheme
{
return WINDOW_TITLE_FONT;
}
+
+ /**
+ * Returns the appropriate font. The font type to return is identified
+ * by the specified id.
+ *
+ * @param id the font type to return
+ *
+ * @return the correct font
+ */
+ private FontUIResource getFont(int id)
+ {
+ FontUIResource font = null;
+ switch (id)
+ {
+ case CONTROL_TEXT_FONT:
+ if (isBoldMetal())
+ font = BOLD_CONTROL_TEXT_FONT;
+ else
+ font = PLAIN_CONTROL_TEXT_FONT;
+ break;
+ case MENU_TEXT_FONT:
+ if (isBoldMetal())
+ font = BOLD_MENU_TEXT_FONT;
+ else
+ font = PLAIN_MENU_TEXT_FONT;
+ break;
+ // TODO: Add other font types and their mapping here.
+ }
+ return font;
+ }
+
+ /**
+ * Determines if the theme should be bold or not. The theme is bold by
+ * default, this can be turned off by setting the system property
+ * swing.boldMetal to true, or by putting the property with the same name
+ * into the current UIManager's defaults.
+ *
+ * @return <code>true</code>, when the theme is bold, <code>false</code>
+ * otherwise
+ */
+ private boolean isBoldMetal()
+ {
+ Object boldMetal = UIManager.get("swing.boldMetal");
+ return (boldMetal == null || ! Boolean.FALSE.equals(boldMetal))
+ && ! ("false".equals(SystemProperties.getProperty("swing.boldMetal")));
+ }
}
diff --git a/javax/swing/plaf/metal/MetalIconFactory.java b/javax/swing/plaf/metal/MetalIconFactory.java
index 30ec7e72b..d39fdc06b 100644
--- a/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/javax/swing/plaf/metal/MetalIconFactory.java
@@ -54,7 +54,6 @@ import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
-import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.UIResource;
@@ -569,8 +568,8 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
- // TODO: pick up appropriate UI colors
- g.setColor(Color.black);
+ y = y + getShift();
+ g.setColor(MetalLookAndFeel.getBlack());
g.drawLine(x, y, x + 9, y);
g.drawLine(x, y + 1, x, y + 15);
g.drawLine(x, y + 15, x + 12, y + 15);
@@ -580,7 +579,7 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 7, y + 2, x + 11, y + 6);
g.drawLine(x + 8, y + 1, x + 9, y + 1);
- g.setColor(new Color(204, 204, 255));
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
g.drawLine(x + 1, y + 1, x + 7, y + 1);
g.drawLine(x + 1, y + 1, x + 1, y + 14);
g.drawLine(x + 1, y + 14, x + 11, y + 14);
@@ -601,7 +600,9 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * The default value is zero, but subclasses may override this (for
+ * example, see {@link TreeLeafIcon}).
*
* @return The shift.
*/
@@ -649,21 +650,21 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
- // TODO: pick up appropriate UI colors
- g.setColor(Color.black);
- g.drawLine(x, y + 3, x, y + 12);
- g.drawLine(x, y + 12, x + 15, y + 12);
- g.drawLine(x + 15, y + 12, x + 15, y + 2);
- g.drawLine(x + 14, y + 3, x + 9, y + 3);
- g.drawLine(x + 8, y + 2, x + 1, y + 2);
- g.setColor(new Color(204, 204, 255));
- g.fillRect(x + 2, y + 4, 7, 8);
- g.fillRect(x + 9, y + 5, 6, 7);
- g.setColor(new Color(102, 102, 153));
- g.drawLine(x + 9, y + 2, x + 14, y + 2);
- g.setColor(new Color(50, 50, 120));
- g.drawLine(x + 9, y + 1, x + 15, y + 1);
- g.drawLine(x + 10, y, x + 15, y);
+ y = y + getShift();
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x, y + 6, x, y + 15);
+ g.drawLine(x, y + 15, x + 15, y + 15);
+ g.drawLine(x + 15, y + 15, x + 15, y + 5);
+ g.drawLine(x + 14, y + 6, x + 9, y + 6);
+ g.drawLine(x + 8, y + 5, x + 1, y + 5);
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ g.fillRect(x + 2, y + 7, 7, 8);
+ g.fillRect(x + 9, y + 8, 6, 7);
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ g.drawLine(x + 9, y + 5, x + 14, y + 5);
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ g.drawLine(x + 9, y + 4, x + 15, y + 4);
+ g.drawLine(x + 10, y + 3, x + 15, y + 3);
}
/**
@@ -679,7 +680,9 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * The default value is zero, but subclasses may override this (for
+ * example, see {@link TreeFolderIcon}).
*
* @return The shift.
*/
@@ -1268,23 +1271,23 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
- g.setColor(new Color(102, 102, 153));
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
g.fillRect(x + 1, y, 14, 2);
g.fillRect(x, y + 1, 2, 14);
g.fillRect(x + 1, y + 14, 14, 2);
g.fillRect(x + 14, y + 1, 2, 14);
g.drawLine(x + 2, y + 5, x + 14, y + 5);
- g.setColor(new Color(204, 204, 255));
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
g.fillRect(x + 2, y + 2, 12, 3);
- g.setColor(new Color(102, 102, 153));
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
g.drawLine(x + 3, y + 3, x + 3, y + 3);
g.drawLine(x + 6, y + 3, x + 6, y + 3);
g.drawLine(x + 9, y + 3, x + 9, y + 3);
g.drawLine(x + 12, y + 3, x + 12, y + 3);
- g.setColor(Color.white);
+ g.setColor(MetalLookAndFeel.getWhite());
g.fillRect(x + 2, y + 6, 12, 8);
g.drawLine(x + 2, y + 2, x + 2, y + 2);
g.drawLine(x + 5, y + 2, x + 5, y + 2);
@@ -1883,7 +1886,8 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * This overridden method returns <code>-1</code>.
*
* @return The shift.
*/
@@ -1918,7 +1922,8 @@ public class MetalIconFactory implements Serializable
}
/**
- * Returns the shift (???).
+ * Returns the vertical shift, in pixels, applied when painting the icon.
+ * This overridden method returns <code>2</code>.
*
* @return The shift.
*/
diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java
index ff26aa232..a9a679093 100644
--- a/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -889,7 +889,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"CheckBox.border", MetalBorders.getButtonBorder(),
"CheckBox.disabledText", getInactiveControlTextColor(),
"CheckBox.focus", getFocusColor(),
- "CheckBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "CheckBox.font", getControlTextFont(),
"CheckBox.foreground", getControlTextColor(),
"CheckBox.icon",
new UIDefaults.ProxyLazyValue("javax.swing.plaf.metal.MetalCheckBoxIcon"),
@@ -905,7 +905,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"CheckBoxMenuItem.commandSound", "sounds/MenuItemCommand.wav",
"CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
"CheckBoxMenuItem.disabledForeground", getMenuDisabledForeground(),
- "CheckBoxMenuItem.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "CheckBoxMenuItem.font", getMenuTextFont(),
"CheckBoxMenuItem.foreground", getMenuForeground(),
"CheckBoxMenuItem.selectionBackground", getMenuSelectedBackground(),
"CheckBoxMenuItem.selectionForeground", getMenuSelectedForeground(),
@@ -924,7 +924,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ComboBox.buttonShadow", getControlShadow(),
"ComboBox.disabledBackground", getControl(),
"ComboBox.disabledForeground", getInactiveSystemTextColor(),
- "ComboBox.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "ComboBox.font", getControlTextFont(),
"ComboBox.foreground", getControlTextColor(),
"ComboBox.selectionBackground", getPrimaryControlShadow(),
"ComboBox.selectionForeground", getControlTextColor(),
@@ -935,10 +935,11 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"DesktopIcon.foreground", getControlTextColor(),
"DesktopIcon.width", new Integer(160),
"DesktopIcon.border", MetalBorders.getDesktopIconBorder(),
+ "DesktopIcon.font", getControlTextFont(),
"EditorPane.background", getWindowBackground(),
"EditorPane.caretForeground", getUserTextColor(),
- "EditorPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "EditorPane.font", getControlTextFont(),
"EditorPane.foreground", getUserTextColor(),
"EditorPane.inactiveForeground", getInactiveSystemTextColor(),
"EditorPane.selectionBackground", getTextHighlightColor(),
@@ -1023,7 +1024,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Menu.borderPainted", Boolean.TRUE,
"MenuItem.commandSound", "sounds/MenuItemCommand.wav",
"Menu.disabledForeground", getMenuDisabledForeground(),
- "Menu.font", getControlTextFont(),
+ "Menu.font", getMenuTextFont(),
"Menu.foreground", getMenuForeground(),
"Menu.selectionBackground", getMenuSelectedBackground(),
"Menu.selectionForeground", getMenuSelectedForeground(),
@@ -1032,7 +1033,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"MenuBar.background", getMenuBackground(),
"MenuBar.border", new MetalBorders.MenuBarBorder(),
- "MenuBar.font", getControlTextFont(),
+ "MenuBar.font", getMenuTextFont(),
"MenuBar.foreground", getMenuForeground(),
"MenuBar.highlight", getControlHighlight(),
"MenuBar.shadow", getControlShadow(),
@@ -1046,7 +1047,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"MenuItem.border", new MetalBorders.MenuItemBorder(),
"MenuItem.borderPainted", Boolean.TRUE,
"MenuItem.disabledForeground", getMenuDisabledForeground(),
- "MenuItem.font", getControlTextFont(),
+ "MenuItem.font", getMenuTextFont(),
"MenuItem.foreground", getMenuForeground(),
"MenuItem.selectionBackground", getMenuSelectedBackground(),
"MenuItem.selectionForeground", getMenuSelectedForeground(),
@@ -1087,13 +1088,13 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"PopupMenu.background", getMenuBackground(),
"PopupMenu.border", new MetalBorders.PopupMenuBorder(),
- "PopupMenu.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "PopupMenu.font", getMenuTextFont(),
"PopupMenu.foreground", getMenuForeground(),
"PopupMenu.popupSound", "sounds/PopupMenuPopup.wav",
"ProgressBar.background", getControl(),
"ProgressBar.border", new BorderUIResource.LineBorderUIResource(getControlDarkShadow(), 1),
- "ProgressBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "ProgressBar.font", getControlTextFont(),
"ProgressBar.foreground", getPrimaryControlShadow(),
"ProgressBar.selectionBackground", getPrimaryControlDarkShadow(),
"ProgressBar.selectionForeground", getControl(),
@@ -1127,7 +1128,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
MetalIconFactory.getRadioButtonMenuItemIcon(),
"RadioButtonMenuItem.commandSound", "sounds/MenuItemCommand.wav",
"RadioButtonMenuItem.disabledForeground", getMenuDisabledForeground(),
- "RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
+ "RadioButtonMenuItem.font", getMenuTextFont(),
"RadioButtonMenuItem.foreground", getMenuForeground(),
"RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
"RadioButtonMenuItem.selectionBackground",
@@ -1174,7 +1175,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Spinner.arrowButtonInsets", new InsetsUIResource(0, 0, 0, 0),
"Spinner.background", getControl(),
"Spinner.border", MetalBorders.getTextFieldBorder(),
- "Spinner.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "Spinner.font", getControlTextFont(),
"Spinner.foreground", getControl(),
"SplitPane.background", getControl(),
@@ -1191,7 +1192,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"TabbedPane.contentOpaque", Boolean.TRUE,
"TabbedPane.darkShadow", getControlDarkShadow(),
"TabbedPane.focus", getPrimaryControlDarkShadow(),
- "TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "TabbedPane.font", getControlTextFont(),
"TabbedPane.foreground", getControlTextColor(),
"TabbedPane.highlight", getControlHighlight(),
"TabbedPane.light", getControl(),
@@ -1254,7 +1255,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"TextPane.selectionForeground", getHighlightedTextColor(),
"TitledBorder.border", new LineBorderUIResource(getPrimaryControl(), 1),
- "TitledBorder.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "TitledBorder.font", getControlTextFont(),
"TitledBorder.titleColor", getSystemTextColor(),
"ToggleButton.background", getControl(),
@@ -1276,7 +1277,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ToolBar.dockingForeground", getPrimaryControlDarkShadow(),
"ToolBar.floatingBackground", getMenuBackground(),
"ToolBar.floatingForeground", getPrimaryControl(),
- "ToolBar.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "ToolBar.font", getMenuTextFont(),
"ToolBar.foreground", getMenuForeground(),
"ToolBar.highlight", getControlHighlight(),
"ToolBar.light", getControlHighlight(),
diff --git a/javax/swing/plaf/metal/MetalScrollBarUI.java b/javax/swing/plaf/metal/MetalScrollBarUI.java
index 75f2750ae..4c75fcb4f 100644
--- a/javax/swing/plaf/metal/MetalScrollBarUI.java
+++ b/javax/swing/plaf/metal/MetalScrollBarUI.java
@@ -1,5 +1,5 @@
/* MetalScrollBarUI.java
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -169,6 +169,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
Boolean prop = (Boolean) scrollbar.getClientProperty(FREE_STANDING_PROP);
isFreeStanding = prop == null ? true : prop.booleanValue();
scrollBarShadowColor = UIManager.getColor("ScrollBar.shadow");
+ scrollBarWidth = UIManager.getInt("ScrollBar.width");
super.installDefaults();
}
@@ -187,7 +188,10 @@ public class MetalScrollBarUI extends BasicScrollBarUI
/**
* Creates a new button to use as the control at the lower end of the
- * {@link JScrollBar}.
+ * {@link JScrollBar}. This method assigns the new button (an instance of
+ * {@link MetalScrollButton} to the {@link #decreaseButton} field, and also
+ * returns the button. The button width is determined by the
+ * <code>ScrollBar.width</code> setting in the UI defaults.
*
* @param orientation the orientation of the button ({@link #NORTH},
* {@link #SOUTH}, {@link #EAST} or {@link #WEST}).
@@ -196,7 +200,6 @@ public class MetalScrollBarUI extends BasicScrollBarUI
*/
protected JButton createDecreaseButton(int orientation)
{
- scrollBarWidth = UIManager.getInt("ScrollBar.width");
decreaseButton = new MetalScrollButton(orientation, scrollBarWidth,
isFreeStanding);
return decreaseButton;
@@ -204,7 +207,10 @@ public class MetalScrollBarUI extends BasicScrollBarUI
/**
* Creates a new button to use as the control at the upper end of the
- * {@link JScrollBar}.
+ * {@link JScrollBar}. This method assigns the new button (an instance of
+ * {@link MetalScrollButton} to the {@link #increaseButton} field, and also
+ * returns the button. The button width is determined by the
+ * <code>ScrollBar.width</code> setting in the UI defaults.
*
* @param orientation the orientation of the button ({@link #NORTH},
* {@link #SOUTH}, {@link #EAST} or {@link #WEST}).
@@ -213,7 +219,6 @@ public class MetalScrollBarUI extends BasicScrollBarUI
*/
protected JButton createIncreaseButton(int orientation)
{
- scrollBarWidth = UIManager.getInt("ScrollBar.width");
increaseButton = new MetalScrollButton(orientation, scrollBarWidth,
isFreeStanding);
return increaseButton;
diff --git a/javax/swing/plaf/metal/OceanTheme.java b/javax/swing/plaf/metal/OceanTheme.java
index 9d76ff7e8..1ea0bc243 100644
--- a/javax/swing/plaf/metal/OceanTheme.java
+++ b/javax/swing/plaf/metal/OceanTheme.java
@@ -266,6 +266,8 @@ public class OceanTheme extends DefaultMetalTheme
defaults.put("Tree.selectionBorderColor", PRIMARY1);
// Borders.
+ defaults.put("List.focusCellHighlightBorder",
+ new LineBorderUIResource(getPrimary1()));
defaults.put("Table.focusCellHighlightBorder",
new LineBorderUIResource(getPrimary1()));
diff --git a/javax/swing/text/html/HTMLEditorKit.java b/javax/swing/text/html/HTMLEditorKit.java
index 3bf380c6f..523c2aca0 100644
--- a/javax/swing/text/html/HTMLEditorKit.java
+++ b/javax/swing/text/html/HTMLEditorKit.java
@@ -1148,7 +1148,8 @@ public class HTMLEditorKit
try
{
styleSheet = new StyleSheet();
- InputStream in = getClass().getResourceAsStream(DEFAULT_CSS);
+ Class c = HTMLEditorKit.class;
+ InputStream in = c.getResourceAsStream(DEFAULT_CSS);
InputStreamReader r = new InputStreamReader(in);
styleSheet.loadRules(r, null);
r.close();
diff --git a/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index 26a30f0cc..3766485ab 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -77,7 +77,7 @@ public class DefaultTreeCellRenderer
protected boolean hasFocus;
/**
- * drawsFocusBorderAroundIcon // FIXME: is this used?
+ * Indicates if the focus border is also drawn around the icon.
*/
private boolean drawsFocusBorderAroundIcon;
@@ -152,6 +152,8 @@ public class DefaultTreeCellRenderer
setBackgroundNonSelectionColor(UIManager.getColor("Tree.textBackground"));
setBackgroundSelectionColor(UIManager.getColor("Tree.selectionBackground"));
setBorderSelectionColor(UIManager.getColor("Tree.selectionBorderColor"));
+ Object val = UIManager.get("Tree.drawsFocusBorderAroundIcon");
+ drawsFocusBorderAroundIcon = val != null && ((Boolean) val).booleanValue();
}
/**
@@ -499,48 +501,66 @@ public class DefaultTreeCellRenderer
*/
public void paint(Graphics g)
{
- // paint background
- Rectangle vr = new Rectangle();
- Rectangle ir = new Rectangle();
- Rectangle tr = new Rectangle();
-
- Insets insets = new Insets(0, 0, 0, 0);
- Border border = UIManager.getBorder("Tree.selectionBorder");
- if (border != null)
- insets = border.getBorderInsets(this);
-
- FontMetrics fm = getToolkit().getFontMetrics(getFont());
- SwingUtilities.layoutCompoundLabel((JLabel) this, fm, getText(),
- getIcon(), getVerticalAlignment(),
- getHorizontalAlignment(),
- getVerticalTextPosition(),
- getHorizontalTextPosition(), vr, ir, tr,
- getIconTextGap());
-
- // Reusing one rectangle.
- Rectangle bounds = getBounds(ir);
-
- bounds.x = tr.x - insets.left;
- bounds.width = tr.width + insets.left + insets.right;
-
- g.setColor(super.getBackground());
- g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+ // Determine background color.
+ Color bgColor;
+ if (selected)
+ bgColor = getBackgroundSelectionColor();
+ else
+ {
+ bgColor = getBackgroundNonSelectionColor();
+ if (bgColor == null)
+ bgColor = getBackground();
+ }
+ // Paint background.
+ int xOffset = -1;
+ if (bgColor != null)
+ {
+ Icon i = getIcon();
+ xOffset = getXOffset();
+ g.setColor(bgColor);
+ g.fillRect(xOffset, 0, getWidth() - xOffset, getHeight());
+ }
- super.paint(g);
-
- // Paint the border of the focused element only (lead selection)
if (hasFocus)
{
- Color b = getBorderSelectionColor();
- if (b != null)
- {
- g.setColor(b);
- g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height - 1);
- }
+ if (drawsFocusBorderAroundIcon)
+ xOffset = 0;
+ else if (xOffset == -1)
+ xOffset = getXOffset();
+ paintFocus(g, xOffset, 0, getWidth() - xOffset, getHeight());
+ }
+ super.paint(g);
+ }
+
+ /**
+ * Paints the focus indicator.
+ */
+ private void paintFocus(Graphics g, int x, int y, int w, int h)
+ {
+ Color col = getBorderSelectionColor();
+ if (col != null)
+ {
+ g.setColor(col);
+ g.drawRect(x, y, w - 1, h - 1);
}
}
/**
+ * Determines the X offset of the label that is caused by
+ * the icon.
+ *
+ * @return the X offset of the label
+ */
+ private int getXOffset()
+ {
+ Icon i = getIcon();
+ int offs = 0;
+ if (i != null && getText() != null)
+ offs = i.getIconWidth() + Math.max(0, getIconTextGap() - 1);
+ return offs;
+ }
+
+ /**
* Returns the preferred size of the cell.
*
* @return The preferred size of the cell.
diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index e8cbf4bb4..afee7ea22 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/javax/swing/tree/DefaultTreeModel.java
@@ -210,17 +210,32 @@ public class DefaultTreeModel
}
/**
- * isLeaf
+ * Returns if the specified node is a leaf or not. When
+ * {@link #asksAllowsChildren} is true, then this checks if the TreeNode
+ * allows children, otherwise it returns the TreeNode's <code>leaf</code>
+ * property.
*
- * @param node TODO
- * @return boolean
+ * @param node the node to check
+ *
+ * @return boolean <code>true</code> if the node is a leaf node,
+ * <code>false</code> otherwise
+ *
+ * @throws ClassCastException if the specified node is not a
+ * <code>TreeNode</code> instance
+ *
+ * @see TreeNode#getAllowsChildren()
+ * @see TreeNode#isLeaf()
*/
public boolean isLeaf(Object node)
{
- if (node instanceof TreeNode)
- return ((TreeNode) node).isLeaf();
+ // The RI throws a ClassCastException when node isn't a TreeNode, so do we.
+ TreeNode treeNode = (TreeNode) node;
+ boolean leaf;
+ if (asksAllowsChildren)
+ leaf = ! treeNode.getAllowsChildren();
else
- return true;
+ leaf = treeNode.isLeaf();
+ return leaf;
}
/**
diff --git a/javax/swing/tree/VariableHeightLayoutCache.java b/javax/swing/tree/VariableHeightLayoutCache.java
index 03251eb1f..b256f1fe9 100644
--- a/javax/swing/tree/VariableHeightLayoutCache.java
+++ b/javax/swing/tree/VariableHeightLayoutCache.java
@@ -339,6 +339,12 @@ public class VariableHeightLayoutCache
return null;
if (dirty)
update();
+
+ // The RI allows null arguments for rect, in which case a new Rectangle
+ // is created.
+ if (rect == null)
+ rect = new Rectangle();
+
Object last = path.getLastPathComponent();
NodeRecord r = (NodeRecord) nodes.get(last);
if (r == null)
diff --git a/native/fdlibm/mprec.c b/native/fdlibm/mprec.c
index e53722f7b..8a7cdc039 100644
--- a/native/fdlibm/mprec.c
+++ b/native/fdlibm/mprec.c
@@ -101,7 +101,7 @@ typedef unsigned long __ULong;
typedef long __Long;
static void *
-_calloc_r (void *ignore, size_t x1, size_t x2)
+mprec_calloc (void *ignore, size_t x1, size_t x2)
{
char *result = (char *) malloc (x1 * x2);
memset (result, 0, x1 * x2);
@@ -119,7 +119,7 @@ _DEFUN (Balloc, (ptr, k), struct _reent *ptr _AND int k)
if (_REENT_MP_FREELIST(ptr) == NULL)
{
/* Allocate a list of pointers to the mprec objects */
- _REENT_MP_FREELIST(ptr) = (struct _Bigint **) _calloc_r (ptr,
+ _REENT_MP_FREELIST(ptr) = (struct _Bigint **) mprec_calloc (ptr,
sizeof (struct _Bigint *),
new_k);
if (_REENT_MP_FREELIST(ptr) == NULL)
@@ -150,7 +150,7 @@ _DEFUN (Balloc, (ptr, k), struct _reent *ptr _AND int k)
{
x = 1 << k;
/* Allocate an mprec Bigint and stick in in the freelist */
- rv = (_Bigint *) _calloc_r (ptr,
+ rv = (_Bigint *) mprec_calloc (ptr,
1,
sizeof (_Bigint) +
(x-1) * sizeof(rv->_x));
@@ -666,7 +666,7 @@ double
_DEFUN (ulp, (_x), double _x)
{
union double_union x, a;
- register __Long L;
+ register int32_t L;
x.d = _x;
diff --git a/native/fdlibm/mprec.h b/native/fdlibm/mprec.h
index 7c7471bc8..0efa2d989 100644
--- a/native/fdlibm/mprec.h
+++ b/native/fdlibm/mprec.h
@@ -100,7 +100,7 @@ union double_union
* An alternative that might be better on some machines is
* #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
*/
-#if defined(IEEE_8087) + defined(VAX)
+#if defined(__IEEE_BYTES_LITTLE_ENDIAN) + defined(IEEE_8087) + defined(VAX)
#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
((unsigned short *)a)[0] = (unsigned short)c, a++)
#else
diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c
index e28c6631b..607b54d57 100644
--- a/native/jni/classpath/jcl.c
+++ b/native/jni/classpath/jcl.c
@@ -1,5 +1,5 @@
/* jcl.c
- Copyright (C) 1998, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,6 +48,57 @@ exception statement from your version. */
#endif
#endif
+/*
+ * Cached Pointer class info.
+ */
+static jclass rawDataClass = NULL;
+static jfieldID rawData_fid = NULL;
+static jmethodID rawData_mid = NULL;
+
+/*
+ * JNI OnLoad constructor.
+ */
+jint
+JNI_OnLoad (JavaVM *vm, void *reserved __attribute__((unused)))
+{
+ JNIEnv *env;
+ void *envp;
+
+ if ((*vm)->GetEnv (vm, &envp, JNI_VERSION_1_4) != JNI_OK)
+ {
+ return JNI_VERSION_1_4;
+ }
+ env = (JNIEnv *) envp;
+#if SIZEOF_VOID_P == 8
+ rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer64");
+ if (rawDataClass != NULL)
+ rawDataClass = (*env)->NewGlobalRef (env, rawDataClass);
+
+ if (rawDataClass != NULL)
+ {
+ rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "J");
+ rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(J)V");
+ }
+#else
+#if SIZEOF_VOID_P == 4
+ rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer32");
+ if (rawDataClass != NULL)
+ rawDataClass = (*env)->NewGlobalRef (env, rawDataClass);
+
+ if (rawDataClass != NULL)
+ {
+ rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "I");
+ rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(I)V");
+ }
+#else
+#error "Pointer size is not supported."
+#endif /* SIZEOF_VOID_P == 4 */
+#endif /* SIZEOF_VOID_P == 8 */
+
+ return JNI_VERSION_1_4;
+}
+
+
JNIEXPORT void JNICALL
JCL_ThrowException (JNIEnv * env, const char *className, const char *errMsg)
{
@@ -183,78 +234,17 @@ JCL_FindClass (JNIEnv * env, const char *className)
/*
- * Build a Pointer object. The function caches the class type
+ * Build a Pointer object.
*/
-static jclass rawDataClass;
-static jfieldID rawData_fid;
-static jmethodID rawData_mid;
-
JNIEXPORT jobject JNICALL
JCL_NewRawDataObject (JNIEnv * env, void *data)
{
- if (rawDataClass == NULL)
+ if (rawDataClass == NULL || rawData_mid == NULL)
{
- jclass tmp;
-#if SIZEOF_VOID_P == 8
- rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer64");
- if (rawDataClass == NULL)
- {
- JCL_ThrowException (env, "java/lang/InternalError",
- "unable to find internal class");
- return NULL;
- }
-
- rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(J)V");
- if (rawData_mid == NULL)
- {
- JCL_ThrowException (env, "java/lang/InternalError",
- "unable to find internal constructor");
- return NULL;
- }
-
- rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "J");
- if (rawData_fid == NULL)
- {
- JCL_ThrowException (env, "java/lang/InternalError",
- "unable to find internal field");
- return NULL;
- }
-#else
- rawDataClass = (*env)->FindClass (env, "gnu/classpath/Pointer32");
- if (rawDataClass == NULL)
- {
- JCL_ThrowException (env, "java/lang/InternalError",
- "unable to find internal class");
- return NULL;
- }
-
- rawData_mid = (*env)->GetMethodID (env, rawDataClass, "<init>", "(I)V");
- if (rawData_mid == NULL)
- {
- JCL_ThrowException (env, "java/lang/InternalError",
- "unable to find internal constructor");
- return NULL;
- }
-
- rawData_fid = (*env)->GetFieldID (env, rawDataClass, "data", "I");
- if (rawData_fid == NULL)
- {
- JCL_ThrowException (env, "java/lang/InternalError",
- "unable to find internal field");
- return NULL;
- }
-
-#endif
- tmp = (*env)->NewGlobalRef (env, rawDataClass);
- if (tmp == NULL)
- {
- JCL_ThrowException (env, "java/lang/InternalError",
- "unable to create an internal global ref");
- return NULL;
- }
- (*env)->DeleteLocalRef(env, rawDataClass);
- rawDataClass = tmp;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Pointer class was not properly initialized");
+ return NULL;
}
#if SIZEOF_VOID_P == 8
@@ -267,6 +257,13 @@ JCL_NewRawDataObject (JNIEnv * env, void *data)
JNIEXPORT void * JNICALL
JCL_GetRawData (JNIEnv * env, jobject rawdata)
{
+ if (rawData_fid == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "Pointer class was not properly initialized");
+ return NULL;
+ }
+
#if SIZEOF_VOID_P == 8
return (void *) (*env)->GetLongField (env, rawdata, rawData_fid);
#else
diff --git a/native/jni/gconf-peer/GConfNativePeer.c b/native/jni/gconf-peer/GConfNativePeer.c
index a442226ca..42986c33a 100644
--- a/native/jni/gconf-peer/GConfNativePeer.c
+++ b/native/jni/gconf-peer/GConfNativePeer.c
@@ -108,8 +108,8 @@ static jclass get_jlist_reference (JNIEnv * env, jclass jlist_class);
* Method: init_class
* Signature: ()V
*/
-JNIEXPORT void
-JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
(JNIEnv *env, jclass clazz)
{
if (reference_count == 0)
@@ -127,8 +127,8 @@ JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
* Method: init_id_chache
* Signature: ()V
*/
-JNIEXPORT void
-JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
(JNIEnv *env, jclass clazz __attribute__ ((unused)))
{
reference_count++;
@@ -157,16 +157,19 @@ JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
/*
* Class: gnu_java_util_prefs_gconf_GConfNativePeer
- * Method: gconf_client_gconf_client_all_keys
+ * Method: gconf_client_all_keys
* Signature: (Ljava/lang/String;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1keys
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1keys
(JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
/* TODO: check all the calls to gdk_threads_enter/leave */
const char *dir = NULL;
+ const char *_val = NULL;
+ const char *_val_unescaped = NULL;
+
GError *err = NULL;
GSList *entries = NULL;
GSList *tmp;
@@ -208,12 +211,18 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all
tmp = entries;
while (tmp != NULL)
{
- const char *_val = gconf_entry_get_key (tmp->data);
+ _val = gconf_entry_get_key (tmp->data);
_val = strrchr (_val, '/');
++_val;
+
+ _val_unescaped = gconf_unescape_key (_val, strlen (_val));
+
(*env)->CallBooleanMethod (env, jlist, jlist_add_id,
- (*env)->NewStringUTF (env, _val));
+ (*env)->NewStringUTF (env, _val_unescaped));
+
tmp = g_slist_next (tmp);
+
+ g_free ((gpointer) _val_unescaped);
}
/* clean up things */
@@ -226,14 +235,17 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all
/*
* Class: gnu_java_util_prefs_gconf_GConfNativePeer
- * Method: gconf_client_gconf_client_all_nodes
+ * Method: gconf_client_all_nodes
* Signature: (Ljava/lang/String;)Ljava/util/List;
*/
JNIEXPORT jobject JNICALL
-Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all_1nodes
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1all_1nodes
(JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring node)
{
const char *dir = NULL;
+ const char *_val = NULL;
+ const char *_val_unescaped = NULL;
+
GError *err = NULL;
GSList *entries = NULL;
GSList *tmp;
@@ -274,12 +286,19 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1gconf_1client_1all
tmp = entries;
while (tmp != NULL)
{
- const char *_val = tmp->data;
+ _val = tmp->data;
+
_val = strrchr (_val, '/');
++_val;
+
+ _val_unescaped = gconf_unescape_key (_val, strlen (_val));
+
(*env)->CallBooleanMethod (env, jlist, jlist_add_id,
- (*env)->NewStringUTF (env, _val));
+ (*env)->NewStringUTF (env, _val_unescaped));
+
tmp = g_slist_next (tmp);
+
+ g_free ((gpointer) _val_unescaped);
}
/* clean up things */
@@ -421,7 +440,7 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1set_1string
gdk_threads_leave ();
if (err != NULL)
{
- g_error_free (err);
+ g_error_free (err);
err = NULL;
result = JNI_FALSE;
}
@@ -511,8 +530,8 @@ Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1client_1dir_1exists
* Method: finalize_class
* Signature: ()V
*/
-JNIEXPORT void
-JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
+JNIEXPORT void JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
(JNIEnv *env, jclass clazz __attribute__ ((unused)))
{
if (reference_count == 0)
@@ -534,6 +553,74 @@ JNICALL Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
reference_count--;
}
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jstring JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1escape_1key
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring plain)
+{
+ const char *escaped = NULL;
+ const char *_plain = NULL;
+ jstring result = NULL;
+
+ _plain = JCL_jstring_to_cstring (env, plain);
+ if (_plain == NULL)
+ {
+ return NULL;
+ }
+
+ gdk_threads_enter ();
+ escaped = gconf_escape_key (_plain, strlen (_plain));
+ gdk_threads_leave ();
+
+ JCL_free_cstring (env, plain, _plain);
+ /* check for NULL, if so prevent string creation */
+ if (escaped != NULL)
+ {
+ result = (*env)->NewStringUTF (env, escaped);
+ g_free ((gpointer) escaped);
+ }
+
+ return result;
+}
+
+/*
+ * Class: gnu_java_util_prefs_gconf_GConfNativePeer
+ * Method: Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key
+ * Signature: (Ljava/lang/String;)Z
+ */
+JNIEXPORT jstring JNICALL
+Java_gnu_java_util_prefs_gconf_GConfNativePeer_gconf_1unescape_1key
+ (JNIEnv *env, jclass clazz __attribute__ ((unused)), jstring escaped)
+{
+ const char *plain = NULL;
+ const char *_escaped = NULL;
+ jstring result = NULL;
+
+ _escaped = JCL_jstring_to_cstring (env, escaped);
+ if (_escaped == NULL)
+ {
+ return NULL;
+ }
+
+ gdk_threads_enter ();
+ plain = gconf_unescape_key (_escaped, strlen (_escaped));
+ gdk_threads_leave ();
+
+ JCL_free_cstring (env, escaped, _escaped);
+ /* check for NULL, if so prevent string creation */
+ if (plain != NULL)
+ {
+ result = (*env)->NewStringUTF (env, plain);
+ g_free ((gpointer) plain);
+ }
+
+ return result;
+}
+
/* ***** END: NATIVE FUNCTIONS ***** */
/* ***** PRIVATE FUNCTIONS IMPLEMENTATION ***** */
diff --git a/native/jni/gconf-peer/Makefile.am b/native/jni/gconf-peer/Makefile.am
index d88218326..1c8c4a147 100644
--- a/native/jni/gconf-peer/Makefile.am
+++ b/native/jni/gconf-peer/Makefile.am
@@ -5,6 +5,8 @@ libgconfpeer_la_SOURCES = GConfNativePeer.c
libgconfpeer_la_LIBADD = $(top_builddir)/native/jni/classpath/native_state.lo \
$(top_builddir)/native/jni/classpath/jcl.lo
+libgconfpeer_la_LDFLAGS = -avoid-version
+
AM_LDFLAGS = @CLASSPATH_MODULE@ @GCONF_LIBS@ @GDK_LIBS@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
diff --git a/native/jni/gtk-peer/cairographics2d.h b/native/jni/gtk-peer/cairographics2d.h
index 675bc0b17..fc564a86a 100644
--- a/native/jni/gtk-peer/cairographics2d.h
+++ b/native/jni/gtk-peer/cairographics2d.h
@@ -97,7 +97,8 @@ enum java_awt_rendering_hints_filter
java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR = 1,
java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED = 2,
java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY = 3,
- java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT = 4
+ java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT = 4,
+ java_awt_rendering_hints_VALUE_INTERPOLATION_BICUBIC = 5
};
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
index 45cf4fbda..0a35a3f18 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
@@ -134,7 +134,11 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setGradient
cairo_pattern_add_color_stop_rgba(pattern, 1.0, r2 / 255.0, g2 / 255.0,
b2 / 255.0, a2 / 255.0);
- extend = (cyclic == JNI_TRUE) ? CAIRO_EXTEND_REFLECT : CAIRO_EXTEND_NONE;
+ #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
+ extend = (cyclic == JNI_TRUE) ? CAIRO_EXTEND_REFLECT : CAIRO_EXTEND_PAD;
+ #else
+ extend = (cyclic == JNI_TRUE) ? CAIRO_EXTEND_REFLECT : CAIRO_EXTEND_NONE;
+ #endif
cairo_pattern_set_extend( pattern, extend );
@@ -143,9 +147,9 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setGradient
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setTexturePixels
+Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setPaintPixels
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
- jlong pointer, jintArray jarr, jint w, jint h, jint stride)
+ jlong pointer, jintArray jarr, jint w, jint h, jint stride, jboolean repeat)
{
struct cairographics2d *gr = NULL;
jint *jpixels = NULL;
@@ -180,7 +184,12 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_setTexturePixels
g_assert (gr->pattern_surface != NULL);
gr->pattern = cairo_pattern_create_for_surface (gr->pattern_surface);
g_assert (gr->pattern != NULL);
- cairo_pattern_set_extend (gr->pattern, CAIRO_EXTEND_REPEAT);
+
+ if (repeat)
+ cairo_pattern_set_extend (gr->pattern, CAIRO_EXTEND_REPEAT);
+ else
+ cairo_pattern_set_extend (gr->pattern, CAIRO_EXTEND_NONE);
+
cairo_set_source (gr->cr, gr->pattern);
}
@@ -188,7 +197,8 @@ JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
jlong pointer, jintArray java_pixels,
- jint w, jint h, jint stride, jdoubleArray java_matrix, jdouble alpha)
+ jint w, jint h, jint stride, jdoubleArray java_matrix, jdouble alpha,
+ jint interpolation)
{
jint *native_pixels = NULL;
jdouble *native_matrix = NULL;
@@ -215,8 +225,28 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_drawPixels
p = cairo_pattern_create_for_surface (surf);
cairo_pattern_set_matrix (p, &mat);
- if (gr->pattern)
- cairo_pattern_set_filter (p, cairo_pattern_get_filter (gr->pattern));
+ switch ((enum java_awt_rendering_hints_filter) interpolation)
+ {
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_NEAREST);
+ break;
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_BILINEAR);
+ break;
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_BICUBIC:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_GAUSSIAN);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_FAST);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_NEAREST);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_BEST);
+ break;
+ }
+
cairo_set_source (gr->cr, p);
if (alpha == 1.)
cairo_paint (gr->cr);
@@ -679,37 +709,6 @@ Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoPreserveClip
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoSurfaceSetFilter
-(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
- jlong pointer, jint filter)
-{
- struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, pointer);
- g_assert (gr != NULL);
-
- if (gr->pattern == NULL)
- return;
-
- switch ((enum java_awt_rendering_hints_filter) filter)
- {
- case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR:
- cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST);
- break;
- case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR:
- cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BILINEAR);
- break;
- case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED:
- cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_FAST);
- break;
- case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT:
- cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_NEAREST);
- break;
- case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY:
- cairo_pattern_set_filter (gr->pattern, CAIRO_FILTER_BEST);
- break;
- }
-}
-
-JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawLine
(JNIEnv *env __attribute__ ((unused)), jobject obj __attribute__ ((unused)),
jlong pointer, jdouble x1, jdouble y1, jdouble x2, jdouble y2)
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
index a25f764b4..350cd345a 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
@@ -181,7 +181,8 @@ Java_gnu_java_awt_peer_gtk_CairoSurface_nativeSetPixels
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_CairoSurface_nativeDrawSurface
(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
- jlong surfacePointer, jlong context, jdoubleArray java_matrix, double alpha)
+ jlong surfacePointer, jlong context, jdoubleArray java_matrix, double alpha,
+ jint interpolation)
{
struct cairographics2d *gr = JLONG_TO_PTR(struct cairographics2d, context);
cairo_t *cr = gr->cr;
@@ -205,6 +206,27 @@ Java_gnu_java_awt_peer_gtk_CairoSurface_nativeDrawSurface
p = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_matrix (p, &mat);
+ switch ((enum java_awt_rendering_hints_filter) interpolation)
+ {
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_NEAREST_NEIGHBOR:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_NEAREST);
+ break;
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_BILINEAR:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_BILINEAR);
+ break;
+ case java_awt_rendering_hints_VALUE_INTERPOLATION_BICUBIC:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_GAUSSIAN);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_SPEED:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_FAST);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_DEFAULT:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_NEAREST);
+ break;
+ case java_awt_rendering_hints_VALUE_ALPHA_INTERPOLATION_QUALITY:
+ cairo_pattern_set_filter (p, CAIRO_FILTER_BEST);
+ break;
+ }
cairo_set_source(cr, p);
if (alpha == 1.0)
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
index e391d64ec..3fb5331a2 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
@@ -88,7 +88,7 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_init (JNIEnv *env,
*/
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkVolatileImage_destroy
-(JNIEnv *env __attribute__((unused)), jobject obj __attribute((unused)),
+(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
jlong pointer)
{
GdkPixmap* pixmap = JLONG_TO_PTR(GdkPixmap, pointer);
@@ -110,10 +110,12 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeGetPixels
/* jint *pixeldata, *jpixdata; */
jint *jpixdata;
GdkPixmap *pixmap;
+ GdkPixbuf *pixbuf;
jintArray jpixels;
int width, height, depth, size;
jclass cls;
jfieldID field;
+ guchar *pixels;
cls = (*env)->GetObjectClass (env, obj);
field = (*env)->GetFieldID (env, cls, "width", "I");
@@ -131,11 +133,19 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeGetPixels
/* get depth in bytes */
depth = gdk_drawable_get_depth( pixmap ) >> 3;
- size = width * height * 4;
+ size = width * height;
jpixels = (*env)->NewIntArray ( env, size );
jpixdata = (*env)->GetIntArrayElements (env, jpixels, NULL);
- /* memcpy (jpixdata, pixeldata, size * sizeof( jint )); */
-
+
+ pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, width, height );
+ gdk_pixbuf_get_from_drawable( pixbuf, pixmap, NULL, 0, 0, 0, 0, width, height );
+
+ if (pixbuf != NULL)
+ {
+ pixels = gdk_pixbuf_get_pixels(pixbuf);
+ memcpy (jpixdata, pixels, size * sizeof(jint));
+ }
+
(*env)->ReleaseIntArrayElements (env, jpixels, jpixdata, 0);
gdk_threads_leave();
@@ -148,7 +158,7 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeGetPixels
*/
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeCopyArea
-(JNIEnv *env __attribute__((unused)), jobject obj __attribute((unused)),
+(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
jlong pointer, jint x, jint y, jint w, jint h, jint dx, jint dy)
{
GdkPixbuf *pixbuf;
@@ -169,7 +179,7 @@ Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeCopyArea
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkVolatileImage_nativeDrawVolatile
-(JNIEnv *env __attribute__((unused)), jobject obj __attribute((unused)),
+(JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)),
jlong pointer, jlong srcptr, jint x, jint y, jint w, jint h)
{
GdkPixmap *dst, *src;
diff --git a/native/jni/java-io/java_io_VMFile.c b/native/jni/java-io/java_io_VMFile.c
index 3f9282049..de1320b0c 100644
--- a/native/jni/java-io/java_io_VMFile.c
+++ b/native/jni/java-io/java_io_VMFile.c
@@ -593,7 +593,7 @@ Java_java_io_VMFile_list (JNIEnv * env, jobject obj
int result;
char **filelist;
void *handle;
- const char *filename;
+ char *filename = (char *) JCL_malloc (env, FILENAME_MAX);
unsigned long int filelist_count, max_filelist_count;
char **tmp_filelist;
jclass str_clazz;
@@ -630,7 +630,7 @@ Java_java_io_VMFile_list (JNIEnv * env, jobject obj
max_filelist_count = REALLOC_SIZE;
/* read the files from the directory */
- result = cpio_readDir (handle, &filename);
+ result = cpio_readDir (handle, filename);
while (result == CPNATIVE_OK)
{
if ((strcmp (filename, ".") != 0) && (strcmp (filename, "..") != 0))
@@ -666,9 +666,11 @@ Java_java_io_VMFile_list (JNIEnv * env, jobject obj
}
/* read next directory entry */
- result = cpio_readDir (handle, &filename);
+ result = cpio_readDir (handle, filename);
}
+ JCL_free (env, filename);
+
/* close directory */
result = cpio_closeDir (handle);
@@ -693,6 +695,9 @@ Java_java_io_VMFile_list (JNIEnv * env, jobject obj
JCL_free (env, filelist);
return 0;
}
+
+ (*env)->DeleteLocalRef (env, str_clazz);
+
for (i = 0; i < filelist_count; i++)
{
/* create new string */
diff --git a/native/jni/java-lang/java_lang_VMDouble.c b/native/jni/java-lang/java_lang_VMDouble.c
index 8435c3fdb..f8c072192 100644
--- a/native/jni/java-lang/java_lang_VMDouble.c
+++ b/native/jni/java-lang/java_lang_VMDouble.c
@@ -121,17 +121,8 @@ Java_java_lang_VMDouble_doubleToLongBits
{
jvalue val;
jlong e, f;
- val.d = doubleValue;
-
-#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
- /* On little endian ARM processors when using FPA, word order of
- doubles is still big endian. So take that into account here. When
- using VFP, word order of doubles follows byte order. */
-
-#define SWAP_DOUBLE(a) (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff))
- val.j = SWAP_DOUBLE(val.j);
-#endif
+ val.d = doubleValue;
e = val.j & 0x7ff0000000000000LL;
f = val.j & 0x000fffffffffffffLL;
@@ -153,11 +144,8 @@ Java_java_lang_VMDouble_doubleToRawLongBits
jclass cls __attribute__ ((__unused__)), jdouble doubleValue)
{
jvalue val;
- val.d = doubleValue;
-#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
- val.j = SWAP_DOUBLE(val.j);
-#endif
+ val.d = doubleValue;
return val.j;
}
@@ -173,11 +161,8 @@ Java_java_lang_VMDouble_longBitsToDouble
jclass cls __attribute__ ((__unused__)), jlong longValue)
{
jvalue val;
- val.j = longValue;
-#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
- val.j = SWAP_DOUBLE(val.j);
-#endif
+ val.j = longValue;
return val.d;
}
diff --git a/native/jni/java-lang/java_lang_VMProcess.c b/native/jni/java-lang/java_lang_VMProcess.c
index e9d85fa65..a6076f2ae 100644
--- a/native/jni/java-lang/java_lang_VMProcess.c
+++ b/native/jni/java-lang/java_lang_VMProcess.c
@@ -38,7 +38,7 @@ exception statement from your version. */
#include <config.h>
#include "java_lang_VMProcess.h"
-#include "gnu_java_nio_channels_FileChannelImpl.h"
+#include "gnu_java_nio_FileChannelImpl.h"
#include <sys/types.h>
#include <sys/wait.h>
@@ -137,8 +137,8 @@ Java_java_lang_VMProcess_nativeSpawn (JNIEnv * env, jobject this,
char *dir = NULL;
pid_t pid = -1;
char errbuf[64];
- jmethodID method;
- jclass clazz;
+ jmethodID method, vmmethod;
+ jclass clazz, vmclazz;
int i;
int pipe_count = redirect ? 2 : 3;
int err;
@@ -214,10 +214,12 @@ Java_java_lang_VMProcess_nativeSpawn (JNIEnv * env, jobject this,
}
/* Create Input/OutputStream objects around parent file descriptors */
- clazz = (*env)->FindClass (env, "gnu/java/nio/channels/FileChannelImpl");
+ vmclazz = (*env)->FindClass (env, "gnu/java/nio/VMChannel");
+ clazz = (*env)->FindClass (env, "gnu/java/nio/FileChannelImpl");
if ((*env)->ExceptionOccurred (env))
goto done;
- method = (*env)->GetMethodID (env, clazz, "<init>", "(II)V");
+ vmmethod = (*env)->GetMethodID (env, vmclazz, "<init>", "(I)V");
+ method = (*env)->GetMethodID (env, clazz, "<init>", "(Lgnu/java/nio/VMChannel;I)V");
if ((*env)->ExceptionOccurred (env))
goto done;
for (i = 0; i < pipe_count; i++)
@@ -228,11 +230,16 @@ Java_java_lang_VMProcess_nativeSpawn (JNIEnv * env, jobject this,
jclass sclazz;
jmethodID smethod;
- jobject channel = (*env)->NewObject (env, clazz, method, fd, mode);
+ jobject vmchannel;
+ jobject channel;
+ vmchannel = (*env)->NewObject (env, vmclazz, vmmethod, fd);
+ if ((*env)->ExceptionOccurred (env))
+ goto done;
+ channel = (*env)->NewObject (env, clazz, method, vmchannel, mode);
if ((*env)->ExceptionOccurred (env))
goto done;
- if (mode == gnu_java_nio_channels_FileChannelImpl_WRITE)
+ if (mode == gnu_java_nio_FileChannelImpl_WRITE)
sclazz = (*env)->FindClass (env, "java/io/FileOutputStream");
else
sclazz = (*env)->FindClass (env, "java/io/FileInputStream");
@@ -240,7 +247,7 @@ Java_java_lang_VMProcess_nativeSpawn (JNIEnv * env, jobject this,
goto done;
smethod = (*env)->GetMethodID (env, sclazz, "<init>",
- "(Lgnu/java/nio/channels/FileChannelImpl;)V");
+ "(Lgnu/java/nio/FileChannelImpl;)V");
if ((*env)->ExceptionOccurred (env))
goto done;
diff --git a/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c b/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
index fb9855908..6ebb64fa5 100644
--- a/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
+++ b/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
@@ -35,265 +35,800 @@ 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. */
-/* do not move; needed here because of some macro definitions */
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <ifaddrs.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <jni.h>
#include <jcl.h>
-#include <cpnative.h>
-#include <cpnet.h>
-#include "javanet.h"
+/* #include "javanet.h" */
#include "gnu_java_net_VMPlainSocketImpl.h"
-/*
- * Note that the functions in this module simply redirect to another
- * internal function. Why? Because many of these functions are shared
- * with PlainDatagramSocketImpl. The unshared ones were done the same
- * way for consistency.
- */
+#define IO_EXCEPTION "java/io/IOException"
+#define SOCKET_EXCEPTION "java/net/SocketException"
+#define BIND_EXCEPTION "java/net/BindException"
+
+#define THROW_NO_NETWORK(env) JCL_ThrowException (env, "java/lang/InternalError", "this platform not configured for network support")
-/*************************************************************************/
/*
- * Creates a new stream or datagram socket
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: bind
+ * Signature: (I[BI)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_create(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj)
+Java_gnu_java_net_VMPlainSocketImpl_bind (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jint fd, jbyteArray addr, jint port)
{
-#ifndef WITHOUT_NETWORK
- _javanet_create(env, obj, JNI_TRUE);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+ struct sockaddr_in sockaddr;
+ jbyte *elems = NULL;
+ int ret;
+
+ if (addr != NULL)
+ elems = (*env)->GetByteArrayElements (env, addr, NULL);
+
+ memset(&sockaddr, 0, sizeof (struct sockaddr_in));
+ sockaddr.sin_family = AF_INET;
+ sockaddr.sin_port = htons (port);
+ /* addr is already in network byte order. */
+ if (elems != NULL)
+ sockaddr.sin_addr.s_addr = *((uint32_t *) elems);
+ else
+ sockaddr.sin_addr.s_addr = INADDR_ANY;
+
+ /* bind(2) from BSD says bind will never return EINTR */
+ /* bind is not a blocking system call */
+ ret = bind (fd, (struct sockaddr *) &sockaddr, sizeof (struct sockaddr_in));
+
+ if (elems != NULL)
+ (*env)->ReleaseByteArrayElements (env, addr, elems, JNI_ABORT);
+
+ if (-1 == ret)
+ JCL_ThrowException (env, BIND_EXCEPTION, strerror (errno));
}
-/*************************************************************************/
/*
- * Close the socket. Any underlying streams will be closed by this
- * action as well.
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: bind6
+ * Signature: (I[BI)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_close(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj)
+Java_gnu_java_net_VMPlainSocketImpl_bind6 (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jbyteArray addr, jint port)
{
-#ifndef WITHOUT_NETWORK
- _javanet_close(env, obj, 1);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+ /* FIXME! Add check if we have IPv6! */
+ struct sockaddr_in6 sockaddr;
+ jbyte *elems;
+ int ret;
+
+ elems = (*env)->GetByteArrayElements (env, addr, NULL);
+
+ memset (&sockaddr, 0, sizeof (struct sockaddr_in6));
+ sockaddr.sin6_family = AF_INET6;
+ sockaddr.sin6_port = htons (port);
+ memcpy (&sockaddr.sin6_addr.s6_addr, elems, 16);
+
+ /* bind(2) from BSD says bind will never return EINTR */
+ /* bind is not a blocking system call */
+ ret = bind (fd, (struct sockaddr *) &sockaddr,
+ sizeof (struct sockaddr_in6));
+
+ (*env)->ReleaseByteArrayElements (env, addr, elems, JNI_ABORT);
+
+ if (-1 == ret)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
}
-/*************************************************************************/
/*
- * Connects to the specified destination.
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: listen
+ * Signature: (II)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_connect(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj,
- jobject addr, jint port)
+Java_gnu_java_net_VMPlainSocketImpl_listen (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jint backlog)
{
-#ifndef WITHOUT_NETWORK
- _javanet_connect(env, obj, addr, port, 1);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+ int ret;
+
+ /* listen(2) says that this call will never return EINTR */
+ /* listen is not a blocking system call */
+ if ((ret = listen (fd, backlog)) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
}
-/*************************************************************************/
+
+/* These constants are also defined in java/net/SocketOptions.java */
+enum java_sockopt {
+ CPNET_SO_KEEPALIVE = 0x8,
+ CPNET_SO_LINGER = 0x80,
+ CPNET_SO_TIMEOUT = 0x1006,
+ CPNET_SO_BINDADDR = 0x0F,
+ CPNET_SO_SNDBUF = 0x1001,
+ CPNET_SO_RCVBUF = 0x1002,
+ CPNET_SO_REUSEADDR = 0x04,
+ CPNET_SO_BROADCAST = 0x20,
+ CPNET_SO_OOBINLINE = 0x1003,
+ CPNET_TCP_NODELAY = 0x01,
+ CPNET_IP_MULTICAST_IF = 0x10,
+ CPNET_IP_MULTICAST_IF2 = 0x1F,
+ CPNET_IP_MULTICAST_LOOP = 0x12,
+ CPNET_IP_TOS = 0x03
+};
+
/*
- * This method binds the specified address to the specified local port.
- * Note that we have to set the local address and local port public instance
- * variables.
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: setOption
+ * Signature: (III)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_bind(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj, jobject addr,
- jint port)
+Java_gnu_java_net_VMPlainSocketImpl_setOption (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jint option, jint value)
{
-#ifndef WITHOUT_NETWORK
- _javanet_bind(env, obj, addr, port, 1);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+ enum java_sockopt joption = (enum java_sockopt) option;
+ int optname = -1;
+ int level = SOL_SOCKET;
+ const int _value = value;
+ struct linger _linger;
+ struct timeval _timeo;
+ void *optval = (void *) &_value;
+ socklen_t optlen = sizeof (int);
+
+ switch (joption)
+ {
+ case CPNET_IP_MULTICAST_LOOP:
+ level = IPPROTO_IP;
+ optname = IP_MULTICAST_LOOP;
+ break;
+
+ case CPNET_SO_KEEPALIVE:
+ optname = SO_KEEPALIVE;
+ break;
+
+ case CPNET_SO_LINGER:
+ optname = SO_LINGER;
+ if (_value == 0)
+ _linger.l_onoff = 0;
+ else
+ _linger.l_onoff = 1;
+ _linger.l_linger = _value;
+ optval = &_linger;
+ optlen = sizeof (struct linger);
+ break;
+
+ case CPNET_SO_TIMEOUT:
+ optname = SO_RCVTIMEO;
+ _timeo.tv_sec = value / 1000;
+ _timeo.tv_usec = (value % 1000) * 1000;
+ optval = &_timeo;
+ optlen = sizeof (struct timeval);
+ break;
+
+ case CPNET_SO_SNDBUF:
+ optname = SO_SNDBUF;
+ break;
+
+ case CPNET_SO_RCVBUF:
+ optname = SO_RCVBUF;
+ break;
+
+ case CPNET_SO_REUSEADDR:
+ optname = SO_REUSEADDR;
+ break;
+
+ case CPNET_SO_BROADCAST:
+ optname = SO_BROADCAST;
+ break;
+
+ case CPNET_SO_OOBINLINE:
+ optname = SO_OOBINLINE;
+ break;
+
+ case CPNET_TCP_NODELAY:
+ level = IPPROTO_TCP;
+ optname = TCP_NODELAY;
+ break;
+
+ case CPNET_IP_TOS:
+ level = IPPROTO_IP;
+ optname = IP_TOS;
+ break;
+
+ case CPNET_SO_BINDADDR:
+ case CPNET_IP_MULTICAST_IF:
+ case CPNET_IP_MULTICAST_IF2:
+ JCL_ThrowException (env, IO_EXCEPTION, "argument not a boolean or integer option");
+ return;
+ }
+
+ if (setsockopt (fd, level, optname, (const void *) optval, optlen) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+}
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: getOption
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_getOption (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jint option)
+{
+ enum java_sockopt joption = (enum java_sockopt) option;
+ int optname = -1;
+ int level = SOL_SOCKET;
+ int value;
+ struct linger linger;
+ struct timeval timeo;
+ void *optval = &value;
+ socklen_t optlen = sizeof (int);
+
+ switch (joption)
+ {
+ case CPNET_IP_MULTICAST_LOOP:
+ level = IPPROTO_IP;
+ optname = IP_MULTICAST_LOOP;
+ break;
+
+ case CPNET_SO_KEEPALIVE:
+ optname = SO_KEEPALIVE;
+ break;
+
+ case CPNET_SO_LINGER:
+ optname = SO_LINGER;
+ optval = &linger;
+ optlen = sizeof (struct linger);
+ break;
+
+ case CPNET_SO_TIMEOUT:
+ optname = SO_RCVTIMEO;
+ optval = &timeo;
+ optlen = sizeof (struct timeval);
+ break;
+
+ case CPNET_SO_SNDBUF:
+ optname = SO_SNDBUF;
+ break;
+
+ case CPNET_SO_RCVBUF:
+ optname = SO_RCVBUF;
+ break;
+
+ case CPNET_SO_REUSEADDR:
+ optname = SO_REUSEADDR;
+ break;
+
+ case CPNET_SO_BROADCAST:
+ optname = SO_BROADCAST;
+ break;
+
+ case CPNET_SO_OOBINLINE:
+ optname = SO_OOBINLINE;
+ break;
+
+ case CPNET_TCP_NODELAY:
+ level = IPPROTO_TCP;
+ optname = TCP_NODELAY;
+ break;
+
+ case CPNET_IP_TOS:
+ level = IPPROTO_IP;
+ optname = IP_TOS;
+ break;
+
+ case CPNET_SO_BINDADDR:
+ case CPNET_IP_MULTICAST_IF:
+ case CPNET_IP_MULTICAST_IF2:
+ JCL_ThrowException (env, IO_EXCEPTION, "argument not a boolean or integer option");
+ return -1;
+ }
+
+ if (getsockopt (fd, level, optname, optval, &optlen) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+ if (joption == CPNET_SO_LINGER)
+ return linger.l_linger;
+ if (joption == CPNET_SO_TIMEOUT)
+ return (timeo.tv_sec * 1000) + (timeo.tv_usec / 1000);
+
+ return value;
}
-/*************************************************************************/
/*
- * Starts listening on a socket with the specified number of pending
- * connections allowed.
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: shutdownInput
+ * Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_listen(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj, jint queuelen)
+Java_gnu_java_net_VMPlainSocketImpl_shutdownInput (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
{
-#ifndef WITHOUT_NETWORK
- _javanet_listen(env, obj, queuelen);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+ if (shutdown (fd, SHUT_RD) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
}
-/*************************************************************************/
-
/*
- * Accepts a new connection and assigns it to the passed in SocketImpl
- * object. Note that we assume this is a PlainSocketImpl just like us.
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: shutdownOutput
+ * Signature: (I)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_accept(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj, jobject impl)
+Java_gnu_java_net_VMPlainSocketImpl_shutdownOutput (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
{
-#ifndef WITHOUT_NETWORK
- _javanet_accept(env, obj, impl);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+ if (shutdown (fd, SHUT_WR) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
}
-/*************************************************************************/
-JNIEXPORT jint JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_available(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj)
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: sendUrgentData
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_sendUrgentData (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jint data)
{
-#ifndef WITHOUT_NETWORK
- jclass cls;
- jfieldID fid;
- int fd;
- int bytesAvailable;
- int result;
-
- cls = (*env)->GetObjectClass(env, obj);
- if (cls == 0)
- {
- JCL_ThrowException(env, IO_EXCEPTION, "internal error");
- return 0;
- }
-
- fid = (*env)->GetFieldID(env, cls, "native_fd", "I");
- if (fid == 0)
- {
- JCL_ThrowException(env, IO_EXCEPTION, "internal error");
- return 0;
- }
+ const char x = (char) data;
- fd = (*env)->GetIntField(env, obj, fid);
-
- result = cpnet_getAvailableBytes (env, fd, &bytesAvailable);
- if (result != CPNATIVE_OK)
- {
- JCL_ThrowException(env, IO_EXCEPTION, cpnative_getErrorString (result));
- return 0;
- }
-
- return bytesAvailable;
-#else /* not WITHOUT_NETWORK */
- return 0;
-#endif /* not WITHOUT_NETWORK */
+ if (send (fd, &x, 1, MSG_OOB) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
}
-/*************************************************************************/
/*
- * This method sets the specified option for a socket
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: join
+ * Signature: (I[B)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_setOption(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj,
- jint option_id, jobject val)
+Java_gnu_java_net_VMPlainSocketImpl_join (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jint fd, jbyteArray addr)
{
-#ifndef WITHOUT_NETWORK
- _javanet_set_option(env, obj, option_id, val);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+#ifdef HAVE_SETSOCKOPT
+ struct ip_mreq maddr;
+ jbyte *addr_elems;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ maddr.imr_multiaddr.s_addr = * ((uint32_t *) addr_elems);
+ maddr.imr_interface.s_addr = INADDR_ANY;
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ &maddr, sizeof (struct ip_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
}
-/*************************************************************************/
/*
- * This method gets the specified option for a socket
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: join6
+ * Signature: (I[B)V
*/
-JNIEXPORT jobject JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_getOption(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj,
- jint option_id)
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_join6 (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jint fd, jbyteArray addr)
{
-#ifndef WITHOUT_NETWORK
- return(_javanet_get_option(env, obj, option_id));
-#else /* not WITHOUT_NETWORK */
- return NULL;
-#endif /* not WITHOUT_NETWORK */
+#ifdef HAVE_SETSOCKOPT
+#ifdef HAVE_INET6
+ struct ipv6_mreq maddr;
+ jbyte *addr_elems;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ memcpy (&(maddr.ipv6mr_multiaddr.s6_addr), addr_elems, 16);
+ maddr.ipv6mr_interface = 0;
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &maddr, sizeof (struct ipv6_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "IPv6 support not available");
+#endif /* HAVE_INET6 */
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
}
-/*************************************************************************/
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leave
+ * Signature: (I[B)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_leave (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jbyteArray addr)
+{
+#ifdef HAVE_SETSOCKOPT
+ struct ip_mreq maddr;
+ jbyte *addr_elems;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ maddr.imr_multiaddr.s_addr = * ((uint32_t *) addr_elems);
+ maddr.imr_interface.s_addr = INADDR_ANY;
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
+ &maddr, sizeof (struct ip_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
+}
/*
- * Reads a buffer from a remote host
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leave6
+ * Signature: (I[B)V
*/
-JNIEXPORT jint JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_read(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj, jarray buf,
- jint offset, jint len)
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_leave6 (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jbyteArray addr)
{
-#ifndef WITHOUT_NETWORK
- return(_javanet_recvfrom(env, obj, buf, offset, len, 0));
-#else /* not WITHOUT_NETWORK */
- return 0;
-#endif /* not WITHOUT_NETWORK */
+#ifdef HAVE_SETSOCKOPT
+#ifdef HAVE_INET6
+ struct ipv6_mreq maddr;
+ jbyte *addr_elems;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ memcpy (&(maddr.ipv6mr_multiaddr.s6_addr), addr_elems, 16);
+ maddr.ipv6mr_interface = 0;
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &maddr, sizeof (struct ipv6_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "IPv6 support not available");
+#endif /* HAVE_INET6 */
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
}
-/*************************************************************************/
+static uint32_t getif_address (JNIEnv *env, char *ifname);
+static int getif_index (JNIEnv *env, char *ifname);
/*
- * Writes a buffer to the remote host
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: joinGroup
+ * Signature: (I[BILjava/lang/String;)V
*/
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_write(JNIEnv *env,
- jclass klass __attribute__ ((__unused__)),
- jobject obj, jarray buf,
- jint offset, jint len)
+Java_gnu_java_net_VMPlainSocketImpl_joinGroup (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jbyteArray addr,
+ jstring ifname)
{
-#ifndef WITHOUT_NETWORK
- _javanet_sendto(env, obj, buf, offset, len, 0);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+#ifdef HAVE_SETSOCKOPT
+ struct ip_mreq maddr;
+ jbyte *addr_elems;
+
+ if (ifname != NULL)
+ {
+ maddr.imr_interface.s_addr = getif_address (env, ifname);
+ if ((*env)->ExceptionCheck (env))
+ return;
+ }
+ else
+ maddr.imr_interface.s_addr = INADDR_ANY;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ maddr.imr_multiaddr.s_addr = * ((uint32_t *) addr_elems);
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ &maddr, sizeof (struct ip_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ (void) ifname;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
}
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: joinGroup6
+ * Signature: (I[BILjava/lang/String;)V
+ */
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_shutdownInput (JNIEnv * env,
- jclass klass __attribute__ ((__unused__)),
- jobject this)
+Java_gnu_java_net_VMPlainSocketImpl_joinGroup6 (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jbyteArray addr,
+ jstring ifname)
{
-#ifndef WITHOUT_NETWORK
- _javanet_shutdownInput (env, this);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+#ifdef HAVE_SETSOCKOPT
+#ifdef HAVE_INET6
+ struct ipv6_mreq maddr;
+ jbyte *addr_elems;
+
+ if (ifname == NULL)
+ {
+ maddr.ipv6mr_interface = getif_index (env, ifname);
+ if ((*env)->ExceptionCheck (env))
+ return;
+ }
+ else
+ maddr.ipv6mr_interface = 0;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ memcpy (&(maddr.ipv6mr_multiaddr.s6_addr), addr_elems, 16);
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+ &maddr, sizeof (struct ipv6_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "IPv6 support not available");
+#endif /* HAVE_INET6 */
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
}
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leaveGroup
+ * Signature: (I[BILjava/lang/String;)V
+ */
JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainSocketImpl_shutdownOutput (JNIEnv * env,
- jclass klass __attribute__ ((__unused__)),
- jobject this)
+Java_gnu_java_net_VMPlainSocketImpl_leaveGroup (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jbyteArray addr,
+ jstring ifname)
{
-#ifndef WITHOUT_NETWORK
- _javanet_shutdownOutput (env, this);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
+#ifdef HAVE_SETSOCKOPT
+ struct ip_mreq maddr;
+ jbyte *addr_elems;
+
+ if (ifname != NULL)
+ {
+ maddr.imr_interface.s_addr = getif_address (env, ifname);
+ if ((*env)->ExceptionCheck (env))
+ return;
+ }
+ else
+ maddr.imr_interface.s_addr = INADDR_ANY;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ maddr.imr_multiaddr.s_addr = * ((uint32_t *) addr_elems);
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
+ &maddr, sizeof (struct ip_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ (void) ifname;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
+}
+
+/*
+ * Class: gnu_java_net_VMPlainSocketImpl
+ * Method: leaveGroup6
+ * Signature: (I[BILjava/lang/String;)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_leaveGroup6 (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jbyteArray addr,
+ jstring ifname)
+{
+#ifdef HAVE_SETSOCKOPT
+#ifdef HAVE_INET6
+ struct ipv6_mreq maddr;
+ jbyte *addr_elems;
+
+ if (ifname == NULL)
+ {
+ maddr.ipv6mr_interface = getif_index (env, ifname);
+ if ((*env)->ExceptionCheck (env))
+ return;
+ }
+ else
+ maddr.ipv6mr_interface = 0;
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+ if (addr_elems == NULL)
+ return;
+
+ memcpy (&(maddr.ipv6mr_multiaddr.s6_addr), addr_elems, 16);
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ if (-1 == setsockopt (fd, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
+ &maddr, sizeof (struct ipv6_mreq)))
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "IPv6 support not available");
+#endif /* HAVE_INET6 */
+#else
+ (void) fd;
+ (void) addr;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
}
-/* end of file */
+static uint32_t
+getif_address (JNIEnv *env, char *ifname)
+{
+#ifdef HAVE_GETIFADDRS
+ struct ifaddrs *ifaddrs, *i;
+ uint32_t addr = 0;
+ int foundaddr = 0;
+
+ if (getifaddrs (&ifaddrs) == -1)
+ {
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+ return 0;
+ }
+
+ for (i = ifaddrs; i != NULL; i = i->ifa_next)
+ {
+ if (strcmp (ifname, i->ifa_name) == 0)
+ {
+ /* Matched the name; see if there is an IPv4 address. */
+ if (i->ifa_addr->sa_family == AF_INET)
+ {
+ foundaddr = 1;
+ addr = ((struct sockaddr_in *) i->ifa_addr)->sin_addr.s_addr;
+ break;
+ }
+ }
+ }
+
+ if (!foundaddr)
+ JCL_ThrowException (env, SOCKET_EXCEPTION, "interface has no IPv4 address");
+
+ freeifaddrs (ifaddrs);
+
+ return addr;
+#else
+ (void) ifname;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "getifaddrs not available");
+ return 0;
+#endif /* HAVE_GETIFADDRS */
+}
+
+static int
+getif_index (JNIEnv *env, char *ifname)
+{
+#ifdef HAVE_GETIFADDRS
+ struct ifaddrs *ifaddrs, *i;
+ char *lastname = NULL;
+ int index = 1;
+ int foundname = 0;
+
+ if (getifaddrs (&ifaddrs) == -1)
+ {
+ JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
+ return -1;
+ }
+
+ lastname = ifaddrs->ifa_name;
+ for (i = ifaddrs; i != NULL; i = i->ifa_next)
+ {
+ if (strcmp (lastname, ifaddrs->ifa_name) != 0)
+ {
+ lastname = ifaddrs->ifa_name;
+ index++;
+ }
+ if (strcmp (ifname, ifaddrs->ifa_name) == 0)
+ {
+ foundname = 1;
+ break;
+ }
+ }
+
+ if (!foundname)
+ JCL_ThrowException (env, SOCKET_EXCEPTION,
+ "no interface with that name");
+
+ freeifaddrs (ifaddrs);
+
+ return index;
+#else
+ (void) ifname;
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "getifaddrs not available");
+ return -1;
+#endif /* HAVE_GETIFADDRS */
+}
diff --git a/native/jni/java-net/java_net_VMInetAddress.c b/native/jni/java-net/java_net_VMInetAddress.c
index 2ca0545fe..fc921ecef 100644
--- a/native/jni/java-net/java_net_VMInetAddress.c
+++ b/native/jni/java-net/java_net_VMInetAddress.c
@@ -299,4 +299,91 @@ Java_java_net_VMInetAddress_getHostByName (JNIEnv * env,
#endif /* not WITHOUT_NETWORK */
}
+/*************************************************************************/
+
+/*
+ * Return the IP address represented by a literal address.
+ * Will return null if the literal address is not valid.
+ */
+JNIEXPORT jbyteArray JNICALL
+Java_java_net_VMInetAddress_aton (JNIEnv *env,
+ jclass class
+ __attribute__ ((__unused__)),
+ jstring host)
+{
+#ifndef WITHOUT_NETWORK
+ const char *hostname;
+ cpnet_address *address;
+ int result;
+ jbyte *octets;
+ jbyteArray ret_octets;
+
+ hostname = (*env)->GetStringUTFChars (env, host, 0);
+ if (!hostname)
+ {
+ JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION, "Null hostname");
+ return (jbyteArray) NULL;
+ }
+
+ result = cpnet_aton (env, hostname, &address);
+ if (result != CPNATIVE_OK)
+ {
+ JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION, "Internal Error");
+ if (address)
+ cpnet_freeAddress (env, address);
+ return (jbyteArray) NULL;
+ }
+ if (!address)
+ return (jbyteArray) NULL;
+
+ if (cpnet_isIPV6Address (address))
+ {
+ ret_octets = (jbyteArray) (*env)->NewByteArray (env, 16);
+
+ if (!ret_octets)
+ {
+ JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION, "Internal Error");
+ cpnet_freeAddress (env, address);
+ return (jbyteArray) NULL;
+ }
+
+ octets = (*env)->GetByteArrayElements (env, ret_octets, 0);
+
+ cpnet_IPV6AddressToBytes (address, octets);
+
+ (*env)->ReleaseByteArrayElements (env, ret_octets, octets, 0);
+ }
+ else if (cpnet_isIPV4Address (address))
+ {
+ ret_octets = (jbyteArray) (*env)->NewByteArray (env, 4);
+
+ if (!ret_octets)
+ {
+ JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION, "Internal Error");
+ cpnet_freeAddress (env, address);
+ return (jbyteArray) NULL;
+ }
+
+ octets = (*env)->GetByteArrayElements (env, ret_octets, 0);
+
+ cpnet_IPV4AddressToBytes (address, octets);
+
+ (*env)->ReleaseByteArrayElements (env, ret_octets, octets, 0);
+ }
+ else
+ {
+ JCL_ThrowException (env, UNKNOWN_HOST_EXCEPTION, "Internal Error");
+ cpnet_freeAddress (env, address);
+ return (jbyteArray) NULL;
+ }
+
+ cpnet_freeAddress (env, address);
+
+ return (ret_octets);
+
+#else /* not WITHOUT_NETWORK */
+ return (jbyteArray) NULL;
+#endif /* not WITHOUT_NETWORK */
+}
+
/* end of file */
diff --git a/native/jni/java-net/java_net_VMNetworkInterface.c b/native/jni/java-net/java_net_VMNetworkInterface.c
index f05e9fcc5..203f6acd0 100644
--- a/native/jni/java-net/java_net_VMNetworkInterface.c
+++ b/native/jni/java-net/java_net_VMNetworkInterface.c
@@ -35,9 +35,15 @@ 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. */
-/* do not move; needed here because of some macro definitions */
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <ifaddrs.h>
+#include <netinet/in.h>
+#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -47,19 +53,197 @@ exception statement from your version. */
#include "java_net_VMNetworkInterface.h"
-#include "javanet.h"
+
+static jmethodID java_net_VMNetworkInterface_init;
+static jmethodID java_net_VMNetworkInterface_addAddress;
/*
- * Returns all local network interfaces as vector
+ * Initialize our static method ID's.
+ *
+ * Class: java_net_VMNetworkInterface
+ * Method: initIds
+ * Signature: ()V
*/
-JNIEXPORT jobject JNICALL
-Java_java_net_VMNetworkInterface_getInterfaces (JNIEnv * env,
- jclass class
- __attribute__ ((__unused__)))
+JNIEXPORT void JNICALL
+Java_java_net_VMNetworkInterface_initIds (JNIEnv *env, jclass clazz)
+{
+ java_net_VMNetworkInterface_init =
+ (*env)->GetMethodID (env, clazz, "<init>", "(Ljava/lang/String;)V");
+ if (java_net_VMNetworkInterface_init == NULL)
+ {
+ if (!(*env)->ExceptionCheck (env))
+ JCL_ThrowException (env, "java/lang/NoSuchMethodError",
+ "VMNetworkinterface.addAddress");
+ return;
+ }
+ java_net_VMNetworkInterface_addAddress =
+ (*env)->GetMethodID (env, clazz, "addAddress", "(Ljava/nio/ByteBuffer;)V");
+ if (java_net_VMNetworkInterface_addAddress == NULL)
+ {
+ if (!(*env)->ExceptionCheck (env))
+ JCL_ThrowException (env, "java/lang/NoSuchMethodError",
+ "VMNetworkinterface.addAddress");
+ }
+}
+
+struct netif_entry
+{
+ char *name;
+ jobject netif;
+ int numaddrs;
+ struct netif_entry *next;
+};
+
+static void
+free_netif_list (JNIEnv *env, struct netif_entry *list)
{
- JCL_ThrowException (env, IO_EXCEPTION,
- "java.net.VMNetworkInterface.getInterfaces(): not implemented");
- return 0;
+ while (list != NULL)
+ {
+ struct netif_entry *e = list->next;
+ JCL_free (env, list);
+ list = e;
+ }
+}
+
+/*
+ * Returns all local network interfaces as an array.
+ */
+JNIEXPORT jobjectArray JNICALL
+Java_java_net_VMNetworkInterface_getVMInterfaces (JNIEnv * env, jclass clazz)
+{
+#ifdef HAVE_GETIFADDRS
+ struct ifaddrs *ifaddrs, *i;
+ struct netif_entry *iflist = NULL, *e;
+ jobjectArray netifs;
+ int numifs = 0;
+ int k;
+
+ if (getifaddrs (&ifaddrs) == -1)
+ {
+ JCL_ThrowException (env, "java/net/SocketException", strerror (errno));
+ return NULL;
+ }
+
+ for (i = ifaddrs; i != NULL; i = i->ifa_next)
+ {
+ if (iflist == NULL)
+ {
+ iflist = JCL_malloc (env, sizeof (struct netif_entry));
+ if (iflist == NULL)
+ {
+ freeifaddrs (ifaddrs);
+ return NULL;
+ }
+ iflist->name = i->ifa_name;
+ iflist->numaddrs = 0;
+ iflist->next = NULL;
+ iflist->netif = (*env)->NewObject (env, clazz, java_net_VMNetworkInterface_init,
+ (*env)->NewStringUTF (env, i->ifa_name));
+ if (iflist->netif == NULL)
+ {
+ freeifaddrs (ifaddrs);
+ JCL_free (env, iflist);
+ return NULL;
+ }
+ e = iflist;
+ }
+ else
+ {
+ struct netif_entry *p = NULL;
+ for (e = iflist; e != NULL; e = e->next)
+ {
+ if (strcmp (e->name, i->ifa_name) == 0)
+ break;
+ p = e;
+ }
+
+ if (e == NULL)
+ {
+ p->next = (struct netif_entry *) JCL_malloc (env, sizeof (struct netif_entry));
+ if (p->next == NULL)
+ {
+ free_netif_list (env, iflist);
+ freeifaddrs (ifaddrs);
+ return NULL;
+ }
+ e = p->next;
+ e->name = i->ifa_name;
+ e->numaddrs = 0;
+ e->next = NULL;
+ e->netif = (*env)->NewObject (env, clazz, java_net_VMNetworkInterface_init,
+ (*env)->NewStringUTF (env, i->ifa_name));
+ if (e->netif == NULL)
+ {
+ free_netif_list (env, iflist);
+ freeifaddrs (ifaddrs);
+ return NULL;
+ }
+ }
+ }
+
+ if (i->ifa_addr == NULL)
+ continue;
+
+ if (i->ifa_addr->sa_family == AF_INET)
+ {
+ struct sockaddr_in *sin = (struct sockaddr_in *) i->ifa_addr;
+ jobject buffer = (*env)->NewDirectByteBuffer (env, &(sin->sin_addr.s_addr), 4);
+ (*env)->CallVoidMethod (env, e->netif, java_net_VMNetworkInterface_addAddress,
+ buffer);
+ if ((*env)->ExceptionCheck (env))
+ {
+ free_netif_list (env, iflist);
+ freeifaddrs (ifaddrs);
+ return NULL;
+ }
+ (*env)->DeleteLocalRef (env, buffer);
+ e->numaddrs++;
+ }
+#ifdef HAVE_INET6
+ else if (i->ifa_addr->sa_family == AF_INET6)
+ {
+ struct sockaddr_in6 *sin = (struct sockaddr_in6 *) i->ifa_addr;
+ jobject buffer = (*env)->NewDirectByteBuffer (env, &(sin->sin6_addr.s6_addr), 16);
+ (*env)->CallVoidMethod (env, e->netif, java_net_VMNetworkInterface_addAddress,
+ buffer);
+ if ((*env)->ExceptionCheck (env))
+ {
+ free_netif_list (env, iflist);
+ freeifaddrs (ifaddrs);
+ return NULL;
+ }
+ (*env)->DeleteLocalRef (env, buffer);
+ e->numaddrs++;
+ }
+#endif /* HAVE_INET6 */
+ }
+
+ /* Count how many interfaces we have that have addresses. */
+ for (e = iflist; e != NULL; e = e->next)
+ {
+ if (e->numaddrs != 0)
+ numifs++;
+ }
+
+ netifs = (*env)->NewObjectArray (env, numifs, clazz, NULL);
+ k = 0;
+ for (e = iflist; e != NULL && k < numifs; e = e->next)
+ {
+ if (e->numaddrs != 0)
+ {
+ (*env)->SetObjectArrayElement (env, netifs, k, e->netif);
+ (*env)->DeleteLocalRef (env, e->netif);
+ k++;
+ }
+ }
+
+ free_netif_list (env, iflist);
+ freeifaddrs (ifaddrs);
+ return netifs;
+#else
+ JCL_ThrowException (env, "java/net/SocketException", "getifaddrs not supported");
+ return NULL;
+#endif /* HAVE_GETIFADDRS */
}
/* end of file */
diff --git a/native/jni/java-nio/Makefile.am b/native/jni/java-nio/Makefile.am
index 800d25be6..a4b830cd4 100644
--- a/native/jni/java-nio/Makefile.am
+++ b/native/jni/java-nio/Makefile.am
@@ -3,16 +3,22 @@ nativeexeclib_LTLIBRARIES = libjavanio.la
libjavanio_la_SOURCES = gnu_java_nio_VMPipe.c \
gnu_java_nio_VMChannel.c \
gnu_java_nio_VMSelector.c \
- gnu_java_nio_channels_FileChannelImpl.c \
gnu_java_nio_charset_iconv_IconvDecoder.c \
gnu_java_nio_charset_iconv_IconvEncoder.c \
+ gnu_java_nio_channels_FileChannelImpl.c \
java_nio_MappedByteBufferImpl.c \
- java_nio_VMDirectByteBuffer.c
+ java_nio_VMDirectByteBuffer.c \
+ gnu_java_nio_EpollSelectorImpl.c \
+ gnu_java_nio_KqueueSelectorImpl.c \
+ javanio.h
libjavanio_la_LIBADD = $(top_builddir)/native/jni/classpath/jcl.lo \
$(top_builddir)/native/jni/native-lib/libclasspathnative.la \
$(LTLIBICONV)
+# Directly included through javanio.h
+EXTRA_DIST = javanio.c
+
AM_LDFLAGS = @CLASSPATH_MODULE@
AM_CPPFLAGS = @CLASSPATH_INCLUDES@
AM_CFLAGS = @WARNING_CFLAGS@ @STRICT_WARNING_CFLAGS@ @ERROR_CFLAGS@
diff --git a/native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c b/native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c
new file mode 100644
index 000000000..d794e6d9f
--- /dev/null
+++ b/native/jni/java-nio/gnu_java_nio_EpollSelectorImpl.c
@@ -0,0 +1,414 @@
+/* gnu_java_nio_EpollSelectorImpl.c --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_SYS_EPOLL_H
+#include <sys/epoll.h>
+#endif /* HAVE_SYS_EPOLL_H */
+
+#include <gnu_java_nio_EpollSelectorImpl.h>
+#include <jcl.h>
+#include <errno.h>
+#include <string.h>
+
+#define IO_EXCEPTION "java/io/IOException"
+
+/* #define TRACE_EPOLL 1 */
+
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_supported
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_epoll_1supported (JNIEnv *e __attribute__((unused)),
+ jclass c __attribute__((unused)))
+{
+#ifdef HAVE_EPOLL_CREATE
+ return JNI_TRUE;
+#else
+ return JNI_FALSE;
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: sizeof_struct
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_sizeof_1struct (JNIEnv *env,
+ jclass c __attribute__((unused)))
+{
+#ifdef HAVE_EPOLL_CREATE
+ (void) env;
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: sizeof is %d\n", __FUNCTION__, sizeof (struct epoll_event));
+#endif /* TRACE_EPOLL */
+ return sizeof (struct epoll_event);
+#else
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+ return -1;
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_create
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_epoll_1create (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint size)
+{
+#ifdef HAVE_EPOLL_CREATE
+ int fd = epoll_create (size);
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: epoll_create returns %d\n", __FUNCTION__, fd);
+#endif /* TRACE_EPOLL */
+
+ if (fd == -1)
+ {
+ if (ENOSYS == errno)
+ JCL_ThrowException (env, "java/lang/InternalError",
+ strerror (errno));
+ else
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+ return fd;
+#else
+ (void) size;
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+ return -1;
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_add
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_epoll_1add (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint efd, jint fd, jint ops)
+{
+#ifdef HAVE_EPOLL_CREATE
+ struct epoll_event event;
+
+ memset (&event, 0, sizeof (struct epoll_event));
+
+ if ((ops & gnu_java_nio_EpollSelectorImpl_OP_ACCEPT) != 0
+ || (ops & gnu_java_nio_EpollSelectorImpl_OP_READ) != 0)
+ event.events = EPOLLIN;
+
+ if ((ops & gnu_java_nio_EpollSelectorImpl_OP_CONNECT) != 0
+ || (ops & gnu_java_nio_EpollSelectorImpl_OP_WRITE) != 0)
+ event.events |= EPOLLOUT;
+
+ event.data.fd = fd;
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: adding struct epoll_event { events: %o; data.fd: %d } to %d\n",
+ __FUNCTION__, event.events, event.data.fd, efd);
+#endif /* TRACE_EPOLL */
+
+ if (epoll_ctl (efd, EPOLL_CTL_ADD, fd, &event) == -1)
+ {
+ if (ENOSYS == errno)
+ JCL_ThrowException (env, "java/lang/InternalError",
+ strerror (errno));
+ else
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+#else
+ (void) efd;
+ (void) fd;
+ (void) ops;
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_modify
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_epoll_1modify (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint efd, jint fd, jint ops)
+{
+#ifdef HAVE_EPOLL_CREATE
+ struct epoll_event event;
+
+ memset (&event, 0, sizeof (struct epoll_event));
+
+ if ((ops & gnu_java_nio_EpollSelectorImpl_OP_ACCEPT) != 0
+ || (ops & gnu_java_nio_EpollSelectorImpl_OP_READ) != 0)
+ event.events = EPOLLIN;
+
+ if ((ops & gnu_java_nio_EpollSelectorImpl_OP_CONNECT) != 0
+ || (ops & gnu_java_nio_EpollSelectorImpl_OP_WRITE) != 0)
+ event.events |= EPOLLOUT;
+
+ event.data.fd = fd;
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: modding struct epoll_event { events: %o; data.fd: %d } on %d\n",
+ __FUNCTION__, event.events, event.data.fd, efd);
+#endif /* TRACE_EPOLL */
+
+ if (epoll_ctl (efd, EPOLL_CTL_MOD, fd, &event) == -1)
+ {
+ if (ENOSYS == errno)
+ JCL_ThrowException (env, "java/lang/InternalError",
+ strerror (errno));
+ else
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+#else
+ (void) efd;
+ (void) fd;
+ (void) ops;
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_delete
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_epoll_1delete (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint efd, jint fd)
+{
+#ifdef HAVE_EPOLL_CREATE
+ struct epoll_event event;
+
+ memset (&event, 0, sizeof (struct epoll_event));
+ event.data.fd = fd;
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: delete events on fd %d for %d\n", __FUNCTION__, fd, efd);
+#endif /* TRACE_EPOLL */
+
+ /* Older kernel versions require a non-null `event' parameter,
+ * even though it is ignored by this call.
+ */
+ if (epoll_ctl (efd, EPOLL_CTL_DEL, fd, &event) == -1)
+ {
+ if (ENOSYS == errno)
+ JCL_ThrowException (env, "java/lang/InternalError",
+ strerror (errno));
+ /* XXX the docs here seem a little strange. If `fd' is closed,
+ epoll_ctl returns EBADF; but the docs say that this happens
+ only when efd is invalid. Go figure.
+ */
+ else if (ENOENT == errno || EBADF == errno)
+ return; /* fd is closed; it's already removed. */
+ else
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+#else
+ (void) efd;
+ (void) fd;
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: epoll_wait
+ * Signature: (ILjava/nio/ByteBuffer;II)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_epoll_1wait (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint efd, jobject nstate,
+ jint num_events, jint timeout)
+{
+#ifdef HAVE_EPOLL_CREATE
+ void *p = (*env)->GetDirectBufferAddress (env, nstate);
+ struct epoll_event *events = (struct epoll_event *) p;
+ int ret;
+
+ if (p == NULL)
+ {
+ if (!(*env)->ExceptionCheck (env))
+ JCL_ThrowException (env, IO_EXCEPTION, "getting native state failed");
+ return -1;
+ }
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: events: %p; num_events: %d; timeout: %d; efd: %d\n",
+ __FUNCTION__, p, num_events, timeout, efd);
+#endif /* TRACE_EPOLL */
+
+ ret = epoll_wait (efd, events, num_events, timeout);
+
+ if (ret == -1)
+ {
+ if (ENOSYS == errno)
+ JCL_ThrowException (env, "java/lang/InternalError",
+ strerror (errno));
+ else if (EINTR == errno)
+ ret = 0;
+ else
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, " epoll_wait returns %d\n", ret);
+ {
+ int i;
+ for (i = 0; i < ret; i++)
+ {
+ fprintf (stderr, " [%4i]: events: %o; data.fd: %d\n", i, events[i].events,
+ events[i].data.fd);
+ }
+ }
+ fflush (stderr);
+#endif /* TRACE_EPOLL */
+
+ return ret;
+#else
+ (void) efd;
+ (void) nstate;
+ (void) num_events;
+ (void) timeout;
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+ return -1;
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: selected_fd
+ * Signature: (Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_selected_1fd (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jobject value)
+{
+#ifdef HAVE_EPOLL_CREATE
+ void *p = (*env)->GetDirectBufferAddress (env, value);
+ struct epoll_event *event = (struct epoll_event *) p;
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: event: %p\n", __FUNCTION__, p);
+#endif /* TRACE_EPOLL */
+
+ if (p == NULL)
+ {
+ if (!(*env)->ExceptionCheck (env))
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "getting native state failed");
+ return -1;
+ }
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, " data.fd: %d\n", event->data.fd);
+ fflush (stderr);
+#endif /* TRACE_EPOLL */
+
+ return event->data.fd;
+#else
+ (void) value;
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+ return -1;
+#endif /* HAVE_EPOLL_CREATE */
+}
+
+
+/*
+ * Class: gnu_java_nio_EpollSelectorImpl
+ * Method: selected_ops
+ * Signature: (Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_EpollSelectorImpl_selected_1ops (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jobject value)
+{
+#ifdef HAVE_EPOLL_CREATE
+ void *p = (*env)->GetDirectBufferAddress (env, value);
+ struct epoll_event *event = (struct epoll_event *) p;
+ int ret = 0;
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, "%s: event: %p\n", __FUNCTION__, p);
+#endif /* TRACE_EPOLL */
+
+ if (p == NULL)
+ {
+ if (!(*env)->ExceptionCheck (env))
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "getting native state failed");
+ return -1;
+ }
+
+ if ((event->events & EPOLLIN) != 0)
+ ret |= gnu_java_nio_EpollSelectorImpl_OP_ACCEPT | gnu_java_nio_EpollSelectorImpl_OP_READ;
+ if ((event->events & EPOLLOUT) != 0)
+ ret |= gnu_java_nio_EpollSelectorImpl_OP_CONNECT | gnu_java_nio_EpollSelectorImpl_OP_WRITE;
+
+#ifdef TRACE_EPOLL
+ fprintf (stderr, " events: %o\n", event->events);
+ fflush (stderr);
+#endif /* TRACE_EPOLL */
+
+ return ret;
+#else
+ (void) value;
+ JCL_ThrowException (env, "java/lang/InternalError", "epoll support not available");
+ return -1;
+#endif /* HAVE_EPOLL_CREATE */
+}
diff --git a/native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c b/native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c
new file mode 100644
index 000000000..94e6db7f8
--- /dev/null
+++ b/native/jni/java-nio/gnu_java_nio_KqueueSelectorImpl.c
@@ -0,0 +1,387 @@
+/* gnu_java_nio_channel_KqueueSelectorImpl.c --
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <sys/types.h>
+#if HAVE_SYS_EVENT_H
+#include <sys/event.h>
+#endif /* HAVE_SYS_EVENT_H */
+#include <sys/time.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <jni.h>
+#include <gnu_java_nio_KqueueSelectorImpl.h>
+
+#include <jcl.h>
+
+#define KEY_OP_ACCEPT 16
+#define KEY_OP_CONNECT 8
+#define KEY_OP_READ 1
+#define KEY_OP_WRITE 4
+
+/* XXX this requires -std=gnu99 or c99 */
+/* #ifdef TRACE_KQUEUE */
+/* #define TRACE(fmt, ...) fprintf (stderr, "%s: " fmt "\n", __FUNCTION__, __VA_ARGS__); */
+/* #else */
+/* #define TRACE(fmt, ...) */
+/* #endif */
+
+/* #define TRACE_KQUEUE 1 */
+
+
+#define throw_not_supported(env) JCL_ThrowException (env, "java/lang/UnsupportedOperationException", "kqueue/kevent support not available")
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: kqueue_supported
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_kqueue_1supported (JNIEnv *env __attribute__((unused)),
+ jclass clazz __attribute__((unused)))
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+ return JNI_TRUE;
+#else
+ return JNI_FALSE;
+#endif /* HAVE_KQUEUE && HAVE_KEVENT */
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: sizeof_struct_kevent
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_sizeof_1struct_1kevent
+(JNIEnv *env __attribute__((unused)), jclass clazz __attribute__((unused)))
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+/* TRACE("return sizeof %lu", sizeof (struct kevent)); */
+ return sizeof (struct kevent);
+#else
+ throw_not_supported (env);
+ return -1;
+#endif /* HAVE_KQUEUE && HAVE_KEVENT */
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: implOpen
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_implOpen
+(JNIEnv *env, jclass clazz __attribute__((unused)))
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+ int kq = kqueue ();
+/* TRACE("kqueue returns %d", kq); */
+ if (kq == -1)
+ JCL_ThrowException (env, "java/io/IOException", strerror (errno));
+ return kq;
+#else
+ throw_not_supported (env);
+ return -1;
+#endif
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: implClose
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_implClose (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jint kq)
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+/* TRACE("closing %d", kq); */
+ if (close (kq) != 0)
+ JCL_ThrowException (env, "java/io/IOException", strerror (errno));
+#else
+ (void) kq;
+ throw_not_supported (env);
+#endif /* HAVE_KQUEUE && HAVE_KEVENT */
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: kevent_set
+ * Signature: (Ljava/nio/ByteBuffer;IIIZ)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_kevent_1set (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jobject nstate, jint i, jint fd,
+ jint ops, jint active, jint key)
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+ struct kevent *kev;
+ short ident;
+
+ kev = (struct kevent *) (*env)->GetDirectBufferAddress (env, nstate);
+
+#ifdef TRACE_KQUEUE
+ printf ("kevent_set fd:%d p:%p i:%d ops:%x active:%x key:%x\n",
+ fd, (void *) kev, i, ops, active, key);
+#endif /* TRACE_KQUEUE */
+
+ if (kev == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "GetDirectBufferAddress returned NULL!");
+ return;
+ }
+
+ ident = fd;
+ memset (&kev[i], 0, sizeof (struct kevent));
+
+ if ((ops & KEY_OP_READ) || (ops & KEY_OP_ACCEPT))
+ {
+ /* Add event if it wasn't previously added. */
+ if (!(active & KEY_OP_READ) && !(active & KEY_OP_ACCEPT))
+ EV_SET(&kev[i], ident, EVFILT_READ, EV_ADD, 0, 0, (void *) key);
+ }
+ else
+ {
+ /* Delete event if it was previously added */
+ if ((active & KEY_OP_READ) || (active & KEY_OP_ACCEPT))
+ EV_SET(&kev[i], ident, EVFILT_READ, EV_DELETE, 0, 0, (void *) key);
+ }
+
+ /* Do the same thing for the write filter. */
+ if ((ops & KEY_OP_WRITE) || (ops & KEY_OP_CONNECT))
+ {
+ if (!(active & KEY_OP_WRITE) && !(active & KEY_OP_CONNECT))
+ EV_SET(&kev[i], ident, EVFILT_WRITE, EV_ADD, 0, 0, (void *) key);
+ }
+ else
+ {
+ if ((active & KEY_OP_WRITE) || (active & KEY_OP_CONNECT))
+ EV_SET(&kev[i], ident, EVFILT_WRITE, EV_DELETE, 0, 0, (void *) key);
+ }
+
+#ifdef TRACE_KQUEUE
+ printf (" set kevent %2d: ident:%u filter:%x flags:%o fflags:%o data:%p udata:%p\n",
+ i, (unsigned) kev[i].ident, kev[i].filter, kev[i].flags, kev[i].fflags,
+ (void *) kev[i].data, kev[i].udata);
+#endif /* TRACE_KQUEUE */
+#else
+ (void) nstate;
+ (void) i;
+ (void) fd;
+ (void) ops;
+ (void) key;
+ (void) active;
+ throw_not_supported (env);
+#endif /* HAVE_KQUEUE && HAVE_KEVENT */
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: kevent
+ * Signature: (ILjava/nio/ByteBuffer;IJ)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_kevent (JNIEnv *env,
+ jobject this __attribute__((unused)),
+ jint kq, jobject nstate, jint nevents,
+ jint maxevents, jlong timeout)
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+ struct timespec tv;
+ struct timespec *t = NULL;
+ struct kevent *kev = (struct kevent *) (*env)->GetDirectBufferAddress (env, nstate);
+ int ret;
+
+#ifdef TRACE_KQUEUE
+ int i;
+
+ printf ("[%d] kevent nevents:%d maxevents:%d timeout:%lld\n", kq, nevents, maxevents, timeout);
+ printf ("[%d] addding/deleting %d events\n", kq, nevents);
+ for (i = 0; i < nevents; i++)
+ {
+ printf ("[%d] kevent input [%d]: ident:%u filter:%x flags:%o fflags:%o data:%p udata:%p\n",
+ kq, i, (unsigned) kev[i].ident, kev[i].filter, kev[i].flags, kev[i].fflags,
+ (void *) kev[i].data, kev[i].udata);
+ }
+#endif
+
+/* TRACE("events: %p; nevents: %d; timeout: %lld", (void *) kev, nevents, timeout); */
+
+ if (timeout != -1)
+ {
+ tv.tv_sec = timeout / 1000;
+ tv.tv_nsec = (timeout % 1000) * 1000;
+ t = &tv;
+ }
+
+ ret = kevent (kq, (const struct kevent *) kev, nevents, kev, maxevents, t);
+
+ if (ret == -1)
+ {
+ if (errno == EINTR)
+ ret = 0;
+ else
+ JCL_ThrowException (env, "java/io/IOException", strerror (errno));
+ }
+
+#ifdef TRACE_KQUEUE
+ for (i = 0; i < ret; i++)
+ {
+ printf ("[%d] kevent output [%d]: ident:%u filter:%x flags:%o fflags:%o data:%p udata:%p\n",
+ kq, i, (unsigned) kev[i].ident, kev[i].filter, kev[i].flags, kev[i].fflags,
+ (void *) kev[i].data, kev[i].udata);
+ }
+#endif
+
+ return ret;
+#else
+ (void) kq;
+ (void) nstate;
+ (void) nevents;
+ (void) maxevents;
+ (void) timeout;
+ throw_not_supported (env);
+ return -1;
+#endif /* HAVE_KQUEUE && HAVE_KEVENT */
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: fetch_key
+ * Signature: (Ljava/nio/ByteBuffer;)I;
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_fetch_1key (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jobject nstate)
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+ struct kevent *kev = (struct kevent *) (*env)->GetDirectBufferAddress (env, nstate);
+/* TRACE("return key %p\n", kev->udata); */
+ return (jint) kev->udata;
+#else
+ (void) nstate;
+ throw_not_supported (env);
+ return -1;
+#endif /* HAVE_KQUEUE && HAVE_KEVENT */
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: ready_ops
+ * Signature: (Ljava/nio/ByteBuffer;I)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_ready_1ops (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jobject nstate, jint interest)
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+ struct kevent *kev = (struct kevent *) (*env)->GetDirectBufferAddress (env, nstate);
+ jint ready = 0;
+
+ if ((kev->flags & EV_ERROR) == EV_ERROR)
+ {
+ printf ("!!! error selecting fd %d: %s", (int) (kev->ident), strerror ((int) (kev->data)));
+ return 0;
+ }
+
+ /* We poll for READ for OP_READ and OP_ACCEPT. */
+ if (kev->filter == EVFILT_READ)
+ {
+ ready = (interest & KEY_OP_READ) | (interest & KEY_OP_ACCEPT);
+/* TRACE("filter EVFILT_READ. Ready ops set to %x", ready); */
+ }
+
+ /* Poll for WRITE for OP_WRITE and OP_CONNECT; I guess we *should*
+ get a WRITE event if we are connected, but I don't know if we do
+ for real. FIXME */
+ if (kev->filter == EVFILT_WRITE)
+ {
+ ready = (interest & KEY_OP_WRITE) | (interest & KEY_OP_CONNECT);
+/* TRACE("filter EVFILT_WRITE. Ready ops set to %x", ready); */
+ }
+
+ return ready;
+#else
+ (void) nstate;
+ (void) interest;
+ throw_not_supported (env);
+ return -1;
+#endif /* HAVE_KQUEUE && HAVE_KEVENT */
+}
+
+
+/*
+ * Class: gnu_java_nio_KqueueSelectorImpl
+ * Method: check_eof
+ * Signature: (Ljava/nio/ByteBuffer;)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_nio_KqueueSelectorImpl_check_1eof (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jobject nstate)
+{
+#if defined(HAVE_KQUEUE) && defined(HAVE_KEVENT)
+ struct kevent *kev = (struct kevent *) (*env)->GetDirectBufferAddress (env, nstate);
+ if ((kev->flags & EV_EOF) == EV_EOF)
+ return JNI_TRUE;
+ return JNI_FALSE;
+#else
+ (void) nstate;
+ throw_not_supported (env);
+ return JNI_FALSE;
+#endif
+}
diff --git a/native/jni/java-nio/gnu_java_nio_VMChannel.c b/native/jni/java-nio/gnu_java_nio_VMChannel.c
index 5571bed27..b4f444361 100644
--- a/native/jni/java-nio/gnu_java_nio_VMChannel.c
+++ b/native/jni/java-nio/gnu_java_nio_VMChannel.c
@@ -36,25 +36,43 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+
+#include <netinet/in.h>
+
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
-#include <sys/uio.h>
#include <string.h>
#include <jni.h>
#include <jcl.h>
#include "gnu_java_nio_VMChannel.h"
+#include "javanio.h"
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
#define IO_EXCEPTION "java/io/IOException"
+#define INTERRUPTED_IO_EXCEPTION "java/io/InterruptedIOException"
#define NON_READABLE_CHANNEL_EXCEPTION "java/nio/channels/NonReadableChannelException"
#define NON_WRITABLE_CHANNEL_EXCEPTION "java/nio/channels/NonWritableChannelException"
+#define SOCKET_TIMEOUT_EXCEPTION "java/net/SocketTimeoutException"
+
+/* Align a value up or down to a multiple of the pagesize. */
+#define ALIGN_DOWN(p,s) ((p) - ((p) % (s)))
+#define ALIGN_UP(p,s) ((p) + ((s) - ((p) % (s))))
/*
* Limit to maximum of 16 buffers
@@ -66,7 +84,7 @@ extern "C"
{
#endif
-enum JCL_buffer_type { DIRECT, ARRAY, UNKNOWN };
+enum JCL_buffer_type { DIRECT, HEAP, ARRAY, UNKNOWN };
struct JCL_buffer
{
@@ -98,6 +116,7 @@ get_method_id(JNIEnv *env, jclass clazz, const char *name,
const char *sig)
{
jmethodID mid = (*env)->GetMethodID(env, clazz, name, sig);
+/* NIODBG("name: %s; sig: %s", name, sig); */
if (mid == NULL)
{
JCL_ThrowException(env, "java/lang/InternalError", name);
@@ -107,18 +126,19 @@ get_method_id(JNIEnv *env, jclass clazz, const char *name,
return mid;
}
-void
+inline void
JCL_print_buffer(JNIEnv *env __attribute__((__unused__)), struct JCL_buffer *buf)
{
- fprintf(stdout, "Buffer - type: %d, ptr: %p\n", buf->type, buf->ptr);
- fflush(stdout);
+ fprintf (stderr, "Buffer - type: %d, ptr: %p\n", buf->type, buf->ptr);
}
int
JCL_init_buffer(JNIEnv *env, struct JCL_buffer *buf, jobject bbuf)
{
- jobject address = (*env)->GetObjectField(env, bbuf, address_fid);
+ void *addr = (*env)->GetDirectBufferAddress (env, bbuf);
+
+/* NIODBG("buf: %p; bbuf: %p; addr: %p", (void *) buf, bbuf, addr); */
buf->position = (*env)->CallIntMethod(env, bbuf, get_position_mid);
buf->limit = (*env)->CallIntMethod(env, bbuf, get_limit_mid);
@@ -126,11 +146,10 @@ JCL_init_buffer(JNIEnv *env, struct JCL_buffer *buf, jobject bbuf)
buf->count = 0;
buf->type = UNKNOWN;
- if (address != NULL)
+ if (addr != NULL)
{
- buf->ptr = (jbyte *) JCL_GetRawData(env, address);
+ buf->ptr = (jbyte *) addr;
buf->type = DIRECT;
- (*env)->DeleteLocalRef(env, address);
}
else
{
@@ -148,7 +167,12 @@ JCL_init_buffer(JNIEnv *env, struct JCL_buffer *buf, jobject bbuf)
}
else
{
- return -1;
+ jobject address = (*env)->GetObjectField (env, bbuf, address_fid);
+ if (address == NULL)
+ return -1; /* XXX handle non-array, non-native buffers? */
+ buf->ptr = (jbyte *) JCL_GetRawData(env, address);
+ buf->type = HEAP;
+ (*env)->DeleteLocalRef(env, address);
}
}
@@ -160,6 +184,8 @@ JCL_release_buffer(JNIEnv *env, struct JCL_buffer *buf, jobject bbuf,
jint action)
{
jbyteArray arr;
+
+/* NIODBG("buf: %p; bbuf: %p; action: %x", (void *) buf, bbuf, action); */
/* Set the position to the appropriate value */
if (buf->count > 0)
@@ -173,6 +199,7 @@ JCL_release_buffer(JNIEnv *env, struct JCL_buffer *buf, jobject bbuf,
switch (buf->type)
{
case DIRECT:
+ case HEAP:
break;
case ARRAY:
arr = (*env)->CallObjectMethod(env, bbuf, array_mid);
@@ -194,6 +221,9 @@ JCL_cleanup_buffers(JNIEnv *env,
jlong num_bytes)
{
jint i;
+
+/* NIODBG("bi_list: %p; vec_len: %d; bbufs: %p; offset: %d; num_bytes: %lld", */
+/* (void *) bi_list, vec_len, bbufs, offset, num_bytes); */
/* Update all of the bbufs with the approriate information */
for (i = 0; i < vec_len; i++)
@@ -217,13 +247,57 @@ JCL_cleanup_buffers(JNIEnv *env,
}
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: stdin_fd
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_stdin_1fd (JNIEnv *env __attribute__((unused)),
+ jclass c __attribute__((unused)))
+{
+/* NIODBG("%d", fileno (stdin)); */
+ return fileno (stdin);
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: stdout_fd
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_stdout_1fd (JNIEnv *env __attribute__((unused)),
+ jclass c __attribute__((unused)))
+{
+/* NIODBG("%d", fileno (stdout)); */
+ return fileno (stdout);
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: stderr_fd
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_stderr_1fd (JNIEnv *env __attribute__((unused)),
+ jclass c __attribute__((unused)))
+{
+/* NIODBG("%d", fileno (stderr)); */
+ return fileno (stderr);
+}
+
+
JNIEXPORT void JNICALL
Java_gnu_java_nio_VMChannel_initIDs (JNIEnv *env,
jclass clazz __attribute__ ((__unused__)))
{
jclass bufferClass = JCL_FindClass(env, "java/nio/Buffer");
jclass byteBufferClass = JCL_FindClass(env, "java/nio/ByteBuffer");
-
+
+/* NIODBG("%s", "..."); */
+
address_fid = (*env)->GetFieldID(env, bufferClass, "address",
"Lgnu/classpath/Pointer;");
if (address_fid == NULL)
@@ -252,6 +326,8 @@ Java_gnu_java_nio_VMChannel_setBlocking (JNIEnv *env,
{
int opts;
+/* NIODBG("fd: %d; blocking: %d", fd, blocking); */
+
opts = fcntl(fd, F_GETFL);
if (opts < 0)
{
@@ -260,10 +336,10 @@ Java_gnu_java_nio_VMChannel_setBlocking (JNIEnv *env,
return;
}
- if (blocking)
- opts |= O_NONBLOCK;
- else
+ if (blocking == JNI_TRUE)
opts &= ~(O_NONBLOCK);
+ else
+ opts |= O_NONBLOCK;
opts = fcntl(fd, F_SETFL, opts);
@@ -277,14 +353,17 @@ Java_gnu_java_nio_VMChannel_setBlocking (JNIEnv *env,
JNIEXPORT jint JNICALL
-Java_gnu_java_nio_VMChannel_read (JNIEnv *env,
- jobject o __attribute__ ((__unused__)),
- jint fd,
- jobject bbuf)
+Java_gnu_java_nio_VMChannel_read__ILjava_nio_ByteBuffer_2 (JNIEnv *env,
+ jobject o __attribute__ ((__unused__)),
+ jint fd,
+ jobject bbuf)
{
+#ifdef HAVE_READ
jint len;
ssize_t result;
struct JCL_buffer buf;
+
+/* NIODBG("fd: %d; bbuf: %p", fd, bbuf); */
if (JCL_init_buffer(env, &buf, bbuf) < 0)
{
@@ -292,14 +371,22 @@ Java_gnu_java_nio_VMChannel_read (JNIEnv *env,
JCL_ThrowException (env, IO_EXCEPTION, "Buffer initialisation failed");
return -1;
}
-
+
len = buf.limit - buf.position;
+
+ if (len == 0)
+ {
+ JCL_release_buffer (env, &buf, bbuf, JNI_ABORT);
+ return 0;
+ }
- result = read(fd, &(buf.ptr[buf.position + buf.offset]), len);
- buf.count = result;
+ result = cpnio_read (fd, &(buf.ptr[buf.position + buf.offset]), len);
if (result == 0)
- result = -1; /* End Of File */
+ {
+ result = -1;
+ buf.count = 0;
+ }
else if (result == -1)
{
buf.count = 0;
@@ -311,7 +398,13 @@ Java_gnu_java_nio_VMChannel_read (JNIEnv *env,
JCL_ThrowException (env, NON_READABLE_CHANNEL_EXCEPTION,
strerror(errno));
return -1;
- }
+ }
+ else if (EINTR == errno) /* read interrupted */
+ {
+ JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
+ JCL_ThrowException(env, INTERRUPTED_IO_EXCEPTION, strerror (errno));
+ return -1;
+ }
else
{
JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
@@ -320,21 +413,31 @@ Java_gnu_java_nio_VMChannel_read (JNIEnv *env,
}
}
else
-
- JCL_release_buffer(env, &buf, bbuf, JNI_COMMIT);
+ buf.count = result;
+
+ JCL_release_buffer(env, &buf, bbuf, 0);
return result;
+#else
+ (void) fd;
+ (void) bbuf;
+ JCL_ThrowException (env, IO_EXCEPTION, "read not supported");
+ return -1;
+#endif /* HAVE_READ */
}
JNIEXPORT jint JNICALL
-Java_gnu_java_nio_VMChannel_write (JNIEnv *env,
- jobject o __attribute__ ((__unused__)),
- jint fd,
- jobject bbuf)
+Java_gnu_java_nio_VMChannel_write__ILjava_nio_ByteBuffer_2 (JNIEnv *env,
+ jobject o __attribute__ ((__unused__)),
+ jint fd,
+ jobject bbuf)
{
+#ifdef HAVE_WRITE
jint len;
ssize_t result;
struct JCL_buffer buf;
+
+/* NIODBG("fd: %d; bbuf: %p", fd, bbuf); */
if (JCL_init_buffer(env, &buf, bbuf) < 0)
{
@@ -342,16 +445,24 @@ Java_gnu_java_nio_VMChannel_write (JNIEnv *env,
JCL_ThrowException (env, IO_EXCEPTION, "Buffer initialisation failed");
return -1;
}
-
+
len = buf.limit - buf.position;
+
+ if (len == 0)
+ {
+ JCL_release_buffer (env, &buf, bbuf, JNI_ABORT);
+ return 0;
+ }
- result = write(fd, &(buf.ptr[buf.position + buf.offset]), len);
+ result = cpnio_write (fd, &(buf.ptr[buf.position + buf.offset]), len);
buf.count = result;
-
+
if (result == -1)
{
if (errno == EAGAIN) /* Non-blocking */
+ {
result = 0;
+ }
else
{
JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
@@ -362,7 +473,13 @@ Java_gnu_java_nio_VMChannel_write (JNIEnv *env,
JCL_release_buffer(env, &buf, bbuf, JNI_ABORT);
- return result;
+ return result;
+#else
+ (void) fd;
+ (void) bbuf;
+ JCL_ThrowException (env, IO_EXCEPTION, "write not supported");
+ return -1;
+#endif /* HAVE_WRITE */
}
@@ -390,7 +507,10 @@ Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env,
struct JCL_buffer bi_list[JCL_IOV_MAX];
ssize_t result;
jint vec_len = length < JCL_IOV_MAX ? length : JCL_IOV_MAX;
- jlong bytes_read = 0;
+ jlong bytes_read = 0;
+
+/* NIODBG("fd: %d; bbufs: %p; offset: %d; length: %d", */
+/* fd, bbufs, offset, length); */
/* Build the vector of buffers to read into */
for (i = 0; i < vec_len; i++)
@@ -401,7 +521,9 @@ Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env,
buf = &bi_list[i];
bbuf = (*env)->GetObjectArrayElement(env, bbufs, offset + i);
- JCL_init_buffer(env, buf, bbuf);
+ JCL_init_buffer(env, buf, bbuf);
+
+/* JCL_print_buffer (env, buf); */
buffers[i].iov_base = &(buf->ptr[buf->position + buf->offset]);
buffers[i].iov_len = buf->limit - buf->position;
@@ -409,7 +531,7 @@ Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env,
}
/* Work the scattering magic */
- result = readv(fd, buffers, vec_len);
+ result = cpnio_readv (fd, buffers, vec_len);
bytes_read = (jlong) result;
/* Handle the response */
@@ -442,6 +564,7 @@ Java_gnu_java_nio_VMChannel_readScattering (JNIEnv *env,
return (jlong) result;
}
+
/*
* Implementation of a gathering write. Will use the appropriate
* vector based read call (currently readv on Linux).
@@ -468,6 +591,8 @@ Java_gnu_java_nio_VMChannel_writeGathering (JNIEnv *env,
jint vec_len = length < JCL_IOV_MAX ? length : JCL_IOV_MAX;
jlong bytes_written;
+/* NIODBG("fd: %d; bbufs: %p; offset: %d; length: %d", */
+/* fd, bbufs, offset, length); */
/* Build the vector of buffers to read into */
for (i = 0; i < vec_len; i++)
@@ -480,13 +605,15 @@ Java_gnu_java_nio_VMChannel_writeGathering (JNIEnv *env,
JCL_init_buffer(env, buf, bbuf);
+/* JCL_print_buffer(env, buf); */
+
buffers[i].iov_base = &(buf->ptr[buf->position + buf->offset]);
buffers[i].iov_len = buf->limit - buf->position;
(*env)->DeleteLocalRef(env, bbuf);
}
/* Work the gathering magic */
- result = writev(fd, buffers, vec_len);
+ result = cpnio_writev (fd, buffers, vec_len);
bytes_written = (jlong) result;
if (result < 0)
@@ -518,6 +645,1150 @@ Java_gnu_java_nio_VMChannel_writeGathering (JNIEnv *env,
}
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: receive
+ * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_receive (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jobject dst, jobject addrPort)
+{
+#ifdef HAVE_RECVFROM
+ char *addrPortPtr = (*env)->GetDirectBufferAddress (env, addrPort);
+ struct JCL_buffer buf;
+#ifdef HAVE_INET6
+ struct sockaddr_in6 sock_storage;
+ struct sockaddr_in6 *sock6;
+ socklen_t slen = sizeof (struct sockaddr_in6);
+#else
+ struct sockaddr_in sock_storage;
+ socklen_t slen = sizeof (struct sockaddr_in);
+#endif /* HAVE_INET6 */
+ struct sockaddr *sockaddr = (struct sockaddr *) &sock_storage;
+ struct sockaddr_in *sock4;
+ int ret;
+ jint result = -1;
+
+ if (JCL_init_buffer (env, &buf, dst) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, "loading buffer failed");
+
+ ret = cpnio_recvfrom (fd, &(buf.ptr[buf.position + buf.offset]),
+ buf.limit - buf.position, MSG_WAITALL,
+ sockaddr, &slen);
+
+ if (-1 == ret)
+ {
+ JCL_release_buffer (env, &buf, dst, JNI_ABORT);
+ if (EINTR == errno)
+ JCL_ThrowException (env, "java/io/InterruptedIOException", strerror (errno));
+ else if (EAGAIN == errno)
+ {
+ /* If the socket is in blocking mode, our timeout expired. */
+ int val = fcntl (fd, F_GETFL, 0);
+ if (val == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ else if ((val & O_NONBLOCK) == 0)
+ JCL_ThrowException (env, "java/net/SocketTimeoutException",
+ "read timed out");
+ }
+ else
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return 0;
+ }
+
+ if (sockaddr->sa_family == AF_INET)
+ {
+ sock4 = (struct sockaddr_in *) sockaddr;
+ memcpy (addrPortPtr, &(sock4->sin_addr.s_addr), 4);
+ ;memcpy (addrPortPtr + 4, &(sock4->sin_port), 2);
+ result = 4;
+ }
+#ifdef HAVE_INET6
+ else if (sockaddr->sa_family == AF_INET6)
+ {
+ sock6 = (struct sockaddr_in6 *) sockaddr;
+ memcpy (addrPortPtr, &(sock6->sin6_addr.s6_addr), 16);
+ memcpy (addrPortPtr + 16, &(sock6->sin6_port), 2);
+ result = 16;
+ }
+#endif /* HAVE_INET6 */
+ else if (ret == 0)
+ {
+ result = 0;
+ }
+ else
+ {
+ JCL_ThrowException (env, "java/net/SocketException",
+ "unsupported address type returned");
+ }
+
+ buf.count += ret;
+ JCL_release_buffer (env, &buf, dst, 0);
+ return result;
+#else
+ (void) fd;
+ (void) dst;
+ (void) addrPort;
+ JCL_ThrowException (env, IO_EXCEPTION, "recvfrom not supported");
+#endif /* HAVE_RECVFROM */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: send
+ * Signature: (Ljava/nio/ByteBuffer;[BI)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_send (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ int fd, jobject src, jbyteArray addr, jint port)
+{
+#ifdef HAVE_SENDTO
+ struct sockaddr_in sockaddr;
+ jbyte *elems;
+ struct JCL_buffer buf;
+ int ret;
+
+/* NIODBG("fd: %d; src: %p; addr: %p; port: %d", */
+/* fd, src, addr, port); */
+
+ if (JCL_init_buffer (env, &buf, src) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, "loading buffer failed");
+ return -1;
+ }
+
+/* JCL_print_buffer (env, &buf); */
+
+ elems = (*env)->GetByteArrayElements (env, addr, NULL);
+
+ sockaddr.sin_family = AF_INET;
+ sockaddr.sin_addr.s_addr = *((uint32_t *) elems);
+ sockaddr.sin_port = htons (port);
+
+ do
+ {
+ ret = cpnio_sendto (fd, &(buf.ptr[buf.position + buf.offset]),
+ buf.limit - buf.position,
+ 0, (const struct sockaddr *) &sockaddr,
+ sizeof (struct sockaddr_in));
+ }
+ while (-1 == ret && EINTR == errno);
+
+ (*env)->ReleaseByteArrayElements (env, addr, elems, JNI_ABORT);
+
+ if (-1 == ret)
+ {
+ if (errno != EAGAIN)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_release_buffer (env, &buf, src, JNI_ABORT);
+ return 0;
+ }
+
+ buf.count += ret;
+ JCL_release_buffer (env, &buf, src, JNI_ABORT);
+ return ret;
+#else
+ (void) fd;
+ (void) src;
+ (void) addr;
+ (void) port;
+#endif /* HAVE_SENDTO */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: send6
+ * Signature: (Ljava/nio/ByteBuffer;[BI)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_send6 (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ int fd, jobject src, jbyteArray addr, jint port)
+{
+#if defined(HAVE_SENDTO) && defined(HAVE_INET6)
+ struct sockaddr_in6 sockaddr;
+ jbyte *elems;
+ struct JCL_buffer buf;
+ int ret;
+
+/* NIODBG("fd: %d; src: %p; addr: %p; port: %d", */
+/* fd, src, addr, port); */
+
+ if (JCL_init_buffer (env, &buf, src) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, "loading buffer failed");
+ return -1;
+ }
+
+/* JCL_print_buffer (env, &buf); */
+
+ elems = (*env)->GetByteArrayElements (env, addr, NULL);
+
+ sockaddr.sin6_family = AF_INET6;
+ memcpy (&sockaddr.sin6_addr.s6_addr, elems, 16);
+ sockaddr.sin6_port = htons (port);
+
+ do
+ {
+ ret = cpnio_sendto (fd, (const void *) (buf.ptr + buf.offset),
+ buf.limit - buf.position,
+ 0, (const struct sockaddr *) &sockaddr,
+ sizeof (struct sockaddr_in6));
+ }
+ while (-1 == ret && EINTR == errno);
+
+ (*env)->ReleaseByteArrayElements (env, addr, elems, JNI_ABORT);
+
+ if (-1 == ret)
+ {
+ if (errno != EAGAIN)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ JCL_release_buffer (env, &buf, src, JNI_ABORT);
+ return 0;
+ }
+
+ buf.count += ret;
+ JCL_release_buffer (env, &buf, src, JNI_ABORT);
+ return ret;
+#else
+ (void) fd;
+ (void) src;
+ (void) addr;
+ (void) port;
+ JCL_ThrowException (env, IO_EXCEPTION, "IPv6 sendto not supported");
+ return -1;
+#endif /* HAVE_SENDTO && HAVE_INET6 */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: read
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_read__I (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
+{
+#ifdef HAVE_READ
+ char in;
+ int ret;
+
+/* NIODBG("fd: %d", fd); */
+
+ ret = cpnio_read (fd, &in, 1);
+ if (-1 == ret)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ if (0 == ret)
+ return -1;
+
+ return (in & 0xFF);
+#else
+ (void) fd;
+ JCL_ThrowException (env, IO_EXCEPTION, "read not supported");
+#endif /* HAVE_READ */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: write
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_write__II (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jint data)
+{
+#ifdef HAVE_WRITE
+ char out = (char) data;
+ int ret;
+
+/* NIODBG("fd: %d; data: %d", fd, data); */
+
+ ret = cpnio_write (fd, &out, 1);
+
+ if (-1 == ret)
+ JCL_ThrowException(env, IO_EXCEPTION, strerror (errno));
+#else
+ (void) fd;
+ (void) data;
+ JCL_ThrowException (env, IO_EXCEPTION, "write not supported");
+#endif /* HAVE_WRITE */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: socket
+ * Signature: (Z)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_socket (JNIEnv *env, jclass clazz __attribute__((unused)),
+ jboolean stream)
+{
+#ifdef HAVE_SOCKET
+ int ret;
+
+ do
+ {
+ ret = cpnio_socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
+ }
+ while (-1 == ret && EINTR == errno);
+
+ if (ret == -1)
+ JCL_ThrowException (env, "java/net/SocketException", strerror (errno));
+/* NIODBG("created socket %d", ret); */
+
+ return ret;
+#else
+ (void) stream;
+ JCL_ThrowException (env, IO_EXCEPTION, "socket not supported");
+ return -1;
+#endif /* HAVE_SOCKET */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: connect
+ * Signature: (I[BI)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_nio_VMChannel_connect (JNIEnv *env, jclass clazz __attribute__((unused)),
+ jint fd, jbyteArray addr, jint port, jint timeout)
+{
+#ifdef HAVE_CONNECT
+ struct sockaddr_in sockaddr;
+ struct timeval timeo;
+ int origflags = 0, flags;
+ jbyte *addr_elems;
+ int ret;
+
+ if ((*env)->GetArrayLength (env, addr) != 4)
+ {
+ JCL_ThrowException (env, "java/io/IOException", "expecting 4-byte address");
+ return JNI_FALSE;
+ }
+
+ if (timeout > 0)
+ {
+ timeo.tv_sec = timeout / 1000;
+ timeo.tv_usec = (timeout % 1000) * 1000;
+ origflags = fcntl (fd, F_GETFL, 0);
+ if (origflags == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ /* Set nonblocking mode, if not already set. */
+ if (!(origflags & O_NONBLOCK))
+ {
+ flags = origflags | O_NONBLOCK;
+ if (fcntl (fd, F_SETFL, flags) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+ }
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+
+ memset (&sockaddr, 0, sizeof (struct sockaddr_in));
+ sockaddr.sin_family = AF_INET;
+ sockaddr.sin_port = htons (port);
+ sockaddr.sin_addr.s_addr = *((uint32_t *) addr_elems);
+
+
+ ret = cpnio_connect (fd, (struct sockaddr *) &sockaddr,
+ sizeof (struct sockaddr_in));
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ /* If a timeout was specified, select on the file descriptor with
+ the timeout. */
+ if (timeout > 0 && ret == -1)
+ {
+ /* Reset the non-blocking flag, if needed. */
+ if (!(origflags & O_NONBLOCK))
+ {
+ if (fcntl (fd, F_SETFL, origflags) == -1)
+ {
+ /* oops */
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+ if (EINPROGRESS == errno)
+ {
+ fd_set wrfds;
+ FD_SET(fd, &wrfds);
+ ret = cpnio_select (fd + 1, NULL, &wrfds, NULL, &timeo);
+ if (ret == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ if (ret == 0) /* connect timed out */
+ {
+ JCL_ThrowException (env, SOCKET_TIMEOUT_EXCEPTION,
+ "connect timed out");
+ return JNI_FALSE;
+ }
+ return JNI_TRUE; /* Connected! */
+ }
+ else if (ECONNREFUSED == errno)
+ {
+ JCL_ThrowException (env, "java/net/ConnectException",
+ strerror (errno));
+ return JNI_FALSE;
+ }
+ else
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+
+ if (ret == -1)
+ {
+ if (EINPROGRESS == errno)
+ return JNI_FALSE;
+ else if (ECONNREFUSED == errno)
+ {
+ JCL_ThrowException (env, "java/net/ConnectException",
+ strerror (errno));
+ return JNI_FALSE;
+ }
+ else
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+
+ return JNI_TRUE;
+#else
+ (void) fd;
+ (void) addr;
+ (void) port;
+ (void) timeout;
+ JCL_ThrowException (env, IO_EXCEPTION, "connect not supported");
+ return JNI_FALSE;
+#endif /* HAVE_CONNECT */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: connect6
+ * Signature: (I[BI)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_nio_VMChannel_connect6 (JNIEnv *env, jclass clazz __attribute__((unused)),
+ jint fd, jbyteArray addr, jint port, int timeout)
+{
+#if defined(HAVE_CONNECT) && defined(HAVE_INET6)
+ struct sockaddr_in6 sockaddr;
+ struct timeval timeo;
+ int flags, origflags = 0;
+ jbyte *addr_elems;
+ int ret;
+
+ if (timeout > 0)
+ {
+ timeo.tv_sec = timeout / 1000;
+ timeo.tv_usec = (timeout % 1000) * 1000;
+ origflags = fcntl (fd, F_GETFL, 0);
+ if (origflags == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ /* Set nonblocking mode, if not already set. */
+ if (!(origflags & O_NONBLOCK))
+ {
+ flags = origflags | O_NONBLOCK;
+ if (fcntl (fd, F_SETFL, flags) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+ }
+
+ addr_elems = (*env)->GetByteArrayElements (env, addr, NULL);
+
+ memset (&sockaddr, 0, sizeof (struct sockaddr_in6));
+ sockaddr.sin6_family = AF_INET6;
+ sockaddr.sin6_port = htons (port);
+ memcpy (&sockaddr.sin6_addr.s6_addr, addr_elems, 16);
+
+ ret = cpnio_connect (fd, (struct sockaddr *) &sockaddr,
+ sizeof (struct sockaddr_in6));
+
+ (*env)->ReleaseByteArrayElements (env, addr, addr_elems, JNI_ABORT);
+
+ /* If a timeout was specified, select on the file descriptor with
+ the timeout. */
+ if (timeout > 0 && ret == -1)
+ {
+ /* Reset the non-blocking flag, if needed. */
+ if (!(origflags & O_NONBLOCK))
+ {
+ if (fcntl (fd, F_SETFL, origflags) == -1)
+ {
+ /* oops */
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+ if (EINPROGRESS == errno)
+ {
+ fd_set wrfds;
+ FD_SET(fd, &wrfds);
+ ret = cpnio_select (fd + 1, NULL, &wrfds, NULL, &timeo);
+ if (ret == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ if (ret == 0) /* connect timed out */
+ {
+ JCL_ThrowException (env, SOCKET_TIMEOUT_EXCEPTION,
+ "connect timed out");
+ return JNI_FALSE;
+ }
+ return JNI_TRUE; /* Connected! */
+ }
+ else if (ECONNREFUSED == errno)
+ {
+ JCL_ThrowException (env, "java/net/ConnectException",
+ strerror (errno));
+ return JNI_FALSE;
+ }
+ else
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+
+ if (ret == -1)
+ {
+ if (EAGAIN == errno)
+ return JNI_FALSE;
+ else if (ECONNREFUSED == errno)
+ {
+ JCL_ThrowException (env, "java/net/ConnectException",
+ strerror (errno));
+ return JNI_FALSE;
+ }
+ else
+ {
+ JCL_ThrowException (env, "java/io/IOException", strerror (errno));
+ return JNI_FALSE;
+ }
+ }
+
+ return JNI_TRUE;
+#else
+ (void) fd;
+ (void) addr;
+ (void) port;
+ (void) timeout;
+ JCL_ThrowException (env, IO_EXCEPTION, "IPv6 connect not supported");
+ return JNI_FALSE;
+#endif /* HAVE_CONNECT && HAVE_INET6 */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: getsockname
+ * Signature: (ILjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_getsockname (JNIEnv *env, jclass clazz __attribute__((unused)),
+ jint fd, jobject name)
+{
+#ifdef HAVE_GETSOCKNAME
+#ifdef HAVE_INET6
+ struct sockaddr_in6 *addr6;
+ struct sockaddr_in6 sock_storage;
+ socklen_t socklen = sizeof (struct sockaddr_in6);
+#else
+ struct sockaddr_in sock_storage;
+ socklen_t socklen = sizeof (struct sockaddr_in);
+#endif /* HAVE_INET6 */
+
+ struct sockaddr *sockaddr = (struct sockaddr *) &sock_storage;
+ struct sockaddr_in *addr4;
+ int ret;
+ char *nameptr = (*env)->GetDirectBufferAddress (env, name);
+
+ ret = getsockname (fd, sockaddr, &socklen);
+ if (ret == -1)
+ {
+ JCL_ThrowException (env, "java/net/SocketException", strerror (errno));
+ return 0;
+ }
+
+ if (sockaddr->sa_family == AF_INET)
+ {
+ addr4 = (struct sockaddr_in *) sockaddr;
+ memcpy (nameptr, &(addr4->sin_addr.s_addr), 4);
+ memcpy (nameptr + 4, &(addr4->sin_port), 2);
+ return 4;
+ }
+
+#ifdef HAVE_INET6
+ /* IPv6 */
+ if (sockaddr->sa_family == AF_INET6)
+ {
+ addr6 = (struct sockaddr_in6 *) sockaddr;
+ memcpy (nameptr, &(addr6->sin6_addr.s6_addr), 16);
+ memcpy (nameptr, &(addr6->sin6_port), 2);
+ return 16;
+ }
+#endif /* HAVE_INET6 */
+ JCL_ThrowException (env, IO_EXCEPTION, "unsupported address format");
+ return -1;
+#else
+ (void) fd;
+ (void) name;
+ JCL_ThrowException (env, IO_EXCEPTION, "getsockname not supported");
+ return -1;
+#endif /* HAVE_GETSOCKNAME */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: getpeername
+ * Signature: (ILjava/nio/ByteBuffer;)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_getpeername (JNIEnv *env, jclass clazz __attribute__((unused)),
+ jint fd, jobject name)
+{
+#ifdef HAVE_GETPEERNAME
+#ifdef HAVE_INET6
+ struct sockaddr_in6 *addr6;
+ struct sockaddr_in6 sock_storage;
+ socklen_t socklen = sizeof (struct sockaddr_in6);
+#else
+ struct sockaddr_in sock_storage;
+ socklen_t socklen = sizeof (struct sockaddr_in);
+#endif /* HAVE_INET6 */
+
+ struct sockaddr *sockaddr = (struct sockaddr *) &sock_storage;
+ struct sockaddr_in *addr4;
+ int ret;
+ char *nameptr = (*env)->GetDirectBufferAddress (env, name);
+
+ ret = getpeername (fd, sockaddr, &socklen);
+ if (ret == -1)
+ {
+ if (ENOTCONN != errno)
+ JCL_ThrowException (env, "java/net/SocketException", strerror (errno));
+ return 0;
+ }
+
+ if (sockaddr->sa_family == AF_INET)
+ {
+ addr4 = (struct sockaddr_in *) sockaddr;
+ memcpy (nameptr, &(addr4->sin_addr.s_addr), 4);
+ memcpy (nameptr + 4, &(addr4->sin_port), 2);
+ return 4;
+ }
+#ifdef HAVE_INET6
+ else if (sockaddr->sa_family == AF_INET6)
+ {
+ addr6 = (struct sockaddr_in6 *) sockaddr;
+ memcpy (nameptr, &(addr6->sin6_addr.s6_addr), 16);
+ memcpy (nameptr, &(addr6->sin6_port), 2);
+ return 16;
+ }
+#endif /* HAVE_INET6 */
+
+ JCL_ThrowException (env, "java/net/SocketException",
+ "unsupported address type");
+ return -1;
+#else
+ (void) fd;
+ (void) name;
+ JCL_ThrowException (env, IO_EXCEPTION, "getpeername not supported");
+ return -1;
+#endif /* HAVE_GETPEERNAME */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: accept
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_accept (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jint fd)
+{
+#ifdef HAVE_ACCEPT
+ int ret;
+
+#ifdef HAVE_INET6
+ struct sockaddr_in6 addr;
+ socklen_t alen = sizeof (struct sockaddr_in6);
+#else
+ struct sockaddr_in addr;
+ socklen_t alen = sizeof (struct sockaddr_in);
+#endif /* HAVE_INET6 */
+
+ do
+ {
+ ret = cpnio_accept (fd, (struct sockaddr *) &addr, &alen);
+ }
+ while (ret == -1 && EINTR == errno);
+
+ if (ret == -1)
+ {
+ if (EWOULDBLOCK != ret && EAGAIN != ret)
+ JCL_ThrowException (env, "java/net/SocketException", strerror (errno));
+ }
+
+ return ret;
+#else
+ (void) fd;
+ JCL_ThrowException (env, IO_EXCEPTION, "accept not supported");
+ return -1;
+#endif /* HAVE_ACCEPT */
+}
+
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: disconnect
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_disconnect (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
+{
+ struct sockaddr sockaddr;
+
+ sockaddr.sa_family = AF_UNSPEC;
+ if (connect (fd, &sockaddr, sizeof (struct sockaddr)) == -1)
+ {
+ /* The expected error for a successful disconnect is EAFNOSUPPORT. */
+ if (errno != EAFNOSUPPORT)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: close
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_close (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
+{
+ if (close (fd) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: available
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_available (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
+{
+ jint avail = 0;
+
+/* NIODBG("fd: %d", fd); */
+ if (ioctl (fd, FIONREAD, &avail) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+/* NIODBG("avail: %d", avail); */
+
+ return avail;
+}
+
+
+enum FileChannel_mode {
+ CPNIO_READ = 1,
+ CPNIO_WRITE = 2,
+ CPNIO_APPEND = 4,
+ CPNIO_EXCL = 8,
+ CPNIO_SYNC = 16,
+ CPNIO_DSYNC = 32
+};
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: open
+ * Signature: (Ljava/lang/String;I)I
+ */
+JNIEXPORT jint JNICALL
+Java_gnu_java_nio_VMChannel_open (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jstring path, jint mode)
+{
+ int nmode = 0;
+ int ret;
+ const char *npath;
+ mode_t mask = umask (0);
+ umask (mask);
+
+ if ((mode & CPNIO_READ) && (mode & CPNIO_WRITE))
+ nmode = O_RDWR;
+ else if (mode & CPNIO_WRITE)
+ nmode = O_WRONLY;
+ else
+ nmode = O_RDONLY;
+
+ nmode = (nmode
+ | ((nmode == O_RDWR || nmode == O_WRONLY) ? O_CREAT : 0)
+ | ((mode & CPNIO_APPEND) ? O_APPEND :
+ ((nmode == O_RDWR || nmode == O_WRONLY) ? O_TRUNC : 0))
+ | ((mode & CPNIO_EXCL) ? O_EXCL : 0)
+ | ((mode & CPNIO_SYNC) ? O_SYNC : 0));
+
+ npath = JCL_jstring_to_cstring (env, path);
+
+/* NIODBG("path: %s; mode: %x", npath, nmode); */
+
+ ret = open (npath, nmode, 0777 & ~mask);
+
+/* NIODBG("ret: %d\n", ret); */
+
+ JCL_free_cstring (env, path, npath);
+
+ if (-1 == ret)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+ return ret;
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: position
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL
+Java_gnu_java_nio_VMChannel_position (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
+{
+#ifdef HAVE_LSEEK
+ off_t ret;
+
+ ret = lseek (fd, 0, SEEK_CUR);
+
+ if (-1 == ret)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+ return (jlong) ret;
+#else
+ JCL_ThrowException (env, IO_EXCEPTION, "position not supported");
+ return -1;
+#endif /* HAVE_LSEEK */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: seek
+ * Signature: (IJ)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_seek (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jlong pos)
+{
+#ifdef HAVE_LSEEK
+ if (lseek (fd, (off_t) pos, SEEK_SET) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+#else
+ JCL_ThrowException (env, IO_EXCEPTION, "seek not supported");
+#endif /* HAVE_LSEEK */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: truncate
+ * Signature: (IJ)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_truncate (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jlong len)
+{
+#if defined(HAVE_FTRUNCATE) && defined(HAVE_LSEEK)
+ off_t pos = lseek (fd, 0, SEEK_CUR);
+ if (pos == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return;
+ }
+ if (ftruncate (fd, (off_t) len) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return;
+ }
+ if (pos > len)
+ {
+ if (lseek (fd, len, SEEK_SET) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+#else
+ JCL_ThrowException (env, IO_EXCEPTION, "truncate not supported");
+#endif /* HAVE_FTRUNCATE && HAVE_LSEEK */
+}
+
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: lock
+ * Signature: (IJJZZ)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_nio_VMChannel_lock (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jlong pos, jlong len,
+ jboolean shared, jboolean wait)
+{
+#if HAVE_FCNTL
+ struct flock fl;
+
+ fl.l_start = (off_t) pos;
+ fl.l_len = (off_t) len;
+ fl.l_pid = getpid ();
+ fl.l_type = (shared ? F_RDLCK : F_WRLCK);
+ fl.l_whence = SEEK_SET;
+
+ if (cpnio_fcntl (fd, (wait ? F_SETLKW : F_SETLK), (long) &fl) == -1)
+ {
+ if (errno != EAGAIN)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+
+ return JNI_TRUE;
+#else
+ JCL_ThrowException (env, IO_EXCEPTION, "lock not supported");
+ return JNI_FALSE;
+#endif /* HAVE_FCNTL */
+}
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: unlock
+ * Signature: (IJJ)V
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_nio_VMChannel_unlock (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jlong pos, jlong len)
+{
+#if HAVE_FCNTL
+ struct flock fl;
+
+ fl.l_start = (off_t) pos;
+ fl.l_len = (off_t) len;
+ fl.l_pid = getpid ();
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+
+ if (cpnio_fcntl (fd, F_SETLK, (long) &fl) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
+#else
+ JCL_ThrowException (env, IO_EXCEPTION, "unlock not supported");
+#endif /* HAVE_FCNTL */
+}
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: size
+ * Signature: (I)J
+ */
+JNIEXPORT jlong JNICALL
+Java_gnu_java_nio_VMChannel_size (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd)
+{
+#ifdef HAVE_FSTAT
+ struct stat st;
+
+ if (fstat (fd, &st) == -1)
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+ return (jlong) st.st_size;
+#else
+ JCL_ThrowException (env, IO_EXCEPTION, "size not supported");
+ return 0;
+#endif
+}
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: map
+ * Signature: (ICJI)Lgnu/classpath/Pointer;
+ */
+JNIEXPORT jobject JNICALL
+Java_gnu_java_nio_VMChannel_map (JNIEnv *env,
+ jclass clazz __attribute__((unused)),
+ jint fd, jchar mode, jlong position, jint size)
+{
+#ifdef HAVE_MMAP
+ jclass MappedByteBufferImpl_class;
+ jmethodID MappedByteBufferImpl_init = NULL;
+ jobject Pointer_instance;
+ volatile jobject buffer;
+ long pagesize;
+ int prot, flags;
+ void *p;
+ void *address;
+
+/* NIODBG("fd: %d; mode: %x; position: %lld; size: %d", */
+/* fd, mode, position, size); */
+
+ /* FIXME: should we just assume we're on an OS modern enough to
+ have 'sysconf'? And not check for 'getpagesize'? */
+#if defined(HAVE_GETPAGESIZE)
+ pagesize = getpagesize ();
+#elif defined(HAVE_SYSCONF)
+ pagesize = sysconf (_SC_PAGESIZE);
+#else
+ JCL_ThrowException (env, IO_EXCEPTION,
+ "can't determine memory page size");
+ return NULL;
+#endif /* HAVE_GETPAGESIZE/HAVE_SYSCONF */
+
+ if ((*env)->ExceptionOccurred (env))
+ {
+ return NULL;
+ }
+
+ prot = PROT_READ;
+ if (mode == '+' || mode == 'c')
+ {
+ /* When writing we need to make sure the file is big enough,
+ otherwise the result of mmap is undefined. */
+ struct stat st;
+ if (fstat (fd, &st) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return NULL;
+ }
+ if (position + size > st.st_size)
+ {
+ if (ftruncate(fd, position + size) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return NULL;
+ }
+ }
+ prot |= PROT_WRITE;
+ }
+
+ flags = (mode == 'c' ? MAP_PRIVATE : MAP_SHARED);
+ p = mmap (NULL, (size_t) ALIGN_UP (size, pagesize), prot, flags,
+ fd, ALIGN_DOWN (position, pagesize));
+ if (p == MAP_FAILED)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return NULL;
+ }
+
+ /* Unalign the mapped value back up, since we aligned offset
+ down to a multiple of the page size. */
+ address = (void *) ((char *) p + (position % pagesize));
+
+ Pointer_instance = JCL_NewRawDataObject(env, address);
+
+ MappedByteBufferImpl_class = (*env)->FindClass (env,
+ "java/nio/MappedByteBufferImpl");
+ if (MappedByteBufferImpl_class != NULL)
+ {
+ MappedByteBufferImpl_init =
+ (*env)->GetMethodID (env, MappedByteBufferImpl_class,
+ "<init>", "(Lgnu/classpath/Pointer;IZ)V");
+ }
+
+ if ((*env)->ExceptionOccurred (env))
+ {
+ munmap (p, ALIGN_UP (size, pagesize));
+ return NULL;
+ }
+ if (MappedByteBufferImpl_init == NULL)
+ {
+ JCL_ThrowException (env, "java/lang/InternalError",
+ "could not get MappedByteBufferImpl constructor");
+ munmap (p, ALIGN_UP (size, pagesize));
+ return NULL;
+ }
+
+ buffer = (*env)->NewObject (env, MappedByteBufferImpl_class,
+ MappedByteBufferImpl_init, Pointer_instance,
+ (jint) size, mode == 'r');
+ return buffer;
+#else
+ (void) fd;
+ (void) mode;
+ (void) position;
+ (void) size;
+ JCL_ThrowException (env, IO_EXCEPTION,
+ "memory-mapped files not implemented");
+ return 0;
+#endif /* HAVE_MMAP */
+}
+
+/*
+ * Class: gnu_java_nio_VMChannel
+ * Method: flush
+ * Signature: (IZ)Z
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_nio_VMChannel_flush (JNIEnv *env,
+ jclass c __attribute__((unused)),
+ jint fd, jboolean metadata __attribute__((unused)))
+{
+#ifdef HAVE_FSYNC
+ /* XXX blocking? */
+ if (fsync (fd) == -1)
+ {
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ return JNI_FALSE;
+ }
+ return JNI_TRUE;
+#else
+ JCL_ThrowException (env, IO_EXCEPTION, "flush not implemented");
+ return JNI_TRUE;
+#endif /* HAVE_FSYNC */
+}
#ifdef __cplusplus
diff --git a/native/jni/java-nio/gnu_java_nio_VMPipe.c b/native/jni/java-nio/gnu_java_nio_VMPipe.c
index 369c5a3d6..cbaaa0834 100644
--- a/native/jni/java-nio/gnu_java_nio_VMPipe.c
+++ b/native/jni/java-nio/gnu_java_nio_VMPipe.c
@@ -35,8 +35,14 @@ 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. */
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
#include <errno.h>
+#include <string.h>
+#include <unistd.h>
#include <jni.h>
#include <jcl.h>
@@ -45,12 +51,33 @@ exception statement from your version. */
#define IO_EXCEPTION "java/io/IOException"
-JNIEXPORT void JNICALL
-Java_gnu_java_nio_VMPipe_init (JNIEnv * env,
- jclass cls __attribute__ ((__unused__)),
- jobject self __attribute__ ((__unused__)),
- jobject provider __attribute__ ((__unused__)))
+/*
+ * Class: gnu_java_nio_VMPipe
+ * Method: pipe0
+ * Signature: ()[I
+ */
+JNIEXPORT jintArray JNICALL
+Java_gnu_java_nio_VMPipe_pipe0 (JNIEnv *env,
+ jclass c __attribute__((unused)))
{
- JCL_ThrowException (env, IO_EXCEPTION,
- "gnu.java.nio.VMPipe.init(): not implemented");
+ int fd[2];
+ jintArray array;
+ jint* elem;
+ int ret;
+
+ /* FIXME: autoconf this? */
+ ret = pipe (fd);
+
+ if (ret == -1)
+ {
+ JCL_ThrowException (env, "java/io/IOException", strerror (errno));
+ return NULL;
+ }
+
+ array = (*env)->NewIntArray (env, 2);
+ elem = (*env)->GetIntArrayElements (env, array, NULL);
+ elem[0] = fd[0];
+ elem[1] = fd[1];
+ (*env)->ReleaseIntArrayElements (env, array, elem, 0);
+ return array;
}
diff --git a/native/jni/java-nio/java_nio_MappedByteBufferImpl.c b/native/jni/java-nio/java_nio_MappedByteBufferImpl.c
index b49091982..2a87d2950 100644
--- a/native/jni/java-nio/java_nio_MappedByteBufferImpl.c
+++ b/native/jni/java-nio/java_nio_MappedByteBufferImpl.c
@@ -1,5 +1,5 @@
/* java_nio_MappedByteBufferImpl.c - Native methods for MappedByteBufferImpl
- Copyright (C) 2004,2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ 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
@@ -43,7 +43,6 @@ exception statement from your version. */
#include "java_nio_MappedByteBufferImpl.h"
-#include <errno.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
diff --git a/native/jni/java-nio/javanio.c b/native/jni/java-nio/javanio.c
new file mode 100644
index 000000000..d9e4d4f1d
--- /dev/null
+++ b/native/jni/java-nio/javanio.c
@@ -0,0 +1,122 @@
+/* javanio.c -- implementations of functions in javanio.h.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+/*
+ * Note, because these functions are trivial, and should be inlined,
+ * we include this file in the header, and do not compile it.
+ */
+
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+CPNIO_EXPORT ssize_t
+cpnio_read (int fd, void *buf, size_t nbytes)
+{
+ return read (fd, buf, nbytes);
+}
+
+CPNIO_EXPORT ssize_t
+cpnio_readv (int fd, const struct iovec *iov, int iovcnt)
+{
+ return readv (fd, iov, iovcnt);
+}
+
+CPNIO_EXPORT ssize_t
+cpnio_write (int fd, const void *buf, size_t nbytes)
+{
+ return write (fd, buf, nbytes);
+}
+
+CPNIO_EXPORT ssize_t
+cpnio_writev (int fd, const struct iovec *iov, size_t iovcnt)
+{
+ return writev (fd, iov, iovcnt);
+}
+
+CPNIO_EXPORT int
+cpnio_socket (int domain, int type, int protocol)
+{
+ return socket (domain, type, protocol);
+}
+
+CPNIO_EXPORT int
+cpnio_connect (int fd, const struct sockaddr *addr, socklen_t addrlen)
+{
+ return connect (fd, addr, addrlen);
+}
+
+CPNIO_EXPORT int
+cpnio_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
+{
+ return accept (fd, addr, addrlen);
+}
+
+CPNIO_EXPORT ssize_t
+cpnio_sendto (int fd, const void *msg, size_t len, int flags,
+ const struct sockaddr *to, socklen_t tolen)
+{
+ return sendto (fd, msg, len, flags, to, tolen);
+}
+
+CPNIO_EXPORT ssize_t
+cpnio_recvfrom (int fd, void *buf, size_t len, int flags,
+ struct sockaddr *from, socklen_t *fromlen)
+{
+ return recvfrom (fd, buf, len, flags, from, fromlen);
+}
+
+CPNIO_EXPORT int
+cpnio_fcntl (int fd, int cmd, long arg)
+{
+#ifdef HAVE_FCNTL
+ return fcntl (fd, cmd, arg);
+#else
+ errno = ENOSUP;
+ return -1;
+#endif /* HAVE_FCNTL */
+}
+
+CPNIO_EXPORT int
+cpnio_select (int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *excepfds, struct timeval *timeo)
+{
+ return select (nfds, readfds, writefds, excepfds, timeo);
+}
diff --git a/native/jni/java-nio/javanio.h b/native/jni/java-nio/javanio.h
new file mode 100644
index 000000000..bdd11055e
--- /dev/null
+++ b/native/jni/java-nio/javanio.h
@@ -0,0 +1,332 @@
+/* javanio.h -- reference implementation of native functions.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is a part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+USA
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#ifndef __JAVANIO_H__
+#define __JAVANIO_H__
+
+/**
+ * This header defines functions that are called by our JNI reference
+ * implementation of java.nio.*. In our reference implementation, these
+ * functions map exactly to their counterparts in POSIX; in implementations
+ * that can't use these functions directly (such as systems that use user-land
+ * threads, and thus can't call blocking system calls directly) can provide
+ * their own implementations suitable for their system.
+ */
+
+/**
+ * This macro is used in all function prototypes below; if any additional
+ * keywords need to be added to a prototype, declare them in this macro.
+ */
+#define CPNIO_EXPORT static inline
+
+/**
+ * Read bytes from the given file descriptor into the given memory address, which
+ * has sufficient space for NBYTES bytes.
+ *
+ * \param fd The file descriptor to read from.
+ * \param buf The memory address to read bytes into.
+ * \param nbytes The number of bytes available to store in BUF.
+ * \return The number of bytes read, possibly zero, on success; return -1 on failure,
+ * and set ERRNO to an appropriate value.
+ * \see read(2)
+ *
+ * Allowed errno values:
+ * [EBADF] If FD is not a valid file descriptor, or is not open for reading.
+ * [EFAULT] If BUF points outside the process's address space.
+ * [EIO] An I/O error occurrs.
+ * [EINTR] If the read is interrupted by a signal.
+ * [EINVAL] If FD is negative.
+ * [EAGAIN] If FD was marked for non-blocking I/O, and no data were ready to
+ * be read.
+ */
+CPNIO_EXPORT ssize_t cpnio_read (int fd, void *buf, size_t nbytes);
+
+/*
+ * Read bytes from a file descriptor into a sequence of IO buffers.
+ *
+ * The iovec structure is defined as:
+ *
+ * struct iovec {
+ * char *iov_base;
+ * size_t iov_len;
+ * };
+ *
+ * The call to _cp_readv should do a scattering read, where for each struct iovec
+ * in the supplied list, up to IOV_LEN bytes are read into IOV_BASE. The function
+ * returns the total number of bytes read into all supplied buffers.
+ *
+ * \param fd The file descriptor.
+ * \param iov A pointer to the head of a list of iovec structures.
+ * \param iovcnt The number of iovec structures pointed to by IOV.
+ * \return The total number of bytes read accross all buffers, possibly zero. On
+ * error, -1 is returned and ERRNO is set.
+ * \see readv(2)
+ *
+ * Allowed ERRNO values include all of those listed for _cp_read, as well as the
+ * following:
+ * [EINVAL] If IOVCNT overflows the maximum number of iovec structures
+ * this platform supports (usually 16), if any IOV_LEN value
+ * is negative, or if the sum of all IOV_LEN values is too
+ * large to be stored in a ssize_t (usually a 32-bit integer).
+ * [EFAULT] If part of IOV points outside the process's address space.
+ */
+CPNIO_EXPORT ssize_t cpnio_readv (int fd, const struct iovec *iov, int iovcnt);
+
+/*
+ * Write NBYTES bytes from BUF to the file descriptor FD, returning the number
+ * of bytes successfully written.
+ *
+ * \param fd The file descriptor.
+ * \param buf A pointer to the bytes to write.
+ * \param nbytes The maximum number of bytes to write.
+ * \return The number of bytes written to the file descriptor, possibly zero. -1
+ * is returned if an error is encountered, and ERRNO will be set.
+ * \see write(2)
+ *
+ * Allowed ERRNO values:
+ * [EBADF] If FD is not a valid file descriptor or is not open for writing.
+ * [EPIPE] If FD is a pipe, when the other side is disconnected; if FD is a
+ * socket, when the peer is not connected.
+ * [EFBIG] When FD is a file, and writing to it overflows the process's
+ * or the system's maximim file size.
+ * [EFAULT] If the buffer to write points outside the process's address
+ * space.
+ * [EINVAL] If the descriptor FD is negative.
+ * [ENOSPC] If FD is a file, and there is insufficient space on the
+ * filesystem.
+ * [EDQUOT] If FD is a file, and the user's disk quota has been exceeded.
+ * [EIO] If an I/O error occurs.
+ * [EINTR] If the call is interrupted by a signal.
+ * [EAGAIN] If FD is in non-blocking mode, and no bytes could be immediately
+ * written.
+ */
+CPNIO_EXPORT ssize_t cpnio_write (int fd, const void *buf, size_t nbytes);
+
+/*
+ * Write data from a sequence of IOVCNT buffers IOV to a file descriptor FD.
+ *
+ * \param fd The file descriptor.
+ * \param iov The list of buffers to write.
+ * \param iovcnt The number of iovec structures pointed to by IOV.
+ * \return The total number of bytes written from the given buffers, possibly
+ * zero. -1 if an error occurs, and ERRNO will be set.
+ * \see writev(2)
+ *
+ * Allowed ERRNO values include those mentioned in _cp_write, as well as:
+ * [EDESTADDRREQ] If the descriptor is a datagram socket, and the peer is
+ * no longer available.
+ * [EINVAL] If IOVCNT is out of range, if any IOV_LEN value is
+ * negative, or if the sum of all IOVCNT IOV_LEN values
+ * will overflow a ssize_t.
+ * [ENOBUFS] If the mbuf pool is exhausted (???).
+ */
+CPNIO_EXPORT ssize_t cpnio_writev (int fd, const struct iovec *iov, size_t iovcnt);
+
+/**
+ * Open a new, unbound and unconnected socket.
+ *
+ * \param domain The socket domain. Implementations need only handle AF_INET.
+ * \param type The socket type; implementations need only handle types
+ * SOCK_STREAM (for streaming sockets) and SOCK_DGRAM (for datagram sockets).
+ * \param protocol This should always be 0. It can be ignored.
+ * \return A new file descriptor pointing to a newly created socket, or -1 on
+ * error, and ERRNO set.
+ *
+ * Allowed ERRNO values:
+ * [EPROTONOSUPPORT] If TYPE is unrecognized.
+ * [EMFILE] If a new file descriptor cannot be allocated, because
+ * the process's descriptor table is full.
+ * [ENFILE] Likewise, but when the system table is full.
+ * [EACCES] If this operation is not allowed.
+ * [ENOBUFS] If there is not enough buffer space available for the
+ * new socket.
+ */
+CPNIO_EXPORT int cpnio_socket (int domain, int type, int protocol);
+
+/**
+ * Connect a socket to a remote address.
+ *
+ * \param fd The file descriptor of the socket to connect.
+ * \param addr The address to connect to. In practice, this should be
+ * either a `struct sockaddr_in' or a `struct sockaddr_in6'.
+ * \param addrlen The size of the address structure passed by ADDR.
+ * \return Zero if the connect succeeds. -1 on error, and ERRNO should be set.
+ *
+ * Allowed ERRNO values:
+ * [EBADF] If FD is not a valid file descriptor.
+ * [ENOTSOCK] If FD is not a socket descriptor.
+ * [EADDRNOTAVAIL] If ADDR is not available for use to this process.
+ * [EAFNOSUPPORT] If the address family of ADDR is not supported.
+ * [EISCONN] If the socket is already connected.
+ * [ETIMEDOUT] If the connection could not be made in a reasonable
+ * amount of time.
+ * [ECONNREFUSED] If the connection attempt was rejected.
+ * [ENETUNREACH] If the network ADDR is on is unreachable.
+ * [EADDRINUSE] If the address is already in use.
+ * [EFAULT] If ADDR points outside the addressable space.
+ * [EINPROGRESS] If FD is in non-blocking mode, and the connection could
+ * not be completed immediately.
+ * [EALREADY] If FD is in non-blocking mode, and a connection attempt
+ * is still pending.
+ * [EACCESS] If ADDR is the broadcast address, and the socket option
+ * SO_BROADCAST is not set.
+ */
+CPNIO_EXPORT int cpnio_connect (int fd, const struct sockaddr *addr, socklen_t addrlen);
+
+/**
+ * Accept an incoming connection on a socket, returning a new socket for
+ * the connection, and storing the peer address in ADDR.
+ *
+ * \param fd The socket file descriptor.
+ * \param addr The structure to store the peer address in.
+ * \param addrlen The size of the data available in ADDR; upon return, the
+ * number of bytes stored in ADDR will be placed here.
+ * \return The new socket file descriptor, or -1 on error, and ERRNO set.
+ *
+ * Allowed ERRNO values:
+ * [EBADF] If FD is not a valid file descriptor.
+ * [ENOTSOCK] If FD in not a socket descriptor.
+ * [EOPNOTSUPP] If the socket is not a SOCK_STREAM socket.
+ * [EFAULT] If ADDR points outside the process's addressable space.
+ * [EWOULDBLOCK] If the socket is in non-blocking mode, and no connection
+ * attempt is currently ready.
+ * [EMFILE] If the process's descriptor table is full.
+ * [ENFILE] If the system's descriptor table is full.
+ */
+CPNIO_EXPORT int cpnio_accept (int fd, struct sockaddr *addr, socklen_t *addrlen);
+
+/**
+ * Send a datagram to the given address.
+ *
+ * \param fd The socket file descriptor.
+ * \param msg A pointer to the message to send.
+ * \param len The size of the message to send.
+ * \param flags Flags for sending.
+ * \param to The remote address to send the message to.
+ * \param tolen The size of the TO address structure.
+ * \return The number of bytes written, possibly zero, on success. Returns
+ * -1 on failure, and sets ERRNO.
+ * \see sendto(2)
+ *
+ * Allowed ERRNO values:
+ * [EBADF]
+ * [ENOTSOCK]
+ * [EFAULT]
+ * [EMSGSIZE]
+ * [EAGAIN]
+ * [ENOBUFS]
+ * [EACCES]
+ * [EHOSTUNREACH]
+ */
+CPNIO_EXPORT ssize_t cpnio_sendto (int fd, const void *msg, size_t len, int flags,
+ const struct sockaddr *to, socklen_t tolen);
+
+/**
+ * Receive a message on a socket, storing the remote host's address in
+ * FROM.
+ *
+ * \param fd The socket file descriptor.
+ * \param buf The buffer to store received bytes in.
+ * \param flags Flags to control the receive.
+ * \param from Where to store the remote address.
+ * \param fromlen Pointer to the size of FROM; on return, it will contain the
+ * size of the structure placed in FROM.
+ * \return The number of bytes received on success. -1 on error, and ERRNO will
+ * be set.
+ * \see recvfrom(2)
+ *
+ * Allewed ERRNO values:
+ * [EBADF] FD is not a valid file descriptor.
+ * [ENOTCONN] If the socket is stream-oriented, and no prior call to
+ * connect(2) was made.
+ * [ENOTSOCK] FD is not a socket.
+ * [EAGAIN] FD is in non-blocking mode, and no message was
+ * immediately available.
+ * [EINTR] The system call was interrupted by a signal.
+ * [EFAULT] BUF, FROM, or FROMLEN lie outside the process's address
+ * space.
+ */
+CPNIO_EXPORT ssize_t cpnio_recvfrom (int fd, void *buf, size_t len, int flags,
+ struct sockaddr *from, socklen_t *fromlen);
+
+
+/**
+ * Control file descriptor properties.
+ *
+ * \param fd The file descriptor to control.
+ * \param cmd The command to execute.
+ * \param arg The command argument.
+ * \return A value other than -1, specific to CMD. On error, -1 is
+ * returned, and ERRNO is set.
+ *
+ * Allowed ERRNO values:
+ * FIXME
+ */
+CPNIO_EXPORT int cpnio_fcntl (int fd, int cmd, long arg);
+
+
+/**
+ * Select from one of the given file descriptor sets a descriptor that
+ * is ready for the given operation (read, write, etc.).
+ *
+ * \param nfds A value one larger than the largest file
+ * descriptor.
+ * \param readfds A set of file descriptors to select for
+ * readability.
+ * \param writefds A set of file descriptors to select for
+ * writability.
+ * \param exceptfds A set of file descriptors to select for
+ * exceptional conditions.
+ * \param tm The selection timeout.
+ * \return The number of file descriptors selected, possibly zero, or
+ * -1 on error (and with ERRNO set).
+ */
+CPNIO_EXPORT int cpnio_select (int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *tm);
+
+/*
+ * We include the implementation file here, because our reference
+ * implementation is trivial, and the functions are declared extern
+ * inline.
+ *
+ * Implementations that need different implementations of these functions
+ * SHOULD remove this line, and compile javanio.c as a separate unit.
+ */
+#include "javanio.c"
+
+#endif /* __JAVANIO_H__ */
diff --git a/native/jni/native-lib/cpio.c b/native/jni/native-lib/cpio.c
index eb544dc83..4d23b7a1f 100644
--- a/native/jni/native-lib/cpio.c
+++ b/native/jni/native-lib/cpio.c
@@ -448,14 +448,28 @@ int cpio_closeDir (void *handle)
}
-int cpio_readDir (void *handle, const char **filename)
+int cpio_readDir (void *handle, char *filename)
{
+#ifdef HAVE_READDIR_R
+ struct dirent dent;
+#endif /* HAVE_READDIR_R */
struct dirent *dBuf;
+#ifdef HAVE_READDIR_R
+ readdir_r ((DIR *) handle, &dent, &dBuf);
+#else
dBuf = readdir((DIR *)handle);
+#endif /* HAVE_READDIR_R */
+
if (dBuf == NULL)
- return errno;
+ {
+ /* Some OS's (OS X) return NULL on end-of-dir, but
+ don't set errno to anything. */
+ if (errno == 0)
+ return ENOENT; /* Whatever. */
+ return errno;
+ }
- *filename = dBuf->d_name;
+ strncpy (filename, dBuf->d_name, FILENAME_MAX);
return 0;
}
diff --git a/native/jni/native-lib/cpio.h b/native/jni/native-lib/cpio.h
index 1776b199d..97483d294 100644
--- a/native/jni/native-lib/cpio.h
+++ b/native/jni/native-lib/cpio.h
@@ -79,6 +79,6 @@ JNIEXPORT int cpio_rename (const char *old_name, const char *new_name);
JNIEXPORT int cpio_openDir (const char *dirname, void **handle);
JNIEXPORT int cpio_closeDir (void *handle);
-JNIEXPORT int cpio_readDir (void *handle, const char **filename);
+JNIEXPORT int cpio_readDir (void *handle, char *filename);
#endif
diff --git a/native/jni/native-lib/cpnet.c b/native/jni/native-lib/cpnet.c
index c112ac2a7..85c4640e1 100644
--- a/native/jni/native-lib/cpnet.c
+++ b/native/jni/native-lib/cpnet.c
@@ -49,6 +49,7 @@ exception statement from your version. */
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
+#include <arpa/inet.h>
#include "cpnet.h"
@@ -597,8 +598,8 @@ jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***ad
struct hostent hret;
struct hostent *result;
jint buflen = 1024;
- int herr;
- int ret;
+ int herr = 0;
+ int ret = 0;
int counter = 0;
cpnet_address **addr_arr;
int i;
@@ -610,7 +611,13 @@ jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***ad
#ifdef HAVE_GETHOSTBYNAME_R
ret = gethostbyname_r (hostname, &hret, buf, buflen, &result, &herr);
#else
- ret = gethostbyname (hostname);
+ hret.h_addr_list = NULL;
+ hret.h_addrtype = 0;
+
+ result = gethostbyname (hostname);
+ if (result == NULL)
+ return -errno;
+ memcpy (&hret, result, sizeof (struct hostent));
#endif
if (ret != 0 || result == NULL)
{
@@ -709,6 +716,49 @@ jint cpnet_getHostByAddr (JNIEnv *env UNUSED, cpnet_address *addr, char *hostnam
return 0;
}
+jint cpnet_aton (JNIEnv *env, const char *hostname, cpnet_address **addr)
+{
+ jbyte *bytes = NULL;
+#ifdef HAVE_INET_PTON
+ jbyte inet6_addr[16];
+#endif
+
+#ifdef HAVE_INET_ATON
+ struct in_addr laddr;
+ if (inet_aton (hostname, &laddr))
+ {
+ bytes = (jbyte *) &laddr;
+ }
+#elif defined(HAVE_INET_ADDR)
+#if ! HAVE_IN_ADDR_T
+ typedef jint in_addr_t;
+#endif
+ in_addr_t laddr = inet_addr (hostname);
+ if (laddr != (in_addr_t)(-1))
+ {
+ bytes = (jbyte *) &laddr;
+ }
+#endif
+ if (bytes)
+ {
+ *addr = cpnet_newIPV4Address(env);
+ cpnet_bytesToIPV4Address(*addr, bytes);
+ return 0;
+ }
+
+#ifdef HAVE_INET_PTON
+ if (inet_pton (AF_INET6, hostname, inet6_addr) > 0)
+ {
+ *addr = cpnet_newIPV6Address(env);
+ cpnet_bytesToIPV6Address(*addr, inet6_addr);
+ return 0;
+ }
+#endif
+
+ *addr = NULL;
+ return 0;
+}
+
void cpnet_freeAddresses(JNIEnv * env, cpnet_address **addr, jint addresses_count)
{
jint i;
diff --git a/native/jni/native-lib/cpnet.h b/native/jni/native-lib/cpnet.h
index 0c7c215f8..3705c76ec 100644
--- a/native/jni/native-lib/cpnet.h
+++ b/native/jni/native-lib/cpnet.h
@@ -94,6 +94,7 @@ JNIEXPORT jint cpnet_getAvailableBytes (JNIEnv *env, jint fd, jint *availableByt
JNIEXPORT jint cpnet_getHostname (JNIEnv *env, char *hostname, jint hostname_len);
JNIEXPORT jint cpnet_getHostByName (JNIEnv *env, const char *hostname, cpnet_address ***adresses, jint *addresses_count);
JNIEXPORT jint cpnet_getHostByAddr (JNIEnv *env, cpnet_address *addr, char *hostname, jint hostname_len);
+JNIEXPORT jint cpnet_aton (JNIEnv *env, const char *hostname, cpnet_address **addr);
JNIEXPORT void cpnet_freeAddresses(JNIEnv * env, cpnet_address **addr, jint addresses_count);
static inline cpnet_address *cpnet_newIPV4Address(JNIEnv * env)
diff --git a/org/omg/CORBA/AnyHolder.java b/org/omg/CORBA/AnyHolder.java
index 10f828aab..c24855480 100644
--- a/org/omg/CORBA/AnyHolder.java
+++ b/org/omg/CORBA/AnyHolder.java
@@ -1,5 +1,5 @@
/* AnyHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -83,7 +83,7 @@ public final class AnyHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For {@link Any}, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_any}.
@@ -105,7 +105,7 @@ public final class AnyHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For {@link Any} the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_any(Any) }.
diff --git a/org/omg/CORBA/AnySeqHelper.java b/org/omg/CORBA/AnySeqHelper.java
index 8ebae7a19..d06e5b854 100644
--- a/org/omg/CORBA/AnySeqHelper.java
+++ b/org/omg/CORBA/AnySeqHelper.java
@@ -1,5 +1,5 @@
/* AnySeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/AnySeqHolder.java b/org/omg/CORBA/AnySeqHolder.java
index b18a1457b..0d21ed3bb 100644
--- a/org/omg/CORBA/AnySeqHolder.java
+++ b/org/omg/CORBA/AnySeqHolder.java
@@ -1,5 +1,5 @@
/* AnySeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -83,7 +83,7 @@ public final class AnySeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>and then all Any's.
*
@@ -109,7 +109,7 @@ public final class AnySeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code> and then all Any's.
*
diff --git a/org/omg/CORBA/BooleanHolder.java b/org/omg/CORBA/BooleanHolder.java
index 73cfeb296..a5b7bd8bc 100644
--- a/org/omg/CORBA/BooleanHolder.java
+++ b/org/omg/CORBA/BooleanHolder.java
@@ -1,5 +1,5 @@
/* BooleanHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,7 +91,7 @@ public final class BooleanHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>boolean</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_boolean}.
@@ -113,7 +113,7 @@ public final class BooleanHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>boolean</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_boolean(boolean) }.
diff --git a/org/omg/CORBA/BooleanSeqHelper.java b/org/omg/CORBA/BooleanSeqHelper.java
index 41f93d10d..3cb2538c3 100644
--- a/org/omg/CORBA/BooleanSeqHelper.java
+++ b/org/omg/CORBA/BooleanSeqHelper.java
@@ -1,5 +1,5 @@
/* BooleanSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/BooleanSeqHolder.java b/org/omg/CORBA/BooleanSeqHolder.java
index bdec3b792..6144a17d6 100644
--- a/org/omg/CORBA/BooleanSeqHolder.java
+++ b/org/omg/CORBA/BooleanSeqHolder.java
@@ -1,5 +1,5 @@
/* BooleanSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class BooleanSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_boolean_array }.
@@ -111,7 +111,7 @@ public final class BooleanSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_boolean_array }.
diff --git a/org/omg/CORBA/ByteHolder.java b/org/omg/CORBA/ByteHolder.java
index c440822e5..c590a433e 100644
--- a/org/omg/CORBA/ByteHolder.java
+++ b/org/omg/CORBA/ByteHolder.java
@@ -1,5 +1,5 @@
/* ByteHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,7 +91,7 @@ public final class ByteHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>octet</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_octet}.
@@ -113,7 +113,7 @@ public final class ByteHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>octet</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_octet(byte) }.
diff --git a/org/omg/CORBA/CharHolder.java b/org/omg/CORBA/CharHolder.java
index b8d0a3d6a..6ef5210a3 100644
--- a/org/omg/CORBA/CharHolder.java
+++ b/org/omg/CORBA/CharHolder.java
@@ -1,5 +1,5 @@
/* CharHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -90,7 +90,7 @@ public final class CharHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>char</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_char}.
@@ -112,7 +112,7 @@ public final class CharHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>char</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_char(char) }.
diff --git a/org/omg/CORBA/CharSeqHelper.java b/org/omg/CORBA/CharSeqHelper.java
index 08406058c..4853f3d16 100644
--- a/org/omg/CORBA/CharSeqHelper.java
+++ b/org/omg/CORBA/CharSeqHelper.java
@@ -1,5 +1,5 @@
/* CharSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/CharSeqHolder.java b/org/omg/CORBA/CharSeqHolder.java
index a60483b5f..3fa5475a0 100644
--- a/org/omg/CORBA/CharSeqHolder.java
+++ b/org/omg/CORBA/CharSeqHolder.java
@@ -1,5 +1,5 @@
/* CharSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class CharSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_char_array }.
@@ -111,7 +111,7 @@ public final class CharSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_char_array }.
diff --git a/org/omg/CORBA/Context.java b/org/omg/CORBA/Context.java
index e3f7363f4..01a7e9944 100644
--- a/org/omg/CORBA/Context.java
+++ b/org/omg/CORBA/Context.java
@@ -1,5 +1,5 @@
/* Context.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,7 +45,7 @@ package org.omg.CORBA;
* used to represent information about various circumstances of the
* invocation. A Context if first created by
* {@link org.omg.CORBA.ORB#get_default_context() } and then invoking
- * {@link create_child(String)} of the default context.
+ * {@link #create_child(String)} of the default context.
*
* The contexts are named.
*
@@ -66,7 +66,7 @@ public abstract class Context
/**
* Create a child of this Context, giving it a name.
- * @param name a name of the child context.
+ * @param child a name of the child context.
*
* @return the newly created context.
*/
diff --git a/org/omg/CORBA/CurrentHelper.java b/org/omg/CORBA/CurrentHelper.java
index f292449ec..36c5f1863 100644
--- a/org/omg/CORBA/CurrentHelper.java
+++ b/org/omg/CORBA/CurrentHelper.java
@@ -1,5 +1,5 @@
/* CurrentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,9 +42,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CORBA/CustomValue.java b/org/omg/CORBA/CustomValue.java
index 0e5809fd6..6814ab3c5 100644
--- a/org/omg/CORBA/CustomValue.java
+++ b/org/omg/CORBA/CustomValue.java
@@ -1,5 +1,5 @@
/* CustomValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.CORBA;
+import org.omg.CORBA.portable.StreamableValue;
import org.omg.CORBA.portable.ValueBase;
/**
@@ -50,7 +51,7 @@ import org.omg.CORBA.portable.ValueBase;
* in the receiving context.
*
* If the value base does not implement this interface, it normally implements
- * {@link org.omg.CORBA.portable.StremableValue} instead.
+ * {@link StreamableValue} instead.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/CORBA/DataOutputStream.java b/org/omg/CORBA/DataOutputStream.java
index 5e0f021fe..20f1afbe2 100644
--- a/org/omg/CORBA/DataOutputStream.java
+++ b/org/omg/CORBA/DataOutputStream.java
@@ -1,5 +1,5 @@
/* DataOutputStream.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -190,63 +190,63 @@ public interface DataOutputStream
/**
* Write array of Any's to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_any_array(Any[] seq, int offset, int length);
/**
* Write array of boolean's to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_boolean_array(boolean[] seq, int offset, int length);
/**
* Write array of narrow chars to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_char_array(char[] seq, int offset, int length);
/**
* Write array of wide chars to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_wchar_array(char[] seq, int offset, int length);
/**
* Write array of octets (bytes) to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_octet_array(byte[] seq, int offset, int length);
/**
* Write array of shorts (16 bit integers) to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_short_array(short[] seq, int offset, int length);
/**
* Write array of unsigned shorts (16 bit integers) to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_ushort_array(short[] seq, int offset, int length);
/**
* Write array of CORBA longs (java ints) to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_long_array(int[] seq, int offset, int length);
/**
* Write array of unsigned CORBA longs (java ints) to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_ulong_array(int[] seq, int offset, int length);
@@ -254,28 +254,28 @@ public interface DataOutputStream
* Write array of unsigned CORBA long longs (java longs)
* to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_ulonglong_array(long[] seq, int offset, int length);
/**
* Write arrayo fo CORBA long longs (java ints) to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_longlong_array(long[] seq, int offset, int length);
/**
* Write array of floats to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_float_array(float[] seq, int offset, int length);
/**
* Write array of doubles to the output stream.
*
- * @param value a value to write.
+ * @param seq a value to write.
*/
void write_double_array(double[] seq, int offset, int length);
} \ No newline at end of file
diff --git a/org/omg/CORBA/DefinitionKindHelper.java b/org/omg/CORBA/DefinitionKindHelper.java
index ef7e26725..05fe99287 100644
--- a/org/omg/CORBA/DefinitionKindHelper.java
+++ b/org/omg/CORBA/DefinitionKindHelper.java
@@ -1,5 +1,5 @@
/* DefinitionKindHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,10 +40,7 @@ package org.omg.CORBA;
import gnu.CORBA.DefinitionKindHolder;
import gnu.CORBA.OrbRestricted;
-import gnu.CORBA.gnuAny;
-import gnu.CORBA.typecodes.PrimitiveTypeCode;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/CORBA/DomainManagerOperations.java b/org/omg/CORBA/DomainManagerOperations.java
index 7dc0526a4..6bda64d76 100644
--- a/org/omg/CORBA/DomainManagerOperations.java
+++ b/org/omg/CORBA/DomainManagerOperations.java
@@ -1,5 +1,5 @@
/* DomainManagerOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,7 +41,7 @@ package org.omg.CORBA;
/**
* Provides the means to access the policies of the domain, with that
- * the implementing {@link DomainManage} is associated.
+ * the implementing {@link DomainManager} is associated.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/CORBA/DoubleHolder.java b/org/omg/CORBA/DoubleHolder.java
index 65c8ebaf5..23ec513f9 100644
--- a/org/omg/CORBA/DoubleHolder.java
+++ b/org/omg/CORBA/DoubleHolder.java
@@ -1,5 +1,5 @@
/* DoubleHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,7 +91,7 @@ public final class DoubleHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>double</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_double}.
@@ -113,7 +113,7 @@ public final class DoubleHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>double</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_double(double) }.
diff --git a/org/omg/CORBA/DoubleSeqHelper.java b/org/omg/CORBA/DoubleSeqHelper.java
index 2d9423fd0..6c971b7be 100644
--- a/org/omg/CORBA/DoubleSeqHelper.java
+++ b/org/omg/CORBA/DoubleSeqHelper.java
@@ -1,5 +1,5 @@
/* DoubleSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/DoubleSeqHolder.java b/org/omg/CORBA/DoubleSeqHolder.java
index 619e9215b..5d7fb1aed 100644
--- a/org/omg/CORBA/DoubleSeqHolder.java
+++ b/org/omg/CORBA/DoubleSeqHolder.java
@@ -1,5 +1,5 @@
/* DoubleSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class DoubleSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_double_array }.
@@ -111,7 +111,7 @@ public final class DoubleSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_double_array }.
diff --git a/org/omg/CORBA/DynAny.java b/org/omg/CORBA/DynAny.java
index 42b933419..edafe435a 100644
--- a/org/omg/CORBA/DynAny.java
+++ b/org/omg/CORBA/DynAny.java
@@ -1,5 +1,5 @@
/* DynAny.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -280,7 +280,7 @@ public interface DynAny
* Insert the {@link Any} value into the enclosed
* {@link Any} inside this DynAny.
*
- * @param a_x the value being inserted.
+ * @param an_any the value being inserted.
* @throws InvalidValue if the value type does not match the
* typecode of the enclosed {@link Any}.
*/
@@ -458,7 +458,7 @@ public interface DynAny
throws InvalidValue;
/**
- * Advances the internal pointer, described in the {@link current_component},
+ * Advances the internal pointer, described in the {@link #current_component},
* one position forward.
*
* @return true if the pointer now points to the new component,
@@ -468,13 +468,13 @@ public interface DynAny
boolean next();
/**
- * Moves the internal pointer, described in the {@link current_component},
+ * Moves the internal pointer, described in the {@link #current_component},
* to the first component.
*/
void rewind();
/**
- * Moves the internal pointer, described in the {@link current_component},
+ * Moves the internal pointer, described in the {@link #current_component},
* to the given position.
*
* @param p the number of the internal component on that the internal
diff --git a/org/omg/CORBA/DynSequence.java b/org/omg/CORBA/DynSequence.java
index be7556705..6a5c77c0b 100644
--- a/org/omg/CORBA/DynSequence.java
+++ b/org/omg/CORBA/DynSequence.java
@@ -1,5 +1,5 @@
/* DynSequence.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,7 +56,7 @@ public interface DynSequence
/**
* Returns the number of elements, stored in the sequence.
- * @return
+ * @return the length of the sequence
*/
int length();
diff --git a/org/omg/CORBA/DynValue.java b/org/omg/CORBA/DynValue.java
index 24d281246..5c67ffbbe 100644
--- a/org/omg/CORBA/DynValue.java
+++ b/org/omg/CORBA/DynValue.java
@@ -1,5 +1,5 @@
/* DynValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -72,7 +72,7 @@ public interface DynValue
/**
* Get all members of the enclosed value type object.
- * @return
+ * @return members, as an array of the name - value pairs.
*/
NameValuePair[] get_members();
diff --git a/org/omg/CORBA/DynamicImplementation.java b/org/omg/CORBA/DynamicImplementation.java
index 3b1b44319..24e6319fe 100644
--- a/org/omg/CORBA/DynamicImplementation.java
+++ b/org/omg/CORBA/DynamicImplementation.java
@@ -1,5 +1,5 @@
/* DynamicImplementation.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -61,7 +61,7 @@ public class DynamicImplementation
{
/**
* Invoke the method of the CORBA object. After converting the parameters,
- * this method delegates call to the {@link ObjectImpl#invoke}.
+ * this method delegates call to the {@link ObjectImpl#_invoke}.
*
* @deprecated since 1.4.
*
diff --git a/org/omg/CORBA/FieldNameHelper.java b/org/omg/CORBA/FieldNameHelper.java
index 6d6de43da..1f884d728 100644
--- a/org/omg/CORBA/FieldNameHelper.java
+++ b/org/omg/CORBA/FieldNameHelper.java
@@ -1,5 +1,5 @@
/* FieldNameHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,7 +55,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class FieldNameHelper
{
/**
- * Insert the FieldName into Any (uses {@link Any.insert_string}).
+ * Insert the FieldName into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -66,7 +66,7 @@ public abstract class FieldNameHelper
}
/**
- * Extract the FieldName from Any ((uses {@link Any.extract_string}).
+ * Extract the FieldName from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -104,7 +104,7 @@ public abstract class FieldNameHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param ostream the stream to write into.
* @param value the string (FieldName) value to write.
diff --git a/org/omg/CORBA/FixedHolder.java b/org/omg/CORBA/FixedHolder.java
index 8913acc17..a44cde52d 100644
--- a/org/omg/CORBA/FixedHolder.java
+++ b/org/omg/CORBA/FixedHolder.java
@@ -1,5 +1,5 @@
/* FixedHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,6 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.typecodes.FixedTypeCode;
-import gnu.CORBA.typecodes.PrimitiveTypeCode;
import java.math.BigDecimal;
@@ -88,7 +87,7 @@ public final class FixedHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>fixed</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_fixed}.
@@ -112,7 +111,7 @@ public final class FixedHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>fixed</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_fixed(BigDecimal) }.
diff --git a/org/omg/CORBA/FloatHolder.java b/org/omg/CORBA/FloatHolder.java
index 1d6de16a1..8d765ced3 100644
--- a/org/omg/CORBA/FloatHolder.java
+++ b/org/omg/CORBA/FloatHolder.java
@@ -1,5 +1,5 @@
/* FloatHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,7 +91,7 @@ public final class FloatHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>float</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_float}.
@@ -113,7 +113,7 @@ public final class FloatHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>float</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_float(float) }.
diff --git a/org/omg/CORBA/FloatSeqHelper.java b/org/omg/CORBA/FloatSeqHelper.java
index 1656dae44..10850e022 100644
--- a/org/omg/CORBA/FloatSeqHelper.java
+++ b/org/omg/CORBA/FloatSeqHelper.java
@@ -1,5 +1,5 @@
/* FloatSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/FloatSeqHolder.java b/org/omg/CORBA/FloatSeqHolder.java
index dbab1ec08..b7e8efcc0 100644
--- a/org/omg/CORBA/FloatSeqHolder.java
+++ b/org/omg/CORBA/FloatSeqHolder.java
@@ -1,5 +1,5 @@
/* FloatSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class FloatSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_float_array }.
@@ -111,7 +111,7 @@ public final class FloatSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_float_array }.
diff --git a/org/omg/CORBA/IdentifierHelper.java b/org/omg/CORBA/IdentifierHelper.java
index 5c055f812..deff90969 100644
--- a/org/omg/CORBA/IdentifierHelper.java
+++ b/org/omg/CORBA/IdentifierHelper.java
@@ -1,5 +1,5 @@
/* IdentifierHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,7 +55,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class IdentifierHelper
{
/**
- * Insert the Identifier into Any (uses {@link Any.insert_string}).
+ * Insert the Identifier into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -66,7 +66,7 @@ public abstract class IdentifierHelper
}
/**
- * Extract the Identifier from Any ((uses {@link Any.extract_string}).
+ * Extract the Identifier from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -104,7 +104,7 @@ public abstract class IdentifierHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param ostream the stream to write into.
* @param value the string (Identifier) value to write.
diff --git a/org/omg/CORBA/IntHolder.java b/org/omg/CORBA/IntHolder.java
index 4729535a7..a27cf435c 100644
--- a/org/omg/CORBA/IntHolder.java
+++ b/org/omg/CORBA/IntHolder.java
@@ -1,5 +1,5 @@
/* IntHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -90,7 +90,7 @@ public final class IntHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>long</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_long}.
@@ -112,7 +112,7 @@ public final class IntHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>long</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_long(int) }.
diff --git a/org/omg/CORBA/LocalObject.java b/org/omg/CORBA/LocalObject.java
index 7c06e1824..a3fd131ca 100644
--- a/org/omg/CORBA/LocalObject.java
+++ b/org/omg/CORBA/LocalObject.java
@@ -1,5 +1,5 @@
/* LocalObject.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -253,12 +253,12 @@ public class LocalObject
/**
* This method is called from <code>rmic</code> generated stubs if the
- * {@link Util#isLocal()}, called passing <code>this</code> as parameter,
+ * {@link Util#isLocal}, called passing <code>this</code> as parameter,
* returns true. If the method returns null, the requested method is then
* invoked on <code>this</code>. Else it is invoked on the returned object,
* casting it into the interface that the local object implements. In this
* case, the generated stub also later calls
- * {@link _servant_postinvoke(ServantObject)}, passing that returned target
+ * {@link #_servant_postinvoke(ServantObject)}, passing that returned target
* as parameter.
*
* @param operation the name of the method being invoked.
@@ -275,7 +275,7 @@ public class LocalObject
/**
* This method is called from <code>rmic</code> generated stubs if the
- * {@link Util#isLocal()}, called passing <code>this</code> as parameter,
+ * {@link Util#isLocal}, called passing <code>this</code> as parameter,
* returns true, and the {@link #_servant_preinvoke} return non-null object.
* The stub then invokes the requrested method on that returned object and
* later calls _servant_postinvoke, passing that returned target as parameter.
@@ -289,7 +289,7 @@ public class LocalObject
/**
* Invokes the operation. This method takes the OutputStream that was previously
- * returned by a {@link _request()} and returns an InputStream which
+ * returned by a {@link #_request(String)} and returns an InputStream which
* contains the reply. Up till jdk 1.5 inclusive this method is marked as
* unimplemented.
*
@@ -304,7 +304,7 @@ public class LocalObject
/**
* While it may look that this should return true, the jdk 1.5 API states
* that it must throw NO_IMPLEMENT instead. The rmi stubs do not call this
- * method to check if the object is local; they call {@link Util#isLocal()}
+ * method to check if the object is local; they call {@link Util#isLocal}
* instead (passing <code>this</code> as parameter).
*
* @return never.
diff --git a/org/omg/CORBA/LongHolder.java b/org/omg/CORBA/LongHolder.java
index ac249fed3..db412d969 100644
--- a/org/omg/CORBA/LongHolder.java
+++ b/org/omg/CORBA/LongHolder.java
@@ -1,5 +1,5 @@
/* LongHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,7 +91,7 @@ public final class LongHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>long long</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_longlong}.
@@ -113,7 +113,7 @@ public final class LongHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>long long</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_longlong(long) }.
diff --git a/org/omg/CORBA/LongLongSeqHelper.java b/org/omg/CORBA/LongLongSeqHelper.java
index 0e31c7136..1ba58d5d3 100644
--- a/org/omg/CORBA/LongLongSeqHelper.java
+++ b/org/omg/CORBA/LongLongSeqHelper.java
@@ -1,5 +1,5 @@
/* LongLongSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/LongLongSeqHolder.java b/org/omg/CORBA/LongLongSeqHolder.java
index e56acd4ad..ebb83cfd0 100644
--- a/org/omg/CORBA/LongLongSeqHolder.java
+++ b/org/omg/CORBA/LongLongSeqHolder.java
@@ -1,5 +1,5 @@
/* LongLongSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class LongLongSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_longlong_array }.
@@ -111,7 +111,7 @@ public final class LongLongSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_longlong_array }.
diff --git a/org/omg/CORBA/LongSeqHelper.java b/org/omg/CORBA/LongSeqHelper.java
index 26b4e91c2..c33611da8 100644
--- a/org/omg/CORBA/LongSeqHelper.java
+++ b/org/omg/CORBA/LongSeqHelper.java
@@ -1,5 +1,5 @@
/* LongSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/LongSeqHolder.java b/org/omg/CORBA/LongSeqHolder.java
index 2359eb0b2..79e94382d 100644
--- a/org/omg/CORBA/LongSeqHolder.java
+++ b/org/omg/CORBA/LongSeqHolder.java
@@ -1,5 +1,5 @@
/* LongSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,10 +87,10 @@ public final class LongSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>and then calls the
- * {@link org.omg.CORBA.portable.InputStream#input.read_long_array }.
+ * {@link org.omg.CORBA.portable.InputStream#read_long_array }.
*
* @param input the input stream to read from.
*/
@@ -102,10 +102,10 @@ public final class LongSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>and then calls the
- * {@link org.omg.CORBA.portable.OutputStream#input.write_long_array }.
+ * {@link org.omg.CORBA.portable.OutputStream#write_long_array }.
*
* @param output the output stream to write into.
*/
diff --git a/org/omg/CORBA/ORB.java b/org/omg/CORBA/ORB.java
index 1cf0e70a6..89bc53764 100644
--- a/org/omg/CORBA/ORB.java
+++ b/org/omg/CORBA/ORB.java
@@ -1,5 +1,5 @@
/* ORB.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,10 +41,8 @@ package org.omg.CORBA;
import gnu.CORBA.OrbFocused;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.OrbRestricted;
-import gnu.CORBA.gnuContext;
import gnu.CORBA.typecodes.FixedTypeCode;
import gnu.CORBA.typecodes.GeneralTypeCode;
-import gnu.CORBA.typecodes.PrimitiveTypeCode;
import gnu.CORBA.typecodes.RecordTypeCode;
import gnu.CORBA.typecodes.RecursiveTypeCode;
@@ -144,7 +142,7 @@ public abstract class ORB
{
/**
* By default, {@link #init(String[], Properties)} and
- * {@link #iinit(Applet, Properties)} return
+ * {@link #init(Applet, Properties)} return
* the built-in fully functional ORB is returned. If the
* <code>props</code> contains the property org.omg.CORBA.ORBClass,
* the value of this property is used as a class name to instantiate
diff --git a/org/omg/CORBA/ObjectHelper.java b/org/omg/CORBA/ObjectHelper.java
index f662a7888..dbf433080 100644
--- a/org/omg/CORBA/ObjectHelper.java
+++ b/org/omg/CORBA/ObjectHelper.java
@@ -1,5 +1,5 @@
/* ObjectHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,7 +40,6 @@ package org.omg.CORBA;
import gnu.CORBA.Minor;
import gnu.CORBA.OrbRestricted;
-import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/CORBA/ObjectHolder.java b/org/omg/CORBA/ObjectHolder.java
index f79a89bef..235f1e66f 100644
--- a/org/omg/CORBA/ObjectHolder.java
+++ b/org/omg/CORBA/ObjectHolder.java
@@ -1,5 +1,5 @@
/* ObjectHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package org.omg.CORBA;
-import gnu.CORBA.typecodes.PrimitiveTypeCode;
import gnu.CORBA.typecodes.RecordTypeCode;
import org.omg.CORBA.portable.InputStream;
@@ -98,10 +97,10 @@ public final class ObjectHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>org.omg.CORBA.Object</code>, the
* functionality is delegated to
- * {@link org.omg.CORBA.portable.InputStream#read_Object}.
+ * {@link org.omg.CORBA.portable.InputStream#read_Object()}.
*
* @param input the input stream to read from.
*/
@@ -120,7 +119,7 @@ public final class ObjectHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>Object</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_Object(Object) }.
diff --git a/org/omg/CORBA/OctetSeqHelper.java b/org/omg/CORBA/OctetSeqHelper.java
index df7b22ff5..e03dba073 100644
--- a/org/omg/CORBA/OctetSeqHelper.java
+++ b/org/omg/CORBA/OctetSeqHelper.java
@@ -1,5 +1,5 @@
/* OctetSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/OctetSeqHolder.java b/org/omg/CORBA/OctetSeqHolder.java
index 62ea73819..8c3e9cb6d 100644
--- a/org/omg/CORBA/OctetSeqHolder.java
+++ b/org/omg/CORBA/OctetSeqHolder.java
@@ -1,5 +1,5 @@
/* OctetSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class OctetSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_octet_array }.
@@ -111,7 +111,7 @@ public final class OctetSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_octet_array }.
diff --git a/org/omg/CORBA/PolicyErrorCodeHelper.java b/org/omg/CORBA/PolicyErrorCodeHelper.java
index 6feabdcfd..ecb9821dc 100644
--- a/org/omg/CORBA/PolicyErrorCodeHelper.java
+++ b/org/omg/CORBA/PolicyErrorCodeHelper.java
@@ -1,5 +1,5 @@
/* PolicyErrorCodeHelper.java --
-Copyright (C) 2005 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,7 +57,7 @@ public abstract class PolicyErrorCodeHelper
{
/**
- * Delegates call to {@link Any.extract_short()}.
+ * Delegates call to {@link Any#extract_short()}.
*/
public static short extract(Any a)
{
@@ -75,7 +75,7 @@ public abstract class PolicyErrorCodeHelper
}
/**
- * Delegates call to {@link Any.insert_short(short)}.
+ * Delegates call to {@link Any#insert_short(short)}.
*/
public static void insert(Any a, short that)
{
@@ -83,7 +83,7 @@ public abstract class PolicyErrorCodeHelper
}
/**
- * Delegates call to {@link InputStream.read_short()}.
+ * Delegates call to {@link InputStream#read_short()}.
*/
public static short read(InputStream istream)
{
@@ -106,7 +106,7 @@ public abstract class PolicyErrorCodeHelper
}
/**
- * Delegates call to {@link OutputStream#write_short()}.
+ * Delegates call to {@link OutputStream#write_short(short)}.
*/
public static void write(OutputStream ostream, short value)
{
diff --git a/org/omg/CORBA/PolicyErrorHelper.java b/org/omg/CORBA/PolicyErrorHelper.java
index 27b5b465e..213acafc7 100644
--- a/org/omg/CORBA/PolicyErrorHelper.java
+++ b/org/omg/CORBA/PolicyErrorHelper.java
@@ -1,5 +1,5 @@
/* PolicyErrorHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -59,8 +59,8 @@ public abstract class PolicyErrorHelper
{
/**
* Create the PolicyError typecode. The typecode defines a structure, named
- * "PolicyError", containing the {@link PolicyErrorCode} (alias int) field,
- * named "reason".
+ * "PolicyError", containing the PolicyErrorCode (alias int, see
+ * {@link PolicyErrorCodeHelper}) field, named "reason".
*/
public static TypeCode type()
{
diff --git a/org/omg/CORBA/PolicyHelper.java b/org/omg/CORBA/PolicyHelper.java
index 53b56244e..4f88cd783 100644
--- a/org/omg/CORBA/PolicyHelper.java
+++ b/org/omg/CORBA/PolicyHelper.java
@@ -1,5 +1,5 @@
/* PolicyHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,9 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CORBA/PolicyListHelper.java b/org/omg/CORBA/PolicyListHelper.java
index da0135c02..54f203675 100644
--- a/org/omg/CORBA/PolicyListHelper.java
+++ b/org/omg/CORBA/PolicyListHelper.java
@@ -1,5 +1,5 @@
/* PolicyListHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,27 +41,19 @@ package org.omg.CORBA;
import gnu.CORBA.Minor;
import gnu.CORBA.OrbRestricted;
-import org.omg.CORBA.Any;
-import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
-import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
-import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.OutputStream;
/**
* The helper operations for the
-* CORBA object {@link Policy[]}.
+* CORBA object {@link Policy}[].
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class PolicyListHelper
{
/**
- * Get the type code of the {@link Policy[]}.
+ * Get the type code of the {@link Policy}[].
*/
public static TypeCode type()
{
diff --git a/org/omg/CORBA/PolicyTypeHelper.java b/org/omg/CORBA/PolicyTypeHelper.java
index 7d5f9bf76..575fe4aa3 100644
--- a/org/omg/CORBA/PolicyTypeHelper.java
+++ b/org/omg/CORBA/PolicyTypeHelper.java
@@ -1,5 +1,5 @@
/* PolicyTypeHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CORBA/PrincipalHolder.java b/org/omg/CORBA/PrincipalHolder.java
index 270427f3f..56cd565aa 100644
--- a/org/omg/CORBA/PrincipalHolder.java
+++ b/org/omg/CORBA/PrincipalHolder.java
@@ -1,5 +1,5 @@
/* PrincipalHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -86,7 +86,7 @@ public final class PrincipalHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For {@link Principal}, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_Principal}.
@@ -108,7 +108,7 @@ public final class PrincipalHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For {@link Principal} the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_Principal(Principal)}
diff --git a/org/omg/CORBA/RepositoryIdHelper.java b/org/omg/CORBA/RepositoryIdHelper.java
index a392002fd..033a96819 100644
--- a/org/omg/CORBA/RepositoryIdHelper.java
+++ b/org/omg/CORBA/RepositoryIdHelper.java
@@ -1,5 +1,5 @@
/* RepositoryIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,7 +55,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class RepositoryIdHelper
{
/**
- * Insert the Repository Id into Any (uses {@link Any.insert_string}).
+ * Insert the Repository Id into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -66,7 +66,7 @@ public abstract class RepositoryIdHelper
}
/**
- * Extract the Repository Id from Any ((uses {@link Any.extract_string}).
+ * Extract the Repository Id from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -104,7 +104,7 @@ public abstract class RepositoryIdHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param ostream the stream to write into.
* @param value the string (Repository Id) value to write.
diff --git a/org/omg/CORBA/Request.java b/org/omg/CORBA/Request.java
index f299d426b..beec78691 100644
--- a/org/omg/CORBA/Request.java
+++ b/org/omg/CORBA/Request.java
@@ -1,5 +1,5 @@
/* Request.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -137,7 +137,7 @@ public abstract class Request
public abstract ContextList contexts();
/**
- * Get the context, previously set using {@link #cts(Context)}.
+ * Get the context, previously set using {@link #ctx(Context)}.
* The context contains the details about this request.
*/
public abstract Context ctx();
@@ -168,7 +168,7 @@ public abstract class Request
/**
* Allow to access the response that has been previously sent using
- * {@link send_deferred()}.
+ * {@link #send_deferred()}.
*
* @throws WrongTransaction if the transaction scope mismatches.
*/
@@ -190,7 +190,7 @@ public abstract class Request
/**
* Check if the response is received to the request that was
- * previously send using {@link send_deferred()}.
+ * previously send using {@link #send_deferred()}.
*
* @return true if the response has been already received, false otherwise.
*/
diff --git a/org/omg/CORBA/ShortHolder.java b/org/omg/CORBA/ShortHolder.java
index dfc4721f3..59bd4cf33 100644
--- a/org/omg/CORBA/ShortHolder.java
+++ b/org/omg/CORBA/ShortHolder.java
@@ -1,5 +1,5 @@
/* ShortHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -91,7 +91,7 @@ public final class ShortHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. For <code>short</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.InputStream#read_short}.
@@ -113,7 +113,7 @@ public final class ShortHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* For <code>short</code>, the functionality
* is delegated to
* {@link org.omg.CORBA.portable.OutputStream#write_short(short) }.
diff --git a/org/omg/CORBA/ShortSeqHelper.java b/org/omg/CORBA/ShortSeqHelper.java
index 40124f216..5140bb966 100644
--- a/org/omg/CORBA/ShortSeqHelper.java
+++ b/org/omg/CORBA/ShortSeqHelper.java
@@ -1,5 +1,5 @@
/* ShortSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/ShortSeqHolder.java b/org/omg/CORBA/ShortSeqHolder.java
index 246d1ecf4..b25024e98 100644
--- a/org/omg/CORBA/ShortSeqHolder.java
+++ b/org/omg/CORBA/ShortSeqHolder.java
@@ -1,5 +1,5 @@
/* ShortSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class ShortSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_short_array }.
@@ -111,7 +111,7 @@ public final class ShortSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_short_array }.
diff --git a/org/omg/CORBA/StringSeqHelper.java b/org/omg/CORBA/StringSeqHelper.java
index 4225c0bd1..19f27292c 100644
--- a/org/omg/CORBA/StringSeqHelper.java
+++ b/org/omg/CORBA/StringSeqHelper.java
@@ -1,5 +1,5 @@
/* StringSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/StringSeqHolder.java b/org/omg/CORBA/StringSeqHolder.java
index 71ac887e2..1bc3281d3 100755
--- a/org/omg/CORBA/StringSeqHolder.java
+++ b/org/omg/CORBA/StringSeqHolder.java
@@ -1,5 +1,5 @@
/* StringSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class StringSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>and then all strings.
*
@@ -113,7 +113,7 @@ public final class StringSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code> and then all strings.
*
diff --git a/org/omg/CORBA/ULongLongSeqHelper.java b/org/omg/CORBA/ULongLongSeqHelper.java
index 1148cb408..b13f33cdf 100644
--- a/org/omg/CORBA/ULongLongSeqHelper.java
+++ b/org/omg/CORBA/ULongLongSeqHelper.java
@@ -1,5 +1,5 @@
/* ULongLongSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/ULongLongSeqHolder.java b/org/omg/CORBA/ULongLongSeqHolder.java
index 70b43bf7f..cd9c02310 100644
--- a/org/omg/CORBA/ULongLongSeqHolder.java
+++ b/org/omg/CORBA/ULongLongSeqHolder.java
@@ -1,5 +1,5 @@
/* ULongLongSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class ULongLongSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_ulonglong_array }.
@@ -111,7 +111,7 @@ public final class ULongLongSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_ulonglong_array }.
diff --git a/org/omg/CORBA/ULongSeqHelper.java b/org/omg/CORBA/ULongSeqHelper.java
index dddc1323d..186350b2c 100644
--- a/org/omg/CORBA/ULongSeqHelper.java
+++ b/org/omg/CORBA/ULongSeqHelper.java
@@ -1,5 +1,5 @@
/* ULongSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/ULongSeqHolder.java b/org/omg/CORBA/ULongSeqHolder.java
index 64d9db6ce..35d9a4384 100644
--- a/org/omg/CORBA/ULongSeqHolder.java
+++ b/org/omg/CORBA/ULongSeqHolder.java
@@ -1,5 +1,5 @@
/* ULongSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class ULongSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_ulong_array }.
@@ -111,7 +111,7 @@ public final class ULongSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_ulong_array }.
diff --git a/org/omg/CORBA/UShortSeqHelper.java b/org/omg/CORBA/UShortSeqHelper.java
index d1fc440a9..0fcd4739f 100644
--- a/org/omg/CORBA/UShortSeqHelper.java
+++ b/org/omg/CORBA/UShortSeqHelper.java
@@ -1,5 +1,5 @@
/* UShortSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/UShortSeqHolder.java b/org/omg/CORBA/UShortSeqHolder.java
index 47e33b9be..3eb83c524 100644
--- a/org/omg/CORBA/UShortSeqHolder.java
+++ b/org/omg/CORBA/UShortSeqHolder.java
@@ -1,5 +1,5 @@
/* UShortSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class UShortSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.InputStream#read_ushort_array }.
@@ -111,7 +111,7 @@ public final class UShortSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
* {@link org.omg.CORBA.portable.OutputStream#write_ushort_array }.
diff --git a/org/omg/CORBA/ValueBaseHelper.java b/org/omg/CORBA/ValueBaseHelper.java
index 1699d912d..644666971 100644
--- a/org/omg/CORBA/ValueBaseHelper.java
+++ b/org/omg/CORBA/ValueBaseHelper.java
@@ -1,5 +1,5 @@
/* ValueBaseHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,9 @@ import gnu.CORBA.typecodes.RecordTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ValueBase;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
@@ -105,7 +107,7 @@ public abstract class ValueBaseHelper
/**
* Get the typecode of the value type.
- * @return
+ * @return the typecode of the value type
*/
public static TypeCode type()
{
diff --git a/org/omg/CORBA/ValueBaseHolder.java b/org/omg/CORBA/ValueBaseHolder.java
index 6f57d17c3..58f48536f 100644
--- a/org/omg/CORBA/ValueBaseHolder.java
+++ b/org/omg/CORBA/ValueBaseHolder.java
@@ -1,5 +1,5 @@
/* ValueBaseHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.CORBA;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
+import org.omg.CORBA.portable.ValueBase;
import java.io.Serializable;
diff --git a/org/omg/CORBA/VersionSpecHelper.java b/org/omg/CORBA/VersionSpecHelper.java
index 984570298..74bdb7b7a 100644
--- a/org/omg/CORBA/VersionSpecHelper.java
+++ b/org/omg/CORBA/VersionSpecHelper.java
@@ -1,5 +1,5 @@
/* VersionSpecHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,7 +55,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class VersionSpecHelper
{
/**
- * Insert the VersionSpec into Any (uses {@link Any.insert_string}).
+ * Insert the VersionSpec into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -66,7 +66,7 @@ public abstract class VersionSpecHelper
}
/**
- * Extract the VersionSpec from Any ((uses {@link Any.extract_string}).
+ * Extract the VersionSpec from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -104,7 +104,7 @@ public abstract class VersionSpecHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param ostream the stream to write into.
* @param value the string (VersionSpec) value to write.
diff --git a/org/omg/CORBA/WCharSeqHelper.java b/org/omg/CORBA/WCharSeqHelper.java
index 4bb92989d..fe4d41650 100644
--- a/org/omg/CORBA/WCharSeqHelper.java
+++ b/org/omg/CORBA/WCharSeqHelper.java
@@ -1,5 +1,5 @@
/* WCharSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/WCharSeqHolder.java b/org/omg/CORBA/WCharSeqHolder.java
index 72a9cc8c1..a1b04d1ef 100644
--- a/org/omg/CORBA/WCharSeqHolder.java
+++ b/org/omg/CORBA/WCharSeqHolder.java
@@ -1,5 +1,5 @@
/* WCharSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,10 +87,10 @@ public final class WCharSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>) and then calls the
- * {@link org.omg.CORBA.portable.InputStream#input.read_wchar_array }.
+ * {@link org.omg.CORBA.portable.InputStream#read_wchar_array }.
*
* @param input the input stream to read from.
*/
@@ -111,10 +111,10 @@ public final class WCharSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code>) and then calls the
- * {@link org.omg.CORBA.portable.OutputStream#input.write_wchar_array }.
+ * {@link org.omg.CORBA.portable.OutputStream#write_wchar_array }.
*
* @param output the output stream to write into.
*/
diff --git a/org/omg/CORBA/WStringSeqHelper.java b/org/omg/CORBA/WStringSeqHelper.java
index 356cf0dd2..ea8eac627 100644
--- a/org/omg/CORBA/WStringSeqHelper.java
+++ b/org/omg/CORBA/WStringSeqHelper.java
@@ -1,5 +1,5 @@
/* WStringSeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,6 +43,7 @@ import gnu.CORBA.typecodes.ArrayTypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
/**
* Provides static helper methods for working with
diff --git a/org/omg/CORBA/WStringSeqHolder.java b/org/omg/CORBA/WStringSeqHolder.java
index 68b77ff6a..b909210f3 100755
--- a/org/omg/CORBA/WStringSeqHolder.java
+++ b/org/omg/CORBA/WStringSeqHolder.java
@@ -1,5 +1,5 @@
/* WStringSeqHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -87,7 +87,7 @@ public final class WStringSeqHolder
}
/**
- * Fill in the {@link value } field by reading the required data
+ * Fill in the {@link #value } field by reading the required data
* from the given stream. This method first reads the array size
* (as CORBA <code>long</code>and then all strings.
*
@@ -113,7 +113,7 @@ public final class WStringSeqHolder
}
/**
- * Write the {@link value } field to the given stream.
+ * Write the {@link #value } field to the given stream.
* This method first writes the array size
* (as CORBA <code>long</code> and then all strings.
*
diff --git a/org/omg/CORBA/WrongTransactionHelper.java b/org/omg/CORBA/WrongTransactionHelper.java
index 27368a4c0..96673fd57 100644
--- a/org/omg/CORBA/WrongTransactionHelper.java
+++ b/org/omg/CORBA/WrongTransactionHelper.java
@@ -1,5 +1,5 @@
/* WrongTransactionHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/CORBA/_IDLTypeStub.java b/org/omg/CORBA/_IDLTypeStub.java
index 6661b0c47..de09b89a7 100644
--- a/org/omg/CORBA/_IDLTypeStub.java
+++ b/org/omg/CORBA/_IDLTypeStub.java
@@ -1,5 +1,5 @@
/* _IDLTypeStub.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
diff --git a/org/omg/CORBA/_PolicyStub.java b/org/omg/CORBA/_PolicyStub.java
index 50481fe17..f633ccbaf 100644
--- a/org/omg/CORBA/_PolicyStub.java
+++ b/org/omg/CORBA/_PolicyStub.java
@@ -1,5 +1,5 @@
/* _PolicyStub.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,8 +39,6 @@ exception statement from your version. */
package org.omg.CORBA;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.ObjectHelper;
import org.omg.CORBA.portable.ApplicationException;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CORBA/portable/BoxedValueHelper.java b/org/omg/CORBA/portable/BoxedValueHelper.java
index cc2afe2df..47c2b9106 100644
--- a/org/omg/CORBA/portable/BoxedValueHelper.java
+++ b/org/omg/CORBA/portable/BoxedValueHelper.java
@@ -1,5 +1,5 @@
/* BoxedValueHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,7 +63,7 @@ public interface BoxedValueHelper
/**
* Read this value type from the CDR stream.
*
- * @param is a stream to read from.
+ * @param istream is a stream to read from.
*
* @return a loaded value type.
*/
@@ -72,7 +72,7 @@ public interface BoxedValueHelper
/**
* Write this value type to the CDR stream.
*
- * @param os a stream to write to.
+ * @param ostream a stream to write to.
* @param value a value to write.
*/
void write_value(OutputStream ostream, Serializable value);
diff --git a/org/omg/CORBA/portable/Delegate.java b/org/omg/CORBA/portable/Delegate.java
index fce04887e..2f056ac31 100644
--- a/org/omg/CORBA/portable/Delegate.java
+++ b/org/omg/CORBA/portable/Delegate.java
@@ -1,5 +1,5 @@
/* Delegate.java --
-Copyright (C) 2005 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -242,7 +242,7 @@ public abstract class Delegate
/**
* Return the hashcode for this CORBA object. The default implementation
- * delegates call to {@link #hash(int)}, passing Integer.MAX_VALUE as an
+ * delegates call to {@link #hash(org.omg.CORBA.Object, int)}, passing Integer.MAX_VALUE as an
* argument.
*
* @param target the object, for that the hash code must be computed.
@@ -408,7 +408,7 @@ public abstract class Delegate
*
* @param self the CORBA object, to that the string representation must be
* returned. By default, the call is delegated to
- * {@link java.lang.Object.toString()}.
+ * {@link java.lang.Object#toString()}.
*
* @return the string representation.
*/
diff --git a/org/omg/CORBA/portable/ObjectImpl.java b/org/omg/CORBA/portable/ObjectImpl.java
index f2f21a79e..f1e348e53 100644
--- a/org/omg/CORBA/portable/ObjectImpl.java
+++ b/org/omg/CORBA/portable/ObjectImpl.java
@@ -1,5 +1,5 @@
/* ObjectImpl.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package org.omg.CORBA.portable;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
import org.omg.CORBA.DomainManager;
@@ -156,9 +157,9 @@ public abstract class ObjectImpl
* @throws BAD_PARAM if the policy of the given type is not
* associated with this object, or if it is not supported by this ORB.
*/
- public Policy _get_policy(int type)
+ public Policy _get_policy(int a_policy_type)
{
- return delegate.get_policy(this, type);
+ return delegate.get_policy(this, a_policy_type);
}
/**
@@ -173,7 +174,7 @@ public abstract class ObjectImpl
* object. The returned value must not change during the object
* lifetime.
*
- * @param maximum the maximal value to return.
+ * @param max the maximal value to return.
*
* @return the hashcode.
*/
@@ -204,7 +205,7 @@ public abstract class ObjectImpl
/**
* Check if this object can be referenced by the given repository id.
*
- * @param repositoryIdentifer the repository id.
+ * @param idl_id the repository id.
*
* @return true if the passed parameter is a repository id of this
* CORBA object.
@@ -233,8 +234,6 @@ public abstract class ObjectImpl
/**
* Returns true if the object is local.
*
- * @param self the object to check.
- *
* @return false, always (following 1.4 specs). Override to get
* functionality.
*/
@@ -278,10 +277,8 @@ public abstract class ObjectImpl
* Release the reply stream back to ORB after finishing reading the data
* from it.
*
- * @param input the stream, normally returned by {@link #invoke} or
+ * @param stream the stream, normally returned by {@link #_invoke} or
* {@link ApplicationException#getInputStream()}, can be null.
- *
- * @throws NO_IMPLEMENT, always (following the 1.4 specification).
*/
public void _releaseReply(InputStream stream)
{
@@ -292,7 +289,7 @@ public abstract class ObjectImpl
/**
* Create a request to invoke the method of this CORBA object.
*
- * @param operation the name of the method to invoke.
+ * @param method the name of the method to invoke.
*
* @return the request.
*/
@@ -304,7 +301,7 @@ public abstract class ObjectImpl
/**
* Create a request to invoke the method of this CORBA object.
*
- * @param operation the name of the method to invoke.
+ * @param method the name of the method to invoke.
* @param response_expected specifies if this is one way message or the
* response to the message is expected.
*
@@ -323,7 +320,6 @@ public abstract class ObjectImpl
*
* The default method returns without action.
*
- * @param self the object.
* @param servant the servant.
*/
public void _servant_postinvoke(ServantObject servant)
@@ -336,9 +332,8 @@ public abstract class ObjectImpl
* The servant can also be casted to the expected type, calling the
* required method directly.
*
- * @param self the object
- * @param operation the operation
- * @param expectedType the expected type of the servant.
+ * @param method the operation
+ * @param expected_type the expected type of the servant.
*
* This implementation always returns null; override for different
* behavior.
@@ -372,10 +367,10 @@ public abstract class ObjectImpl
* them.
*/
public org.omg.CORBA.Object _set_policy_override(Policy[] policies,
- SetOverrideType set_add
+ SetOverrideType how
)
{
- return delegate.set_policy_override(this, policies, set_add);
+ return delegate.set_policy_override(this, policies, how);
}
/**
diff --git a/org/omg/CORBA/portable/ServantObject.java b/org/omg/CORBA/portable/ServantObject.java
index b35dedc35..253defc0a 100644
--- a/org/omg/CORBA/portable/ServantObject.java
+++ b/org/omg/CORBA/portable/ServantObject.java
@@ -1,5 +1,5 @@
/* ServantObject.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ package org.omg.CORBA.portable;
*
* @see ObjectImpl#_servant_preinvoke(String, Class)
* @see ObjectImpl#_servant_postinvoke(ServantObject)
- * @see Delegate#servant_preinvoke(org.omg.CORBA.Object, String operation, Class)
+ * @see Delegate#servant_preinvoke(org.omg.CORBA.Object, String, Class)
* @see Delegate#servant_postinvoke(org.omg.CORBA.Object, ServantObject)
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
diff --git a/org/omg/CORBA/portable/StreamableValue.java b/org/omg/CORBA/portable/StreamableValue.java
index ce9b2ca28..7ab61a6d4 100644
--- a/org/omg/CORBA/portable/StreamableValue.java
+++ b/org/omg/CORBA/portable/StreamableValue.java
@@ -1,5 +1,5 @@
/* StreamableValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ import java.io.Serializable;
* If the value type does not provide the user defined methods for reading
* and writing its content, it must implement this interface for reading
* and writing the content in a default way. This is done by implementing
- * the {@link Streamable#read} and {@link Streamable#write}. IDL compiler
+ * the {@link Streamable#_read} and {@link Streamable#_write}. IDL compiler
* should generate the implementation of this interface automatically.
*
* @see CustomValue for specifying the user-defined io methods.
diff --git a/org/omg/CORBA_2_3/ORB.java b/org/omg/CORBA_2_3/ORB.java
index 82660fea7..0895b8037 100644
--- a/org/omg/CORBA_2_3/ORB.java
+++ b/org/omg/CORBA_2_3/ORB.java
@@ -1,5 +1,5 @@
/* ORB.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,12 +38,14 @@ exception statement from your version. */
package org.omg.CORBA_2_3;
+import javax.rmi.CORBA.Tie;
+
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.portable.ValueFactory;
/**
- * This class should provide the {@link org.omg.CORBA.ORB) ORB extensions,
+ * This class should provide the {@link org.omg.CORBA.ORB}) ORB extensions,
* defined in the OMG CORBA version 2.3 specification. However in the
* Sun's API specification is written that this functionality is not
* implemented at least at least till 1.4 inclusive.
@@ -93,10 +95,9 @@ public abstract class ORB
*
* @param repository_id a repository id
*
- * @return never
* @throws NO_IMPLEMENT, always.
*/
- public void unregister_value_factory(String id)
+ public void unregister_value_factory(String repository_id)
{
throw new NO_IMPLEMENT();
}
@@ -117,7 +118,7 @@ public abstract class ORB
}
/**
- * This method is called by RMI-IIOP {@link javax.rmi.Tie#orb(ORB)},
+ * This method is called by RMI-IIOP {@link Tie#orb(ORB)},
* passing <code>this</code> as parameter. The ORB will try to connect
* that tie as one of its objects.
*/
diff --git a/org/omg/CORBA_2_3/portable/InputStream.java b/org/omg/CORBA_2_3/portable/InputStream.java
index 23055ef2d..349590eed 100644
--- a/org/omg/CORBA_2_3/portable/InputStream.java
+++ b/org/omg/CORBA_2_3/portable/InputStream.java
@@ -1,5 +1,5 @@
/* InputStream.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -72,7 +72,7 @@ public abstract class InputStream
*
* As specified in OMG specification, this reads a single
* boolean and then delegates either to {@link #read_Object()} (for false)
- * or to {@link #read_Value()} (for true).
+ * or to {@link #read_value()} (for true).
*
* @return an abstract interface, unmarshaled from the stream.
*/
@@ -93,7 +93,7 @@ public abstract class InputStream
*
* As specified in OMG specification, this reads a single
* boolean and then delegates either to {@link #read_Object(Class)} (for false)
- * or to {@link #read_Value(Class)} (for true).
+ * or to {@link #read_value(Class)} (for true).
*
* @param clz a base class for the abstract interface.
*
@@ -125,8 +125,6 @@ public abstract class InputStream
* {@link #read_value(Class)} or {@link #read_value(Serializable)}
* instead.
*
- * @param repository_id a repository id of the value type.
- *
* @return an value type structure, unmarshaled from the stream
*/
public Serializable read_value()
diff --git a/org/omg/CORBA_2_3/portable/OutputStream.java b/org/omg/CORBA_2_3/portable/OutputStream.java
index 70f9a4913..f1369f782 100644
--- a/org/omg/CORBA_2_3/portable/OutputStream.java
+++ b/org/omg/CORBA_2_3/portable/OutputStream.java
@@ -1,5 +1,5 @@
/* OutputStream.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,8 @@ package org.omg.CORBA_2_3.portable;
import gnu.CORBA.CDR.Vio;
import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.CustomValue;
+import org.omg.CORBA.portable.StreamableValue;
import org.omg.CORBA.portable.ValueBase;
import java.io.Serializable;
@@ -92,7 +94,7 @@ public abstract class OutputStream
* Writes a value type into the output stream.
*
* The value type must implement either {@link CustomValue} (for user-defined
- * writing method) or {@link StramableValue} (for standard writing using code,
+ * writing method) or {@link StreamableValue} (for standard writing using code,
* generated by IDL compiler).
*
* The written record will have a repository id, matching the class of the
@@ -109,7 +111,7 @@ public abstract class OutputStream
* Write value to the stream using the boxed value helper.
*
* The value type must implement either {@link CustomValue}
- * (for user-defined writing method) or {@link StramableValue}
+ * (for user-defined writing method) or {@link StreamableValue}
* (for standard writing using code, generated by IDL compiler).
*
* @param value a value to write.
@@ -129,7 +131,7 @@ public abstract class OutputStream
* writing two Id inheritance hierarchy.
*
* The value type must implement either {@link CustomValue}
- * (for user-defined writing method) or {@link StramableValue}
+ * (for user-defined writing method) or {@link StreamableValue}
* (for standard writing using code, generated by IDL compiler).
*
* @param value a value type object to write.
@@ -144,7 +146,7 @@ public abstract class OutputStream
* repository id.
*
* The value type must implement either {@link CustomValue} (for user-defined
- * writing method) or {@link StramableValue} (for standard writing using code,
+ * writing method) or {@link StreamableValue} (for standard writing using code,
* generated by IDL compiler).
*
* @param repository_id a repository id of the value type.
diff --git a/org/omg/CosNaming/BindingIteratorHelper.java b/org/omg/CosNaming/BindingIteratorHelper.java
index cb17d5748..5430905e5 100644
--- a/org/omg/CosNaming/BindingIteratorHelper.java
+++ b/org/omg/CosNaming/BindingIteratorHelper.java
@@ -1,5 +1,5 @@
/* BindingIteratorHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
@@ -126,15 +125,13 @@ public abstract class BindingIteratorHelper
* performed to verify that the object actually supports the requested type.
* The {@link BAD_OPERATION} will be thrown if unsupported operations are
* invoked on the new returned reference, but no failure is expected at the
- * time of the unchecked_narrow.
+ * time of the unchecked_narrow. See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted binding iterator.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static BindingIterator unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/CosNaming/BindingType.java b/org/omg/CosNaming/BindingType.java
index d78990349..480e7bb33 100644
--- a/org/omg/CosNaming/BindingType.java
+++ b/org/omg/CosNaming/BindingType.java
@@ -1,5 +1,5 @@
/* BindingType.java --
- 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 @@ public class BindingType
/**
* This constant means that the binding has been created by the
- * means, different from the listed in {@link _ncontext} description.
+ * means, different from the listed in {@link #_ncontext} description.
*/
public static final int _nobject = 0;
@@ -75,7 +75,7 @@ public class BindingType
/**
* This constant means that the binding has been created by the
- * means, different from the listed in {@link _ncontext} description.
+ * means, different from the listed in {@link #_ncontext} description.
*/
public static final BindingType nobject = new BindingType(_nobject);
@@ -101,7 +101,7 @@ public class BindingType
* @param value the binding type code.
* @return the matching binding type instance.
*
- * @throws BAD_KIND if there is no matching binding type for
+ * @throws BAD_PARAM if there is no matching binding type for
* the passed value.
*/
public static BindingType from_int(int value)
diff --git a/org/omg/CosNaming/BindingTypeHelper.java b/org/omg/CosNaming/BindingTypeHelper.java
index 8f456ee70..542f3e0e9 100644
--- a/org/omg/CosNaming/BindingTypeHelper.java
+++ b/org/omg/CosNaming/BindingTypeHelper.java
@@ -1,5 +1,5 @@
/* BindingTypeHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/CosNaming/IstringHelper.java b/org/omg/CosNaming/IstringHelper.java
index b90b452e6..df680f436 100644
--- a/org/omg/CosNaming/IstringHelper.java
+++ b/org/omg/CosNaming/IstringHelper.java
@@ -1,5 +1,5 @@
/* IstringHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -59,7 +59,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class IstringHelper
{
/**
- * Insert the IString into Any (uses {@link Any.insert_string}).
+ * Insert the IString into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -70,7 +70,7 @@ public abstract class IstringHelper
}
/**
- * Extract the IString from Any ((uses {@link Any.extract_string}).
+ * Extract the IString from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -100,7 +100,7 @@ public abstract class IstringHelper
/**
* Calls {@link InputStream#read_string()}.
*
- * @param instream the stream to read from.
+ * @param istream the stream to read from.
*/
public static String read(InputStream istream)
{
@@ -108,7 +108,7 @@ public abstract class IstringHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param ostream the stream to write into.
* @param value the string (IString) value to write.
diff --git a/org/omg/CosNaming/NameComponentHelper.java b/org/omg/CosNaming/NameComponentHelper.java
index 8127aa01d..0f7e73b45 100644
--- a/org/omg/CosNaming/NameComponentHelper.java
+++ b/org/omg/CosNaming/NameComponentHelper.java
@@ -1,5 +1,5 @@
/* NameComponentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -81,7 +81,7 @@ public abstract class NameComponentHelper
/**
* Get the repository Id of the {@link NameComponent}.
- * @return
+ * @return "IDL:omg.org/CosNaming/NameComponent:1.0"
*/
public static String id()
{
diff --git a/org/omg/CosNaming/NameHelper.java b/org/omg/CosNaming/NameHelper.java
index f66fa4f09..d1dafb960 100644
--- a/org/omg/CosNaming/NameHelper.java
+++ b/org/omg/CosNaming/NameHelper.java
@@ -1,5 +1,5 @@
/* NameHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/CosNaming/NamingContextExtHelper.java b/org/omg/CosNaming/NamingContextExtHelper.java
index aca0e9dfd..98d0b4a8c 100644
--- a/org/omg/CosNaming/NamingContextExtHelper.java
+++ b/org/omg/CosNaming/NamingContextExtHelper.java
@@ -1,5 +1,5 @@
/* NamingContextExtHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
@@ -127,15 +126,13 @@ public abstract class NamingContextExtHelper
* performed to verify that the object actually supports the requested type.
* The {@link BAD_OPERATION} will be thrown if unsupported operations are
* invoked on the new returned reference, but no failure is expected at the
- * time of the unchecked_narrow.
+ * time of the unchecked_narrow. See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted NamingContextExt
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static NamingContextExt unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java b/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
index 810460744..8333ff826 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/AddressHelper.java
@@ -1,5 +1,5 @@
/* AddressHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,7 +45,6 @@ import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
-import org.omg.CORBA.portable.Streamable;
/**
* Helper operations for address. Address is directly mapped into
diff --git a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
index c7f3849a0..ea17473e3 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHelper.java
@@ -1,5 +1,5 @@
/* InvalidAddressHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,7 +41,6 @@ package org.omg.CosNaming.NamingContextExtPackage;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java
index 114919462..5ded186a6 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/InvalidAddressHolder.java
@@ -1,5 +1,5 @@
/* InvalidAddressHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,6 +42,7 @@ import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
+import org.omg.CosNaming.NamingContextPackage.NotEmpty;
/**
* The holder for the exception {@link InvalidAddress}.
diff --git a/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java b/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
index 06faa2ff9..f020cef82 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/StringNameHelper.java
@@ -1,5 +1,5 @@
/* StringNameHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,11 +41,9 @@ package org.omg.CosNaming.NamingContextExtPackage;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
-import org.omg.CORBA.portable.Streamable;
/**
* Helper operations for the string name.
diff --git a/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java b/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
index 173bb989e..b565530e5 100644
--- a/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
+++ b/org/omg/CosNaming/NamingContextExtPackage/URLStringHelper.java
@@ -1,5 +1,5 @@
/* URLStringHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,7 +41,6 @@ package org.omg.CosNaming.NamingContextExtPackage;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/CosNaming/NamingContextHelper.java b/org/omg/CosNaming/NamingContextHelper.java
index 48b90c25a..6bbd0729f 100644
--- a/org/omg/CosNaming/NamingContextHelper.java
+++ b/org/omg/CosNaming/NamingContextHelper.java
@@ -1,5 +1,5 @@
/* NamingContextHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
@@ -135,15 +134,11 @@ public abstract class NamingContextHelper
* to verify that the object actually supports the requested type. The
* {@link BAD_OPERATION} will be thrown if unsupported operations are invoked
* on the new returned reference, but no failure is expected at the time of
- * the unchecked_narrow.
+ * the unchecked_narrow. See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted NamingContext.
- *
- * @since 1.5
- *
- * @see OMG issue 4158.
*/
public static NamingContext unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
index f43111cb2..1eaf50d12 100644
--- a/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/AlreadyBoundHelper.java
@@ -1,5 +1,5 @@
/* AlreadyBoundHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidName.java b/org/omg/CosNaming/NamingContextPackage/InvalidName.java
index 90ca3a5c5..59784ea1b 100644
--- a/org/omg/CosNaming/NamingContextPackage/InvalidName.java
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidName.java
@@ -1,5 +1,5 @@
/* InvalidName.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,7 +40,6 @@ package org.omg.CosNaming.NamingContextPackage;
import org.omg.CORBA.UserException;
import org.omg.CORBA.portable.IDLEntity;
-import org.omg.CosNaming.NameComponent;
/**
* The exception is thrown if the name has the zero length or is otherwise
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
index 5893332b8..b5a428cac 100644
--- a/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidNameHelper.java
@@ -1,5 +1,5 @@
/* InvalidNameHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
index a9b802f95..c4e06c39c 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotEmptyHelper.java
@@ -1,5 +1,5 @@
/* NotEmptyHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
index 9d44dcbf3..ddc7701a5 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHelper.java
@@ -1,5 +1,5 @@
/* NotFoundReasonHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java
index fc41b1833..a18801c66 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReasonHolder.java
@@ -1,5 +1,5 @@
/* NotFoundReasonHolder.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -81,7 +81,9 @@ public final class NotFoundReasonHolder
/**
* Get the type code of {@link NotFoundReason}.
- * @return
+ *
+ * @return the typecode of enumeration, allowed value names being
+ * "missing_node", "not_context" and "not_object"
*/
public TypeCode _type()
{
diff --git a/org/omg/DynamicAny/AnySeqHelper.java b/org/omg/DynamicAny/AnySeqHelper.java
index ddf1422ff..31ed2ba02 100644
--- a/org/omg/DynamicAny/AnySeqHelper.java
+++ b/org/omg/DynamicAny/AnySeqHelper.java
@@ -1,5 +1,5 @@
/* AnySeqHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
+import org.omg.CORBA.AnySeqHolder;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
diff --git a/org/omg/DynamicAny/DynAnyFactoryHelper.java b/org/omg/DynamicAny/DynAnyFactoryHelper.java
index 97b54873f..612ba71c3 100644
--- a/org/omg/DynamicAny/DynAnyFactoryHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryHelper.java
@@ -1,5 +1,5 @@
/* DynAnyFactoryHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,9 +42,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.Minor;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -88,15 +88,13 @@ public abstract class DynAnyFactoryHelper
* Narrow the given object to the DynAnyFactory. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See also OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynAnyFactory.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynAnyFactory unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -163,7 +161,7 @@ public abstract class DynAnyFactoryHelper
* This should read DynAnyFactory from the CDR input stream, but (following
* the JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynAnyFactoryOperations.java b/org/omg/DynamicAny/DynAnyFactoryOperations.java
index 058e36958..c3cd919ad 100644
--- a/org/omg/DynamicAny/DynAnyFactoryOperations.java
+++ b/org/omg/DynamicAny/DynAnyFactoryOperations.java
@@ -1,5 +1,5 @@
/* DynAnyFactoryOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.DynamicAny;
import org.omg.CORBA.Any;
+import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
@@ -83,7 +84,7 @@ public interface DynAnyFactoryOperations
* </tr>
* <tr>
* <td>{@link Any}</td>
- * <td>{@link Any} with no value and typecode of kind {@link TCKind.tk_null}</td>
+ * <td>{@link Any} with no value and typecode of kind {@link TCKind#tk_null}</td>
* <td>{@link DynAny}</td>
* </tr>
* <tr>
diff --git a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
index 96dbb5fb6..018417226 100644
--- a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
@@ -1,5 +1,5 @@
/* InconsistentTypeCodeHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/DynamicAny/DynAnyHelper.java b/org/omg/DynamicAny/DynAnyHelper.java
index a238bf48b..315cddbd2 100644
--- a/org/omg/DynamicAny/DynAnyHelper.java
+++ b/org/omg/DynamicAny/DynAnyHelper.java
@@ -1,5 +1,5 @@
/* DynAnyHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -86,15 +86,13 @@ public abstract class DynAnyHelper
* Narrow the given object to the DynAny. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See also OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynAny.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynAny unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -160,7 +158,7 @@ public abstract class DynAnyHelper
* This should read DynAny from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynAnyOperations.java b/org/omg/DynamicAny/DynAnyOperations.java
index 73d8fac23..a009f4c88 100644
--- a/org/omg/DynamicAny/DynAnyOperations.java
+++ b/org/omg/DynamicAny/DynAnyOperations.java
@@ -1,5 +1,5 @@
/* DynAnyOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -263,7 +263,7 @@ public interface DynAnyOperations
* Insert the {@link Any} value into the enclosed {@link Any} inside this
* DynAny.
*
- * @param a_x the value being inserted.
+ * @param an_any the value being inserted.
* @throws InvalidValue if the value type does not match the typecode of the
* enclosed {@link Any}.
*/
@@ -452,7 +452,7 @@ public interface DynAnyOperations
throws InvalidValue, TypeMismatch;
/**
- * Advances the internal pointer, described in the {@link current_component},
+ * Advances the internal pointer, described in the {@link #current_component},
* one position forward.
*
* @return true if the pointer now points to the new component, false if there
@@ -462,13 +462,13 @@ public interface DynAnyOperations
boolean next();
/**
- * Moves the internal pointer, described in the {@link current_component}, to
+ * Moves the internal pointer, described in the {@link #current_component}, to
* the first component.
*/
void rewind();
/**
- * Moves the internal pointer, described in the {@link current_component}, to
+ * Moves the internal pointer, described in the {@link #current_component}, to
* the given position.
*
* @param p the number of the internal component on that the internal pointer
diff --git a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
index 0258d3589..d27ad6a6b 100644
--- a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
@@ -1,5 +1,5 @@
/* InvalidValueHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
index 244a98aa0..7d4fc8789 100644
--- a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
@@ -1,5 +1,5 @@
/* TypeMismatchHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/DynamicAny/DynAnySeqHelper.java b/org/omg/DynamicAny/DynAnySeqHelper.java
index 66208ea19..f7550fd79 100644
--- a/org/omg/DynamicAny/DynAnySeqHelper.java
+++ b/org/omg/DynamicAny/DynAnySeqHelper.java
@@ -1,5 +1,5 @@
/* DynAnySeq.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,7 +51,7 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
- * A helper operations for the array of {@link DynAny} ({@link DynAnySeq}).
+ * A helper operations for the array of {@link DynAny} (DynAny[]).
* Following the 1.5 JDK specifications, DynAny (and hence an sequence of
* DynAny's) is always a local object, so the two methods of this helper
* ({@link #read} and {@link #write} are not in use, always throwing
@@ -133,7 +133,7 @@ public abstract class DynAnySeqHelper
* The method should write this object to the CDR input stream, but
* (following the JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynArrayHelper.java b/org/omg/DynamicAny/DynArrayHelper.java
index 26824d747..4cd3e3a52 100644
--- a/org/omg/DynamicAny/DynArrayHelper.java
+++ b/org/omg/DynamicAny/DynArrayHelper.java
@@ -1,5 +1,5 @@
/* DynArrayHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,16 +85,14 @@ public abstract class DynArrayHelper
* Narrow the given object to the DynArray. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynArray.
*
* @since 1.5
- *
- * @see OMG issue 4158.
- */
+ */
public static DynArray unchecked_narrow(org.omg.CORBA.Object obj)
{
return narrow(obj);
@@ -159,7 +157,7 @@ public abstract class DynArrayHelper
* This should read DynArray from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynEnumHelper.java b/org/omg/DynamicAny/DynEnumHelper.java
index 9af2e1194..da63e844f 100644
--- a/org/omg/DynamicAny/DynEnumHelper.java
+++ b/org/omg/DynamicAny/DynEnumHelper.java
@@ -1,5 +1,5 @@
/* DynEnumHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -86,15 +86,13 @@ public abstract class DynEnumHelper
* Narrow the given object to the DynEnum. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynEnum.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynEnum unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -160,7 +158,7 @@ public abstract class DynEnumHelper
* This should read DynEnum from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynFixedHelper.java b/org/omg/DynamicAny/DynFixedHelper.java
index 4471bb26b..e730d43bb 100644
--- a/org/omg/DynamicAny/DynFixedHelper.java
+++ b/org/omg/DynamicAny/DynFixedHelper.java
@@ -1,5 +1,5 @@
/* DynFixedHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -86,15 +86,13 @@ public abstract class DynFixedHelper
* Narrow the given object to the DynFixed. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynFixed.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynFixed unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -160,7 +158,7 @@ public abstract class DynFixedHelper
* This should read DynFixed from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynSequenceHelper.java b/org/omg/DynamicAny/DynSequenceHelper.java
index 0aa7cdd2a..f330108b0 100644
--- a/org/omg/DynamicAny/DynSequenceHelper.java
+++ b/org/omg/DynamicAny/DynSequenceHelper.java
@@ -1,5 +1,5 @@
/* DynSequenceHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynSequenceHelper
* Narrow the given object to the DynSequence. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynSequence.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynSequence unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynSequenceHelper
* This should read DynSequence from the CDR input stream, but (following the
* JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynStructHelper.java b/org/omg/DynamicAny/DynStructHelper.java
index c683260f6..077b7d098 100644
--- a/org/omg/DynamicAny/DynStructHelper.java
+++ b/org/omg/DynamicAny/DynStructHelper.java
@@ -1,5 +1,5 @@
/* DynStructHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynStructHelper
* Narrow the given object to the DynStruct. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynStruct.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynStruct unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynStructHelper
* This should read DynStruct from the CDR input stream, but (following the
* JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynStructOperations.java b/org/omg/DynamicAny/DynStructOperations.java
index 3b5af1710..03524b2f9 100644
--- a/org/omg/DynamicAny/DynStructOperations.java
+++ b/org/omg/DynamicAny/DynStructOperations.java
@@ -1,5 +1,5 @@
/* DynStructOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -101,7 +101,7 @@ public interface DynStructOperations
* @specnote The name-based value assignment is not supported by Sun's jdk
* 1.4.
*
- * @param an array of NameDynValuePair's, each defining a single field in the
+ * @param value an array of NameDynValuePair's, each defining a single field in the
* structure.
*
* @throws TypeMismatch if the member of the passed array has a different type
@@ -125,7 +125,7 @@ public interface DynStructOperations
* @specnote The name-based value assignment is not supported by Sun's jdk
* 1.4.
*
- * @param an array of NameValuePair's, each defining a single field in the
+ * @param value an array of NameValuePair's, each defining a single field in the
* structure.
*
* @throws TypeMismatch if the member of the passed array has a different type
diff --git a/org/omg/DynamicAny/DynUnionHelper.java b/org/omg/DynamicAny/DynUnionHelper.java
index e868ea412..f1016d078 100644
--- a/org/omg/DynamicAny/DynUnionHelper.java
+++ b/org/omg/DynamicAny/DynUnionHelper.java
@@ -1,5 +1,5 @@
/* DynUnionHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynUnionHelper
* Narrow the given object to the DynUnion. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynUnion.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynUnion unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynUnionHelper
* This should read DynUnion from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynValueHelper.java b/org/omg/DynamicAny/DynValueHelper.java
index ad75bc31f..17d9bbc5a 100644
--- a/org/omg/DynamicAny/DynValueHelper.java
+++ b/org/omg/DynamicAny/DynValueHelper.java
@@ -1,5 +1,5 @@
/* DynValueHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynValueHelper
* Narrow the given object to the DynValue. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynValue.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynValue unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynValueHelper
* This should read DynValue from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/FieldNameHelper.java b/org/omg/DynamicAny/FieldNameHelper.java
index f15b8adfa..fb5ea1c7f 100644
--- a/org/omg/DynamicAny/FieldNameHelper.java
+++ b/org/omg/DynamicAny/FieldNameHelper.java
@@ -59,7 +59,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class FieldNameHelper
{
/**
- * Insert the FieldName into Any (uses {@link Any.insert_string}).
+ * Insert the FieldName into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -70,7 +70,7 @@ public abstract class FieldNameHelper
}
/**
- * Extract the FieldName from Any ((uses {@link Any.extract_string}).
+ * Extract the FieldName from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -100,7 +100,7 @@ public abstract class FieldNameHelper
/**
* Calls {@link InputStream#read_string()}.
*
- * @param instream the stream to read from.
+ * @param istream the stream to read from.
*/
public static String read(InputStream istream)
{
@@ -108,7 +108,7 @@ public abstract class FieldNameHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param ostream the stream to write into.
* @param value the string (FieldName) value to write.
diff --git a/org/omg/DynamicAny/NameDynAnyPairHelper.java b/org/omg/DynamicAny/NameDynAnyPairHelper.java
index a9d9edba7..4e133a513 100644
--- a/org/omg/DynamicAny/NameDynAnyPairHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairHelper.java
@@ -1,5 +1,5 @@
/* NameDynAnyPairHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -151,7 +151,7 @@ public abstract class NameDynAnyPairHelper
* The method should write this object to the CDR input stream, but
* (following the JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
index 56e6104ec..817ed8a70 100644
--- a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
@@ -1,5 +1,5 @@
/* NameDynAnyPairSeq.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import org.omg.CORBA.portable.OutputStream;
/**
* A helper operations for the array of {@link NameDynAnyPair}
- * ({@link NameDynAnyPairSeq}).
+ * (NameDynAnyPair[]).
*
* Following the 1.5 JDK specifications, DynAny (and hence the sequence
* of structures, containing DynAny) is always a local object.
@@ -132,7 +132,7 @@ public abstract class NameDynAnyPairSeqHelper
* The method should write this object to the CDR input stream, but
* (following the JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/IOP/CodecFactoryHelper.java b/org/omg/IOP/CodecFactoryHelper.java
index 89404f7d5..d3dc40935 100644
--- a/org/omg/IOP/CodecFactoryHelper.java
+++ b/org/omg/IOP/CodecFactoryHelper.java
@@ -1,5 +1,5 @@
/* CodecFactoryHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,10 +41,10 @@ package org.omg.IOP;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -120,15 +120,13 @@ public abstract class CodecFactoryHelper
* Narrow the given object to the CodecFactory. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted CodecFactory.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static CodecFactory unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -141,7 +139,7 @@ public abstract class CodecFactoryHelper
*
* @specnote Suns implementation (1.4) throws this exception either.
*
- * @throws {@link MARSHAL}, minor code 0 and incomplete, always.
+ * @throws MARSHAL, minor code 0 and incomplete, always.
*/
public static CodecFactory read(InputStream input)
{
@@ -154,7 +152,7 @@ public abstract class CodecFactoryHelper
*
* @specnote Suns implementation (1.4) throws this exception either.
*
- * @throws {@link MARSHAL}, minor code 0 and incomplete, always.
+ * @throws MARSHAL, minor code 0 and incomplete, always.
*/
public static void write(OutputStream output, CodecFactory value)
{
diff --git a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
index 8861e43da..2110f0d5b 100644
--- a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
+++ b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
@@ -1,5 +1,5 @@
/* UnknownEncodingHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,7 +45,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/CodecOperations.java b/org/omg/IOP/CodecOperations.java
index 3dfae1207..873f54607 100644
--- a/org/omg/IOP/CodecOperations.java
+++ b/org/omg/IOP/CodecOperations.java
@@ -1,5 +1,5 @@
/* CodecOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -66,7 +66,7 @@ public interface CodecOperations
* by this {@link Codec} (wide char and wide string are not supported
* by ENCODING_CDR_ENCAPS v 1.0).
*
- * @see decode(byte[])
+ * @see #decode(byte[])
*/
byte[] encode(Any that)
throws InvalidTypeForEncoding;
@@ -83,7 +83,7 @@ public interface CodecOperations
*
* @throws FormatMismatch on the invalid structure of the byte array.
*
- * @see encode(Any)
+ * @see #encode(Any)
*/
Any decode(byte[] them)
throws FormatMismatch;
@@ -96,7 +96,7 @@ public interface CodecOperations
* @return the array, containing the encoded value alone (no preceeding
* typecode).
*
- * @see decode_value(byte[], TypeCode)
+ * @see #decode_value(byte[], TypeCode)
*/
byte[] encode_value(Any that_value)
throws InvalidTypeForEncoding;
@@ -119,7 +119,7 @@ public interface CodecOperations
* @throws TypeMismatch if discovered that the the byte array defines a
* different structure.
*
- * @see encode_value(Any)
+ * @see #encode_value(Any)
*/
Any decode_value(byte[] them, TypeCode type)
throws FormatMismatch, TypeMismatch;
diff --git a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
index 2a9295ae8..020975617 100644
--- a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
@@ -1,5 +1,5 @@
/* FormatMismatchHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
index e2a8c9057..246a1b93f 100644
--- a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
+++ b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
@@ -1,5 +1,5 @@
/* InvalidTypeForEncodingHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
index 432e84d24..88e00a243 100644
--- a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
@@ -1,5 +1,5 @@
/* TypeMismatchHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/IOP/ComponentIdHelper.java b/org/omg/IOP/ComponentIdHelper.java
index 35ffd9a69..f94187698 100644
--- a/org/omg/IOP/ComponentIdHelper.java
+++ b/org/omg/IOP/ComponentIdHelper.java
@@ -1,5 +1,5 @@
/* ComponentIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/ExceptionDetailMessage.java b/org/omg/IOP/ExceptionDetailMessage.java
index 167ab1ac7..92a068cba 100644
--- a/org/omg/IOP/ExceptionDetailMessage.java
+++ b/org/omg/IOP/ExceptionDetailMessage.java
@@ -1,5 +1,5 @@
/* ExceptionDetailMessage.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ package org.omg.IOP;
* USER_EXCEPTION reply status, as the alternative to the stack trace
* that might contain sensitive or unwanted information. The service
* context contains the CDR-encapsulated wide string, usually
- * returned by {@link Exception#getMessage}.
+ * returned by {@link Exception#getMessage()}.
* </p><p>
* The applications may also send the more comprehensive UnknownExceptionInfo
* ( = 9 ) service context that contains the thrown exception, written
diff --git a/org/omg/IOP/MultipleComponentProfileHelper.java b/org/omg/IOP/MultipleComponentProfileHelper.java
index 1c04ec54f..6a941dee6 100644
--- a/org/omg/IOP/MultipleComponentProfileHelper.java
+++ b/org/omg/IOP/MultipleComponentProfileHelper.java
@@ -1,5 +1,5 @@
/* MultipleComponentProfileHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.OutputStream;
@@ -52,7 +51,7 @@ import org.omg.CORBA.portable.InputStream;
/**
* A helper operations for the array of {@link TaggedComponent}
- * ({@link MultipleComponentProfile}).
+ * (MultipleComponentProfile).
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/IOP/ProfileIdHelper.java b/org/omg/IOP/ProfileIdHelper.java
index 340fa27d5..362b2dff3 100644
--- a/org/omg/IOP/ProfileIdHelper.java
+++ b/org/omg/IOP/ProfileIdHelper.java
@@ -1,5 +1,5 @@
/* ProfileIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/ServiceContextListHelper.java b/org/omg/IOP/ServiceContextListHelper.java
index 7875db29e..9de0b6ffd 100644
--- a/org/omg/IOP/ServiceContextListHelper.java
+++ b/org/omg/IOP/ServiceContextListHelper.java
@@ -1,5 +1,5 @@
/* ServiceContextListHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,21 +43,20 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
* The helper operations for the
-* CORBA object {@link ServiceContext[]}.
+* CORBA object {@link ServiceContext}[].
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class ServiceContextListHelper
{
/**
- * Get the type code of the {@link ServiceContext[]}.
+ * Get the type code of the {@link ServiceContext}[].
*/
public static TypeCode type()
{
diff --git a/org/omg/IOP/ServiceIdHelper.java b/org/omg/IOP/ServiceIdHelper.java
index 084dbd06d..9c4cbbe4a 100644
--- a/org/omg/IOP/ServiceIdHelper.java
+++ b/org/omg/IOP/ServiceIdHelper.java
@@ -1,5 +1,5 @@
/* ServiceIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/TAG_CODE_SETS.java b/org/omg/IOP/TAG_CODE_SETS.java
index cc7752483..07c5c9c32 100644
--- a/org/omg/IOP/TAG_CODE_SETS.java
+++ b/org/omg/IOP/TAG_CODE_SETS.java
@@ -1,5 +1,5 @@
/* TAG_CODE_SETS.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ package org.omg.IOP;
* profile provides information about the native and supported encodings
* for the "narrow" (usually 8 bit) and "wide" (usually 16 bit) characters.
* In Gnu Classpath implementation the class, responsible for providing
- * this information is {@link gnu.CORBA.CharSets_OSF}.
+ * this information is {@link gnu.CORBA.GIOP.CharSets_OSF}.
* </p>
* <p>
* If this profile is missing, it is assumed, that the "narrow" characters
diff --git a/org/omg/PortableInterceptor/ClientRequestInfoOperations.java b/org/omg/PortableInterceptor/ClientRequestInfoOperations.java
index 73efa122f..e4d70211a 100644
--- a/org/omg/PortableInterceptor/ClientRequestInfoOperations.java
+++ b/org/omg/PortableInterceptor/ClientRequestInfoOperations.java
@@ -1,5 +1,5 @@
/* ClientRequestInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.INV_POLICY;
import org.omg.CORBA.Policy;
@@ -285,8 +286,6 @@ public interface ClientRequestInfoOperations extends RequestInfoOperations
* @param type the type of the policy being requested.
*
* @return should return the policy that applies to this operation.
- *
- * @throws NO_IMPLEMENT always.
*/
Policy get_request_policy(int type) throws INV_POLICY;
diff --git a/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java b/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java
index 4a60b77f5..efd98707b 100644
--- a/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java
+++ b/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java
@@ -1,5 +1,5 @@
/* ClientRequestInterceptorOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import org.omg.CORBA.SystemException;
+
/**
* Defines operations, applicable to the client side request interceptor. The
diff --git a/org/omg/PortableInterceptor/CurrentHelper.java b/org/omg/PortableInterceptor/CurrentHelper.java
index e453f6010..88ab0e270 100644
--- a/org/omg/PortableInterceptor/CurrentHelper.java
+++ b/org/omg/PortableInterceptor/CurrentHelper.java
@@ -1,5 +1,5 @@
/* CurrentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,13 +42,12 @@ import gnu.CORBA.Minor;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
-import org.omg.PortableServer.ServantActivator;
/**
* The helper operations for the CORBA object {@link Current}.
@@ -123,15 +122,13 @@ public abstract class CurrentHelper
* Narrow the given object to the Current. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See also OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted Current.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static Current unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/PortableInterceptor/IORInfo.java b/org/omg/PortableInterceptor/IORInfo.java
index 9495d79ec..ec7235102 100644
--- a/org/omg/PortableInterceptor/IORInfo.java
+++ b/org/omg/PortableInterceptor/IORInfo.java
@@ -1,5 +1,5 @@
/* IORInfo.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import java.io.Serializable;
* Provides the server-side ORB service possibility to add components to the new
* IOR being created. Also, provides access to policies, applicable to the
* object, referenced by that IOR. The ORB passes an instance of IORInfo as a
- * parameter to {@link IORInterceptor#establish_components}.
+ * parameter to {@link IORInterceptorOperations#establish_components}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java b/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
index 926974f1a..71fb928f7 100644
--- a/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
+++ b/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
@@ -1,5 +1,5 @@
/* IORInterceptor_3_0Helper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/PortableInterceptor/ORBIdHelper.java b/org/omg/PortableInterceptor/ORBIdHelper.java
index 8332845a6..6b73b1151 100644
--- a/org/omg/PortableInterceptor/ORBIdHelper.java
+++ b/org/omg/PortableInterceptor/ORBIdHelper.java
@@ -1,5 +1,5 @@
/* ORBIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -58,7 +58,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ORBIdHelper
{
/**
- * Insert the ORB Id into Any (uses {@link Any.insert_string}).
+ * Insert the ORB Id into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -69,7 +69,7 @@ public abstract class ORBIdHelper
}
/**
- * Extract the ORB Id from Any ((uses {@link Any.extract_string}).
+ * Extract the ORB Id from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -107,7 +107,7 @@ public abstract class ORBIdHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param output the stream to write into.
* @param value the string (ORB Id) value to write.
diff --git a/org/omg/PortableInterceptor/ORBInitInfoOperations.java b/org/omg/PortableInterceptor/ORBInitInfoOperations.java
index 7b545ff81..16710a08a 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoOperations.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoOperations.java
@@ -1,5 +1,5 @@
/* ORBInitInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.ORB;
import org.omg.IOP.CodecFactory;
import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
@@ -90,7 +92,7 @@ public interface ORBInitInfoOperations
throws DuplicateName;
/**
- * Allocate a slot on a {@link PortableInterceptor.Current}. While slots can
+ * Allocate a slot on a {@link Current} of this interceptor. While slots can
* be allocated by this method, they cannot be initialized.
* {@link CurrentOperations#get_slot} and {@link CurrentOperations#set_slot}
* throw {@link org.omg.CORBA.BAD_INV_ORDER} while called from the interceptor
@@ -103,8 +105,8 @@ public interface ORBInitInfoOperations
/**
* Returns the arguments passed to the ORB.init.
*
- * @return the first parameter, passed to the method
- * {@link org.omg.CORBA.ORB#init}.
+ * @return the first parameter, passed to the methods from the group
+ * org.omg.CORBA.ORB#init(String[], ...).
*/
String[] arguments();
@@ -127,7 +129,7 @@ public interface ORBInitInfoOperations
/**
* Register the initial reference. The registered object will be accessible by
- * the {@link ORB.resolve_initial_references} under the object_name.
+ * the {@link ORB#resolve_initial_references} under the object_name.
*
* @param object_name the name of the object to register.
* @param object the object to register.
diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
index a87a3b747..329fcf564 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
@@ -1,5 +1,5 @@
/* InvalidNameHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableInterceptor/ORBInitializerOperations.java b/org/omg/PortableInterceptor/ORBInitializerOperations.java
index 90c2325f2..d5dd771fd 100644
--- a/org/omg/PortableInterceptor/ORBInitializerOperations.java
+++ b/org/omg/PortableInterceptor/ORBInitializerOperations.java
@@ -1,5 +1,5 @@
/* ORBInitializerOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -67,7 +67,7 @@ public interface ORBInitializerOperations
* @param info the object describing ORB being created and containing methods
* to register the interceptor.
*
- * @see ORBInitInfoOperations#register_initial_references
+ * @see ORBInitInfoOperations#register_initial_reference
*/
void post_init(ORBInitInfo info);
} \ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
index 72c864811..b9a237dce 100644
--- a/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
+++ b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
@@ -1,5 +1,5 @@
/* ObjectReferenceFactoryHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ValueMember;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java b/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
index 014c11308..0ea54ea5f 100644
--- a/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
+++ b/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
@@ -1,5 +1,5 @@
/* ObjectReferenceTemplateHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.VM_ABSTRACT;
import org.omg.CORBA.ValueMember;
diff --git a/org/omg/PortableInterceptor/RequestInfoOperations.java b/org/omg/PortableInterceptor/RequestInfoOperations.java
index f865a14d2..10b9662a6 100644
--- a/org/omg/PortableInterceptor/RequestInfoOperations.java
+++ b/org/omg/PortableInterceptor/RequestInfoOperations.java
@@ -1,5 +1,5 @@
/* RequestInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@ package org.omg.PortableInterceptor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.NO_RESOURCES;
import org.omg.CORBA.TypeCode;
import org.omg.Dynamic.Parameter;
import org.omg.IOP.ServiceContext;
@@ -182,7 +183,7 @@ public interface RequestInfoOperations
* the client. However up till JDK 1.5 inclusive this method always returns
* SYNC_WITH_TRANSPORT.
*
- * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always.
+ * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT#value} (1), always.
*
* @specnote as defined in the Suns 1.5 JDK API.
*/
diff --git a/org/omg/PortableInterceptor/ServerIdHelper.java b/org/omg/PortableInterceptor/ServerIdHelper.java
index e4f8fe9c2..84ffdfa8e 100644
--- a/org/omg/PortableInterceptor/ServerIdHelper.java
+++ b/org/omg/PortableInterceptor/ServerIdHelper.java
@@ -1,5 +1,5 @@
/* ServerIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -58,7 +58,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ServerIdHelper
{
/**
- * Insert the Server Id into Any (uses {@link Any.insert_string}).
+ * Insert the Server Id into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -69,7 +69,7 @@ public abstract class ServerIdHelper
}
/**
- * Extract the Server Id from Any ((uses {@link Any.extract_string}).
+ * Extract the Server Id from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -107,7 +107,7 @@ public abstract class ServerIdHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param output the stream to write into.
* @param value the string (Server Id) value to write.
diff --git a/org/omg/PortableInterceptor/ServerRequestInfoOperations.java b/org/omg/PortableInterceptor/ServerRequestInfoOperations.java
index a9ee7d920..52de9d824 100644
--- a/org/omg/PortableInterceptor/ServerRequestInfoOperations.java
+++ b/org/omg/PortableInterceptor/ServerRequestInfoOperations.java
@@ -1,5 +1,5 @@
/* ServerRequestInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.INV_POLICY;
import org.omg.CORBA.Policy;
import org.omg.IOP.ServiceContext;
@@ -287,7 +288,7 @@ public interface ServerRequestInfoOperations
/**
* Checks if the servant is the given repository id.
*
- * @param the repository id to compare.
+ * @param id the repository id to compare.
*
* @return true if the servant repository id matches the parameter, false
* otherwise.
diff --git a/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java b/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java
index b57ca28f7..ccba1a76e 100644
--- a/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java
+++ b/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import org.omg.CORBA.SystemException;
+
/**
* Defines operations, applicable to the server side request interceptor. The
@@ -50,16 +52,16 @@ public interface ServerRequestInterceptorOperations
{
/**
* ORB calls this method before invoking the servant manager. Operation
- * parameters are not available at this point. The interceptor has possibility
+ * parameters are not available at this point. The interceptor has possibility
* to forward the request by throwing {@link ForwardRequest}.
- *
- * @throws SystemException if it does, the receive_request_service_contexts is
- * not called for the subsequent interceptors, calling send_exception instead.
- * The completion status of such exception must be COMPLETED_NO.
- *
+ *
+ * @throws SystemException if it does, the receive_request_service_contexts is
+ * not called for the subsequent interceptors, calling
+ * send_exception instead. The completion status of such exception
+ * must be COMPLETED_NO.
* @throws ForwardRequest to forward the invocation to another target. The
- * receive_request_service_contexts is not called for the subsequent
- * interceptors, calling send_other instead.
+ * receive_request_service_contexts is not called for the subsequent
+ * interceptors, calling send_other instead.
*/
void receive_request_service_contexts(ServerRequestInfo info)
throws ForwardRequest;
diff --git a/org/omg/PortableServer/AdapterActivatorOperations.java b/org/omg/PortableServer/AdapterActivatorOperations.java
index dcf7edd04..d1091852e 100644
--- a/org/omg/PortableServer/AdapterActivatorOperations.java
+++ b/org/omg/PortableServer/AdapterActivatorOperations.java
@@ -1,5 +1,5 @@
/* AdapterActivatorOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+
/**
* Defines the operations, applicable to the AdapterActivator.
diff --git a/org/omg/PortableServer/CurrentHelper.java b/org/omg/PortableServer/CurrentHelper.java
index 3afbf669b..f201e38bc 100644
--- a/org/omg/PortableServer/CurrentHelper.java
+++ b/org/omg/PortableServer/CurrentHelper.java
@@ -1,5 +1,5 @@
/* CurrentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.PortableServer;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.NO_IMPLEMENT;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
index 02c74c535..4a2a9a6a0 100644
--- a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
+++ b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
@@ -1,5 +1,5 @@
/* NoContextHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/ForwardRequestHelper.java b/org/omg/PortableServer/ForwardRequestHelper.java
index b30a2abeb..d5d5751b9 100644
--- a/org/omg/PortableServer/ForwardRequestHelper.java
+++ b/org/omg/PortableServer/ForwardRequestHelper.java
@@ -1,5 +1,5 @@
/* ForwardRequestHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer;
import gnu.CORBA.Minor;
+import gnu.CORBA.ObjectCreator;
import gnu.CORBA.OrbRestricted;
import gnu.CORBA.Poa.ForwardRequestHolder;
diff --git a/org/omg/PortableServer/IdAssignmentPolicyValue.java b/org/omg/PortableServer/IdAssignmentPolicyValue.java
index ac81d389c..cc6f3962a 100644
--- a/org/omg/PortableServer/IdAssignmentPolicyValue.java
+++ b/org/omg/PortableServer/IdAssignmentPolicyValue.java
@@ -1,5 +1,5 @@
/* IdAssignmentPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/IdUniquenessPolicyValue.java b/org/omg/PortableServer/IdUniquenessPolicyValue.java
index c0f281249..0294ee209 100644
--- a/org/omg/PortableServer/IdUniquenessPolicyValue.java
+++ b/org/omg/PortableServer/IdUniquenessPolicyValue.java
@@ -1,5 +1,5 @@
/* IdUniquenessPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/ImplicitActivationPolicyValue.java b/org/omg/PortableServer/ImplicitActivationPolicyValue.java
index 9d81d5fab..6631424c4 100644
--- a/org/omg/PortableServer/ImplicitActivationPolicyValue.java
+++ b/org/omg/PortableServer/ImplicitActivationPolicyValue.java
@@ -1,5 +1,5 @@
/* ImplicitActivationPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/LifespanPolicyValue.java b/org/omg/PortableServer/LifespanPolicyValue.java
index 117eb5a3c..e1ab856b0 100644
--- a/org/omg/PortableServer/LifespanPolicyValue.java
+++ b/org/omg/PortableServer/LifespanPolicyValue.java
@@ -1,5 +1,5 @@
/* LifespanPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/POA.java b/org/omg/PortableServer/POA.java
index 863a12bf8..624d658da 100644
--- a/org/omg/PortableServer/POA.java
+++ b/org/omg/PortableServer/POA.java
@@ -1,5 +1,5 @@
/* POA.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,8 +55,8 @@ import org.omg.CORBA.portable.IDLEntity;
* strategies are possible.
* </p>
*
- * @see org.omg.CORBA.ORB.resolve_initial_references
- * @see POAOperations.servant_to_reference
+ * @see org.omg.CORBA.ORB#resolve_initial_references
+ * @see POAOperations#servant_to_reference
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/PortableServer/POAHelper.java b/org/omg/PortableServer/POAHelper.java
index d6a951be5..122cfb304 100644
--- a/org/omg/PortableServer/POAHelper.java
+++ b/org/omg/PortableServer/POAHelper.java
@@ -1,5 +1,5 @@
/* POAHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -139,7 +139,7 @@ public abstract class POAHelper
* it doesnot. The jdk 1.5 API specification defines that POA cannot be
* exported.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
index e23d11997..e6a3068af 100644
--- a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
+++ b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAManagerPackage/State.java b/org/omg/PortableServer/POAManagerPackage/State.java
index 9e856098b..b32d420a8 100644
--- a/org/omg/PortableServer/POAManagerPackage/State.java
+++ b/org/omg/PortableServer/POAManagerPackage/State.java
@@ -1,5 +1,5 @@
/* State.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,8 @@ package org.omg.PortableServer.POAManagerPackage;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TRANSIENT;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
@@ -54,7 +56,7 @@ import java.io.Serializable;
* receive and process requests.</li>
* <li>DISCARDING When the manager is in the discarding state,
* the associated POAs discard all incoming requests. The sending clients
- * receive the {@link org.omg.TRANSIENT} system exception, with standard
+ * receive the {@link TRANSIENT} system exception, with standard
* minor code 1. This mode is needed for flow control, when the system is
* flooded with requests.
* </li>
diff --git a/org/omg/PortableServer/POAOperations.java b/org/omg/PortableServer/POAOperations.java
index 1c22ceed2..58d062d2b 100644
--- a/org/omg/PortableServer/POAOperations.java
+++ b/org/omg/PortableServer/POAOperations.java
@@ -1,5 +1,5 @@
/* POAOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,11 @@ exception statement from your version. */
package org.omg.PortableServer;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.OBJ_ADAPTER;
import org.omg.CORBA.Policy;
+import org.omg.CORBA.TRANSIENT;
import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;
import org.omg.PortableServer.POAPackage.AdapterNonExistent;
import org.omg.PortableServer.POAPackage.InvalidPolicy;
@@ -107,7 +111,7 @@ public interface POAOperations
* the Active Object Map using this Id a a key. If the servant
* activator is set, its incarnate method will be called. In this case,
* the passed servant in this method can be null; in this case, the servant,
- * returned by {@link ServantLocatorOperations#incarnate} will
+ * returned by {@link ServantActivatorOperations#incarnate} will
* be used.
*
* @param a_servant a servant that would serve the object with the
@@ -129,7 +133,7 @@ public interface POAOperations
* object with the provided Object Id. If the servant activator is
* set, its incarnate method will be called. In this case,
* the passed servant in this method can be null; in this case, the servant,
- * returned by {@link ServantLocatorOperations#incarnate} will
+ * returned by {@link ServantActivatorOperations#incarnate} will
* be used.
*
* @param an_Object_Id an object id for the given object.
@@ -241,7 +245,7 @@ public interface POAOperations
/**
* Set a servant manager for this POA.
*
- * @param a servant manager being set. If the RETAIN policy applies, the
+ * @param a_manager servant manager being set. If the RETAIN policy applies, the
* manager must implement a {@link ServantActivator}. If the NON_RETAIN
* policy applies, the manager must implement a {@link ServantLocator}.
*
@@ -298,7 +302,7 @@ public interface POAOperations
* @param the_Object_Id the object id.
*
* @throws ObjectNotActive if there is no active object with such Id.
- * @throws WrongPolicy. This method requires either RETAIN or
+ * @throws WrongPolicy This method requires either RETAIN or
* USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
* apply to this POA.
*/
@@ -328,7 +332,7 @@ public interface POAOperations
*
* @throws ObjectNotActive if none of the conditions above are satisfied.
* @throws WrongAdapter if the object reference was not created with this POA.
- * @throws WrongPolicy. This method requires either RETAIN or
+ * @throws WrongPolicy This method requires either RETAIN or
* USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
* apply to this POA.
*/
@@ -408,7 +412,7 @@ public interface POAOperations
/**
* Set the adapter activator for this POA.
*
- * @param the activator being set.
+ * @param activator the activator being set.
*/
void the_activator(AdapterActivator activator);
@@ -437,7 +441,7 @@ public interface POAOperations
* <p> Destroy this POA and all descendant POAs. The destroyed POAs can be
* later re-created via {@link AdapterActivator} or by invoking
* {@link #create_POA}.
- * This differs from {@link PoaManagerOperations#deactivate} that does
+ * This differs from {@link POAManagerOperations#deactivate} that does
* not allow recreation of the deactivated POAs. After deactivation,
* recreation is only possible if the POAs were later destroyed.
* </p><p>
@@ -462,7 +466,7 @@ public interface POAOperations
/**
* Create the IdUniquenessPolicy policy.
*
- * @param value states which one Id uniqueness policy will apply.
+ * @param a_value states which one Id uniqueness policy will apply.
*
* @return the created policy.
*/
@@ -471,7 +475,7 @@ public interface POAOperations
/**
* Create the ImplicitActivationPolicy policy.
*
- * @param value states which one activation policy will apply.
+ * @param a_value states which one activation policy will apply.
*
* @return the created policy.
*/
@@ -480,7 +484,7 @@ public interface POAOperations
/**
* Create the LifespanPolicy policy.
*
- * @param value states which one object lifespan policy will apply.
+ * @param a_value states which one object lifespan policy will apply.
*
* @return the created policy.
*/
@@ -489,7 +493,7 @@ public interface POAOperations
/**
* Create the RequestProcessingPolicy policy.
*
- * @param value states which one request processing policy will apply.
+ * @param a_value states which one request processing policy will apply.
*
* @return the created policy.
*/
@@ -498,7 +502,7 @@ public interface POAOperations
/**
* Create the ServantRetentionPolicy policy.
*
- * @param value states which one servant retention policy will apply.
+ * @param a_value states which one servant retention policy will apply.
*
* @return the created policy.
*/
@@ -507,7 +511,7 @@ public interface POAOperations
/**
* Create the ThreadPolicy policy.
*
- * @param value states which one thread policy will apply.
+ * @param a_value states which one thread policy will apply.
*
* @return the created policy.
*/
diff --git a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
index f616637ae..6476eeaa5 100644
--- a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
@@ -1,5 +1,5 @@
/* AdapterAlreadyExistsHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
index bad920a5a..1c007fb43 100644
--- a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
@@ -1,5 +1,5 @@
/* AdapterNonExistentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/InvalidPolicy.java b/org/omg/PortableServer/POAPackage/InvalidPolicy.java
index 51ef615fb..470d9af4a 100644
--- a/org/omg/PortableServer/POAPackage/InvalidPolicy.java
+++ b/org/omg/PortableServer/POAPackage/InvalidPolicy.java
@@ -69,7 +69,7 @@ public final class InvalidPolicy
/**
* Create InvalidPolicy with no explaining
- * message and leaving {@link index} with default 0 value.
+ * message and leaving {@link #index} with default 0 value.
*/
public InvalidPolicy()
{
@@ -77,7 +77,7 @@ public final class InvalidPolicy
/**
* Create the InvalidPolicy with explaining
- * message and initialisintg {@link index} to the passed value.
+ * message and initialisintg {@link #index} to the passed value.
*
* @param why a string, explaining, why this exception has been thrown.
* @param a_index a value for index.
@@ -90,7 +90,7 @@ public final class InvalidPolicy
/**
* Create the InvalidPolicy without explaining
- * message and initialisintg {@link index} to the passed value.
+ * message and initialisintg {@link #index} to the passed value.
*
* @param a_index a value for index.
*/
diff --git a/org/omg/PortableServer/POAPackage/NoServantHelper.java b/org/omg/PortableServer/POAPackage/NoServantHelper.java
index b9afb8ed7..56e8c4d16 100644
--- a/org/omg/PortableServer/POAPackage/NoServantHelper.java
+++ b/org/omg/PortableServer/POAPackage/NoServantHelper.java
@@ -1,5 +1,5 @@
/* NoServantHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
index bf5e9cd9e..7f2e1484c 100644
--- a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
@@ -1,5 +1,5 @@
/* ObjectAlreadyActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
index 2f5867cbd..4cdf80891 100644
--- a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
@@ -1,5 +1,5 @@
/* ObjectNotActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
index 33ca06674..30b0b52d0 100644
--- a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
@@ -1,5 +1,5 @@
/* ServantAlreadyActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
index e86f4e948..f77ecfc50 100644
--- a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
@@ -1,5 +1,5 @@
/* ServantNotActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
index 7650014c1..f1181fe61 100644
--- a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
@@ -1,5 +1,5 @@
/* WrongAdapterHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
index a9e7fc594..bd09c2e96 100644
--- a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
@@ -1,5 +1,5 @@
/* WrongPolicyHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/RequestProcessingPolicyValue.java b/org/omg/PortableServer/RequestProcessingPolicyValue.java
index 0b1ce4d0b..2f22e3090 100644
--- a/org/omg/PortableServer/RequestProcessingPolicyValue.java
+++ b/org/omg/PortableServer/RequestProcessingPolicyValue.java
@@ -1,5 +1,5 @@
/* RequestProcessingPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/Servant.java b/org/omg/PortableServer/Servant.java
index 5c99ee1a0..24eb715a9 100644
--- a/org/omg/PortableServer/Servant.java
+++ b/org/omg/PortableServer/Servant.java
@@ -80,7 +80,7 @@ import gnu.CORBA.Poa.gnuPOA;
* The Servant type is a CORBA <code>native</code> type.
* </p>
*
- * @see POA.servant_to_reference(Servant)
+ * @see POA#servant_to_reference(Servant)
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
@@ -128,8 +128,7 @@ public abstract class Servant
* Checks if the passed servant is an instance of the given CORBA IDL type.
* By default, forwards the requet to the delegate.
*
- * @param a_servant a servant to check.
- * @param an_id a repository ID, representing an IDL type for that the
+ * @param repository_id a repository ID, representing an IDL type for that the
* servant must be checked.
*
* @return true if the servant is an instance of the given type, false
@@ -166,7 +165,7 @@ public abstract class Servant
* reference "RootPOA" for that orb. By default, forwards request to the
* delegate.
*
- * @see ORB.resolve_initial_references
+ * @see ORB#resolve_initial_references
*/
public POA _default_POA()
{
@@ -214,7 +213,7 @@ public abstract class Servant
* the given servant. This is important when the same servant serves
* multiple objects. If the servant is not yet connected to the passed
* orb, the method will try to connect it to that orb on POA, returned
- * by the method {@link _default_POA}. That method can be overridden to
+ * by the method {@link #_default_POA}. That method can be overridden to
* get poa where the object must be automatically connected when
* calling this method.
*
diff --git a/org/omg/PortableServer/ServantActivatorHelper.java b/org/omg/PortableServer/ServantActivatorHelper.java
index e1c4f09c8..48598aa20 100644
--- a/org/omg/PortableServer/ServantActivatorHelper.java
+++ b/org/omg/PortableServer/ServantActivatorHelper.java
@@ -1,5 +1,5 @@
/* ServantActivatorHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,7 +45,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -121,15 +120,13 @@ public abstract class ServantActivatorHelper
* Narrow the given object to the ServantActivator. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted ServantActivator.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static ServantActivator unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/PortableServer/ServantLocatorHelper.java b/org/omg/PortableServer/ServantLocatorHelper.java
index 7bb933f7b..467464791 100644
--- a/org/omg/PortableServer/ServantLocatorHelper.java
+++ b/org/omg/PortableServer/ServantLocatorHelper.java
@@ -1,5 +1,5 @@
/* ServantLocatorHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,8 +43,8 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -121,15 +121,13 @@ public abstract class ServantLocatorHelper
* Narrow the given object to the ServantLocator. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted ServantLocator.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static ServantLocator unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/PortableServer/ServantLocatorOperations.java b/org/omg/PortableServer/ServantLocatorOperations.java
index 6ed214e2f..58448c1af 100644
--- a/org/omg/PortableServer/ServantLocatorOperations.java
+++ b/org/omg/PortableServer/ServantLocatorOperations.java
@@ -1,5 +1,5 @@
/* ServantLocatorOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ public interface ServantLocatorOperations
* @param operation the name of the method or operation being invoked.
* @param cookie_holder the holder where the servant manager can store
* an arbitrary java.lang.Object. This object will be later passed as a
- * <code>cookie</code> parameter for {@link postinvoke}, to create tie
+ * <code>cookie</code> parameter for {@link #postinvoke}, to create tie
* between preinvoke and postinvoke. The application should <i>not</i>
* suppose that each call of preinvoke is followed by the subsequent
* postinvoke for the same invocation; under multi threaded policy these
diff --git a/org/omg/PortableServer/ServantRetentionPolicyValue.java b/org/omg/PortableServer/ServantRetentionPolicyValue.java
index 0b6ecf62f..607df1293 100644
--- a/org/omg/PortableServer/ServantRetentionPolicyValue.java
+++ b/org/omg/PortableServer/ServantRetentionPolicyValue.java
@@ -1,5 +1,5 @@
/* ServantRetentionPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/ThreadPolicyValue.java b/org/omg/PortableServer/ThreadPolicyValue.java
index 5c771a7d6..2ba1b8e82 100644
--- a/org/omg/PortableServer/ThreadPolicyValue.java
+++ b/org/omg/PortableServer/ThreadPolicyValue.java
@@ -1,5 +1,5 @@
/* ThreadPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/_ServantActivatorStub.java b/org/omg/PortableServer/_ServantActivatorStub.java
index 6f9071593..f323f6d38 100644
--- a/org/omg/PortableServer/_ServantActivatorStub.java
+++ b/org/omg/PortableServer/_ServantActivatorStub.java
@@ -1,5 +1,5 @@
/* _ServantActivatorStub.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,18 +38,10 @@ exception statement from your version. */
package org.omg.PortableServer;
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.ObjectHelper;
-import org.omg.CORBA.portable.ApplicationException;
-import org.omg.CORBA.portable.Delegate;
-import org.omg.CORBA.portable.InputStream;
-import org.omg.CORBA.portable.ObjectImpl;
-import org.omg.CORBA.portable.OutputStream;
-import org.omg.CORBA.portable.RemarshalException;
-
import java.io.Serializable;
+import org.omg.CORBA.portable.ObjectImpl;
+
/**
* <p>This ServantActivator stub is an optional base for the
* servant activators. This stub cannot accept remote invocations, as
diff --git a/org/omg/PortableServer/_ServantLocatorStub.java b/org/omg/PortableServer/_ServantLocatorStub.java
index 8234ba2c7..9f142e1e8 100644
--- a/org/omg/PortableServer/_ServantLocatorStub.java
+++ b/org/omg/PortableServer/_ServantLocatorStub.java
@@ -1,5 +1,5 @@
/* _ServantLocatorStub.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
diff --git a/resource/gnu/classpath/tools/common/Messages.properties b/resource/gnu/classpath/tools/common/Messages.properties
new file mode 100644
index 000000000..989fde74e
--- /dev/null
+++ b/resource/gnu/classpath/tools/common/Messages.properties
@@ -0,0 +1,40 @@
+# MessagesBundle.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.
+
+ClasspathToolParser.JArgument=pass argument to the Java runtime
+ClasspathToolParser.JName=OPTION
+ClasspathToolParser.VersionFormat={0} (GNU Classpath) {1}\n\nCopyright 2006 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/resource/gnu/classpath/tools/getopt/Messages.properties b/resource/gnu/classpath/tools/getopt/Messages.properties
index 42827e6e3..a747ab4b4 100644
--- a/resource/gnu/classpath/tools/getopt/Messages.properties
+++ b/resource/gnu/classpath/tools/getopt/Messages.properties
@@ -38,12 +38,9 @@
Parser.StdOptions=Standard options
Parser.PrintHelp=print this help, then exit
Parser.PrintVersion=print version number, then exit
-Parser.JArgument=pass argument to the Java runtime
-Parser.JName=OPTION
Parser.ArgReqd=option ''{0}'' requires an argument
Parser.Unrecognized=unrecognized option ''{0}''
Parser.NoArg=option ''{0}'' doesn''t allow an argument
Parser.UnrecDash=unrecognized option ''-{0}''
Parser.TryHelpShort=Try ''{0} -help'' for more information
Parser.TryHelpLong=Try ''{0} --help'' for more information
-ClasspathToolParser.VersionFormat={0} (GNU Classpath) {1}\n\nCopyright 2006 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/resource/gnu/classpath/tools/orbd/messages.properties b/resource/gnu/classpath/tools/orbd/messages.properties
new file mode 100644
index 000000000..b427d102b
--- /dev/null
+++ b/resource/gnu/classpath/tools/orbd/messages.properties
@@ -0,0 +1,46 @@
+# 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.
+
+Main.Usage=Usage: orbd [OPTIONS]
+Main.ORBInitialPort=port on which persistent naming service is to be started
+Main.Port=PORT
+Main.IOR=file in which to store persistent naming service's IOR reference
+Main.IORFile=FILE
+Main.Restart=restart persistent naming service, clearing persistent naming database
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.InternalError=orbd: internal error:
diff --git a/resource/gnu/classpath/tools/rmic/messages.properties b/resource/gnu/classpath/tools/rmic/messages.properties
new file mode 100644
index 000000000..7be7cb0c7
--- /dev/null
+++ b/resource/gnu/classpath/tools/rmic/messages.properties
@@ -0,0 +1,61 @@
+# 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.
+
+Main.Usage:rmic [OPTIONS] CLASSNAME...
+Main.NoWarn:show no warnings
+Main.NoWrite:check for errors and do not write any files
+Main.Verbose:show verbose output
+Main.DirOpt:write generated files to given directory
+Main.DirArg:DIRECTORY
+Main.ClasspathOpt:where to find input classes
+Main.ClasspathArg:PATH
+Main.BootclasspathOpt:where to find classes used to run rmic (ignored)
+Main.BootclasspathArg:PATH
+Main.ExtdirsOpt:where to find extension classes used to run rmic (ignored)
+Main.ExtdirsArg:PATH
+Main.IIOP:generate stubs and ties for IIOP
+Main.Always:always overwrite generated files (ignored)
+Main.AlwaysGenerate:same as -always
+Main.NoLocalStubs:do not create same-process stubs (ignored)
+Main.POA:generate servant-based ties
+Main.Keep:keep generated stub, skeleton and tie sources
+Main.KeepGenerated:same as -keep
+Main.v11:generate JDK 1.1 protocol stubs and skeletons
+Main.v12:generate JDK 1.2 JRMP stubs (default)
+Main.vcompat:generate JDK 1.1 protocol and JDK 1.2 JRMP stubs
+Main.DebugInfo:include debugging information in generated classes
+Main.InternalError:rmic: internal error:
diff --git a/resource/gnu/classpath/tools/rmid/messages.properties b/resource/gnu/classpath/tools/rmid/messages.properties
new file mode 100644
index 000000000..234cea12a
--- /dev/null
+++ b/resource/gnu/classpath/tools/rmid/messages.properties
@@ -0,0 +1,50 @@
+# 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.
+
+Main.Usage=Usage: rmid [OPTIONS]
+Main.ControlGroup=Activation process control
+Main.PortOption=port on which activation system is to be started
+Main.Port=PORT
+Main.Restart=restart activation system, clearing persistent naming database, if any
+Main.Stop=stop activation system
+Main.PersistenceGroup=Persistence
+Main.Persistent=make activation system persistent
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.DebugGroup=Debugging
+Main.Verbose=log binding events to standard out
+Main.InternalError=rmid: internal error:
diff --git a/resource/gnu/classpath/tools/rmiregistry/messages.properties b/resource/gnu/classpath/tools/rmiregistry/messages.properties
new file mode 100644
index 000000000..46f7cfdb7
--- /dev/null
+++ b/resource/gnu/classpath/tools/rmiregistry/messages.properties
@@ -0,0 +1,48 @@
+# 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.
+
+Main.Usage=Usage: rmiregistry [OPTIONS] [PORT]
+Main.ControlGroup=Registry process control
+Main.Restart=restart RMI naming service, clearing persistent naming database, if any
+Main.Stop=stop RMI naming service
+Main.PersistenceGroup=Persistence
+Main.Persistent=make RMI naming service persistent
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.DebugGroup=Debugging
+Main.Verbose=log binding events to standard out
+Main.InternalError=rmiregistry: internal error:
diff --git a/resource/gnu/classpath/tools/tnameserv/messages.properties b/resource/gnu/classpath/tools/tnameserv/messages.properties
new file mode 100644
index 000000000..3861e24ba
--- /dev/null
+++ b/resource/gnu/classpath/tools/tnameserv/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.
+
+Main.Usage=Usage: tnameserv [OPTIONS]
+Main.ORBInitialPort=port on which naming service is to be started
+Main.Port=PORT
+Main.IOR=file in which to store naming service's IOR reference
+Main.IORFile=FILE
+Main.InternalError=tnameserv: internal error:
diff --git a/scripts/check_jni_methods.sh b/scripts/check_jni_methods.sh
index 4cc00cc17..b46e37821 100755
--- a/scripts/check_jni_methods.sh
+++ b/scripts/check_jni_methods.sh
@@ -35,9 +35,6 @@ cat > $TMPFILE3 << EOF
-Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose
-Java_java_lang_VMSystem_arraycopy
-Java_java_lang_VMSystem_identityHashCode
--Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
--Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
--Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
EOF
# Compare again silently.
diff --git a/tools/.cvsignore b/tools/.cvsignore
index 49dfefd00..a013e8d16 100644
--- a/tools/.cvsignore
+++ b/tools/.cvsignore
@@ -12,3 +12,8 @@ gjar
gnative2ascii
gserialver
gjavah
+gorbd
+grmic
+grmid
+grmiregistry
+gtnameserv
diff --git a/tools/Makefile.am b/tools/Makefile.am
index b6bc4fbe2..04c2f2bbf 100755
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -15,12 +15,14 @@ endif
if USE_ASM
javah = gjavah
+rmic = grmic
endif
if CREATE_WRAPPERS
bin_SCRIPTS =
bin_PROGRAMS = gappletviewer gjarsigner gkeytool \
- gjar gnative2ascii gserialver $(javah)
+ gjar gnative2ascii gserialver $(javah) grmiregistry \
+ gtnameserv gorbd grmid $(rmic)
AM_CPPFLAGS = -Wall \
@@ -58,23 +60,50 @@ gserialver_CFLAGS = \
-DTOOLPACKAGE="\"serialver\"" \
-DTOOLNAME="\"gserialver\""
+grmiregistry_SOURCES = toolwrapper.c
+grmiregistry_CFLAGS = \
+ -DTOOLPACKAGE="\"rmiregistry\"" \
+ -DTOOLNAME="\"grmiregistry\""
+
+gtnameserv_SOURCES = toolwrapper.c
+gtnameserv_CFLAGS = \
+ -DTOOLPACKAGE="\"tnameserv\"" \
+ -DTOOLNAME="\"gtnameserv\""
+
+gorbd_SOURCES = toolwrapper.c
+gorbd_CFLAGS = \
+ -DTOOLPACKAGE="\"orbd\"" \
+ -DTOOLNAME="\"gorbd\""
+
+grmid_SOURCES = toolwrapper.c
+grmid_CFLAGS = \
+ -DTOOLPACKAGE="\"rmid\"" \
+ -DTOOLNAME="\"grmid\""
+
if USE_ASM
gjavah_SOURCES = toolwrapper.c
gjavah_CFLAGS = \
-DTOOLPACKAGE="\"javah\"" \
-DTOOLNAME="\"gjavah\""
+
+grmic_SOURCES = toolwrapper.c
+grmic_CFLAGS = \
+ -DTOOLPACKAGE="\"rmic\"" \
+ -DTOOLNAME="\"grmic\""
endif
else
bin_SCRIPTS = gappletviewer gjarsigner gkeytool \
- gjar gnative2ascii gserialver $(javah)
+ gjar gnative2ascii gserialver $(javah) grmiregistry \
+ gtnameserv gorbd grmid $(rmic)
bin_PROGRAMS =
endif
EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
- gjar.in gnative2ascii.in gserialver.in gjavah.in
+ gjar.in gnative2ascii.in gserialver.in gjavah.in grmiregistry.in \
+ gtnameserv.in gorbd.in grmid.in grmic.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
+TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*/*.java
# The zip files with classes we want to produce.
TOOLS_ZIP = tools.zip
@@ -82,26 +111,14 @@ TOOLS_ZIP = tools.zip
# Extra objects that will not exist until configure-time
BUILT_SOURCES = $(TOOLS_ZIP)
-# The templates that must be included into the generated zip file.
-GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav
-RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmi/rmic/templates/*.jav
-
-TOOLS_TEMPLATES = $(GRMIC_TEMPLATES) $(RMIC_TEMPLATES)
-
-# This covers the built-in help texts, both for giop and rmic subpackages.
-GIOP_HELPS = $(srcdir)/gnu/classpath/tools/giop/*.txt
-RMI_HELPS = $(srcdir)/gnu/classpath/tools/rmi/*.txt
-
-TOOLS_HELPS = $(GIOP_HELPS) $(RMI_HELPS)
-
-# The tool specific README files.
-READMES = $(srcdir)/gnu/classpath/tools/giop/README
+# RMIC templates that must be included in the generated zip file.
+RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmic/templates/*.jav
# All the files we find "interesting"
-ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(TOOLS_TEMPLATES) $(TOOLS_HELPS) $(READMES)
+ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(RMIC_TEMPLATES)
# Some architecture independent data to be installed.
-TOOLS_DATA = $(TOOLS_ZIP) README
+TOOLS_DATA = $(TOOLS_ZIP)
# Where we want these data files installed.
TOOLSdir = $(pkgdatadir)
@@ -125,20 +142,29 @@ dist-hook:
# immediately. And copy the template files we use to the classes dir
# so they get also included.
$(TOOLS_ZIP): $(TOOLS_JAVA_FILES)
- mkdir -p classes/gnu/classpath/tools/giop/grmic/templates
- mkdir -p classes/gnu/classpath/tools/rmi/rmic/templates
mkdir -p classes/gnu/classpath/tools/appletviewer
+ mkdir -p classes/gnu/classpath/tools/common
+ mkdir -p classes/gnu/classpath/tools/getopt
+ mkdir -p classes/gnu/classpath/tools/jar
mkdir -p classes/gnu/classpath/tools/jarsigner
mkdir -p classes/gnu/classpath/tools/keytool
- cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmi/rmic/templates
- cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates
- cp $(RMI_HELPS) classes/gnu/classpath/tools/rmi/
- cp $(GIOP_HELPS) classes/gnu/classpath/tools/giop/
+ mkdir -p classes/gnu/classpath/tools/native2ascii
+ mkdir -p classes/gnu/classpath/tools/orbd
+ mkdir -p classes/gnu/classpath/tools/rmid
+ mkdir -p classes/gnu/classpath/tools/rmiregistry
+ mkdir -p classes/gnu/classpath/tools/serialver
+ mkdir -p classes/gnu/classpath/tools/tnameserv
find $(srcdir)/gnu/classpath/tools -name '*.java' -print > classes.lst
if test -z "$(PATH_TO_ASM)"; then \
mv classes.lst classes.tmp; \
fgrep -v /javah/ classes.tmp > classes.lst; \
+ mv classes.lst classes.tmp; \
+ fgrep -v /rmic/ classes.tmp > classes.lst; \
rm -f classes.tmp;\
+ else \
+ mkdir -p classes/gnu/classpath/tools/javah; \
+ mkdir -p classes/gnu/classpath/tools/rmic/templates; \
+ cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmic/templates; \
fi
$(JCOMPILER) -d classes @classes.lst
(cd classes; \
diff --git a/tools/gnu/classpath/tools/HelpPrinter.java b/tools/gnu/classpath/tools/HelpPrinter.java
deleted file mode 100644
index 89468918a..000000000
--- a/tools/gnu/classpath/tools/HelpPrinter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/* HelpPrinter -- help message printer
- 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.classpath.tools;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * The shared class to print the help message and exit, when applicable.
- * Support the --help key.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class HelpPrinter
-{
- /**
- * Check for the --help, -help and -? keys. If one is found, print help and
- * exit the program.
- *
- * @param args the program arguments.
- * @param helpResourcePath the path to the help resource, related to the
- * HelpPrinter class.
- */
- public static void checkHelpKey(String[] args, String helpResourcePath)
- {
- for (int i = 0; i < args.length; i++)
- {
- String a = args[i];
- if (a.equals("-?") || a.equalsIgnoreCase("-help")
- || a.equalsIgnoreCase("--help"))
- printHelpAndExit(helpResourcePath);
- }
- }
-
- /**
- * Prints the contents of the resource specified by the designated path.
- *
- * @param helpResourcePath the path to a help resource, related to the
- * HelpPrinter class.
- */
- public static void printHelp(String helpResourcePath)
- {
- InputStream in = HelpPrinter.class.getResourceAsStream(helpResourcePath);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- try
- {
- String s;
- while ((s = br.readLine()) != null)
- System.out.println(s);
- }
- catch (IOException x)
- {
- System.err.print("Resource loading is broken:");
- x.printStackTrace(System.err);
- }
- finally
- {
- try
- {
- br.close();
- }
- catch (IOException ignored)
- {
- }
- }
- }
-
- /**
- * Prints the help message and terminates.
- *
- * @param helpResourcePath the path to the help resource, related to the
- * HelpPrinter class.
- */
- public static void printHelpAndExit(String helpResourcePath)
- {
- printHelp(helpResourcePath);
- System.exit(0);
- }
-}
diff --git a/tools/gnu/classpath/tools/appletviewer/Main.java b/tools/gnu/classpath/tools/appletviewer/Main.java
index 1d9fed2b0..b22368003 100644
--- a/tools/gnu/classpath/tools/appletviewer/Main.java
+++ b/tools/gnu/classpath/tools/appletviewer/Main.java
@@ -37,17 +37,19 @@ exception statement from your version. */
package gnu.classpath.tools.appletviewer;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
import gnu.classpath.tools.getopt.Parser;
import java.applet.Applet;
import java.awt.Dimension;
+import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -249,6 +251,7 @@ class Main
if (pluginMode)
{
+ // Plugin will warn user about missing security manager.
InputStream in;
OutputStream out;
@@ -259,6 +262,33 @@ class Main
}
else
{
+ // Warn user about missing security manager.
+ System.err.println("WARNING: CURRENTLY GAPPLETVIEWER RUNS WITH NO SECURITY MANAGER.\n\n"
+ + "THIS MEANS THAT APPLETS YOU LOAD CAN DO ANYTHING A JAVA APPLICATION\n"
+ + "THAT YOU DOWNLOAD AND RUN CAN DO. BE *VERY* CAREFUL WHICH APPLETS YOU RUN.\n"
+ + "DO NOT USE GAPPLETVIEWER ON YOUR SYSTEM IF YOUR SYSTEM STORES IMPORTANT DATA.\n"
+ + "THIS DATA CAN BE DESTROYED OR STOLEN IF YOU LOAD A MALICIOUS APPLET.\n");
+
+ System.err.println("[press 'c' or 'C' to continue or anything else to quit]");
+
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ String response = null;
+
+ try
+ {
+ response = stdin.readLine();
+ }
+ catch (IOException e)
+ {
+ System.err.println("failed to read response to warning message: " + e);
+ System.exit(1);
+ }
+
+ if (!(response.equals("c") || response.equals("C")))
+ {
+ System.exit(0);
+ }
+
if (code == null)
{
// The --code option wasn't given and there are no URL
diff --git a/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java b/tools/gnu/classpath/tools/common/ClasspathToolParser.java
index e712056ef..e44b9011c 100644
--- a/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
+++ b/tools/gnu/classpath/tools/common/ClasspathToolParser.java
@@ -36,11 +36,14 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath.tools.getopt;
+package gnu.classpath.tools.common;
import java.text.MessageFormat;
import gnu.classpath.Configuration;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
/**
* This is like the Parser class, but is specialized for use by
@@ -63,11 +66,22 @@ public class ClasspathToolParser
public ClasspathToolParser(String programName)
{
- super(programName, getVersionString(programName));
+ this(programName, false);
}
public ClasspathToolParser(String programName, boolean longOnly)
{
super(programName, getVersionString(programName), longOnly);
+ addFinal(new Option('J',
+ Messages.getString("ClasspathToolParser.JArgument"),//$NON-NLS-1$
+ Messages.getString("ClasspathToolParser.JName"), //$NON-NLS-1$
+ true)
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ // -J should be handled by the wrapper binary.
+ // We add it here so that it shows up in the --help output.
+ }
+ });
}
}
diff --git a/tools/gnu/classpath/tools/common/Messages.java b/tools/gnu/classpath/tools/common/Messages.java
new file mode 100644
index 000000000..1c92d348d
--- /dev/null
+++ b/tools/gnu/classpath/tools/common/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- i18n support for tools common code
+ 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.common;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.common.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/rmi/Persistent.java b/tools/gnu/classpath/tools/common/Persistent.java
index 5cd1efe91..5a2b48a8d 100644
--- a/tools/gnu/classpath/tools/rmi/Persistent.java
+++ b/tools/gnu/classpath/tools/common/Persistent.java
@@ -35,7 +35,7 @@ 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.rmi;
+package gnu.classpath.tools.common;
import java.util.Timer;
import java.util.TimerTask;
diff --git a/tools/gnu/classpath/tools/getopt/Messages.java b/tools/gnu/classpath/tools/getopt/Messages.java
index 3c963d786..19f101743 100644
--- a/tools/gnu/classpath/tools/getopt/Messages.java
+++ b/tools/gnu/classpath/tools/getopt/Messages.java
@@ -41,7 +41,7 @@ package gnu.classpath.tools.getopt;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-public class Messages
+class Messages
{
private static final String BUNDLE_NAME
= "gnu.classpath.tools.getopt.Messages"; //$NON-NLS-1$
diff --git a/tools/gnu/classpath/tools/getopt/Option.java b/tools/gnu/classpath/tools/getopt/Option.java
index 6f775e4a1..53255811e 100644
--- a/tools/gnu/classpath/tools/getopt/Option.java
+++ b/tools/gnu/classpath/tools/getopt/Option.java
@@ -44,7 +44,10 @@ package gnu.classpath.tools.getopt;
* like '--verbose'; if the parser is working in "long option only" mode, then a
* long flag has a single dash, like '-verbose'. Both a long and a short form
* may be specified; it is not valid to have neither. A description is mandatory
- * for options; this is used to automatically generate '--help' output.
+ * for options; this is used to automatically generate '--help' output. An option
+ * which takes an argument and which has a short form can also be "joined", in
+ * this case the option's argument can either be separated, like "-I path" or
+ * joined with the short option name, like "-Ipath".
*/
public abstract class Option
{
@@ -56,6 +59,8 @@ public abstract class Option
private String argumentName;
+ private boolean joined;
+
/**
* Create a new option with the given short name and description.
*
@@ -64,6 +69,8 @@ public abstract class Option
*/
protected Option(char shortName, String description)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.description = description;
}
@@ -78,12 +85,34 @@ public abstract class Option
*/
protected Option(char shortName, String description, String argumentName)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.description = description;
this.argumentName = argumentName;
}
/**
+ * Create a new option with the given short name and description.
+ *
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ * @param joined true if the short option is joined to its argument
+ */
+ protected Option(char shortName, String description, String argumentName,
+ boolean joined)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.description = description;
+ this.argumentName = argumentName;
+ this.joined = joined;
+ }
+
+ /**
* Create a new option with the given long name and description. The long name
* should be specified without any leading dashes.
*
@@ -122,6 +151,8 @@ public abstract class Option
*/
protected Option(String longName, char shortName, String description)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.longName = longName;
this.description = description;
@@ -140,10 +171,35 @@ public abstract class Option
protected Option(String longName, char shortName, String description,
String argumentName)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.longName = longName;
+ this.argumentName = argumentName;
+ this.description = description;
+ }
+
+ /**
+ * Create a new option with the given short and long names and description.
+ * The long name should be specified without any leading dashes.
+ *
+ * @param longName the long name
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ * @param joined true if the short option is joined to its argument
+ */
+ protected Option(String longName, char shortName, String description,
+ String argumentName, boolean joined)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.longName = longName;
this.argumentName = argumentName;
this.description = description;
+ this.joined = joined;
}
/**
@@ -188,6 +244,16 @@ public abstract class Option
}
/**
+ * Return true if this is a "joined" option, false otherwise.
+ * Only the short form of an option can be joined; this will always
+ * return false for an option which does not have a short form.
+ */
+ public boolean isJoined()
+ {
+ return joined;
+ }
+
+ /**
* This is called by the parser when this option is recognized. It may be
* called multiple times during a single parse. If this option takes an
* argument, the argument will be passed in. Otherwise the argument will be
diff --git a/tools/gnu/classpath/tools/getopt/OptionGroup.java b/tools/gnu/classpath/tools/getopt/OptionGroup.java
index f7d966d94..63853b2d0 100644
--- a/tools/gnu/classpath/tools/getopt/OptionGroup.java
+++ b/tools/gnu/classpath/tools/getopt/OptionGroup.java
@@ -231,10 +231,7 @@ public class OptionGroup
{
if (argName != null)
{
- // This is a silly hack just for '-J'. We don't
- // support joined options in general, but this option
- // is filtered out before argument processing can see it.
- if (option.getShortName() != 'J')
+ if (! option.isJoined())
{
out.print(' ');
++column;
diff --git a/tools/gnu/classpath/tools/getopt/Parser.java b/tools/gnu/classpath/tools/getopt/Parser.java
index 3c6cf6f46..b142836a5 100644
--- a/tools/gnu/classpath/tools/getopt/Parser.java
+++ b/tools/gnu/classpath/tools/getopt/Parser.java
@@ -72,6 +72,8 @@ public class Parser
private OptionGroup defaultGroup = new OptionGroup();
+ private OptionGroup finalGroup;
+
// These are used while parsing.
private int currentIndex;
@@ -166,7 +168,7 @@ public class Parser
this.longOnly = longOnly;
// Put standard options in their own section near the end.
- OptionGroup finalGroup = new OptionGroup(Messages.getString("Parser.StdOptions")); //$NON-NLS-1$
+ finalGroup = new OptionGroup(Messages.getString("Parser.StdOptions")); //$NON-NLS-1$
finalGroup.add(new Option("help", Messages.getString("Parser.PrintHelp")) //$NON-NLS-1$ //$NON-NLS-2$
{
public void parsed(String argument) throws OptionException
@@ -183,15 +185,6 @@ public class Parser
System.exit(0);
}
});
- finalGroup.add(new Option('J', Messages.getString("Parser.JArgument"), Messages.getString("Parser.JName")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- public void parsed(String argument) throws OptionException
- {
- // -J should be handled by the appletviewer wrapper binary.
- // We add it here so that it shows up in the --help output.
- // Note that there is a special case for this in OptionGroup.
- }
- });
add(finalGroup);
add(defaultGroup);
@@ -230,6 +223,18 @@ public class Parser
}
/**
+ * This is like {@link #add(Option)}, but adds the option to the "final"
+ * group. This should be used sparingly, if at all; it is intended for
+ * other very generic options like --help or --version.
+ * @param opt the option to add
+ */
+ protected synchronized void addFinal(Option opt)
+ {
+ options.add(opt);
+ finalGroup.add(opt);
+ }
+
+ /**
* Add an option group to this parser. All the options in this group will be
* recognized by the parser.
*
@@ -314,11 +319,10 @@ public class Parser
String option = real.substring(index);
String justName = option;
int eq = option.indexOf('=');
- if (eq != - 1)
+ if (eq != -1)
justName = option.substring(0, eq);
- char shortName = 0;
- if (justName.length() == 1)
- shortName = justName.charAt(0);
+ boolean isPlainShort = justName.length() == 1;
+ char shortName = justName.charAt(0);
Option found = null;
for (int i = options.size() - 1; i >= 0; --i)
{
@@ -328,8 +332,14 @@ public class Parser
found = opt;
break;
}
- if (shortName != 0 && opt.getShortName() == shortName)
+ if ((isPlainShort || opt.isJoined())
+ && opt.getShortName() == shortName)
{
+ if (! isPlainShort)
+ {
+ // The rest of the option string is the argument.
+ eq = 0;
+ }
found = opt;
break;
}
@@ -343,7 +353,7 @@ public class Parser
String argument = null;
if (found.getTakesArgument())
{
- if (eq == - 1)
+ if (eq == -1)
argument = getArgument(real);
else
argument = option.substring(eq + 1);
@@ -358,35 +368,42 @@ public class Parser
found.parsed(argument);
}
- private void handleShortOption(char option) throws OptionException
+ private void handleShortOptions(String option) throws OptionException
{
- Option found = null;
- for (int i = options.size() - 1; i >= 0; --i)
+ for (int charIndex = 1; charIndex < option.length(); ++charIndex)
{
- Option opt = (Option) options.get(i);
- if (option == opt.getShortName())
+ char optChar = option.charAt(charIndex);
+ Option found = null;
+ for (int i = options.size() - 1; i >= 0; --i)
{
- found = opt;
- break;
+ Option opt = (Option) options.get(i);
+ if (optChar == opt.getShortName())
+ {
+ found = opt;
+ break;
+ }
}
- }
- if (found == null)
- {
- String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
- new Object[] { "" + option }); //$NON-NLS-1$
- throw new OptionException(msg);
- }
- String argument = null;
- if (found.getTakesArgument())
- argument = getArgument("-" + option); //$NON-NLS-1$
- found.parsed(argument);
- }
-
- private void handleShortOptions(String option) throws OptionException
- {
- for (int i = 1; i < option.length(); ++i)
- {
- handleShortOption(option.charAt(i));
+ if (found == null)
+ {
+ String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
+ new Object[] { "" + optChar }); //$NON-NLS-1$
+ throw new OptionException(msg);
+ }
+ String argument = null;
+ if (found.getTakesArgument())
+ {
+ // If this is a joined short option, and there are more
+ // characters left in this argument, use those as the
+ // argument.
+ if (found.isJoined() && charIndex + 1 < option.length())
+ {
+ argument = option.substring(charIndex + 1);
+ charIndex = option.length();
+ }
+ else
+ argument = getArgument("-" + optChar); //$NON-NLS-1$
+ }
+ found.parsed(argument);
}
}
diff --git a/tools/gnu/classpath/tools/giop/GRMIC.java b/tools/gnu/classpath/tools/giop/GRMIC.java
deleted file mode 100644
index c910d7083..000000000
--- a/tools/gnu/classpath/tools/giop/GRMIC.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/* GRMIC.java -- GIOP support for RMIC.
- 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.
-*/
-
-package gnu.classpath.tools.giop;
-
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.giop.grmic.GiopRmicCompiler;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * The main class of the GIOP compiler to generate stubs and ties for
- * javax.rmi package.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class GRMIC
-{
- /**
- * The version of the compiler.
- */
- public static String VERSION = "0.0 alpha pre";
-
- /**
- * The GRMIC compiler methods
- *
- * @param args the compiler parameters.
- */
- public static void main(String[] args)
- {
- boolean noWrite = false;
- boolean verbose = false;
-
- String HelpPath = "giop/GRMIC.txt";
-
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- File output = new File(".");
-
- if (args.length == 0)
- {
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else
- {
- GiopRmicCompiler compiler = new GiopRmicCompiler();
-
- int cl = - 1;
-
- Options: for (int i = 0; i < args.length; i++)
- {
- String c = args[i];
- if (c.equals("-poa"))
- compiler.setPoaMode(true);
- else if (c.equals("-impl"))
- compiler.setPoaMode(false);
- else if (c.equals("-v"))
- {
- printVersion();
- System.exit(0);
- }
- else if (c.equals("-nowrite"))
- noWrite = true;
- else if (c.equals("-nowarn"))
- compiler.setWarnings(false);
- else if (c.equals("-verbose"))
- {
- verbose = true;
- compiler.setVerbose(true);
- }
- else if (c.equals("-force"))
- {
- compiler.setForce(true);
- }
- else if (c.equals("-d"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- output = new File(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.equals("-classpath"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- compiler.setClassPath(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.charAt(0) != '-')
- // No more options - start of class list.
- {
- cl = i;
- break Options;
- }
- }
-
- if (cl < 0)
- HelpPrinter.printHelpAndExit(HelpPath);
-
- if (verbose)
- System.out.println("Compiling to " + output.getAbsolutePath());
-
- // Compile classes
- Compile: for (int i = cl; i < args.length; i++)
- {
- if (args[i].charAt(0) != '-')
- {
- compiler.reset();
- Class c = compiler.loadClass(args[i]);
-
- compiler.compile(c);
- String packag = compiler.getPackageName().replace('.', '/');
- File fw = new File(output, packag);
-
- // Generate stub.
- String stub = compiler.generateStub();
- String subName = "_" + compiler.getStubName() + "_Stub.java";
-
- compiler.reset();
- compiler.compile(c);
-
- // Generate tie
- String tie = compiler.generateTie();
- String tieName = "_" + compiler.name(c) + "_Tie.java";
-
- if (noWrite)
- continue Compile;
-
- try
- {
- fw.mkdirs();
- OutputStream out = new FileOutputStream(new File(fw,
- subName));
- out.write(stub.getBytes());
- out.close();
-
- out = new FileOutputStream(new File(fw, tieName));
- out.write(tie.getBytes());
- out.close();
- }
- catch (IOException ioex)
- {
- System.err.println("Output path not accessible");
- ioex.printStackTrace();
- System.exit(1);
- }
- }
- }
- }
- }
-
- /**
- * Print the version information.
- */
- public static void printVersion()
- {
- System.out.println
- ("grmic v "+VERSION+" - GIOP stub and tie generator for javax.rmi.* ");
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/GRMIC.txt b/tools/gnu/classpath/tools/giop/GRMIC.txt
deleted file mode 100644
index 875bcdbcf..000000000
--- a/tools/gnu/classpath/tools/giop/GRMIC.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-GIOP stub and tie generator source code generator for javax.rmi.*, omg.org.*
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: grmic <options> <class names>
-
- where <options> includes:
- -poa Generate the Servant based ties (default)
- -impl Generate the obsoleted ObjectImpl based ties
- (for backward compatibility)
- -nowarn Show no warnings
- -nowrite Do not write any files (check for errors only)
- -d <folder> Place generated files into the given folder
- -classpath <path> Specifies the path, where to find the classes being
- compiled
-
- -help Print this help text
- -v Print version
- -verbose Verbose output
- -force Try to generate code even if the input classes seem not
- consistent with RMI specification.
-
-
- and <class names> can include one or more non abstract classes that implement
- Remote and are accessible via current class path.
-
-* This tool generates the source code that must be compiled with java compiler.
-* GRMIC is invoked from RMIC if the -iiop or -giop keys are specified.
-
diff --git a/tools/gnu/classpath/tools/giop/IorParser.java b/tools/gnu/classpath/tools/giop/IorParser.java
deleted file mode 100644
index 411b8997d..000000000
--- a/tools/gnu/classpath/tools/giop/IorParser.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/* IorParser.java -- IOR parser.
- 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.
-*/
-
-
-package gnu.classpath.tools.giop;
-
-import gnu.CORBA.IOR;
-import gnu.classpath.tools.HelpPrinter;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.omg.CORBA.BAD_PARAM;
-
-/**
- * Parses the information, encoded in the Interoperable Object References
- * (IORs).
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class IorParser
-{
- /**
- * Parse and print IOR reference. The system exit code is 0 if the parsed
- * IOR was correct, 1 if it was invalid or missing.
- *
- * @param args supports -f file to read IOR from the file.
- */
- public static void main(String[] args)
- {
- boolean ok = false;
- String HelpResource = "giop/IorParser.txt";
- HelpPrinter.checkHelpKey(args, HelpResource);
- if (args.length == 0)
- HelpPrinter.printHelpAndExit(HelpResource);
- else if (args[0].equals("-f") && args.length==2)
- {
- File file = new File(args[1]);
- if (!file.exists())
- System.err.println("The file "+file.getAbsolutePath()+" is missing.");
- // Read IOR reference from file.
- String ior = null;
- try
- {
- FileReader fr = new FileReader(file);
- BufferedReader br = new BufferedReader(fr);
- ior = br.readLine();
- br.close();
- ok = parseAndPrint(ior);
- }
- catch (IOException e)
- {
- System.err.print("Unable to read the file "+file);
- e.printStackTrace();
- }
-
- }
- else if (args.length == 1)
- ok = parseAndPrint(args[0]);
- else
- HelpPrinter.printHelpAndExit(HelpResource);
-
- if (ok)
- System.exit(0);
- else
- System.exit(1);
- }
-
- /**
- * Parse and print IOR.
- *
- * @param ior the IOR string to anlyse.
- * @return true if the passed value is a valid IOR, false otherwise.
- */
- public static boolean parseAndPrint(String ior)
- {
- try
- {
- IOR gior = IOR.parse(ior);
- System.out.println(gior.toStringFormatted());
- return true;
- }
- catch (BAD_PARAM e)
- {
- System.out.println("Invalid ior: "+e.getMessage());
- return false;
- }
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/IorParser.txt b/tools/gnu/classpath/tools/giop/IorParser.txt
deleted file mode 100644
index 3b04224f1..000000000
--- a/tools/gnu/classpath/tools/giop/IorParser.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-IOR (interoperable GIOP object reference) parser,
- usage: IorParser -f ior_file
- or: IorParser -f ior_string
-
diff --git a/tools/gnu/classpath/tools/giop/NameServicePersistent.txt b/tools/gnu/classpath/tools/giop/NameServicePersistent.txt
deleted file mode 100644
index 3de15f62a..000000000
--- a/tools/gnu/classpath/tools/giop/NameServicePersistent.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-GNU Classpath GIOP persitent naming service.
- usage: NameServicePersistent <options>
-
- where <options> includes:
-* -org.omg.CORBA.ORBInitialPort NNN
- or -ORBInitialPort NNN - specifies the port, on that the
- service must be started. If this key
- is not specified, the service starts
- at the port 900.
-
-* -ior FILE_NAME - store the IOR reference to this naming
- service to the specified file. The
- IOR reference contains enough
- information to locate the service
- on the web.
-* - folder FOLDER - store the persistent information
- to the given folder
-* - reset - discard any previously stored
- persistent information (cold start)
-
-
-
diff --git a/tools/gnu/classpath/tools/giop/NamingService.txt b/tools/gnu/classpath/tools/giop/NamingService.txt
deleted file mode 100644
index f57e4ac66..000000000
--- a/tools/gnu/classpath/tools/giop/NamingService.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-GNU Classpath GIOP naming service, usage: NameService <options>
-
- where <options> includes:
-* -org.omg.CORBA.ORBInitialPort NNN or
-* -ORBInitialPort NNN - specifies the port, on that the
- service must be started. If this key
- is not specified, the service starts
- at the port 900.
-
-* -ior FILE_NAME - store the IOR reference to this naming
- service to the specified file. The
- IOR reference contains enough
- information to locate the service
- on the web.
-
diff --git a/tools/gnu/classpath/tools/giop/README b/tools/gnu/classpath/tools/giop/README
deleted file mode 100644
index 94fc2f158..000000000
--- a/tools/gnu/classpath/tools/giop/README
+++ /dev/null
@@ -1,19 +0,0 @@
-This package defines GIOP tools for creating the applications that use this
-protocol. It provides necessary support for org.omg.* and javax.rmi.*
-packages.
-
-All GIOP tools support the --help option.
-
-The list of the currently available tools:
-
-* GRMIC - RMI-IIOP stub and tie generator.
-* NameService - GIOP transient naming service (this tool is called
- tnameserv in Sun's package).
-* NameServicePersistent
- - GIOP persistent naming service (this tool is called
- orbd in Sun's package).
-* IorParser - Parses the stringified form of the interoperable
- object references (IOR's).
-* RMIC - RMI stub and tie source code generator (complements
- the ASM based bytecode generator in the separate
- tools package). \ No newline at end of file
diff --git a/tools/gnu/classpath/tools/jar/Main.java b/tools/gnu/classpath/tools/jar/Main.java
index 8ea770bb6..34f637204 100644
--- a/tools/gnu/classpath/tools/jar/Main.java
+++ b/tools/gnu/classpath/tools/jar/Main.java
@@ -38,7 +38,7 @@
package gnu.classpath.tools.jar;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/jarsigner/Main.java b/tools/gnu/classpath/tools/jarsigner/Main.java
index b6b50e741..0cff2fd85 100644
--- a/tools/gnu/classpath/tools/jarsigner/Main.java
+++ b/tools/gnu/classpath/tools/jarsigner/Main.java
@@ -41,8 +41,8 @@ package gnu.classpath.tools.jarsigner;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.classpath.tools.common.CallbackUtil;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.common.ProviderUtil;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/javah/CniIncludePrinter.java b/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
index 6561169bb..fb007b131 100644
--- a/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
+++ b/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
@@ -46,24 +46,35 @@ import java.io.PrintStream;
public class CniIncludePrinter
extends Printer
{
+ protected CniIncludePrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
- protected CniIncludePrinter(Main classpath)
+ protected void writePreambleImpl(PrintStream ps)
{
- super(classpath);
+ // does nothing
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new PrintStream(fos);
+ }
+
+ public void printClass(ClassWrapper klass) throws IOException
{
// Never write Object or Class. This is a hack, maybe
// the user would like to see what they look like...
if (klass.name.equals("java/lang/Object")
|| klass.name.equals("java/lang/Class"))
return;
- File klassFile = new File(outputDir, klass.name + ".h");
- klassFile.getParentFile().mkdirs();
- PrintStream ps = new PrintStream(new FileOutputStream(klassFile));
+ PrintStream ps = getPrintStream(klass.name + ".h", klass);
+ if (ps == null)
+ return;
+ ps.println();
klass.printFully(ps);
ps.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/CniStubPrinter.java b/tools/gnu/classpath/tools/javah/CniStubPrinter.java
index 9732e2941..d91f367c4 100644
--- a/tools/gnu/classpath/tools/javah/CniStubPrinter.java
+++ b/tools/gnu/classpath/tools/javah/CniStubPrinter.java
@@ -41,6 +41,7 @@ package gnu.classpath.tools.javah;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.Iterator;
@@ -50,10 +51,10 @@ import org.objectweb.asm.tree.MethodNode;
public class CniStubPrinter
extends Printer
{
-
- protected CniStubPrinter(Main classpath)
+ protected CniStubPrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
{
- super(classpath);
+ super(classpath, outFile, isDir, force);
}
private void printDecl(CniPrintStream out, String className, MethodNode method)
@@ -72,24 +73,34 @@ public class CniStubPrinter
out.print(")");
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ protected void writePreambleImpl(PrintStream out)
{
- if (! klass.hasNativeMethod())
- return;
- File klassFile = new File(outputDir, klass.name + ".cc");
- klassFile.getParentFile().mkdirs();
- String className = klass.name.replaceAll("/", "::");
-
- CniPrintStream out = new CniPrintStream(new FileOutputStream(klassFile));
out.println("// This file is intended to give you a head start on implementing native");
out.println("// methods using CNI.");
out.println("// Be aware: running 'gcjh -stubs' once more for this class may");
out.println("// overwrite any edits you have made to this file.");
out.println();
-
- out.println("#include <" + klass.name + ".h>");
out.println("#include <gcj/cni.h>");
out.println("#include <java/lang/UnsupportedOperationException.h>");
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new CniPrintStream(fos);
+ }
+
+ public void printClass(ClassWrapper klass) throws IOException
+ {
+ if (! klass.hasNativeMethod())
+ return;
+ String className = klass.name.replaceAll("/", "::");
+ CniPrintStream out = (CniPrintStream) getPrintStream(klass.name + ".cc",
+ klass);
+ if (out == null)
+ return;
+ out.println();
+ out.println("#include <" + klass.name + ".h>");
out.println();
Iterator i = klass.methods.iterator();
@@ -115,5 +126,4 @@ public class CniStubPrinter
}
out.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/FieldHelper.java b/tools/gnu/classpath/tools/javah/FieldHelper.java
index ecc82e3c1..a9385e04d 100644
--- a/tools/gnu/classpath/tools/javah/FieldHelper.java
+++ b/tools/gnu/classpath/tools/javah/FieldHelper.java
@@ -52,6 +52,8 @@ public class FieldHelper
out.print(" ");
if (Modifier.isStatic(field.access))
out.print("static ");
+ if (Modifier.isVolatile(field.access))
+ out.print("volatile ");
if ((field.value instanceof Integer) || (field.value instanceof Long))
out.print("const ");
out.print(Type.getType(field.desc));
diff --git a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
index c01634007..3d88650c1 100644
--- a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
@@ -41,6 +41,7 @@ package gnu.classpath.tools.javah;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.Iterator;
@@ -51,10 +52,10 @@ import org.objectweb.asm.tree.MethodNode;
public class JniIncludePrinter
extends Printer
{
-
- protected JniIncludePrinter(Main classpath)
+ protected JniIncludePrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
{
- super(classpath);
+ super(classpath, outFile, isDir, force);
}
private void writeFields(ClassWrapper klass, JniPrintStream out)
@@ -93,17 +94,27 @@ public class JniIncludePrinter
out.println();
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ protected void writePreambleImpl(PrintStream out)
+ {
+ out.println("/* DO NOT EDIT THIS FILE - it is machine generated */");
+ out.println();
+ out.println("#include <jni.h>");
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new JniPrintStream(classpath, fos, klass);
+ }
+
+ public void printClass(ClassWrapper klass) throws IOException
{
if (! klass.hasNativeMethod())
return;
String xname = JniHelper.mangle(klass.name);
- File outFile = new File(outputDir, xname + ".h");
-
- JniPrintStream out = new JniPrintStream(classpath,
- new FileOutputStream(outFile),
- klass);
- out.println("/* DO NOT EDIT THIS FILE - it is machine generated */");
+ JniPrintStream out = (JniPrintStream) getPrintStream(xname + ".h", klass);
+ if (out == null)
+ return;
out.println();
out.print("#ifndef __");
out.print(xname);
@@ -112,8 +123,6 @@ public class JniIncludePrinter
out.print(xname);
out.println("__");
out.println();
- out.println("#include <jni.h>");
- out.println();
out.println("#ifdef __cplusplus");
out.println("extern \"C\"");
out.println("{");
@@ -144,8 +153,6 @@ public class JniIncludePrinter
out.print("#endif /* __");
out.print(xname);
out.println("__ */");
-
out.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/JniStubPrinter.java b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
index d590a5cd1..0bc11873f 100644
--- a/tools/gnu/classpath/tools/javah/JniStubPrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
@@ -41,6 +41,7 @@ package gnu.classpath.tools.javah;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.Iterator;
@@ -50,26 +51,34 @@ import org.objectweb.asm.tree.MethodNode;
public class JniStubPrinter
extends Printer
{
+ protected JniStubPrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
+
+ protected void writePreambleImpl(PrintStream out)
+ {
+ out.println("/* This file is intended to give you a head start on implementing native");
+ out.println(" methods using JNI.");
+ out.println(" Be aware: running gcjh or compatible tool with '-stubs' option once more");
+ out.println(" for the same input may overwrite any edits you have made to this file. */");
+ }
- protected JniStubPrinter(Main classpath)
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
{
- super(classpath);
+ return new JniPrintStream(classpath, fos, klass);
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ public void printClass(ClassWrapper klass) throws IOException
{
if (! klass.hasNativeMethod())
return;
String xname = JniHelper.mangle(klass.name);
- File outFile = new File(outputDir, xname + ".c");
-
- JniPrintStream out = new JniPrintStream(classpath,
- new FileOutputStream(outFile),
- klass);
- out.println("/* This file is intended to give you a head start on implementing native");
- out.println(" methods using CNI.");
- out.println(" Be aware: running 'gcjh -stubs' once more for this class may");
- out.println(" overwrite any edits you have made to this file. */");
+ JniPrintStream out = (JniPrintStream) getPrintStream(xname + ".c", klass);
+ if (out == null)
+ return;
out.println();
out.print("#include <");
out.print(xname);
@@ -94,5 +103,4 @@ public class JniStubPrinter
}
out.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/Main.java b/tools/gnu/classpath/tools/javah/Main.java
index f342d4ae1..2cddbaae7 100644
--- a/tools/gnu/classpath/tools/javah/Main.java
+++ b/tools/gnu/classpath/tools/javah/Main.java
@@ -38,7 +38,7 @@
package gnu.classpath.tools.javah;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.Parser;
@@ -70,6 +70,9 @@ public class Main
// The output directory.
String outputDir;
+ // The output file name used if/when -o option is used.
+ String outFileName;
+
// The loader that we use to load class files.
URLClassLoader loader;
@@ -85,6 +88,9 @@ public class Main
// True if we're emitting CNI code.
boolean cni;
+ // True if output files should always be written.
+ boolean force;
+
// Map class names to class wrappers.
HashMap classMap = new HashMap();
@@ -184,9 +190,24 @@ public class Main
{
if (outputDir != null)
throw new OptionException("-d already seen");
+ if (outFileName != null)
+ throw new OptionException("only one of -d or -o may be used");
outputDir = dir;
}
});
+ result.add(new Option('o',
+ "Set output file (only one of -d or -o may be used)",
+ "FILE")
+ {
+ public void parsed(String fileName) throws OptionException
+ {
+ if (outFileName != null)
+ throw new OptionException("-o already seen");
+ if (outputDir != null)
+ throw new OptionException("only one of -d or -o may be used");
+ outFileName = fileName;
+ }
+ });
result.add(new Option("cmdfile", "Read command file", "FILE")
{
public void parsed(String file) throws OptionException
@@ -212,6 +233,15 @@ public class Main
stubs = true;
}
});
+ result.add(new Option("jni", "Emit JNI stubs or header (default)")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ if (cni)
+ throw new OptionException("only one of -jni or -cni may be used");
+ cni = false;
+ }
+ });
result.add(new Option("cni", "Emit CNI stubs or header (default JNI)")
{
public void parsed(String arg0) throws OptionException
@@ -226,6 +256,13 @@ public class Main
verbose = true;
}
});
+ result.add(new Option("force", "Output files should always be written")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ force = true;
+ }
+ });
return result;
}
@@ -235,15 +272,40 @@ public class Main
if (outputDir == null)
outputFile = new File(".");
else
+ outputFile = new File(outputDir);
+ return outputFile;
+ }
+
+ /**
+ * @return The {@link File} object where the generated code will be written.
+ * Returns <code>null</code> if the option <code>-force</code> was
+ * specified on the command line and the designated file already
+ * exists.
+ * @throws IOException if <code>outFileName</code> is not a writable file.
+ */
+ private File makeOutputFile() throws IOException
+ {
+ File result = new File(outFileName);
+ if (result.exists())
{
- outputFile = new File(outputDir);
- outputFile.mkdirs();
+ if (! result.isFile())
+ throw new IOException("'" + outFileName + "' is not a file");
+ if (! force)
+ {
+ if (verbose)
+ System.err.println("["+ outFileName
+ + " already exists. Use -force to overwrite]");
+ return null;
+ }
+ if (! result.delete())
+ throw new IOException("Was unable to delete existing file: "
+ + outFileName);
}
- return outputFile;
+ return result;
}
- private void writeHeaders(ArrayList klasses, Printer printer,
- File outputDirFile) throws IOException
+ private void writeHeaders(ArrayList klasses, Printer printer)
+ throws IOException
{
Iterator i = klasses.iterator();
while (i.hasNext())
@@ -251,7 +313,7 @@ public class Main
ClassWrapper klass = (ClassWrapper) i.next();
if (verbose)
System.err.println("[writing " + klass + "]");
- printer.printClass(outputDirFile, klass);
+ printer.printClass(klass);
}
}
@@ -261,21 +323,25 @@ public class Main
String[] classNames = p.parse(args);
loader = classpath.getLoader();
- File outputFile = makeOutputDirectory();
+ boolean isDirectory = outFileName == null;
+ File outputFile = isDirectory ? makeOutputDirectory() : makeOutputFile();
+ if (outputFile == null)
+ return;
+
Printer printer;
if (! cni)
{
if (stubs)
- printer = new JniStubPrinter(this);
+ printer = new JniStubPrinter(this, outputFile, isDirectory, force);
else
- printer = new JniIncludePrinter(this);
+ printer = new JniIncludePrinter(this, outputFile, isDirectory, force);
}
else
{
if (stubs)
- printer = new CniStubPrinter(this);
+ printer = new CniStubPrinter(this, outputFile, isDirectory, force);
else
- printer = new CniIncludePrinter(this);
+ printer = new CniIncludePrinter(this, outputFile, isDirectory, force);
}
// First we load all of the files. That way if
@@ -324,7 +390,7 @@ public class Main
results.add(klass);
}
- writeHeaders(results, printer, outputFile);
+ writeHeaders(results, printer);
}
public ArrayList getClassTextList(String name)
diff --git a/tools/gnu/classpath/tools/javah/PathOptionGroup.java b/tools/gnu/classpath/tools/javah/PathOptionGroup.java
index f11077fa0..4287354ae 100644
--- a/tools/gnu/classpath/tools/javah/PathOptionGroup.java
+++ b/tools/gnu/classpath/tools/javah/PathOptionGroup.java
@@ -96,7 +96,7 @@ public class PathOptionGroup
setPath(classpath, path);
}
});
- add(new Option('I', "Add directory to class path", "DIR")
+ add(new Option('I', "Add directory to class path", "DIR", true)
{
public void parsed(String path) throws OptionException
{
diff --git a/tools/gnu/classpath/tools/javah/Printer.java b/tools/gnu/classpath/tools/javah/Printer.java
index 0c25934e2..9c4b48d2e 100644
--- a/tools/gnu/classpath/tools/javah/Printer.java
+++ b/tools/gnu/classpath/tools/javah/Printer.java
@@ -39,17 +39,100 @@
package gnu.classpath.tools.javah;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
public abstract class Printer
{
protected Main classpath;
- protected Printer(Main classpath)
+ /**
+ * The {@link File} object that denotes either a directory (when the
+ * <code>-d</code> option was used), or a file (when the <code>-o</code>
+ * option was used) on the command line.
+ */
+ protected File outputFileObject;
+
+ /**
+ * Set to <code>true</code> if the field <code>outputFileObject</code> denotes
+ * a directory; i.e. for each input class file, one JNI header file will be
+ * generated in that directory.
+ * <p>
+ * Set to <code>false</code> if the field <code>outputFileObject</code>
+ * denotes a file; i.e. all generated headers will be written to that file.
+ */
+ protected boolean isDirectory;
+
+ /**
+ * Set to <code>true</code> if the output file(s) should always be written.
+ * <p>
+ * When set to <code>false</code>, the contents of the header/stub are only
+ * written to the file if it does not already exist.
+ */
+ protected boolean force;
+
+ /**
+ * Set to <code>true</code> if all output is directed to one file, and the
+ * common preamble text has already been generated.
+ */
+ protected boolean wrotePreamble;
+
+ protected Printer(Main classpath, File outFile, boolean isDir, boolean force)
{
this.classpath = classpath;
+ if (outFile == null)
+ throw new IllegalArgumentException("File argument MUST NOT be null");
+ outputFileObject = outFile;
+ isDirectory = isDir;
+ if (! isDirectory)
+ {
+ File parent = outputFileObject.getParentFile();
+ if (parent != null)
+ parent.mkdirs();
+ }
+ this.force = force;
+ }
+
+ public abstract void printClass(ClassWrapper klass) throws IOException;
+
+ protected abstract void writePreambleImpl(PrintStream ps);
+
+ protected abstract PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass);
+
+ protected PrintStream getPrintStream(String fullName, ClassWrapper klass)
+ throws FileNotFoundException
+ {
+ PrintStream result;
+ FileOutputStream fos;
+ if (isDirectory)
+ {
+ File outFile = new File(outputFileObject, fullName);
+ if (outFile.exists() && ! force)
+ return null;
+ File parent = outFile.getParentFile();
+ if (parent != null)
+ parent.mkdirs();
+ fos = new FileOutputStream(outFile);
+ result = getPrintStreamImpl(fos, klass);
+ writePreamble(result);
+ }
+ else
+ {
+ // the first time we open this file, wrotePreamble is false
+ fos = new FileOutputStream(outputFileObject, wrotePreamble);
+ result = getPrintStreamImpl(fos, klass);
+ if (! wrotePreamble)
+ writePreamble(result);
+ }
+ return result;
}
- public abstract void printClass(File outputDir, ClassWrapper klass)
- throws IOException;
+ protected void writePreamble(PrintStream out)
+ {
+ writePreambleImpl(out);
+ wrotePreamble = true;
+ }
}
diff --git a/tools/gnu/classpath/tools/keytool/CACertCmd.java b/tools/gnu/classpath/tools/keytool/CACertCmd.java
index 2bf832bee..a53a8b21a 100644
--- a/tools/gnu/classpath/tools/keytool/CACertCmd.java
+++ b/tools/gnu/classpath/tools/keytool/CACertCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/CertReqCmd.java b/tools/gnu/classpath/tools/keytool/CertReqCmd.java
index 692b1f690..bdf3aac8f 100644
--- a/tools/gnu/classpath/tools/keytool/CertReqCmd.java
+++ b/tools/gnu/classpath/tools/keytool/CertReqCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/DeleteCmd.java b/tools/gnu/classpath/tools/keytool/DeleteCmd.java
index 8107055d0..53611b21c 100644
--- a/tools/gnu/classpath/tools/keytool/DeleteCmd.java
+++ b/tools/gnu/classpath/tools/keytool/DeleteCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/ExportCmd.java b/tools/gnu/classpath/tools/keytool/ExportCmd.java
index 75f71801c..a07edc631 100644
--- a/tools/gnu/classpath/tools/keytool/ExportCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ExportCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
index e2048b223..79d3824af 100644
--- a/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
+++ b/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
index d0de589d9..ac0ee1329 100644
--- a/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
+++ b/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/ImportCmd.java b/tools/gnu/classpath/tools/keytool/ImportCmd.java
index 1eaf6b337..18a21aa68 100644
--- a/tools/gnu/classpath/tools/keytool/ImportCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ImportCmd.java
@@ -40,7 +40,7 @@ package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java b/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
index 81549864b..973ed46ce 100644
--- a/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
+++ b/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java b/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
index 89e6daa02..5f91becd9 100644
--- a/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
+++ b/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
@@ -40,7 +40,7 @@ package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/ListCmd.java b/tools/gnu/classpath/tools/keytool/ListCmd.java
index 61cec01a4..7579c3f85 100644
--- a/tools/gnu/classpath/tools/keytool/ListCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ListCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/Main.java b/tools/gnu/classpath/tools/keytool/Main.java
index 7c3ebd053..2d5234ad0 100644
--- a/tools/gnu/classpath/tools/keytool/Main.java
+++ b/tools/gnu/classpath/tools/keytool/Main.java
@@ -39,8 +39,8 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.common.ProviderUtil;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/PrintCertCmd.java b/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
index 2c5461b36..2100a6026 100644
--- a/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
+++ b/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/SelfCertCmd.java b/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
index 75f1e8299..f297046c7 100644
--- a/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
+++ b/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java b/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
index 1313ec6ab..489ecccb0 100644
--- a/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
+++ b/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
@@ -40,7 +40,7 @@ package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java b/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
index 9508c103e..622de6056 100644
--- a/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
+++ b/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
@@ -38,7 +38,7 @@
package gnu.classpath.tools.native2ascii;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/giop/NameServicePersistent.java b/tools/gnu/classpath/tools/orbd/Main.java
index df0c9539d..91c50d7f8 100644
--- a/tools/gnu/classpath/tools/giop/NameServicePersistent.java
+++ b/tools/gnu/classpath/tools/orbd/Main.java
@@ -35,23 +35,28 @@ 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.giop;
+package gnu.classpath.tools.orbd;
import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.NamingService.Ext;
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.giop.nameservice.PersistentContext;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
import org.omg.CosNaming.NamingContextExt;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
/**
- * The server for the gnu classpath persistent naming service.
+ * The server for the GNU Classpath persistent naming service.
*
* GNU Classpath currently works with this naming service and is also
* interoperable with the Sun Microsystems naming services from releases 1.3 and
@@ -59,7 +64,7 @@ import java.io.UnsupportedEncodingException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class NameServicePersistent
+public class Main
{
/**
* The default port (900), on that the naming service starts if no
@@ -67,6 +72,11 @@ public class NameServicePersistent
*/
public static final int PORT = 900;
+ private int port = PORT;
+ private String iorf;
+ private boolean cold;
+ private String directory = "";
+
/**
* Get the object key for the naming service. The default key is the string
* "NameService" in ASCII.
@@ -85,61 +95,74 @@ public class NameServicePersistent
}
}
- /**
- * Start the naming service on the current host at the given port. The
- * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
- * present, specifies the port, on that the service must be started. If this
- * key is not specified, the service starts at the port 900. The parameter
- * -ior FILE_NAME, if present, forces to store the ior string of this naming
- * service to the specified file.
- *
- * @param args the parameter string.
- */
- public static void main(String[] args)
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("orbd", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("ORBInitialPort", //$NON-NLS-1$
+ Messages.getString("Main.ORBInitialPort"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ parser.add(new Option("ior", //$NON-NLS-1$
+ Messages.getString("Main.IOR"), //$NON-NLS-1$
+ Messages.getString("Main.IORFile")) //$NON-NLS-1$
+ {
+ public void parsed(String fileArgument) throws OptionException
+ {
+ iorf = fileArgument;
+ }
+ });
+ parser.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ cold = true;
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
{
- HelpPrinter.checkHelpKey(args, "giop/NameServicePersistent.txt");
- System.out.println("Please use --help for options.");
+ Parser parser = initializeParser();
+ parser.parse(args);
- int port = PORT;
- String iorf = null;
- boolean reset = false;
- String folder = "";
try
{
// Create and initialize the ORB
final OrbFunctional orb = new OrbFunctional();
-
- for (int i = 0; i < args.length; i++)
- {
- if (i < args.length - 1)
- {
- if (args[i].endsWith("ORBInitialPort"))
- port = Integer.parseInt(args[i + 1]);
-
- if (args[i].equals("-ior"))
- iorf = args[i + 1];
-
- if (args[i].equals("-folder"))
- folder = args[i + 1];
- }
- if (args[i].equals("-reset"))
- reset = true;
- }
-
OrbFunctional.setPort(port);
// Create the servant and register it with the ORB
- File dataFolder = new File(folder);
+ File dataDirectory = new File(directory);
System.out.println("Persistent data stored at "
- + dataFolder.getAbsolutePath());
- dataFolder.mkdirs();
+ + dataDirectory.getAbsolutePath());
+ dataDirectory.mkdirs();
// / TODO support more starting modes.
NamingContextExt namer = new Ext(
new PersistentContext(
orb,
- dataFolder,
- reset));
+ dataDirectory,
+ cold));
// Case with the key "NameService".
orb.connect(namer, "NameService".getBytes());
@@ -173,14 +196,33 @@ public class NameServicePersistent
}
}.start();
}
- catch (Exception e)
+ catch (FileNotFoundException e)
{
- System.err.println("ERROR: " + e);
- e.printStackTrace(System.out);
+ throw new RuntimeException(e);
}
+ finally
+ {
+ // Restore the default value for allocating ports for the subsequent
+ // objects.
+ OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
+ }
+ }
- // Restore the default value for allocating ports for the subsequent
- // objects.
- OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
+ /**
+ * The persistent naming service entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main orbdprogram = new Main();
+ try
+ {
+ orbdprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
}
}
diff --git a/tools/gnu/classpath/tools/orbd/Messages.java b/tools/gnu/classpath/tools/orbd/Messages.java
new file mode 100644
index 000000000..c9bb371ad
--- /dev/null
+++ b/tools/gnu/classpath/tools/orbd/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for orbd
+ 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.orbd;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.orbd.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/giop/nameservice/PersistentContext.java b/tools/gnu/classpath/tools/orbd/PersistentContext.java
index 9f0903f0a..9b4f27a3d 100644
--- a/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java
+++ b/tools/gnu/classpath/tools/orbd/PersistentContext.java
@@ -36,7 +36,7 @@
exception statement from your version. */
-package gnu.classpath.tools.giop.nameservice;
+package gnu.classpath.tools.orbd;
import gnu.CORBA.NamingService.NameTransformer;
import gnu.CORBA.NamingService.TransientContext;
diff --git a/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java b/tools/gnu/classpath/tools/orbd/PersistentContextMap.java
index ce0188cf2..e983ef30f 100644
--- a/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java
+++ b/tools/gnu/classpath/tools/orbd/PersistentContextMap.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath.tools.giop.nameservice;
+package gnu.classpath.tools.orbd;
import java.io.File;
diff --git a/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java b/tools/gnu/classpath/tools/orbd/PersistentMap.java
index 6939ede17..6c6164d21 100644
--- a/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java
+++ b/tools/gnu/classpath/tools/orbd/PersistentMap.java
@@ -36,7 +36,7 @@
exception statement from your version. */
-package gnu.classpath.tools.giop.nameservice;
+package gnu.classpath.tools.orbd;
import gnu.CORBA.NamingService.NamingMap;
diff --git a/tools/gnu/classpath/tools/rmi/REGISTRY.txt b/tools/gnu/classpath/tools/rmi/REGISTRY.txt
deleted file mode 100644
index 7d8e19232..000000000
--- a/tools/gnu/classpath/tools/rmi/REGISTRY.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-The persistent RMI naming service, required for the remote method invocations
-(packages java.rmi.*, java.rmi.Registry.*).
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: rmiregistry <options>
-
- where <options> includes:
- -port N Start the registry on the given local port. If this key
- is not specified, the service starts on the port 1099.
- -verbose Log binding events to stdout.
- -stop Stop the running naming service at the given port.
-
- -transient Start transient registry service that does not write any
- data to the disk. Such service looses the stored bindings if
- restarted. If this key is not specified, the
- persistent naming service is started.
- -restart "Cold start:, clear the persistent naming database, if any.
- -folder Folder Store the persistent binding file in the given folder. If this
- key is not specified, the file with persistent bindings is
- stored into the current folder.
-
-
-
diff --git a/tools/gnu/classpath/tools/rmi/RMIC.java b/tools/gnu/classpath/tools/rmi/RMIC.java
deleted file mode 100644
index fa4d87c17..000000000
--- a/tools/gnu/classpath/tools/rmi/RMIC.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/* RMIC.java -- RMI stub generator.
- 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.
-*/
-
-
-package gnu.classpath.tools.rmi;
-
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.giop.GRMIC;
-import gnu.classpath.tools.rmi.rmic.RmicCompiler;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class RMIC
-{
- /**
- * The version of the compiler.
- */
- public static String VERSION = "0.01 alpha pre";
-
- /**
- * The GRMIC compiler methods
- *
- * @param args the compiler parameters.
- */
- public static void main(String[] args)
- {
- // Check for the -iiop or -giop keys. If one of these keys is present,
- // forward all call to GRMIC.
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-giop") || args[i].equals("-iiop"))
- {
- GRMIC.main(args);
- return;
- }
- }
-
- boolean noWrite = false;
- boolean verbose = false;
-
- String HelpPath = "rmi/RMIC.txt";
-
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- File output = new File(".");
-
- if (args.length == 0)
- {
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else
- {
- RmicCompiler compiler = new RmicCompiler();
-
- int cl = - 1;
-
- Options: for (int i = 0; i < args.length; i++)
- {
- String c = args[i];
- if (c.equals("-v"))
- {
- printVersion();
- System.exit(0);
- }
- else if (c.equals("-nowrite"))
- noWrite = true;
- else if (c.equals("-nowarn"))
- compiler.setWarnings(false);
- else if (c.equals("-verbose"))
- {
- verbose = true;
- compiler.setVerbose(true);
- }
- else if (c.equals("-force"))
- {
- compiler.setForce(true);
- }
- else if (c.equals("-d"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- output = new File(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.equals("-classpath"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- compiler.setClassPath(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.charAt(0) != '-')
- // No more options - start of class list.
- {
- cl = i;
- break Options;
- }
- }
-
- if (cl < 0)
- HelpPrinter.printHelpAndExit(HelpPath);
-
- if (verbose)
- System.out.println("Compiling to " + output.getAbsolutePath());
-
- // Compile classes
- Compile: for (int i = cl; i < args.length; i++)
- {
- if (args[i].charAt(0) != '-')
- {
- compiler.reset();
- Class c = compiler.loadClass(args[i]);
-
- compiler.compile(c);
- String packag = compiler.getPackageName().replace('.', '/');
- File fw = new File(output, packag);
-
- // Generate stub.
- String stub = compiler.generateStub();
- String subName = compiler.getStubName() + "_Stub.java";
-
- if (noWrite)
- continue Compile;
-
- try
- {
- fw.mkdirs();
- OutputStream out = new FileOutputStream(new File(fw,
- subName));
- out.write(stub.getBytes());
- out.close();
- }
- catch (IOException ioex)
- {
- System.err.println("Output path not accessible");
- ioex.printStackTrace();
- System.exit(1);
- }
- }
- }
- }
- }
-
- /**
- * Print the version information.
- */
- public static void printVersion()
- {
- System.out.println
- ("rmic v "+VERSION+" - RMI stub generator for java.rmi.* ");
- }
-}
diff --git a/tools/gnu/classpath/tools/rmi/RMIC.txt b/tools/gnu/classpath/tools/rmi/RMIC.txt
deleted file mode 100644
index 882cca553..000000000
--- a/tools/gnu/classpath/tools/rmi/RMIC.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-RMI stub and tie source code generator for java.rmi.*, javax.rmi.*
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: rmic <options> <class names>
-
- where <options> includes:
- -nowarn Show no warnings
- -nowrite Do not write any files (check for errors only)
- -d <folder> Place generated files into the given folder
- -classpath <path> Specifies the path, where to find the classes being
- compiled
-
- -help Print this help text
- -v Print version
- -verbose Verbose output
- -force Try to generate code even if the input classes seem not
- consistent with RMI specification.
-
- -1.2 Generate v 1.2 stubs (default)*
-
- -iiop Generate stubs and ties for the GIOP based RMI package
- extension, javax.rmi. With this key, the two additional
- keys are accepted:
- -poa Generate the Servant based ties (default)
- -impl Generate the obsoleted ObjectImpl based ties
- (for backward compatibility)
- -help Show more details on the giop stub and tie generator
- options.
- -giop Same as -iiop*
-
-
- and <class names> can include one or more non abstract classes that implement
- Remote and are accessible via current class path.
-
-* This tool generates the source code that must be compiled with java compiler.
-* The deprecated 1.1 version stubs are currently not supported (the v 1.2
- style stubs are always generated).
-* -iiop is a standard key for this tool, but it is also a registered OMG mark
- when giop is not.
-
diff --git a/tools/gnu/classpath/tools/rmi/RMID.txt b/tools/gnu/classpath/tools/rmi/RMID.txt
deleted file mode 100644
index a62613fd4..000000000
--- a/tools/gnu/classpath/tools/rmi/RMID.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-The persistent RMI activation daemon, support RMI object activation
-(package java.rmi.activation.*).
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: rmid <options>
-
- where <options> includes:
- -port N Start the service on the given local port. If this key
- is not specified, the service starts on the port 1098.
- -verbose Log registration events to stdout.
- -stop Stop the running activation service at the given port.
-
- -transient Start transient activation service that does not write any
- data to the disk. Such service looses the stored activation
- descriptors, if restarted. If this key is not specified, the
- persistent naming service is started.
- -restart "Cold start:, clear the activation descriptor database, if any.
- -folder Folder Store the persistent descriptor file in the given folder. If this
- key is not specified, the file with persistent activation
- information is stored into the current folder.
-
-All activation groups are activated on the same virtual machine, where the
-daemon is running. For security reasons, all the classes, required for
-activation, must be available in the classpath of that machine.
- \ No newline at end of file
diff --git a/tools/gnu/classpath/tools/AbstractMethodGenerator.java b/tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java
index d82284988..492566a80 100644
--- a/tools/gnu/classpath/tools/AbstractMethodGenerator.java
+++ b/tools/gnu/classpath/tools/rmic/AbstractMethodGenerator.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath.tools;
+package gnu.classpath.tools.rmic;
public interface AbstractMethodGenerator
{
diff --git a/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java b/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java
new file mode 100644
index 000000000..9c50efa8f
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java
@@ -0,0 +1,1824 @@
+/* ClassRmicCompiler.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. */
+
+package gnu.classpath.tools.rmic;
+
+import gnu.java.rmi.server.RMIHashes;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.rmi.MarshalException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.UnmarshalException;
+import java.rmi.server.Operation;
+import java.rmi.server.RemoteCall;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.server.Skeleton;
+import java.rmi.server.SkeletonMismatchException;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.Type;
+
+public class ClassRmicCompiler
+ implements RmicBackend
+{
+ private String[] args;
+ private int next;
+ private List errors = new ArrayList();
+ private boolean keep = false;
+ private boolean need11Stubs = true;
+ private boolean need12Stubs = true;
+ private boolean compile = true;
+ private boolean verbose;
+ private boolean noWrite;
+ private String destination;
+ private String classpath;
+ private ClassLoader loader;
+ private int errorCount = 0;
+
+ private Class clazz;
+ private String classname;
+ private String classInternalName;
+ private String fullclassname;
+ private MethodRef[] remotemethods;
+ private String stubname;
+ private String skelname;
+ private List mRemoteInterfaces;
+
+ /**
+ * @return true if run was successful
+ */
+ public boolean run(String[] inputFiles)
+ {
+ args = inputFiles;
+
+ if (next >= args.length)
+ return false;
+
+ for (int i = next; i < args.length; i++)
+ {
+ try
+ {
+ if (verbose)
+ System.out.println("[Processing class " + args[i] + ".class]");
+ processClass(args[i].replace(File.separatorChar, '.'));
+ }
+ catch (IOException e)
+ {
+ errors.add(e);
+ }
+ catch (RMICException e)
+ {
+ errors.add(e);
+ }
+ }
+ if (errors.size() > 0)
+ {
+ for (Iterator it = errors.iterator(); it.hasNext(); )
+ {
+ Exception ex = (Exception) it.next();
+ logError(ex);
+ }
+ }
+
+ return errorCount == 0;
+ }
+
+ private void processClass(String cls) throws IOException, RMICException
+ {
+ // reset class specific vars
+ clazz = null;
+ classname = null;
+ classInternalName = null;
+ fullclassname = null;
+ remotemethods = null;
+ stubname = null;
+ skelname = null;
+ mRemoteInterfaces = new ArrayList();
+
+ analyzeClass(cls);
+ generateStub();
+ if (need11Stubs)
+ generateSkel();
+ }
+
+ private void analyzeClass(String cname)
+ throws RMICException
+ {
+ if (verbose)
+ System.out.println("[analyze class " + cname + "]");
+ int p = cname.lastIndexOf('.');
+ if (p != -1)
+ classname = cname.substring(p + 1);
+ else
+ classname = cname;
+ fullclassname = cname;
+
+ findClass();
+ findRemoteMethods();
+ }
+
+ /**
+ * @deprecated
+ */
+ public Exception getException()
+ {
+ return errors.size() == 0 ? null : (Exception) errors.get(0);
+ }
+
+ private void findClass()
+ throws RMICException
+ {
+ ClassLoader cl = (loader == null
+ ? ClassLoader.getSystemClassLoader()
+ : loader);
+ try
+ {
+ clazz = Class.forName(fullclassname, false, cl);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RMICException
+ ("Class " + fullclassname + " not found in classpath", cnfe);
+ }
+
+ if (! Remote.class.isAssignableFrom(clazz))
+ {
+ throw new RMICException
+ ("Class " + clazz.getName()
+ + " does not implement a remote interface.");
+ }
+ }
+
+ private static Type[] typeArray(Class[] cls)
+ {
+ Type[] t = new Type[cls.length];
+ for (int i = 0; i < cls.length; i++)
+ {
+ t[i] = Type.getType(cls[i]);
+ }
+
+ return t;
+ }
+
+ private static String[] internalNameArray(Type[] t)
+ {
+ String[] s = new String[t.length];
+ for (int i = 0; i < t.length; i++)
+ {
+ s[i] = t[i].getInternalName();
+ }
+
+ return s;
+ }
+
+ private static String[] internalNameArray(Class[] c)
+ {
+ return internalNameArray(typeArray(c));
+ }
+
+ private static final String forName = "class$";
+
+ private static Object param(Method m, int argIndex)
+ {
+ List l = new ArrayList();
+ l.add(m);
+ l.add(new Integer(argIndex));
+ return l;
+ }
+
+ private static void generateClassForNamer(ClassVisitor cls)
+ {
+ MethodVisitor cv =
+ cls.visitMethod
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_SYNTHETIC, forName,
+ Type.getMethodDescriptor
+ (Type.getType(Class.class), new Type[] { Type.getType(String.class) }),
+ null, null);
+
+ Label start = new Label();
+ cv.visitLabel(start);
+ cv.visitVarInsn(Opcodes.ALOAD, 0);
+ cv.visitMethodInsn
+ (Opcodes.INVOKESTATIC,
+ Type.getInternalName(Class.class),
+ "forName",
+ Type.getMethodDescriptor
+ (Type.getType(Class.class), new Type[] { Type.getType(String.class) }));
+ cv.visitInsn(Opcodes.ARETURN);
+
+ Label handler = new Label();
+ cv.visitLabel(handler);
+ cv.visitVarInsn(Opcodes.ASTORE, 1);
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(NoClassDefFoundError.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitVarInsn(Opcodes.ALOAD, 1);
+ cv.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(ClassNotFoundException.class),
+ "getMessage",
+ Type.getMethodDescriptor(Type.getType(String.class), new Type[] {}));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(NoClassDefFoundError.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ cv.visitInsn(Opcodes.ATHROW);
+ cv.visitTryCatchBlock
+ (start, handler, handler,
+ Type.getInternalName(ClassNotFoundException.class));
+ cv.visitMaxs(-1, -1);
+ }
+
+ private void generateClassConstant(MethodVisitor cv, Class cls) {
+ if (cls.isPrimitive())
+ {
+ Class boxCls;
+ if (cls.equals(Boolean.TYPE))
+ boxCls = Boolean.class;
+ else if (cls.equals(Character.TYPE))
+ boxCls = Character.class;
+ else if (cls.equals(Byte.TYPE))
+ boxCls = Byte.class;
+ else if (cls.equals(Short.TYPE))
+ boxCls = Short.class;
+ else if (cls.equals(Integer.TYPE))
+ boxCls = Integer.class;
+ else if (cls.equals(Long.TYPE))
+ boxCls = Long.class;
+ else if (cls.equals(Float.TYPE))
+ boxCls = Float.class;
+ else if (cls.equals(Double.TYPE))
+ boxCls = Double.class;
+ else if (cls.equals(Void.TYPE))
+ boxCls = Void.class;
+ else
+ throw new IllegalArgumentException("unknown primitive type " + cls);
+
+ cv.visitFieldInsn
+ (Opcodes.GETSTATIC, Type.getInternalName(boxCls), "TYPE",
+ Type.getDescriptor(Class.class));
+ return;
+ }
+ cv.visitLdcInsn(cls.getName());
+ cv.visitMethodInsn
+ (Opcodes.INVOKESTATIC, classInternalName, forName,
+ Type.getMethodDescriptor
+ (Type.getType(Class.class),
+ new Type[] { Type.getType(String.class) }));
+ }
+
+ private void generateClassArray(MethodVisitor code, Class[] classes)
+ {
+ code.visitLdcInsn(new Integer(classes.length));
+ code.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Class.class));
+ for (int i = 0; i < classes.length; i++)
+ {
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn(new Integer(i));
+ generateClassConstant(code, classes[i]);
+ code.visitInsn(Opcodes.AASTORE);
+ }
+ }
+
+ private void fillOperationArray(MethodVisitor clinit)
+ {
+ // Operations array
+ clinit.visitLdcInsn(new Integer(remotemethods.length));
+ clinit.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Operation.class));
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+
+ StringBuffer desc = new StringBuffer();
+ desc.append(getPrettyName(m.getReturnType()) + " ");
+ desc.append(m.getName() + "(");
+
+ // signature
+ Class[] sig = m.getParameterTypes();
+ for (int j = 0; j < sig.length; j++)
+ {
+ desc.append(getPrettyName(sig[j]));
+ if (j + 1 < sig.length)
+ desc.append(", ");
+ }
+
+ // push operations array
+ clinit.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ // push array index
+ clinit.visitLdcInsn(new Integer(i));
+
+ // instantiate operation and leave a copy on the stack
+ clinit.visitTypeInsn(Opcodes.NEW, typeArg(Operation.class));
+ clinit.visitInsn(Opcodes.DUP);
+ clinit.visitLdcInsn(desc.toString());
+ clinit.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(Operation.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+
+ // store in operations array
+ clinit.visitInsn(Opcodes.AASTORE);
+ }
+ }
+
+ private void generateStaticMethodObjs(MethodVisitor clinit)
+ {
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+
+ /*
+ * $method_<i>m.getName()</i>_<i>i</i> =
+ * <i>m.getDeclaringClass()</i>.class.getMethod
+ * (m.getName(), m.getParameterType())
+ */
+ String methodVar = "$method_" + m.getName() + "_" + i;
+ generateClassConstant(clinit, m.getDeclaringClass());
+ clinit.visitLdcInsn(m.getName());
+ generateClassArray(clinit, m.getParameterTypes());
+ clinit.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(Class.class),
+ "getMethod",
+ Type.getMethodDescriptor
+ (Type.getType(Method.class),
+ new Type[] { Type.getType(String.class),
+ Type.getType(Class[].class) }));
+
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, methodVar,
+ Type.getDescriptor(Method.class));
+ }
+ }
+
+ private void generateStub()
+ throws IOException
+ {
+ stubname = fullclassname + "_Stub";
+ String stubclassname = classname + "_Stub";
+ File file = new File((destination == null ? "." : destination)
+ + File.separator
+ + stubname.replace('.', File.separatorChar)
+ + ".class");
+
+ if (verbose)
+ System.out.println("[Generating class " + stubname + "]");
+
+ final ClassWriter stub = new ClassWriter(true);
+ classInternalName = stubname.replace('.', '/');
+ final String superInternalName =
+ Type.getType(RemoteStub.class).getInternalName();
+
+ String[] remoteInternalNames =
+ internalNameArray((Class[]) mRemoteInterfaces.toArray(new Class[] {}));
+ stub.visit
+ (Opcodes.V1_2, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, classInternalName,
+ null, superInternalName, remoteInternalNames);
+
+ if (need12Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "serialVersionUID",
+ Type.LONG_TYPE.getDescriptor(), null, new Long(2L));
+ }
+
+ if (need11Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL,
+ "interfaceHash", Type.LONG_TYPE.getDescriptor(), null,
+ new Long(RMIHashes.getInterfaceHash(clazz)));
+
+ if (need12Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor(), null, null);
+ }
+
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL,
+ "operations", Type.getDescriptor(Operation[].class), null, null);
+ }
+
+ // Set of method references.
+ if (need12Stubs)
+ {
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+ String slotName = "$method_" + m.getName() + "_" + i;
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, slotName,
+ Type.getDescriptor(Method.class), null, null);
+ }
+ }
+
+ MethodVisitor clinit = stub.visitMethod
+ (Opcodes.ACC_STATIC, "<clinit>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+
+ if (need11Stubs)
+ {
+ fillOperationArray(clinit);
+ if (! need12Stubs)
+ clinit.visitInsn(Opcodes.RETURN);
+ }
+
+ if (need12Stubs)
+ {
+ // begin of try
+ Label begin = new Label();
+
+ // beginning of catch
+ Label handler = new Label();
+ clinit.visitLabel(begin);
+
+ // Initialize the methods references.
+ if (need11Stubs)
+ {
+ /*
+ * RemoteRef.class.getMethod("invoke", new Class[] {
+ * Remote.class, Method.class, Object[].class, long.class })
+ */
+ generateClassConstant(clinit, RemoteRef.class);
+ clinit.visitLdcInsn("invoke");
+ generateClassArray
+ (clinit, new Class[] { Remote.class, Method.class,
+ Object[].class, long.class });
+ clinit.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(Class.class),
+ "getMethod",
+ Type.getMethodDescriptor
+ (Type.getType(Method.class),
+ new Type[] { Type.getType(String.class),
+ Type.getType(Class[].class) }));
+
+ // useNewInvoke = true
+ clinit.visitInsn(Opcodes.ICONST_1);
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor());
+ }
+
+ generateStaticMethodObjs(clinit);
+
+ // jump past handler
+ clinit.visitInsn(Opcodes.RETURN);
+ clinit.visitLabel(handler);
+ if (need11Stubs)
+ {
+ // useNewInvoke = false
+ clinit.visitInsn(Opcodes.ICONST_0);
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor());
+ clinit.visitInsn(Opcodes.RETURN);
+ }
+ else
+ {
+ // throw NoSuchMethodError
+ clinit.visitTypeInsn(Opcodes.NEW, typeArg(NoSuchMethodError.class));
+ clinit.visitInsn(Opcodes.DUP);
+ clinit.visitLdcInsn("stub class initialization failed");
+ clinit.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(NoSuchMethodError.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class) }));
+ clinit.visitInsn(Opcodes.ATHROW);
+ }
+
+ clinit.visitTryCatchBlock
+ (begin, handler, handler,
+ Type.getInternalName(NoSuchMethodException.class));
+
+ }
+
+ clinit.visitMaxs(-1, -1);
+
+ generateClassForNamer(stub);
+
+ // Constructors
+ if (need11Stubs)
+ {
+ // no arg public constructor
+ MethodVisitor code = stub.visitMethod
+ (Opcodes.ACC_PUBLIC, "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}),
+ null, null);
+ code.visitVarInsn(Opcodes.ALOAD, 0);
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, superInternalName, "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ code.visitInsn(Opcodes.RETURN);
+
+ code.visitMaxs(-1, -1);
+ }
+
+ // public RemoteRef constructor
+ MethodVisitor constructor = stub.visitMethod
+ (Opcodes.ACC_PUBLIC, "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] {Type.getType(RemoteRef.class)}),
+ null, null);
+ constructor.visitVarInsn(Opcodes.ALOAD, 0);
+ constructor.visitVarInsn(Opcodes.ALOAD, 1);
+ constructor.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, superInternalName, "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] {Type.getType(RemoteRef.class)}));
+ constructor.visitInsn(Opcodes.RETURN);
+ constructor.visitMaxs(-1, -1);
+
+ // Method implementations
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+ Class[] sig = m.getParameterTypes();
+ Class returntype = m.getReturnType();
+ Class[] except = sortExceptions
+ ((Class[]) remotemethods[i].exceptions.toArray(new Class[0]));
+
+ MethodVisitor code = stub.visitMethod
+ (Opcodes.ACC_PUBLIC,
+ m.getName(),
+ Type.getMethodDescriptor(Type.getType(returntype), typeArray(sig)),
+ null,
+ internalNameArray(typeArray(except)));
+
+ final Variables var = new Variables();
+
+ // this and parameters are the declared vars
+ var.declare("this");
+ for (int j = 0; j < sig.length; j++)
+ var.declare(param(m, j), size(sig[j]));
+
+ Label methodTryBegin = new Label();
+ code.visitLabel(methodTryBegin);
+
+ if (need12Stubs)
+ {
+ Label oldInvoke = new Label();
+ if (need11Stubs)
+ {
+ // if not useNewInvoke jump to old invoke
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "useNewInvoke",
+ Type.getDescriptor(boolean.class));
+ code.visitJumpInsn(Opcodes.IFEQ, oldInvoke);
+ }
+
+ // this.ref
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD, Type.getInternalName(RemoteObject.class),
+ "ref", Type.getDescriptor(RemoteRef.class));
+
+ // "this" is first arg to invoke
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+
+ // method object is second arg to invoke
+ String methName = "$method_" + m.getName() + "_" + i;
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, methName,
+ Type.getDescriptor(Method.class));
+
+ // args to remote method are third arg to invoke
+ if (sig.length == 0)
+ code.visitInsn(Opcodes.ACONST_NULL);
+ else
+ {
+ // create arg Object[] (with boxed primitives) and push it
+ code.visitLdcInsn(new Integer(sig.length));
+ code.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Object.class));
+
+ var.allocate("argArray");
+ code.visitVarInsn(Opcodes.ASTORE, var.get("argArray"));
+
+ for (int j = 0; j < sig.length; j++)
+ {
+ int size = size(sig[j]);
+ int insn = loadOpcode(sig[j]);
+ Class box = sig[j].isPrimitive() ? box(sig[j]) : null;
+
+ code.visitVarInsn(Opcodes.ALOAD, var.get("argArray"));
+ code.visitLdcInsn(new Integer(j));
+
+ // put argument on stack
+ if (box != null)
+ {
+ code.visitTypeInsn(Opcodes.NEW, typeArg(box));
+ code.visitInsn(Opcodes.DUP);
+ code.visitVarInsn(insn, var.get(param(m, j)));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(box),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(sig[j]) }));
+ }
+ else
+ code.visitVarInsn(insn, var.get(param(m, j)));
+
+ code.visitInsn(Opcodes.AASTORE);
+ }
+
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("argArray"));
+ }
+
+ // push remote operation opcode
+ code.visitLdcInsn(new Long(remotemethods[i].hash));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "invoke",
+ Type.getMethodDescriptor
+ (Type.getType(Object.class),
+ new Type[] { Type.getType(Remote.class),
+ Type.getType(Method.class),
+ Type.getType(Object[].class),
+ Type.LONG_TYPE }));
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ int retcode = returnOpcode(returntype);
+ Class boxCls =
+ returntype.isPrimitive() ? box(returntype) : null;
+ code.visitTypeInsn
+ (Opcodes.CHECKCAST, typeArg(boxCls == null ? returntype : boxCls));
+ if (returntype.isPrimitive())
+ {
+ // unbox
+ code.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getType(boxCls).getInternalName(),
+ unboxMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.getType(returntype), new Type[] {}));
+ }
+
+ code.visitInsn(retcode);
+ }
+ else
+ code.visitInsn(Opcodes.RETURN);
+
+
+ if (need11Stubs)
+ code.visitLabel(oldInvoke);
+ }
+
+ if (need11Stubs)
+ {
+
+ // this.ref.newCall(this, operations, index, interfaceHash)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD,
+ Type.getInternalName(RemoteObject.class),
+ "ref",
+ Type.getDescriptor(RemoteRef.class));
+
+ // "this" is first arg to newCall
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+
+ // operations is second arg to newCall
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ // method index is third arg
+ code.visitLdcInsn(new Integer(i));
+
+ // interface hash is fourth arg
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "interfaceHash",
+ Type.LONG_TYPE.getDescriptor());
+
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "newCall",
+ Type.getMethodDescriptor
+ (Type.getType(RemoteCall.class),
+ new Type[] { Type.getType(RemoteObject.class),
+ Type.getType(Operation[].class),
+ Type.INT_TYPE,
+ Type.LONG_TYPE }));
+
+ // store call object on stack and leave copy on stack
+ var.allocate("call");
+ code.visitInsn(Opcodes.DUP);
+ code.visitVarInsn(Opcodes.ASTORE, var.get("call"));
+
+ Label beginArgumentTryBlock = new Label();
+ code.visitLabel(beginArgumentTryBlock);
+
+ // ObjectOutput out = call.getOutputStream();
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getOutputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectOutput.class), new Type[] {}));
+
+ for (int j = 0; j < sig.length; j++)
+ {
+ // dup the ObjectOutput
+ code.visitInsn(Opcodes.DUP);
+
+ // get j'th arg to remote method
+ code.visitVarInsn(loadOpcode(sig[j]), var.get(param(m, j)));
+
+ Class argCls =
+ sig[j].isPrimitive() ? sig[j] : Object.class;
+
+ // out.writeFoo
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectOutput.class),
+ writeMethod(sig[j]),
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(argCls) }));
+ }
+
+ // pop ObjectOutput
+ code.visitInsn(Opcodes.POP);
+
+ Label iohandler = new Label();
+ Label endArgumentTryBlock = new Label();
+ code.visitJumpInsn(Opcodes.GOTO, endArgumentTryBlock);
+ code.visitLabel(iohandler);
+
+ // throw new MarshalException(msg, ioexception);
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ code.visitTypeInsn(Opcodes.NEW, typeArg(MarshalException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn("error marshalling arguments");
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(MarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ code.visitLabel(endArgumentTryBlock);
+ code.visitTryCatchBlock
+ (beginArgumentTryBlock, iohandler, iohandler,
+ Type.getInternalName(IOException.class));
+
+ // this.ref.invoke(call)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD, Type.getInternalName(RemoteObject.class),
+ "ref", Type.getDescriptor(RemoteRef.class));
+ code.visitVarInsn(Opcodes.ALOAD, var.get("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "invoke",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(RemoteCall.class) }));
+
+ // handle return value
+ boolean needcastcheck = false;
+
+ Label beginReturnTryCatch = new Label();
+ code.visitLabel(beginReturnTryCatch);
+
+ int returncode = returnOpcode(returntype);
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ // call.getInputStream()
+ code.visitVarInsn(Opcodes.ALOAD, var.get("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getInputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectInput.class), new Type[] {}));
+
+ Class readCls =
+ returntype.isPrimitive() ? returntype : Object.class;
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectInput.class),
+ readMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.getType(readCls), new Type[] {}));
+
+ boolean castresult = false;
+
+ if (! returntype.isPrimitive())
+ {
+ if (! returntype.equals(Object.class))
+ castresult = true;
+ else
+ needcastcheck = true;
+ }
+
+ if (castresult)
+ code.visitTypeInsn(Opcodes.CHECKCAST, typeArg(returntype));
+
+ // leave result on stack for return
+ }
+
+ // this.ref.done(call)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD,
+ Type.getInternalName(RemoteObject.class),
+ "ref",
+ Type.getDescriptor(RemoteRef.class));
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "done",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(RemoteCall.class) }));
+
+ // return; or return result;
+ code.visitInsn(returncode);
+
+ // exception handler
+ Label handler = new Label();
+ code.visitLabel(handler);
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+
+ // throw new UnmarshalException(msg, e)
+ code.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn("error unmarshalling return");
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ Label endReturnTryCatch = new Label();
+
+ // catch IOException
+ code.visitTryCatchBlock
+ (beginReturnTryCatch, handler, handler,
+ Type.getInternalName(IOException.class));
+
+ if (needcastcheck)
+ {
+ // catch ClassNotFoundException
+ code.visitTryCatchBlock
+ (beginReturnTryCatch, handler, handler,
+ Type.getInternalName(ClassNotFoundException.class));
+ }
+ }
+
+ Label rethrowHandler = new Label();
+ code.visitLabel(rethrowHandler);
+ // rethrow declared exceptions
+ code.visitInsn(Opcodes.ATHROW);
+
+ boolean needgeneral = true;
+ for (int j = 0; j < except.length; j++)
+ {
+ if (except[j] == Exception.class)
+ needgeneral = false;
+ }
+
+ for (int j = 0; j < except.length; j++)
+ {
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, rethrowHandler,
+ Type.getInternalName(except[j]));
+ }
+
+ if (needgeneral)
+ {
+ // rethrow unchecked exceptions
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, rethrowHandler,
+ Type.getInternalName(RuntimeException.class));
+
+ Label generalHandler = new Label();
+ code.visitLabel(generalHandler);
+ String msg = "undeclared checked exception";
+
+ // throw new java.rmi.UnexpectedException(msg, e)
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ code.visitTypeInsn(Opcodes.NEW, typeArg(UnexpectedException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn(msg);
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnexpectedException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type [] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, generalHandler,
+ Type.getInternalName(Exception.class));
+ }
+
+ code.visitMaxs(-1, -1);
+ }
+
+ stub.visitEnd();
+ byte[] classData = stub.toByteArray();
+ if (!noWrite)
+ {
+ if (file.exists())
+ file.delete();
+ if (file.getParentFile() != null)
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(classData);
+ fos.flush();
+ fos.close();
+ }
+ }
+
+ private void generateSkel() throws IOException
+ {
+ skelname = fullclassname + "_Skel";
+ String skelclassname = classname + "_Skel";
+ File file = new File(destination == null ? "" : destination
+ + File.separator
+ + skelname.replace('.', File.separatorChar)
+ + ".class");
+ if (verbose)
+ System.out.println("[Generating class " + skelname + "]");
+
+ final ClassWriter skel = new ClassWriter(true);
+ classInternalName = skelname.replace('.', '/');
+ skel.visit
+ (Opcodes.V1_1, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL,
+ classInternalName, Type.getInternalName(Object.class), null,
+ new String[] { Type.getType(Skeleton.class).getInternalName() });
+
+ skel.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "interfaceHash",
+ Type.LONG_TYPE.getDescriptor(), null,
+ new Long(RMIHashes.getInterfaceHash(clazz)));
+
+ skel.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "operations",
+ Type.getDescriptor(Operation[].class), null, null);
+
+ MethodVisitor clinit = skel.visitMethod
+ (Opcodes.ACC_STATIC, "<clinit>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+
+ fillOperationArray(clinit);
+ clinit.visitInsn(Opcodes.RETURN);
+
+ clinit.visitMaxs(-1, -1);
+
+ // no arg public constructor
+ MethodVisitor init = skel.visitMethod
+ (Opcodes.ACC_PUBLIC, "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+ init.visitVarInsn(Opcodes.ALOAD, 0);
+ init.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "<init>",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ init.visitInsn(Opcodes.RETURN);
+ init.visitMaxs(-1, -1);
+
+ /*
+ * public Operation[] getOperations()
+ * returns a clone of the operations array
+ */
+ MethodVisitor getOp = skel.visitMethod
+ (Opcodes.ACC_PUBLIC, "getOperations",
+ Type.getMethodDescriptor
+ (Type.getType(Operation[].class), new Type[] {}),
+ null, null);
+ getOp.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+ getOp.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL, Type.getInternalName(Object.class),
+ "clone", Type.getMethodDescriptor(Type.getType(Object.class),
+ new Type[] {}));
+ getOp.visitTypeInsn(Opcodes.CHECKCAST, typeArg(Operation[].class));
+ getOp.visitInsn(Opcodes.ARETURN);
+ getOp.visitMaxs(-1, -1);
+
+ // public void dispatch(Remote, RemoteCall, int opnum, long hash)
+ MethodVisitor dispatch = skel.visitMethod
+ (Opcodes.ACC_PUBLIC,
+ "dispatch",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(Remote.class),
+ Type.getType(RemoteCall.class),
+ Type.INT_TYPE, Type.LONG_TYPE }), null,
+ new String[] { Type.getInternalName(Exception.class) });
+
+ Variables var = new Variables();
+ var.declare("this");
+ var.declare("remoteobj");
+ var.declare("remotecall");
+ var.declare("opnum");
+ var.declareWide("hash");
+
+ /*
+ * if opnum >= 0
+ * XXX it is unclear why there is handling of negative opnums
+ */
+ dispatch.visitVarInsn(Opcodes.ILOAD, var.get("opnum"));
+ Label nonNegativeOpnum = new Label();
+ Label opnumSet = new Label();
+ dispatch.visitJumpInsn(Opcodes.IFGE, nonNegativeOpnum);
+
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ // assign opnum if hash matches supplied hash
+ dispatch.visitVarInsn(Opcodes.LLOAD, var.get("hash"));
+ dispatch.visitLdcInsn(new Long(remotemethods[i].hash));
+ Label notIt = new Label();
+ dispatch.visitInsn(Opcodes.LCMP);
+ dispatch.visitJumpInsn(Opcodes.IFNE, notIt);
+
+ // opnum = <opnum>
+ dispatch.visitLdcInsn(new Integer(i));
+ dispatch.visitVarInsn(Opcodes.ISTORE, var.get("opnum"));
+ dispatch.visitJumpInsn(Opcodes.GOTO, opnumSet);
+ dispatch.visitLabel(notIt);
+ }
+
+ // throw new SkeletonMismatchException
+ Label mismatch = new Label();
+ dispatch.visitJumpInsn(Opcodes.GOTO, mismatch);
+
+ dispatch.visitLabel(nonNegativeOpnum);
+
+ // if opnum is already set, check that the hash matches the interface
+ dispatch.visitVarInsn(Opcodes.LLOAD, var.get("hash"));
+ dispatch.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName,
+ "interfaceHash", Type.LONG_TYPE.getDescriptor());
+ dispatch.visitInsn(Opcodes.LCMP);
+ dispatch.visitJumpInsn(Opcodes.IFEQ, opnumSet);
+
+ dispatch.visitLabel(mismatch);
+ dispatch.visitTypeInsn
+ (Opcodes.NEW, typeArg(SkeletonMismatchException.class));
+ dispatch.visitInsn(Opcodes.DUP);
+ dispatch.visitLdcInsn("interface hash mismatch");
+ dispatch.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(SkeletonMismatchException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ dispatch.visitInsn(Opcodes.ATHROW);
+
+ // opnum has been set
+ dispatch.visitLabel(opnumSet);
+
+ dispatch.visitVarInsn(Opcodes.ALOAD, var.get("remoteobj"));
+ dispatch.visitTypeInsn(Opcodes.CHECKCAST, typeArg(clazz));
+ dispatch.visitVarInsn(Opcodes.ASTORE, var.get("remoteobj"));
+
+ Label deflt = new Label();
+ Label[] methLabels = new Label[remotemethods.length];
+ for (int i = 0; i < methLabels.length; i++)
+ methLabels[i] = new Label();
+
+ // switch on opnum
+ dispatch.visitVarInsn(Opcodes.ILOAD, var.get("opnum"));
+ dispatch.visitTableSwitchInsn
+ (0, remotemethods.length - 1, deflt, methLabels);
+
+ // Method dispatch
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ dispatch.visitLabel(methLabels[i]);
+ Method m = remotemethods[i].meth;
+ generateMethodSkel(dispatch, m, var);
+ }
+
+ dispatch.visitLabel(deflt);
+ dispatch.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ dispatch.visitInsn(Opcodes.DUP);
+ dispatch.visitLdcInsn("invalid method number");
+ dispatch.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ dispatch.visitInsn(Opcodes.ATHROW);
+
+ dispatch.visitMaxs(-1, -1);
+
+ skel.visitEnd();
+ byte[] classData = skel.toByteArray();
+ if (!noWrite)
+ {
+ if (file.exists())
+ file.delete();
+ if (file.getParentFile() != null)
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(classData);
+ fos.flush();
+ fos.close();
+ }
+ }
+
+ private void generateMethodSkel(MethodVisitor cv, Method m, Variables var)
+ {
+ Class[] sig = m.getParameterTypes();
+
+ Label readArgs = new Label();
+ cv.visitLabel(readArgs);
+
+ boolean needcastcheck = false;
+
+ // ObjectInput in = call.getInputStream();
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class), "getInputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectInput.class), new Type[] {}));
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("objectinput"));
+
+ for (int i = 0; i < sig.length; i++)
+ {
+ // dup input stream
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("objectinput"));
+
+ Class readCls = sig[i].isPrimitive() ? sig[i] : Object.class;
+
+ // in.readFoo()
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectInput.class),
+ readMethod(sig[i]),
+ Type.getMethodDescriptor
+ (Type.getType(readCls), new Type [] {}));
+
+ if (! sig[i].isPrimitive() && ! sig[i].equals(Object.class))
+ {
+ needcastcheck = true;
+ cv.visitTypeInsn(Opcodes.CHECKCAST, typeArg(sig[i]));
+ }
+
+ // store arg in variable
+ cv.visitVarInsn
+ (storeOpcode(sig[i]), var.allocate(param(m, i), size(sig[i])));
+ }
+
+ var.deallocate("objectinput");
+
+ Label doCall = new Label();
+ Label closeInput = new Label();
+
+ cv.visitJumpInsn(Opcodes.JSR, closeInput);
+ cv.visitJumpInsn(Opcodes.GOTO, doCall);
+
+ // throw new UnmarshalException
+ Label handler = new Label();
+ cv.visitLabel(handler);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitLdcInsn("error unmarshalling arguments");
+ cv.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("toThrow"));
+ cv.visitJumpInsn(Opcodes.JSR, closeInput);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("toThrow"));
+ cv.visitInsn(Opcodes.ATHROW);
+
+ cv.visitTryCatchBlock
+ (readArgs, handler, handler, Type.getInternalName(IOException.class));
+ if (needcastcheck)
+ {
+ cv.visitTryCatchBlock
+ (readArgs, handler, handler,
+ Type.getInternalName(ClassCastException.class));
+ }
+
+ // finally block
+ cv.visitLabel(closeInput);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("retAddress"));
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "releaseInputStream",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ cv.visitVarInsn(Opcodes.RET, var.deallocate("retAddress"));
+ var.deallocate("toThrow");
+
+ // do the call using args stored as variables
+ cv.visitLabel(doCall);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remoteobj"));
+ for (int i = 0; i < sig.length; i++)
+ cv.visitVarInsn(loadOpcode(sig[i]), var.deallocate(param(m, i)));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL, Type.getInternalName(clazz), m.getName(),
+ Type.getMethodDescriptor(m));
+
+ Class returntype = m.getReturnType();
+ if (! returntype.equals(Void.TYPE))
+ {
+ cv.visitVarInsn
+ (storeOpcode(returntype), var.allocate("result", size(returntype)));
+ }
+
+ // write result to result stream
+ Label writeResult = new Label();
+ cv.visitLabel(writeResult);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitInsn(Opcodes.ICONST_1);
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getResultStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectOutput.class),
+ new Type[] { Type.BOOLEAN_TYPE }));
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ // out.writeFoo(result)
+ cv.visitVarInsn(loadOpcode(returntype), var.deallocate("result"));
+ Class writeCls = returntype.isPrimitive() ? returntype : Object.class;
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectOutput.class),
+ writeMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(writeCls) }));
+ }
+
+ cv.visitInsn(Opcodes.RETURN);
+
+ // throw new MarshalException
+ Label marshalHandler = new Label();
+ cv.visitLabel(marshalHandler);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(MarshalException.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitLdcInsn("error marshalling return");
+ cv.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(MarshalException.class),
+ "<init>",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ cv.visitInsn(Opcodes.ATHROW);
+ cv.visitTryCatchBlock
+ (writeResult, marshalHandler, marshalHandler,
+ Type.getInternalName(IOException.class));
+ }
+
+ private static String typeArg(Class cls)
+ {
+ if (cls.isArray())
+ return Type.getDescriptor(cls);
+
+ return Type.getInternalName(cls);
+ }
+
+ private static String readMethod(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not read void");
+
+ String method;
+ if (cls.equals(Boolean.TYPE))
+ method = "readBoolean";
+ else if (cls.equals(Byte.TYPE))
+ method = "readByte";
+ else if (cls.equals(Character.TYPE))
+ method = "readChar";
+ else if (cls.equals(Short.TYPE))
+ method = "readShort";
+ else if (cls.equals(Integer.TYPE))
+ method = "readInt";
+ else if (cls.equals(Long.TYPE))
+ method = "readLong";
+ else if (cls.equals(Float.TYPE))
+ method = "readFloat";
+ else if (cls.equals(Double.TYPE))
+ method = "readDouble";
+ else
+ method = "readObject";
+
+ return method;
+ }
+
+ private static String writeMethod(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not read void");
+
+ String method;
+ if (cls.equals(Boolean.TYPE))
+ method = "writeBoolean";
+ else if (cls.equals(Byte.TYPE))
+ method = "writeByte";
+ else if (cls.equals(Character.TYPE))
+ method = "writeChar";
+ else if (cls.equals(Short.TYPE))
+ method = "writeShort";
+ else if (cls.equals(Integer.TYPE))
+ method = "writeInt";
+ else if (cls.equals(Long.TYPE))
+ method = "writeLong";
+ else if (cls.equals(Float.TYPE))
+ method = "writeFloat";
+ else if (cls.equals(Double.TYPE))
+ method = "writeDouble";
+ else
+ method = "writeObject";
+
+ return method;
+ }
+
+ private static int returnOpcode(Class cls)
+ {
+ int returncode;
+ if (cls.equals(Boolean.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Byte.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Character.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Short.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Integer.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Long.TYPE))
+ returncode = Opcodes.LRETURN;
+ else if (cls.equals(Float.TYPE))
+ returncode = Opcodes.FRETURN;
+ else if (cls.equals(Double.TYPE))
+ returncode = Opcodes.DRETURN;
+ else if (cls.equals(Void.TYPE))
+ returncode = Opcodes.RETURN;
+ else
+ returncode = Opcodes.ARETURN;
+
+ return returncode;
+ }
+
+ private static int loadOpcode(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not load void");
+
+ int loadcode;
+ if (cls.equals(Boolean.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Byte.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Character.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Short.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Integer.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Long.TYPE))
+ loadcode = Opcodes.LLOAD;
+ else if (cls.equals(Float.TYPE))
+ loadcode = Opcodes.FLOAD;
+ else if (cls.equals(Double.TYPE))
+ loadcode = Opcodes.DLOAD;
+ else
+ loadcode = Opcodes.ALOAD;
+
+ return loadcode;
+ }
+
+ private static int storeOpcode(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not load void");
+
+ int storecode;
+ if (cls.equals(Boolean.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Byte.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Character.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Short.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Integer.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Long.TYPE))
+ storecode = Opcodes.LSTORE;
+ else if (cls.equals(Float.TYPE))
+ storecode = Opcodes.FSTORE;
+ else if (cls.equals(Double.TYPE))
+ storecode = Opcodes.DSTORE;
+ else
+ storecode = Opcodes.ASTORE;
+
+ return storecode;
+ }
+
+ private static String unboxMethod(Class primitive)
+ {
+ if (! primitive.isPrimitive())
+ throw new IllegalArgumentException("can not unbox nonprimitive");
+
+ String method;
+ if (primitive.equals(Boolean.TYPE))
+ method = "booleanValue";
+ else if (primitive.equals(Byte.TYPE))
+ method = "byteValue";
+ else if (primitive.equals(Character.TYPE))
+ method = "charValue";
+ else if (primitive.equals(Short.TYPE))
+ method = "shortValue";
+ else if (primitive.equals(Integer.TYPE))
+ method = "intValue";
+ else if (primitive.equals(Long.TYPE))
+ method = "longValue";
+ else if (primitive.equals(Float.TYPE))
+ method = "floatValue";
+ else if (primitive.equals(Double.TYPE))
+ method = "doubleValue";
+ else
+ throw new IllegalStateException("unknown primitive class " + primitive);
+
+ return method;
+ }
+
+ public static Class box(Class cls)
+ {
+ if (! cls.isPrimitive())
+ throw new IllegalArgumentException("can only box primitive");
+
+ Class box;
+ if (cls.equals(Boolean.TYPE))
+ box = Boolean.class;
+ else if (cls.equals(Byte.TYPE))
+ box = Byte.class;
+ else if (cls.equals(Character.TYPE))
+ box = Character.class;
+ else if (cls.equals(Short.TYPE))
+ box = Short.class;
+ else if (cls.equals(Integer.TYPE))
+ box = Integer.class;
+ else if (cls.equals(Long.TYPE))
+ box = Long.class;
+ else if (cls.equals(Float.TYPE))
+ box = Float.class;
+ else if (cls.equals(Double.TYPE))
+ box = Double.class;
+ else
+ throw new IllegalStateException("unknown primitive type " + cls);
+
+ return box;
+ }
+
+ private static int size(Class cls) {
+ if (cls.equals(Long.TYPE) || cls.equals(Double.TYPE))
+ return 2;
+ else
+ return 1;
+ }
+
+ /**
+ * Sort exceptions so the most general go last.
+ */
+ private Class[] sortExceptions(Class[] except)
+ {
+ for (int i = 0; i < except.length; i++)
+ {
+ for (int j = i + 1; j < except.length; j++)
+ {
+ if (except[i].isAssignableFrom(except[j]))
+ {
+ Class tmp = except[i];
+ except[i] = except[j];
+ except[j] = tmp;
+ }
+ }
+ }
+ return (except);
+ }
+
+ public void setup(boolean keep, boolean need11Stubs, boolean need12Stubs,
+ boolean iiop, boolean poa, boolean debug, boolean warnings,
+ boolean noWrite, boolean verbose, boolean force, String classpath,
+ String bootclasspath, String extdirs, String outputDirectory)
+ {
+ this.keep = keep;
+ this.need11Stubs = need11Stubs;
+ this.need12Stubs = need12Stubs;
+ this.verbose = verbose;
+ this.noWrite = noWrite;
+
+ // Set up classpath.
+ this.classpath = classpath;
+ StringTokenizer st =
+ new StringTokenizer(classpath, File.pathSeparator);
+ URL[] u = new URL[st.countTokens()];
+ for (int i = 0; i < u.length; i++)
+ {
+ String path = st.nextToken();
+ File f = new File(path);
+ try
+ {
+ u[i] = f.toURL();
+ }
+ catch (java.net.MalformedURLException mue)
+ {
+ logError("malformed classpath component " + path);
+ return;
+ }
+ }
+ loader = new URLClassLoader(u);
+
+ destination = outputDirectory;
+ }
+
+ private void findRemoteMethods()
+ throws RMICException
+ {
+ List rmeths = new ArrayList();
+ for (Class cur = clazz; cur != null; cur = cur.getSuperclass())
+ {
+ Class[] interfaces = cur.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ if (java.rmi.Remote.class.isAssignableFrom(interfaces[i]))
+ {
+ Class remoteInterface = interfaces[i];
+ if (verbose)
+ System.out.println
+ ("[implements " + remoteInterface.getName() + "]");
+
+ // check if the methods declare RemoteExceptions
+ Method[] meths = remoteInterface.getMethods();
+ for (int j = 0; j < meths.length; j++)
+ {
+ Method m = meths[j];
+ Class[] exs = m.getExceptionTypes();
+
+ boolean throwsRemote = false;
+ for (int k = 0; k < exs.length; k++)
+ {
+ if (exs[k].isAssignableFrom(RemoteException.class))
+ throwsRemote = true;
+ }
+
+ if (! throwsRemote)
+ {
+ throw new RMICException
+ ("Method " + m + " in interface " + remoteInterface
+ + " does not throw a RemoteException");
+ }
+
+ rmeths.add(m);
+ }
+
+ mRemoteInterfaces.add(remoteInterface);
+ }
+ }
+ }
+
+ // intersect exceptions for doubly inherited methods
+ boolean[] skip = new boolean[rmeths.size()];
+ for (int i = 0; i < skip.length; i++)
+ skip[i] = false;
+ List methrefs = new ArrayList();
+ for (int i = 0; i < rmeths.size(); i++)
+ {
+ if (skip[i]) continue;
+ Method current = (Method) rmeths.get(i);
+ MethodRef ref = new MethodRef(current);
+ for (int j = i+1; j < rmeths.size(); j++)
+ {
+ Method other = (Method) rmeths.get(j);
+ if (ref.isMatch(other))
+ {
+ ref.intersectExceptions(other);
+ skip[j] = true;
+ }
+ }
+ methrefs.add(ref);
+ }
+
+ // Convert into a MethodRef array and sort them
+ remotemethods = (MethodRef[])
+ methrefs.toArray(new MethodRef[methrefs.size()]);
+ Arrays.sort(remotemethods);
+ }
+
+ /**
+ * Prints an error to System.err and increases the error count.
+ */
+ private void logError(Exception theError)
+ {
+ logError(theError.getMessage());
+ if (verbose)
+ theError.printStackTrace(System.err);
+ }
+
+ /**
+ * Prints an error to System.err and increases the error count.
+ */
+ private void logError(String theError)
+ {
+ errorCount++;
+ System.err.println("error: " + theError);
+ }
+
+ private static String getPrettyName(Class cls)
+ {
+ StringBuffer str = new StringBuffer();
+ for (int count = 0;; count++)
+ {
+ if (! cls.isArray())
+ {
+ str.append(cls.getName());
+ for (; count > 0; count--)
+ str.append("[]");
+ return (str.toString());
+ }
+ cls = cls.getComponentType();
+ }
+ }
+
+ private static class MethodRef
+ implements Comparable
+ {
+ Method meth;
+ long hash;
+ List exceptions;
+ private String sig;
+
+ MethodRef(Method m) {
+ meth = m;
+ sig = Type.getMethodDescriptor(meth);
+ hash = RMIHashes.getMethodHash(m);
+ // add exceptions removing subclasses
+ exceptions = removeSubclasses(m.getExceptionTypes());
+ }
+
+ public int compareTo(Object obj) {
+ MethodRef that = (MethodRef) obj;
+ int name = this.meth.getName().compareTo(that.meth.getName());
+ if (name == 0) {
+ return this.sig.compareTo(that.sig);
+ }
+ return name;
+ }
+
+ public boolean isMatch(Method m)
+ {
+ if (!meth.getName().equals(m.getName()))
+ return false;
+
+ Class[] params1 = meth.getParameterTypes();
+ Class[] params2 = m.getParameterTypes();
+ if (params1.length != params2.length)
+ return false;
+
+ for (int i = 0; i < params1.length; i++)
+ if (!params1[i].equals(params2[i])) return false;
+
+ return true;
+ }
+
+ private static List removeSubclasses(Class[] classes)
+ {
+ List list = new ArrayList();
+ for (int i = 0; i < classes.length; i++)
+ {
+ Class candidate = classes[i];
+ boolean add = true;
+ for (int j = 0; j < classes.length; j++)
+ {
+ if (classes[j].equals(candidate))
+ continue;
+ else if (classes[j].isAssignableFrom(candidate))
+ add = false;
+ }
+ if (add) list.add(candidate);
+ }
+
+ return list;
+ }
+
+ public void intersectExceptions(Method m)
+ {
+ List incoming = removeSubclasses(m.getExceptionTypes());
+
+ List updated = new ArrayList();
+
+ for (int i = 0; i < exceptions.size(); i++)
+ {
+ Class outer = (Class) exceptions.get(i);
+ boolean addOuter = false;
+ for (int j = 0; j < incoming.size(); j++)
+ {
+ Class inner = (Class) incoming.get(j);
+
+ if (inner.equals(outer) || inner.isAssignableFrom(outer))
+ addOuter = true;
+ else if (outer.isAssignableFrom(inner))
+ updated.add(inner);
+ }
+
+ if (addOuter)
+ updated.add(outer);
+ }
+
+ exceptions = updated;
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/giop/grmic/CompilationError.java b/tools/gnu/classpath/tools/rmic/CompilationError.java
index d1fa814ee..176a09598 100644
--- a/tools/gnu/classpath/tools/giop/grmic/CompilationError.java
+++ b/tools/gnu/classpath/tools/rmic/CompilationError.java
@@ -19,7 +19,7 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
-package gnu.classpath.tools.giop.grmic;
+package gnu.classpath.tools.rmic;
/**
* This error is thrown when the target being compiled has illegal
diff --git a/tools/gnu/classpath/tools/giop/grmic/Generator.java b/tools/gnu/classpath/tools/rmic/Generator.java
index 17ab821ec..64eb2eaf6 100644
--- a/tools/gnu/classpath/tools/giop/grmic/Generator.java
+++ b/tools/gnu/classpath/tools/rmic/Generator.java
@@ -19,7 +19,7 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
-package gnu.classpath.tools.giop.grmic;
+package gnu.classpath.tools.rmic;
import java.io.BufferedReader;
import java.io.IOException;
diff --git a/tools/gnu/classpath/tools/giop/grmic/GiopIo.java b/tools/gnu/classpath/tools/rmic/GiopIo.java
index 0e0df7bc5..0d77d1a78 100644
--- a/tools/gnu/classpath/tools/giop/grmic/GiopIo.java
+++ b/tools/gnu/classpath/tools/rmic/GiopIo.java
@@ -19,7 +19,7 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
-package gnu.classpath.tools.giop.grmic;
+package gnu.classpath.tools.rmic;
import java.rmi.Remote;
@@ -44,7 +44,7 @@ public class GiopIo
* the parent generator, used to name the class
* @return the write statement.
*/
- public static String getWriteStatement(Class c, String variable, GiopRmicCompiler r)
+ public static String getWriteStatement(Class c, String variable, SourceGiopRmicCompiler r)
{
if (c.equals(boolean.class))
return "out.write_boolean(" + variable + ");";
@@ -80,7 +80,7 @@ public class GiopIo
* the parent generator, used to name the class
* @return the right side of the read statement.
*/
- public static String getReadStatement(Class c, GiopRmicCompiler r)
+ public static String getReadStatement(Class c, SourceGiopRmicCompiler r)
{
if (c.equals(boolean.class))
return "in.read_boolean();";
diff --git a/tools/gnu/classpath/tools/giop/grmic/HashFinder.java b/tools/gnu/classpath/tools/rmic/HashFinder.java
index 2efdb1e76..cf4d67f0c 100644
--- a/tools/gnu/classpath/tools/giop/grmic/HashFinder.java
+++ b/tools/gnu/classpath/tools/rmic/HashFinder.java
@@ -20,7 +20,7 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
-package gnu.classpath.tools.giop.grmic;
+package gnu.classpath.tools.rmic;
import java.util.HashSet;
diff --git a/tools/gnu/classpath/tools/rmic/Main.java b/tools/gnu/classpath/tools/rmic/Main.java
new file mode 100644
index 000000000..12d1fa20e
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/Main.java
@@ -0,0 +1,282 @@
+/* Main.java -- RMI stub generator.
+ 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.
+*/
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+/**
+ * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Main
+{
+ private boolean noWrite;
+ private boolean warnings = true;
+ private boolean verbose;
+ private boolean force;
+ private String classpath = ".";
+ private String outputDirectory = ".";
+ private boolean poa;
+ private boolean need11Stubs = false;
+ private boolean need12Stubs = true;
+ private boolean keep;
+ private boolean iiop;
+ /**
+ * Specifies whether or not JRMP mode was explicitly requested.
+ */
+ private boolean jrmp;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("rmic", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("nowarn", //$NON-NLS-1$
+ Messages.getString("Main.NoWarn")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ warnings = false;
+ }
+ });
+ parser.add(new Option("nowrite", //$NON-NLS-1$
+ Messages.getString("Main.NoWrite")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ noWrite = true;
+ }
+ });
+ parser.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ parser.add(new Option("d", //$NON-NLS-1$
+ Messages.getString("Main.DirOpt"), //$NON-NLS-1$
+ Messages.getString("Main.DirArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ outputDirectory = argument;
+ }
+ });
+ parser.add(new Option("classpath", //$NON-NLS-1$
+ Messages.getString("Main.ClasspathOpt"), //$NON-NLS-1$
+ Messages.getString("Main.ClasspathArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ classpath = argument;
+ }
+ });
+ parser.add(new Option("bootclasspath", //$NON-NLS-1$
+ Messages.getString("Main.BootclasspathOpt"), //$NON-NLS-1$
+ Messages.getString("Main.BootclasspathArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("extdirs", //$NON-NLS-1$
+ Messages.getString("Main.ExtdirsOpt"), //$NON-NLS-1$
+ Messages.getString("Main.ExtdirsArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("iiop", //$NON-NLS-1$
+ Messages.getString("Main.IIOP")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ iiop = true;
+ }
+ });
+ parser.add(new Option("always", //$NON-NLS-1$
+ Messages.getString("Main.Always")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ force = true;
+ }
+ });
+ parser.add(new Option("alwaysgenerate", //$NON-NLS-1$
+ Messages.getString("Main.AlwaysGenerate")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ force = true;
+ }
+ });
+ parser.add(new Option("nolocalstubs", //$NON-NLS-1$
+ Messages.getString("Main.NoLocalStubs")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("poa", //$NON-NLS-1$
+ Messages.getString("Main.POA")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ poa = true;
+ }
+ });
+ parser.add(new Option("keep", //$NON-NLS-1$
+ Messages.getString("Main.Keep")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ keep = true;
+ }
+ });
+ parser.add(new Option("keepgenerated", //$NON-NLS-1$
+ Messages.getString("Main.KeepGenerated")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ keep = true;
+ }
+ });
+ parser.add(new Option("v1.1", //$NON-NLS-1$
+ Messages.getString("Main.v11")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ need11Stubs = true;
+ need12Stubs = false;
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("v1.2", //$NON-NLS-1$
+ Messages.getString("Main.v12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("vcompat", //$NON-NLS-1$
+ Messages.getString("Main.vcompat")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ need11Stubs = true;
+ need12Stubs = true;
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("g", //$NON-NLS-1$
+ Messages.getString("Main.DebugInfo")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ String[] files = p.parse(args);
+
+ if (files.length == 0)
+ {
+ p.printHelp();
+ System.exit(1);
+ }
+
+ ArrayList backends = new ArrayList();
+
+ // FIXME: need an IDL RmicBackend
+ // FIXME: need a ClassGiopRmicCompiler RmicBackend
+ if (iiop)
+ {
+ backends.add(new SourceGiopRmicCompiler());
+
+ if (jrmp)
+ {
+ // Both IIOP and JRMP stubs were requested.
+ backends.add(new ClassRmicCompiler());
+ // FIXME: SourceRmicCompiler should support v1.1
+ if (keep)
+ backends.add(new SourceRmicCompiler());
+ }
+ }
+ else
+ {
+ backends.add(new ClassRmicCompiler());
+ if (keep)
+ backends.add(new SourceRmicCompiler());
+ }
+
+ for (int i = 0; i < backends.size(); i++)
+ {
+ RmicBackend b = (RmicBackend) backends.get(i);
+ b.setup(keep, need11Stubs, need12Stubs,
+ iiop, poa, false, warnings,
+ noWrite, verbose, force, classpath,
+ null, null, outputDirectory);
+ if (!b.run(files))
+ System.exit(1);
+ }
+ }
+
+ /**
+ * The RMI compiler entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmicprogram = new Main();
+ try
+ {
+ rmicprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+}
diff --git a/tools/gnu/classpath/tools/rmic/Messages.java b/tools/gnu/classpath/tools/rmic/Messages.java
new file mode 100644
index 000000000..5e67dd163
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmic
+ 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.rmic;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmic.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/giop/grmic/MethodGenerator.java b/tools/gnu/classpath/tools/rmic/MethodGenerator.java
index 80148d51a..335a0a65c 100644
--- a/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java
+++ b/tools/gnu/classpath/tools/rmic/MethodGenerator.java
@@ -19,9 +19,9 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
-package gnu.classpath.tools.giop.grmic;
+package gnu.classpath.tools.rmic;
-import gnu.classpath.tools.AbstractMethodGenerator;
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
import java.lang.reflect.Method;
import java.util.Properties;
@@ -42,7 +42,7 @@ public class MethodGenerator implements AbstractMethodGenerator
/**
* The parent code generator.
*/
- GiopRmicCompiler rmic;
+ SourceGiopRmicCompiler rmic;
/**
* The previous method in the list, null for the first element.
@@ -64,7 +64,7 @@ public class MethodGenerator implements AbstractMethodGenerator
* the Rmic generator instance, where more class - related
* information is defined.
*/
- public MethodGenerator(Method aMethod, GiopRmicCompiler aRmic)
+ public MethodGenerator(Method aMethod, SourceGiopRmicCompiler aRmic)
{
method = aMethod;
rmic = aRmic;
diff --git a/tools/gnu/classpath/tools/rmic/RMICException.java b/tools/gnu/classpath/tools/rmic/RMICException.java
new file mode 100644
index 000000000..8d6e5f766
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/RMICException.java
@@ -0,0 +1,49 @@
+/* RMICException.java --
+ 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. */
+
+package gnu.classpath.tools.rmic;
+
+/**
+ * Thrown by the underlying compiler used by RMIC when it fails to compile a file.
+ *
+ * @author Dalibor Topic <robilad@kaffe.org>
+ */
+
+public class RMICException extends Exception {
+ /**
+ * Create an exception with a message. The cause remains uninitialized.
+ *
+ * @param s the message string
+ * @see #initCause(Throwable)
+ */
+ public RMICException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message string
+ * @param cause the cause of this exception
+ */
+ public RMICException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java b/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
index 8da486571..48abb8fad 100644
--- a/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java
+++ b/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
@@ -25,9 +25,9 @@
*/
-package gnu.classpath.tools.rmi.rmic;
+package gnu.classpath.tools.rmic;
-import gnu.classpath.tools.AbstractMethodGenerator;
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
import gnu.java.rmi.server.RMIHashes;
import java.lang.reflect.Method;
@@ -50,7 +50,7 @@ public class RmiMethodGenerator
/**
* The parent code generator.
*/
- RmicCompiler rmic;
+ SourceRmicCompiler rmic;
/**
* Create the new method generator for the given method.
@@ -59,7 +59,7 @@ public class RmiMethodGenerator
* @param aRmic the Rmic generator instance, where more class - related
* information is defined.
*/
- public RmiMethodGenerator(Method aMethod, RmicCompiler aRmic)
+ public RmiMethodGenerator(Method aMethod, SourceRmicCompiler aRmic)
{
method = aMethod;
rmic = aRmic;
diff --git a/tools/gnu/classpath/tools/rmic/RmicBackend.java b/tools/gnu/classpath/tools/rmic/RmicBackend.java
new file mode 100644
index 000000000..60eb854ca
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/RmicBackend.java
@@ -0,0 +1,31 @@
+/* RmicBackend.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. */
+
+package gnu.classpath.tools.rmic;
+public interface RmicBackend
+{
+ void setup(boolean keep, boolean need11Stubs, boolean need12Stubs,
+ boolean iiop, boolean poa, boolean debug, boolean warnings,
+ boolean noWrite, boolean verbose, boolean force, String classpath,
+ String bootclasspath, String extdirs, String outputDirectory);
+
+ boolean run(String[] inputFiles);
+}
diff --git a/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java b/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
index 6d895a14c..e9b7bff0b 100644
--- a/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
+++ b/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
@@ -1,4 +1,4 @@
-/* GiopRmicCompiler -- Central GIOP-based RMI stub and tie compiler class.
+/* SourceGiopRmicCompiler -- Central GIOP-based RMI stub and tie compiler class.
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -19,11 +19,14 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
*/
-package gnu.classpath.tools.giop.grmic;
+package gnu.classpath.tools.rmic;
-import gnu.classpath.tools.AbstractMethodGenerator;
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
@@ -46,8 +49,8 @@ import java.util.TreeSet;
*
* @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
*/
-public class GiopRmicCompiler
- extends Generator implements Comparator
+public class SourceGiopRmicCompiler
+ extends Generator implements Comparator, RmicBackend
{
/** The package name. */
protected String packag;
@@ -101,6 +104,20 @@ public class GiopRmicCompiler
protected boolean warnings = true;
/**
+ * If this flag is set (false by default), the compiler does not
+ * write output files.
+ */
+ protected boolean noWrite = false;
+
+ /**
+ * If this flag is set (false by default), the compiler keeps source
+ * output files. For SourceGiopRmicCompiler this overrides
+ * -nowrite, since -nowrite doesn't apply to sources kept with
+ * -keep.
+ */
+ protected boolean keep = false;
+
+ /**
* Verbose output
*/
protected boolean verbose = false;
@@ -109,7 +126,12 @@ public class GiopRmicCompiler
* Force mode - do not check the exceptions
*/
protected boolean force = false;
-
+
+ /**
+ * The output directory for generated files.
+ */
+ protected String outputDirectory;
+
/**
* The class loader to load the class being compiled.
*/
@@ -590,4 +612,83 @@ public class GiopRmicCompiler
else
return name;
}
+
+ /**
+ * Assumes that output directory is already created.
+ */
+ protected boolean outputTie(File fw, Class c)
+ {
+ try
+ {
+ String tie = generateTie();
+ String tieName = "_" + name(c) + "_Tie.java";
+
+ OutputStream out = new FileOutputStream(new File(fw, tieName));
+ out.write(tie.getBytes());
+ out.close();
+ }
+ catch (IOException ioex)
+ {
+ System.err.println("Output path not accessible");
+ ioex.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ public void setup(boolean keep, boolean need11Stubs, boolean need12Stubs,
+ boolean iiop, boolean poa, boolean debug, boolean warnings,
+ boolean noWrite, boolean verbose, boolean force, String classpath,
+ String bootclasspath, String extdirs, String outputDirectory)
+ {
+ setWarnings(warnings);
+ setVerbose(verbose);
+ setForce(force);
+ setClassPath(classpath);
+ setPoaMode(poa);
+ this.outputDirectory = outputDirectory;
+ this.noWrite = noWrite;
+ this.keep = keep;
+ }
+
+ public boolean run(String[] inputFiles)
+ {
+ for (int i = 0; i < inputFiles.length; i++)
+ {
+ reset();
+ Class c = loadClass(inputFiles[i]);
+
+ compile(c);
+ String packag = getPackageName().replace('.', '/');
+ File fw = new File(outputDirectory, packag);
+
+ // Generate stub.
+ String stub = generateStub();
+ String subName = getStubName() + "_Stub.java";
+
+ // -keep overrides -nowrite for sources.
+ if (!noWrite || keep)
+ {
+ try
+ {
+ fw.mkdirs();
+ OutputStream out = new FileOutputStream(new File(fw,
+ subName));
+ out.write(stub.getBytes());
+ out.close();
+
+ // Generate tie
+ if (!outputTie(fw, c))
+ return false;
+ }
+ catch (IOException ioex)
+ {
+ System.err.println("Output path not accessible");
+ ioex.printStackTrace();
+ return false;
+ }
+ }
+ }
+ return true;
+ }
}
diff --git a/tools/gnu/classpath/tools/rmi/rmic/RmicCompiler.java b/tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java
index bc51aad38..3779c5d28 100644
--- a/tools/gnu/classpath/tools/rmi/rmic/RmicCompiler.java
+++ b/tools/gnu/classpath/tools/rmic/SourceRmicCompiler.java
@@ -1,4 +1,4 @@
-/* RmicCompiler.java -- RMI stub generator for java.rmi.*
+/* SourceRmicCompiler.java -- RMI stub generator for java.rmi.*
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -25,20 +25,20 @@ combination.
*/
-package gnu.classpath.tools.rmi.rmic;
+package gnu.classpath.tools.rmic;
import java.lang.reflect.Method;
+import java.io.File;
import java.util.Iterator;
-import gnu.classpath.tools.AbstractMethodGenerator;
-import gnu.classpath.tools.giop.grmic.GiopRmicCompiler;
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
/**
* RMI stub source code generator, required to support java.rmi.*
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class RmicCompiler extends GiopRmicCompiler
+public class SourceRmicCompiler extends SourceGiopRmicCompiler
{
/**
* If true, the zero size object array is declared in the stub to reduce
@@ -168,4 +168,12 @@ public class RmicCompiler extends GiopRmicCompiler
{
return name;
}
+
+ /**
+ * Override to do nothing.
+ */
+ protected boolean outputTie(File fw, Class c)
+ {
+ return true;
+ }
}
diff --git a/tools/gnu/classpath/tools/rmic/Variables.java b/tools/gnu/classpath/tools/rmic/Variables.java
new file mode 100644
index 000000000..bddf5f783
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/Variables.java
@@ -0,0 +1,137 @@
+/* Variables.java --
+ Copyright (c) 2004, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA. */
+
+package gnu.classpath.tools.rmic;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+class Variables
+{
+ private final HashSet free = new HashSet();
+ private final HashMap names = new HashMap();
+ private final HashSet wides = new HashSet();
+ private final HashSet declared = new HashSet();
+ private boolean allocated = false;
+
+ public void declare(Object name)
+ {
+ declare(name, 1);
+ }
+
+ public void declareWide(Object name)
+ {
+ declare(name, 2);
+ }
+
+ public void declare(Object name, int size)
+ {
+ if (allocated)
+ throw new IllegalStateException("cannot declare after allocating");
+ if (size != 1 && size != 2)
+ throw new IllegalArgumentException("size must be 1 or 2");
+ if (names.containsKey(name))
+ throw new IllegalStateException("already allocated " + name);
+
+ allocateNew(name, size);
+ declared.add(name);
+ }
+
+ private int allocateNew(Object name, int size)
+ {
+ // total allocation size is first unallocated slot
+ int i = free.size() + names.size() + wides.size();
+ names.put(name, new Integer(i));
+ if (size == 2) wides.add(name);
+ return i;
+ }
+
+ public int allocate(Object name)
+ {
+ return allocate(name, 1);
+ }
+
+ public int allocateWide(Object name)
+ {
+ return allocate(name, 2);
+ }
+
+ public int allocate(Object name, int size)
+ {
+ allocated = true;
+ if (size != 1 && size != 2)
+ throw new IllegalArgumentException("size must be 1 or 2");
+ if (names.containsKey(name))
+ throw new IllegalStateException("already allocated " + name);
+
+ if (size == 2)
+ {
+ // look for consecutive free slots
+ for (Iterator it = free.iterator(); it.hasNext(); )
+ {
+ Integer i = (Integer) it.next();
+ Integer next = new Integer(i.intValue() + 1);
+ if (free.contains(next))
+ {
+ free.remove(i);
+ free.remove(next);
+ wides.add(name);
+ names.put(name, i);
+ return i.intValue();
+ }
+ }
+ }
+ else if (free.size() > 0)
+ {
+ Integer i = (Integer) free.iterator().next();
+ free.remove(i);
+ names.put(name, i);
+ return i.intValue();
+ }
+
+ return allocateNew(name, size);
+ }
+
+ public int deallocate(Object name)
+ {
+ if (! names.containsKey(name))
+ throw new IllegalArgumentException("no variable " + name);
+
+ if (declared.contains(name))
+ throw new IllegalStateException(name + " can't be deallocated");
+
+ Integer i = (Integer) names.get(name);
+ names.remove(name);
+ free.add(i);
+ if (wides.remove(name))
+ free.add(new Integer(i.intValue() + 1));
+ return i.intValue();
+ }
+
+ public int get(Object name)
+ {
+ if (! names.containsKey(name))
+ throw new IllegalArgumentException("no variable " + name);
+
+ return ((Integer) names.get(name)).intValue();
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmi/rmic/WrapUnWrapper.java b/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java
index 8ee4fa5f2..c51925fa6 100644
--- a/tools/gnu/classpath/tools/rmi/rmic/WrapUnWrapper.java
+++ b/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java
@@ -20,7 +20,7 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
*/
-package gnu.classpath.tools.rmi.rmic;
+package gnu.classpath.tools.rmic;
public class WrapUnWrapper
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/ImplTie.jav b/tools/gnu/classpath/tools/rmic/templates/ImplTie.jav
index aff606b90..aff606b90 100644
--- a/tools/gnu/classpath/tools/giop/grmic/templates/ImplTie.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/ImplTie.jav
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav b/tools/gnu/classpath/tools/rmic/templates/Stub.jav
index 371e12d44..371e12d44 100644
--- a/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub.jav
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav b/tools/gnu/classpath/tools/rmic/templates/StubMethod.jav
index 17636deb6..17636deb6 100644
--- a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/StubMethod.jav
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav b/tools/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav
index 0125a02b0..0125a02b0 100644
--- a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav
diff --git a/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12.jav b/tools/gnu/classpath/tools/rmic/templates/Stub_12.jav
index 1c55a0597..1c55a0597 100644
--- a/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub_12.jav
diff --git a/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12Method.jav b/tools/gnu/classpath/tools/rmic/templates/Stub_12Method.jav
index 9aaf8f5ad..9aaf8f5ad 100644
--- a/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12Method.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub_12Method.jav
diff --git a/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12MethodVoid.jav b/tools/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav
index 860a93c84..860a93c84 100644
--- a/tools/gnu/classpath/tools/rmi/rmic/templates/Stub_12MethodVoid.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav b/tools/gnu/classpath/tools/rmic/templates/Tie.jav
index 797ae1401..797ae1401 100644
--- a/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/Tie.jav
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav b/tools/gnu/classpath/tools/rmic/templates/TieMethod.jav
index 493f0009b..493f0009b 100644
--- a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/TieMethod.jav
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav b/tools/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav
index 3db17da7c..3db17da7c 100644
--- a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav
+++ b/tools/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav
diff --git a/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl.java b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java
index dda40b06c..390117a05 100644
--- a/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl.java
+++ b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java
@@ -35,10 +35,9 @@ 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.rmi.rmid;
+package gnu.classpath.tools.rmid;
-import gnu.classpath.tools.rmi.Persistent;
-import gnu.classpath.tools.rmi.PersistentBidiHashTable;
+import gnu.classpath.tools.common.Persistent;
import gnu.java.rmi.activation.ActivationSystemTransient;
import java.io.File;
diff --git a/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl_Stub.java b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java
index 22fa10e4b..535f8ab92 100644
--- a/tools/gnu/classpath/tools/rmi/rmid/ActivationSystemImpl_Stub.java
+++ b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath.tools.rmi.rmid;
+package gnu.classpath.tools.rmid;
import java.rmi.MarshalledObject;
import java.rmi.RemoteException;
diff --git a/tools/gnu/classpath/tools/rmi/RMID.java b/tools/gnu/classpath/tools/rmid/Main.java
index 81d09671a..d601b13f1 100644
--- a/tools/gnu/classpath/tools/rmi/RMID.java
+++ b/tools/gnu/classpath/tools/rmid/Main.java
@@ -1,4 +1,4 @@
-/* RMID.java -- the RMI activation daemon.
+/* Main.java -- the RMI activation daemon.
Copyright (c) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,10 +35,15 @@ 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.rmi;
+package gnu.classpath.tools.rmid;
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.rmi.rmid.ActivationSystemImpl;
+import gnu.classpath.tools.rmid.ActivationSystemImpl;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
import gnu.java.rmi.activation.ActivationSystemTransient;
import gnu.java.rmi.server.UnicastServerRef;
@@ -57,7 +62,7 @@ import java.rmi.server.RMIServerSocketFactory;
*
* @author Audrius Meskauskas (audriusa@bioinformatics.org)
*/
-public class RMID
+public class Main
{
/**
* The RMI server socket factory.
@@ -74,55 +79,102 @@ public class RMID
*/
static String ACTIVATION_SYSTEM_NAME = "java.rmi.activation.ActivationSystem";
- /**
- * The RMI activation daemon entry point.
- */
- public static void main(String[] args)
+ // Parse parameters:
+ private boolean stop = false;
+ private String directory = ".";
+ private boolean cold = false;
+ private boolean persistent = false;
+
+ private Parser initializeParser()
{
- String HelpPath = "rmi/RMID.txt";
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- // Parse parameters:
- boolean stop = false;
- String folder = ".";
- boolean cold = false;
- boolean trans = false;
-
- for (int i = 0; i < args.length; i++)
+ Parser parser = new ClasspathToolParser("rmiregistry", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+
+ OptionGroup controlGroup
+ = new OptionGroup(Messages.getString("Main.ControlGroup")); //$NON-NLS-1$
+ controlGroup.add(new Option("port", //$NON-NLS-1$
+ Messages.getString("Main.PortOption"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
{
- String a = args[i];
- if (a.equals("-verbose"))
- ActivationSystemTransient.debug = true;
- else if (a.equals("-stop"))
- stop = true;
- else if (a.equals("-restart"))
+ public void parsed(String portArgument) throws OptionException
+ {
+ ACTIVATION_REGISTRY_PORT = Integer.parseInt(portArgument);
+ }
+ });
+ controlGroup.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
cold = true;
- else if (a.equals("-transient"))
- trans = true;
- else if (i < args.length - 1)
- {
- // The additional key parameter is possible.
- if (a.equals("-port"))
- ACTIVATION_REGISTRY_PORT = Integer.parseInt(args[++i]);
- else if (a.equals("-folder"))
- folder = args[++i];
- }
- }
+ }
+ });
+ controlGroup.add(new Option("stop", //$NON-NLS-1$
+ Messages.getString("Main.Stop")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ stop = true;
+ }
+ });
+ parser.add(controlGroup);
+
+ OptionGroup persistenceGroup
+ = new OptionGroup(Messages.getString("Main.PersistenceGroup")); //$NON-NLS-1$
+ persistenceGroup.add(new Option("persistent", //$NON-NLS-1$
+ Messages.getString("Main.Persistent")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ persistent = true;
+ }
+ });
+ persistenceGroup.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(persistenceGroup);
+
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebugGroup")); //$NON-NLS-1$
+ debuggingGroup.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString ("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ ActivationSystemTransient.debug = true;
+ }
+ });
+ parser.add(debuggingGroup);
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args);
try
{
if (!stop)
{
// Start the system.
- File dataFolder = new File(folder);
- if (!dataFolder.exists())
- dataFolder.mkdirs();
+ File dataDirectory = new File(directory);
+ if (!dataDirectory.exists())
+ dataDirectory.mkdirs();
ActivationSystem system;
- if (trans)
+ if (!persistent)
system = ActivationSystemTransient.getInstance();
else
- system = ActivationSystemImpl.getInstance(dataFolder, cold);
+ system = ActivationSystemImpl.getInstance(dataDirectory, cold);
// We must export with the specific activation id that is only
// possible when going into the gnu.java.rmi.activation.
@@ -186,4 +238,22 @@ public class RMID
e.printStackTrace();
}
}
+
+ /**
+ * The activation system entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmidprogram = new Main();
+ try
+ {
+ rmidprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
}
diff --git a/tools/gnu/classpath/tools/rmid/Messages.java b/tools/gnu/classpath/tools/rmid/Messages.java
new file mode 100644
index 000000000..4365c6de7
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmid/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmid
+ 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.rmid;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmid.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/rmi/PersistentBidiHashTable.java b/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java
index 94b5bcbee..d213373d5 100644
--- a/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java
+++ b/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java
@@ -35,9 +35,10 @@ 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.rmi;
+package gnu.classpath.tools.rmid;
-import gnu.classpath.tools.rmi.rmid.ActivationSystemImpl;
+import gnu.classpath.tools.common.Persistent;
+import gnu.classpath.tools.rmid.ActivationSystemImpl;
import gnu.java.rmi.activation.BidiTable;
import java.io.BufferedInputStream;
diff --git a/tools/gnu/classpath/tools/rmi/REGISTRY.java b/tools/gnu/classpath/tools/rmiregistry/Main.java
index 63f633f99..e5c41930d 100644
--- a/tools/gnu/classpath/tools/rmi/REGISTRY.java
+++ b/tools/gnu/classpath/tools/rmiregistry/Main.java
@@ -1,4 +1,4 @@
-/* REGISTY.java -- RMI registry starter.
+/* Main.java -- RMI registry starter.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,10 +36,15 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath.tools.rmi;
+package gnu.classpath.tools.rmiregistry;
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.rmi.registry.RegistryImpl;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.classpath.tools.rmiregistry.RegistryImpl;
import gnu.java.rmi.server.UnicastServerRef;
import java.io.File;
@@ -57,7 +62,7 @@ import java.util.Map;
*
* @author Audrius Meskauskas (audriusa@bioinformatics.org)
*/
-public class REGISTRY
+public class Main
{
/**
* The stop command.
@@ -68,58 +73,102 @@ public class REGISTRY
* If true, the registry prints registration events to console.
*/
public static boolean verbose = false;
-
+
/**
- * The RMI registry implementation entry point.
+ * Parsed parameters.
*/
- public static void main(String[] args)
+ private String directory = ".";
+ private boolean cold = false;
+ private boolean persistent = false;
+ private boolean stop = false;
+ private int port = Registry.REGISTRY_PORT;
+ private RMIServerSocketFactory ssf = null;
+
+ private Parser initializeParser()
{
- String HelpPath = "rmi/REGISTRY.txt";
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- // Parse parameters:
- String folder = ".";
- boolean cold = false;
- boolean trans = false;
- boolean stop = false;
-
- int port = Registry.REGISTRY_PORT;
- RMIServerSocketFactory ssf = null;
-
- for (int i = 0; i < args.length; i++)
+ Parser parser = new ClasspathToolParser("rmiregistry", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ OptionGroup controlGroup
+ = new OptionGroup(Messages.getString("Main.ControlGroup")); //$NON-NLS-1$
+ controlGroup.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
{
- String a = args[i];
- if (a.equals("-restart"))
+ public void parsed(String argument) throws OptionException
+ {
cold = true;
- else if (a.equals("-transient"))
- trans = true;
- else if (a.equals("-verbose"))
- verbose = true;
- else if (a.equals("-stop"))
+ }
+ });
+ controlGroup.add(new Option("stop", //$NON-NLS-1$
+ Messages.getString("Main.Stop")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
stop = true;
- else if (i < args.length - 1)
- {
- // The additional key parameter is possible.
- if (a.equals("-port"))
- port = Integer.parseInt(args[++i]);
- else if (a.equals("-folder"))
- folder = args[++i];
- }
- }
+ }
+ });
+ parser.add(controlGroup);
+
+ OptionGroup persistenceGroup
+ = new OptionGroup(Messages.getString("Main.PersistenceGroup")); //$NON-NLS-1$
+ persistenceGroup.add(new Option("persistent", //$NON-NLS-1$
+ Messages.getString("Main.Persistent")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ persistent = true;
+ }
+ });
+ persistenceGroup.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(persistenceGroup);
+
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebugGroup")); //$NON-NLS-1$
+ debuggingGroup.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString ("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ parser.add(debuggingGroup);
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args, new FileArgumentCallback()
+ {
+ public void notifyFile(String portArgument)
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
if (!stop)
{
Map table;
- if (trans)
+ if (!persistent)
table = new Hashtable();
else
{
// Start the system.
- File dataFolder = new File(folder);
- if (!dataFolder.exists())
- dataFolder.mkdirs();
+ File dataDirectory = new File(directory);
+ if (!dataDirectory.exists())
+ dataDirectory.mkdirs();
table = PersistentHashTable.createInstance(
- new File(dataFolder, "rmiregistry.data"), cold);
+ new File(dataDirectory, "rmiregistry.data"), cold);
}
RegistryImpl system = new RegistryImpl(table);
@@ -157,9 +206,27 @@ public class REGISTRY
}
catch (NotBoundException e)
{
- System.out.println("The naming service at port "+port+" is not a "+
- REGISTRY.class.getName());
+ System.out.println("The naming service at port " + port + " is not a "
+ + Main.class.getName());
}
}
}
+
+ /**
+ * The RMI registry implementation entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmiregistryprogram = new Main();
+ try
+ {
+ rmiregistryprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
}
diff --git a/tools/gnu/classpath/tools/rmiregistry/Messages.java b/tools/gnu/classpath/tools/rmiregistry/Messages.java
new file mode 100644
index 000000000..05bfcf62d
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmiregistry/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmiregistry
+ 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.rmiregistry;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmiregistry.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/rmi/PersistentHashTable.java b/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java
index 925e829ff..89d66ce4a 100644
--- a/tools/gnu/classpath/tools/rmi/PersistentHashTable.java
+++ b/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java
@@ -35,7 +35,9 @@ 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.rmi;
+package gnu.classpath.tools.rmiregistry;
+
+import gnu.classpath.tools.common.Persistent;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -127,26 +129,40 @@ public class PersistentHashTable
try
{
PersistentHashTable k2v;
+ System.out.println ("Here1");
if (file.exists())
{
+ System.out.println ("Here2");
if (coldStart)
{
+ System.out.println ("Here2.5");
file.delete();
k2v = new PersistentHashTable(file);
}
else
{
+ System.out.println ("Here3");
FileInputStream fi = new FileInputStream(file);
+ System.out.println ("Here3.1");
BufferedInputStream b = new BufferedInputStream(fi);
+ System.out.println ("Here3.2");
ObjectInputStream oin = new ObjectInputStream(b);
+ System.out.println ("Here3.3");
+ System.out.println ("Here4");
k2v = (PersistentHashTable) oin.readObject();
oin.close();
+ System.out.println ("Here5");
}
}
else
+ {
+ System.out.println ("Here6");
k2v = new PersistentHashTable(file);
+ System.out.println ("Here7");
+ }
+ System.out.println ("Here8");
k2v.ready = true;
return k2v;
}
diff --git a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java
index 90bd3a6bd..b93d3c116 100644
--- a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java
+++ b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java
@@ -36,10 +36,9 @@ 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.rmi.registry;
+package gnu.classpath.tools.rmiregistry;
-import gnu.classpath.tools.rmi.Persistent;
-import gnu.classpath.tools.rmi.REGISTRY;
+import gnu.classpath.tools.common.Persistent;
import java.rmi.AccessException;
import java.rmi.AlreadyBoundException;
@@ -85,7 +84,7 @@ public class RegistryImpl implements Registry
public void bind(String name, Remote obj) throws RemoteException,
AlreadyBoundException, AccessException
{
- if (REGISTRY.verbose)
+ if (Main.verbose)
System.out.println("Bind "+name);
if (bindings.containsKey(name))
throw new AlreadyBoundException(name);
@@ -96,7 +95,7 @@ public class RegistryImpl implements Registry
public void unbind(String name) throws RemoteException, NotBoundException,
AccessException
{
- if (name.equals(REGISTRY.STOP))
+ if (name.equals(Main.STOP))
{
if (bindings instanceof Persistent)
((Persistent) bindings).writeContent();
@@ -106,7 +105,7 @@ public class RegistryImpl implements Registry
}
else
{
- if (REGISTRY.verbose)
+ if (Main.verbose)
System.out.println("Unbind "+name);
if (!bindings.containsKey(name))
@@ -120,7 +119,7 @@ public class RegistryImpl implements Registry
public void rebind(String name, Remote obj) throws RemoteException,
AccessException
{
- if (REGISTRY.verbose)
+ if (Main.verbose)
System.out.println("Rebind "+name);
bindings.put(name, obj);
}
diff --git a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java
index 36b7d94a5..5150debd1 100644
--- a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java
+++ b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java
@@ -36,7 +36,7 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.classpath.tools.rmi.registry;
+package gnu.classpath.tools.rmiregistry;
import java.io.IOException;
import java.io.ObjectInput;
diff --git a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java
index d8cac5bfc..94d35e92f 100644
--- a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java
+++ b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java
@@ -35,7 +35,7 @@ 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.rmi.registry;
+package gnu.classpath.tools.rmiregistry;
import java.rmi.AccessException;
import java.rmi.AlreadyBoundException;
diff --git a/tools/gnu/classpath/tools/serialver/SerialVer.java b/tools/gnu/classpath/tools/serialver/SerialVer.java
index b5a12ec92..21e0a805a 100644
--- a/tools/gnu/classpath/tools/serialver/SerialVer.java
+++ b/tools/gnu/classpath/tools/serialver/SerialVer.java
@@ -21,7 +21,7 @@
package gnu.classpath.tools.serialver;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/giop/NameService.java b/tools/gnu/classpath/tools/tnameserv/Main.java
index 7e13185f2..460b78185 100644
--- a/tools/gnu/classpath/tools/giop/NameService.java
+++ b/tools/gnu/classpath/tools/tnameserv/Main.java
@@ -1,4 +1,4 @@
-/* NameService.java -- Transient GIOP naming service.
+/* Main.java -- Transient GIOP naming service.
Copyright (C) 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,10 +35,15 @@ 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.giop;
+package gnu.classpath.tools.tnameserv;
import gnu.CORBA.NamingService.NamingServiceTransient;
-import gnu.classpath.tools.HelpPrinter;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
/**
* The implementation of the transient naming service. The naming service
@@ -52,24 +57,61 @@ import gnu.classpath.tools.HelpPrinter;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class NameService
+public class Main
{
+ private int port = -1;
+ private String iorf;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("tnameserv", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("ORBInitialPort", //$NON-NLS-1$
+ Messages.getString("Main.ORBInitialPort"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ parser.add(new Option("ior", //$NON-NLS-1$
+ Messages.getString("Main.IOR"), //$NON-NLS-1$
+ Messages.getString("Main.IORFile")) //$NON-NLS-1$
+ {
+ public void parsed(String fileArgument) throws OptionException
+ {
+ iorf = fileArgument;
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args);
+ NamingServiceTransient.start(port, iorf);
+ }
+
/**
- * Start the naming service on the current host at the given port. The
- * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
- * present, specifies the port, on that the service must be started. If this
- * key is not specified, the service starts at the port 900.
- *
- * The parameter -ior FILE_NAME, if present, forces to store the ior string of
- * this naming service to the specified file.
- *
- * @param args the parameter string.
+ * The naming service entry point.
*/
public static void main(String[] args)
{
- HelpPrinter.checkHelpKey(args, "giop/NamingService.txt");
- System.out.println("Please use --help for options.");
- NamingServiceTransient.main(args);
+ Main tnameservprogram = new Main();
+ try
+ {
+ tnameservprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
}
-
}
diff --git a/tools/gnu/classpath/tools/tnameserv/Messages.java b/tools/gnu/classpath/tools/tnameserv/Messages.java
new file mode 100644
index 000000000..505397302
--- /dev/null
+++ b/tools/gnu/classpath/tools/tnameserv/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for tnameserv
+ 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.tnameserv;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.tnameserv.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/gorbd.in b/tools/gorbd.in
new file mode 100644
index 000000000..ab1a19a86
--- /dev/null
+++ b/tools/gorbd.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath orbd tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.orbd.Main "$@"
diff --git a/tools/grmic.in b/tools/grmic.in
new file mode 100644
index 000000000..2bb29a721
--- /dev/null
+++ b/tools/grmic.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmic tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip:@PATH_TO_ASM@
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.rmic.Main "$@"
diff --git a/tools/grmid.in b/tools/grmid.in
new file mode 100644
index 000000000..aa4e1432a
--- /dev/null
+++ b/tools/grmid.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmid tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.rmid.Main "$@"
diff --git a/tools/grmiregistry.in b/tools/grmiregistry.in
new file mode 100644
index 000000000..5e2798fd3
--- /dev/null
+++ b/tools/grmiregistry.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmiregistry tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.rmiregistry.Main "$@"
diff --git a/tools/gtnameserv.in b/tools/gtnameserv.in
new file mode 100644
index 000000000..c8e7484f6
--- /dev/null
+++ b/tools/gtnameserv.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath tnameserv tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.tnameserv.Main "$@"
diff --git a/vm/reference/gnu/java/net/VMPlainSocketImpl.java b/vm/reference/gnu/java/net/VMPlainSocketImpl.java
index 76be558dc..126294c7f 100644
--- a/vm/reference/gnu/java/net/VMPlainSocketImpl.java
+++ b/vm/reference/gnu/java/net/VMPlainSocketImpl.java
@@ -38,8 +38,11 @@ exception statement from your version. */
package gnu.java.net;
import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketImpl;
@@ -47,6 +50,8 @@ import java.net.SocketOptions;
import java.net.UnknownHostException;
import gnu.classpath.Configuration;
+import gnu.java.nio.VMChannel;
+import gnu.java.nio.VMChannel.State;
/**
* The VM interface for {@link gnu.java.net.PlainSocketImpl}.
@@ -56,6 +61,8 @@ import gnu.classpath.Configuration;
*/
public final class VMPlainSocketImpl
{
+ private final State nfd;
+
/**
* Static initializer to load native library.
*/
@@ -66,249 +73,333 @@ public final class VMPlainSocketImpl
System.loadLibrary("javanet");
}
}
+
+ public VMPlainSocketImpl()
+ {
+ // XXX consider adding security check here.
+ nfd = new State();
+ }
+
+ public VMPlainSocketImpl(VMChannel channel) throws IOException
+ {
+ this();
+ nfd.setChannelFD(channel.getState());
+ }
+
+ public State getState()
+ {
+ return nfd;
+ }
- /**
- * Sets the specified option on a socket to the passed in object.
- * The optionId parameter is one of the defined constants in
- * the SocketImpl interface.
- *
- * @param socket the socket object
- * @param optionId the identifier of the option
- * @param value the value to set the option to
- *
- * @throws SocketException if an error occurs
- */
- static native void setOption(PlainSocketImpl socket, int optionId, Object value)
- throws SocketException;
-
- /**
- * Returns the current setting of the specified option. The optionId
- * is one of the defined constants in this interface.
- *
- * @param socket the socket object
- * @param optionId the option identifier
- *
- * @return the current value of the option
- *
- * @throws SocketException ff an error occurs
- */
- static native Object getOption(PlainSocketImpl socket, int optionId)
+ public void setOption(int optionId, Object optionValue)
+ throws SocketException
+ {
+ int value;
+ if (optionValue instanceof Integer)
+ value = ((Integer) optionValue).intValue();
+ else if (optionValue instanceof Boolean)
+ value = ((Boolean) optionValue).booleanValue() ? 1 : 0;
+ else
+ throw new IllegalArgumentException("option value type "
+ + optionValue.getClass().getName());
+
+ try
+ {
+ setOption(nfd.getNativeFD(), optionId, value);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+
+ private static native void setOption(int fd, int id, int value)
throws SocketException;
/**
- * Creates a new socket that is not bound to any local address/port and
- * is not connected to any remote address/port.
- *
- * @param socket the socket object
- *
- * @throws IOException if something goes wrong while creating the socket
+ * Get a socket option. This implementation is only required to support
+ * socket options that are boolean values, which include:
+ *
+ * SocketOptions.IP_MULTICAST_LOOP
+ * SocketOptions.SO_BROADCAST
+ * SocketOptions.SO_KEEPALIVE
+ * SocketOptions.SO_OOBINLINE
+ * SocketOptions.TCP_NODELAY
+ *
+ * and socket options that are integer values, which include:
+ *
+ * SocketOptions.IP_TOS
+ * SocketOptions.SO_LINGER
+ * SocketOptions.SO_RCVBUF
+ * SocketOptions.SO_SNDBUF
+ * SocketOptions.SO_TIMEOUT
+ *
+ * @param optionId The option ID to fetch.
+ * @return A {@link Boolean} or {@link Integer} containing the socket
+ * option.
+ * @throws SocketException
*/
- static native void create(PlainSocketImpl socket) throws IOException;
-
+ public Object getOption(int optionId) throws SocketException
+ {
+ int value;
+ try
+ {
+ value = getOption(nfd.getNativeFD(), optionId);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+
+ switch (optionId)
+ {
+ case SocketOptions.IP_MULTICAST_LOOP:
+ case SocketOptions.SO_BROADCAST:
+ case SocketOptions.SO_KEEPALIVE:
+ case SocketOptions.SO_OOBINLINE:
+ case SocketOptions.TCP_NODELAY:
+ return Boolean.valueOf(value != 0);
+
+ case SocketOptions.IP_TOS:
+ case SocketOptions.SO_LINGER:
+ case SocketOptions.SO_RCVBUF:
+ case SocketOptions.SO_SNDBUF:
+ case SocketOptions.SO_TIMEOUT:
+ return new Integer(value);
+
+ default:
+ throw new SocketException("getting option " + optionId +
+ " not supported here");
+ }
+ }
+
+ private static native int getOption(int fd, int id) throws SocketException;
+
/**
- * Connects to the remote address and port specified as arguments.
+ * Binds this socket to the given local address and port.
*
- * @param socket the socket object
- * @param addr the remote address to connect to
- * @param port the remote port to connect to
- *
- * @throws IOException if an error occurs
+ * @param address The address to bind to; the InetAddress is either
+ * an IPv4 or IPv6 address.
+ * @throws IOException If binding fails; for example, if the port
+ * in the given InetSocketAddress is privileged, and the current
+ * process has insufficient privileges.
*/
- static native void connect(PlainSocketImpl socket, InetAddress addr,
- int port) throws IOException;
-
+ public void bind(InetSocketAddress address) throws IOException
+ {
+ InetAddress addr = address.getAddress();
+ if (addr instanceof Inet4Address)
+ {
+ bind (nfd.getNativeFD(), addr.getAddress(), address.getPort());
+ }
+ else if (addr instanceof Inet6Address)
+ bind6 (nfd.getNativeFD(), addr.getAddress(), address.getPort());
+ else
+ throw new SocketException ("unsupported address type");
+ }
+
/**
- * Binds to the specified port on the specified addr. Note that this addr
- * must represent a local IP address. **** How bind to INADDR_ANY? ****
- *
- * @param socket the socket object
- * @param addr the address to bind to
- * @param port the port number to bind to
+ * Native bind function for IPv4 addresses. The addr array must be
+ * exactly four bytes long.
+ *
+ * VMs without native support need not implement this.
*
- * @exception IOException If an error occurs
+ * @param fd The native file descriptor integer.
+ * @param addr The IPv4 address, in network byte order.
+ * @param port The port to bind to.
+ * @throws IOException
*/
- static native void bind(PlainSocketImpl socket, InetAddress addr, int port)
+ private static native void bind(int fd, byte[] addr, int port)
throws IOException;
-
+
/**
- * Starts listening for connections on a socket. The queueLen parameter
- * is how many pending connections will queue up waiting to be serviced
- * before being accepted. If the queue of pending requests exceeds this
- * number, additional connections will be refused.
- *
- * @param socket the socket object
- * @param queueLen the length of the pending connection queue
+ * Native bind function for IPv6 addresses. The addr array must be
+ * exactly sixteen bytes long.
*
- * @exception IOException if an error occurs
- */
- static native void listen(PlainSocketImpl socket, int queueLen)
- throws IOException;
-
- /**
- * Accepts a new connection on this socket.
+ * VMs without native support need not implement this.
*
- * @param socket the socket object
- * @param impl the socket object to accept this connection.
+ * @param fd The native file descriptor integer.
+ * @param addr The IPv6 address, in network byte order.
+ * @param port The port to bind to.
+ * @throws IOException
*/
- static native void accept(PlainSocketImpl socket, SocketImpl impl)
+ private static native void bind6(int fd, byte[] addr, int port)
throws IOException;
/**
- * Returns the number of bytes that the caller can read from this socket
- * without blocking.
- *
- * @param socket the socket object
- *
- * @return the number of readable bytes before blocking
- *
- * @throws IOException If an error occurs
- */
- static native int available(PlainSocketImpl socket) throws IOException;
-
- /**
- * Closes the socket. This will cause any InputStream or OutputStream
- * objects for this Socket to be closed as well.
- *
- * <p>
- * Note that if the SO_LINGER option is set on this socket, then the
- * operation could block.
- * </p>
- *
- * @param socket the socket object
+ * Listen on this socket for incoming connections.
*
- * @throws IOException if an error occurs
+ * @param backlog The backlog of connections.
+ * @throws IOException If listening fails.
+ * @see gnu.java.nio.VMChannel#accept()
*/
- static native void close(PlainSocketImpl socket) throws IOException;
-
+ public void listen(int backlog) throws IOException
+ {
+ listen(nfd.getNativeFD(), backlog);
+ }
+
/**
- * Internal method used by SocketInputStream for reading data from
- * the connection. Reads up to len bytes of data into the buffer
- * buf starting at offset bytes into the buffer.
- *
- * @param socket the socket object
+ * Native listen function. VMs without native support need not implement
+ * this.
*
- * @return the actual number of bytes read or -1 if end of stream.
- *
- * @throws IOException if an error occurs
+ * @param fd The file descriptor integer.
+ * @param backlog The listen backlog size.
+ * @throws IOException
*/
- static native int read(PlainSocketImpl socket, byte[] buf, int offset,
- int len) throws IOException;
+ private static native void listen(int fd, int backlog) throws IOException;
- /**
- * Internal method used by SocketInputStream for reading data from
- * the connection. Reads and returns one byte of data.
- *
- * @param socket the socket object
- *
- * @return read byte or -1 if end of stream.
- *
- * @throws IOException if an error occurs
- */
- static int read(PlainSocketImpl socket) throws IOException
+ public void join(InetAddress group) throws IOException
{
- byte[] buf = new byte[1];
- if (read(socket, buf, 0, 1) > 0)
- return buf[0] & 0xFF;
+ if (group instanceof Inet4Address)
+ join(nfd.getNativeFD(), group.getAddress());
+ else if (group instanceof Inet6Address)
+ join6(nfd.getNativeFD(), group.getAddress());
else
- return -1;
+ throw new IllegalArgumentException("unknown address type");
}
+
+ private static native void join(int fd, byte[] addr) throws IOException;
+
+ private static native void join6(int fd, byte[] addr) throws IOException;
+
+ public void leave(InetAddress group) throws IOException
+ {
+ if (group instanceof Inet4Address)
+ leave(nfd.getNativeFD(), group.getAddress());
+ else if (group instanceof Inet6Address)
+ leave6(nfd.getNativeFD(), group.getAddress());
+ else
+ throw new IllegalArgumentException("unknown address type");
+ }
+
+ private static native void leave(int fd, byte[] addr) throws IOException;
+
+ private static native void leave6(int fd, byte[] addr) throws IOException;
- /**
- * Internal method used by SocketOuputStream for writing data to
- * the connection. Writes up to len bytes of data from the buffer
- * <code>buf</code> starting at <cod>offset</code> bytes into the buffer.
- *
- * @param socket the socket object
- * @param buf the buffer to write to the stream
- * @param offset the start offset in the buffer
- * @param len the number of bytes to write
- *
- * @throws IOException if an error occurs
- */
- static native void write(PlainSocketImpl socket, byte[] buf, int offset,
- int len) throws IOException;
-
- /**
- * Internal method used by SocketOuputStream for writing data to
- * the connection. Writes exactly one byte to the socket.
- *
- * @param socket the socket object
- * @param data the byte to write to the socket
- *
- * @throws IOException if an error occurs
- */
- static void write(PlainSocketImpl socket, int data)
+ public void joinGroup(InetSocketAddress addr, NetworkInterface netif)
throws IOException
{
- write(socket, new byte[]{ (byte) data }, 0, 1);
+ InetAddress address = addr.getAddress();
+
+ if (address instanceof Inet4Address)
+ joinGroup(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else if (address instanceof Inet6Address)
+ joinGroup6(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else
+ throw new IllegalArgumentException("unknown address type");
}
-
- /**
- * Sets the input stream for this socket to the end of the stream. Any
- * attempts to read more bytes from the stream will return an EOF.
- *
- * @param socket the socket object
- *
- * @throws IOException if I/O errors occur
- */
- static native void shutdownInput(PlainSocketImpl socket) throws IOException;
-
- /**
- * Disables the output stream for this socket. Any attempt to write more
- * data to the socket will throw an IOException.
- *
- * @param socket the socket object
- *
- * @throws IOException if I/O errors occur
- */
- static native void shutdownOutput(PlainSocketImpl socket) throws IOException;
-
- /**
- * Connects to the remote socket address with a specified timeout.
- *
- * @param socket the socket object
- * @param address the remote address to connect to
- * @param timeout the timeout to use for this connect, 0 means infinite.
- *
- * @throws IOException if an error occurs
- */
- static synchronized void connect(PlainSocketImpl socket,
- SocketAddress address, int timeout)
+
+ private static native void joinGroup(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+ private static native void joinGroup6(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+ public void leaveGroup(InetSocketAddress addr, NetworkInterface netif)
throws IOException
{
- InetSocketAddress sockAddr = (InetSocketAddress) address;
- InetAddress addr = sockAddr.getAddress();
-
- if (addr == null)
- throw new UnknownHostException(sockAddr.getHostName());
-
- int port = sockAddr.getPort();
-
- if (timeout < 0)
- throw new IllegalArgumentException("negative timeout");
-
- Object oldTimeoutObj = null;
- try
- {
- oldTimeoutObj = getOption(socket, SocketOptions.SO_TIMEOUT);
- setOption(socket, SocketOptions.SO_TIMEOUT, new Integer(timeout));
- connect(socket, addr, port);
- }
- finally
- {
- if (oldTimeoutObj != null)
- setOption(socket, SocketOptions.SO_TIMEOUT, oldTimeoutObj);
- }
+ InetAddress address = addr.getAddress();
+ if (address instanceof Inet4Address)
+ leaveGroup(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else if (address instanceof Inet6Address)
+ leaveGroup6(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else
+ throw new IllegalArgumentException("unknown address type");
}
-
+
+ private static native void leaveGroup(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+ private static native void leaveGroup6(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+
+ public void shutdownInput() throws IOException
+ {
+ shutdownInput(nfd.getNativeFD());
+ }
+
+ private static native void shutdownInput(int native_fd) throws IOException;
+
+ public void shutdownOutput() throws IOException
+ {
+ shutdownOutput(nfd.getNativeFD());
+ }
+
+ private static native void shutdownOutput(int native_fd) throws IOException;
+
+ public void sendUrgentData(int data) throws IOException
+ {
+ sendUrgentData(nfd.getNativeFD(), data);
+ }
+
+ private static native void sendUrgentData(int natfive_fd, int data) throws IOException;
+
+ public void close() throws IOException
+ {
+ nfd.close();
+ }
+
+ // Inner classes.
+
/**
- * Send one byte of urgent data over the socket.
- *
- * @param socket the socket object
- * @param data the byte to send
+ * Our wrapper for the native file descriptor. In this implementation,
+ * it is a simple wrapper around {@link VMChannel.State}, to simplify
+ * management of the native state.
*/
- static void sendUrgendData(PlainSocketImpl socket, int data)
+ public final class State
{
- throw new InternalError ("PlainSocketImpl::sendUrgentData not implemented");
+ private VMChannel.State channelFd;
+
+ State()
+ {
+ channelFd = null;
+ }
+
+ public boolean isValid()
+ {
+ if (channelFd != null)
+ return channelFd.isValid();
+ return false;
+ }
+
+ public int getNativeFD() throws IOException
+ {
+ return channelFd.getNativeFD();
+ }
+
+ public void setChannelFD(final VMChannel.State nfd) throws IOException
+ {
+ if (this.channelFd != null && this.channelFd.isValid())
+ throw new IOException("file descriptor already initialized");
+ this.channelFd = nfd;
+ }
+
+ public void close() throws IOException
+ {
+ if (channelFd == null)
+ throw new IOException("invalid file descriptor");
+ channelFd.close();
+ }
+
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ if (isValid())
+ close();
+ }
+ finally
+ {
+ super.finalize();
+ }
+ }
}
-}
+} \ No newline at end of file
diff --git a/vm/reference/gnu/java/nio/VMChannel.java b/vm/reference/gnu/java/nio/VMChannel.java
index fdea8ff62..688a94ac4 100644
--- a/vm/reference/gnu/java/nio/VMChannel.java
+++ b/vm/reference/gnu/java/nio/VMChannel.java
@@ -39,13 +39,17 @@ exception statement from your version. */
package gnu.java.nio;
import gnu.classpath.Configuration;
-import gnu.java.net.PlainSocketImpl;
-import gnu.java.nio.PipeImpl.SinkChannelImpl;
-import gnu.java.nio.PipeImpl.SourceChannelImpl;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.classpath.jdwp.exception.NotImplementedException;
import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
/**
* Native interface to support configuring of channel to run in a non-blocking
@@ -54,33 +58,43 @@ import java.nio.ByteBuffer;
* @author Michael Barker <mike@middlesoft.co.uk>
*
*/
-public class VMChannel
+public final class VMChannel
{
- private final int fd;
-
- private VMChannel(int fd)
- {
- this.fd = fd;
- }
+ /**
+ * Our reference implementation uses an integer to store the native
+ * file descriptor. Implementations without such support
+ */
+ private final State nfd;
- public static VMChannel getVMChannel(PlainSocketImpl socket)
- {
- return new VMChannel(socket.getNativeFD());
- }
+ private Kind kind;
- public static VMChannel getVMChannel(SourceChannelImpl source)
+ public VMChannel()
{
- return new VMChannel(source.getNativeFD());
+ // XXX consider adding security check here, so only Classpath
+ // code may create instances.
+ this.nfd = new State();
+ kind = Kind.OTHER;
}
- public static VMChannel getVMChannel(SinkChannelImpl sink)
+ /**
+ * This constructor is used by the POSIX reference implementation;
+ * other virtual machines need not support it.
+ *
+ * <strong>Important:</strong> do not call this in library code that is
+ * not specific to Classpath's reference implementation.
+ *
+ * @param native_fd The native file descriptor integer.
+ * @throws IOException
+ */
+ VMChannel(final int native_fd) throws IOException
{
- return new VMChannel(sink.getNativeFD());
+ this();
+ this.nfd.setNativeFD(native_fd);
}
- public static VMChannel getVMChannel(FileChannelImpl file)
+ public State getState()
{
- return new VMChannel(file.getNativeFD());
+ return nfd;
}
static
@@ -93,81 +107,151 @@ public class VMChannel
initIDs();
}
+ public static VMChannel getStdin() throws IOException
+ {
+ return new VMChannel(stdin_fd());
+ }
+
+ public static VMChannel getStdout() throws IOException
+ {
+ return new VMChannel(stdout_fd());
+ }
+
+ public static VMChannel getStderr() throws IOException
+ {
+ return new VMChannel(stderr_fd());
+ }
+
+ private static native int stdin_fd();
+ private static native int stdout_fd();
+ private static native int stderr_fd();
+
/**
* Set the file descriptor to have the required blocking
* setting.
*
- * @param fd
- * @param blocking
+ * @param blocking The blocking flag to set.
*/
- public native void setBlocking(int fd, boolean blocking);
+ public void setBlocking(boolean blocking) throws IOException
+ {
+ setBlocking(nfd.getNativeFD(), blocking);
+ }
+
+ private static native void setBlocking(int fd, boolean blocking)
+ throws IOException;
- public void setBlocking(boolean blocking)
+ public int available() throws IOException
{
- setBlocking(fd, blocking);
+ return available(nfd.getNativeFD());
}
+ private static native int available(int native_fd) throws IOException;
/**
* Reads a byte buffer directly using the supplied file descriptor.
- * Assumes that the buffer is a DirectBuffer.
*
- * @param fd Native file descriptor to read from.
* @param dst Direct Byte Buffer to read to.
* @return Number of bytes read.
* @throws IOException If an error occurs or dst is not a direct buffers.
*/
- native int read(int fd, ByteBuffer dst)
- throws IOException;
-
public int read(ByteBuffer dst)
throws IOException
{
- return read(fd, dst);
+ return read(nfd.getNativeFD(), dst);
}
+ private static native int read(int fd, ByteBuffer dst) throws IOException;
+
+ /**
+ * Read a single byte.
+ *
+ * @return The byte read, or -1 on end of file.
+ * @throws IOException
+ */
+ public int read() throws IOException
+ {
+ return read(nfd.getNativeFD());
+ }
+
+ private static native int read(int fd) throws IOException;
+
/**
* Reads into byte buffers directly using the supplied file descriptor.
* Assumes that the buffer list contains DirectBuffers. Will perform a
* scattering read.
*
- * @param fd Native file descriptor to read from.
* @param dsts An array direct byte buffers.
* @param offset Index of the first buffer to read to.
* @param length The number of buffers to read to.
* @return Number of bytes read.
* @throws IOException If an error occurs or the dsts are not direct buffers.
*/
- native long readScattering(int fd, ByteBuffer[] dsts, int offset, int length)
- throws IOException;
-
public long readScattering(ByteBuffer[] dsts, int offset, int length)
throws IOException
{
if (offset + length > dsts.length)
throw new IndexOutOfBoundsException("offset + length > dsts.length");
+
+ return readScattering(nfd.getNativeFD(), dsts, offset, length);
+ }
+
+ private static native long readScattering(int fd, ByteBuffer[] dsts,
+ int offset, int length)
+ throws IOException;
+
+ /**
+ * Receive a datagram on this channel, returning the host address
+ * that sent the datagram.
+ *
+ * @param dst Where to store the datagram.
+ * @return The host address that sent the datagram.
+ * @throws IOException
+ */
+ public SocketAddress receive(ByteBuffer dst) throws IOException
+ {
+ if (kind != Kind.SOCK_DGRAM)
+ throw new SocketException("not a datagram socket");
+ ByteBuffer hostPort = ByteBuffer.allocateDirect(18);
+ int hostlen = receive(nfd.getNativeFD(), dst, hostPort);
+ if (hostlen == 0)
+ return null;
+ if (hostlen == 4) // IPv4
+ {
+ byte[] addr = new byte[4];
+ hostPort.get(addr);
+ int port = hostPort.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet4Address.getByAddress(addr), port);
+ }
+ if (hostlen == 16) // IPv6
+ {
+ byte[] addr = new byte[16];
+ hostPort.get(addr);
+ int port = hostPort.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet6Address.getByAddress(addr), port);
+ }
- return readScattering(fd, dsts, offset, length);
+ throw new SocketException("host address received with invalid length: "
+ + hostlen);
}
+ private static native int receive (int fd, ByteBuffer dst, ByteBuffer address)
+ throws IOException;
+
/**
* Writes from a direct byte bufer using the supplied file descriptor.
* Assumes the buffer is a DirectBuffer.
*
- * @param fd
- * @param src
+ * @param src The source buffer.
* @return Number of bytes written.
* @throws IOException
*/
- native int write(int fd, ByteBuffer src)
- throws IOException;
-
- public int write(ByteBuffer src)
- throws IOException
+ public int write(ByteBuffer src) throws IOException
{
- return write(fd, src);
+ return write(nfd.getNativeFD(), src);
}
+ private native int write(int fd, ByteBuffer src) throws IOException;
+
/**
* Writes from byte buffers directly using the supplied file descriptor.
* Assumes the that buffer list constains DirectBuffers. Will perform
@@ -180,18 +264,463 @@ public class VMChannel
* @return Number of bytes written.
* @throws IOException
*/
- native long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length)
- throws IOException;
-
public long writeGathering(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
if (offset + length > srcs.length)
throw new IndexOutOfBoundsException("offset + length > srcs.length");
- return writeGathering(fd, srcs, offset, length);
+ // A gathering write is limited to 16 buffers; when writing, ensure
+ // that we have at least one buffer with something in it in the 16
+ // buffer window starting at offset.
+ while (!srcs[offset].hasRemaining() && offset < srcs.length)
+ offset++;
+
+ // There are no buffers with anything to write.
+ if (offset == srcs.length)
+ return 0;
+
+ // If we advanced `offset' so far that we don't have `length'
+ // buffers left, reset length to only the remaining buffers.
+ if (length > srcs.length - offset)
+ length = srcs.length - offset;
+
+ return writeGathering(nfd.getNativeFD(), srcs, offset, length);
}
+ private native long writeGathering(int fd, ByteBuffer[] srcs,
+ int offset, int length)
+ throws IOException;
+
+ /**
+ * Send a datagram to the given address.
+ *
+ * @param src The source buffer.
+ * @param dst The destination address.
+ * @return The number of bytes written.
+ * @throws IOException
+ */
+ public int send(ByteBuffer src, InetSocketAddress dst)
+ throws IOException
+ {
+ InetAddress addr = dst.getAddress();
+ if (addr == null)
+ throw new NullPointerException();
+ if (addr instanceof Inet4Address)
+ return send(nfd.getNativeFD(), src, addr.getAddress(), dst.getPort());
+ else if (addr instanceof Inet6Address)
+ return send6(nfd.getNativeFD(), src, addr.getAddress(), dst.getPort());
+ else
+ throw new SocketException("unrecognized inet address type");
+ }
+
+ // Send to an IPv4 address.
+ private static native int send(int fd, ByteBuffer src, byte[] addr, int port)
+ throws IOException;
+
+ // Send to an IPv6 address.
+ private static native int send6(int fd, ByteBuffer src, byte[] addr, int port)
+ throws IOException;
+
+ /**
+ * Write a single byte.
+ *
+ * @param b The byte to write.
+ * @throws IOException
+ */
+ public void write(int b) throws IOException
+ {
+ write(nfd.getNativeFD(), b);
+ }
+
+ private static native void write(int fd, int b) throws IOException;
+
private native static void initIDs();
+ // Network (socket) specific methods.
+
+ /**
+ * Create a new socket. This method will initialize the native file
+ * descriptor state of this instance.
+ *
+ * @param stream Whether or not to create a streaming socket, or a datagram
+ * socket.
+ * @throws IOException If creating a new socket fails, or if this
+ * channel already has its native descriptor initialized.
+ */
+ public void initSocket(boolean stream) throws IOException
+ {
+ if (nfd.isValid())
+ throw new IOException("native FD already initialized");
+ if (stream)
+ kind = Kind.SOCK_STREAM;
+ else
+ kind = Kind.SOCK_DGRAM;
+ nfd.setNativeFD(socket(stream));
+ }
+
+ /**
+ * Create a new socket, returning the native file descriptor.
+ *
+ * @param stream Set to true for streaming sockets; false for datagrams.
+ * @return The native file descriptor.
+ * @throws IOException If creating the socket fails.
+ */
+ private static native int socket(boolean stream) throws IOException;
+
+ /**
+ * Connect the underlying socket file descriptor to the remote host.
+ *
+ * @param saddr The address to connect to.
+ * @param timeout The connect timeout to use for blocking connects.
+ * @return True if the connection succeeded; false if the file descriptor
+ * is in non-blocking mode and the connection did not immediately
+ * succeed.
+ * @throws IOException If an error occurs while connecting.
+ */
+ public boolean connect(InetSocketAddress saddr, int timeout)
+ throws IOException
+ {
+ InetAddress addr = saddr.getAddress();
+ if (addr instanceof Inet4Address)
+ return connect(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+ timeout);
+ if (addr instanceof Inet6Address)
+ return connect6(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+ timeout);
+ throw new IOException("unsupported internet address");
+ }
+
+ private static native boolean connect(int fd, byte[] addr, int port, int timeout)
+ throws IOException;
+
+ private static native boolean connect6(int fd, byte[] addr, int port, int timeout)
+ throws IOException;
+
+ /**
+ * Disconnect this channel, if it is a datagram socket. Disconnecting
+ * a datagram channel will disassociate it from any address, so the
+ * socket will remain open, but can send and receive datagrams from
+ * any address.
+ *
+ * @throws IOException If disconnecting this channel fails, or if this
+ * channel is not a datagram channel.
+ */
+ public void disconnect() throws IOException
+ {
+ if (kind != Kind.SOCK_DGRAM)
+ throw new IOException("can only disconnect datagram channels");
+ disconnect(nfd.getNativeFD());
+ }
+
+ private static native void disconnect(int fd) throws IOException;
+
+ public InetSocketAddress getLocalAddress() throws IOException
+ {
+ if (!nfd.isValid())
+ return null;
+ ByteBuffer name = ByteBuffer.allocateDirect(18);
+ int namelen = getsockname(nfd.getNativeFD(), name);
+ if (namelen == 0) // not bound
+ return null; // XXX return some wildcard?
+ if (namelen == 4)
+ {
+ byte[] addr = new byte[4];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet4Address.getByAddress(addr), port);
+ }
+ if (namelen == 16)
+ {
+ byte[] addr = new byte[16];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet6Address.getByAddress(addr), port);
+ }
+ throw new SocketException("invalid address length");
+ }
+
+ private static native int getsockname(int fd, ByteBuffer name)
+ throws IOException;
+
+ /**
+ * Returns the socket address of the remote peer this channel is connected
+ * to, or null if this channel is not yet connected.
+ *
+ * @return The peer address.
+ * @throws IOException
+ */
+ public InetSocketAddress getPeerAddress() throws IOException
+ {
+ if (!nfd.isValid())
+ return null;
+ ByteBuffer name = ByteBuffer.allocateDirect(18);
+ int namelen = getpeername (nfd.getNativeFD(), name);
+ if (namelen == 0) // not connected yet
+ return null;
+ if (namelen == 4) // IPv4
+ {
+ byte[] addr = new byte[4];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet4Address.getByAddress(addr), port);
+ }
+ else if (namelen == 16) // IPv6
+ {
+ byte[] addr = new byte[16];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet6Address.getByAddress(addr), port);
+ }
+ throw new SocketException("invalid address length");
+ }
+
+ /*
+ * The format here is the peer address, followed by the port number.
+ * The returned value is the length of the peer address; thus, there
+ * will be LEN + 2 valid bytes put into NAME.
+ */
+ private static native int getpeername(int fd, ByteBuffer name)
+ throws IOException;
+
+ /**
+ * Accept an incoming connection, returning a new VMChannel, or null
+ * if the channel is nonblocking and no connection is pending.
+ *
+ * @return The accepted connection, or null.
+ * @throws IOException If an IO error occurs.
+ */
+ public VMChannel accept() throws IOException
+ {
+ int new_fd = accept(nfd.getNativeFD());
+ if (new_fd == -1) // non-blocking accept had no pending connection
+ return null;
+ return new VMChannel(new_fd);
+ }
+
+ private static native int accept(int native_fd) throws IOException;
+
+ // File-specific methods.
+
+ /**
+ * Open a file at PATH, initializing the native state to operate on
+ * that open file.
+ *
+ * @param path The absolute file path.
+ * @throws IOException If the file cannot be opened, or if this
+ * channel was previously initialized.
+ */
+ public void openFile(String path, int mode) throws IOException
+ {
+ if (nfd.isValid() || nfd.isClosed())
+ throw new IOException("can't reinitialize this channel");
+ int fd = open(path, mode);
+ nfd.setNativeFD(fd);
+ kind = Kind.FILE;
+ }
+
+ private static native int open(String path, int mode) throws IOException;
+
+ public long position() throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return position(nfd.getNativeFD());
+ }
+
+ private static native long position(int fd) throws IOException;
+
+ public void seek(long pos) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ seek(nfd.getNativeFD(), pos);
+ }
+
+ private static native void seek(int fd, long pos) throws IOException;
+
+ public void truncate(long length) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ truncate(nfd.getNativeFD(), length);
+ }
+
+ private static native void truncate(int fd, long len) throws IOException;
+
+ public boolean lock(long pos, long len, boolean shared, boolean wait)
+ throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return lock(nfd.getNativeFD(), pos, len, shared, wait);
+ }
+
+ private static native boolean lock(int fd, long pos, long len,
+ boolean shared, boolean wait)
+ throws IOException;
+
+ public void unlock(long pos, long len) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ unlock(nfd.getNativeFD(), pos, len);
+ }
+
+ private static native void unlock(int fd, long pos, long len) throws IOException;
+
+ public long size() throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return size(nfd.getNativeFD());
+ }
+
+ private static native long size(int fd) throws IOException;
+
+ public MappedByteBuffer map(char mode, long position, int size)
+ throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return map(nfd.getNativeFD(), mode, position, size);
+ }
+
+ private static native MappedByteBuffer map(int fd, char mode,
+ long position, int size)
+ throws IOException;
+
+ public boolean flush(boolean metadata) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return flush(nfd.getNativeFD(), metadata);
+ }
+
+ private static native boolean flush(int fd, boolean metadata) throws IOException;
+
+ // Close.
+
+ /**
+ * Close this socket. The socket is also automatically closed when this
+ * object is finalized.
+ *
+ * @throws IOException If closing the socket fails, or if this object has
+ * no open socket.
+ */
+ public void close() throws IOException
+ {
+ nfd.close();
+ }
+
+ static native void close(int native_fd) throws IOException;
+
+ // Inner classes.
+
+ /**
+ * A wrapper for a native file descriptor integer. This tracks the state
+ * of an open file descriptor, and ensures that
+ *
+ * This class need not be fully supported by virtual machines; if a
+ * virtual machine does not use integer file descriptors, or does and
+ * wishes to hide that, then the methods of this class may be stubbed out.
+ *
+ * System-specific classes that depend on access to native file descriptor
+ * integers SHOULD declare this fact.
+ */
+ public final class State
+ {
+ private int native_fd;
+ private boolean valid;
+ private boolean closed;
+
+ State()
+ {
+ native_fd = -1;
+ valid = false;
+ closed = false;
+ }
+
+ public boolean isValid()
+ {
+ return valid;
+ }
+
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ public int getNativeFD() throws IOException
+ {
+ if (!valid)
+ throw new IOException("invalid file descriptor");
+ return native_fd;
+ }
+
+ void setNativeFD(final int native_fd) throws IOException
+ {
+ if (valid)
+ throw new IOException("file descriptor already initialized");
+ this.native_fd = native_fd;
+ valid = true;
+ }
+
+ public void close() throws IOException
+ {
+ if (!valid)
+ throw new IOException("invalid file descriptor");
+ try
+ {
+ VMChannel.close(native_fd);
+ }
+ finally
+ {
+ valid = false;
+ closed = true;
+ }
+ }
+
+ public String toString()
+ {
+ if (closed)
+ return "<<closed>>";
+ if (!valid)
+ return "<<invalid>>";
+ return String.valueOf(native_fd);
+ }
+
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ if (valid)
+ close();
+ }
+ finally
+ {
+ super.finalize();
+ }
+ }
+ }
+
+ /**
+ * An enumeration of possible kinds of channel.
+ */
+ static class Kind // XXX enum
+ {
+ /** A streaming (TCP) socket. */
+ static final Kind SOCK_STREAM = new Kind();
+
+ /** A datagram (UDP) socket. */
+ static final Kind SOCK_DGRAM = new Kind();
+
+ /** A file. */
+ static final Kind FILE = new Kind();
+
+ /** Something else; not a socket or file. */
+ static final Kind OTHER = new Kind();
+
+ private Kind() { }
+ }
}
diff --git a/vm/reference/gnu/java/nio/VMPipe.java b/vm/reference/gnu/java/nio/VMPipe.java
index 11dd2aa7b..e5257c1cf 100644
--- a/vm/reference/gnu/java/nio/VMPipe.java
+++ b/vm/reference/gnu/java/nio/VMPipe.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.java.nio;
import java.io.IOException;
-import java.nio.channels.spi.SelectorProvider;
import gnu.classpath.Configuration;
/**
@@ -58,7 +57,24 @@ final class VMPipe
System.loadLibrary ("javanio");
}
}
-
- static native void init(PipeImpl self, SelectorProvider provider)
- throws IOException;
+
+ /**
+ * Create a pipe, consisting of a readable VMChannel and a writable
+ * VMChannel. The readable channel is returned is the first element
+ * of the array, and the writable in the second.
+ *
+ * @return A pair of VMChannels; the first readable, the second
+ * writable.
+ * @throws IOException If the pipe cannot be created.
+ */
+ static VMChannel[] pipe() throws IOException
+ {
+ VMChannel[] pipe = new VMChannel[2];
+ int[] fds = pipe0();
+ pipe[0] = new VMChannel(fds[0]);
+ pipe[1] = new VMChannel(fds[1]);
+ return pipe;
+ }
+
+ private static native int[] pipe0() throws IOException;
}
diff --git a/vm/reference/java/net/VMInetAddress.java b/vm/reference/java/net/VMInetAddress.java
index 19f5d7d34..a99c216b9 100644
--- a/vm/reference/java/net/VMInetAddress.java
+++ b/vm/reference/java/net/VMInetAddress.java
@@ -84,4 +84,14 @@ class VMInetAddress implements Serializable
*/
public static native byte[][] getHostByName(String hostname)
throws UnknownHostException;
+
+ /**
+ * Return the IP address represented by a literal address.
+ * Will return null if the literal address is not valid.
+ *
+ * @param address the name of the host
+ *
+ * @return The IP address as a byte array
+ */
+ public static native byte[] aton(String address);
}
diff --git a/vm/reference/java/net/VMNetworkInterface.java b/vm/reference/java/net/VMNetworkInterface.java
index 47f803246..7a29f4ee3 100644
--- a/vm/reference/java/net/VMNetworkInterface.java
+++ b/vm/reference/java/net/VMNetworkInterface.java
@@ -40,6 +40,9 @@ package java.net;
import gnu.classpath.Configuration;
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.Set;
import java.util.Vector;
/**
@@ -54,22 +57,50 @@ import java.util.Vector;
*/
final class VMNetworkInterface
{
+ String name;
+ Set addresses;
+
+ VMNetworkInterface(String name)
+ {
+ this.name = name;
+ addresses = new HashSet();
+ }
+
static
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- System.loadLibrary("javanet");
- }
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("javanet");
+
+ initIds();
+ }
+
+ private static native void initIds();
/**
- * Returns a Vector of InetAddresses. The returned value will be
- * 'condensed', meaning that all elements with the same interface
- * name will be collapesed into one InetAddress for that name
- * containing all addresses before the returning the result to the
- * user. This means the native method can be implemented in a naive
- * way mapping each address/interface to a name even if that means
- * that the Vector contains multiple InetAddresses with the same
- * interface name.
+ * Return a list of VM network interface objects.
+ *
+ * @return The list of network interfaces.
+ * @throws SocketException
*/
- public static native Vector getInterfaces()
+ public static native VMNetworkInterface[] getVMInterfaces()
throws SocketException;
+
+ private void addAddress(ByteBuffer addr)
+ throws SocketException, UnknownHostException
+ {
+ if (addr.remaining() == 4)
+ {
+ byte[] ipv4 = new byte[4];
+ addr.get(ipv4);
+ addresses.add(Inet4Address.getByAddress(ipv4));
+ }
+ else if (addr.remaining() == 16)
+ {
+ byte[] ipv6 = new byte[16];
+ addr.get(ipv6);
+ addresses.add(Inet6Address.getByAddress(ipv6));
+ }
+ else
+ throw new SocketException("invalid interface address");
+ }
}
diff --git a/vm/reference/java/nio/channels/VMChannels.java b/vm/reference/java/nio/channels/VMChannels.java
index e58d7fbf9..c833b6eec 100644
--- a/vm/reference/java/nio/channels/VMChannels.java
+++ b/vm/reference/java/nio/channels/VMChannels.java
@@ -40,7 +40,7 @@ package java.nio.channels;
import gnu.java.nio.ChannelInputStream;
import gnu.java.nio.ChannelOutputStream;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.FileChannelImpl;
import java.io.FileInputStream;
import java.io.FileOutputStream;